summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/ui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-05-20 09:47:09 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-06-07 11:15:42 +0000
commit189d4fd8fad9e3c776873be51938cd31a42b6177 (patch)
tree6497caeff5e383937996768766ab3bb2081a40b2 /chromium/chrome/browser/ui
parent8bc75099d364490b22f43a7ce366b366c08f4164 (diff)
BASELINE: Update Chromium to 90.0.4430.221
Change-Id: Iff4d9d18d2fcf1a576f3b1f453010f744a232920 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui')
-rw-r--r--chromium/chrome/browser/ui/BUILD.gn615
-rw-r--r--chromium/chrome/browser/ui/android/appmenu/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn10
-rw-r--r--chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn44
-rw-r--r--chromium/chrome/browser/ui/android/favicon/BUILD.gn4
-rw-r--r--chromium/chrome/browser/ui/android/layouts/BUILD.gn3
-rw-r--r--chromium/chrome/browser/ui/android/layouts/glue/BUILD.gn22
-rw-r--r--chromium/chrome/browser/ui/android/native_page/BUILD.gn19
-rw-r--r--chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd348
-rw-r--r--chromium/chrome/browser/ui/android/theme/BUILD.gn39
-rw-r--r--chromium/chrome/browser/ui/android/toolbar/BUILD.gn215
-rw-r--r--chromium/chrome/browser/ui/ash/holding_space/BUILD.gn5
-rw-r--r--chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn9
-rw-r--r--chromium/chrome/browser/ui/commander/BUILD.gn21
-rw-r--r--chromium/chrome/browser/ui/messages/android/BUILD.gn8
-rw-r--r--chromium/chrome/browser/ui/views/BUILD.gn4
-rw-r--r--chromium/chrome/browser/ui/webui/DEPS4
-rw-r--r--chromium/chrome/browser/ui/webui/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/OWNERS7
-rw-r--r--chromium/chrome/browser/ui/webui/about_ui.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/about_ui_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/app_launcher_login_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc207
-rw-r--r--chromium/chrome/browser/ui/webui/app_launcher_page_ui.h28
-rw-r--r--chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.h29
-rw-r--r--chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/bluetooth_internals/BUILD.gn5
-rw-r--r--chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/browser_switch/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/browser_switch/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/browser_switch/browser_switch_ui.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_manager_localized_strings_provider.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc102
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/certificates_handler.cc60
-rw-r--r--chromium/chrome/browser/ui/webui/certificates_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/certificates_handler_unittest.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_controller_factory.cc81
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_controller_factory.h30
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc110
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc280
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_webui_navigation_browsertest.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/add_supervision/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/add_supervision/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.h6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/bluetooth_dialog_localized_strings_provider.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc108
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h55
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc68
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h16
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc54
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_installer/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/diagnostics_dialog.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/diagnostics_dialog.h35
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_browsertest.cc (renamed from chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_browsertest.cc)59
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc (renamed from chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_chromeos.cc)56
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h (renamed from chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_chromeos.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.cc127
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.h126
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.cc77
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.h68
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emoji/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emoji/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.cc91
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_handler.cc83
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_handler.h30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_picker.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_picker.h26
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.cc69
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h115
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc160
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h60
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc110
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h33
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc265
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/active_directory_login_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc13
-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.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h20
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc116
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h26
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc68
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h60
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_module.h40
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc115
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.h81
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc163
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc189
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h46
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc80
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc331
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h49
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.h11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.h58
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.h7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.cc111
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h89
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/online_login_helper.h11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc187
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.cc61
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h14
-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.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc590
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h133
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc64
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h24
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_browsertest.cc54
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.h29
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc111
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h38
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc115
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h77
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc112
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_browsertest.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_page_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h32
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc73
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_logs_message_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_ui.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/onc_import_message_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/power_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_shares_localized_strings_provider.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h2
-rw-r--r--chromium/chrome/browser/ui/webui/commander/OWNERS5
-rw-r--r--chromium/chrome/browser/ui/webui/commander/commander_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/components/components_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/components/components_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/components/components_ui.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/crashes_ui.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler_unittest.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/device_log_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/devtools_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/discards/discards_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/discards/graph_dump_impl.h34
-rw-r--r--chromium/chrome/browser/ui/webui/discards/graph_dump_impl_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.h22
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.h9
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h6
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.cc (renamed from chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc)98
-rw-r--r--chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h (renamed from chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.h)33
-rw-r--r--chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.cc (renamed from chromium/chrome/browser/ui/webui/supervised_user_internals_ui.cc)26
-rw-r--r--chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.h21
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom5
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc189
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h71
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.h6
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc77
-rw-r--r--chromium/chrome/browser/ui/webui/feedback/feedback_ui.h21
-rw-r--r--chromium/chrome/browser/ui/webui/flags/flags_ui.cc (renamed from chromium/chrome/browser/ui/webui/flags_ui.cc)37
-rw-r--r--chromium/chrome/browser/ui/webui/flags/flags_ui.h (renamed from chromium/chrome/browser/ui/webui/flags_ui.h)11
-rw-r--r--chromium/chrome/browser/ui/webui/flags/flags_ui_handler.cc (renamed from chromium/chrome/browser/ui/webui/flags_ui_handler.cc)9
-rw-r--r--chromium/chrome/browser/ui/webui/flags/flags_ui_handler.h (renamed from chromium/chrome/browser/ui/webui/flags_ui_handler.h)8
-rw-r--r--chromium/chrome/browser/ui/webui/flags/flags_ui_unittest.cc (renamed from chromium/chrome/browser/ui/webui/flags_ui_unittest.cc)2
-rw-r--r--chromium/chrome/browser/ui/webui/gcm_internals_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/help/help_utils_chromeos.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/help/test_version_updater.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/help/test_version_updater.h12
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater.h35
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_basic.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_basic.h4
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos.h13
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_mac.h4
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_mac.mm15
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_win.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_win.h3
-rw-r--r--chromium/chrome/browser/ui/webui/history/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/history/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/history/browsing_history_handler.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/history/browsing_history_handler_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/history/foreign_session_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/history/history_login_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/history/history_login_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/history/history_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/identity_internals_ui.cc40
-rw-r--r--chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.js18
-rw-r--r--chromium/chrome/browser/ui/webui/inspect_ui.cc65
-rw-r--r--chromium/chrome/browser/ui/webui/inspect_ui.h14
-rw-r--r--chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals.mojom51
-rw-r--r--chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc91
-rw-r--r--chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.h2
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/BUILD.gn11
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom101
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc316
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h79
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc834
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc71
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h40
-rw-r--r--chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.cc (renamed from chromium/chrome/browser/ui/webui/invalidations_message_handler.cc)44
-rw-r--r--chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.h (renamed from chromium/chrome/browser/ui/webui/invalidations_message_handler.h)16
-rw-r--r--chromium/chrome/browser/ui/webui/invalidations/invalidations_ui.cc (renamed from chromium/chrome/browser/ui/webui/invalidations_ui.cc)22
-rw-r--r--chromium/chrome/browser/ui/webui/invalidations/invalidations_ui.h (renamed from chromium/chrome/browser/ui/webui/invalidations_ui.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/local_state/local_state_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/managed_ui_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/management/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/management/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_a11y_browsertest.cc (renamed from chromium/chrome/browser/ui/webui/management_a11y_browsertest.cc)2
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_a11y_browsertest.h (renamed from chromium/chrome/browser/ui/webui/management_a11y_browsertest.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui.cc (renamed from chromium/chrome/browser/ui/webui/management_ui.cc)32
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui.h (renamed from chromium/chrome/browser/ui/webui/management_ui.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_browsertest.cc (renamed from chromium/chrome/browser/ui/webui/management_ui_browsertest.cc)17
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_handler.cc (renamed from chromium/chrome/browser/ui/webui/management_ui_handler.cc)120
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_handler.h (renamed from chromium/chrome/browser/ui/webui/management_ui_handler.h)28
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_handler_chromeos.cc (renamed from chromium/chrome/browser/ui/webui/management_ui_handler_chromeos.cc)2
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_handler_chromeos.h (renamed from chromium/chrome/browser/ui/webui/management_ui_handler_chromeos.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc (renamed from chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc)114
-rw-r--r--chromium/chrome/browser/ui/webui/media/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/media/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/media/media_feeds_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/media/media_history_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/memories/BUILD.gn11
-rw-r--r--chromium/chrome/browser/ui/webui/memories/OWNERS (renamed from chromium/chrome/browser/ui/webui/interventions_internals/OWNERS)4
-rw-r--r--chromium/chrome/browser/ui/webui/memories/memories.mojom37
-rw-r--r--chromium/chrome/browser/ui/webui/memories/memories_handler.cc216
-rw-r--r--chromium/chrome/browser/ui/webui/memories/memories_handler.h72
-rw-r--r--chromium/chrome/browser/ui/webui/memories/memories_ui.cc59
-rw-r--r--chromium/chrome/browser/ui/webui/memories/memories_ui.h42
-rw-r--r--chromium/chrome/browser/ui/webui/nacl_ui.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_logs_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.cc52
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn5
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share.mojom117
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.cc40
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.h2
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom39
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom6
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/shared_resources.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/net_export_ui.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc92
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h2
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/foo/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/foo/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom91
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc473
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h65
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc147
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h34
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.h6
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc107
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h25
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/cookie_controls_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc257
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h10
-rw-r--r--chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/offline/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/offline/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/plural_string_handler.cc64
-rw-r--r--chromium/chrome/browser/ui/webui/plural_string_handler.h18
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui.cc (renamed from chromium/chrome/browser/ui/webui/policy_ui.cc)9
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui.h (renamed from chromium/chrome/browser/ui/webui/policy_ui.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc (renamed from chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc)31
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui_handler.cc (renamed from chromium/chrome/browser/ui/webui/policy_ui_handler.cc)121
-rw-r--r--chromium/chrome/browser/ui/webui/policy/policy_ui_handler.h (renamed from chromium/chrome/browser/ui/webui/policy_ui_handler.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/predictors/predictors_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/DEPS5
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc76
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc201
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc89
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default_unittest.cc232
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_win_unittest.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc255
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h61
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.cc379
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.h125
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos_unittest.cc212
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_metrics.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc562
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h90
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_utils.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/printer_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/profile_helper.cc45
-rw-r--r--chromium/chrome/browser/ui/webui/profile_info_watcher.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/profile_info_watcher.h4
-rw-r--r--chromium/chrome/browser/ui/webui/quota_internals/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/quota_internals/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/quota_internals/quota_internals_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later.mojom7
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.cc88
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_page_handler_unittest.cc61
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_ui.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_ui.h3
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/BUILD.gn16
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/OWNERS6
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/realbox.mojom79
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc335
-rw-r--r--chromium/chrome/browser/ui/webui/realbox/realbox_handler.h88
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/BUILD.gn1
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/sandbox/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/sandbox/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/sessions/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/sessions/session_service_internals_ui.cc100
-rw-r--r--chromium/chrome/browser/ui/webui/sessions/session_service_internals_ui.h21
-rw-r--r--chromium/chrome/browser/ui/webui/settings/DEPS3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.cc72
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.h16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/appearance_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/appearance_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/captions_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/captions_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.h12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win_unittest.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/DEPS1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc152
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler_unittest.cc123
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.cc38
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/app_management/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/app_management/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc92
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/BUILD.gn3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom31
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc130
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h26
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc81
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.h1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.cc40
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h40
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler_unittest.cc83
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc102
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler_unittest.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc7
-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.cc147
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h67
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc47
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.cc35
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/main_section.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h27
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc104
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/on_startup_section.cc98
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/on_startup_section.h38
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_unittest.cc43
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/parental_controls_handler.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc348
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.cc90
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.h48
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc64
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc128
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h31
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc275
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.h14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/quick_unlock_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/BUILD.gn3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc70
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h37
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc38
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h26
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry_unittest.cc45
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search_section.h1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker_unittest.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.cc211
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.h53
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/tts_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h20
-rw-r--r--chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/downloads_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/downloads_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/font_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/font_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/import_data_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/import_data_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/languages_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/languages_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc62
-rw-r--r--chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler_unittest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/native_certificates_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/on_startup_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/on_startup_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.cc292
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.h39
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc277
-rw-r--r--chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc47
-rw-r--r--chromium/chrome/browser/ui/webui/settings/profile_info_handler.h23
-rw-r--r--chromium/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/recent_site_settings_helper_unittest.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/settings/reset_settings_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc139
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler.h31
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc136
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc353
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h108
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler_unittest.cc481
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc373
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler_browsertest.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc174
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h49
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_security_key_handler_unittest.cc144
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_ui.cc109
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_ui.h25
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_utils.cc (renamed from chromium/chrome/browser/ui/webui/settings_utils.cc)10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_utils.h (renamed from chromium/chrome/browser/ui/webui/settings_utils.h)10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_utils_linux.cc (renamed from chromium/chrome/browser/ui/webui/settings_utils_linux.cc)5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_utils_mac.mm (renamed from chromium/chrome/browser/ui/webui/settings_utils_mac.mm)25
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_utils_unittest.cc (renamed from chromium/chrome/browser/ui/webui/settings_utils_unittest.cc)2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_utils_win.cc (renamed from chromium/chrome/browser/ui/webui/settings_utils_win.cc)16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.cc62
-rw-r--r--chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc87
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.h24
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_helper.h9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_helper_unittest.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/system_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/signin/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/OWNERS5
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc53
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h39
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h11
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc261
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc135
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h16
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.h7
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.cc175
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h83
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_browsertest.cc74
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_onboarding.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc191
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h7
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc112
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc119
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service.h10
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_customization_handler.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_customization_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_customization_ui.cc40
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc310
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h32
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_handler_unittest.cc222
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc52
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc290
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h137
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc205
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_email_confirmation_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_error_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_error_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_error_ui.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_error_ui.h2
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc101
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h81
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_reauth_ui.cc38
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_ui_error.cc88
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_ui_error.h62
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.h16
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc197
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.h15
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc869
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h122
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_ui.cc105
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_ui.h38
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc237
-rw-r--r--chromium/chrome/browser/ui/webui/supervised_user_internals_ui.h21
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_browsertest.js (renamed from chromium/chrome/browser/ui/webui/sync_internals_browsertest.js)27
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc (renamed from chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc)6
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h (renamed from chromium/chrome/browser/ui/webui/sync_internals_message_handler.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler_unittest.cc (renamed from chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc)2
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_ui.cc (renamed from chromium/chrome/browser/ui/webui/sync_internals_ui.cc)6
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals/sync_internals_ui.h (renamed from chromium/chrome/browser/ui/webui/sync_internals_ui.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/system_info_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search.mojom32
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.cc89
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler_unittest.cc53
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.h4
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_browsertest.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.h2
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_browsertest.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler.cc174
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler_unittest.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_util.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker_unittest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/test_data_source.cc35
-rw-r--r--chromium/chrome/browser/ui/webui/test_data_source.h4
-rw-r--r--chromium/chrome/browser/ui/webui/test_files_request_filter.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/theme_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/theme_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc35
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h15
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/usb_internals/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/usb_internals/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/util/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/util/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler.cc (renamed from chromium/chrome/browser/ui/webui/version_handler.cc)5
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler.h (renamed from chromium/chrome/browser/ui/webui/version_handler.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler_chromeos.cc (renamed from chromium/chrome/browser/ui/webui/version_handler_chromeos.cc)2
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler_chromeos.h (renamed from chromium/chrome/browser/ui/webui/version_handler_chromeos.h)8
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler_win.cc (renamed from chromium/chrome/browser/ui/webui/version_handler_win.cc)4
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler_win.h (renamed from chromium/chrome/browser/ui/webui/version_handler_win.h)8
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_handler_win_unittest.cc (renamed from chromium/chrome/browser/ui/webui/version_handler_win_unittest.cc)4
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_ui.cc (renamed from chromium/chrome/browser/ui/webui/version_ui.cc)32
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_ui.h (renamed from chromium/chrome/browser/ui/webui/version_ui.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_util_win.cc (renamed from chromium/chrome/browser/ui/webui/version_util_win.cc)7
-rw-r--r--chromium/chrome/browser/ui/webui/version/version_util_win.h (renamed from chromium/chrome/browser/ui/webui/version_util_win.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/video_tutorials/DIR_METADATA4
-rw-r--r--chromium/chrome/browser/ui/webui/video_tutorials/OWNERS3
-rw-r--r--chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.h17
-rw-r--r--chromium/chrome/browser/ui/webui/video_tutorials/video_player_ui.cc (renamed from chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.cc)30
-rw-r--r--chromium/chrome/browser/ui/webui/video_tutorials/video_player_ui.h36
-rw-r--r--chromium/chrome/browser/ui/webui/web_ui_test_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/web_ui_test_handler.h18
-rw-r--r--chromium/chrome/browser/ui/webui/webapks/webapks_handler.cc (renamed from chromium/chrome/browser/ui/webui/webapks_handler.cc)8
-rw-r--r--chromium/chrome/browser/ui/webui/webapks/webapks_handler.h (renamed from chromium/chrome/browser/ui/webui/webapks_handler.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/webapks/webapks_ui.cc (renamed from chromium/chrome/browser/ui/webui/webapks_ui.cc)15
-rw-r--r--chromium/chrome/browser/ui/webui/webapks/webapks_ui.h (renamed from chromium/chrome/browser/ui/webui/webapks_ui.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.cc (renamed from chromium/chrome/browser/ui/webui/webui_js_exception/webui_js_exception_ui.cc)27
-rw-r--r--chromium/chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.h22
-rw-r--r--chromium/chrome/browser/ui/webui/webui_js_exception/webui_js_exception_ui.h22
-rw-r--r--chromium/chrome/browser/ui/webui/webui_util.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/webui_util.h39
-rw-r--r--chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/DIR_METADATA3
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/helpers.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc6
862 files changed, 18303 insertions, 14910 deletions
diff --git a/chromium/chrome/browser/ui/BUILD.gn b/chromium/chrome/browser/ui/BUILD.gn
index 91bb3832b7e..4dbdfc0c32c 100644
--- a/chromium/chrome/browser/ui/BUILD.gn
+++ b/chromium/chrome/browser/ui/BUILD.gn
@@ -5,6 +5,7 @@
import("//build/config/buildflags_paint_preview.gni")
import("//build/config/chromecast_build.gni")
import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/chromeos/ui_mode.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/crypto.gni")
import("//build/config/features.gni")
@@ -36,7 +37,7 @@ static_library("ui") {
"app_list/app_list_util.cc",
"app_list/app_list_util.h",
- # All other browser/ui/app_list files go under is_chromeos below.
+ # All other browser/ui/app_list files go under is_chromeos_ash below.
"autofill/autofill_bubble_handler.h",
"autofill/autofill_popup_controller.h",
"autofill/autofill_popup_controller_impl.cc",
@@ -55,6 +56,8 @@ static_library("ui") {
"autofill/payments/credit_card_scanner_view.cc",
"autofill/payments/credit_card_scanner_view.h",
"autofill/payments/credit_card_scanner_view_delegate.h",
+ "autofill/payments/offer_notification_helper.cc",
+ "autofill/payments/offer_notification_helper.h",
"autofill/payments/payments_ui_constants.h",
"autofill/popup_constants.h",
"autofill/popup_controller_common.cc",
@@ -84,6 +87,8 @@ static_library("ui") {
"crypto_module_password_dialog.h",
"cryptuiapi_shim.h",
"enterprise_startup_dialog.h",
+ "file_system_access_dialogs.cc",
+ "file_system_access_dialogs.h",
"find_bar/find_bar.h",
"find_bar/find_bar_state.cc",
"find_bar/find_bar_state.h",
@@ -101,8 +106,6 @@ static_library("ui") {
"login/login_navigation_throttle.h",
"login/login_tab_helper.cc",
"login/login_tab_helper.h",
- "native_file_system_dialogs.cc",
- "native_file_system_dialogs.h",
"page_info/chrome_page_info_client.cc",
"page_info/chrome_page_info_client.h",
"page_info/chrome_page_info_delegate.cc",
@@ -168,6 +171,8 @@ static_library("ui") {
"tab_modal_confirm_dialog.h",
"tab_ui_helper.cc",
"tab_ui_helper.h",
+ "toolbar/chrome_labs_prefs.cc",
+ "toolbar/chrome_labs_prefs.h",
"toolbar/chrome_location_bar_model_delegate.cc",
"toolbar/chrome_location_bar_model_delegate.h",
"translate/source_language_combobox_model.cc",
@@ -184,6 +189,9 @@ static_library("ui") {
"uninstall_browser_prompt.h",
"view_ids.h",
"webauthn/authenticator_request_dialog.h",
+ "webid/identity_dialog_controller.cc",
+ "webid/identity_dialog_controller.h",
+ "webid/identity_dialogs.h",
"webui/about_ui.cc",
"webui/about_ui.h",
"webui/autofill_and_password_manager_internals/autofill_internals_ui.cc",
@@ -192,6 +200,8 @@ static_library("ui") {
"webui/autofill_and_password_manager_internals/internals_ui_handler.h",
"webui/autofill_and_password_manager_internals/password_manager_internals_ui.cc",
"webui/autofill_and_password_manager_internals/password_manager_internals_ui.h",
+ "webui/chrome_untrusted_web_ui_controller_factory.cc",
+ "webui/chrome_untrusted_web_ui_controller_factory.h",
"webui/chrome_web_ui_controller_factory.cc",
"webui/chrome_web_ui_controller_factory.h",
"webui/components/components_handler.cc",
@@ -216,24 +226,20 @@ static_library("ui") {
"webui/engagement/site_engagement_ui.h",
"webui/fileicon_source.cc",
"webui/fileicon_source.h",
- "webui/flags_ui.cc",
- "webui/flags_ui.h",
- "webui/flags_ui_handler.cc",
- "webui/flags_ui_handler.h",
+ "webui/flags/flags_ui.cc",
+ "webui/flags/flags_ui.h",
+ "webui/flags/flags_ui_handler.cc",
+ "webui/flags/flags_ui_handler.h",
"webui/gcm_internals_ui.cc",
"webui/gcm_internals_ui.h",
"webui/internals/internals_ui.cc",
"webui/internals/internals_ui.h",
"webui/interstitials/interstitial_ui.cc",
"webui/interstitials/interstitial_ui.h",
- "webui/interventions_internals/interventions_internals_page_handler.cc",
- "webui/interventions_internals/interventions_internals_page_handler.h",
- "webui/interventions_internals/interventions_internals_ui.cc",
- "webui/interventions_internals/interventions_internals_ui.h",
- "webui/invalidations_message_handler.cc",
- "webui/invalidations_message_handler.h",
- "webui/invalidations_ui.cc",
- "webui/invalidations_ui.h",
+ "webui/invalidations/invalidations_message_handler.cc",
+ "webui/invalidations/invalidations_message_handler.h",
+ "webui/invalidations/invalidations_ui.cc",
+ "webui/invalidations/invalidations_ui.h",
"webui/local_state/local_state_ui.cc",
"webui/local_state/local_state_ui.h",
"webui/log_web_ui_url.cc",
@@ -258,10 +264,10 @@ static_library("ui") {
"webui/omnibox/omnibox_page_handler.h",
"webui/omnibox/omnibox_ui.cc",
"webui/omnibox/omnibox_ui.h",
- "webui/policy_ui.cc",
- "webui/policy_ui.h",
- "webui/policy_ui_handler.cc",
- "webui/policy_ui_handler.h",
+ "webui/policy/policy_ui.cc",
+ "webui/policy/policy_ui.h",
+ "webui/policy/policy_ui_handler.cc",
+ "webui/policy/policy_ui_handler.h",
"webui/predictors/predictors_handler.cc",
"webui/predictors/predictors_handler.h",
"webui/predictors/predictors_ui.cc",
@@ -278,10 +284,10 @@ static_library("ui") {
"webui/quota_internals/quota_internals_ui.h",
"webui/signin_internals_ui.cc",
"webui/signin_internals_ui.h",
- "webui/sync_internals_message_handler.cc",
- "webui/sync_internals_message_handler.h",
- "webui/sync_internals_ui.cc",
- "webui/sync_internals_ui.h",
+ "webui/sync_internals/sync_internals_message_handler.cc",
+ "webui/sync_internals/sync_internals_message_handler.h",
+ "webui/sync_internals/sync_internals_ui.cc",
+ "webui/sync_internals/sync_internals_ui.h",
"webui/test_files_request_filter.cc",
"webui/test_files_request_filter.h",
"webui/translate_internals/chrome_translate_internals_handler.cc",
@@ -296,16 +302,23 @@ static_library("ui") {
"webui/user_actions/user_actions_ui.h",
"webui/user_actions/user_actions_ui_handler.cc",
"webui/user_actions/user_actions_ui_handler.h",
- "webui/version_handler.cc",
- "webui/version_handler.h",
- "webui/version_ui.cc",
- "webui/version_ui.h",
+ "webui/version/version_handler.cc",
+ "webui/version/version_handler.h",
+ "webui/version/version_ui.cc",
+ "webui/version/version_ui.h",
"webui/webui_load_timer.cc",
"webui/webui_load_timer.h",
"webui/webui_util.cc",
"webui/webui_util.h",
]
+ if (enable_session_service) {
+ sources += [
+ "webui/sessions/session_service_internals_ui.cc",
+ "webui/sessions/session_service_internals_ui.h",
+ ]
+ }
+
if (safe_browsing_mode == 1) {
sources += [
"webui/reset_password/reset_password_ui.cc",
@@ -313,8 +326,6 @@ static_library("ui") {
]
}
- # TODO(crbug/925153): Remove this circular dependency.
- allow_circular_includes_from = [ "//chrome/browser/safe_browsing" ]
defines = []
libs = []
@@ -329,8 +340,9 @@ static_library("ui") {
# have the same dependencies. Once browser_ui is untangled from
# browser, then we can clean up these dependencies.
public_deps = [
- "//chrome/services/machine_learning:machine_learning_tflite_buildflags",
"//components/dom_distiller/core",
+ "//components/optimization_guide:machine_learning_tflite_buildflags",
+ "//components/paint_preview/buildflags",
"//components/safe_browsing:buildflags",
"//components/sync",
"//components/sync_user_events",
@@ -343,6 +355,7 @@ static_library("ui") {
"//base:i18n",
"//base/allocator:buildflags",
"//build:branding_buildflags",
+ "//build:chromeos_buildflags",
"//cc/paint",
"//chrome:extra_resources",
"//chrome:resources",
@@ -353,6 +366,7 @@ static_library("ui") {
"//chrome/app/theme:chrome_unscaled_resources",
"//chrome/app/theme:theme_resources",
"//chrome/app/vector_icons",
+ "//chrome/browser:browser_process",
"//chrome/browser:buildflags",
"//chrome/browser:dev_ui_browser_resources",
"//chrome/browser:resource_prefetch_predictor_proto",
@@ -360,20 +374,22 @@ static_library("ui") {
"//chrome/browser/image_decoder",
"//chrome/browser/media:mojo_bindings",
"//chrome/browser/media/feeds:mojo_bindings",
+ "//chrome/browser/profiles:profile",
"//chrome/browser/profiling_host",
- "//chrome/browser/resources/invalidations:invalidations_resources",
+ "//chrome/browser/resources/invalidations:resources",
"//chrome/browser/resources/media:webrtc_logs_resources",
- "//chrome/browser/resources/net_internals:net_internals_resources",
+ "//chrome/browser/resources/net_internals:resources",
"//chrome/browser/resources/omnibox:resources",
- "//chrome/browser/resources/quota_internals:quota_internals_resources",
+ "//chrome/browser/resources/quota_internals:resources",
"//chrome/browser/resources/usb_internals:resources",
"//chrome/browser/safe_browsing",
"//chrome/browser/ui/webui/bluetooth_internals",
"//chrome/browser/ui/webui/downloads:mojo_bindings",
- "//chrome/browser/ui/webui/interventions_internals:mojo_bindings",
+ "//chrome/browser/ui/webui/memories:mojo_bindings",
"//chrome/browser/ui/webui/new_tab_page:mojo_bindings",
"//chrome/browser/ui/webui/omnibox:mojo_bindings",
"//chrome/browser/ui/webui/read_later:mojo_bindings",
+ "//chrome/browser/ui/webui/realbox:mojo_bindings",
"//chrome/browser/ui/webui/tab_search:mojo_bindings",
"//chrome/browser/ui/webui/usb_internals:mojo_bindings",
"//chrome/browser/video_tutorials",
@@ -387,6 +403,7 @@ static_library("ui") {
"//components/account_id",
"//components/autofill/content/browser:risk_proto",
"//components/autofill/core/browser",
+ "//components/autofill_assistant/browser/public:public",
"//components/blocked_content",
"//components/bookmarks/browser",
"//components/bookmarks/managed",
@@ -410,6 +427,7 @@ static_library("ui") {
"//components/download/content/factory",
"//components/download/content/public",
"//components/embedder_support",
+ "//components/embedder_support:browser_util",
"//components/encrypted_messages:encrypted_message_proto",
"//components/enterprise",
"//components/error_page/content/browser",
@@ -418,8 +436,6 @@ static_library("ui") {
"//components/feature_engagement",
"//components/feed:buildflags",
"//components/feed:feature_list",
- "//components/feed/content:feed_content",
- "//components/feed/core:feed_core",
"//components/feedback",
"//components/find_in_page",
"//components/flags_ui",
@@ -437,7 +453,9 @@ static_library("ui") {
"//components/keyed_service/core",
"//components/language/core/browser",
"//components/language/core/common",
+ "//components/lens",
"//components/lookalikes/core",
+ "//components/memories/core",
"//components/metrics_services_manager",
"//components/navigation_metrics",
"//components/net_log",
@@ -447,8 +465,7 @@ static_library("ui") {
"//components/omnibox/browser",
"//components/omnibox/browser:vector_icons",
"//components/onc",
- "//components/optimization_guide",
- "//components/paint_preview/buildflags",
+ "//components/optimization_guide/core",
"//components/password_manager/content/browser",
"//components/password_manager/core/browser",
"//components/password_manager/core/browser:affiliation",
@@ -465,13 +482,11 @@ static_library("ui") {
"//components/previews/core",
"//components/proxy_config",
"//components/query_parser",
- "//components/rappor",
"//components/reading_list/core",
"//components/reading_list/features:flags",
"//components/renderer_context_menu",
"//components/resources",
"//components/safe_browsing/content/password_protection",
- "//components/safe_browsing/content/password_protection:password_protection_metrics_util",
"//components/safe_browsing/content/triggers:ad_popup_trigger",
"//components/safe_browsing/content/triggers:ad_redirect_trigger",
"//components/safe_browsing/content/web_ui",
@@ -481,6 +496,7 @@ static_library("ui") {
"//components/safe_browsing/core/common:safe_browsing_prefs",
"//components/safe_browsing/core/db:database_manager",
"//components/safe_browsing/core/db:util",
+ "//components/safe_browsing/core/password_protection:password_protection_metrics_util",
"//components/schema_org/common:improved_mojom",
"//components/search",
"//components/search_engines",
@@ -494,6 +510,7 @@ static_library("ui") {
"//components/signin/core/browser",
"//components/signin/public/base:signin_buildflags",
"//components/signin/public/identity_manager",
+ "//components/site_engagement/content",
"//components/site_engagement/core/mojom:mojo_bindings",
"//components/spellcheck/browser",
"//components/ssl_errors",
@@ -526,6 +543,7 @@ static_library("ui") {
"//components/viz/host",
"//components/web_cache/browser",
"//components/web_resource",
+ "//components/webapps/browser",
"//components/webrtc_logging/browser",
"//content/app/resources",
"//content/browser/webrtc/resources",
@@ -539,12 +557,12 @@ static_library("ui") {
"//printing/buildflags",
"//rlz/buildflags",
"//services/device/public/cpp:device_features",
+ "//services/device/public/cpp/geolocation",
"//services/metrics/public/cpp:ukm_builders",
"//services/network/public/mojom",
"//skia",
"//storage/browser",
"//storage/common",
- "//third_party/adobe/flash:flapper_version_h",
"//third_party/blink/public:buildflags",
"//third_party/blink/public:resources",
"//third_party/blink/public/common",
@@ -580,8 +598,15 @@ static_library("ui") {
"//ui/webui/resources/cr_components/customize_themes:mojom",
"//v8:v8_version",
]
- allow_circular_includes_from +=
- [ "//chrome/browser/ui/webui/bluetooth_internals" ]
+
+ # TODO(crbug/925153): Remove this circular dependency.
+ allow_circular_includes_from = [
+ # TODO(crbug.com/1158905): Remove this circular dependency.
+ "//chrome/browser/devtools",
+ "//chrome/browser/safe_browsing",
+ "//chrome/browser/ui/webui/bluetooth_internals",
+ "//chrome/browser/profiling_host",
+ ]
if (is_win || is_mac || is_linux || is_chromeos) {
deps += [ "//chrome/browser/ui/webui/discards:mojo_bindings" ]
@@ -592,6 +617,10 @@ static_library("ui") {
}
if (is_android) {
+ sources += [
+ "autofill/payments/offer_notification_infobar_controller_impl.cc",
+ "autofill/payments/offer_notification_infobar_controller_impl.h",
+ ]
deps += [
"//chrome/app:chromium_strings",
"//chrome/browser/notifications/scheduler/public",
@@ -599,11 +628,14 @@ static_library("ui") {
"//chrome/browser/ui/webui/feed_internals:mojo_bindings",
"//components/browser_ui/util/android",
"//components/feed/core/common:feed_core_common",
+ "//components/feed/core/shared_prefs:feed_shared_prefs",
"//components/feed/core/v2:feed_core_v2",
"//components/infobars/content",
+ "//components/messages/android:feature_flags",
"//components/query_tiles",
"//components/resources:android_resources",
"//components/security_state/content/android",
+ "//url:gurl_android",
]
} else {
# !is_android
@@ -669,6 +701,8 @@ static_library("ui") {
"android/external_protocol_dialog_android.cc",
"android/infobars/autofill_credit_card_filling_infobar.cc",
"android/infobars/autofill_credit_card_filling_infobar.h",
+ "android/infobars/autofill_offer_notification_infobar.cc",
+ "android/infobars/autofill_offer_notification_infobar.h",
"android/infobars/autofill_save_card_infobar.cc",
"android/infobars/autofill_save_card_infobar.h",
"android/infobars/chrome_confirm_infobar.cc",
@@ -687,8 +721,6 @@ static_library("ui") {
"android/infobars/grouped_permission_infobar.h",
"android/infobars/infobar_container_android.cc",
"android/infobars/infobar_container_android.h",
- "android/infobars/installable_ambient_badge_infobar.cc",
- "android/infobars/installable_ambient_badge_infobar.h",
"android/infobars/instant_apps_infobar.cc",
"android/infobars/instant_apps_infobar.h",
"android/infobars/near_oom_infobar.cc",
@@ -750,6 +782,7 @@ static_library("ui") {
"android/tab_model/tab_model_observer_jni_bridge.h",
"android/toolbar/location_bar_model_android.cc",
"android/toolbar/location_bar_model_android.h",
+ "android/webid/identity_dialogs_android.cc",
"browser_otr_state_android.cc",
"javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_android.cc",
"javascript_dialogs/javascript_tab_modal_dialog_manager_delegate_android.h",
@@ -766,25 +799,19 @@ static_library("ui") {
"webui/offline/offline_internals_ui.h",
"webui/offline/offline_internals_ui_message_handler.cc",
"webui/offline/offline_internals_ui_message_handler.h",
- "webui/video_tutorials/video_player_source.cc",
- "webui/video_tutorials/video_player_source.h",
- "webui/webapks_handler.cc",
- "webui/webapks_handler.h",
- "webui/webapks_ui.cc",
- "webui/webapks_ui.h",
+ "webui/video_tutorials/video_player_ui.cc",
+ "webui/video_tutorials/video_player_ui.h",
+ "webui/webapks/webapks_handler.cc",
+ "webui/webapks/webapks_handler.h",
+ "webui/webapks/webapks_ui.cc",
+ "webui/webapks/webapks_ui.h",
]
- if (enable_feed_v1 || enable_feed_v2) {
+ if (enable_feed_v2) {
sources += [
"webui/feed_internals/feed_internals_ui.cc",
"webui/feed_internals/feed_internals_ui.h",
]
}
- if (enable_feed_v1) {
- sources += [
- "webui/feed_internals/feed_internals_page_handler.cc",
- "webui/feed_internals/feed_internals_page_handler.h",
- ]
- }
if (enable_feed_v2) {
sources += [
"webui/feed_internals/feedv2_internals_page_handler.cc",
@@ -796,7 +823,7 @@ static_library("ui") {
"//chrome/android:jni_headers",
"//chrome/android/features/dev_ui:buildflags",
"//chrome/browser/image_decoder",
- "//chrome/browser/resources/webapks:webapks_ui_resources",
+ "//chrome/browser/resources/webapks:resources",
"//components/autofill_assistant/browser",
"//components/autofill_assistant/browser:proto",
"//components/browser_ui/client_certificate/android",
@@ -908,8 +935,8 @@ static_library("ui") {
"chrome_web_modal_dialog_manager_delegate.h",
"collected_cookies_infobar_delegate.cc",
"collected_cookies_infobar_delegate.h",
- "commander/apps_command_source.cc",
- "commander/apps_command_source.h",
+ "commander/bookmark_command_source.cc",
+ "commander/bookmark_command_source.h",
"commander/command_source.cc",
"commander/command_source.h",
"commander/commander.cc",
@@ -920,10 +947,16 @@ static_library("ui") {
"commander/commander_frontend.h",
"commander/commander_view_model.cc",
"commander/commander_view_model.h",
- "commander/fuzzy_finder.cc",
- "commander/fuzzy_finder.h",
+ "commander/entity_match.cc",
+ "commander/entity_match.h",
+ "commander/open_url_command_source.cc",
+ "commander/open_url_command_source.h",
"commander/simple_command_source.cc",
"commander/simple_command_source.h",
+ "commander/tab_command_source.cc",
+ "commander/tab_command_source.h",
+ "commander/window_command_source.cc",
+ "commander/window_command_source.h",
"confirm_bubble_model.cc",
"confirm_bubble_model.h",
"content_settings/content_setting_bubble_model.cc",
@@ -958,6 +991,10 @@ static_library("ui") {
"find_bar/find_bar_platform_helper.h",
"focus_tab_after_navigation_helper.cc",
"focus_tab_after_navigation_helper.h",
+ "font_access/font_access_chooser.cc",
+ "font_access/font_access_chooser.h",
+ "font_access/font_access_chooser_controller.cc",
+ "font_access/font_access_chooser_controller.h",
"global_error/global_error.cc",
"global_error/global_error.h",
"global_error/global_error_bubble_view_base.h",
@@ -976,16 +1013,21 @@ static_library("ui") {
"global_media_controls/media_dialog_delegate.h",
"global_media_controls/media_notification_container_impl.h",
"global_media_controls/media_notification_container_observer.h",
+ "global_media_controls/media_notification_container_observer_set.cc",
+ "global_media_controls/media_notification_container_observer_set.h",
"global_media_controls/media_notification_device_monitor.cc",
"global_media_controls/media_notification_device_monitor.h",
"global_media_controls/media_notification_device_provider.h",
"global_media_controls/media_notification_device_provider_impl.cc",
"global_media_controls/media_notification_device_provider_impl.h",
+ "global_media_controls/media_notification_producer.h",
"global_media_controls/media_notification_service.cc",
"global_media_controls/media_notification_service.h",
"global_media_controls/media_notification_service_factory.cc",
"global_media_controls/media_notification_service_factory.h",
"global_media_controls/media_notification_service_observer.h",
+ "global_media_controls/media_session_notification_producer.cc",
+ "global_media_controls/media_session_notification_producer.h",
"global_media_controls/media_toolbar_button_controller.cc",
"global_media_controls/media_toolbar_button_controller.h",
"global_media_controls/media_toolbar_button_controller_delegate.cc",
@@ -1005,8 +1047,6 @@ static_library("ui") {
"hats/hats_service.h",
"hats/hats_service_factory.cc",
"hats/hats_service_factory.h",
- "hats/hats_survey_status_checker.cc",
- "hats/hats_survey_status_checker.h",
"hid/hid_chooser.cc",
"hid/hid_chooser.h",
"hid/hid_chooser_controller.cc",
@@ -1231,8 +1271,12 @@ static_library("ui") {
"task_manager/task_manager_columns.h",
"task_manager/task_manager_table_model.cc",
"task_manager/task_manager_table_model.h",
+ "thumbnails/background_thumbnail_capturer.h",
+ "thumbnails/background_thumbnail_video_capturer.cc",
+ "thumbnails/background_thumbnail_video_capturer.h",
"thumbnails/thumbnail_capture_driver.cc",
"thumbnails/thumbnail_capture_driver.h",
+ "thumbnails/thumbnail_capture_info.h",
"thumbnails/thumbnail_image.cc",
"thumbnails/thumbnail_image.h",
"thumbnails/thumbnail_readiness_tracker.cc",
@@ -1282,6 +1326,8 @@ static_library("ui") {
"user_education/feature_promo_controller.h",
"user_education/feature_promo_snooze_service.cc",
"user_education/feature_promo_snooze_service.h",
+ "user_education/feature_promo_text_replacements.cc",
+ "user_education/feature_promo_text_replacements.h",
"user_education/reopen_tab_in_product_help.cc",
"user_education/reopen_tab_in_product_help.h",
"user_education/reopen_tab_in_product_help_factory.cc",
@@ -1326,6 +1372,8 @@ static_library("ui") {
"webui/extensions/extensions_ui.h",
"webui/favicon_source.cc",
"webui/favicon_source.h",
+ "webui/feedback/feedback_ui.cc",
+ "webui/feedback/feedback_ui.h",
"webui/help/version_updater.h",
"webui/history/browsing_history_handler.cc",
"webui/history/browsing_history_handler.h",
@@ -1345,10 +1393,10 @@ static_library("ui") {
"webui/internals/web_app/web_app_internals_page_handler_impl.h",
"webui/managed_ui_handler.cc",
"webui/managed_ui_handler.h",
- "webui/management_ui.cc",
- "webui/management_ui.h",
- "webui/management_ui_handler.cc",
- "webui/management_ui_handler.h",
+ "webui/management/management_ui.cc",
+ "webui/management/management_ui.h",
+ "webui/management/management_ui_handler.cc",
+ "webui/management/management_ui_handler.h",
"webui/media/media_feeds_ui.cc",
"webui/media/media_feeds_ui.h",
"webui/media_router/media_router_internals_ui.cc",
@@ -1356,6 +1404,10 @@ static_library("ui") {
"webui/media_router/media_router_internals_webui_message_handler.cc",
"webui/media_router/media_router_internals_webui_message_handler.h",
"webui/media_router/web_contents_display_observer.h",
+ "webui/memories/memories_handler.cc",
+ "webui/memories/memories_handler.h",
+ "webui/memories/memories_ui.cc",
+ "webui/memories/memories_ui.h",
"webui/new_tab_page/new_tab_page_handler.cc",
"webui/new_tab_page/new_tab_page_handler.h",
"webui/new_tab_page/new_tab_page_ui.cc",
@@ -1396,6 +1448,8 @@ static_library("ui") {
"webui/read_later/read_later_page_handler.h",
"webui/read_later/read_later_ui.cc",
"webui/read_later/read_later_ui.h",
+ "webui/realbox/realbox_handler.cc",
+ "webui/realbox/realbox_handler.h",
"webui/sanitized_image_source.cc",
"webui/sanitized_image_source.h",
"webui/settings/about_handler.cc",
@@ -1458,14 +1512,14 @@ static_library("ui") {
"webui/settings/settings_startup_pages_handler.h",
"webui/settings/settings_ui.cc",
"webui/settings/settings_ui.h",
+ "webui/settings/settings_utils.cc",
+ "webui/settings/settings_utils.h",
"webui/settings/shared_settings_localized_strings_provider.cc",
"webui/settings/shared_settings_localized_strings_provider.h",
"webui/settings/site_settings_handler.cc",
"webui/settings/site_settings_handler.h",
"webui/settings/site_settings_helper.cc",
"webui/settings/site_settings_helper.h",
- "webui/settings_utils.cc",
- "webui/settings_utils.h",
"webui/signin/login_ui_service.cc",
"webui/signin/login_ui_service.h",
"webui/signin/login_ui_service_factory.cc",
@@ -1508,18 +1562,22 @@ static_library("ui") {
"//build:chromeos_buildflags",
"//chrome/app/vector_icons",
"//chrome/browser:theme_properties",
- "//chrome/browser/media/kaleidoscope/mojom",
+ "//chrome/browser/browsing_data:constants",
+ "//chrome/browser/cart:mojo_bindings",
"//chrome/browser/media/router",
"//chrome/browser/profile_resetter:profile_reset_report_proto",
"//chrome/browser/promo_browser_command:mojo_bindings",
"//chrome/browser/resource_coordinator:tab_metrics_event_proto",
"//chrome/browser/resource_coordinator/tab_ranker",
"//chrome/browser/safe_browsing:advanced_protection",
+ "//chrome/browser/search/drive:mojo_bindings",
"//chrome/browser/search/task_module:mojo_bindings",
"//chrome/browser/ui/color:color_headers",
"//chrome/browser/ui/color:mixers",
+ "//chrome/browser/ui/commander:fuzzy_finder",
"//chrome/browser/ui/webui/app_management:mojo_bindings",
"//chrome/browser/ui/webui/internals/web_app:mojo_bindings",
+ "//chrome/browser/web_applications/components",
"//chrome/common:buildflags",
"//chrome/common/search:generate_chrome_colors_info",
"//chrome/common/search:mojo_bindings",
@@ -1547,24 +1605,26 @@ static_library("ui") {
"//device/bluetooth/strings:strings_grit",
"//device/fido",
"//ppapi/c",
+ "//services/device/public/cpp/hid",
"//services/device/public/mojom",
"//services/metrics/public/cpp:metrics_cpp",
"//services/preferences/public/mojom:mojom",
"//third_party/blink/public/common:headers",
"//third_party/libaddressinput",
"//third_party/libaddressinput:strings",
+ "//ui/base/dragdrop/mojom",
"//ui/events",
]
public_deps += [ "//ui/base/dragdrop/mojom:mojom_headers" ]
- if (use_ozone && !is_chromeos) {
+ if (use_ozone && !is_chromeos_ash) {
deps += [
"//ui/base:features",
"//ui/ozone",
]
}
- if (is_linux && !is_chromeos) {
+ if (is_linux || is_chromeos_lacros) {
deps += [ "//ui/base/ime/linux" ]
}
@@ -1599,15 +1659,15 @@ static_library("ui") {
if (enable_supervised_users) {
sources += [
- "webui/supervised_user_internals_message_handler.cc",
- "webui/supervised_user_internals_message_handler.h",
- "webui/supervised_user_internals_ui.cc",
- "webui/supervised_user_internals_ui.h",
+ "webui/family_link_user_internals/family_link_user_internals_message_handler.cc",
+ "webui/family_link_user_internals/family_link_user_internals_message_handler.h",
+ "webui/family_link_user_internals/family_link_user_internals_ui.cc",
+ "webui/family_link_user_internals/family_link_user_internals_ui.h",
]
deps += [ "//chrome/browser/supervised_user/supervised_user_error_page" ]
}
- if (is_chromeos) {
+ if (is_chromeos_ash) {
assert(enable_extensions)
assert(enable_supervised_users)
assert(toolkit_views)
@@ -1692,8 +1752,6 @@ static_library("ui") {
"app_list/chrome_app_list_model_updater.h",
"app_list/extension_app_utils.cc",
"app_list/extension_app_utils.h",
- "app_list/icon_standardizer.cc",
- "app_list/icon_standardizer.h",
"app_list/internal_app/internal_app_metadata.cc",
"app_list/internal_app/internal_app_metadata.h",
"app_list/md_icon_normalizer.cc",
@@ -1736,12 +1794,6 @@ static_library("ui") {
"app_list/search/cros_action_history/cros_action_recorder.h",
"app_list/search/cros_action_history/cros_action_recorder_tab_tracker.cc",
"app_list/search/cros_action_history/cros_action_recorder_tab_tracker.h",
- "app_list/search/drive_quick_access_chip_result.cc",
- "app_list/search/drive_quick_access_chip_result.h",
- "app_list/search/drive_quick_access_provider.cc",
- "app_list/search/drive_quick_access_provider.h",
- "app_list/search/drive_quick_access_result.cc",
- "app_list/search/drive_quick_access_result.h",
"app_list/search/file_chip_result.cc",
"app_list/search/file_chip_result.h",
"app_list/search/files/drive_zero_state_provider.cc",
@@ -1768,6 +1820,10 @@ static_library("ui") {
"app_list/search/omnibox_result.h",
"app_list/search/os_settings_provider.cc",
"app_list/search/os_settings_provider.h",
+ "app_list/search/score_normalizer/balanced_reservoir.cc",
+ "app_list/search/score_normalizer/balanced_reservoir.h",
+ "app_list/search/score_normalizer/score_normalizer.cc",
+ "app_list/search/score_normalizer/score_normalizer.h",
"app_list/search/search_controller.cc",
"app_list/search/search_controller.h",
"app_list/search/search_controller_factory.cc",
@@ -1798,8 +1854,6 @@ static_library("ui") {
"app_list/search/search_result_ranker/frecency_store.h",
"app_list/search/search_result_ranker/histogram_util.cc",
"app_list/search/search_result_ranker/histogram_util.h",
- "app_list/search/search_result_ranker/ml_app_rank_provider.cc",
- "app_list/search/search_result_ranker/ml_app_rank_provider.h",
"app_list/search/search_result_ranker/ranking_item_util.cc",
"app_list/search/search_result_ranker/ranking_item_util.h",
"app_list/search/search_result_ranker/recurrence_predictor.cc",
@@ -1826,8 +1880,6 @@ static_library("ui") {
"ash/accessibility/accessibility_controller_client.h",
"ash/ambient/ambient_client_impl.cc",
"ash/ambient/ambient_client_impl.h",
- "ash/arc_chrome_actions_client.cc",
- "ash/arc_chrome_actions_client.h",
"ash/arc_custom_tab_modal_dialog_host.cc",
"ash/arc_custom_tab_modal_dialog_host.h",
"ash/ash_shell_init.cc",
@@ -1928,6 +1980,8 @@ static_library("ui") {
"ash/launcher/app_service/app_service_instance_registry_helper.h",
"ash/launcher/app_service/app_service_shelf_context_menu.cc",
"ash/launcher/app_service/app_service_shelf_context_menu.h",
+ "ash/launcher/app_service/exo_app_type_resolver.cc",
+ "ash/launcher/app_service/exo_app_type_resolver.h",
"ash/launcher/app_service/launcher_app_service_app_updater.cc",
"ash/launcher/app_service/launcher_app_service_app_updater.h",
"ash/launcher/app_shortcut_launcher_item_controller.cc",
@@ -1959,10 +2013,14 @@ static_library("ui") {
"ash/launcher/chrome_launcher_controller_util.h",
"ash/launcher/crostini_app_display.cc",
"ash/launcher/crostini_app_display.h",
+ "ash/launcher/crostini_app_window.cc",
+ "ash/launcher/crostini_app_window.h",
"ash/launcher/extension_shelf_context_menu.cc",
"ash/launcher/extension_shelf_context_menu.h",
"ash/launcher/extension_uninstaller.cc",
"ash/launcher/extension_uninstaller.h",
+ "ash/launcher/lacros_app_window.cc",
+ "ash/launcher/lacros_app_window.h",
"ash/launcher/launcher_app_updater.cc",
"ash/launcher/launcher_app_updater.h",
"ash/launcher/launcher_controller_helper.cc",
@@ -2008,6 +2066,8 @@ static_library("ui") {
"ash/network/network_state_notifier.h",
"ash/network/tether_notification_presenter.cc",
"ash/network/tether_notification_presenter.h",
+ "ash/projector/projector_client_impl.cc",
+ "ash/projector/projector_client_impl.h",
"ash/quick_answers/quick_answers_browser_client_impl.cc",
"ash/quick_answers/quick_answers_browser_client_impl.h",
"ash/screen_orientation_delegate_chromeos.cc",
@@ -2020,6 +2080,16 @@ static_library("ui") {
"ash/session_controller_client_impl.h",
"ash/session_util.cc",
"ash/session_util.h",
+ "ash/sharesheet/sharesheet_bubble_view.cc",
+ "ash/sharesheet/sharesheet_bubble_view.h",
+ "ash/sharesheet/sharesheet_content_previews.cc",
+ "ash/sharesheet/sharesheet_content_previews.h",
+ "ash/sharesheet/sharesheet_expand_button.cc",
+ "ash/sharesheet/sharesheet_expand_button.h",
+ "ash/sharesheet/sharesheet_image_decode.cc",
+ "ash/sharesheet/sharesheet_image_decode.h",
+ "ash/sharesheet/sharesheet_target_button.cc",
+ "ash/sharesheet/sharesheet_target_button.h",
"ash/system_tray_client.cc",
"ash/system_tray_client.h",
"ash/tab_scrubber.cc",
@@ -2043,6 +2113,8 @@ static_library("ui") {
"settings_window_manager_chromeos.h",
"settings_window_manager_observer_chromeos.h",
"supervised_user/parent_permission_dialog.h",
+ "toolbar/move_to_desks_menu_model.cc",
+ "toolbar/move_to_desks_menu_model.h",
"views/apps/app_dialog/app_block_dialog_view.cc",
"views/apps/app_dialog/app_block_dialog_view.h",
"views/apps/app_dialog/app_pause_dialog_view.cc",
@@ -2056,6 +2128,8 @@ static_library("ui") {
"views/arc_data_removal_dialog_view.cc",
"views/borealis/borealis_installer_view.cc",
"views/borealis/borealis_installer_view.h",
+ "views/borealis/borealis_splash_screen_view.cc",
+ "views/borealis/borealis_splash_screen_view.h",
"views/chrome_views_delegate_chromeos.cc",
"views/crostini/crostini_ansible_software_config_view.cc",
"views/crostini/crostini_ansible_software_config_view.h",
@@ -2079,18 +2153,11 @@ static_library("ui") {
"views/extensions/request_file_system_dialog_view.h",
"views/frame/browser_frame_ash.cc",
"views/frame/browser_frame_ash.h",
- "views/frame/browser_frame_header_chromeos.cc",
- "views/frame/browser_frame_header_chromeos.h",
- "views/frame/browser_non_client_frame_view_ash.cc",
- "views/frame/browser_non_client_frame_view_ash.h",
- "views/frame/browser_non_client_frame_view_factory_chromeos.cc",
"views/frame/custom_tab_browser_frame.cc",
"views/frame/custom_tab_browser_frame.h",
"views/frame/immersive_mode_controller_chromeos.cc",
"views/frame/immersive_mode_controller_chromeos.h",
"views/frame/native_browser_frame_factory_chromeos.cc",
- "views/frame/top_controls_slide_controller_chromeos.cc",
- "views/frame/top_controls_slide_controller_chromeos.h",
"views/platform_keys_certificate_selector_chromeos.cc",
"views/platform_keys_certificate_selector_chromeos.h",
"views/plugin_vm/plugin_vm_installer_view.cc",
@@ -2101,12 +2168,6 @@ static_library("ui") {
"views/relaunch_notification/relaunch_notification_controller_platform_impl_chromeos.h",
"views/relaunch_notification/relaunch_notification_metrics.cc",
"views/relaunch_notification/relaunch_notification_metrics.h",
- "views/sharesheet/sharesheet_bubble_view.cc",
- "views/sharesheet/sharesheet_bubble_view.h",
- "views/sharesheet/sharesheet_expand_button.cc",
- "views/sharesheet/sharesheet_expand_button.h",
- "views/sharesheet/sharesheet_target_button.cc",
- "views/sharesheet/sharesheet_target_button.h",
# On chromeos, file manager extension handles the file open/save dialog.
"views/select_file_dialog_extension.cc",
@@ -2162,8 +2223,6 @@ static_library("ui") {
"webui/chromeos/bluetooth_dialog_localized_strings_provider.h",
"webui/chromeos/bluetooth_pairing_dialog.cc",
"webui/chromeos/bluetooth_pairing_dialog.h",
- "webui/chromeos/cellular_setup/cellular_setup_dialog.cc",
- "webui/chromeos/cellular_setup/cellular_setup_dialog.h",
"webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc",
"webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h",
"webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc",
@@ -2192,20 +2251,22 @@ static_library("ui") {
"webui/chromeos/cryptohome_ui.h",
"webui/chromeos/cryptohome_web_ui_handler.cc",
"webui/chromeos/cryptohome_web_ui_handler.h",
+ "webui/chromeos/diagnostics_dialog.cc",
+ "webui/chromeos/diagnostics_dialog.h",
"webui/chromeos/drive_internals_ui.cc",
"webui/chromeos/drive_internals_ui.h",
"webui/chromeos/edu_account_login_handler_chromeos.cc",
"webui/chromeos/edu_account_login_handler_chromeos.h",
- "webui/chromeos/edu_coexistence_consent_tracker.cc",
- "webui/chromeos/edu_coexistence_consent_tracker.h",
- "webui/chromeos/edu_coexistence_login_handler_chromeos.cc",
- "webui/chromeos/edu_coexistence_login_handler_chromeos.h",
- "webui/chromeos/first_run/first_run_actor.cc",
- "webui/chromeos/first_run/first_run_actor.h",
- "webui/chromeos/first_run/first_run_handler.cc",
- "webui/chromeos/first_run/first_run_handler.h",
- "webui/chromeos/first_run/first_run_ui.cc",
- "webui/chromeos/first_run/first_run_ui.h",
+ "webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc",
+ "webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h",
+ "webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.cc",
+ "webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.h",
+ "webui/chromeos/emoji/emoji_dialog.cc",
+ "webui/chromeos/emoji/emoji_dialog.h",
+ "webui/chromeos/emoji/emoji_handler.cc",
+ "webui/chromeos/emoji/emoji_handler.h",
+ "webui/chromeos/emoji/emoji_picker.cc",
+ "webui/chromeos/emoji/emoji_picker.h",
"webui/chromeos/image_source.cc",
"webui/chromeos/image_source.h",
"webui/chromeos/in_session_password_change/confirm_password_change_handler.cc",
@@ -2258,14 +2319,6 @@ static_library("ui") {
"webui/chromeos/login/demo_setup_screen_handler.h",
"webui/chromeos/login/device_disabled_screen_handler.cc",
"webui/chromeos/login/device_disabled_screen_handler.h",
- "webui/chromeos/login/discover/discover_handler.cc",
- "webui/chromeos/login/discover/discover_handler.h",
- "webui/chromeos/login/discover/discover_manager.cc",
- "webui/chromeos/login/discover/discover_manager.h",
- "webui/chromeos/login/discover/discover_ui.cc",
- "webui/chromeos/login/discover/discover_ui.h",
- "webui/chromeos/login/discover/modules/discover_module_pin_setup.cc",
- "webui/chromeos/login/discover/modules/discover_module_pin_setup.h",
"webui/chromeos/login/enable_adb_sideloading_screen_handler.cc",
"webui/chromeos/login/enable_adb_sideloading_screen_handler.h",
"webui/chromeos/login/enable_debugging_screen_handler.cc",
@@ -2298,6 +2351,8 @@ static_library("ui") {
"webui/chromeos/login/kiosk_enable_screen_handler.h",
"webui/chromeos/login/l10n_util.cc",
"webui/chromeos/login/l10n_util.h",
+ "webui/chromeos/login/locale_switch_screen_handler.cc",
+ "webui/chromeos/login/locale_switch_screen_handler.h",
"webui/chromeos/login/marketing_opt_in_screen_handler.cc",
"webui/chromeos/login/marketing_opt_in_screen_handler.h",
"webui/chromeos/login/multidevice_setup_screen_handler.cc",
@@ -2308,6 +2363,8 @@ static_library("ui") {
"webui/chromeos/login/network_screen_handler.h",
"webui/chromeos/login/network_state_informer.cc",
"webui/chromeos/login/network_state_informer.h",
+ "webui/chromeos/login/offline_login_screen_handler.cc",
+ "webui/chromeos/login/offline_login_screen_handler.h",
"webui/chromeos/login/online_login_helper.cc",
"webui/chromeos/login/online_login_helper.h",
"webui/chromeos/login/oobe_display_chooser.cc",
@@ -2336,14 +2393,14 @@ static_library("ui") {
"webui/chromeos/login/sync_consent_screen_handler.h",
"webui/chromeos/login/terms_of_service_screen_handler.cc",
"webui/chromeos/login/terms_of_service_screen_handler.h",
+ "webui/chromeos/login/testapi/oobe_test_api_handler.cc",
+ "webui/chromeos/login/testapi/oobe_test_api_handler.h",
"webui/chromeos/login/tpm_error_screen_handler.cc",
"webui/chromeos/login/tpm_error_screen_handler.h",
"webui/chromeos/login/update_required_screen_handler.cc",
"webui/chromeos/login/update_required_screen_handler.h",
"webui/chromeos/login/update_screen_handler.cc",
"webui/chromeos/login/update_screen_handler.h",
- "webui/chromeos/login/user_board_screen_handler.cc",
- "webui/chromeos/login/user_board_screen_handler.h",
"webui/chromeos/login/user_creation_screen_handler.cc",
"webui/chromeos/login/user_creation_screen_handler.h",
"webui/chromeos/login/welcome_screen_handler.cc",
@@ -2408,8 +2465,8 @@ static_library("ui") {
"webui/help/help_utils_chromeos.h",
"webui/help/version_updater_chromeos.cc",
"webui/help/version_updater_chromeos.h",
- "webui/management_ui_handler_chromeos.cc",
- "webui/management_ui_handler_chromeos.h",
+ "webui/management/management_ui_handler_chromeos.cc",
+ "webui/management/management_ui_handler_chromeos.h",
"webui/nearby_internals/nearby_internals_contact_handler.cc",
"webui/nearby_internals/nearby_internals_contact_handler.h",
"webui/nearby_internals/nearby_internals_http_handler.cc",
@@ -2464,6 +2521,8 @@ static_library("ui") {
"webui/settings/chromeos/device_display_handler.h",
"webui/settings/chromeos/device_keyboard_handler.cc",
"webui/settings/chromeos/device_keyboard_handler.h",
+ "webui/settings/chromeos/device_name_handler.cc",
+ "webui/settings/chromeos/device_name_handler.h",
"webui/settings/chromeos/device_pointer_handler.cc",
"webui/settings/chromeos/device_pointer_handler.h",
"webui/settings/chromeos/device_power_handler.cc",
@@ -2480,6 +2539,8 @@ static_library("ui") {
"webui/settings/chromeos/fingerprint_handler.h",
"webui/settings/chromeos/google_assistant_handler.cc",
"webui/settings/chromeos/google_assistant_handler.h",
+ "webui/settings/chromeos/guest_os_handler.cc",
+ "webui/settings/chromeos/guest_os_handler.h",
"webui/settings/chromeos/hierarchy.cc",
"webui/settings/chromeos/hierarchy.h",
"webui/settings/chromeos/internet_handler.cc",
@@ -2498,6 +2559,8 @@ static_library("ui") {
"webui/settings/chromeos/multidevice_handler.h",
"webui/settings/chromeos/multidevice_section.cc",
"webui/settings/chromeos/multidevice_section.h",
+ "webui/settings/chromeos/on_startup_section.cc",
+ "webui/settings/chromeos/on_startup_section.h",
"webui/settings/chromeos/os_settings_features_util.cc",
"webui/settings/chromeos/os_settings_features_util.h",
"webui/settings/chromeos/os_settings_identifier.h",
@@ -2515,6 +2578,8 @@ static_library("ui") {
"webui/settings/chromeos/parental_controls_handler.h",
"webui/settings/chromeos/people_section.cc",
"webui/settings/chromeos/people_section.h",
+ "webui/settings/chromeos/peripheral_data_access_handler.cc",
+ "webui/settings/chromeos/peripheral_data_access_handler.h",
"webui/settings/chromeos/personalization_section.cc",
"webui/settings/chromeos/personalization_section.h",
"webui/settings/chromeos/plugin_vm_handler.cc",
@@ -2542,6 +2607,8 @@ static_library("ui") {
"webui/settings/chromeos/server_printer_url_util.h",
"webui/settings/chromeos/settings_user_action_tracker.cc",
"webui/settings/chromeos/settings_user_action_tracker.h",
+ "webui/settings/chromeos/switch_access_handler.cc",
+ "webui/settings/chromeos/switch_access_handler.h",
"webui/settings/chromeos/tts_handler.cc",
"webui/settings/chromeos/tts_handler.h",
"webui/settings/chromeos/wallpaper_handler.cc",
@@ -2554,8 +2621,10 @@ static_library("ui") {
"webui/signin/inline_login_handler_chromeos.h",
"webui/signin/inline_login_handler_modal_delegate.cc",
"webui/signin/inline_login_handler_modal_delegate.h",
- "webui/version_handler_chromeos.cc",
- "webui/version_handler_chromeos.h",
+ "webui/signin/signin_helper_chromeos.cc",
+ "webui/signin/signin_helper_chromeos.h",
+ "webui/version/version_handler_chromeos.cc",
+ "webui/version/version_handler_chromeos.h",
"window_sizer/window_sizer_chromeos.cc",
"window_sizer/window_sizer_chromeos.h",
]
@@ -2565,6 +2634,10 @@ static_library("ui") {
"//ash/app_list",
"//ash/assistant/model",
"//ash/assistant/util",
+ "//ash/components/account_manager",
+ "//ash/components/audio",
+ "//ash/components/pcie_peripheral",
+ "//ash/constants",
"//ash/keyboard/ui",
"//ash/public/cpp",
"//ash/public/cpp/app_list/vector_icons",
@@ -2586,6 +2659,9 @@ static_library("ui") {
"//chrome/browser/nearby_sharing/logging:util",
"//chrome/browser/nearby_sharing/proto",
"//chrome/browser/resources:bluetooth_pairing_dialog_resources",
+ "//chrome/browser/resources:internet_config_dialog_resources",
+ "//chrome/browser/resources:internet_detail_dialog_resources",
+ "//chrome/browser/resources/chromeos:multidevice_setup_resources",
"//chrome/browser/ui/app_list/search/cros_action_history:cros_action_proto",
"//chrome/browser/ui/app_list/search/search_result_ranker:app_launch_event_logger_proto",
"//chrome/browser/ui/app_list/search/search_result_ranker:app_launch_predictor_proto",
@@ -2601,24 +2677,24 @@ static_library("ui") {
"//chrome/browser/ui/webui/nearby_share/public/mojom",
"//chrome/browser/ui/webui/settings/chromeos/constants:mojom",
"//chrome/browser/ui/webui/settings/chromeos/search:mojo_bindings",
+ "//chrome/browser/web_applications/preinstalled_web_apps",
"//chrome/services/file_util/public/cpp",
"//chromeos",
"//chromeos/assistant:buildflags",
- "//chromeos/audio",
- "//chromeos/components/account_manager",
- "//chromeos/components/bloom/public/cpp",
- "//chromeos/components/bloom/public/cpp:bloom_controller_factory",
"//chromeos/components/camera_app_ui",
"//chromeos/components/connectivity_diagnostics",
- "//chromeos/components/connectivity_diagnostics:network_diagnostics_resource_provider",
"//chromeos/components/diagnostics_ui",
"//chromeos/components/drivefs/mojom:mojom",
+ "//chromeos/components/eche_app_ui",
"//chromeos/components/help_app_ui",
- "//chromeos/components/local_search_service:local_search_service",
+ "//chromeos/components/local_search_service/public/cpp",
+ "//chromeos/components/local_search_service/public/mojom",
"//chromeos/components/media_app_ui",
"//chromeos/components/multidevice",
"//chromeos/components/multidevice/debug_webui",
"//chromeos/components/multidevice/logging",
+ "//chromeos/components/network_ui:network_diagnostics_resource_provider",
+ "//chromeos/components/network_ui:network_health_resource_provider",
"//chromeos/components/phonehub",
"//chromeos/components/phonehub:debug",
"//chromeos/components/print_management",
@@ -2628,16 +2704,19 @@ static_library("ui") {
"//chromeos/components/string_matching",
"//chromeos/components/tether",
"//chromeos/components/web_applications",
- "//chromeos/constants",
+ "//chromeos/crosapi/cpp",
"//chromeos/cryptohome",
"//chromeos/dbus",
"//chromeos/dbus/audio",
"//chromeos/dbus/cryptohome",
"//chromeos/dbus/cryptohome:cryptohome_proto",
"//chromeos/dbus/kerberos:kerberos_proto",
+ "//chromeos/dbus/pciguard:pciguard",
"//chromeos/dbus/power",
"//chromeos/dbus/session_manager",
"//chromeos/dbus/system_clock",
+ "//chromeos/dbus/tpm_manager",
+ "//chromeos/dbus/tpm_manager:tpm_manager_proto",
"//chromeos/dbus/upstart",
"//chromeos/disks",
"//chromeos/login/auth",
@@ -2672,6 +2751,7 @@ static_library("ui") {
"//components/captive_portal/core",
"//components/consent_auditor:consent_auditor",
"//components/exo",
+ "//components/full_restore",
"//components/login",
"//components/metrics/structured:structured_events",
"//components/services/app_service/public/cpp:app_file_handling",
@@ -2681,7 +2761,11 @@ static_library("ui") {
"//components/services/app_service/public/cpp:instance_update",
"//components/session_manager/core",
"//components/user_manager",
+ "//extensions/browser/api/messaging",
+ "//extensions/browser/api/virtual_keyboard_private",
+ "//extensions/browser/api/vpn_provider",
"//google_apis/drive",
+ "//media/capture:capture_lib",
"//mojo/public/js:resources_grit",
"//services/audio/public/mojom",
"//services/data_decoder/public/cpp",
@@ -2693,6 +2777,7 @@ static_library("ui") {
"//ui/chromeos",
"//ui/chromeos/events",
"//ui/compositor_extra",
+ "//ui/events/ozone/layout:layout",
"//ui/file_manager:file_manager",
"//ui/ozone",
]
@@ -2720,17 +2805,33 @@ static_library("ui") {
}
}
- # TODO(crbug.com/1052397): Rename GN variable. This is the lacros browser.
- if (chromeos_is_browser_only) {
+ if (is_chromeos_ash || is_chromeos_lacros) {
+ sources += [
+ "views/frame/browser_frame_header_chromeos.cc",
+ "views/frame/browser_frame_header_chromeos.h",
+ "views/frame/browser_non_client_frame_view_chromeos.cc",
+ "views/frame/browser_non_client_frame_view_chromeos.h",
+ "views/frame/browser_non_client_frame_view_factory_chromeos.cc",
+ "views/frame/top_controls_slide_controller_chromeos.cc",
+ "views/frame/top_controls_slide_controller_chromeos.h",
+ ]
+ deps += [ "//components/account_manager_core:account_manager_core" ]
+ }
+
+ if (is_chromeos_lacros) {
sources += [
"views/chrome_browser_main_extra_parts_views_lacros.cc",
"views/chrome_browser_main_extra_parts_views_lacros.h",
+ "views/frame/browser_frame_lacros.cc",
+ "views/frame/browser_frame_lacros.h",
"views/frame/immersive_mode_controller_chromeos.cc",
"views/frame/immersive_mode_controller_chromeos.h",
"window_sizer/window_sizer_chromeos.cc",
"window_sizer/window_sizer_chromeos.h",
]
deps += [
+ "//chromeos/crosapi/mojom",
+ "//chromeos/lacros",
"//chromeos/ui/base",
"//chromeos/ui/frame",
]
@@ -2773,12 +2874,8 @@ static_library("ui") {
"views/close_bubble_on_tab_activation_helper.h",
"views/external_protocol_dialog.cc",
"views/external_protocol_dialog.h",
- "views/hats/hats_bubble_view.cc",
- "views/hats/hats_bubble_view.h",
"views/hats/hats_next_web_dialog.cc",
"views/hats/hats_next_web_dialog.h",
- "views/hats/hats_web_dialog.cc",
- "views/hats/hats_web_dialog.h",
"views/profiles/incognito_menu_view.cc",
"views/profiles/incognito_menu_view.h",
"views/profiles/profile_menu_view.cc",
@@ -2807,7 +2904,7 @@ static_library("ui") {
deps += [ "//ui/webui" ]
}
- if (is_win || is_mac || is_linux) {
+ if (is_win || is_mac || (is_linux || is_chromeos_lacros)) {
sources += [
"bookmarks/bookmark_bubble_sign_in_delegate.cc",
"bookmarks/bookmark_bubble_sign_in_delegate.h",
@@ -2822,16 +2919,16 @@ static_library("ui") {
"sync/one_click_signin_links_delegate.h",
"sync/one_click_signin_links_delegate_impl.cc",
"sync/one_click_signin_links_delegate_impl.h",
- "user_manager.cc",
- "user_manager.h",
"views/profiles/badged_profile_photo.cc",
"views/profiles/badged_profile_photo.h",
+ "views/profiles/profile_picker_force_signin_dialog_delegate.cc",
+ "views/profiles/profile_picker_force_signin_dialog_delegate.h",
+ "views/profiles/profile_picker_force_signin_dialog_host.cc",
+ "views/profiles/profile_picker_force_signin_dialog_host.h",
"views/profiles/profile_picker_view.cc",
"views/profiles/profile_picker_view.h",
"views/profiles/profile_picker_view_sync_delegate.cc",
"views/profiles/profile_picker_view_sync_delegate.h",
- "views/profiles/user_manager_view.cc",
- "views/profiles/user_manager_view.h",
"webui/app_launcher_page_ui.cc",
"webui/app_launcher_page_ui.h",
"webui/browser_switch/browser_switch_ui.cc",
@@ -2852,8 +2949,6 @@ static_library("ui") {
"webui/signin/profile_picker_handler.h",
"webui/signin/profile_picker_ui.cc",
"webui/signin/profile_picker_ui.h",
- "webui/signin/signin_create_profile_handler.cc",
- "webui/signin/signin_create_profile_handler.h",
"webui/signin/signin_email_confirmation_dialog.cc",
"webui/signin/signin_email_confirmation_dialog.h",
"webui/signin/signin_email_confirmation_ui.cc",
@@ -2866,12 +2961,10 @@ static_library("ui") {
"webui/signin/signin_reauth_handler.h",
"webui/signin/signin_reauth_ui.cc",
"webui/signin/signin_reauth_ui.h",
+ "webui/signin/signin_ui_error.cc",
+ "webui/signin/signin_ui_error.h",
"webui/signin/signin_utils_desktop.cc",
"webui/signin/signin_utils_desktop.h",
- "webui/signin/user_manager_screen_handler.cc",
- "webui/signin/user_manager_screen_handler.h",
- "webui/signin/user_manager_ui.cc",
- "webui/signin/user_manager_ui.h",
"webui/welcome/bookmark_handler.cc",
"webui/welcome/bookmark_handler.h",
"webui/welcome/bookmark_item.cc",
@@ -2892,14 +2985,20 @@ static_library("ui") {
"webui/welcome/welcome_ui.h",
]
- deps += [ "//components/country_codes" ]
+ deps += [
+ "//chrome/common/search:generate_colors_info",
+ "//components/country_codes",
+ ]
if (enable_dice_support) {
sources += [
"signin/dice_web_signin_interceptor_delegate.cc",
"signin/dice_web_signin_interceptor_delegate.h",
+ "signin/profile_customization_bubble_sync_controller.h",
"views/profiles/dice_web_signin_interception_bubble_view.cc",
"views/profiles/dice_web_signin_interception_bubble_view.h",
+ "views/profiles/profile_customization_bubble_sync_controller.cc",
+ "views/profiles/profile_customization_bubble_sync_controller.h",
"views/profiles/profile_customization_bubble_view.cc",
"views/profiles/profile_customization_bubble_view.h",
"webui/signin/dice_turn_sync_on_helper.cc",
@@ -3018,8 +3117,6 @@ static_library("ui") {
"cocoa/main_menu_item.h",
"cocoa/native_window_tracker_cocoa.h",
"cocoa/native_window_tracker_cocoa.mm",
- "cocoa/nsmenuitem_additions.h",
- "cocoa/nsmenuitem_additions.mm",
"cocoa/profiles/profile_menu_controller.h",
"cocoa/profiles/profile_menu_controller.mm",
"cocoa/renderer_context_menu/render_view_context_menu_mac.h",
@@ -3030,6 +3127,13 @@ static_library("ui") {
"cocoa/rosetta_required_infobar_delegate.mm",
"cocoa/scoped_menu_bar_lock.h",
"cocoa/scoped_menu_bar_lock.mm",
+ "cocoa/screentime/fake_webpage_controller.h",
+ "cocoa/screentime/fake_webpage_controller.mm",
+ "cocoa/screentime/tab_helper.h",
+ "cocoa/screentime/tab_helper.mm",
+ "cocoa/screentime/webpage_controller.h",
+ "cocoa/screentime/webpage_controller_impl.h",
+ "cocoa/screentime/webpage_controller_impl.mm",
"cocoa/share_menu_controller.h",
"cocoa/share_menu_controller.mm",
"cocoa/simple_message_box_cocoa.h",
@@ -3059,8 +3163,6 @@ static_library("ui") {
"content_settings/media_authorization_wrapper_test.h",
"content_settings/media_authorization_wrapper_test.mm",
"find_bar/find_bar_platform_helper_mac.mm",
- "startup/mac_system_infobar_delegate.cc",
- "startup/mac_system_infobar_delegate.h",
"views/apps/chrome_app_window_client_views_mac.mm",
"views/certificate_viewer_mac_views.mm",
"views/dropdown_bar_host_mac.mm",
@@ -3076,7 +3178,7 @@ static_library("ui") {
"views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm",
"webui/help/version_updater_mac.h",
"webui/help/version_updater_mac.mm",
- "webui/settings_utils_mac.mm",
+ "webui/settings/settings_utils_mac.mm",
"window_sizer/window_sizer_mac.mm",
]
@@ -3097,6 +3199,7 @@ static_library("ui") {
"Carbon.framework",
"Quartz.framework",
]
+ weak_frameworks = [ "ScreenTime.framework" ]
if (enable_chromium_updater) {
deps += [
@@ -3178,11 +3281,11 @@ static_library("ui") {
"webui/conflicts/conflicts_ui.h",
"webui/settings/chrome_cleanup_handler_win.cc",
"webui/settings/chrome_cleanup_handler_win.h",
- "webui/settings_utils_win.cc",
- "webui/version_handler_win.cc",
- "webui/version_handler_win.h",
- "webui/version_util_win.cc",
- "webui/version_util_win.h",
+ "webui/settings/settings_utils_win.cc",
+ "webui/version/version_handler_win.cc",
+ "webui/version/version_handler_win.h",
+ "webui/version/version_util_win.cc",
+ "webui/version/version_util_win.h",
]
public_deps += [
"//ui/views",
@@ -3194,6 +3297,7 @@ static_library("ui") {
"//chrome/browser/win/conflicts:module_info",
"//chrome/credential_provider/common:common_constants",
"//chrome/services/util_win/public/mojom:mojom",
+ "//components/lens",
"//components/search_engines",
"//third_party/iaccessible2",
"//third_party/isimpledom",
@@ -3233,7 +3337,7 @@ static_library("ui") {
}
}
- if (is_linux) {
+ if (is_linux || is_chromeos_lacros) {
sources += [
"views/apps/chrome_app_window_client_views_linux.cc",
"views/first_run_dialog.cc",
@@ -3247,7 +3351,7 @@ static_library("ui") {
"views/status_icons/status_icon_linux_wrapper.h",
"webui/help/version_updater_basic.cc",
"webui/help/version_updater_basic.h",
- "webui/settings_utils_linux.cc",
+ "webui/settings/settings_utils_linux.cc",
]
deps += [
"//ui/base:wm_role_names",
@@ -3290,7 +3394,7 @@ static_library("ui") {
]
}
if (use_ozone) {
- if (!is_linux) {
+ if (!is_linux && !is_chromeos_lacros) {
sources += [
"views/frame/browser_desktop_window_tree_host_platform.cc",
"views/frame/browser_desktop_window_tree_host_platform.h",
@@ -3298,12 +3402,18 @@ static_library("ui") {
}
sources += [ "views/frame/native_browser_frame_factory_ozone.cc" ]
}
- if (is_linux) {
+ if (is_linux || is_chromeos_lacros) {
sources += [
"views/frame/browser_desktop_window_tree_host_linux.cc",
"views/frame/browser_desktop_window_tree_host_linux.h",
]
}
+ if (is_chromeos_lacros) {
+ sources += [
+ "views/frame/browser_desktop_window_tree_host_lacros.cc",
+ "views/frame/browser_desktop_window_tree_host_lacros.h",
+ ]
+ }
if (use_gtk) {
# This is the only component that can interact with gtk.
deps += [ "//ui/gtk" ]
@@ -3319,8 +3429,8 @@ static_library("ui") {
"webui/certificate_viewer_ui.h",
"webui/certificate_viewer_webui.cc",
"webui/certificate_viewer_webui.h",
- "webui/webui_js_exception/webui_js_exception_ui.cc",
- "webui/webui_js_exception/webui_js_exception_ui.h",
+ "webui/webui_js_error/webui_js_error_ui.cc",
+ "webui/webui_js_error/webui_js_error_ui.h",
]
if (use_aura) {
deps += [ "//third_party/fontconfig" ]
@@ -3329,9 +3439,9 @@ static_library("ui") {
if (toolkit_views) {
sources += [
- "autofill/address_profiles/save_address_profile_bubble_controller.cc",
- "autofill/address_profiles/save_address_profile_bubble_controller.h",
- "autofill/payments/local_card_migration_bubble.h",
+ "autofill/autofill_bubble_base.h",
+ "autofill/autofill_bubble_controller_base.cc",
+ "autofill/autofill_bubble_controller_base.h",
"autofill/payments/local_card_migration_bubble_controller_impl.cc",
"autofill/payments/local_card_migration_bubble_controller_impl.h",
"autofill/payments/local_card_migration_controller_observer.h",
@@ -3342,10 +3452,12 @@ static_library("ui") {
"autofill/payments/local_card_migration_dialog_state.h",
"autofill/payments/manage_migration_ui_controller.cc",
"autofill/payments/manage_migration_ui_controller.h",
+ "autofill/payments/offer_notification_bubble_controller.h",
+ "autofill/payments/offer_notification_bubble_controller_impl.cc",
+ "autofill/payments/offer_notification_bubble_controller_impl.h",
"autofill/payments/save_card_bubble_controller.h",
"autofill/payments/save_card_bubble_controller_impl.cc",
"autofill/payments/save_card_bubble_controller_impl.h",
- "autofill/payments/save_card_bubble_view.h",
"autofill/payments/save_card_ui.h",
"autofill/payments/save_payment_icon_controller.cc",
"autofill/payments/save_payment_icon_controller.h",
@@ -3353,6 +3465,11 @@ static_library("ui") {
"autofill/payments/save_upi_bubble_controller.h",
"autofill/payments/save_upi_bubble_controller_impl.cc",
"autofill/payments/save_upi_bubble_controller_impl.h",
+ "autofill/save_address_profile_bubble_controller.h",
+ "autofill/save_address_profile_bubble_controller_impl.cc",
+ "autofill/save_address_profile_bubble_controller_impl.h",
+ "autofill/save_address_profile_icon_controller.cc",
+ "autofill/save_address_profile_icon_controller.h",
"bubble_anchor_util.h",
"manifest_web_app_browser_controller.cc",
"manifest_web_app_browser_controller.h",
@@ -3374,10 +3491,10 @@ static_library("ui") {
"views/accessibility/caption_bubble_model.h",
"views/accessibility/caret_browsing_dialog_delegate.cc",
"views/accessibility/caret_browsing_dialog_delegate.h",
- "views/accessibility/invert_bubble_view.cc",
- "views/accessibility/invert_bubble_view.h",
"views/accessibility/non_accessible_image_view.cc",
"views/accessibility/non_accessible_image_view.h",
+ "views/accessibility/theme_tracking_non_accessible_image_view.cc",
+ "views/accessibility/theme_tracking_non_accessible_image_view.h",
"views/apps/app_dialog/app_dialog_view.cc",
"views/apps/app_dialog/app_dialog_view.h",
"views/apps/app_dialog/app_uninstall_dialog_view.cc",
@@ -3400,8 +3517,6 @@ static_library("ui") {
"views/apps/app_info_dialog/app_info_summary_panel.h",
"views/apps/chrome_native_app_window_views.cc",
"views/apps/chrome_native_app_window_views.h",
- "views/autofill/address_profiles/save_address_profile_view.cc",
- "views/autofill/address_profiles/save_address_profile_view.h",
"views/autofill/autofill_bubble_handler_impl.cc",
"views/autofill/autofill_bubble_handler_impl.h",
"views/autofill/autofill_popup_base_view.cc",
@@ -3423,6 +3538,10 @@ static_library("ui") {
"views/autofill/payments/local_card_migration_icon_view.h",
"views/autofill/payments/migratable_card_view.cc",
"views/autofill/payments/migratable_card_view.h",
+ "views/autofill/payments/offer_notification_bubble_views.cc",
+ "views/autofill/payments/offer_notification_bubble_views.h",
+ "views/autofill/payments/offer_notification_icon_view.cc",
+ "views/autofill/payments/offer_notification_icon_view.h",
"views/autofill/payments/payments_view_util.cc",
"views/autofill/payments/payments_view_util.h",
"views/autofill/payments/save_card_bubble_views.cc",
@@ -3433,12 +3552,14 @@ static_library("ui") {
"views/autofill/payments/save_card_manage_cards_bubble_views.h",
"views/autofill/payments/save_card_offer_bubble_views.cc",
"views/autofill/payments/save_card_offer_bubble_views.h",
- "views/autofill/payments/save_card_sign_in_promo_bubble_views.cc",
- "views/autofill/payments/save_card_sign_in_promo_bubble_views.h",
"views/autofill/payments/save_payment_icon_view.cc",
"views/autofill/payments/save_payment_icon_view.h",
"views/autofill/payments/save_upi_offer_bubble_views.cc",
"views/autofill/payments/save_upi_offer_bubble_views.h",
+ "views/autofill/save_address_profile_icon_view.cc",
+ "views/autofill/save_address_profile_icon_view.h",
+ "views/autofill/save_address_profile_view.cc",
+ "views/autofill/save_address_profile_view.h",
"views/bookmarks/bookmark_bar_view.cc",
"views/bookmarks/bookmark_bar_view.h",
"views/bookmarks/bookmark_bar_view_observer.h",
@@ -3456,12 +3577,16 @@ static_library("ui") {
"views/bookmarks/bookmark_menu_delegate.h",
"views/browser_commands_views.cc",
"views/browser_dialogs_views.cc",
+ "views/bubble/bubble_contents_wrapper.cc",
+ "views/bubble/bubble_contents_wrapper.h",
+ "views/bubble/bubble_contents_wrapper_service.cc",
+ "views/bubble/bubble_contents_wrapper_service.h",
+ "views/bubble/bubble_contents_wrapper_service_factory.cc",
+ "views/bubble/bubble_contents_wrapper_service_factory.h",
"views/bubble/webui_bubble_dialog_view.cc",
"views/bubble/webui_bubble_dialog_view.h",
"views/bubble/webui_bubble_manager.cc",
"views/bubble/webui_bubble_manager.h",
- "views/bubble/webui_bubble_view.cc",
- "views/bubble/webui_bubble_view.h",
"views/bubble_anchor_util_views.cc",
"views/bubble_anchor_util_views.h",
"views/bubble_menu_item_factory.cc",
@@ -3509,6 +3634,8 @@ static_library("ui") {
"views/desktop_capture/desktop_media_source_view.h",
"views/desktop_capture/desktop_media_tab_list.cc",
"views/desktop_capture/desktop_media_tab_list.h",
+ "views/desktop_capture/get_current_browsing_context_media_dialog.cc",
+ "views/desktop_capture/get_current_browsing_context_media_dialog.h",
"views/device_chooser_content_view.cc",
"views/device_chooser_content_view.h",
"views/devtools_process_observer.cc",
@@ -3557,6 +3684,16 @@ static_library("ui") {
"views/extensions/extensions_toolbar_button.h",
"views/extensions/extensions_toolbar_container.cc",
"views/extensions/extensions_toolbar_container.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",
+ "views/file_system_access/file_system_access_permission_view.h",
+ "views/file_system_access/file_system_access_restricted_directory_dialog_view.cc",
+ "views/file_system_access/file_system_access_restricted_directory_dialog_view.h",
+ "views/file_system_access/file_system_access_ui_helpers.cc",
+ "views/file_system_access/file_system_access_ui_helpers.h",
+ "views/file_system_access/file_system_access_usage_bubble_view.cc",
+ "views/file_system_access/file_system_access_usage_bubble_view.h",
"views/find_bar_host.cc",
"views/find_bar_host.h",
"views/find_bar_view.cc",
@@ -3683,6 +3820,8 @@ static_library("ui") {
"views/location_bar/location_bar_view.h",
"views/location_bar/location_icon_view.cc",
"views/location_bar/location_icon_view.h",
+ "views/location_bar/omnibox_chip_button.cc",
+ "views/location_bar/omnibox_chip_button.h",
"views/location_bar/permission_chip.cc",
"views/location_bar/permission_chip.h",
"views/location_bar/selected_keyword_view.cc",
@@ -3725,16 +3864,6 @@ static_library("ui") {
"views/media_router/web_contents_display_observer_view.h",
"views/message_box_dialog.cc",
"views/message_box_dialog.h",
- "views/native_file_system/native_file_system_access_icon_view.cc",
- "views/native_file_system/native_file_system_access_icon_view.h",
- "views/native_file_system/native_file_system_permission_view.cc",
- "views/native_file_system/native_file_system_permission_view.h",
- "views/native_file_system/native_file_system_restricted_directory_dialog_view.cc",
- "views/native_file_system/native_file_system_restricted_directory_dialog_view.h",
- "views/native_file_system/native_file_system_ui_helpers.cc",
- "views/native_file_system/native_file_system_ui_helpers.h",
- "views/native_file_system/native_file_system_usage_bubble_view.cc",
- "views/native_file_system/native_file_system_usage_bubble_view.h",
"views/omnibox/omnibox_match_cell_view.cc",
"views/omnibox/omnibox_match_cell_view.h",
"views/omnibox/omnibox_mouse_enter_exit_handler.cc",
@@ -3845,6 +3974,8 @@ static_library("ui") {
"views/payments/error_message_view_controller.h",
"views/payments/order_summary_view_controller.cc",
"views/payments/order_summary_view_controller.h",
+ "views/payments/payment_credential_enrollment_dialog_view.cc",
+ "views/payments/payment_credential_enrollment_dialog_view.h",
"views/payments/payment_handler_modal_dialog_manager_delegate.cc",
"views/payments/payment_handler_modal_dialog_manager_delegate.h",
"views/payments/payment_handler_web_flow_view_controller.cc",
@@ -3868,7 +3999,8 @@ static_library("ui") {
"views/payments/profile_list_view_controller.h",
"views/payments/secure_payment_confirmation_dialog_view.cc",
"views/payments/secure_payment_confirmation_dialog_view.h",
- "views/payments/secure_payment_confirmation_view.cc",
+ "views/payments/secure_payment_confirmation_views_util.cc",
+ "views/payments/secure_payment_confirmation_views_util.h",
"views/payments/shipping_address_editor_view_controller.cc",
"views/payments/shipping_address_editor_view_controller.h",
"views/payments/shipping_option_view_controller.cc",
@@ -4021,6 +4153,14 @@ static_library("ui") {
"views/toolbar/browser_actions_container.h",
"views/toolbar/browser_app_menu_button.cc",
"views/toolbar/browser_app_menu_button.h",
+ "views/toolbar/chrome_labs_bubble_view.cc",
+ "views/toolbar/chrome_labs_bubble_view.h",
+ "views/toolbar/chrome_labs_bubble_view_model.cc",
+ "views/toolbar/chrome_labs_bubble_view_model.h",
+ "views/toolbar/chrome_labs_button.cc",
+ "views/toolbar/chrome_labs_button.h",
+ "views/toolbar/chrome_labs_item_view.cc",
+ "views/toolbar/chrome_labs_item_view.h",
"views/toolbar/extension_toolbar_menu_view.cc",
"views/toolbar/extension_toolbar_menu_view.h",
"views/toolbar/home_button.cc",
@@ -4064,18 +4204,28 @@ static_library("ui") {
"views/user_education/feature_promo_registry.h",
"views/user_education/new_badge_label.cc",
"views/user_education/new_badge_label.h",
+ "views/user_education/tip_marquee_view.cc",
+ "views/user_education/tip_marquee_view.h",
+ "views/web_apps/frame_toolbar/web_app_content_settings_container.cc",
+ "views/web_apps/frame_toolbar/web_app_content_settings_container.h",
+ "views/web_apps/frame_toolbar/web_app_frame_toolbar_utils.cc",
+ "views/web_apps/frame_toolbar/web_app_frame_toolbar_utils.h",
+ "views/web_apps/frame_toolbar/web_app_frame_toolbar_view.cc",
+ "views/web_apps/frame_toolbar/web_app_frame_toolbar_view.h",
+ "views/web_apps/frame_toolbar/web_app_menu_button.cc",
+ "views/web_apps/frame_toolbar/web_app_menu_button.h",
+ "views/web_apps/frame_toolbar/web_app_navigation_button_container.cc",
+ "views/web_apps/frame_toolbar/web_app_navigation_button_container.h",
+ "views/web_apps/frame_toolbar/web_app_origin_text.cc",
+ "views/web_apps/frame_toolbar/web_app_origin_text.h",
+ "views/web_apps/frame_toolbar/web_app_toolbar_button_container.cc",
+ "views/web_apps/frame_toolbar/web_app_toolbar_button_container.h",
"views/web_apps/pwa_confirmation_bubble_view.cc",
"views/web_apps/pwa_confirmation_bubble_view.h",
"views/web_apps/web_app_confirmation_view.cc",
"views/web_apps/web_app_confirmation_view.h",
- "views/web_apps/web_app_frame_toolbar_view.cc",
- "views/web_apps/web_app_frame_toolbar_view.h",
"views/web_apps/web_app_info_image_source.cc",
"views/web_apps/web_app_info_image_source.h",
- "views/web_apps/web_app_menu_button.cc",
- "views/web_apps/web_app_menu_button.h",
- "views/web_apps/web_app_origin_text.cc",
- "views/web_apps/web_app_origin_text.h",
"views/web_apps/web_app_uninstall_dialog_view.cc",
"views/web_apps/web_app_uninstall_dialog_view.h",
"views/webauthn/authenticator_bio_enrollment_sheet_view.cc",
@@ -4084,6 +4234,8 @@ static_library("ui") {
"views/webauthn/authenticator_client_pin_entry_sheet_view.h",
"views/webauthn/authenticator_client_pin_entry_view.cc",
"views/webauthn/authenticator_client_pin_entry_view.h",
+ "views/webauthn/authenticator_paask_sheet_view.cc",
+ "views/webauthn/authenticator_paask_sheet_view.h",
"views/webauthn/authenticator_qr_sheet_view.cc",
"views/webauthn/authenticator_qr_sheet_view.h",
"views/webauthn/authenticator_request_dialog_view.cc",
@@ -4100,8 +4252,16 @@ static_library("ui") {
"views/webauthn/ring_progress_bar.h",
"views/webauthn/sheet_view_factory.cc",
"views/webauthn/sheet_view_factory.h",
+ "views/webauthn/webauthn_bubble_view.cc",
+ "views/webauthn/webauthn_bubble_view.h",
"views/webauthn/webauthn_hover_button.cc",
"views/webauthn/webauthn_hover_button.h",
+ "views/webauthn/webauthn_icon_view.cc",
+ "views/webauthn/webauthn_icon_view.h",
+ "views/webid/webid_permission_dialog.cc",
+ "views/webid/webid_permission_dialog.h",
+ "views/webid/webid_signin_window.cc",
+ "views/webid/webid_signin_window.h",
"views/window_name_prompt.cc",
"webauthn/account_hover_list_model.cc",
"webauthn/account_hover_list_model.h",
@@ -4116,31 +4276,35 @@ static_library("ui") {
"webauthn/transport_hover_list_model.h",
"webauthn/transport_utils.cc",
"webauthn/transport_utils.h",
+ "webauthn/webauthn_ui_helpers.cc",
+ "webauthn/webauthn_ui_helpers.h",
]
deps += [
"//base",
"//base/util/timer",
"//chrome/browser/ui/views",
- "//chrome/common/qr_code_generator",
"//components/constrained_window",
"//components/content_settings/browser/ui",
"//components/media_message_center",
"//components/page_info",
"//components/payments/content",
+ "//components/payments/content:utils",
"//components/payments/core",
+ "//components/qr_code_generator",
"//components/reading_list/features:flags",
"//components/tab_count_metrics",
"//components/ui_devtools/views",
"//device/vr/buildflags:buildflags",
"//services/media_session/public/mojom",
- "//ui/base/dragdrop/mojom:mojom_shared",
+ "//ui/gfx/geometry",
"//ui/views:buildflags",
]
+ public_deps += [ "//ui/base/dragdrop/mojom:mojom_headers" ]
allow_circular_includes_from += [ "//chrome/browser/ui/views" ]
- if (is_linux) {
+ if (is_linux || is_chromeos_lacros) {
sources += [
"views/chrome_views_delegate_linux.cc",
"views/frame/desktop_linux_browser_frame_view.cc",
@@ -4189,10 +4353,14 @@ static_library("ui") {
}
if (is_win) {
- sources += [ "views/chrome_views_delegate_win.cc" ]
+ sources += [
+ "accessibility_util.h",
+ "views/accessibility/accessibility_util.cc",
+ "views/chrome_views_delegate_win.cc",
+ ]
}
- if (is_win || is_linux) {
+ if (is_win || (is_linux || is_chromeos_lacros)) {
sources += [
"views/native_widget_factory.cc",
"views/native_widget_factory.h",
@@ -4201,7 +4369,7 @@ static_library("ui") {
if (use_aura) {
# These files can do Gtk+-based theming for builds with gtk enabled.
- if (is_linux) {
+ if (is_linux || is_chromeos_lacros) {
sources += [
"views/chrome_browser_main_extra_parts_views_linux.cc",
"views/chrome_browser_main_extra_parts_views_linux.h",
@@ -4224,7 +4392,7 @@ static_library("ui") {
}
}
- if (!is_chromeos) {
+ if (!is_chromeos_ash) {
sources += [
"views/accessibility/accessibility_focus_highlight.cc",
"views/accessibility/accessibility_focus_highlight.h",
@@ -4296,9 +4464,13 @@ static_library("ui") {
"//ui/wm",
]
- if (!is_chromeos) {
+ if (!is_chromeos_ash && !is_chromeos_lacros) {
+ sources +=
+ [ "views/frame/browser_non_client_frame_view_factory_views.cc" ]
+ }
+
+ if (!is_chromeos_ash) {
sources += [
- "views/frame/browser_non_client_frame_view_factory_views.cc",
"views/frame/desktop_browser_frame_aura.cc",
"views/frame/desktop_browser_frame_aura.h",
]
@@ -4318,10 +4490,12 @@ static_library("ui") {
"//chrome/browser/apps/platform_apps", # TODO(loyso): Remove this dep.
"//chrome/browser/apps/platform_apps/api",
"//chrome/browser/extensions",
+ "//chrome/browser/web_share_target",
"//chrome/common/extensions/api",
"//components/drive",
"//components/guest_view/browser",
"//extensions/browser",
+ "//extensions/browser/api/management",
"//extensions/common:mojom",
"//extensions/components/native_app_window",
"//extensions/strings",
@@ -4393,6 +4567,8 @@ static_library("ui") {
"views/extensions/settings_overridden_dialog_view.h",
"web_applications/app_browser_controller.cc",
"web_applications/app_browser_controller.h",
+ "web_applications/share_target_utils.cc",
+ "web_applications/share_target_utils.h",
"web_applications/system_web_app_ui_utils.cc",
"web_applications/system_web_app_ui_utils.h",
"web_applications/web_app_browser_controller.cc",
@@ -4411,6 +4587,8 @@ static_library("ui") {
"web_applications/web_app_metrics.h",
"web_applications/web_app_metrics_factory.cc",
"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_ui_manager_impl.cc",
"web_applications/web_app_ui_manager_impl.h",
"web_applications/web_app_uninstall_dialog.h",
@@ -4480,16 +4658,21 @@ static_library("ui") {
"webui/print_preview/printer_handler.h",
]
deps += [
+ "//chrome/common/printing:printing",
+ "//chrome/services/printing/public/mojom",
"//components/printing/common:mojo_interfaces",
+ "//components/services/print_compositor/public/mojom",
"//printing/mojom",
"//services/device/public/cpp/usb",
"//services/device/public/mojom:usb",
]
- if (is_chromeos) {
+ if (is_chromeos_ash) {
sources += [
"webui/print_preview/local_printer_handler_chromeos.cc",
"webui/print_preview/local_printer_handler_chromeos.h",
+ "webui/print_preview/print_preview_handler_chromeos.cc",
+ "webui/print_preview/print_preview_handler_chromeos.h",
]
} else {
sources += [
@@ -4504,7 +4687,7 @@ static_library("ui") {
"webui/print_preview/privet_printer_handler.h",
]
- if (!is_chromeos) {
+ if (!is_chromeos_ash) {
deps += [ "//chrome/common:service_process_mojom" ]
}
}
@@ -4514,8 +4697,8 @@ static_library("ui") {
deps += [
"//chrome/browser/ui/webui/reset_password:mojo_bindings",
"//chrome/common/safe_browsing:proto",
- "//components/safe_browsing/content/password_protection:password_protection_metrics_util",
"//components/safe_browsing/core:csd_proto",
+ "//components/safe_browsing/core/password_protection:password_protection_metrics_util",
]
}
@@ -4556,7 +4739,7 @@ static_library("ui") {
}
if (enable_webui_tab_strip) {
- deps += [ "//chrome/browser/resources/tab_strip:tab_strip_resources" ]
+ deps += [ "//chrome/browser/resources/tab_strip:resources" ]
sources += [
"views/frame/webui_tab_strip_container_view.cc",
@@ -4603,9 +4786,11 @@ static_library("test_support") {
]
public_deps = [ ":ui" ]
deps = [
+ "//build:chromeos_buildflags",
"//chrome/app/theme:theme_resources",
"//chrome/browser",
"//chrome/browser/devtools",
+ "//chrome/browser/profiles:profile",
"//components/omnibox/browser",
"//components/password_manager/core/browser",
"//components/payments/content",
@@ -4699,7 +4884,7 @@ static_library("test_support") {
]
}
- if (is_chromeos) {
+ if (is_chromeos_ash) {
sources += [
"ash/ash_test_util.cc",
"ash/ash_test_util.h",
@@ -4730,7 +4915,7 @@ static_library("test_support") {
}
}
-if (is_chromeos) {
+if (is_chromeos_ash) {
source_set("ash_test_support") {
check_includes = false
sources = [
diff --git a/chromium/chrome/browser/ui/android/appmenu/BUILD.gn b/chromium/chrome/browser/ui/android/appmenu/BUILD.gn
index d35c204280f..77e1eeec46b 100644
--- a/chromium/chrome/browser/ui/android/appmenu/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/appmenu/BUILD.gn
@@ -20,7 +20,7 @@ android_library("java") {
]
deps = [
"//chrome/browser/android/lifecycle:java",
- "//third_party/android_deps:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
]
resources_package = "org.chromium.chrome.browser.ui.appmenu"
}
diff --git a/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn b/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
index a677a598fc8..c6e18f19c14 100644
--- a/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
@@ -30,8 +30,8 @@ android_library("java") {
"//chrome/browser/ui/android/appmenu:java",
"//components/browser_ui/widget/android:java",
"//third_party/android_deps:android_support_v7_appcompat_java",
- "//third_party/android_deps:androidx_annotation_annotation_java",
- "//third_party/android_deps:androidx_appcompat_appcompat_resources_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_appcompat_appcompat_resources_java",
"//ui/android:ui_java",
]
resources_package = "org.chromium.chrome.browser.ui.appmenu.internal"
@@ -81,11 +81,11 @@ android_library("javatests") {
"//components/browser_ui/widget/android:test_support_java",
"//content/public/test/android:content_java_test_support",
"//third_party/android_deps:android_support_v7_appcompat_java",
- "//third_party/android_deps:androidx_annotation_annotation_java",
- "//third_party/android_deps:androidx_appcompat_appcompat_resources_java",
- "//third_party/android_deps:androidx_test_runner_java",
"//third_party/android_support_test_runner:rules_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_test_runner_java",
"//third_party/junit",
"//third_party/mockito:mockito_java",
"//ui/android:ui_full_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 186177a2231..50f19bbd013 100644
--- a/chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn
@@ -7,37 +7,22 @@ import("//build/config/android/rules.gni")
android_library("java") {
sources = [
"java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoDeps.java",
- "java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoDialog.java",
"java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoManager.java",
"java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoMetrics.java",
"java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoUtils.java",
]
deps = [
- ":java_resources",
"//base:base_java",
"//chrome/browser/android/lifecycle:java",
"//chrome/browser/flags:java",
"//chrome/browser/preferences:java",
"//chrome/browser/profiles/android:java",
- "//components/browser_ui/widget/android:java",
- "//third_party/android_deps:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
"//ui/android:ui_full_java",
]
resources_package = "org.chromium.chrome.browser.ui.default_browser_promo"
}
-android_resources("java_resources") {
- sources = [
- "java/res/drawable/default_browser_promo_illustration.xml",
- "java/res/drawable/ic_illustration_aroundlogo.xml",
- ]
- deps = [
- "//chrome/browser/ui/android/strings:ui_strings_grd",
- "//components/browser_ui/widget/android:java_resources",
- "//ui/android:ui_java_resources",
- ]
-}
-
java_library("junit") {
# Skip platform checks since Robolectric depends on requires_android targets.
bypass_platform_checks = true
@@ -52,30 +37,3 @@ java_library("junit") {
"//third_party/mockito:mockito_java",
]
}
-
-android_library("javatests") {
- testonly = true
-
- sources = [ "java/src/org/chromium/chrome/browser/ui/default_browser_promo/DefaultBrowserPromoManagerTest.java" ]
-
- deps = [
- ":java",
- "//base:base_java",
- "//base:base_java_test_support",
- "//chrome/browser/android/lifecycle:java",
- "//chrome/browser/flags:java",
- "//chrome/test/android:chrome_java_test_support",
- "//components/browser_ui/widget/android:java",
- "//content/public/test/android:content_java_test_support",
- "//third_party/android_deps:android_support_v7_appcompat_java",
- "//third_party/android_deps:androidx_preference_preference_java",
- "//third_party/android_deps:androidx_test_runner_java",
- "//third_party/android_deps:espresso_java",
- "//third_party/android_support_test_runner:rules_java",
- "//third_party/android_support_test_runner:runner_java",
- "//third_party/hamcrest:hamcrest_java",
- "//third_party/junit:junit",
- "//ui/android:ui_full_java",
- "//ui/android:ui_java_test_support",
- ]
-}
diff --git a/chromium/chrome/browser/ui/android/favicon/BUILD.gn b/chromium/chrome/browser/ui/android/favicon/BUILD.gn
index 5197d6777a8..443859bcdb2 100644
--- a/chromium/chrome/browser/ui/android/favicon/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/favicon/BUILD.gn
@@ -21,8 +21,8 @@ android_library("java") {
"//components/embedder_support/android:util_java",
"//components/url_formatter/android:url_formatter_java",
"//content/public/android:content_java",
- "//third_party/android_deps:androidx_annotation_annotation_java",
- "//third_party/android_deps:androidx_core_core_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_core_core_java",
"//ui/android:ui_java",
"//url:gurl_java",
]
diff --git a/chromium/chrome/browser/ui/android/layouts/BUILD.gn b/chromium/chrome/browser/ui/android/layouts/BUILD.gn
index a85bb82ab12..de0417084a3 100644
--- a/chromium/chrome/browser/ui/android/layouts/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/layouts/BUILD.gn
@@ -9,6 +9,7 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/layouts/CompositorModelChangeProcessor.java",
"java/src/org/chromium/chrome/browser/layouts/EventFilter.java",
"java/src/org/chromium/chrome/browser/layouts/LayoutManager.java",
+ "java/src/org/chromium/chrome/browser/layouts/LayoutManagerProvider.java",
"java/src/org/chromium/chrome/browser/layouts/LayoutStateProvider.java",
"java/src/org/chromium/chrome/browser/layouts/LayoutType.java",
"java/src/org/chromium/chrome/browser/layouts/SceneOverlay.java",
@@ -26,7 +27,7 @@ android_library("java") {
"//base:base_java",
"//base:jni_java",
"//components/browser_ui/widget/android:java",
- "//third_party/android_deps:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
"//ui/android:ui_java",
]
}
diff --git a/chromium/chrome/browser/ui/android/layouts/glue/BUILD.gn b/chromium/chrome/browser/ui/android/layouts/glue/BUILD.gn
new file mode 100644
index 00000000000..c930761756d
--- /dev/null
+++ b/chromium/chrome/browser/ui/android/layouts/glue/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+import("//build/config/android/rules.gni")
+
+android_library("java") {
+ visibility = [
+ ":*",
+ "//chrome/android:chrome_java",
+ ]
+
+ sources = [
+ "java/src/org/chromium/chrome/browser/layouts/LayoutManagerAppUtils.java",
+ "java/src/org/chromium/chrome/browser/layouts/ManagedLayoutManager.java",
+ ]
+
+ deps = [
+ "..:java",
+ "//ui/android:ui_java",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/android/native_page/BUILD.gn b/chromium/chrome/browser/ui/android/native_page/BUILD.gn
index 85cfe3cafd3..cf88512b178 100644
--- a/chromium/chrome/browser/ui/android/native_page/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/native_page/BUILD.gn
@@ -15,6 +15,23 @@ android_library("java") {
"//components/browser_ui/styles/android:java",
"//components/embedder_support/android:util_java",
"//content/public/android:content_java",
- "//third_party/android_deps:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
+ ]
+}
+
+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/native_page/NativePageTest.java",
+ ]
+
+ 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/strings/android_chrome_strings.grd b/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd
index 79d36699b1a..0ec96780992 100644
--- a/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -196,7 +196,7 @@ CHAR-LIMIT guidelines:
<file lang="zh-TW" path="translations/android_chrome_strings_zh-TW.xtb" />
<file lang="zu" path="translations/android_chrome_strings_zu.xtb" />
</translations>
- <release allow_pseudo="false" seq="1">
+ <release seq="1">
<messages fallback_to_english="true">
<!-- NOTE: Generic strings used across multiple features belong in //components/browser_ui/strings/android. -->
@@ -254,6 +254,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_NOTIFICATION_CATEGORY_PERMISSION_REQUESTS" desc="Label for permission requests, within a list of notification categories. [CHAR-LIMIT=32]">
Permission requests
</message>
+ <message name="IDS_NOTIFICATION_CATEGORY_PRICE_DROP" desc="Label for notification that indicates there is a lower price in an open tab, within a list of notification categories. [CHAR-LIMIT=32]">
+ Price drop alerts
+ </message>
<message name="IDS_UNSUPPORTED" desc="Message displayed to the user when an attempted action is not supported.">
Unsupported
@@ -275,6 +278,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_PREFS_SYNC_AND_SERVICES_CONTENT_DESCRIPTION" desc="The accessibility text to read when the 'Sync and Google services' Settings page is opened from the sign-in page. This text is attached to the 'Navigate Up' button shown at the top of the screen. The first two sentences describe the screen that is currently shown to the user, while 'Navigate up' is a description for the button this text is attached to. 'Navigate up' should match TC ID 6794660482873516081.">
You are currently customizing your Sync and Google service settings. To finish turning on sync, tap the Confirm button near the bottom of the screen. Navigate up
</message>
+ <message name="IDS_PREFS_MANAGE_SYNC_SETTINGS_CONTENT_DESCRIPTION" is_accessibility_with_no_ui="true" desc="The accessibility text to read when the 'Manage Sync Settings' page is opened from the sign-in page. This text is attached to the 'Navigate Up' button shown at the top of the screen. The first two sentences describe the screen that is currently shown to the user, while 'Navigate up' is a description for the button this text is attached to. 'Navigate up' should match TC ID 6794660482873516081.">
+ You are currently customizing your Sync settings. To finish turning on sync, tap the Confirm button near the bottom of the screen. Navigate up
+ </message>
<message name="IDS_SIGNIN_PREF_DISALLOWED_TITLE" desc="Title for the signin entry in Settings when signin is disallowed.">
Not signed in
</message>
@@ -452,9 +458,6 @@ CHAR-LIMIT guidelines:
<message name="IDS_AUTOFILL_CREATE_PROFILE" desc="Button that allows the user to create a new profile (which contains the user's name, address, etc) that will be automatically filled into web page forms. [CHAR-LIMIT=32]">
Add address
</message>
- <message name="IDS_AUTOFILL_EDIT_PROFILE" desc="Button that allows the user to edit a profile (which contains the user's name, address, etc) that can be automatically filled into web page forms. [CHAR-LIMIT=32]">
- Edit address
- </message>
<message name="IDS_AUTOFILL_CREATE_CREDIT_CARD" desc="Button that allows the user to add a new card that will be automatically filled into web page forms. This can be either credit, debit, or prepaid card. [CHAR-LIMIT=32]">
Add card
</message>
@@ -464,6 +467,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_AUTOFILL_PROFILE_EDITOR_COUNTRY" desc="Label for a spinner input field containing a list of countries or regions [CHAR-LIMIT=32]">
Country/Region
</message>
+ <message name="IDS_AUTOFILL_PROFILE_EDITOR_HONORIFIC_PREFIX" desc="Label for text input field containing a title that can be auto-filled by Chrome. [CHAR-LIMIT=32]" meaning="A 'Title' field in a web form could be a prefix like Ms., Mx., or Dr. or a position held, like Captain or Rabbi.">
+ Title
+ </message>
<message name="IDS_AUTOFILL_PROFILE_EDITOR_EMAIL_ADDRESS" desc="Label for text input field containing an e-mail address. [CHAR-LIMIT=32]">
Email
</message>
@@ -561,6 +567,15 @@ CHAR-LIMIT guidelines:
<message name="IDS_PASSWORD_EDIT_HINT" desc="Small hint on the editing screens that advises users to store the same password as they use on the currently edited site.">
Make sure the password you are saving matches your password for <ph name="SITE">%1$s<ex>example.com</ex></ph>
</message>
+ <message name="IDS_PASSWORD_ENTRY_EDIT_DELETION_DIALOG_BODY" desc="Text explaining the user that deleting the credential that they are viewing will not remove their account on the reaspective website.">
+ Deleting this password will not delete your account on <ph name="SITE">%1$s<ex>example.com</ex></ph>
+ </message>
+ <message name="IDS_PASSWORD_ENTRY_EDIT_DELETE_CREDENTIAL_DIALOG_TITLE" desc="The title of a prompt to confirm that the user intends to delete the stored password.">
+ Delete password?
+ </message>
+ <message name="IDS_PASSWORD_ENTRY_EDIT_DELETE_CREDENTIAL_DIALOG_CONFIRM" desc="The caption the button confirming that the user intends to delete the stored password.">
+ Delete password
+ </message>
<message name="IDS_PASSWORD_ENTRY_VIEWER_TITLE" desc='Title of the overview screen for a saved password.'>
Saved password
</message>
@@ -609,12 +624,21 @@ CHAR-LIMIT guidelines:
<message name="IDS_PASSWORD_ENTRY_VIEWER_SET_LOCK_SCREEN" desc='Text prompting user to set device lock in order to view/copy passwords'>
To view or copy your password here, set screen lock on this device.
</message>
+ <message name="IDS_PASSWORD_ENTRY_VIEW_SET_SCREEN_LOCK" desc='Text prompting user to set up screen lock on their device in order to view passwords'>
+ To view passwords, first set a screen lock on your device
+ </message>
+ <message name="IDS_PASSWORD_ENTRY_COPY_SET_SCREEN_LOCK" desc='Text prompting user to set up screen lock on their device in order to copy passwords'>
+ To copy passwords, first set a screen lock on your device
+ </message>
+ <message name="IDS_PASSWORD_ENTRY_EDIT_DUPLICATE_USERNAME_ERROR" desc='Error text displayed when the user changes the username in the editor to another username that they already saved for the same site.'>
+ You already saved this username for this site
+ </message>
+ <message name="IDS_PASSWORD_ENTRY_EDIT_EMPTY_PASSWORD_ERROR" desc='Error text displayed when the user has left the password field empty in the credential editor.'>
+ Enter password
+ </message>
<message name="IDS_PASSWORD_EXPORT_SET_LOCK_SCREEN" desc="Text prompting user to set device lock in order to be able to export passwords">
Turn on screen lock in Settings to export your passwords from this device
</message>
- <message name="IDS_PASSWORD_ENTRY_VIEW_SET_SCREEN_LOCK" desc="Text prompting the user to set up a screen lock on their device in order to be able to view passwords">
- To view passwords, first set a screen lock on your device
- </message>
<message name="IDS_PASSWORD_GENERATION_POPUP_CONTENT_DESCRIPTION" desc="The text announced by the screen reader when the password generation popup is shown.">
Showing password generation popup
</message>
@@ -653,6 +677,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_LOCKSCREEN_DESCRIPTION_VIEW" desc="When a user attempts to view a password for a particular website in Chrome's settings, Chrome launches a lock screen to verify the user's identity and displays the following explanation.">
Unlock to view your password
</message>
+ <message name="IDS_LOCKSCREEN_DESCRIPTION_EDIT" desc="When a user attempts to edit a password for a particular website in Chrome's settings, Chrome launches a lock screen to verify the user's identity and displays the following explanation.">
+ Unlock to edit your password
+ </message>
<message name="IDS_LOCKSCREEN_DESCRIPTION_EXPORT" desc="When a user attempts to export saved passwords in Chrome's settings, Chrome launches a lock screen to verify the user's identity and displays the following explanation.">
Unlock to export your passwords
</message>
@@ -674,26 +701,6 @@ CHAR-LIMIT guidelines:
Chrome’s homepage
</message>
- <!-- Homepage Promo card -->
- <message name="IDS_HOMEPAGE_PROMO_TITLE" desc="The title displayed on homepage promo card, which guide user set chrome's new tab page as their new homepage.">
- Get here quicker
- </message>
- <message name="IDS_HOMEPAGE_PROMO_TITLE_SLIM" desc="The title displayed on homepage promo card, which guide user set chrome's new tab page as their new homepage. Used for the one liner variation.">
- Make this page your homepage
- </message>
- <message name="IDS_HOMEPAGE_PROMO_DESCRIPTION" desc="The description displayed on homepage promo card, which guide user set chrome's new tab page as their new homepage.">
- See your top sites and recent stories whenever you tap the Home button
- </message>
- <message name="IDS_HOMEPAGE_PROMO_PRIMARY_BUTTON" desc="The text displayed on homepage promo card's primary button compat, which will change the user's homepage to new tab page when they tab.">
- Change homepage
- </message>
- <message name="IDS_HOMEPAGE_PROMO_PRIMARY_BUTTON_SLIM" desc="The text displayed on homepage promo card's primary button compat, which will change the user's homepage to new tab page when they tab. Used for the slim variation that has a smaller space for the button.">
- Change
- </message>
- <message name="IDS_HOMEPAGE_PROMO_SNACKBAR_MESSAGE" desc="The text displayed on the snackbar that appears after setting homepage by click on homepage promo card's primary button, which will change the user's homepage to new tab page.">
- Homepage changed
- </message>
-
<!-- Enhanced Protection Promo card -->
<message name="IDS_ENHANCED_PROTECTION_PROMO_TITLE" desc="The title displayed on homepage promo card, which guides the user to the chrome settings page to select the enhanced protection option.">
Get Chrome’s strongest security
@@ -777,6 +784,15 @@ Touch &amp; hold any word to search. To refine your search, select more or fewer
<message name="IDS_CONTEXTUAL_SEARCH_NO_THANKS_BUTTON" desc="A button to confirm and dismiss opt out promo">
No thanks
</message>
+ <message name="IDS_CONTEXTUAL_SEARCH_HELP_BODY" desc="Some help text that is shown in the body of a paragraph. The text tells the user what gesture to use instead of a previous gesture in order to search.">
+ To search from this page, touch &amp; hold words instead of tapping them
+ </message>
+ <message name="IDS_CONTEXTUAL_SEARCH_HELP_HEADER" desc="Summary help text that is shown at the top of a paragraph. The text tells the user what gesture to use in order to search.">
+ Touch &amp; hold for more relevant info
+ </message>
+ <message name="IDS_CONTEXTUAL_SEARCH_DEFAULT_CAPTION" desc="Summary help text that is shown as a second line in the Contextual Search peeking bottom sheet telling the user that they can tap the text in order to open the sheet and see search results there.">
+ Tap to see search results
+ </message>
<message name="IDS_DO_NOT_TRACK_TITLE" desc="Title for 'Do Not Track' preference">
“Do Not Track”
</message>
@@ -789,6 +805,42 @@ For example, some websites may respond to this request by showing you ads that a
Access payment methods
</message>
+ <!-- Privacy Sandbox Settings. Used by //chrome/browser/privacy_sandbox. -->
+ <message name="IDS_PREFS_PRIVACY_SANDBOX" desc="Title for the 'Privacy Sandbox' page. 'Privacy Sandbox' is a noun phrase (title case).">
+ Privacy Sandbox
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_STATUS_ENABLED" desc="Status text, displayed when the Privacy sandbox APIs are enabled.">
+ Trial features are on
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_STATUS_DISABLED" desc="Status text, displayed when the Privacy sandbox APIs are disabled.">
+ Trial features are off
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_DESCRIPTION_TITLE" desc="Title for the description text of 'Privacy Sandbox'.">
+ About Privacy Sandbox
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_DESCRIPTION" desc="Description of the 'Privacy Sandbox'.">
+ Privacy Sandbox is an ongoing initiative to preserve the open web that will help safeguard you from tracking mechanisms.
+
+Today, websites rely on many technologies, like third-party cookies, for important services like showing relevant ads and measuring a site’s performance.
+
+Privacy Sandbox preserves the vitality of the open web by creating better ways to perform these services – without breaking sites, and while preventing you from being surreptitiously tracked across the web.
+
+Privacy Sandbox is still in active development and is available in selected regions. For now, sites may try out Privacy Sandbox while continuing to use current web technologies like third-party cookies. <ph name="BEGIN_LINK">&lt;link&gt;</ph>Learn more<ph name="END_LINK">&lt;/link&gt;</ph>
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_TOGGLE" desc="Title for the Privacy Sandbox toggle.">
+ Privacy Sandbox trials
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_TOGGLE_DESCRIPTION" desc="Description for the Privacy Sandbox toggle.">
+ When enabled, sites may use the privacy-preserving techniques shown here to provide their content and services. These include alternatives to cross-site tracking. More trials may be added over time.
+
+<ph name="BEGIN_LIST_ITEM1">&lt;li1&gt;</ph>Advertisers can learn when thousands of users share a similar interest – like a crowd at a concert — and select ads for the crowd, rather than an individual person.<ph name="END_LIST_ITEM1">&lt;/li1&gt;</ph>
+
+<ph name="BEGIN_LIST_ITEM2">&lt;li2&gt;</ph>Advertisers can study the effectiveness of ads in a way that does not track you across sites.<ph name="END_LIST_ITEM2">&lt;/li2&gt;</ph>
+ </message>
+ <message name="IDS_PRIVACY_SANDBOX_SNACKBAR_MESSAGE" desc="The text displayed in the snackbar, which gives the user an option to navigate to the Privacy Sandbox settings page. 'Privacy sandbox' has TC ID 5753235213964358658.">
+ Learn about and control new technologies that aim to replace third-party cookies
+ </message>
+
<!-- Secure DNS Settings. Used by //chrome/browser/privacy. -->
<message name="IDS_SETTINGS_CUSTOM" desc="Label for a custom option in a dropdown menu.">
Custom
@@ -936,8 +988,8 @@ Your Google account may have other forms of browsing history like searches and a
</message>
<!-- Safety check -->
- <message name="IDS_PREFS_SAFETY_CHECK" desc="Title of the Safety check element in settings, allowing the user to check multiple areas of browser safety. The NEW label is displayed when the number of times the user ran the check is less than 3. [CHAR-LIMIT=32]">
- Safety check <ph name="BEGIN_NEW">&lt;new&gt;</ph>New<ph name="END_NEW">&lt;/new&gt;</ph>
+ <message name="IDS_PREFS_SAFETY_CHECK" desc="Title of the Safety check element in settings, allowing the user to check multiple areas of browser safety. [CHAR-LIMIT=32]">
+ Safety check
</message>
<message name="IDS_SAFETY_CHECK_DESCRIPTION" desc="Introduces the safety check categories to the user. Followed by several items, such as 'Safe Browsing', 'Updates', 'Passwords'.">
Chrome can help keep you safe from data breaches, unsafe websites, and more
@@ -1181,12 +1233,6 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_LANGUAGES_ITEM_OPTION_OFFER_TO_TRANSLATE" desc="Option in language item menu. User can click the 'Offer to translate' option to toggle whether they want Chrome to translate pages in this language. [CHAR-LIMIT=32]">
Offer to translate
</message>
- <message name="IDS_LANGUAGES_SET_APPLICATION_LANGUAGE_PROMPT" desc="Option in language item menu. User can click the 'App Language' option to toggle whether or not the Chrome user interface should be displayed in this language. [CHAR-LIMIT=32]">
- Use as Chrome’s language
- </message>
- <message name="IDS_LANGUAGES_SET_AS_APPLICATION_LANGUAGE" desc="Toast to display after selecting language to use for Chrome's user interface.">
- <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> will use <ph name="language">%2$s<ex>Hindi</ex></ph> on restart.
- </message>
<message name="IDS_LANGUAGES_EXPLICIT_ASK_TITLE" desc="Title of the dialog that explicitly asks the user which languages they can read.">
What languages do you read?
</message>
@@ -1214,12 +1260,21 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_LANGUAGES_SETTINGS_AUTOMATIC" desc="Title of Translation settings that lists languages that should be automatically translated.">
Automatically translate these languages
</message>
- <message name="IDS_LANGUAGES_SETTINGS_DONT_OFFER_LANG" desc="Title of Translation settings that lists languages where no prompt to translate will be shown.">
+ <message name="IDS_LANGUAGES_SETTINGS_AUTOMATIC_TITLE" desc="Short title for Translation settings page showing a list of languages that should be automatically translated.">
+ Automatically translate
+ </message>
+ <message name="IDS_LANGUAGES_SETTINGS_DONT_OFFER_LANGS" desc="Title of Translation settings that lists languages where no prompt to translate will be shown.">
Don’t offer to translate these languages
</message>
+ <message name="IDS_LANGUAGES_SETTINGS_NEVER_LANGS_TITLE" desc="Short title for Translation settings page showing a list of languages that should never be translated">
+ Never translate
+ </message>
<message name="IDS_LANGUAGES_SETTINGS_DONT_OFFER_SITES" desc="Title of Translation settings that lists websites where no prompt to translate will be shown.">
Don’t offer to translate these sites
</message>
+ <message name="IDS_LANGUAGES_SETTINGS_NEVER_SITES_TITLE" desc="Short title for Translation settings page showing a list of sites that should never be translated">
+ Never translate sites
+ </message>
<!-- Lite Mode-->
<message name="IDS_DATA_REDUCTION_TITLE_LITE_MODE" desc="Menu item for Lite mode, which allows users to save mobile data by compressing network traffic.">
@@ -1546,7 +1601,7 @@ Your Google account may have other forms of browsing history like searches and a
Google Terms of Service
</message>
<message name="IDS_GOOGLE_TERMS_OF_SERVICE_URL" desc="URL for Google terms of service" translateable="false">
- https://policies.google.com/terms
+ https://policies.google.com/terms/embedded
</message>
<message name="IDS_CHROME_ADDITIONAL_TERMS_OF_SERVICE_TITLE" desc="Title for Chrome and Chrome OS addtional terms of service">
Chrome &amp; Chrome OS Additional Terms of Service
@@ -1781,7 +1836,7 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SYNC_ERROR_CARD_TITLE" desc="Title of the Sync Error Card. [CHAR-LIMIT=32]">
Sync isn't working
</message>
- <message name="IDS_SYNC_PASSWORDS_ERROR_CARD_TITLE" desc="Title of the Sync Error Card when it affects passwords only. [CHAR-LIMIT=32]">
+ <message name="IDS_PASSWORD_SYNC_ERROR_SUMMARY" desc="Short message shown in various UIs (e.g. Sync Error Card body) to inform that passwords can't be synced (due to missing trusted vault keys). [CHAR-LIMIT=32]">
Error syncing passwords
</message>
<message name="IDS_SYNC_SETTINGS_NOT_CONFIRMED_TITLE" desc="Title of the error message shown when sync setup was not complete. [CHAR-LIMIT=60]">
@@ -1793,11 +1848,8 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_HINT_SYNC_AUTH_ERROR" desc="Hint message to resolve sync auth error.">
Sign in again to start sync
</message>
- <message name="IDS_HINT_SYNC_RETRIEVE_KEYS_LEGACY" desc="Hint message to resolve sync encryption error.">
- Fix now
- </message>
<message name="IDS_HINT_SYNC_RETRIEVE_KEYS" desc="Hint message to resolve sync encryption error.">
- Error syncing passwords
+ Fix now
</message>
<message name="IDS_HINT_PASSPHRASE_REQUIRED" desc="Hint message to resolve passphrase required error.">
Enter your passphrase to start sync
@@ -1828,9 +1880,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_AUTH_ERROR_CARD_BUTTON" desc="Button text for auth error in sync error cards.">
Sign in again
</message>
- <message name="IDS_TRUSTED_VAULT_ERROR_CARD_BUTTON" desc="Button text for trusted vault error in sync error cards.">
- Unlock with Screen Lock
- </message>
<!-- Sync error strings -->
<message name="IDS_SYNC_ERROR_GENERIC" desc="Sync error string for generic error. [CHAR-LIMIT=80]">
@@ -2099,6 +2148,12 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_CONTEXTMENU_SEARCH_WITH_GOOGLE_LENS" desc="Context sensitive menu item for deep linking into google lens. [CHAR-LIMIT=30]">
Search with Google Lens <ph name="BEGIN_NEW">&lt;new&gt;</ph>New<ph name="END_NEW">&lt;/new&gt;</ph>
</message>
+ <message name="IDS_CONTEXTMENU_SEARCH_IMAGE_WITH_GOOGLE_LENS" desc="Context sensitive menu item for deep linking into google lens. [CHAR-LIMIT=30]">
+ Search image with Google Lens <ph name="BEGIN_NEW">&lt;new&gt;</ph>New<ph name="END_NEW">&lt;/new&gt;</ph>
+ </message>
+ <message name="IDS_CONTEXTMENU_TRANSLATE_IMAGE_WITH_GOOGLE_LENS" desc="Context sensitive chip for deep linking into google lens for translate results. [CHAR-LIMIT=30]">
+ Translate image with Google Lens <ph name="BEGIN_NEW">&lt;new&gt;</ph>New<ph name="END_NEW">&lt;/new&gt;</ph>
+ </message>
<message name="IDS_CONTEXTMENU_SHOP_SIMILAR_PRODUCTS" desc="Context sensitive menu item for deep linking into google lens for shopping results. [CHAR-LIMIT=30]">
Shop similar products <ph name="BEGIN_NEW">&lt;new&gt;</ph>New<ph name="END_NEW">&lt;/new&gt;</ph>
</message>
@@ -2141,11 +2196,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Refreshing page
</message>
- <!-- App banner accessibility strings, used for touch exploration -->
- <message name="IDS_APP_BANNER_VIEW_NATIVE_APP_INSTALL_ACCESSIBILITY" desc="Accessibility text: Indicates that clicking on the button will either purchase the app or install it.">
- Get the app from the Google Play Store: <ph name="APP_ACTION">%s<ex>Install</ex></ph>
- </message>
-
<!-- DOM Distiller strings -->
<message name="IDS_DARK_MODE" desc="Title of button that will change theme of distilled pages to dark mode.">
Dark
@@ -2170,27 +2220,15 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
</message>
<!-- Add to Home screen strings -->
- <message name="IDS_MENU_ADD_TO_HOMESCREEN" desc="Menu item for adding a shortcut to the Home screen (default title). [CHAR-LIMIT=27]">
- Add to Home screen
- </message>
<message name="IDS_MENU_OPEN_WEBAPK" desc="Menu item for opening the installed WebAPK associated with the current PWA. [CHAR-LIMIT=27]">
Open <ph name="WEBAPK_NAME">%1$s<ex>Telegram</ex></ph>
</message>
<message name="IDS_OPEN_WEBAPK_FAILED" desc="Opening of a WebAPK failed.">
Could not open app
</message>
- <message name="IDS_MENU_ADD_TO_HOMESCREEN_INSTALL" desc="Menu item for adding a shortcut to the Home screen. [CHAR-LIMIT=27]">
- Install app
- </message>
<message name="IDS_APP_BANNER_ADD" desc="A button in an app banner to confirm adding a site to homescreen">
Add
</message>
- <message name="IDS_APP_BANNER_INSTALL" desc="A button in an app banner to confirm adding a site to homescreen">
- Install
- </message>
- <message name="IDS_ADDED_TO_HOMESCREEN" desc="Indicates that the website with the specified name was added to the user's Home screen.">
- <ph name="NAME">%1$s<ex>Google</ex></ph> was added to your Home screen
- </message>
<message name="IDS_WEBAPK_INSTALL_IN_PROGRESS" desc="Indicates that an installation for the WebAPK for the specific website is already in progress.">
Still adding previous site
</message>
@@ -2218,6 +2256,15 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_IPH_INFOBAR_ADD_TO_HOME_SCREEN_DESCRIPTION_TABLET" desc="The description of in-product-help infobar encouraging users to add a commonly visited webpage to the home screen. Shown on tablets.">
Add this site to your tablet’s Home screen so you can get here more easily
</message>
+ <message name="IDS_PWA_INSTALL_BOTTOM_SHEET_ACCESSIBILITY" desc="The content description for the bottom sheet install UI.">
+ Install this app
+ </message>
+ <message name="IDS_PWA_INSTALL_BOTTOM_SHEET_SCREENSHOT" desc="The content description string for a screenshot in the bottom sheet install UI.">
+ Screenshot
+ </message>
+ <message name="IDS_IMAGE_ZOOM_CONTENT_DESCRIPTION" desc="The content description string for the screenshot in the image zoom view.">
+ Screenshot. Tap to close.
+ </message>
<!-- Page info popup -->
<message name="IDS_PAGE_INFO_CONNECTION_OFFLINE" desc="Message to display in the page info bubble when viewing and offline page.">
@@ -2236,6 +2283,10 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
You are viewing a preview of this page
</message>
+<message name="IDS_PAGE_INFO_IPH" desc="Message to in InProductHelp bubble to make users aware of changing permissions in PageInfo.">
+ Change your site settings here
+ </message>
+
<!-- Sad tab page -->
<message name="IDS_SAD_TAB_SUGGESTIONS" desc="The help message displayed on the sad tab page after a tab crashes.">
If you’re seeing this frequently, try these <ph name="BEGIN_LINK">&lt;link&gt;</ph>suggestions<ph name="END_LINK">&lt;/link&gt;</ph>.
@@ -2579,6 +2630,12 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_SIGNIN_ACCOUNT_PICKER_DIALOG_TITLE" desc="The title for the dialog that shows the list of accounts on the device and asks the user to select one of these accounts. [CHAR-LIMIT=27]">
Choose an account
</message>
+ <message name="IDS_ACCOUNT_PICKER_BOTTOM_SHEET_ACCESSIBILITY_OPENED" is_accessibility_with_no_ui="true" desc="The accessibility text to read when account picker bottom sheet is opened.">
+ Sign in to Chrome, opened.
+ </message>
+ <message name="IDS_ACCOUNT_PICKER_BOTTOM_SHEET_ACCESSIBILITY_CLOSED" is_accessibility_with_no_ui="true" desc="The accessibility text to read when account picker bottom sheet is closed.">
+ 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.
</message>
@@ -2594,6 +2651,9 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_SIGNIN_ACCOUNT_PICKER_AUTH_ERROR_SUBTITLE" desc="The subtitle of the account picker bottom sheet when there is an authentication error with the credentials of the account selected.">
Sorry, we couldn’t validate your credentials
</message>
+ <message name="IDS_SIGNIN_ACCOUNT_PICKER_DISMISS_BUTTON" desc="Dismiss button text of the account picker bottom sheet">
+ Skip
+ </message>
<message name="IDS_SIGNIN_ACCOUNT_PICKER_GENERAL_ERROR_BUTTON" desc="Button text of the account picker bottom sheet when something went wrong in the sign-in process. User can try again if they click it.">
Try again
</message>
@@ -2693,28 +2753,18 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_REMOVE_ALL" desc="Context menu option to clear the list of recently closed tabs">
Remove all
</message>
- <message name="IDS_ACCESSIBILITY_NTP_OFFLINE_BADGE" desc="Content description for the badge that indicates offline availability of a most visited item or content suggestion on the new tab page.">
- Available offline
- </message>
<message name="IDS_NTP_LEARN_MORE_ABOUT_SUGGESTED_CONTENT" desc="Text in the footer of the New Tab Page. Part of the text is a link to a help center page where the user can learn more about suggested content.">
<ph name="BEGIN_LINK">&lt;link&gt;</ph>Learn more<ph name="END_LINK">&lt;/link&gt;</ph> about suggested content
</message>
- <if expr="enable_feed_v1">
- <message name="IDS_NTP_SUGGESTIONS_FETCH_FAILED" desc="Snackbar text shown when the user presses the More button to get more suggestions, but this fails (eg, no internet connectivity).">
- Can’t get suggestions
- </message>
- </if>
- <if expr="enable_feed_v1">
- <message name="IDS_NTP_SUGGESTIONS_FETCH_NO_NEW_SUGGESTIONS" desc="Snackbar text shown when the user presses the More button to get more suggestions, the fetch succeeds but provides no new suggestions.">
- No new suggestions
- </message>
- </if>
<message name="IDS_NTP_MANAGE_MY_ACTIVITY" desc="Content description to manage my activity from the feed header overflow menu.">
Manage activity
</message>
<message name="IDS_NTP_MANAGE_INTERESTS" desc="Content description to manage settings from the feed header overflow menu.">
Manage interests
</message>
+ <message name="IDS_NTP_MANAGE_REACTIONS" desc="Content description to manage feed reactions from the feed header overflow menu.">
+ Manage reactions
+ </message>
<message name="IDS_NTP_TURN_OFF_FEED" desc="Content description to turn off the feed from the feed header overflow menu.">
Turn off
</message>
@@ -2922,6 +2972,12 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_MENU_FIND_IN_PAGE" desc="Menu item allowing users to find text within the current page. [CHAR-LIMIT=27]">
Find in page
</message>
+ <message name="IDS_MENU_FOLLOW" desc="Menu item allowing users to follow the current website. [CHAR-LIMIT=27]">
+ Follow
+ </message>
+ <message name="IDS_MENU_FOLLOWING" desc="Menu item indicating the current website is followed, allowing users to unfollow the current website. [CHAR-LIMIT=27]">
+ Following
+ </message>
<message name="IDS_MENU_PAINT_PREVIEW_SHOW" desc="Menu item allowing users to capture and show a paint preview of a page. [CHAR-LIMIT=27]" translateable="false">
Show Paint Preview
</message>
@@ -3081,14 +3137,14 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_READING_LIST_TITLE" desc="The title for the reading list page in main bookmark UI.">
Reading list
</message>
+ <message name="IDS_READING_LIST_TITLE_NEW" desc="The title for the reading list with a new text.">
+ Reading list <ph name="BEGIN_NEW">&lt;new&gt;</ph>New<ph name="END_NEW">&lt;/new&gt;</ph>
+ </message>
<message name="IDS_READING_LIST_READ" desc="The header for the read section in the reading list UI.">
Read
</message>
<message name="IDS_READING_LIST_UNREAD" desc="The header for the unread section in the reading list UI.">
- Unread
- </message>
- <message name="IDS_READING_LIST_READY_FOR_OFFLINE" desc="The string to inform the user that the reading list has offline page ready.">
- Ready for offline
+ Unread - Available offline
</message>
<message name="IDS_READING_LIST_SAVED" desc="App-based message shown after user adds a new link to the reading list. [CHAR-LIMIT=32]">
Added to reading list
@@ -3096,16 +3152,13 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_READING_LIST_MARK_AS_READ" desc="The text for the action to mark the reading list as read.">
Mark as read
</message>
- <message name="IDS_READING_LIST_SHARE" desc="The text for the action to share the reading list item.">
- Share
- </message>
<message name="IDS_READING_LIST_REMINDER_NOTIFICATION_TITLE" desc="The title of the reminder notification for reading list.">
Catch up on your reading list
</message>
<message name="IDS_READING_LIST_REMINDER_NOTIFICATION_SUBTITLE" desc="The subtitle of the reminder notification for reading list.">
{READING_LIST_REMINDER_NOTIFICATION_SUBTITLE, plural,
- =1 {You have <ph name="READING_LIST_REMINDER_NOTIFICATION_SUBTITLE_ONE">%1$d<ex>1</ex></ph> page}
- other {You have <ph name="READING_LIST_REMINDER_NOTIFICATION_SUBTITLE_MANY">%1$d<ex>8</ex></ph> pages}}
+ =1 {You have <ph name="READING_LIST_REMINDER_NOTIFICATION_SUBTITLE_ONE">%1$d<ex>1</ex></ph> unread page}
+ other {You have <ph name="READING_LIST_REMINDER_NOTIFICATION_SUBTITLE_MANY">%1$d<ex>8</ex></ph> unread pages}}
</message>
<message name="IDS_READING_LIST_UNREAD_PAGE_COUNT" desc="Inform the user about the number of unread reading list items.">
{READING_LIST_UNREAD_PAGE_COUNT, plural,
@@ -3119,7 +3172,7 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
Save this page for later and get a reminder
</message>
<message name="IDS_READING_LIST_SAVE_PAGES_FOR_LATER" desc="The text on the reading list in product help bubble to introduce the feature to the user.">
- Save pages for later and get a reminder
+ Add pages to your Reading List to get a reminder
</message>
<message name="IDS_READING_LIST_FIND_IN_BOOKMARKS" desc="The text to inform the user to find the reading list in bookmarks UI.">
Find your reading list in Bookmarks
@@ -3127,12 +3180,6 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_READING_LIST_EMPTY_LIST_TITLE" desc="The text on reading list page when there are no reading list items informing user that reading list is supposed to appear on this surface.">
You’ll find your reading list here
</message>
- <message name="IDS_READING_LIST_EMPTY_LIST_DESCRIPTION" desc="The description text on reading list page when there are no reading list items informing user that they can save articles to read later which will appear on this surface.">
- You can save pages to your reading list to find them again
- </message>
- <message name="IDS_READING_LIST_EMPTY_LIST_DESCRIPTION_OFFLINE" desc="The description text on reading list page when there are no reading list items informing user that they can save articles to read later offline which will appear on this surface.">
- You can save pages to your reading list to find them again or read offline
- </message>
<!-- Offline pages -->
<message name="IDS_OFFLINE_PAGES_VIEWING_OFFLINE_PAGE" desc="Text explaining that the user is viewing an offline copy of a web page.">
@@ -3240,6 +3287,9 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_MIC" desc="Content description for the voice search button.">
Start voice search
</message>
+ <message name="IDS_ACCESSIBILITY_BTN_LENS_CAMERA" desc="Content description for the Lens button. When the user taps the button, they can perform a 'search with your camera or photos', which opens the Google Lens app.">
+ Search with your camera using Google Lens
+ </message>
<message name="IDS_ACCESSIBILITY_NEW_TAB_PAGE" desc="Accessibility text to read aloud when the user focuses the new tab view.">
New tab
</message>
@@ -3594,7 +3644,7 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
You can clear the data in Chrome Settings
</message>
<message name="IDS_TWA_CLEAR_DATA_DIALOG_KEEP_DATA" desc="Text on the negative button of the clear data dialog">
- Keep data
+ Keep Data
</message>
<message name="IDS_TWA_CLEAR_DATA_SITE_SELECTION_TITLE" desc="Title of screen showing the sites linked to TWA, allowing the user to clean data in any of them.">
Linked sites
@@ -3991,13 +4041,13 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_PREFS_WEB_ASSISTANCE_SECTION_TITLE" desc="Title for the web assistance section">
Web Assistance
</message>
- <message name="IDS_PREFS_AUTOFILL_ASSISTANT_GET_HELP_TITLE" desc="Title for the switch toggling whether Autofill Assistant is enabled. [CHAR-LIMIT=32]">
+ <message name="IDS_PREFS_AUTOFILL_ASSISTANT_GET_HELP_TITLE" desc="Title for the switch toggling whether Autofill Assistant is enabled.">
Get help with tasks on the web
</message>
<message name="IDS_PREFS_AUTOFILL_ASSISTANT_GET_HELP_SUMMARY" desc="Description for the Autofill Assistant toggle.">
To help you complete tasks, Google will receive the URLs and contents of sites on which you use Assistant, as well as information you submit through Assistant
</message>
- <message name="IDS_PREFS_AUTOFILL_ASSISTANT_PROACTIVE_HELP_TITLE" desc="Title for the switch toggling whether proactive help is enabled. When turned on, the Assistant will be able to proactively show up (without explicit user prompt) and offer to help. [CHAR-LIMIT=32]">
+ <message name="IDS_PREFS_AUTOFILL_ASSISTANT_PROACTIVE_HELP_TITLE" desc="Title for the switch toggling whether proactive help is enabled. When turned on, the Assistant will be able to proactively show up (without explicit user prompt) and offer to help.">
Proactive Help
</message>
<message name="IDS_PREFS_AUTOFILL_ASSISTANT_PROACTIVE_HELP_SUMMARY" desc="Description for the proactive help toggle. It explains that the Assistant may appear proactively when it detects that it can help the user. ">
@@ -4082,6 +4132,50 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
Google Chrome as a Security Key
</message>
+ <message name="IDS_CABLEV2_REGISTRATION_SUCCEEDED"
+ desc="The text of a small pop-up, that appears at the bottom of the screen on Android, informing the user that their attempt to register their phone as an authentication device was successful. The translation of the verb should hopefully match that in TC ID 1295743531323106866. (The attached image doesn't show the pop-up at the bottom because it's too fleeting to screenshot, so I've drawn in roughly what it looks like.)">
+ Registration succeeded
+ </message>
+
+ <message name="IDS_CABLEV2_REGISTRATION_FAILED"
+ desc="The text of a small pop-up, that appears at the bottom of the screen on Android, informing the user that their attempt to register their phone as an authentication device was unsuccessful. The translation of the verb should hopefully match that in TC ID 1295743531323106866. (The attached image doesn't show the pop-up at the bottom because it's too fleeting to screenshot, so I've drawn in roughly what it looks like.)">
+ Registration failed
+ </message>
+
+ <message name="IDS_CABLEV2_SIGN_IN_SUCCEEDED"
+ desc="The text of a small pop-up, that appears at the bottom of the screen on Android, informing the user that their attempt to sign-in using their phone as an authentication device was successful. The translation of 'sign-in' should hopefully match that in TC ID 6840924527405570820. (The attached image doesn't show the pop-up at the bottom because it's too fleeting to screenshot, so I've drawn in roughly what it looks like.)">
+ Sign-in succeeded
+ </message>
+
+ <message name="IDS_CABLEV2_SIGN_IN_FAILED"
+ desc="The text of a small pop-up, that appears at the bottom of the screen on Android, informing the user that their attempt to sign-in using their phone as an authentication device was unsuccessful. The translation of 'sign-in' should hopefully match that in TC ID 6840924527405570820. (The attached image doesn't show the pop-up at the bottom because it's too fleeting to screenshot, so I've drawn in roughly what it looks like.)">
+ Sign-in failed
+ </message>
+
+ <message name="IDS_CABLEV2_USB_DISCON_TITLE" desc="The title of a screen that advises the user to disconnect their phone. This shows when the user has connected their phone to their computer using a USB cable and needs to disconnect it once they have finished their current actions.">
+ Connected with USB cable
+ </message>
+
+ <message name="IDS_CABLEV2_USB_DISCON_BODY" desc="The body of a screen that advises the user to disconnect their phone. This shows when the user has connected their phone to their computer using a USB cable and needs to disconnect it once they have finished their current actions.">
+ Disconnect when you’re done
+ </message>
+
+ <message name="IDS_CABLEV2_SERVERLINK_CONNECTING_TO_YOUR_DEVICE" desc="The title of a screen that is shown when a user is connecting their phone to a desktop or laptop computer in order to sign in with it.">
+ Connecting to your device…
+ </message>
+
+ <message name="IDS_CABLEV2_SERVERLINK_STATUS_CONNECTING" desc="A small subheader on a screen that is shown when a user is connecting their phone to a desktop or laptop computer in order to sign in with it.">
+ This may take a minute
+ </message>
+
+ <message name="IDS_CABLEV2_SERVERLINK_STATUS_CONNECTED" desc="A small subheader on a screen that is shown when a user is connecting their phone to a desktop or laptop computer in order to sign in with it. (In the attached image, this text will appear in place of the text 'This may take a minute'.) This text is shown once the connection to the desktop/laptop has completed and the phone is awaiting instructions.">
+ Connected to device
+ </message>
+
+ <message name="IDS_CABLEV2_SERVERLINK_STATUS_PROCESSING" desc="A small subheader on a screen that is shown when a user is connecting their phone to a desktop or laptop computer in order to sign in with it. (In the attached image, this text will appear in place of the text 'This may take a minute'.) This text is shown once a challenge from the desktop/laptop has been received.">
+ Processing request
+ </message>
+
<!-- QR Code -->
<message name="IDS_QR_CODE_SHARE_ICON_LABEL" desc="Icon label for sharing with QR Code activity.">
QR Code
@@ -4139,8 +4233,12 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
Screenshot
</message>
+ <message name="IDS_SHARING_LONG_SCREENSHOT" desc="Label for Long Screenshot button in the sharing hub.">
+ Long Screenshot
+ </message>
+
<message name="IDS_SHARING_HIGHLIGHTS" desc="Label for Link-to-text button in the sharing hub.">
- Link to text
+ Link to highlight
</message>
<message name="IDS_SHARING_COPIED" desc="Text shown in the toast notification when Copy is selected in the sharing hub.">
@@ -4200,7 +4298,23 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
</message>
<message name="IDS_LINK_TO_TEXT_FAILURE_TOAST_MESSAGE" desc="Toast displayed when link to highlighted text was not possible to create.">
- Can't create link to text. Share link to page.
+ Can’t create link to highlight. Share link to page.
+ </message>
+
+ <message name="IDS_LINK_TO_TEXT_FAILURE_TOAST_MESSAGE_V2" desc="Toast displayed when link to highlighted text was not possible to create.">
+ Can’t create link to highlight
+ </message>
+
+ <message name="IDS_LINK_TO_TEXT_SUCCESS_LINK_TOAST_MESSAGE" desc="Toast displayed when link to highlighted text was not possible to create.">
+ Include link to highlight
+ </message>
+
+ <message name="IDS_LINK_TO_TEXT_SUCCESS_TEXT_TOAST_MESSAGE" desc="Toast displayed when link to highlighted text was not possible to create.">
+ Share text only
+ </message>
+
+ <message name="IDS_NEW_BADGE" desc="Notification displayed to indicate that there is a new sharing feature.">
+ New
</message>
<!-- Share Screenshot strings -->
@@ -4264,31 +4378,6 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
Viewing live page
</message>
- <!-- Default Browser Promo Strings-->
- <message name="IDS_DEFAULT_BROWSER_PROMO_DIALOG_TITLE" desc="Title of the default browser promo dialog">
- Set <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> as your default?
- </message>
- <message name="IDS_DEFAULT_BROWSER_PROMO_DIALOG_DESC" desc="Description in the default browser promo dialog, which is concatenated with one of the following steps strings">
- <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph> has the smarts and speed you need to safely do, create, and explore online
- </message>
- <message name="IDS_DEFAULT_BROWSER_PROMO_DIALOG_DISAMBIGUATION_SHEET_STEPS" desc="Description of the steps to set the default browser throught disambiguation sheet. 'Always' should match TC ID 5575222334666843269.">
- 1. Choose <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph>\n2. Tap “Always”
- </message>
- <message name="IDS_DEFAULT_BROWSER_PROMO_DIALOG_SYSTEM_SETTINGS_STEPS"
- desc="Description of the steps to set the default browser throught system settings.
- 'Go to Settings' should match TC ID 4431460803004659888. 'Browser App' should match TC ID 6222206565850006894.">
- 1. Go to Settings\n2. Tap “Browser App”\n3. Choose <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph>
- </message>
- <message name="IDS_DEFAULT_BROWSER_PROMO_DIALOG_ROLE_MANAGER_STEPS" desc="Description of the steps to set the default browser throught role manager. 'Set as default' should match TC ID 5706081295230541240.">
- 1. Choose <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph>\n2. Tap “Set as default”
- </message>
- <message name="IDS_DEFAULT_BROWSER_PROMO_DIALOG_CHOOSE_CHROME_BUTTON" desc="A button in the default browser promo dialog to choose chrome as default">
- Choose <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph>
- </message>
- <message name="IDS_DEFAULT_BROWSER_PROMO_DIALOG_GO_TO_SETTINGS_BUTTON" desc="A button in the default browser promo to navigate users to systen settings. 'Go to Settings' should match TC ID 4431460803004659888.">
- Go to Settings
- </message>
-
<!-- HTTPS image compression InfoBar -->
<message name="IDS_LITE_MODE_HTTPS_IMAGE_COMPRESSION_MESSAGE" desc="The text of the infobar notifying the user that Chrome's Lite mode will now also compresses HTTPS images.">
Lite mode now saves you more data by optimizing images on HTTPS pages.
@@ -4345,6 +4434,18 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_IMAGE_DESCRIPTIONS_SETTINGS_USE_MOBILE_DATA_CONTENT" desc="Content of radio button to allow user to specify getting accessibility image descriptions while on mobile data.">
Wi-Fi is used when available
</message>
+ <message name="IDS_IMAGE_DESCRIPTIONS_TOAST_OFF" desc="Content for a toast that will appear when a user disables the image descriptions feature to confirm to the user it is now off.">
+ Image descriptions are off
+ </message>
+ <message name="IDS_IMAGE_DESCRIPTIONS_TOAST_JUST_ONCE" desc="Content for a toast that will appear when a user chooses to get image descriptions just once for the current page.">
+ Image descriptions added for this page
+ </message>
+ <message name="IDS_IMAGE_DESCRIPTIONS_TOAST_ON" desc="Content for a toast that will appear when a user enables the image descriptions feature to confirm to the user it is now on.">
+ Image descriptions are on
+ </message>
+ <message name="IDS_IMAGE_DESCRIPTIONS_TOAST_ON_NO_WIFI" desc="Content for a toast that will appear when a user enables the image descriptions feature with the wifi only requirement while the user is not currently on a wifi connection.">
+ Image descriptions will resume when you connect to Wi-Fi
+ </message>
<!-- Assistant voice search consent ui. -->
<message name="IDS_AVS_CONSENT_UI_TITLE" desc="Title for a dialog asking the user's permission to use Assistant for voice search.">
@@ -4379,6 +4480,11 @@ Data from your Incognito session will only be cleared from Chrome when you <ph n
<message name="IDS_AVS_SETTING_ENABLED_DESCRIPTION" desc="Description of the Assistant voice search setting.">
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>
</messages>
</release>
</grit>
diff --git a/chromium/chrome/browser/ui/android/theme/BUILD.gn b/chromium/chrome/browser/ui/android/theme/BUILD.gn
new file mode 100644
index 00000000000..6b7034fbb1a
--- /dev/null
+++ b/chromium/chrome/browser/ui/android/theme/BUILD.gn
@@ -0,0 +1,39 @@
+# 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.
+
+import("//build/config/android/rules.gni")
+
+android_library("java") {
+ sources = [
+ "java/src/org/chromium/chrome/browser/theme/ThemeColorProvider.java",
+ "java/src/org/chromium/chrome/browser/theme/ThemeUtils.java",
+ "java/src/org/chromium/chrome/browser/theme/TopUiThemeColorProvider.java",
+ ]
+
+ deps = [
+ ":java_resources",
+ "//base:base_java",
+ "//chrome/browser/tab:java",
+ "//chrome/browser/ui/android/native_page:java",
+ "//components/browser_ui/styles/android:java",
+ "//components/embedder_support/android:util_java",
+ "//components/security_state/content/android:java",
+ "//content/public/android:content_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_appcompat_appcompat_resources_java",
+ "//ui/android:ui_no_recycler_view_java",
+ ]
+ resources_package = "org.chromium.chrome.browser.theme"
+}
+
+android_resources("java_resources") {
+ sources = [
+ "java/res/color/toolbar_icon_tint_dark.xml",
+ "java/res/values/colors.xml",
+ ]
+ deps = [
+ "//components/browser_ui/styles/android:java_resources",
+ "//components/browser_ui/widget/android:java_resources",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/android/toolbar/BUILD.gn b/chromium/chrome/browser/ui/android/toolbar/BUILD.gn
new file mode 100644
index 00000000000..55c37bed113
--- /dev/null
+++ b/chromium/chrome/browser/ui/android/toolbar/BUILD.gn
@@ -0,0 +1,215 @@
+# 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.
+
+import("//build/config/android/config.gni")
+import("//build/config/android/rules.gni")
+import("//chrome/browser/buildflags.gni")
+
+android_library("java") {
+ sources = [
+ "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/ControlContainer.java",
+ "java/src/org/chromium/chrome/browser/toolbar/HomeButton.java",
+ "java/src/org/chromium/chrome/browser/toolbar/KeyboardNavigationListener.java",
+ "java/src/org/chromium/chrome/browser/toolbar/NewTabButton.java",
+ "java/src/org/chromium/chrome/browser/toolbar/ProgressAnimationSmooth.java",
+ "java/src/org/chromium/chrome/browser/toolbar/SettableThemeColorProvider.java",
+ "java/src/org/chromium/chrome/browser/toolbar/TabCountProvider.java",
+ "java/src/org/chromium/chrome/browser/toolbar/TabSwitcherButtonCoordinator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/TabSwitcherButtonProperties.java",
+ "java/src/org/chromium/chrome/browser/toolbar/TabSwitcherButtonView.java",
+ "java/src/org/chromium/chrome/browser/toolbar/TabSwitcherButtonViewBinder.java",
+ "java/src/org/chromium/chrome/browser/toolbar/TabSwitcherDrawable.java",
+ "java/src/org/chromium/chrome/browser/toolbar/ToolbarIntentMetadata.java",
+ "java/src/org/chromium/chrome/browser/toolbar/ToolbarProgressBar.java",
+ "java/src/org/chromium/chrome/browser/toolbar/ToolbarProgressBarAnimatingView.java",
+ "java/src/org/chromium/chrome/browser/toolbar/ToolbarTabController.java",
+ "java/src/org/chromium/chrome/browser/toolbar/ToolbarTabControllerImpl.java",
+ "java/src/org/chromium/chrome/browser/toolbar/VoiceToolbarButtonController.java",
+ "java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarButtonController.java",
+ "java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarFeatures.java",
+ "java/src/org/chromium/chrome/browser/toolbar/adaptive/OptionalNewTabButtonController.java",
+ "java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsContentDelegate.java",
+ "java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsMediator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsProperties.java",
+ "java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsViewBinder.java",
+ "java/src/org/chromium/chrome/browser/toolbar/bottom/ScrollingBottomViewResourceFrameLayout.java",
+ "java/src/org/chromium/chrome/browser/toolbar/bottom/ScrollingBottomViewSceneLayer.java",
+ "java/src/org/chromium/chrome/browser/toolbar/load_progress/LoadProgressCoordinator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/load_progress/LoadProgressMediator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/load_progress/LoadProgressProperties.java",
+ "java/src/org/chromium/chrome/browser/toolbar/load_progress/LoadProgressSimulator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/load_progress/LoadProgressViewBinder.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/ActionModeController.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/CohortUtils.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/HomeButtonCoordinator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/IncognitoSwitchCoordinator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/IncognitoSwitchProperties.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/IncognitoSwitchViewBinder.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/ToggleTabStackButton.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/ToggleTabStackButtonCoordinator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/Toolbar.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/ToolbarActionModeCallback.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/TopToolbarOverlayCoordinator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/TopToolbarOverlayMediator.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/TopToolbarOverlayProperties.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/TopToolbarSceneLayer.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/ViewShiftingActionBarDelegate.java",
+ ]
+
+ deps = [
+ ":java_resources",
+ "//base:base_java",
+ "//base:jni_java",
+ "//chrome/browser/android/lifecycle:java",
+ "//chrome/browser/browser_controls/android:java",
+ "//chrome/browser/device:java",
+ "//chrome/browser/flags:java",
+ "//chrome/browser/fullscreen/android:java",
+ "//chrome/browser/profiles/android:java",
+ "//chrome/browser/tab:java",
+ "//chrome/browser/tab_group:java",
+ "//chrome/browser/tabmodel:java",
+ "//chrome/browser/ui/android/layouts:java",
+ "//chrome/browser/ui/android/native_page:java",
+ "//chrome/browser/ui/android/theme:java",
+ "//chrome/browser/user_education:java",
+ "//components/browser_ui/widget/android:java",
+ "//components/browser_ui/widget/android:java_resources",
+ "//components/embedder_support/android:util_java",
+ "//components/feature_engagement:feature_engagement_java",
+ "//components/profile_metrics:browser_profile_type_enum_java",
+ "//content/public/android:content_java",
+ "//third_party/android_deps:android_support_v7_appcompat_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
+ "//ui/android:ui_full_java",
+ "//ui/android:ui_utils_java",
+ "//url:gurl_java",
+ ]
+ annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
+ resources_package = "org.chromium.chrome.browser.toolbar"
+}
+
+generate_jni("jni_headers") {
+ sources = [
+ "java/src/org/chromium/chrome/browser/toolbar/bottom/ScrollingBottomViewSceneLayer.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/TopToolbarSceneLayer.java",
+ ]
+}
+
+android_resources("java_resources") {
+ sources = [
+ "java/res/drawable-hdpi/btn_tabswitcher_modern.png",
+ "java/res/drawable-hdpi/btn_toolbar_home.png",
+ "java/res/drawable-hdpi/incognito_simple.png",
+ "java/res/drawable-hdpi/incognito_switch.png",
+ "java/res/drawable-hdpi/modern_location_bar.9.png",
+ "java/res/drawable-mdpi/btn_tabswitcher_modern.png",
+ "java/res/drawable-mdpi/btn_toolbar_home.png",
+ "java/res/drawable-mdpi/incognito_simple.png",
+ "java/res/drawable-mdpi/incognito_switch.png",
+ "java/res/drawable-mdpi/modern_location_bar.9.png",
+ "java/res/drawable-xhdpi/btn_tabswitcher_modern.png",
+ "java/res/drawable-xhdpi/btn_toolbar_home.png",
+ "java/res/drawable-xhdpi/incognito_simple.png",
+ "java/res/drawable-xhdpi/incognito_switch.png",
+ "java/res/drawable-xhdpi/modern_location_bar.9.png",
+ "java/res/drawable-xxhdpi/btn_tabswitcher_modern.png",
+ "java/res/drawable-xxhdpi/btn_toolbar_home.png",
+ "java/res/drawable-xxhdpi/incognito_simple.png",
+ "java/res/drawable-xxhdpi/incognito_switch.png",
+ "java/res/drawable-xxhdpi/modern_location_bar.9.png",
+ "java/res/drawable-xxxhdpi/btn_tabswitcher_modern.png",
+ "java/res/drawable-xxxhdpi/btn_toolbar_home.png",
+ "java/res/drawable-xxxhdpi/incognito_simple.png",
+ "java/res/drawable-xxxhdpi/incognito_switch.png",
+ "java/res/drawable/new_tab_icon.xml",
+ "java/res/layout/bottom_control_container.xml",
+ "java/res/layout/control_container.xml",
+ "java/res/layout/tab_switcher_toolbar.xml",
+ "java/res/values-sw600dp/dimens.xml",
+ "java/res/values/dimens.xml",
+ "java/res/values/ids.xml",
+ ]
+
+ deps = [
+ "//chrome/browser/ui/android/strings:ui_strings_grd",
+ "//components/browser_ui/styles/android: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/toolbar/VoiceToolbarButtonControllerUnitTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveToolbarButtonControllerTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/HomeButtonCoordinatorTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/ToggleTabStackButtonCoordinatorTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/ToggleTabStackButtonTest.java",
+ "java/src/org/chromium/chrome/browser/toolbar/top/TopToolbarOverlayMediatorTest.java",
+ ]
+
+ deps = [
+ ":java",
+ "//base:base_java",
+ "//base:base_java_test_support",
+ "//base:base_junit_test_support",
+ "//chrome/browser/android/lifecycle:java",
+ "//chrome/browser/browser_controls/android:java",
+ "//chrome/browser/flags:java",
+ "//chrome/browser/tab:java",
+ "//chrome/browser/ui/android/layouts:java",
+ "//chrome/browser/ui/android/theme:java",
+ "//chrome/browser/user_education:java",
+ "//chrome/test/android:chrome_java_test_support",
+ "//components/browser_ui/widget/android:java",
+ "//components/feature_engagement:feature_engagement_java",
+ "//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_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/load_progress/LoadProgressMediatorTest.java",
+ ]
+
+ deps = [
+ ":java",
+ ":java_resources",
+ "//base:base_java",
+ "//base:base_java_test_support",
+ "//chrome/browser/tab:java",
+ "//chrome/test/android:chrome_java_test_support",
+ "//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",
+ ]
+
+ resources_package = "org.chromium.chrome.browser.toolbar"
+}
diff --git a/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn b/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn
index 2c8135400ef..806ebebf443 100644
--- a/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn
+++ b/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn
@@ -20,13 +20,18 @@ source_set("browser_tests") {
"//base/test:test_support",
"//chrome/browser",
"//chrome/browser/chromeos",
+ "//chrome/browser/chromeos:test_support",
"//chrome/browser/extensions",
+ "//chrome/browser/profiles:profile",
"//chrome/browser/ui",
"//chrome/test:test_support_ui",
+ "//chromeos/dbus/power:power",
"//content/test:test_support",
"//ui/aura",
"//ui/base",
+ "//ui/base/dragdrop/mojom",
"//ui/events:test_support",
+ "//ui/gfx:test_support",
"//ui/views",
"//ui/wm/public",
]
diff --git a/chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn b/chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn
index 722621ed41f..281f436ef4b 100644
--- a/chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn
+++ b/chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn
@@ -27,6 +27,7 @@ mac_app_bundle("alert_notification_xpc_service") {
deps = [
":common",
"//base",
+ "//chrome/services/mac_notifications/public/cpp:constants",
"//third_party/crashpad/crashpad/client",
]
@@ -57,10 +58,7 @@ static_library("common") {
"notification_builder_base.mm",
"notification_builder_mac.h",
"notification_builder_mac.mm",
- "notification_constants_mac.h",
- "notification_constants_mac.mm",
"notification_delivery.h",
- "notification_operation.h",
"notification_response_builder_mac.h",
"notification_response_builder_mac.mm",
"unnotification_builder_mac.h",
@@ -71,5 +69,8 @@ static_library("common") {
"xpc_mach_port.mm",
]
- deps = [ "//base" ]
+ deps = [
+ "//base",
+ "//chrome/services/mac_notifications/public/cpp:constants",
+ ]
}
diff --git a/chromium/chrome/browser/ui/commander/BUILD.gn b/chromium/chrome/browser/ui/commander/BUILD.gn
new file mode 100644
index 00000000000..798eba3146c
--- /dev/null
+++ b/chromium/chrome/browser/ui/commander/BUILD.gn
@@ -0,0 +1,21 @@
+import("//testing/libfuzzer/fuzzer_test.gni")
+
+source_set("fuzzy_finder") {
+ sources = [
+ "fuzzy_finder.cc",
+ "fuzzy_finder.h",
+ ]
+ deps = [
+ "//base:base",
+ "//base:i18n",
+ "//ui/gfx/range",
+ ]
+}
+
+fuzzer_test("fuzzy_finder_fuzzer") {
+ sources = [ "fuzzy_finder_fuzzer.cc" ]
+ deps = [
+ ":fuzzy_finder",
+ "//base:base",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/messages/android/BUILD.gn b/chromium/chrome/browser/ui/messages/android/BUILD.gn
index 9ab66142513..c9c8ade2f35 100644
--- a/chromium/chrome/browser/ui/messages/android/BUILD.gn
+++ b/chromium/chrome/browser/ui/messages/android/BUILD.gn
@@ -40,9 +40,9 @@ android_library("java") {
"//components/infobars/android:java",
"//components/infobars/core:infobar_enums_java",
"//content/public/android:content_java",
- "//third_party/android_deps:androidx_annotation_annotation_java",
- "//third_party/android_deps:androidx_appcompat_appcompat_java",
- "//third_party/android_deps:androidx_appcompat_appcompat_resources_java",
+ "//third_party/androidx:androidx_annotation_annotation_java",
+ "//third_party/androidx:androidx_appcompat_appcompat_java",
+ "//third_party/androidx:androidx_appcompat_appcompat_resources_java",
"//ui/android:ui_full_java",
"//ui/android:ui_utils_java",
]
@@ -83,9 +83,9 @@ android_library("javatests") {
"//chrome/test/android:chrome_java_test_support",
"//content/public/android:content_java",
"//content/public/test/android:content_java_test_support",
- "//third_party/android_deps:androidx_test_runner_java",
"//third_party/android_support_test_runner:rules_java",
"//third_party/android_support_test_runner:runner_java",
+ "//third_party/androidx:androidx_test_runner_java",
"//third_party/junit",
"//ui/android:ui_java_test_support",
]
diff --git a/chromium/chrome/browser/ui/views/BUILD.gn b/chromium/chrome/browser/ui/views/BUILD.gn
index 7c9e5d3b547..54829b2cb78 100644
--- a/chromium/chrome/browser/ui/views/BUILD.gn
+++ b/chromium/chrome/browser/ui/views/BUILD.gn
@@ -2,6 +2,7 @@
# 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("//build/config/ui.gni")
import("//ui/views/features.gni")
@@ -26,6 +27,7 @@ component("views") {
deps = [
"//base",
"//build:branding_buildflags",
+ "//build:chromeos_buildflags",
"//chrome/app:command_ids",
"//chrome/app:generated_resources",
"//components/keep_alive_registry",
@@ -40,7 +42,7 @@ component("views") {
"//url",
]
- if (is_chromeos) {
+ if (is_chromeos_ash) {
deps += [ "//ash" ]
}
}
diff --git a/chromium/chrome/browser/ui/webui/DEPS b/chromium/chrome/browser/ui/webui/DEPS
index 35b8fd79336..424b07072f2 100644
--- a/chromium/chrome/browser/ui/webui/DEPS
+++ b/chromium/chrome/browser/ui/webui/DEPS
@@ -1,4 +1,6 @@
include_rules = [
+ "+ash/components/account_manager",
+ "+ash/components/audio",
"+components/services/app_service/public",
"+device/bluetooth",
"+extensions/strings/grit/extensions_strings.h",
@@ -10,4 +12,4 @@ include_rules = [
"+third_party/angle", # For ANGLE version.
"+third_party/brotli", # For compressed resources.
"+third_party/zlib/zlib.h", # For compression level constants.
-] \ No newline at end of file
+]
diff --git a/chromium/chrome/browser/ui/webui/DIR_METADATA b/chromium/chrome/browser/ui/webui/DIR_METADATA
new file mode 100644
index 00000000000..8325efaab7d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>WebUI"
+}
diff --git a/chromium/chrome/browser/ui/webui/OWNERS b/chromium/chrome/browser/ui/webui/OWNERS
index db0825c6759..c5159e358d5 100644
--- a/chromium/chrome/browser/ui/webui/OWNERS
+++ b/chromium/chrome/browser/ui/webui/OWNERS
@@ -20,11 +20,4 @@ per-file ntp_tiles_internals_ui.*=file://components/ntp_tiles/OWNERS
per-file signin_internals_ui*=achuith@chromium.org
-per-file sync_internals*=file://components/sync/OWNERS
-
per-file invalidations_message_handler.*=file://components/invalidation/OWNERS
-
-per-file policy*=file://chromeos/policy/OWNERS
-per-file policy*=file://chrome/browser/policy/OWNERS
-
-# COMPONENT: UI>Browser>WebUI
diff --git a/chromium/chrome/browser/ui/webui/about_ui.cc b/chromium/chrome/browser/ui/webui/about_ui.cc
index ea457a333aa..3d0d6375ec1 100644
--- a/chromium/chrome/browser/ui/webui/about_ui.cc
+++ b/chromium/chrome/browser/ui/webui/about_ui.cc
@@ -39,6 +39,7 @@
#include "base/threading/thread.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/defaults.h"
@@ -77,15 +78,15 @@
#include "chrome/browser/ui/webui/theme_source.h"
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include <map>
#include "base/base64.h"
#include "base/stl_util.h"
#include "base/strings/strcat.h"
+#include "chrome/browser/ash/login/demo_mode/demo_setup_controller.h"
#include "chrome/browser/browser_process_platform_part_chromeos.h"
#include "chrome/browser/chromeos/customization/customization_document.h"
-#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/component_updater/cros_component_manager.h"
#include "chromeos/system/statistics_provider.h"
@@ -101,7 +102,7 @@ constexpr char kCreditsJsPath[] = "credits.js";
constexpr char kStatsJsPath[] = "stats.js";
constexpr char kStringsJsPath[] = "strings.js";
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char kKeyboardUtilsPath[] = "keyboard_utils.js";
@@ -625,7 +626,7 @@ void AboutUIHTMLSource::StartDataRequest(
int idr = IDR_ABOUT_UI_CREDITS_HTML;
if (path == kCreditsJsPath)
idr = IDR_ABOUT_UI_CREDITS_JS;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
else if (path == kKeyboardUtilsPath)
idr = IDR_KEYBOARD_UTILS_JS;
#endif
@@ -639,7 +640,7 @@ void AboutUIHTMLSource::StartDataRequest(
} else if (source_name_ == chrome::kChromeUILinuxProxyConfigHost) {
response = AboutLinuxProxyConfig();
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
} else if (source_name_ == chrome::kChromeUIOSCreditsHost) {
ChromeOSCreditsHandler::Start(path, std::move(callback));
return;
@@ -649,7 +650,7 @@ void AboutUIHTMLSource::StartDataRequest(
#endif
#if !defined(OS_ANDROID)
} else if (source_name_ == chrome::kChromeUITermsHost) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (!path.empty()) {
ChromeOSTermsHandler::Start(path, std::move(callback));
return;
@@ -672,19 +673,18 @@ void AboutUIHTMLSource::FinishDataRequest(
}
std::string AboutUIHTMLSource::GetMimeType(const std::string& path) {
- if (path == kCreditsJsPath ||
-#if defined(OS_CHROMEOS)
+ if (path == kCreditsJsPath ||
+#if BUILDFLAG(IS_CHROMEOS_ASH)
path == kKeyboardUtilsPath ||
#endif
- path == kStatsJsPath ||
- path == kStringsJsPath) {
+ path == kStatsJsPath || path == kStringsJsPath) {
return "application/javascript";
}
return "text/html";
}
bool AboutUIHTMLSource::ShouldAddContentSecurityPolicy() {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (source_name_ == chrome::kChromeUIOSCreditsHost ||
source_name_ == chrome::kChromeUICrostiniCreditsHost) {
return false;
@@ -704,7 +704,7 @@ std::string AboutUIHTMLSource::GetContentSecurityPolicy(
std::string AboutUIHTMLSource::GetAccessControlAllowOriginForOrigin(
const std::string& origin) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Allow chrome://oobe to load chrome://terms via XHR.
if (source_name_ == chrome::kChromeUITermsHost &&
base::StartsWith(chrome::kChromeUIOobeURL, origin,
diff --git a/chromium/chrome/browser/ui/webui/about_ui_unittest.cc b/chromium/chrome/browser/ui/webui/about_ui_unittest.cc
index 9fb55c847f7..a9e8f5cc9f7 100644
--- a/chromium/chrome/browser/ui/webui/about_ui_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/about_ui_unittest.cc
@@ -19,7 +19,7 @@
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/task/post_task.h"
-#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
+#include "chrome/browser/ash/login/demo_mode/demo_setup_controller.h"
#include "chrome/browser/chromeos/login/ui/fake_login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h"
diff --git a/chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc b/chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc
index 37b0093f042..6f06af7b287 100644
--- a/chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc
+++ b/chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc
@@ -13,6 +13,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
@@ -31,6 +32,7 @@
#include "components/prefs/pref_service.h"
#include "components/signin/public/base/signin_metrics.h"
#include "components/signin/public/base/signin_pref_names.h"
+#include "components/signin/public/identity_manager/consent_level.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -82,14 +84,14 @@ AppLauncherLoginHandler::~AppLauncherLoginHandler() {}
void AppLauncherLoginHandler::RegisterMessages() {
profile_info_watcher_ = std::make_unique<ProfileInfoWatcher>(
Profile::FromWebUI(web_ui()),
- base::Bind(&AppLauncherLoginHandler::UpdateLogin,
- base::Unretained(this)));
+ base::BindRepeating(&AppLauncherLoginHandler::UpdateLogin,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"initializeSyncLogin",
base::BindRepeating(&AppLauncherLoginHandler::HandleInitializeSyncLogin,
base::Unretained(this)));
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
"showSyncLoginUI",
base::BindRepeating(&AppLauncherLoginHandler::HandleShowSyncLoginUI,
@@ -102,16 +104,17 @@ void AppLauncherLoginHandler::HandleInitializeSyncLogin(
UpdateLogin();
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void AppLauncherLoginHandler::HandleShowSyncLoginUI(
const base::ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui());
if (!signin::ShouldShowPromo(profile))
return;
- std::string username = IdentityManagerFactory::GetForProfile(profile)
- ->GetPrimaryAccountInfo()
- .email;
+ std::string username =
+ IdentityManagerFactory::GetForProfile(profile)
+ ->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
+ .email;
if (!username.empty())
return;
@@ -125,7 +128,7 @@ void AppLauncherLoginHandler::HandleShowSyncLoginUI(
web_contents->GetURL().spec() == chrome::kChromeUIAppsURL
? signin_metrics::AccessPoint::ACCESS_POINT_APPS_PAGE_LINK
: signin_metrics::AccessPoint::ACCESS_POINT_NTP_LINK;
- chrome::ShowBrowserSignin(browser, access_point);
+ chrome::ShowBrowserSignin(browser, access_point, signin::ConsentLevel::kSync);
RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED);
}
#endif
@@ -145,8 +148,9 @@ void AppLauncherLoginHandler::UpdateLogin() {
if (!username.empty()) {
ProfileAttributesStorage& storage =
g_browser_process->profile_manager()->GetProfileAttributesStorage();
- ProfileAttributesEntry* entry;
- if (storage.GetProfileAttributesWithPath(profile->GetPath(), &entry)) {
+ ProfileAttributesEntry* entry =
+ storage.GetProfileAttributesWithPath(profile->GetPath());
+ if (entry) {
// Only show the profile picture and full name for the single profile
// case. In the multi-profile case the profile picture is visible in the
// title bar and the full name can be ambiguous.
@@ -164,12 +168,12 @@ void AppLauncherLoginHandler::UpdateLogin() {
}
}
} else {
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// Chromeos does not show this status header.
bool is_signin_allowed =
profile->GetOriginalProfile()->GetPrefs()->GetBoolean(
prefs::kSigninAllowed);
- if (!profile->IsLegacySupervised() && is_signin_allowed) {
+ if (is_signin_allowed) {
base::string16 signed_in_link = l10n_util::GetStringUTF16(
IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK);
signed_in_link =
@@ -202,7 +206,7 @@ void AppLauncherLoginHandler::UpdateLogin() {
// static
bool AppLauncherLoginHandler::ShouldShow(Profile* profile) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// For now we don't care about showing sync status on Chrome OS. The promo
// UI and the avatar menu don't exist on that platform.
return false;
diff --git a/chromium/chrome/browser/ui/webui/app_launcher_login_handler.h b/chromium/chrome/browser/ui/webui/app_launcher_login_handler.h
index da07c05d622..2a787f39093 100644
--- a/chromium/chrome/browser/ui/webui/app_launcher_login_handler.h
+++ b/chromium/chrome/browser/ui/webui/app_launcher_login_handler.h
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "content/public/browser/web_ui_message_handler.h"
class Profile;
@@ -41,7 +42,7 @@ class AppLauncherLoginHandler : public content::WebUIMessageHandler {
// passed from JS and should be an empty list.
void HandleInitializeSyncLogin(const base::ListValue* args);
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// Called from JS when the user clicks the login container. It shows the
// appropriate UI based on the current sync state. |args| is the list of
// arguments passed from JS and should be an empty list.
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 f8fb2735d3b..53f974c44dc 100644
--- a/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc
+++ b/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc
@@ -7,32 +7,48 @@
#include <memory>
#include <string>
-#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_macros.h"
+#include "build/build_config.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/identity_manager_factory.h"
+#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/webui/app_launcher_login_handler.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/browser/ui/webui/ntp/app_icon_webui_handler.h"
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
#include "chrome/browser/ui/webui/ntp/app_resource_cache_factory.h"
#include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
-#include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
#include "chrome/browser/ui/webui/theme_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/browser/web_applications/web_app_provider.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "chrome/grit/apps_resources.h"
+#include "chrome/grit/apps_resources_map.h"
+#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/render_frame_host.h"
-#include "content/public/browser/render_process_host.h"
+#include "components/bookmarks/common/bookmark_pref_names.h"
+#include "components/google/core/common/google_util.h"
+#include "components/prefs/pref_change_registrar.h"
+#include "components/prefs/pref_service.h"
+#include "components/signin/public/identity_manager/identity_manager.h"
+#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
#include "extensions/browser/extension_system.h"
+#include "extensions/common/extension_urls.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/webui/web_ui_util.h"
+#include "ui/gfx/animation/animation.h"
-using content::BrowserThread;
+#if defined(OS_MAC)
+#include "chrome/browser/platform_util.h"
+#endif
///////////////////////////////////////////////////////////////////////////////
// AppLauncherPageUI
@@ -61,14 +77,122 @@ AppLauncherPageUI::AppLauncherPageUI(content::WebUI* web_ui)
// earlier.
web_ui->AddMessageHandler(std::make_unique<ThemeHandler>());
- content::URLDataSource::Add(
+ /*content::URLDataSource::Add(
GetProfile(),
- std::make_unique<HTMLSource>(GetProfile()->GetOriginalProfile()));
+ std::make_unique<HTMLSource>(GetProfile()->GetOriginalProfile()));*/
+
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIAppLauncherPageHost);
+ content::WebUIDataSource::Add(GetProfile(), source);
+
+ source->AddResourcePaths(base::make_span(kAppsResources, kAppsResourcesSize));
+ source->SetDefaultResource(IDR_APPS_NEW_TAB_HTML);
+ source->UseStringsJs();
+
+ static constexpr webui::LocalizedString kLocalizedStrings[] = {
+ {"title", IDS_NEW_TAB_TITLE},
+ {"webStoreTitle", IDS_EXTENSION_WEB_STORE_TITLE},
+ {"webStoreTitleShort", IDS_EXTENSION_WEB_STORE_TITLE_SHORT},
+ {"attributionintro", IDS_NEW_TAB_ATTRIBUTION_INTRO},
+ {"appuninstall", IDS_EXTENSIONS_UNINSTALL},
+ {"appoptions", IDS_NEW_TAB_APP_OPTIONS},
+ {"appdetails", IDS_NEW_TAB_APP_DETAILS},
+ {"appinfodialog", IDS_APP_CONTEXT_MENU_SHOW_INFO},
+ {"appcreateshortcut", IDS_NEW_TAB_APP_CREATE_SHORTCUT},
+ {"appinstalllocally", IDS_NEW_TAB_APP_INSTALL_LOCALLY},
+ {"appDefaultPageName", IDS_APP_DEFAULT_PAGE_NAME},
+ {"applaunchtypepinned", IDS_APP_CONTEXT_MENU_OPEN_PINNED},
+ {"applaunchtyperegular", IDS_APP_CONTEXT_MENU_OPEN_REGULAR},
+ {"applaunchtypewindow", IDS_APP_CONTEXT_MENU_OPEN_WINDOW},
+ {"applaunchtypefullscreen", IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN},
+ {"syncpromotext", IDS_SYNC_START_SYNC_BUTTON_LABEL},
+ {"syncLinkText", IDS_SYNC_ADVANCED_OPTIONS},
+ {"learnMore", IDS_LEARN_MORE},
+ {"appInstallHintText", IDS_NEW_TAB_APP_INSTALL_HINT_LABEL},
+ {"learn_more", IDS_LEARN_MORE},
+ {"tile_grid_screenreader_accessible_description",
+ IDS_NEW_TAB_TILE_GRID_ACCESSIBLE_DESCRIPTION},
+ {"page_switcher_change_title", IDS_NEW_TAB_PAGE_SWITCHER_CHANGE_TITLE},
+ {"page_switcher_same_title", IDS_NEW_TAB_PAGE_SWITCHER_SAME_TITLE},
+ {"runonoslogin", IDS_APP_CONTEXT_MENU_RUN_ON_OS_LOGIN},
+ };
+ source->AddLocalizedStrings(kLocalizedStrings);
+
+ PrefService* prefs = GetProfile()->GetPrefs();
+ source->AddString(
+ "bookmarkbarattached",
+ prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar) ? "true" : "false");
+
+ source->AddBoolean("shouldShowSyncLogin",
+ AppLauncherLoginHandler::ShouldShow(GetProfile()));
+
+ const std::string& app_locale = g_browser_process->GetApplicationLocale();
+ source->AddString("webStoreLink",
+ google_util::AppendGoogleLocaleParam(
+ extension_urls::GetWebstoreLaunchURL(), app_locale)
+ .spec());
+
+ bool is_swipe_tracking_from_scroll_events_enabled = false;
+#if defined(OS_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.
+ is_swipe_tracking_from_scroll_events_enabled =
+ platform_util::IsSwipeTrackingFromScrollEventsEnabled();
+#endif
+ source->AddBoolean("isSwipeTrackingFromScrollEventsEnabled",
+ is_swipe_tracking_from_scroll_events_enabled);
+
+ source->AddBoolean("showWebStoreIcon",
+ !prefs->GetBoolean(prefs::kHideWebStoreIcon));
+
+ pref_change_registrar_.Init(prefs);
+ pref_change_registrar_.Add(
+ prefs::kHideWebStoreIcon,
+ base::BindRepeating(&AppLauncherPageUI::OnHideWebStoreIconChanged,
+ base::Unretained(this)));
+
+ source->AddBoolean("canShowAppInfoDialog", CanPlatformShowAppInfoDialog());
+
+ AppLauncherHandler::RegisterLoadTimeData(GetProfile(), source);
+
+ // Control fade and resize animations.
+ source->AddBoolean("anim", gfx::Animation::ShouldRenderRichAnimation());
+
+ source->AddBoolean("isUserSignedIn",
+ IdentityManagerFactory::GetForProfile(GetProfile())
+ ->HasPrimaryAccount(signin::ConsentLevel::kSync));
+
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::ScriptSrc,
+ "script-src chrome://resources 'self' 'unsafe-eval' "
+ "'unsafe-inline';");
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::StyleSrc,
+ "style-src 'self' chrome://resources chrome://theme "
+ "'unsafe-inline';");
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::ImgSrc,
+ "img-src 'self' chrome://extension-icon chrome://app-icon chrome://theme "
+ "chrome://resources data:;");
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::TrustedTypes,
+ "trusted-types apps-page-js cr-ui-bubble-js-static "
+ "parse-html-subset;");
}
AppLauncherPageUI::~AppLauncherPageUI() {
}
+void AppLauncherPageUI::OnHideWebStoreIconChanged() {
+ std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue);
+ PrefService* prefs = GetProfile()->GetPrefs();
+ update->SetBoolean("showWebStoreIcon",
+ !prefs->GetBoolean(prefs::kHideWebStoreIcon));
+ content::WebUIDataSource::Update(
+ GetProfile(), chrome::kChromeUIAppLauncherPageHost, std::move(update));
+}
+
// static
base::RefCountedMemory* AppLauncherPageUI::GetFaviconResourceBytes(
ui::ScaleFactor scale_factor) {
@@ -92,70 +216,3 @@ bool AppLauncherPageUI::OverrideHandleWebUIMessage(
Profile* AppLauncherPageUI::GetProfile() const {
return Profile::FromWebUI(web_ui());
}
-
-///////////////////////////////////////////////////////////////////////////////
-// HTMLSource
-
-AppLauncherPageUI::HTMLSource::HTMLSource(Profile* profile)
- : profile_(profile) {
-}
-
-std::string AppLauncherPageUI::HTMLSource::GetSource() {
- return chrome::kChromeUIAppLauncherPageHost;
-}
-
-void AppLauncherPageUI::HTMLSource::StartDataRequest(
- const GURL& url,
- const content::WebContents::Getter& wc_getter,
- content::URLDataSource::GotDataCallback callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
- NTPResourceCache* resource = AppResourceCacheFactory::GetForProfile(profile_);
-
- content::WebContents* web_contents = wc_getter.Run();
- content::RenderProcessHost* render_host =
- web_contents ? web_contents->GetMainFrame()->GetProcess() : nullptr;
- NTPResourceCache::WindowType win_type = NTPResourceCache::GetWindowType(
- profile_, render_host);
- scoped_refptr<base::RefCountedMemory> html_bytes(
- resource->GetNewTabHTML(win_type));
-
- std::move(callback).Run(html_bytes.get());
-}
-
-std::string AppLauncherPageUI::HTMLSource::GetMimeType(
- const std::string& resource) {
- return "text/html";
-}
-
-bool AppLauncherPageUI::HTMLSource::ShouldReplaceExistingSource() {
- return false;
-}
-
-bool AppLauncherPageUI::HTMLSource::AllowCaching() {
- // Should not be cached to reflect dynamically-generated contents that may
- // depend on user profiles.
- return false;
-}
-
-std::string AppLauncherPageUI::HTMLSource::GetContentSecurityPolicy(
- network::mojom::CSPDirectiveName directive) {
- if (directive == network::mojom::CSPDirectiveName::ScriptSrc) {
- // 'unsafe-inline' is added to script-src.
- return "script-src chrome://resources 'self' 'unsafe-eval' "
- "'unsafe-inline';";
- } else if (directive == network::mojom::CSPDirectiveName::StyleSrc) {
- return "style-src 'self' chrome://resources chrome://theme "
- "'unsafe-inline';";
- } else if (directive == network::mojom::CSPDirectiveName::ImgSrc) {
- return "img-src chrome://extension-icon chrome://app-icon chrome://theme "
- "chrome://resources data:;";
- } else if (directive == network::mojom::CSPDirectiveName::TrustedTypes) {
- return "trusted-types apps-page-js cr-ui-bubble-js-static "
- "parse-html-subset;";
- }
-
- return content::URLDataSource::GetContentSecurityPolicy(directive);
-}
-
-AppLauncherPageUI::HTMLSource::~HTMLSource() = default;
diff --git a/chromium/chrome/browser/ui/webui/app_launcher_page_ui.h b/chromium/chrome/browser/ui/webui/app_launcher_page_ui.h
index 070ba242b3c..0733226f37f 100644
--- a/chromium/chrome/browser/ui/webui/app_launcher_page_ui.h
+++ b/chromium/chrome/browser/ui/webui/app_launcher_page_ui.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_PAGE_UI_H_
#include "base/macros.h"
-#include "content/public/browser/url_data_source.h"
+#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/web_ui_controller.h"
#include "ui/base/layout.h"
@@ -31,32 +31,10 @@ class AppLauncherPageUI : public content::WebUIController {
const base::ListValue& args) override;
private:
- class HTMLSource : public content::URLDataSource {
- public:
- explicit HTMLSource(Profile* profile);
- ~HTMLSource() override;
-
- // content::URLDataSource implementation.
- std::string GetSource() override;
- void StartDataRequest(
- const GURL& url,
- const content::WebContents::Getter& wc_getter,
- content::URLDataSource::GotDataCallback callback) override;
- std::string GetMimeType(const std::string&) override;
- bool ShouldReplaceExistingSource() override;
- bool AllowCaching() override;
- std::string GetContentSecurityPolicy(
- network::mojom::CSPDirectiveName directive) override;
-
- private:
-
- // Pointer back to the original profile.
- Profile* profile_;
-
- DISALLOW_COPY_AND_ASSIGN(HTMLSource);
- };
+ void OnHideWebStoreIconChanged();
Profile* GetProfile() const;
+ PrefChangeRegistrar pref_change_registrar_;
DISALLOW_COPY_AND_ASSIGN(AppLauncherPageUI);
};
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 1b1430cba07..7ba1410e85b 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
@@ -7,9 +7,10 @@
#include <utility>
#include <vector>
+#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
-#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "build/chromeos_buildflags.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/extensions/extension_service.h"
@@ -27,7 +28,7 @@
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "components/arc/arc_prefs.h"
@@ -37,7 +38,7 @@ using apps::mojom::OptionalBool;
namespace {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char kArcFrameworkPackage[] = "android";
constexpr int kMinAndroidFrameworkVersion = 28; // Android P
#endif
@@ -51,11 +52,11 @@ constexpr char const* kAppIdsWithHiddenPinToShelf[] = {
extension_misc::kChromeAppId,
};
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char const* kAppIdsWithHiddenStoragePermission[] = {
arc::kPlayStoreAppId,
};
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
app_management::mojom::ExtensionAppPermissionMessagePtr
CreateExtensionAppPermissionMessage(
@@ -77,7 +78,7 @@ bool ShouldHidePinToShelf(const std::string app_id) {
}
bool ShouldHideStoragePermission(const std::string app_id) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
return base::Contains(kAppIdsWithHiddenStoragePermission, app_id);
#else
return false;
@@ -98,11 +99,11 @@ AppManagementPageHandler::AppManagementPageHandler(
Observe(&proxy->AppRegistryCache());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (arc::IsArcAllowedForProfile(profile_)) {
- arc_app_list_prefs_observer_.Add(ArcAppListPrefs::Get(profile_));
+ arc_app_list_prefs_observation_.Observe(ArcAppListPrefs::Get(profile_));
}
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
AppManagementPageHandler::~AppManagementPageHandler() {}
@@ -166,7 +167,7 @@ void AppManagementPageHandler::GetExtensionAppPermissionMessages(
void AppManagementPageHandler::SetPinned(const std::string& app_id,
OptionalBool pinned) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
shelf_delegate_.SetPinned(app_id, pinned);
#else
NOTREACHED();
@@ -220,7 +221,7 @@ app_management::mojom::AppPtr AppManagementPageHandler::CreateUIAppPtr(
// On other OS's, is_pinned defaults to OptionalBool::kUnknown, which is
// used to represent the fact that there is no concept of being pinned.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
app->is_pinned = shelf_delegate_.IsPinned(update.AppId())
? OptionalBool::kTrue
: OptionalBool::kFalse;
@@ -258,7 +259,7 @@ void AppManagementPageHandler::OnAppRegistryCacheWillBeDestroyed(
Observe(nullptr);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// static
bool AppManagementPageHandler::IsCurrentArcVersionSupported(Profile* profile) {
if (arc::IsArcAllowedForProfile(profile)) {
@@ -285,4 +286,4 @@ void AppManagementPageHandler::OnPackageModified(
}
OnArcVersionChanged(package_info.package_version);
}
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.h b/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.h
index cd94f678a88..144d0ad3d0c 100644
--- a/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.h
@@ -6,7 +6,8 @@
#define CHROME_BROWSER_UI_WEBUI_APP_MANAGEMENT_APP_MANAGEMENT_PAGE_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/app_management/app_management.mojom-forward.h"
#include "chrome/browser/ui/webui/app_management/app_management_shelf_delegate_chromeos.h"
#include "components/services/app_service/public/cpp/app_registry_cache.h"
@@ -15,16 +16,16 @@
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#endif
class Profile;
class AppManagementPageHandler : public app_management::mojom::PageHandler,
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
public ArcAppListPrefs::Observer,
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
public apps::AppRegistryCache::Observer {
public:
AppManagementPageHandler(
@@ -33,14 +34,14 @@ class AppManagementPageHandler : public app_management::mojom::PageHandler,
Profile* profile);
~AppManagementPageHandler() override;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
static bool IsCurrentArcVersionSupported(Profile* profile);
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void OnPinnedChanged(const std::string& app_id, bool pinned);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void OnArcVersionChanged(int androidVersion);
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// app_management::mojom::PageHandler:
void GetApps(GetAppsCallback callback) override;
@@ -62,13 +63,13 @@ class AppManagementPageHandler : public app_management::mojom::PageHandler,
void OnAppRegistryCacheWillBeDestroyed(
apps::AppRegistryCache* cache) override;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// ArcAppListPrefs::Observer:
void OnPackageInstalled(
const arc::mojom::ArcPackageInfo& package_info) override;
void OnPackageModified(
const arc::mojom::ArcPackageInfo& package_info) override;
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
mojo::Receiver<app_management::mojom::PageHandler> receiver_;
@@ -76,11 +77,11 @@ class AppManagementPageHandler : public app_management::mojom::PageHandler,
Profile* profile_;
-#if defined(OS_CHROMEOS)
- ScopedObserver<ArcAppListPrefs, ArcAppListPrefs::Observer>
- arc_app_list_prefs_observer_{this};
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ base::ScopedObservation<ArcAppListPrefs, ArcAppListPrefs::Observer>
+ arc_app_list_prefs_observation_{this};
AppManagementShelfDelegate shelf_delegate_{this};
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
DISALLOW_COPY_AND_ASSIGN(AppManagementPageHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/DIR_METADATA b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/DIR_METADATA
new file mode 100644
index 00000000000..43d76b8a8a7
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>Passwords"
+}
diff --git a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/OWNERS b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/OWNERS
index f7b1a422a6c..64be223825b 100644
--- a/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/autofill_and_password_manager_internals/OWNERS
@@ -1,5 +1,3 @@
battre@chromium.org
dvadym@chromium.org
koerber@google.com
-
-# COMPONENT: UI>Browser>Passwords
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 e782fb857e2..e617165337f 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
@@ -8,10 +8,10 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/channel_info.h"
#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/version_info/version_info.h"
#include "components/version_ui/version_handler_helper.h"
@@ -41,7 +41,7 @@ content::WebUIDataSource* CreateInternalsHTMLSource(
: "Developer build");
source->AddString(version_ui::kVersionModifier, chrome::GetChannelName());
source->AddString(version_ui::kCL, version_info::GetLastChange());
- source->AddString(version_ui::kUserAgent, GetUserAgent());
+ source->AddString(version_ui::kUserAgent, embedder_support::GetUserAgent());
source->AddString("app_locale", g_browser_process->GetApplicationLocale());
return source;
}
@@ -128,7 +128,7 @@ void InternalsUIHandler::OnResetCache(const base::ListValue* args) {
content::BrowserContext* browser_context = Profile::FromWebUI(web_ui());
autofill_cache_resetter_.emplace(browser_context);
}
- autofill_cache_resetter_->ResetCache(base::Bind(
+ autofill_cache_resetter_->ResetCache(base::BindOnce(
&InternalsUIHandler::OnResetCacheDone, base::Unretained(this)));
}
diff --git a/chromium/chrome/browser/ui/webui/bluetooth_internals/BUILD.gn b/chromium/chrome/browser/ui/webui/bluetooth_internals/BUILD.gn
index d2a181073ad..0c6bc32be96 100644
--- a/chromium/chrome/browser/ui/webui/bluetooth_internals/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/bluetooth_internals/BUILD.gn
@@ -2,6 +2,7 @@
# 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")
source_set("bluetooth_internals") {
@@ -16,6 +17,8 @@ source_set("bluetooth_internals") {
deps = [
":mojo_bindings",
+ "//build:chromeos_buildflags",
+ "//chrome/browser/profiles:profile",
"//chrome/browser/resources/bluetooth_internals:resources",
"//chrome/common",
"//content/public/browser",
@@ -23,7 +26,7 @@ source_set("bluetooth_internals") {
"//ui/webui",
]
- if (is_chromeos) {
+ if (is_chromeos_ash) {
deps += [ "//chrome/browser/chromeos" ]
}
}
diff --git a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.cc b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.cc
index 33da2b12ec6..66a8d8507fe 100644
--- a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.cc
+++ b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.cc
@@ -9,6 +9,7 @@
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/chromeos/bluetooth/debug_logs_manager.h"
#include "device/bluetooth/adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
@@ -16,7 +17,7 @@
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "url/gurl.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/bluetooth/debug_logs_manager.h"
#endif
@@ -41,7 +42,7 @@ void BluetoothInternalsHandler::GetDebugLogsChangeHandler(
mojo::PendingRemote<mojom::DebugLogsChangeHandler> handler_remote;
bool initial_toggle_value = false;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
using chromeos::bluetooth::DebugLogsManager;
// If no logs manager exists for this user, debug logs are not supported.
diff --git a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.h b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.h
index 16e715cc515..769d962f8e3 100644
--- a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.h
+++ b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.h
@@ -6,12 +6,13 @@
#define CHROME_BROWSER_UI_WEBUI_BLUETOOTH_INTERNALS_BLUETOOTH_INTERNALS_HANDLER_H_
#include "base/macros.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals.mojom.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
namespace chromeos {
namespace bluetooth {
class DebugLogsManager;
@@ -27,7 +28,7 @@ class BluetoothInternalsHandler : public mojom::BluetoothInternalsHandler {
mojo::PendingReceiver<mojom::BluetoothInternalsHandler> receiver);
~BluetoothInternalsHandler() override;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void set_debug_logs_manager(
chromeos::bluetooth::DebugLogsManager* debug_logs_manager) {
debug_logs_manager_ = debug_logs_manager;
@@ -45,7 +46,7 @@ class BluetoothInternalsHandler : public mojom::BluetoothInternalsHandler {
mojo::Receiver<mojom::BluetoothInternalsHandler> receiver_;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::bluetooth::DebugLogsManager* debug_logs_manager_ = nullptr;
#endif
diff --git a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc
index efc6427495a..5f0efbbb89c 100644
--- a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h"
#include "base/bind.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
@@ -12,8 +13,10 @@
#include "chrome/grit/bluetooth_internals_resources.h"
#include "chrome/grit/bluetooth_internals_resources_map.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "services/network/public/mojom/content_security_policy.mojom.h"
+#include "ui/resources/grit/webui_generated_resources.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/bluetooth/debug_logs_manager_factory.h"
#endif
@@ -22,20 +25,18 @@ BluetoothInternalsUI::BluetoothInternalsUI(content::WebUI* web_ui)
// Set up the chrome://bluetooth-internals source.
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(chrome::kChromeUIBluetoothInternalsHost);
+ html_source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::ScriptSrc,
+ "script-src chrome://resources chrome://test 'self';");
+ html_source->DisableTrustedTypesCSP();
+ html_source->AddResourcePath("test_loader_util.js",
+ IDR_WEBUI_JS_TEST_LOADER_UTIL_JS);
// Add required resources.
- html_source->AddResourcePath("adapter.mojom-lite.js",
- IDR_BLUETOOTH_INTERNALS_ADAPTER_MOJO_JS);
- html_source->AddResourcePath("device.mojom-lite.js",
- IDR_BLUETOOTH_INTERNALS_DEVICE_MOJO_JS);
- html_source->AddResourcePath("bluetooth_internals.mojom-lite.js",
- IDR_BLUETOOTH_INTERNALS_MOJO_JS);
- html_source->AddResourcePath("uuid.mojom-lite.js",
- IDR_BLUETOOTH_INTERNALS_UUID_MOJO_JS);
- webui::AddResourcePathsBulk(
- html_source, base::make_span(kBluetoothInternalsResources,
- kBluetoothInternalsResourcesSize));
- html_source->SetDefaultResource(IDR_BLUETOOTH_INTERNALS_HTML);
+ html_source->AddResourcePaths(base::make_span(
+ kBluetoothInternalsResources, kBluetoothInternalsResourcesSize));
+ html_source->SetDefaultResource(
+ IDR_BLUETOOTH_INTERNALS_BLUETOOTH_INTERNALS_HTML);
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, html_source);
@@ -49,7 +50,7 @@ void BluetoothInternalsUI::BindInterface(
mojo::PendingReceiver<mojom::BluetoothInternalsHandler> receiver) {
page_handler_ =
std::make_unique<BluetoothInternalsHandler>(std::move(receiver));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
page_handler_->set_debug_logs_manager(
chromeos::bluetooth::DebugLogsManagerFactory::GetForProfile(
Profile::FromWebUI(web_ui())));
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/DIR_METADATA b/chromium/chrome/browser/ui/webui/bookmarks/DIR_METADATA
new file mode 100644
index 00000000000..087172e2e23
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/bookmarks/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>Bookmarks"
+}
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/OWNERS b/chromium/chrome/browser/ui/webui/bookmarks/OWNERS
index 267acc634e7..b963a3ff102 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/OWNERS
+++ b/chromium/chrome/browser/ui/webui/bookmarks/OWNERS
@@ -1,3 +1 @@
calamity@chromium.org
-
-# COMPONENT: UI>Browser>Bookmarks
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 801f16e8344..5cdda35448d 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_message_handler.cc
@@ -33,12 +33,12 @@ void BookmarksMessageHandler::OnJavascriptAllowed() {
pref_change_registrar_.Init(prefs);
pref_change_registrar_.Add(
prefs::kIncognitoModeAvailability,
- base::Bind(&BookmarksMessageHandler::UpdateIncognitoAvailability,
- base::Unretained(this)));
+ base::BindRepeating(&BookmarksMessageHandler::UpdateIncognitoAvailability,
+ base::Unretained(this)));
pref_change_registrar_.Add(
bookmarks::prefs::kEditBookmarksEnabled,
- base::Bind(&BookmarksMessageHandler::UpdateCanEditBookmarks,
- base::Unretained(this)));
+ base::BindRepeating(&BookmarksMessageHandler::UpdateCanEditBookmarks,
+ base::Unretained(this)));
}
void BookmarksMessageHandler::OnJavascriptDisallowed() {
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
index a1b0b5ed94d..155e3aa532d 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
+++ b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
@@ -47,7 +47,7 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIBookmarksHost);
webui::SetupWebUIDataSource(
- source, base::make_span(kBookmarksResources, kBookmarksResourcesSize), "",
+ source, base::make_span(kBookmarksResources, kBookmarksResourcesSize),
IDR_BOOKMARKS_BOOKMARKS_HTML);
// Build an Accelerator to describe undo shortcut
@@ -74,6 +74,7 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
{"emptyUnmodifiableList", IDS_BOOKMARK_MANAGER_EMPTY_UNMODIFIABLE_LIST},
{"folderLabel", IDS_BOOKMARK_MANAGER_FOLDER_LABEL},
{"itemsSelected", IDS_BOOKMARK_MANAGER_ITEMS_SELECTED},
+ {"itemsUnselected", IDS_BOOKMARK_MANAGER_ITEMS_UNSELECTED},
{"listAxLabel", IDS_BOOKMARK_MANAGER_LIST_AX_LABEL},
{"menu", IDS_MENU},
{"menuAddBookmark", IDS_BOOKMARK_MANAGER_MENU_ADD_BOOKMARK},
diff --git a/chromium/chrome/browser/ui/webui/browser_switch/DIR_METADATA b/chromium/chrome/browser/ui/webui/browser_switch/DIR_METADATA
new file mode 100644
index 00000000000..9ecb37d8b84
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/browser_switch/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "Enterprise>BrowserSwitcher"
+}
diff --git a/chromium/chrome/browser/ui/webui/browser_switch/OWNERS b/chromium/chrome/browser/ui/webui/browser_switch/OWNERS
index 02916cd005d..3bfa6d85787 100644
--- a/chromium/chrome/browser/ui/webui/browser_switch/OWNERS
+++ b/chromium/chrome/browser/ui/webui/browser_switch/OWNERS
@@ -1,4 +1,2 @@
pastarmovj@chromium.org
nicolaso@chromium.org
-
-# COMPONENT: Enterprise>BrowserSwitcher
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 d20b3478c3f..afb3ab64893 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
@@ -236,12 +236,9 @@ class BrowserSwitchHandler : public content::WebUIMessageHandler {
// Immediately re-download and apply XML rules.
void HandleRefreshXml(const base::ListValue* args);
- std::unique_ptr<browser_switcher::BrowserSwitcherPrefs::CallbackSubscription>
- prefs_subscription_;
+ base::CallbackListSubscription prefs_subscription_;
- std::unique_ptr<
- browser_switcher::BrowserSwitcherService::CallbackSubscription>
- service_subscription_;
+ base::CallbackListSubscription service_subscription_;
base::WeakPtrFactory<BrowserSwitchHandler> weak_ptr_factory_{this};
@@ -294,8 +291,8 @@ void BrowserSwitchHandler::OnJavascriptAllowed() {
}
void BrowserSwitchHandler::OnJavascriptDisallowed() {
- prefs_subscription_.reset();
- service_subscription_.reset();
+ prefs_subscription_ = {};
+ service_subscription_ = {};
}
void BrowserSwitchHandler::OnAllRulesetsParsed(
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 d250a3880c5..e93105eace7 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
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/certificate_manager_localized_strings_provider.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
@@ -80,7 +81,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_CERTIFICATE_MANAGER_CONFIRM_PASSWORD},
{"certificateImportErrorFormat",
IDS_SETTINGS_CERTIFICATE_MANAGER_IMPORT_ERROR_FORMAT},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"certificateProvisioningListHeader",
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_LIST_HEADER},
{"certificateProvisioningRefresh",
@@ -89,8 +90,10 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_DETAILS},
{"certificateProvisioningAdvancedSectionTitle",
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_ADVANCED},
- {"certificateProvisioningProfile",
- IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_CERTIFICATE_PROFILE},
+ {"certificateProvisioningProfileName",
+ IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_CERTIFICATE_PROFILE_NAME},
+ {"certificateProvisioningProfileId",
+ IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_CERTIFICATE_PROFILE_ID},
{"certificateProvisioningStatus",
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS},
{"certificateProvisioningStatusId",
@@ -98,11 +101,11 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
{"certificateProvisioningLastUpdate",
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_LAST_UPDATE},
{"certificateProvisioningPublicKey", IDS_CERT_DETAILS_SUBJECT_KEY},
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// For A11y.
{"menu", IDS_MENU},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
} // namespace certificate_manager
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 22a5e408268..7817c30c431 100644
--- a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
@@ -11,13 +11,13 @@
#include "base/strings/string16.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_common.h"
#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_scheduler_user_service.h"
#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_worker.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/common/net/x509_certificate_model_nss.h"
#include "chrome/grit/generated_resources.h"
#include "components/user_manager/user.h"
@@ -105,12 +105,14 @@ base::string16 GetTimeSinceLastUpdate(base::Time last_update_time) {
base::Value CreateProvisioningProcessEntry(
const std::string& cert_profile_id,
+ const std::string& cert_profile_name,
bool is_device_wide,
CertProvisioningWorkerState state,
base::Time time_since_last_update,
const std::string& public_key_spki_der) {
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));
@@ -134,14 +136,15 @@ void CollectProvisioningProcesses(
for (const auto& worker_entry : cert_provisioning_scheduler->GetWorkers()) {
CertProvisioningWorker* worker = worker_entry.second.get();
list_to_append_to->Append(CreateProvisioningProcessEntry(
- worker_entry.first, is_device_wide, worker->GetState(),
- worker->GetLastUpdateTime(), worker->GetPublicKey()));
+ worker_entry.first, worker->GetCertProfile().name, is_device_wide,
+ worker->GetState(), worker->GetLastUpdateTime(),
+ worker->GetPublicKey()));
}
for (const auto& failed_worker_entry :
cert_provisioning_scheduler->GetFailedCertProfileIds()) {
const FailedWorkerInfo& worker = failed_worker_entry.second;
list_to_append_to->Append(CreateProvisioningProcessEntry(
- failed_worker_entry.first, is_device_wide,
+ failed_worker_entry.first, worker.cert_profile_name, is_device_wide,
CertProvisioningWorkerState::kFailed, worker.last_update_time,
worker.public_key));
}
@@ -166,9 +169,9 @@ CertificateProvisioningUiHandler::CertificateProvisioningUiHandler(
? scheduler_for_device
: nullptr) {
if (scheduler_for_user_)
- observed_schedulers_.Add(scheduler_for_user_);
+ observed_schedulers_.AddObservation(scheduler_for_user_);
if (scheduler_for_device_)
- observed_schedulers_.Add(scheduler_for_device_);
+ observed_schedulers_.AddObservation(scheduler_for_device_);
}
CertificateProvisioningUiHandler::~CertificateProvisioningUiHandler() = default;
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 8732b3481e1..a71ce112181 100644
--- a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h
@@ -8,7 +8,7 @@
#include <utility>
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_multi_source_observation.h"
#include "base/timer/timer.h"
#include "base/values.h"
#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_scheduler.h"
@@ -109,7 +109,8 @@ class CertificateProvisioningUiHandler
// Keeps track of the CertProvisioningSchedulers that this UI handler
// observes.
- ScopedObserver<CertProvisioningScheduler, CertProvisioningSchedulerObserver>
+ base::ScopedMultiSourceObservation<CertProvisioningScheduler,
+ CertProvisioningSchedulerObserver>
observed_schedulers_{this};
base::WeakPtrFactory<CertificateProvisioningUiHandler> weak_ptr_factory_{
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 abf57ab87ae..ef18fbda19e 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
@@ -13,6 +13,7 @@
#include "base/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/values_test_util.h"
+#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_common.h"
#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_scheduler.h"
#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_test_helpers.h"
#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_worker.h"
@@ -75,12 +76,23 @@ BA 48 53 4A E2 1C 42 24 EB E5 CD 46 E0 4E 9B 2B
Public Exponent (24 bits):
01 00 01)";
+// Test values for creating CertProfile for MockCertProvisioningWorker.
+constexpr char kCertProfileVersion[] = "cert_profile_version_1";
+constexpr base::TimeDelta kCertProfileRenewalPeriod =
+ base::TimeDelta::FromSeconds(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(MockCertProvisioningWorker* worker,
CertProvisioningWorkerState state,
- const std::string* public_key) {
+ const std::string* public_key,
+ CertProfile& cert_profile) {
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));
}
// Recursively visits all strings in |value| and replaces placeholders such as
@@ -263,17 +275,23 @@ TEST_F(CertificateProvisioningUiHandlerTest, NoProcesses) {
}
TEST_F(CertificateProvisioningUiHandlerTest, HasProcesses) {
+ CertProfile user_cert_profile(
+ kUserCertProfileId, kUserCertProfileName, kCertProfileVersion,
+ /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
auto user_cert_worker = std::make_unique<MockCertProvisioningWorker>();
SetupMockCertProvisioningWorker(
user_cert_worker.get(), CertProvisioningWorkerState::kKeypairGenerated,
- &der_encoded_spki_);
- user_workers_["user_cert_profile_1"] = std::move(user_cert_worker);
+ &der_encoded_spki_, user_cert_profile);
+ user_workers_[kUserCertProfileId] = std::move(user_cert_worker);
+ CertProfile device_cert_profile(
+ kDeviceCertProfileId, kDeviceCertProfileName, kCertProfileVersion,
+ /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
auto device_cert_worker = std::make_unique<MockCertProvisioningWorker>();
SetupMockCertProvisioningWorker(
device_cert_worker.get(), CertProvisioningWorkerState::kKeypairGenerated,
- &der_encoded_spki_);
- device_workers_["device_cert_profile_1"] = std::move(device_cert_worker);
+ &der_encoded_spki_, device_cert_profile);
+ 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.
@@ -281,36 +299,42 @@ TEST_F(CertificateProvisioningUiHandlerTest, HasProcesses) {
std::vector<std::string> profile_ids;
ASSERT_NO_FATAL_FAILURE(
RefreshCertProvisioningProcesses(&all_processes, &profile_ids));
- ASSERT_THAT(profile_ids, UnorderedElementsAre("user_cert_profile_1"));
-
+ ASSERT_THAT(profile_ids, UnorderedElementsAre(kUserCertProfileId));
EXPECT_EQ(
- GetByProfileId(all_processes, "user_cert_profile_1"),
+ GetByProfileId(all_processes, kUserCertProfileId),
FormatJsonDict(
R"({
- "certProfileId": "user_cert_profile_1",
+ "certProfileId": "$0",
+ "certProfileName": "$1",
"isDeviceWide": false,
- "publicKey": "$0",
+ "publicKey": "$2",
"stateId": 1,
- "status": "$1",
+ "status": "$3",
"timeSinceLastUpdate": ""
})",
- {kFormattedPublicKey,
+ {kUserCertProfileId, kUserCertProfileName, kFormattedPublicKey,
l10n_util::GetStringUTF8(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING)}));
}
TEST_F(CertificateProvisioningUiHandlerAffiliatedTest, HasProcessesAffiliated) {
+ CertProfile user_cert_profile(
+ kUserCertProfileId, kUserCertProfileName, kCertProfileVersion,
+ /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
auto user_cert_worker = std::make_unique<MockCertProvisioningWorker>();
SetupMockCertProvisioningWorker(
user_cert_worker.get(), CertProvisioningWorkerState::kKeypairGenerated,
- &der_encoded_spki_);
- user_workers_["user_cert_profile_1"] = std::move(user_cert_worker);
+ &der_encoded_spki_, user_cert_profile);
+ user_workers_[kUserCertProfileId] = std::move(user_cert_worker);
+ CertProfile device_cert_profile(
+ kDeviceCertProfileId, kDeviceCertProfileName, kCertProfileVersion,
+ /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
auto device_cert_worker = std::make_unique<MockCertProvisioningWorker>();
SetupMockCertProvisioningWorker(device_cert_worker.get(),
CertProvisioningWorkerState::kFailed,
- &der_encoded_spki_);
- device_workers_["device_cert_profile_1"] = std::move(device_cert_worker);
+ &der_encoded_spki_, device_cert_profile);
+ 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.
@@ -318,35 +342,37 @@ TEST_F(CertificateProvisioningUiHandlerAffiliatedTest, HasProcessesAffiliated) {
std::vector<std::string> profile_ids;
ASSERT_NO_FATAL_FAILURE(
RefreshCertProvisioningProcesses(&all_processes, &profile_ids));
- ASSERT_THAT(profile_ids, UnorderedElementsAre("user_cert_profile_1",
- "device_cert_profile_1"));
+ ASSERT_THAT(profile_ids,
+ UnorderedElementsAre(kUserCertProfileId, kDeviceCertProfileId));
EXPECT_EQ(
- GetByProfileId(all_processes, "user_cert_profile_1"),
+ GetByProfileId(all_processes, kUserCertProfileId),
FormatJsonDict(
R"({
- "certProfileId": "user_cert_profile_1",
+ "certProfileId": "$0",
+ "certProfileName": "$1",
"isDeviceWide": false,
- "publicKey": "$0",
+ "publicKey": "$2",
"stateId": 1,
- "status": "$1",
+ "status": "$3",
"timeSinceLastUpdate": ""
})",
- {kFormattedPublicKey,
+ {kUserCertProfileId, kUserCertProfileName, kFormattedPublicKey,
l10n_util::GetStringUTF8(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING)}));
EXPECT_EQ(
- GetByProfileId(all_processes, "device_cert_profile_1"),
+ GetByProfileId(all_processes, kDeviceCertProfileId),
FormatJsonDict(
R"({
- "certProfileId": "device_cert_profile_1",
+ "certProfileId": "$0",
+ "certProfileName": "$1",
"isDeviceWide": true,
- "publicKey": "$0",
+ "publicKey": "$2",
"stateId": 10,
- "status": "$1",
+ "status": "$3",
"timeSinceLastUpdate": ""
})",
- {kFormattedPublicKey,
+ {kDeviceCertProfileId, kDeviceCertProfileName, kFormattedPublicKey,
l10n_util::GetStringUTF8(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_FAILURE)}));
}
@@ -362,11 +388,14 @@ TEST_F(CertificateProvisioningUiHandlerTest, Updates) {
ASSERT_THAT(profile_ids, UnorderedElementsAre());
EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
+ CertProfile user_cert_profile(
+ kUserCertProfileId, kUserCertProfileName, kCertProfileVersion,
+ /*is_va_enabled=*/true, kCertProfileRenewalPeriod);
auto user_cert_worker = std::make_unique<MockCertProvisioningWorker>();
SetupMockCertProvisioningWorker(
user_cert_worker.get(), CertProvisioningWorkerState::kKeypairGenerated,
- &der_encoded_spki_);
- user_workers_["user_cert_profile_1"] = std::move(user_cert_worker);
+ &der_encoded_spki_, user_cert_profile);
+ user_workers_[kUserCertProfileId] = std::move(user_cert_worker);
// The user worker triggers an update
content::TestWebUIListenerObserver result_waiter_1(
@@ -381,20 +410,21 @@ TEST_F(CertificateProvisioningUiHandlerTest, Updates) {
// Only the user worker is expected to be displayed in the UI, because the
// user is not affiliated.
- ASSERT_THAT(profile_ids, UnorderedElementsAre("user_cert_profile_1"));
+ ASSERT_THAT(profile_ids, UnorderedElementsAre(kUserCertProfileId));
EXPECT_EQ(
- GetByProfileId(all_processes, "user_cert_profile_1"),
+ GetByProfileId(all_processes, kUserCertProfileId),
FormatJsonDict(
R"({
- "certProfileId": "user_cert_profile_1",
+ "certProfileId": "$0",
+ "certProfileName": "$1",
"isDeviceWide": false,
- "publicKey": "$0",
+ "publicKey": "$2",
"stateId": 1,
- "status": "$1",
+ "status": "$3",
"timeSinceLastUpdate": ""
})",
- {kFormattedPublicKey,
+ {kUserCertProfileId, kUserCertProfileName, kFormattedPublicKey,
l10n_util::GetStringUTF8(
IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING)}));
diff --git a/chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc b/chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc
index 651ea3608e8..5d259226c36 100644
--- a/chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc
+++ b/chromium/chrome/browser/ui/webui/certificate_viewer_ui.cc
@@ -46,11 +46,14 @@ content::WebUIDataSource* GetWebUIDataSource(const std::string& host) {
{"certFields", IDS_CERT_DETAILS_CERTIFICATE_FIELDS_LABEL},
{"certFieldVal", IDS_CERT_DETAILS_CERTIFICATE_FIELD_VALUE_LABEL},
};
- AddLocalizedStringsBulk(html_source, kStrings);
+ html_source->AddLocalizedStrings(kStrings);
html_source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::TrustedTypes,
- "trusted-types cr-ui-tree-js-static;");
+ "trusted-types cr-ui-tree-js-static certificate-test-script;");
+ html_source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::ScriptSrc,
+ "script-src chrome://resources chrome://test 'self';");
html_source->UseStringsJs();
diff --git a/chromium/chrome/browser/ui/webui/certificates_handler.cc b/chromium/chrome/browser/ui/webui/certificates_handler.cc
index d6a44ad5af2..285bf4168d0 100644
--- a/chromium/chrome/browser/ui/webui/certificates_handler.cc
+++ b/chromium/chrome/browser/ui/webui/certificates_handler.cc
@@ -25,6 +25,7 @@
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/certificate_viewer.h"
#include "chrome/browser/profiles/profile.h"
@@ -185,20 +186,20 @@ class FileAccessProvider
public:
// The first parameter is 0 on success or errno on failure. The second
// parameter is read result.
- typedef base::Callback<void(const int*, const std::string*)> ReadCallback;
+ typedef base::OnceCallback<void(const int*, const std::string*)> ReadCallback;
// The first parameter is 0 on success or errno on failure. The second
// parameter is the number of bytes written on success.
- typedef base::Callback<void(const int*, const int*)> WriteCallback;
+ typedef base::OnceCallback<void(const int*, const int*)> WriteCallback;
base::CancelableTaskTracker::TaskId StartRead(
const base::FilePath& path,
- const ReadCallback& callback,
+ ReadCallback callback,
base::CancelableTaskTracker* tracker);
base::CancelableTaskTracker::TaskId StartWrite(
const base::FilePath& path,
const std::string& data,
- const WriteCallback& callback,
+ WriteCallback callback,
base::CancelableTaskTracker* tracker);
private:
@@ -218,7 +219,7 @@ class FileAccessProvider
base::CancelableTaskTracker::TaskId FileAccessProvider::StartRead(
const base::FilePath& path,
- const ReadCallback& callback,
+ ReadCallback callback,
base::CancelableTaskTracker* tracker) {
// Owned by reply callback posted below.
int* saved_errno = new int(0);
@@ -231,13 +232,14 @@ base::CancelableTaskTracker::TaskId FileAccessProvider::StartRead(
task_runner.get(), FROM_HERE,
base::BindOnce(&FileAccessProvider::DoRead, this, path, saved_errno,
data),
- base::BindOnce(callback, base::Owned(saved_errno), base::Owned(data)));
+ base::BindOnce(std::move(callback), base::Owned(saved_errno),
+ base::Owned(data)));
}
base::CancelableTaskTracker::TaskId FileAccessProvider::StartWrite(
const base::FilePath& path,
const std::string& data,
- const WriteCallback& callback,
+ WriteCallback callback,
base::CancelableTaskTracker* tracker) {
// Owned by reply callback posted below.
int* saved_errno = new int(0);
@@ -251,7 +253,7 @@ base::CancelableTaskTracker::TaskId FileAccessProvider::StartWrite(
task_runner.get(), FROM_HERE,
base::BindOnce(&FileAccessProvider::DoWrite, this, path, data,
saved_errno, bytes_written),
- base::BindOnce(callback, base::Owned(saved_errno),
+ base::BindOnce(std::move(callback), base::Owned(saved_errno),
base::Owned(bytes_written)));
}
@@ -552,8 +554,8 @@ void CertificatesHandler::ExportPersonalSlotsUnlocked() {
}
file_access_provider_->StartWrite(
file_path_, output,
- base::Bind(&CertificatesHandler::ExportPersonalFileWritten,
- base::Unretained(this)),
+ base::BindOnce(&CertificatesHandler::ExportPersonalFileWritten,
+ base::Unretained(this)),
&tracker_);
}
@@ -573,7 +575,7 @@ void CertificatesHandler::ExportPersonalFileWritten(const int* write_errno,
}
void CertificatesHandler::HandleImportPersonal(const base::ListValue* args) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// When policy changes while user on the certificate manager page, the UI
// doesn't update without page refresh and user can still see and use import
// button. Because of this 'return' the button will do nothing.
@@ -609,8 +611,8 @@ void CertificatesHandler::ImportPersonalFileSelected(
const base::FilePath& path) {
file_access_provider_->StartRead(
path,
- base::Bind(&CertificatesHandler::ImportPersonalFileRead,
- base::Unretained(this)),
+ base::BindOnce(&CertificatesHandler::ImportPersonalFileRead,
+ base::Unretained(this)),
&tracker_);
}
@@ -758,8 +760,8 @@ void CertificatesHandler::HandleImportServer(const base::ListValue* args) {
void CertificatesHandler::ImportServerFileSelected(const base::FilePath& path) {
file_access_provider_->StartRead(
path,
- base::Bind(&CertificatesHandler::ImportServerFileRead,
- base::Unretained(this)),
+ base::BindOnce(&CertificatesHandler::ImportServerFileRead,
+ base::Unretained(this)),
&tracker_);
}
@@ -810,14 +812,14 @@ void CertificatesHandler::ImportServerFileRead(const int* read_errno,
}
void CertificatesHandler::HandleImportCA(const base::ListValue* args) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// When policy changes while user on the certificate manager page, the UI
// doesn't update without page refresh and user can still see and use import
// button. Because of this 'return' the button will do nothing.
if (!IsCACertificateManagementAllowedPolicy(CertificateSource::kImported)) {
return;
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
CHECK_EQ(1U, args->GetSize());
AssignWebUICallbackId(args);
@@ -834,8 +836,8 @@ void CertificatesHandler::HandleImportCA(const base::ListValue* args) {
void CertificatesHandler::ImportCAFileSelected(const base::FilePath& path) {
file_access_provider_->StartRead(
path,
- base::Bind(&CertificatesHandler::ImportCAFileRead,
- base::Unretained(this)),
+ base::BindOnce(&CertificatesHandler::ImportCAFileRead,
+ base::Unretained(this)),
&tracker_);
}
@@ -965,12 +967,12 @@ void CertificatesHandler::OnCertificateManagerModelCreated(
void CertificatesHandler::CertificateManagerModelReady() {
bool client_import_allowed = true;
bool ca_import_allowed = true;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
client_import_allowed =
IsClientCertificateManagementAllowedPolicy(Slot::kUser);
ca_import_allowed =
IsCACertificateManagementAllowedPolicy(CertificateSource::kImported);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
if (IsJavascriptAllowed()) {
FireWebUIListener("client-import-allowed-changed",
base::Value(client_import_allowed));
@@ -1157,7 +1159,7 @@ CertificatesHandler::GetCertInfoFromCallbackArgs(const base::Value& args,
return cert_info_id_map_.Lookup(cert_info_id);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
bool CertificatesHandler::IsClientCertificateManagementAllowedPolicy(
Slot slot) const {
Profile* profile = Profile::FromWebUI(web_ui());
@@ -1185,7 +1187,7 @@ bool CertificatesHandler::IsCACertificateManagementAllowedPolicy(
return policy_value != CACertificateManagementPermission::kNone;
}
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
bool CertificatesHandler::CanDeleteCertificate(
const CertificateManagerModel::CertInfo* cert_info) const {
@@ -1195,7 +1197,7 @@ bool CertificatesHandler::CanDeleteCertificate(
return false;
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (cert_info->type() == net::CertType::USER_CERT) {
return IsClientCertificateManagementAllowedPolicy(
cert_info->device_wide() ? Slot::kSystem : Slot::kUser);
@@ -1206,7 +1208,7 @@ bool CertificatesHandler::CanDeleteCertificate(
: CertificateSource::kBuiltIn;
return IsCACertificateManagementAllowedPolicy(source);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return true;
}
@@ -1217,16 +1219,16 @@ bool CertificatesHandler::CanEditCertificate(
CertificateManagerModel::CertInfo::Source::kPolicy)) {
return false;
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
CertificateSource source = cert_info->can_be_deleted()
? CertificateSource::kImported
: CertificateSource::kBuiltIn;
return IsCACertificateManagementAllowedPolicy(source);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return true;
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void CertificatesHandler::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
// Allow users to manage all client certificates by default. This can be
@@ -1241,6 +1243,6 @@ void CertificatesHandler::RegisterProfilePrefs(
prefs::kCACertificateManagementAllowed,
static_cast<int>(CACertificateManagementPermission::kAll));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace certificate_manager
diff --git a/chromium/chrome/browser/ui/webui/certificates_handler.h b/chromium/chrome/browser/ui/webui/certificates_handler.h
index e346efa177e..ec6dda4dcd2 100644
--- a/chromium/chrome/browser/ui/webui/certificates_handler.h
+++ b/chromium/chrome/browser/ui/webui/certificates_handler.h
@@ -13,6 +13,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/task/cancelable_task_tracker.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/certificate_manager_model.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "net/cert/nss_cert_database.h"
@@ -23,7 +24,7 @@ namespace user_prefs {
class PrefRegistrySyncable;
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
enum class Slot { kUser, kSystem };
enum class CertificateSource { kBuiltIn, kImported };
@@ -50,7 +51,7 @@ enum class CACertificateManagementPermission : int {
// Disallow users from managing certificates
kNone = 2
};
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace certificate_manager {
@@ -75,7 +76,7 @@ class CertificatesHandler : public content::WebUIMessageHandler,
void* params) override;
void FileSelectionCanceled(void* params) override;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Register profile preferences.
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
#endif
@@ -201,7 +202,7 @@ class CertificatesHandler : public content::WebUIMessageHandler,
const base::Value& args,
size_t arg_index);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Returns true if the user may manage certificates on |slot| according
// to ClientCertificateManagementAllowed policy.
bool IsClientCertificateManagementAllowedPolicy(Slot slot) const;
@@ -209,7 +210,7 @@ class CertificatesHandler : public content::WebUIMessageHandler,
// Returns true if the user may manage certificates according
// to CACertificateManagementAllowed policy.
bool IsCACertificateManagementAllowedPolicy(CertificateSource source) const;
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Returns true if the certificate represented by |cert_info| can be deleted.
bool CanDeleteCertificate(
diff --git a/chromium/chrome/browser/ui/webui/certificates_handler_unittest.cc b/chromium/chrome/browser/ui/webui/certificates_handler_unittest.cc
index 6ada07d72d6..9d2e4314bca 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 "build/chromeos_buildflags.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
@@ -21,11 +22,11 @@ class CertificateHandlerTest : public ChromeRenderViewHostTestHarness {
pref_service_ = profile()->GetTestingPrefService();
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
bool IsCACertificateManagementAllowedPolicy(CertificateSource source) const {
return cert_handler_.IsCACertificateManagementAllowedPolicy(source);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
bool CanDeleteCertificate(
const CertificateManagerModel::CertInfo* cert_info) const {
@@ -43,7 +44,7 @@ class CertificateHandlerTest : public ChromeRenderViewHostTestHarness {
sync_preferences::TestingPrefServiceSyncable* pref_service_ = nullptr;
};
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(CertificateHandlerTest, IsCACertificateManagementAllowedPolicyTest) {
{
pref_service_->SetInteger(
@@ -78,7 +79,7 @@ TEST_F(CertificateHandlerTest, IsCACertificateManagementAllowedPolicyTest) {
IsCACertificateManagementAllowedPolicy(CertificateSource::kBuiltIn));
}
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(CertificateHandlerTest, CanDeleteCertificateCommonTest) {
CertificateManagerModel::CertInfo default_cert_info(
@@ -126,7 +127,7 @@ TEST_F(CertificateHandlerTest, CanDeleteUserCertificateTest) {
EXPECT_TRUE(CanDeleteCertificate(&cert_info));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{
pref_service_->SetInteger(
prefs::kClientCertificateManagementAllowed,
@@ -162,7 +163,7 @@ TEST_F(CertificateHandlerTest, CanDeleteUserCertificateTest) {
cert_info.device_wide_ = true;
EXPECT_FALSE(CanDeleteCertificate(&cert_info));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
TEST_F(CertificateHandlerTest, CanDeleteCACertificateTest) {
@@ -180,7 +181,7 @@ TEST_F(CertificateHandlerTest, CanDeleteCACertificateTest) {
EXPECT_TRUE(CanDeleteCertificate(&cert_info));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{
pref_service_->SetInteger(
prefs::kCACertificateManagementAllowed,
@@ -215,7 +216,7 @@ TEST_F(CertificateHandlerTest, CanDeleteCACertificateTest) {
cert_info.can_be_deleted_ = true;
EXPECT_FALSE(CanDeleteCertificate(&cert_info));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
TEST_F(CertificateHandlerTest, CanEditCertificateCommonTest) {
@@ -259,7 +260,7 @@ TEST_F(CertificateHandlerTest, CanEditUserCertificateTest) {
EXPECT_FALSE(CanEditCertificate(&cert_info));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{
pref_service_->SetInteger(
prefs::kClientCertificateManagementAllowed,
@@ -295,7 +296,7 @@ TEST_F(CertificateHandlerTest, CanEditUserCertificateTest) {
cert_info.device_wide_ = true;
EXPECT_FALSE(CanEditCertificate(&cert_info));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
TEST_F(CertificateHandlerTest, CanEditCACertificateTest) {
@@ -313,7 +314,7 @@ TEST_F(CertificateHandlerTest, CanEditCACertificateTest) {
EXPECT_TRUE(CanEditCertificate(&cert_info));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{
pref_service_->SetInteger(
prefs::kCACertificateManagementAllowed,
@@ -349,5 +350,5 @@ TEST_F(CertificateHandlerTest, CanEditCACertificateTest) {
cert_info.can_be_deleted_ = true;
EXPECT_FALSE(CanEditCertificate(&cert_info));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
diff --git a/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_controller_factory.cc b/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_controller_factory.cc
new file mode 100644
index 00000000000..6be318681f9
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_controller_factory.cc
@@ -0,0 +1,81 @@
+// 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/chrome_untrusted_web_ui_controller_factory.h"
+
+#include "base/no_destructor.h"
+#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "content/public/common/url_constants.h"
+#include "ui/webui/webui_config.h"
+#include "url/gurl.h"
+
+#if defined(OS_ANDROID)
+#include "chrome/browser/ui/webui/video_tutorials/video_player_ui.h"
+#endif // defined(OS_ANDROID)
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/chromeos/web_applications/terminal_ui.h"
+#if !defined(OFFICIAL_BUILD)
+#include "chromeos/components/sample_system_web_app_ui/untrusted_sample_system_web_app_ui.h"
+#endif // !defined(OFFICIAL_BUILD)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+
+using WebUIConfigList =
+ std::vector<std::pair<std::string, std::unique_ptr<ui::WebUIConfig>>>;
+
+namespace {
+
+// Returns a std::vector<> containing all WebUIConfigs. We use a vector instead
+// of adding WebUIConfigs directly into the flat_map because individual inserts
+// are O(n), giving O(n^2) construction time for the entire map. By contrast,
+// constructing from a vector is O(n log n).
+WebUIConfigList CreateConfigs() {
+ WebUIConfigList config_list;
+ auto register_config =
+ [&config_list](std::unique_ptr<ui::WebUIConfig> config) {
+ DCHECK_EQ(config->scheme(), content::kChromeUIUntrustedScheme);
+ const std::string& host = config->host();
+ config_list.emplace_back(host, std::move(config));
+ };
+ // Delete once register_config is used outside of Chrome OS.
+ ALLOW_UNUSED_LOCAL(register_config);
+
+ // Register WebUIConfigs below.
+#if defined(OS_ANDROID)
+ register_config(std::make_unique<video_tutorials::VideoPlayerUIConfig>());
+#endif // defined(OS_ANDROID)
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ register_config(std::make_unique<TerminalUIConfig>());
+#if !defined(OFFICIAL_BUILD)
+ register_config(
+ std::make_unique<chromeos::UntrustedSampleSystemWebAppUIConfig>());
+#endif // !defined(OFFICIAL_BUILD)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+
+ return config_list;
+}
+
+} // namespace
+
+// static
+void ChromeUntrustedWebUIControllerFactory::RegisterInstance() {
+ static base::NoDestructor<ChromeUntrustedWebUIControllerFactory> instance;
+ content::WebUIControllerFactory::RegisterFactory(instance.get());
+}
+
+ChromeUntrustedWebUIControllerFactory::ChromeUntrustedWebUIControllerFactory()
+ : configs_(CreateConfigs()) {}
+
+ChromeUntrustedWebUIControllerFactory::
+ ~ChromeUntrustedWebUIControllerFactory() = default;
+
+const ui::UntrustedWebUIControllerFactory::WebUIConfigMap&
+ChromeUntrustedWebUIControllerFactory::GetWebUIConfigMap() {
+ return configs_;
+}
diff --git a/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_controller_factory.h b/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_controller_factory.h
new file mode 100644
index 00000000000..fd16bca71a3
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chrome_untrusted_web_ui_controller_factory.h
@@ -0,0 +1,30 @@
+// 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_CHROME_UNTRUSTED_WEB_UI_CONTROLLER_FACTORY_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROME_UNTRUSTED_WEB_UI_CONTROLLER_FACTORY_H_
+
+#include "ui/webui/untrusted_web_ui_controller_factory.h"
+
+class ChromeUntrustedWebUIControllerFactory
+ : public ui::UntrustedWebUIControllerFactory {
+ public:
+ // Register the singleton instance of this class.
+ static void RegisterInstance();
+
+ ChromeUntrustedWebUIControllerFactory();
+ ChromeUntrustedWebUIControllerFactory(
+ const ChromeUntrustedWebUIControllerFactory&) = delete;
+ ChromeUntrustedWebUIControllerFactory& operator=(
+ const ChromeUntrustedWebUIControllerFactory&) = delete;
+
+ protected:
+ const WebUIConfigMap& GetWebUIConfigMap() override;
+
+ private:
+ ~ChromeUntrustedWebUIControllerFactory() override;
+ WebUIConfigMap configs_;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROME_UNTRUSTED_WEB_UI_CONTROLLER_FACTORY_H_
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 e42e6dd995e..d784a95efe4 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
@@ -2,11 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string_piece.h"
+#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/webui/welcome/helpers.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -21,36 +25,6 @@
namespace {
-class NavigationNotificationObserver : public content::NotificationObserver {
- public:
- NavigationNotificationObserver()
- : got_navigation_(false),
- http_status_code_(0) {
- registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
- content::NotificationService::AllSources());
- }
-
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override {
- DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
- got_navigation_ = true;
- http_status_code_ =
- content::Details<content::LoadCommittedDetails>(details)->
- http_status_code;
- }
-
- int http_status_code() const { return http_status_code_; }
- bool got_navigation() const { return got_navigation_; }
-
- private:
- content::NotificationRegistrar registrar_;
- int got_navigation_;
- int http_status_code_;
-
- DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver);
-};
-
class NavigationObserver : public content::WebContentsObserver {
public:
enum NavigationResult {
@@ -68,10 +42,19 @@ public:
navigation_result_ =
navigation_handle->IsErrorPage() ? ERROR_PAGE : SUCCESS;
net_error_ = navigation_handle->GetNetErrorCode();
+ got_navigation_ = true;
+ if (navigation_handle->HasCommitted() &&
+ !navigation_handle->IsSameDocument() &&
+ !navigation_handle->IsErrorPage()) {
+ http_status_code_ =
+ navigation_handle->GetResponseHeaders()->response_code();
+ }
}
NavigationResult navigation_result() const { return navigation_result_; }
net::Error net_error() const { return net_error_; }
+ bool got_navigation() const { return got_navigation_; }
+ int http_status_code() const { return http_status_code_; }
void Reset() {
navigation_result_ = NOT_FINISHED;
@@ -81,6 +64,8 @@ public:
private:
NavigationResult navigation_result_;
net::Error net_error_ = net::OK;
+ bool got_navigation_ = false;
+ int http_status_code_ = -1;
DISALLOW_COPY_AND_ASSIGN(NavigationObserver);
};
@@ -92,7 +77,8 @@ typedef InProcessBrowserTest ChromeURLDataManagerTest;
// Makes sure navigating to the new tab page results in a http status code
// of 200.
IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, 200) {
- NavigationNotificationObserver observer;
+ NavigationObserver observer(
+ browser()->tab_strip_model()->GetActiveWebContents());
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
EXPECT_TRUE(observer.got_navigation());
EXPECT_EQ(200, observer.http_status_code());
@@ -142,7 +128,14 @@ class ChromeURLDataManagerWebUITrustedTypesTest
: public InProcessBrowserTest,
public testing::WithParamInterface<const char*> {
public:
- ChromeURLDataManagerWebUITrustedTypesTest() = default;
+ ChromeURLDataManagerWebUITrustedTypesTest() {
+ std::vector<base::Feature> enabled_features;
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
+ if (GetParam() == std::string("chrome://welcome"))
+ enabled_features.push_back(welcome::kForceEnabled);
+#endif
+ feature_list_.InitWithFeatures(enabled_features, {});
+ }
void CheckTrustedTypesViolation(base::StringPiece url) {
std::string message_filter1 = "*This document requires*assignment*";
@@ -155,16 +148,26 @@ class ChromeURLDataManagerWebUITrustedTypesTest
ASSERT_TRUE(embedded_test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL(url));
- // We don't ASSERT_TRUE here because some WebUI pages are by design not
- // PAGE_TYPE_NORMAL (e.g. chrome://interstitials/ssl).
- content::WaitForLoadStop(content);
+
+ if (url == "chrome://network-error" || url == "chrome://dino") {
+ // We don't ASSERT_TRUE here because some WebUI pages are
+ // PAGE_TYPE_ERROR by design.
+ content::WaitForLoadStop(content);
+ } else {
+ ASSERT_TRUE(content::WaitForLoadStop(content));
+ }
+
EXPECT_TRUE(console_observer.messages().empty());
}
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
};
// Verify that there's no Trusted Types violation in chrome://chrome-urls
IN_PROC_BROWSER_TEST_P(ChromeURLDataManagerWebUITrustedTypesTest,
NoTrustedTypesViolation) {
+ LOG(INFO) << "Navigating to " << GetParam();
CheckTrustedTypesViolation(GetParam());
}
@@ -175,23 +178,18 @@ static constexpr const char* const kChromeUrls[] = {
// TODO(crbug.com/1114074): DCHECK failure when opening
// chrome://appcache-internals.
// "chrome://appcache-internals",
- "chrome://apps",
"chrome://autofill-internals",
"chrome://blob-internals",
"chrome://bluetooth-internals",
"chrome://bookmarks",
- "chrome://browser-switch",
"chrome://chrome-urls",
"chrome://components",
- "chrome://conflicts",
"chrome://connection-help",
"chrome://connection-monitoring-detected",
"chrome://conversion-internals",
"chrome://crashes",
"chrome://credits",
"chrome://device-log",
- // TODO(crbug.com/1114062): Crash when closing chrome://devices.
- // "chrome://devices",
"chrome://dino",
// TODO(crbug.com/1113446): Test failure due to excessive output.
// "chrome://discards",
@@ -210,25 +208,20 @@ static constexpr const char* const kChromeUrls[] = {
"chrome://inspect",
"chrome://internals/web-app",
"chrome://interstitials/ssl",
- "chrome://interventions-internals",
"chrome://invalidations",
"chrome://local-state",
"chrome://management",
- "chrome://md-user-manager",
"chrome://media-engagement",
- "chrome://media-feeds",
"chrome://media-history",
"chrome://media-internals",
"chrome://media-router-internals",
"chrome://memory-internals",
- "chrome://nacl",
"chrome://net-export",
"chrome://net-internals",
"chrome://network-error",
"chrome://network-errors",
"chrome://new-tab-page",
"chrome://newtab",
- "chrome://notifications-internals",
"chrome://ntp-tiles-internals",
"chrome://omnibox",
"chrome://password-manager-internals",
@@ -240,16 +233,13 @@ static constexpr const char* const kChromeUrls[] = {
"chrome://quota-internals",
"chrome://reset-password",
"chrome://safe-browsing",
- "chrome://sandbox",
"chrome://serviceworker-internals",
"chrome://settings",
// TODO(crbug.com/1115600): DCHECK failure when opening
// chrome://signin-dice-web-intercept.
// "chrome://signin-dice-web-intercept",
- "chrome://signin-email-confirmation",
"chrome://signin-internals",
"chrome://site-engagement",
- "chrome://snippets-internals",
"chrome://suggestions",
// TODO(crbug.com/1099564): Navigating to chrome://sync-confirmation and
// quickly navigating away cause DCHECK failure.
@@ -269,15 +259,15 @@ static constexpr const char* const kChromeUrls[] = {
"chrome://version",
"chrome://webrtc-internals",
"chrome://webrtc-logs",
- "chrome://welcome",
#if defined(OS_ANDROID)
"chrome://explore-sites-internals",
"chrome://internals/notifications",
"chrome://internals/query-tiles",
"chrome://offline-internals",
+ "chrome://snippets-internals",
"chrome://webapks",
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
"chrome://account-manager-error",
"chrome://account-manager-welcome",
"chrome://account-migration-welcome",
@@ -288,13 +278,12 @@ static constexpr const char* const kChromeUrls[] = {
// "chrome://arc-overview-tracing",
"chrome://assistant-optin",
"chrome://bluetooth-pairing",
- "chrome://cellular-setup",
"chrome://certificate-manager",
"chrome://crostini-credits",
"chrome://crostini-installer",
"chrome://cryptohome",
"chrome://drive-internals",
- "chrome://first-run",
+ "chrome://family-link-user-internals",
"chrome://help-app",
"chrome://internet-config-dialog",
"chrome://internet-detail-dialog",
@@ -311,13 +300,22 @@ static constexpr const char* const kChromeUrls[] = {
"chrome://slow",
"chrome://smb-credentials-dialog",
"chrome://smb-share-dialog",
- "chrome://supervised-user-internals",
"chrome://sys-internals",
- // TODO(crbug.com/1115643): DCHECK failure when opening
- // chrome-untrusted://crosh.
- // "chrome-untrusted://crosh",
"chrome-untrusted://terminal",
#endif
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
+ "chrome://apps",
+ "chrome://browser-switch",
+ "chrome://signin-email-confirmation",
+ "chrome://welcome",
+#endif
+#if !defined(OS_MAC)
+ "chrome://sandbox",
+ "chrome://nacl",
+#endif
+#if defined(OS_WIN)
+ "chrome://conflicts",
+#endif
};
INSTANTIATE_TEST_SUITE_P(,
diff --git a/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc b/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc
index 41c795ede53..868c0254910 100644
--- a/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc
@@ -35,13 +35,17 @@ WebContents* ChromeWebContentsHandler::OpenURLFromTab(
WebContents* source,
const OpenURLParams& params) {
if (!context)
- return NULL;
+ return nullptr;
Profile* profile = Profile::FromBrowserContext(context);
Browser* browser = chrome::FindTabbedBrowser(profile, false);
const bool browser_created = !browser;
if (!browser) {
+ if (Browser::GetCreationStatusForProfile(profile) !=
+ Browser::CreationStatus::kOk) {
+ return nullptr;
+ }
// TODO(erg): OpenURLParams should pass a user_gesture flag, pass it to
// CreateParams, and pass the real value to nav_params below.
browser = Browser::Create(
@@ -89,12 +93,10 @@ void ChromeWebContentsHandler::AddNewContents(
Browser* browser = chrome::FindTabbedBrowser(profile, false);
const bool browser_created = !browser;
if (!browser) {
- // TODO(https://crbug.com/1141608): Remove when root cause is found.
- if (Browser::GetBrowserCreationStatusForProfile(profile) !=
- Browser::BrowserCreationStatus::kOk) {
- NOTREACHED() << "Browser creation status: "
- << static_cast<int>(
- Browser::GetBrowserCreationStatusForProfile(profile));
+ // The request can be triggered by Captive portal when browser is not ready
+ // (https://crbug.com/1141608).
+ if (Browser::GetCreationStatusForProfile(profile) !=
+ Browser::CreationStatus::kOk) {
return;
}
browser = Browser::Create(
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 36103b6f487..96a009f80e1 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
@@ -13,12 +13,11 @@
#include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/accessibility/accessibility_ui.h"
#include "chrome/browser/buildflags.h"
-#include "chrome/browser/chromeos/login/login_pref_names.h"
#include "chrome/browser/devtools/devtools_ui_bindings.h"
-#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/media/history/media_history_keyed_service.h"
#include "chrome/browser/media/media_engagement_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -29,13 +28,6 @@
#include "chrome/browser/ui/webui/autofill_and_password_manager_internals/autofill_internals_ui.h"
#include "chrome/browser/ui/webui/autofill_and_password_manager_internals/password_manager_internals_ui.h"
#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h"
-#include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.h"
-#include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_ui.h"
-#include "chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.h"
-#include "chrome/browser/ui/webui/chromeos/chrome_url_disabled/chrome_url_disabled_ui.h"
-#include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h"
-#include "chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.h"
-#include "chrome/browser/ui/webui/commander/commander_ui.h"
#include "chrome/browser/ui/webui/components/components_ui.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/browser/ui/webui/crashes_ui.h"
@@ -43,13 +35,11 @@
#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_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/identity_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/interventions_internals/interventions_internals_ui.h"
-#include "chrome/browser/ui/webui/invalidations_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"
#include "chrome/browser/ui/webui/media/media_engagement_ui.h"
@@ -61,17 +51,15 @@
#include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
#include "chrome/browser/ui/webui/ntp_tiles_internals_ui.h"
#include "chrome/browser/ui/webui/omnibox/omnibox_ui.h"
-#include "chrome/browser/ui/webui/policy_ui.h"
+#include "chrome/browser/ui/webui/policy/policy_ui.h"
#include "chrome/browser/ui/webui/predictors/predictors_ui.h"
#include "chrome/browser/ui/webui/quota_internals/quota_internals_ui.h"
-#include "chrome/browser/ui/webui/settings/settings_ui.h"
-#include "chrome/browser/ui/webui/settings_utils.h"
#include "chrome/browser/ui/webui/signin_internals_ui.h"
-#include "chrome/browser/ui/webui/sync_internals_ui.h"
+#include "chrome/browser/ui/webui/sync_internals/sync_internals_ui.h"
#include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h"
#include "chrome/browser/ui/webui/usb_internals/usb_internals_ui.h"
#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
-#include "chrome/browser/ui/webui/version_ui.h"
+#include "chrome/browser/ui/webui/version/version_ui.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_features.h"
@@ -83,6 +71,7 @@
#include "components/favicon_base/select_favicon_frames.h"
#include "components/grit/components_scaled_resources.h"
#include "components/history/core/browser/history_types.h"
+#include "components/memories/core/memories_features.h"
#include "components/nacl/common/buildflags.h"
#include "components/prefs/pref_service.h"
#include "components/reading_list/features/reading_list_switches.h"
@@ -94,6 +83,7 @@
#include "components/security_interstitials/content/known_interception_disclosure_ui.h"
#include "components/security_interstitials/content/urls.h"
#include "components/signin/public/base/signin_buildflags.h"
+#include "components/site_engagement/content/site_engagement_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/content_client.h"
@@ -123,26 +113,30 @@
#include "chrome/browser/ui/webui/explore_sites_internals/explore_sites_internals_ui.h"
#include "chrome/browser/ui/webui/feed_internals/feed_internals_ui.h"
#include "chrome/browser/ui/webui/offline/offline_internals_ui.h"
-#include "chrome/browser/ui/webui/webapks_ui.h"
+#include "chrome/browser/ui/webui/webapks/webapks_ui.h"
#include "components/feed/buildflags.h"
#include "components/feed/feed_feature_list.h"
#else // defined(OS_ANDROID)
#include "chrome/browser/media/feeds/media_feeds_service.h"
-#include "chrome/browser/media/kaleidoscope/constants.h"
-#include "chrome/browser/media/kaleidoscope/kaleidoscope_ui.h"
#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/bookmarks/bookmarks_ui.h"
+#include "chrome/browser/ui/webui/commander/commander_ui.h"
#include "chrome/browser/ui/webui/devtools_ui.h"
#include "chrome/browser/ui/webui/downloads/downloads_ui.h"
+#include "chrome/browser/ui/webui/feedback/feedback_ui.h"
#include "chrome/browser/ui/webui/history/history_ui.h"
+#include "chrome/browser/ui/webui/identity_internals_ui.h"
#include "chrome/browser/ui/webui/inspect_ui.h"
-#include "chrome/browser/ui/webui/management_ui.h"
+#include "chrome/browser/ui/webui/management/management_ui.h"
#include "chrome/browser/ui/webui/media_router/media_router_internals_ui.h"
+#include "chrome/browser/ui/webui/memories/memories_ui.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page_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/read_later/read_later_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/signin/inline_login_ui.h"
#include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h"
#include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.h"
@@ -152,12 +146,16 @@
#include "media/base/media_switches.h"
#endif // defined(OS_ANDROID)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/constants/ash_features.h"
+#include "ash/constants/ash_switches.h"
#include "base/system/sys_info.h"
+#include "chrome/browser/ash/login/easy_unlock/easy_unlock_service.h"
+#include "chrome/browser/ash/login/easy_unlock/easy_unlock_service_factory.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/device_sync/device_sync_client_factory.h"
-#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h"
-#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_factory.h"
+#include "chrome/browser/chromeos/file_manager/path_util.h"
+#include "chrome/browser/chromeos/login/login_pref_names.h"
#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_service_factory.h"
#include "chrome/browser/chromeos/net/network_health/network_health_service.h"
#include "chrome/browser/chromeos/printing/print_management/printing_manager.h"
@@ -165,25 +163,31 @@
#include "chrome/browser/chromeos/scanning/scan_service.h"
#include "chrome/browser/chromeos/scanning/scan_service_factory.h"
#include "chrome/browser/chromeos/scanning/scanning_paths_provider_impl.h"
+#include "chrome/browser/chromeos/scanning/scanning_util.h"
#include "chrome/browser/chromeos/secure_channel/secure_channel_client_provider.h"
#include "chrome/browser/chromeos/web_applications/chrome_camera_app_ui_delegate.h"
#include "chrome/browser/chromeos/web_applications/chrome_help_app_ui_delegate.h"
#include "chrome/browser/chromeos/web_applications/chrome_media_app_ui_delegate.h"
#include "chrome/browser/feedback/feedback_dialog_utils.h"
-#include "chrome/browser/nearby_sharing/common/nearby_share_features.h"
+#include "chrome/browser/nearby_sharing/nearby_sharing_service_factory.h"
+#include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_error_ui.h"
+#include "chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_ui.h"
+#include "chrome/browser/ui/webui/chromeos/account_manager/account_migration_welcome_ui.h"
#include "chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui.h"
#include "chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_ui.h"
#include "chrome/browser/ui/webui/chromeos/arc_power_control/arc_power_control_ui.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h"
#include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.h"
-#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_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/chrome_url_disabled/chrome_url_disabled_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"
#include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
-#include "chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h"
+#include "chrome/browser/ui/webui/chromeos/emoji/emoji_picker.h"
+#include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h"
+#include "chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.h"
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
@@ -207,6 +211,8 @@
#include "chromeos/components/connectivity_diagnostics/url_constants.h"
#include "chromeos/components/diagnostics_ui/diagnostics_ui.h"
#include "chromeos/components/diagnostics_ui/url_constants.h"
+#include "chromeos/components/eche_app_ui/eche_app_ui.h"
+#include "chromeos/components/eche_app_ui/url_constants.h"
#include "chromeos/components/help_app_ui/help_app_ui.h"
#include "chromeos/components/help_app_ui/url_constants.h"
#include "chromeos/components/media_app_ui/media_app_guest_ui.h"
@@ -218,15 +224,14 @@
#include "chromeos/components/print_management/url_constants.h"
#include "chromeos/components/scanning/scanning_ui.h"
#include "chromeos/components/scanning/url_constants.h"
-#include "chromeos/constants/chromeos_features.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/services/multidevice_setup/multidevice_setup_service.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "chromeos/services/network_health/public/mojom/network_diagnostics.mojom.h"
+#include "chromeos/services/network_health/public/mojom/network_health.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#endif
-#if defined(OS_CHROMEOS) && !defined(OFFICIAL_BUILD)
+#if BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OFFICIAL_BUILD)
#include "chrome/browser/chromeos/web_applications/chrome_file_manager_ui_delegate.h"
#include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.h"
#include "chromeos/components/file_manager/file_manager_ui.h"
@@ -237,15 +242,15 @@
#include "chromeos/components/telemetry_extension_ui/url_constants.h"
#endif
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/webui/app_launcher_page_ui.h"
#endif
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
-#include "chrome/browser/ui/webui/webui_js_exception/webui_js_exception_ui.h"
+#include "chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.h"
#endif
-#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OS_ANDROID)
#include "chrome/browser/ui/sync/sync_promo_ui.h"
#include "chrome/browser/ui/webui/browser_switch/browser_switch_ui.h"
#include "chrome/browser/ui/webui/signin/profile_customization_ui.h"
@@ -253,7 +258,6 @@
#include "chrome/browser/ui/webui/signin/signin_email_confirmation_ui.h"
#include "chrome/browser/ui/webui/signin/signin_error_ui.h"
#include "chrome/browser/ui/webui/signin/signin_reauth_ui.h"
-#include "chrome/browser/ui/webui/signin/user_manager_ui.h"
#include "chrome/browser/ui/webui/welcome/helpers.h"
#include "chrome/browser/ui/webui/welcome/welcome_ui.h"
#endif
@@ -293,13 +297,17 @@
#endif
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-#include "chrome/browser/ui/webui/supervised_user_internals_ui.h"
+#include "chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.h"
#endif
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
#include "chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.h"
#endif
+#if BUILDFLAG(ENABLE_SESSION_SERVICE)
+#include "chrome/browser/ui/webui/sessions/session_service_internals_ui.h"
+#endif
+
using content::WebUI;
using content::WebUIController;
using ui::WebDialogUI;
@@ -317,6 +325,14 @@ WebUIController* NewWebUI(WebUI* web_ui, const GURL& url) {
return new T(web_ui);
}
+// Template for handlers defined in a component layer, that take an instance of
+// a delegate implemented in the chrome layer.
+template <class WEB_UI_CONTROLLER, class DELEGATE>
+WebUIController* NewComponentUI(WebUI* web_ui, const GURL& url) {
+ auto delegate = std::make_unique<DELEGATE>(web_ui);
+ return new WEB_UI_CONTROLLER(web_ui, std::move(delegate));
+}
+
#if !defined(OS_ANDROID)
template <>
WebUIController* NewWebUI<PageNotAvailableForGuestUI>(WebUI* web_ui,
@@ -331,42 +347,12 @@ WebUIController* NewWebUI<AboutUI>(WebUI* web_ui, const GURL& url) {
return new AboutUI(web_ui, url.host());
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
template <>
WebUIController* NewWebUI<chromeos::OobeUI>(WebUI* web_ui, const GURL& url) {
return new chromeos::OobeUI(web_ui, url);
}
-template <>
-WebUIController* NewWebUI<chromeos::CameraAppUI>(WebUI* web_ui,
- const GURL& url) {
- auto delegate = std::make_unique<ChromeCameraAppUIDelegate>(web_ui);
- return new chromeos::CameraAppUI(web_ui, std::move(delegate));
-}
-
-#if !defined(OFFICIAL_BUILD)
-template <>
-WebUIController* NewWebUI<chromeos::file_manager::FileManagerUI>(
- WebUI* web_ui,
- const GURL& url) {
- auto delegate = std::make_unique<ChromeFileManagerUIDelegate>();
- return new chromeos::file_manager::FileManagerUI(web_ui, std::move(delegate));
-}
-#endif // !defined(OFFICIAL_BUILD)
-
-template <>
-WebUIController* NewWebUI<chromeos::HelpAppUI>(WebUI* web_ui, const GURL& url) {
- auto delegate = std::make_unique<ChromeHelpAppUIDelegate>(web_ui);
- return new chromeos::HelpAppUI(web_ui, std::move(delegate));
-}
-
-template <>
-WebUIController* NewWebUI<chromeos::MediaAppUI>(WebUI* web_ui,
- const GURL& url) {
- auto delegate = std::make_unique<ChromeMediaAppUIDelegate>(web_ui);
- return new chromeos::MediaAppUI(web_ui, std::move(delegate));
-}
-
void BindPrintManagement(
Profile* profile,
mojo::PendingReceiver<
@@ -407,10 +393,22 @@ std::unique_ptr<ui::SelectFilePolicy> CreateChromeSelectFilePolicy(
template <>
WebUIController* NewWebUI<chromeos::ScanningUI>(WebUI* web_ui,
const GURL& url) {
+ Profile* profile = Profile::FromWebUI(web_ui);
return new chromeos::ScanningUI(
- web_ui, base::BindRepeating(&BindScanService, Profile::FromWebUI(web_ui)),
+ web_ui, base::BindRepeating(&BindScanService, profile),
base::BindRepeating(&CreateChromeSelectFilePolicy),
- std::make_unique<chromeos::ScanningPathsProviderImpl>());
+ std::make_unique<chromeos::ScanningPathsProviderImpl>(),
+ base::BindRepeating(
+ &chromeos::scanning::ShowFileInFilesApp,
+ chromeos::scanning::GetDrivePath(profile),
+ file_manager::util::GetMyFilesFolderForProfile(profile)));
+}
+
+template <>
+WebUIController* NewWebUI<chromeos::DiagnosticsDialogUI>(WebUI* web_ui,
+ const GURL& url) {
+ return new chromeos::DiagnosticsDialogUI(
+ web_ui, base::BindRepeating(&CreateChromeSelectFilePolicy));
}
void BindMultiDeviceSetup(
@@ -453,19 +451,26 @@ WebUIController* NewWebUI<chromeos::ConnectivityDiagnosticsUI>(
chromeos::network_health::NetworkHealthService::GetInstance()
->BindDiagnosticsReceiver(std::move(receiver));
}),
+ /* BindNetworkHealthServiceCallback */
+ base::BindRepeating(
+ [](mojo::PendingReceiver<
+ chromeos::network_health::mojom::NetworkHealthService> receiver) {
+ chromeos::network_health::NetworkHealthService::GetInstance()
+ ->BindHealthReceiver(std::move(receiver));
+ }),
/* SendFeedbackReportCallback */
base::BindRepeating(
&chrome::ShowFeedbackDialogForWebUI,
chrome::WebUIFeedbackSource::kConnectivityDiagnostics));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
template <>
WebUIController* NewWebUI<WelcomeUI>(WebUI* web_ui, const GURL& url) {
return new WelcomeUI(web_ui, url);
}
-#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
bool IsAboutUI(const GURL& url) {
return (url.host_piece() == chrome::kChromeUIChromeURLsHost ||
@@ -476,7 +481,7 @@ bool IsAboutUI(const GURL& url) {
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_OPENBSD)
|| url.host_piece() == chrome::kChromeUILinuxProxyConfigHost
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
|| url.host_piece() == chrome::kChromeUIOSCreditsHost ||
url.host_piece() == chrome::kChromeUICrostiniCreditsHost
#endif
@@ -511,10 +516,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chrome::kChromeUIAutofillInternalsHost)
return &NewWebUI<AutofillInternalsUI>;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (url.host_piece() == chrome::kChromeUIAppDisabledHost)
return &NewWebUI<chromeos::ChromeURLDisabledUI>;
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
if (url.host_piece() == chrome::kChromeUIBluetoothInternalsHost)
return &NewWebUI<BluetoothInternalsUI>;
@@ -541,8 +546,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<InternalsUI>;
if (url.host_piece() == chrome::kChromeUIInterstitialHost)
return &NewWebUI<InterstitialUI>;
- if (url.host_piece() == chrome::kChromeUIInterventionsInternalsHost)
- return &NewWebUI<InterventionsInternalsUI>;
if (url.host_piece() == chrome::kChromeUIInvalidationsHost)
return &NewWebUI<InvalidationsUI>;
if (url.host_piece() ==
@@ -587,14 +590,14 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<VersionUI>;
#if !defined(OS_ANDROID)
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// AppLauncherPage is not needed on Android or ChromeOS.
if (url.host_piece() == chrome::kChromeUIAppLauncherPageHost && profile &&
extensions::ExtensionSystem::Get(profile)->extension_service() &&
!profile->IsGuestSession()) {
return &NewWebUI<AppLauncherPageUI>;
}
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
if (profile->IsGuestSession() &&
(url.host_piece() == chrome::kChromeUIAppLauncherPageHost ||
url.host_piece() == chrome::kChromeUIBookmarksHost ||
@@ -603,6 +606,12 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
url.host_piece() == chrome::kChromeUINewTabPageHost)) {
return &NewWebUI<PageNotAvailableForGuestUI>;
}
+ if (profile->IsEphemeralGuestProfile() &&
+ (url.host_piece() == chrome::kChromeUIBookmarksHost ||
+ url.host_piece() == chrome::kChromeUIExtensionsHost ||
+ url.host_piece() == chrome::kChromeUINewTabPageHost)) {
+ return &NewWebUI<PageNotAvailableForGuestUI>;
+ }
// Bookmarks are part of NTP on Android.
if (url.host_piece() == chrome::kChromeUIBookmarksHost)
return &NewWebUI<BookmarksUI>;
@@ -618,6 +627,14 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<NewTabUI>;
if (url.host_piece() == chrome::kChromeUINewTabPageHost)
return &NewWebUI<NewTabPageUI>;
+ if (base::FeatureList::IsEnabled(features::kWebUIFeedback)) {
+ if (url.host_piece() == chrome::kChromeUIFeedbackHost)
+ return &NewWebUI<FeedbackUI>;
+ }
+ if (base::FeatureList::IsEnabled(memories::kMemories)) {
+ if (url.host_piece() == chrome::kChromeUIMemoriesHost)
+ return &NewWebUI<MemoriesUI>;
+ }
if (base::FeatureList::IsEnabled(reading_list::switches::kReadLater)) {
if (url.host_piece() == chrome::kChromeUIReadLaterHost)
return &NewWebUI<ReadLaterUI>;
@@ -647,7 +664,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chrome::kChromeUIConflictsHost)
return &NewWebUI<ConflictsUI>;
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (url.host_piece() == chrome::kChromeUIPasswordChangeHost) {
if (!profile->GetPrefs()->GetBoolean(
chromeos::prefs::kSamlInSessionPasswordChangeEnabled)) {
@@ -671,8 +688,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::UrgentPasswordExpiryNotificationUI>;
}
if (url.host_piece() == chrome::kChromeUILockScreenStartReauthHost) {
- if (!profile->GetPrefs()->GetBoolean(
- chromeos::prefs::kSamlLockScreenReauthenticationEnabled)) {
+ if (!ash::features::IsSamlReauthenticationOnLockscreenEnabled()) {
return nullptr;
}
return &NewWebUI<chromeos::LockScreenStartReauthUI>;
@@ -687,10 +703,12 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::AddSupervisionUI>;
if (url.host_piece() == chrome::kChromeUIBluetoothPairingHost)
return &NewWebUI<chromeos::BluetoothPairingDialogUI>;
- if (url.host_piece() == chrome::kChromeUICellularSetupHost)
- return &NewWebUI<chromeos::cellular_setup::CellularSetupDialogUI>;
+// TODO(crbug.com/1147032): The certificates settings page is temporarily
+// disabled for Lacros-Chrome until a better solution is found.
+#if !BUILDFLAG(IS_CHROMEOS_LACROS)
if (url.host_piece() == chrome::kChromeUICertificateManagerHost)
return &NewWebUI<chromeos::CertificateManagerDialogUI>;
+#endif // !BUILDFLAG(IS_CHROMEOS_LACROS)
if (base::FeatureList::IsEnabled(
chromeos::features::kConnectivityDiagnosticsWebUi) &&
url.host_piece() == chromeos::kChromeUIConnectivityDiagnosticsHost) {
@@ -705,10 +723,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::CryptohomeUI>;
if (url.host_piece() == chrome::kChromeUIDriveInternalsHost)
return &NewWebUI<chromeos::DriveInternalsUI>;
- if (url.host_piece() == chrome::kChromeUIFirstRunHost)
- return &NewWebUI<chromeos::FirstRunUI>;
if (url.host_piece() == chromeos::kChromeUIHelpAppHost)
- return &NewWebUI<chromeos::HelpAppUI>;
+ return &NewComponentUI<chromeos::HelpAppUI, ChromeHelpAppUIDelegate>;
if (url.host_piece() == chrome::kChromeUIMachineLearningInternalsHost)
return &NewWebUI<chromeos::machine_learning::MachineLearningInternalsUI>;
if (url.host_piece() == chrome::kChromeUIMobileSetupHost)
@@ -727,11 +743,9 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::PowerUI>;
if (base::FeatureList::IsEnabled(chromeos::features::kDiagnosticsApp) &&
url.host_piece() == chromeos::kChromeUIDiagnosticsAppHost) {
- return &NewWebUI<chromeos::DiagnosticsUI>;
+ return &NewWebUI<chromeos::DiagnosticsDialogUI>;
}
- if (base::FeatureList::IsEnabled(
- chromeos::features::kPrintJobManagementApp) &&
- url.host_piece() == chromeos::kChromeUIPrintManagementHost)
+ if (url.host_piece() == chromeos::kChromeUIPrintManagementHost)
return &NewWebUI<chromeos::printing::printing_manager::PrintManagementUI>;
if (base::FeatureList::IsEnabled(chromeos::features::kScanningUI) &&
url.host_piece() == chromeos::kChromeUIScanningAppHost) {
@@ -739,7 +753,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
if (base::FeatureList::IsEnabled(chromeos::features::kMediaApp)) {
if (url.host_piece() == chromeos::kChromeUIMediaAppHost)
- return &NewWebUI<chromeos::MediaAppUI>;
+ return &NewComponentUI<chromeos::MediaAppUI, ChromeMediaAppUIDelegate>;
}
if (url.host_piece() == chromeos::multidevice::kChromeUIProximityAuthHost &&
profile->IsRegularProfile()) {
@@ -749,11 +763,11 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::InternetConfigDialogUI>;
if (url.host_piece() == chrome::kChromeUIInternetDetailDialogHost)
return &NewWebUI<chromeos::InternetDetailDialogUI>;
- if (base::FeatureList::IsEnabled(features::kNearbySharing)) {
- if (url.host_piece() == chrome::kChromeUINearbyShareHost &&
- profile->IsRegularProfile()) {
- return &NewWebUI<nearby_share::NearbyShareDialogUI>;
- }
+ if (NearbySharingServiceFactory::IsNearbyShareSupportedForBrowserContext(
+ profile) &&
+ url.host_piece() == chrome::kChromeUINearbyShareHost &&
+ profile->IsRegularProfile()) {
+ return &NewWebUI<nearby_share::NearbyShareDialogUI>;
}
if (url.host_piece() == chrome::kChromeUISetTimeHost)
return &NewWebUI<chromeos::SetTimeUI>;
@@ -772,7 +786,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chromeos::kChromeUICameraAppHost &&
web_app::SystemWebAppManager::IsAppEnabled(
web_app::SystemAppType::CAMERA)) {
- return &NewWebUI<chromeos::CameraAppUI>;
+ return &NewComponentUI<chromeos::CameraAppUI, ChromeCameraAppUIDelegate>;
}
if (url.host_piece() == chrome::kChromeUINearbyInternalsHost)
return &NewWebUI<NearbyInternalsUI>;
@@ -789,6 +803,14 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::ArcPowerControlUI>;
}
}
+ if (url.host_piece() == chrome::kChromeUIEmojiPickerHost &&
+ base::FeatureList::IsEnabled(chromeos::features::kImeSystemEmojiPicker)) {
+ return &NewWebUI<chromeos::EmojiPicker>;
+ }
+ if (url.host_piece() == chromeos::eche_app::kChromeUIEcheAppHost &&
+ base::FeatureList::IsEnabled(chromeos::features::kEcheSWA)) {
+ return &NewWebUI<chromeos::eche_app::EcheAppUI>;
+ }
#if !defined(OFFICIAL_BUILD)
#if !defined(USE_REAL_DBUS_CLIENTS)
@@ -797,8 +819,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<DeviceEmulatorUI>;
}
#endif // !defined(USE_REAL_DBUS_CLIENTS)
- if (url.host_piece() == chromeos::file_manager::kChromeUIFileManagerHost)
- return &NewWebUI<chromeos::file_manager::FileManagerUI>;
+ if (url.host_piece() == chromeos::file_manager::kChromeUIFileManagerHost) {
+ return &NewComponentUI<chromeos::file_manager::FileManagerUI,
+ ChromeFileManagerUIDelegate>;
+ }
if (url.host_piece() == chromeos::kChromeUISampleSystemWebAppHost)
return &NewWebUI<chromeos::SampleSystemWebAppUI>;
if (url.host_piece() == chromeos::kChromeUITelemetryExtensionHost) {
@@ -807,10 +831,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
}
#endif // !defined(OFFICIAL_BUILD)
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
- if (url.host_piece() == chrome::kChromeUIWebUIJsExceptionHost)
- return &NewWebUI<WebUIJsExceptionUI>;
+ if (url.host_piece() == chrome::kChromeUIWebUIJsErrorHost)
+ return &NewWebUI<WebUIJsErrorUI>;
#endif
#if defined(OS_ANDROID)
if (url.host_piece() == chrome::kChromeUIExploreSitesInternalsHost &&
@@ -820,11 +844,11 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<OfflineInternalsUI>;
if (url.host_piece() == chrome::kChromeUISnippetsInternalsHost &&
!profile->IsOffTheRecord()) {
-#if BUILDFLAG(ENABLE_FEED_V1) || BUILDFLAG(ENABLE_FEED_V2)
+#if BUILDFLAG(ENABLE_FEED_V2)
return &NewWebUI<FeedInternalsUI>;
#else
return nullptr;
-#endif // BUILDFLAG(ENABLE_FEED_V1) || BUILDFLAG(ENABLE_FEED_V2)
+#endif // BUILDFLAG(ENABLE_FEED_V2)
}
if (url.host_piece() == chrome::kChromeUIWebApksHost)
return &NewWebUI<WebApksUI>;
@@ -844,13 +868,11 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<SyncConfirmationUI>;
}
#endif // defined(OS_ANDROID)
-#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OS_ANDROID)
if (url.host_piece() == chrome::kChromeUIProfileCustomizationHost)
return &NewWebUI<ProfileCustomizationUI>;
if (url.host_piece() == chrome::kChromeUIProfilePickerHost)
return &NewWebUI<ProfilePickerUI>;
- if (url.host_piece() == chrome::kChromeUIMdUserManagerHost)
- return &NewWebUI<UserManagerUI>;
if (url.host_piece() == chrome::kChromeUISigninErrorHost &&
(!profile->IsOffTheRecord() || profile->IsSystemProfile()))
return &NewWebUI<SigninErrorUI>;
@@ -866,12 +888,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<WelcomeUI>;
#endif
-#if !defined(OS_ANDROID)
- if (base::FeatureList::IsEnabled(media::kKaleidoscope)) {
- if (url.host_piece() == kKaleidoscopeUIHost)
- return &NewWebUI<KaleidoscopeUI>;
- }
-#endif // !defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_NACL)
if (url.host_piece() == chrome::kChromeUINaClHost)
return &NewWebUI<NaClUI>;
@@ -931,8 +947,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chrome::kChromeUIDiscardsHost)
return &NewWebUI<DiscardsUI>;
#endif
+// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
+// of lacros-chrome is complete.
#if defined(OS_WIN) || defined(OS_MAC) || \
- (defined(OS_LINUX) && !defined(OS_CHROMEOS))
+ (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
if (url.host_piece() == chrome::kChromeUIBrowserSwitchHost)
return &NewWebUI<BrowserSwitchUI>;
#endif
@@ -943,7 +961,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<security_interstitials::ConnectionHelpUI>;
}
- if (SiteEngagementService::IsEnabled() &&
+ if (site_engagement::SiteEngagementService::IsEnabled() &&
url.host_piece() == chrome::kChromeUISiteEngagementHost) {
return &NewWebUI<SiteEngagementUI>;
}
@@ -972,8 +990,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
#endif
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- if (url.host_piece() == chrome::kChromeUISupervisedUserInternalsHost)
- return &NewWebUI<SupervisedUserInternalsUI>;
+ if (url.host_piece() == chrome::kChromeUIFamilyLinkUserInternalsHost)
+ return &NewWebUI<FamilyLinkUserInternalsUI>;
#endif
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
@@ -981,6 +999,11 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<DiceWebSigninInterceptUI>;
#endif
+#if BUILDFLAG(ENABLE_SESSION_SERVICE)
+ if (url.host_piece() == chrome::kChromeUISessionServiceInternalsHost)
+ return &NewWebUI<SessionServiceInternalsUI>;
+#endif
+
return nullptr;
}
@@ -1001,12 +1024,6 @@ bool ChromeWebUIControllerFactory::UseWebUIForURL(
return GetWebUIType(browser_context, url) != WebUI::kNoWebUI;
}
-bool ChromeWebUIControllerFactory::UseWebUIBindingsForURL(
- content::BrowserContext* browser_context,
- const GURL& url) {
- return UseWebUIForURL(browser_context, url);
-}
-
std::unique_ptr<WebUIController>
ChromeWebUIControllerFactory::CreateWebUIControllerForURL(WebUI* web_ui,
const GURL& url) {
@@ -1143,11 +1160,11 @@ base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
return FlagsUI::GetFaviconResourceBytes(scale_factor);
#if !defined(OS_ANDROID)
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// The Apps launcher page is not available on android or ChromeOS.
if (page_url.host_piece() == chrome::kChromeUIAppLauncherPageHost)
return AppLauncherPageUI::GetFaviconResourceBytes(scale_factor);
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
// Bookmarks are part of NTP on Android.
if (page_url.host_piece() == chrome::kChromeUIBookmarksHost)
@@ -1161,8 +1178,13 @@ base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
return DownloadsUI::GetFaviconResourceBytes(scale_factor);
// Android doesn't use the Options/Settings pages.
- if (page_url.host_piece() == chrome::kChromeUISettingsHost)
+ if (page_url.host_piece() == chrome::kChromeUISettingsHost) {
+ if (page_url.path() == chrome::kPrivacySandboxSubPagePath) {
+ return settings_utils::GetPrivacySandboxFaviconResourceBytes(
+ scale_factor);
+ }
return settings_utils::GetFaviconResourceBytes(scale_factor);
+ }
if (page_url.host_piece() == chrome::kChromeUIManagementHost)
return ManagementUI::GetFaviconResourceBytes(scale_factor);
@@ -1174,10 +1196,10 @@ base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
#endif // !defined(OS_ANDROID)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (page_url.host_piece() == chrome::kChromeUIOSSettingsHost)
return settings_utils::GetFaviconResourceBytes(scale_factor);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return nullptr;
}
diff --git a/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h b/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h
index ada994e360c..860d0e2a028 100644
--- a/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h
+++ b/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h
@@ -41,8 +41,6 @@ class ChromeWebUIControllerFactory : public content::WebUIControllerFactory {
const GURL& url) override;
bool UseWebUIForURL(content::BrowserContext* browser_context,
const GURL& url) override;
- bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
- const GURL& url) override;
std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(
content::WebUI* web_ui,
const GURL& url) override;
diff --git a/chromium/chrome/browser/ui/webui/chrome_webui_navigation_browsertest.cc b/chromium/chrome/browser/ui/webui/chrome_webui_navigation_browsertest.cc
index 30a12dfc8f4..c4ad53e24a7 100644
--- a/chromium/chrome/browser/ui/webui/chrome_webui_navigation_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chrome_webui_navigation_browsertest.cc
@@ -16,6 +16,7 @@
#include "ipc/ipc_security_test_util.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
+#include "ui/webui/untrusted_web_ui_browsertest_util.h"
#include "url/url_constants.h"
// Tests embedder specific behavior of WebUIs.
@@ -23,9 +24,12 @@ class ChromeWebUINavigationBrowserTest : public InProcessBrowserTest {
public:
ChromeWebUINavigationBrowserTest() {
content::WebUIControllerFactory::RegisterFactory(&factory_);
+ content::WebUIControllerFactory::RegisterFactory(&untrusted_factory_);
}
~ChromeWebUINavigationBrowserTest() override {
+ content::WebUIControllerFactory::UnregisterFactoryForTesting(
+ &untrusted_factory_);
content::WebUIControllerFactory::UnregisterFactoryForTesting(&factory_);
}
@@ -35,8 +39,13 @@ class ChromeWebUINavigationBrowserTest : public InProcessBrowserTest {
ASSERT_TRUE(embedded_test_server()->Start());
}
+ ui::TestUntrustedWebUIControllerFactory& untrusted_factory() {
+ return untrusted_factory_;
+ }
+
private:
content::TestWebUIControllerFactory factory_;
+ ui::TestUntrustedWebUIControllerFactory untrusted_factory_;
};
// Verify that a browser check stops websites from embeding chrome:// iframes.
@@ -96,8 +105,8 @@ IN_PROC_BROWSER_TEST_F(
content::TestNavigationObserver observer(web_contents);
content::TestUntrustedDataSourceCSP csp;
csp.no_xfo = true;
- content::AddUntrustedDataSource(browser()->profile(), "test-iframe-host",
- csp);
+ untrusted_factory().add_web_ui_config(
+ std::make_unique<ui::TestUntrustedWebUIConfig>("test-iframe-host", csp));
content::PwnMessageHelper::OpenURL(
child, content::GetChromeUntrustedUIURL("test-iframe-host/title1.html"));
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 9e647883a1b..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
@@ -37,21 +37,12 @@ AccountManagerErrorUI::AccountManagerErrorUI(content::WebUI* web_ui)
"secondaryAccountsDisabledErrorMessage",
IDS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_TEXT);
- html_source->AddLocalizedString(
- "childUserArcDisabledErrorTitle",
- IDS_ACCOUNT_MANAGER_CHILD_USER_ARC_DISABLED_TITLE);
- html_source->AddLocalizedString(
- "childUserArcDisabledErrorMessage",
- IDS_ACCOUNT_MANAGER_CHILD_USER_ARC_DISABLED_TEXT);
-
html_source->AddLocalizedString("okButton", IDS_APP_OK);
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
html_source->AddResourcePath("googleg.svg",
IDR_ACCOUNT_MANAGER_WELCOME_GOOGLE_LOGO_SVG);
#endif
- html_source->AddResourcePath("family_link_logo.svg",
- IDR_FAMILY_LINK_LOGO_SVG);
// Add required resources.
html_source->AddResourcePath("account_manager_shared_css.js",
diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.cc
index 1fea1309248..bc5579c8ee1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager/account_manager_welcome_dialog.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "ash/constants/ash_features.h"
#include "base/check_op.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/application_lifetime.h"
@@ -44,6 +45,10 @@ AccountManagerWelcomeDialog::~AccountManagerWelcomeDialog() {
// static
bool AccountManagerWelcomeDialog::ShowIfRequired() {
+ if (chromeos::features::IsAccountManagementFlowsV2Enabled()) {
+ return false;
+ }
+
PrefService* pref_service =
ProfileManager::GetActiveUserProfile()->GetPrefs();
const int num_times_shown = pref_service->GetInteger(
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 b9b4264bbf6..3a059d24f2a 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
@@ -11,12 +11,15 @@
#include "base/callback.h"
#include "base/strings/utf_string_conversions.h"
#include "build/branding_buildflags.h"
+#include "chrome/browser/account_manager_facade_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.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 "components/account_manager_core/account_manager_facade.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
#include "net/base/url_util.h"
@@ -56,9 +59,12 @@ class MigrationMessageHandler : public content::WebUIMessageHandler {
CHECK(!args->GetList().empty());
const std::string& account_email = args->GetList()[0].GetString();
- InlineLoginDialogChromeOS::Show(account_email,
- InlineLoginDialogChromeOS::Source::
- kAccountManagerMigrationWelcomeScreen);
+ Profile* profile = Profile::FromWebUI(web_ui());
+ ::GetAccountManagerFacade(profile->GetPath().value())
+ ->ShowReauthAccountDialog(
+ account_manager::AccountManagerFacade::AccountAdditionSource::
+ kAccountManagerMigrationWelcomeScreen,
+ account_email);
HandleCloseDialog(args);
}
@@ -79,13 +85,7 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui)
: ui::WebDialogUI(web_ui) {
content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
chrome::kChromeUIAccountMigrationWelcomeHost);
- html_source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test 'self';");
- html_source->DisableTrustedTypesCSP();
-
- html_source->UseStringsJs();
- html_source->EnableReplaceI18nInJS();
+ webui::SetJSModuleDefaults(html_source);
// Add localized strings.
html_source->AddLocalizedString("welcomePageTitle",
@@ -115,9 +115,6 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui)
html_source->AddResourcePath("googleg.svg",
IDR_ACCOUNT_MANAGER_WELCOME_GOOGLE_LOGO_SVG);
#endif
- html_source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
- html_source->AddResourcePath("test_loader.html",
- IDR_WEBUI_HTML_TEST_LOADER_HTML);
html_source->SetDefaultResource(IDR_ACCOUNT_MIGRATION_WELCOME_HTML);
web_ui->AddMessageHandler(std::make_unique<MigrationMessageHandler>(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/DIR_METADATA
new file mode 100644
index 00000000000..c0ebf855f7d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "FamilyExperiences"
+} \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/OWNERS
index 08850f42120..046a70f4ef0 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/OWNERS
@@ -1,2 +1,4 @@
+danan@chromium.org
+
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui.cc
index 00bdb206760..a8c7890bbfa 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/add_supervision_ui.cc
@@ -202,13 +202,14 @@ void AddSupervisionUI::SetUpResources() {
}
source->DisableTrustedTypesCSP();
+ source->EnableReplaceI18nInJS();
// Forward data to the WebUI.
source->AddResourcePath("post_message_api.js",
IDR_ADD_SUPERVISION_POST_MESSAGE_API_JS);
source->AddResourcePath("add_supervision_api_server.js",
IDR_ADD_SUPERVISION_API_SERVER_JS);
- source->AddResourcePath("add_supervision.js", IDR_ADD_SUPERVISION_JS);
+ source->AddResourcePath("add_supervision_ui.js", IDR_ADD_SUPERVISION_UI_JS);
source->AddResourcePath("images/network_unavailable.svg",
IDR_ADD_SUPERVISION_NETWORK_UNAVAILABLE_SVG);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.cc
index ff42bc9e1ee..8308b73841a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.cc
@@ -18,6 +18,7 @@
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/layout_provider.h"
+#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
@@ -87,4 +88,7 @@ bool ConfirmSignoutDialog::IsShowing() {
return ConfirmSignoutDialog::current_instance_ != nullptr;
}
+BEGIN_METADATA(ConfirmSignoutDialog, views::DialogDelegateView)
+END_METADATA
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.h
index 6e37acc2286..4e0bab6f69d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/add_supervision/confirm_signout_dialog.h
@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "ui/base/ui_base_types.h"
+#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/window/dialog_delegate.h"
namespace views {
@@ -20,6 +21,9 @@ namespace chromeos {
// signing out.
class ConfirmSignoutDialog : public views::DialogDelegateView {
public:
+ METADATA_HEADER(ConfirmSignoutDialog);
+ ConfirmSignoutDialog(const ConfirmSignoutDialog&) = delete;
+ ConfirmSignoutDialog& operator=(const ConfirmSignoutDialog&) = delete;
~ConfirmSignoutDialog() override;
// views::WidgetDelegate:
@@ -35,8 +39,6 @@ class ConfirmSignoutDialog : public views::DialogDelegateView {
private:
ConfirmSignoutDialog();
static views::Widget* current_instance_;
-
- DISALLOW_COPY_AND_ASSIGN(ConfirmSignoutDialog);
};
} // namespace chromeos
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 0f4dfbd1612..ddd95d7bf85 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
@@ -272,8 +272,8 @@ base::trace_event::TraceConfig GetTracingConfig(ArcGraphicsTracingMode mode) {
switch (mode) {
case ArcGraphicsTracingMode::kFull: {
base::trace_event::TraceConfig config(
- "-*,exo,viz,toplevel,gpu,cc,blink,disabled-by-default-android "
- "gfx,disabled-by-default-android view",
+ "-*,exo,viz,toplevel,gpu,cc,blink,disabled-by-default-android gfx,"
+ "disabled-by-default-android view",
base::trace_event::RECORD_CONTINUOUSLY);
config.EnableSystrace();
// By default, systracing starts pre-defined set of categories with
@@ -373,7 +373,7 @@ void ArcGraphicsTracingHandler::OnWindowActivated(ActivationReason reason,
jank_detector_ =
std::make_unique<arc::ArcGraphicsJankDetector>(base::BindRepeating(
&ArcGraphicsTracingHandler::OnJankDetected, base::Unretained(this)));
- exo::Surface* const surface = exo::GetShellMainSurface(arc_active_window_);
+ exo::Surface* const surface = exo::GetShellRootSurface(arc_active_window_);
DCHECK(surface);
surface->AddSurfaceObserver(this);
}
@@ -451,7 +451,7 @@ void ArcGraphicsTracingHandler::DiscardActiveArcWindow() {
if (!arc_active_window_)
return;
- exo::Surface* const surface = exo::GetShellMainSurface(arc_active_window_);
+ exo::Surface* const surface = exo::GetShellRootSurface(arc_active_window_);
if (surface)
surface->RemoveSurfaceObserver(this);
@@ -478,8 +478,8 @@ void ArcGraphicsTracingHandler::StartTracing() {
tracing_active_ = true;
if (jank_detector_)
jank_detector_->Reset();
- system_stat_colletor_ = std::make_unique<arc::ArcSystemStatCollector>();
- system_stat_colletor_->Start(GetMaxInterval());
+ system_stat_collector_ = std::make_unique<arc::ArcSystemStatCollector>();
+ system_stat_collector_->Start(GetMaxInterval());
// Timestamp and app information would be updated when |OnTracingStarted| is
// called.
@@ -500,8 +500,8 @@ void ArcGraphicsTracingHandler::StopTracing() {
tracing_time_max_ = TRACE_TIME_TICKS_NOW();
- if (system_stat_colletor_)
- system_stat_colletor_->Stop();
+ if (system_stat_collector_)
+ system_stat_collector_->Stop();
content::TracingController* const controller =
content::TracingController::GetInstance();
@@ -537,7 +537,7 @@ void ArcGraphicsTracingHandler::OnTracingStarted() {
tracing_time_min_ = TRACE_TIME_TICKS_NOW();
if (mode_ == ArcGraphicsTracingMode::kOverview) {
stop_tracing_timer_.Start(
- FROM_HERE, system_stat_colletor_->max_interval(),
+ FROM_HERE, system_stat_collector_->max_interval(),
base::BindOnce(&ArcGraphicsTracingHandler::StopTracingAndActivate,
base::Unretained(this)));
}
@@ -558,7 +558,7 @@ void ArcGraphicsTracingHandler::OnTracingStopped(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&BuildGraphicsModel, std::move(string_data), mode_,
active_task_title_, active_task_icon_png_, timestamp_,
- std::move(system_stat_colletor_), tracing_time_min_,
+ std::move(system_stat_collector_), tracing_time_min_,
tracing_time_max_, model_path),
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 53682da30ce..4e01039b91e 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
@@ -130,7 +130,7 @@ class ArcGraphicsTracingHandler : public content::WebUIMessageHandler,
std::unique_ptr<arc::ArcGraphicsJankDetector> jank_detector_;
// Collects system stat runtime.
- std::unique_ptr<arc::ArcSystemStatCollector> system_stat_colletor_;
+ std::unique_ptr<arc::ArcSystemStatCollector> system_stat_collector_;
// Information about active task, title and icon.
std::string active_task_title_;
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 213904250d1..dde1522879a 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
@@ -300,27 +300,27 @@ void ArcPowerControlHandler::StartTracing() {
throttling_events_.clear();
throttling_events_.emplace_back(
std::make_pair(tracing_time_min_, instance_throttle_->level()));
- system_stat_colletor_ = std::make_unique<arc::ArcSystemStatCollector>();
- system_stat_colletor_->Start(kMaxIntervalToDisplay);
- stop_tracing_timer_.Start(FROM_HERE, system_stat_colletor_->max_interval(),
+ system_stat_collector_ = std::make_unique<arc::ArcSystemStatCollector>();
+ system_stat_collector_->Start(kMaxIntervalToDisplay);
+ stop_tracing_timer_.Start(FROM_HERE, system_stat_collector_->max_interval(),
base::BindOnce(&ArcPowerControlHandler::StopTracing,
base::Unretained(this)));
}
void ArcPowerControlHandler::StopTracing() {
- if (!system_stat_colletor_)
+ if (!system_stat_collector_)
return;
const base::TimeTicks tracing_time_max = TRACE_TIME_TICKS_NOW();
stop_tracing_timer_.Stop();
- system_stat_colletor_->Stop();
+ system_stat_collector_->Stop();
SetTracingStatus("Building model...");
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&BuildTracingModel, timestamp_, tracing_time_min_,
- tracing_time_max, std::move(system_stat_colletor_),
+ tracing_time_max, std::move(system_stat_collector_),
std::move(wakefulness_mode_events_),
std::move(throttling_events_)),
base::BindOnce(&ArcPowerControlHandler::OnTracingModelReady,
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 10af11c79f9..60c4ed69afa 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
@@ -73,7 +73,7 @@ class ArcPowerControlHandler : public content::WebUIMessageHandler,
base::Time timestamp_;
base::TimeTicks tracing_time_min_;
base::OneShotTimer stop_tracing_timer_;
- std::unique_ptr<arc::ArcSystemStatCollector> system_stat_colletor_;
+ std::unique_ptr<arc::ArcSystemStatCollector> system_stat_collector_;
// It collects power mode and throttling events in case tracing is active.
WakefulnessModeEvents wakefulness_mode_events_;
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 6dbdf0c4d59..58397c1546e 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
@@ -8,11 +8,14 @@
#include <string>
#include <utility>
+#include "ash/constants/ash_features.h"
+#include "ash/public/cpp/shelf_config.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "build/buildflag.h"
-#include "chrome/browser/chromeos/assistant/assistant_util.h"
+#include "chrome/browser/ash/assistant/assistant_util.h"
+#include "chrome/browser/chromeos/login/ui/oobe_dialog_size_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/ash_util.h"
@@ -58,15 +61,8 @@ constexpr gfx::Insets kDialogInsets =
constexpr char kFlowTypeParamKey[] = "flow-type";
constexpr char kCaptionBarHeightParamKey[] = "caption-bar-height";
-
-GURL CreateAssistantOptInURL(ash::FlowType type) {
- GURL gurl(chrome::kChromeUIAssistantOptInURL);
- gurl = net::AppendQueryParameter(
- gurl, kFlowTypeParamKey, base::NumberToString(static_cast<int>(type)));
- gurl = net::AppendQueryParameter(gurl, kCaptionBarHeightParamKey,
- base::NumberToString(kCaptionBarHeight));
- return gurl;
-}
+constexpr char kOobeDialogHeightParamKey[] = "oobe-dialog-height";
+constexpr char kOobeDialogWidthParamKey[] = "oobe-dialog-width";
} // namespace
@@ -98,6 +94,8 @@ AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui)
IDR_ASSISTANT_VOICE_MATCH_ANIMATION);
source->AddResourcePath("voice_match_already_setup_animation.json",
IDR_ASSISTANT_VOICE_MATCH_ALREADY_SETUP_ANIMATION);
+ source->AddBoolean("newLayoutEnabled",
+ chromeos::features::IsNewOobeLayoutEnabled());
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';");
source->DisableTrustedTypesCSP();
@@ -184,12 +182,35 @@ void AssistantOptInDialog::AdjustWidgetInitParams(
params->z_order = ui::ZOrderLevel::kNormal;
}
+GURL AssistantOptInDialog::CreateAssistantOptInURL(ash::FlowType type) {
+ GURL gurl(chrome::kChromeUIAssistantOptInURL);
+ gurl = net::AppendQueryParameter(
+ gurl, kFlowTypeParamKey, base::NumberToString(static_cast<int>(type)));
+ gurl = net::AppendQueryParameter(gurl, kCaptionBarHeightParamKey,
+ base::NumberToString(kCaptionBarHeight));
+ gfx::Size size;
+ GetDialogSize(&size);
+ gurl = net::AppendQueryParameter(gurl, kOobeDialogHeightParamKey,
+ base::NumberToString(size.height()));
+ gurl = net::AppendQueryParameter(gurl, kOobeDialogWidthParamKey,
+ base::NumberToString(size.width()));
+ return gurl;
+}
+
void AssistantOptInDialog::GetDialogSize(gfx::Size* size) const {
auto bounds = display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
- bounds.Inset(kDialogInsets);
- auto dialog_size = bounds.size();
- dialog_size.SetToMin(kDialogMaxSize);
- dialog_size.SetToMax(kDialogMinSize);
+ gfx::Size dialog_size;
+ if (features::IsNewOobeLayoutEnabled()) {
+ const bool is_horizontal = bounds.width() > bounds.height();
+ dialog_size = CalculateOobeDialogSize(
+ display::Screen::GetScreen()->GetPrimaryDisplay().size(),
+ ash::ShelfConfig::Get()->shelf_size(), is_horizontal);
+ } else {
+ bounds.Inset(kDialogInsets);
+ dialog_size = bounds.size();
+ dialog_size.SetToMin(kDialogMaxSize);
+ dialog_size.SetToMax(kDialogMinSize);
+ }
size->SetSize(dialog_size.width(), dialog_size.height());
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h
index 245debafde6..9df565a81e8 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h
@@ -67,6 +67,8 @@ class AssistantOptInDialog : public SystemWebDialogDelegate {
void OnDialogClosed(const std::string& json_retval) override;
private:
+ GURL CreateAssistantOptInURL(ash::FlowType type);
+
AssistantOptInUI* assistant_ui_ = nullptr;
// Callback to run if the flow is completed.
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 861f8c86490..c689f9a421c 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
@@ -6,13 +6,13 @@
#include <utility>
+#include "ash/components/audio/cras_audio_handler.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/consent_auditor/consent_auditor_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/services/assistant/public/cpp/assistant_prefs.h"
#include "chromeos/services/assistant/public/cpp/features.h"
#include "components/arc/arc_prefs.h"
@@ -203,6 +203,11 @@ base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui,
dictionary.SetKey(
"valuePropIntro",
base::Value(activity_control_ui.intro_text_paragraph(0)));
+ if (activity_control_ui.intro_text_paragraph_size() > 1) {
+ dictionary.SetKey(
+ "valuePropIntroTitle",
+ base::Value(activity_control_ui.intro_text_paragraph(1)));
+ }
}
if (activity_control_ui.footer_paragraph_size()) {
dictionary.SetKey("valuePropFooter",
diff --git a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_dialog_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_dialog_localized_strings_provider.cc
index c1e8120e9b8..df15db25386 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_dialog_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_dialog_localized_strings_provider.cc
@@ -63,7 +63,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
{"bluetooth_connect_writeNotPermitted",
IDS_SETTINGS_BLUETOOTH_CONNECT_WRITE_NOT_PERMITTED},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
} // namespace bluetooth_dialog
diff --git a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
index f899f699aab..f60dcee986f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
@@ -110,7 +110,6 @@ BluetoothPairingDialogUI::BluetoothPairingDialogUI(content::WebUI* web_ui)
source,
base::make_span(kBluetoothPairingDialogResources,
kBluetoothPairingDialogResourcesSize),
- std::string(),
IDR_BLUETOOTH_PAIRING_DIALOG_BLUETOOTH_PAIRING_DIALOG_CONTAINER_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc
deleted file mode 100644
index 04f89448390..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc
+++ /dev/null
@@ -1,108 +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/cellular_setup/cellular_setup_dialog.h"
-
-#include "base/bind.h"
-#include "base/supports_user_data.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/browser_dialogs.h"
-#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/cellular_setup_resources.h"
-#include "chrome/grit/cellular_setup_resources_map.h"
-#include "chromeos/services/cellular_setup/cellular_setup_base.h"
-#include "chromeos/services/cellular_setup/cellular_setup_impl.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "ui/aura/window.h"
-
-namespace chromeos {
-
-namespace cellular_setup {
-
-namespace {
-
-// TODO(azeemarshad): Determine the exact height and width of the dialog. The
-// current mocks are unclear, so these are just a guess.
-constexpr int kDialogHeightPx = 850;
-constexpr int kDialogWidthPx = 650;
-
-CellularSetupDialog* dialog_instance = nullptr;
-
-} // namespace
-
-// static
-void CellularSetupDialog::ShowDialog(const std::string& cellular_network_guid) {
- if (dialog_instance) {
- dialog_instance->dialog_window()->Focus();
- return;
- }
-
- dialog_instance = new CellularSetupDialog();
-
- // Note: chrome::ShowWebDialog() is used instead of
- // dialog_instance->ShowSystemDialog() because it provides the dialog to
- // ability to switch to full-screen in tablet mode.
- chrome::ShowWebDialog(nullptr /* parent */,
- ProfileManager::GetActiveUserProfile(),
- dialog_instance);
-}
-
-CellularSetupDialog::CellularSetupDialog()
- : SystemWebDialogDelegate(GURL(chrome::kChromeUICellularSetupUrl),
- base::string16()) {
- set_can_resize(false);
-}
-
-CellularSetupDialog::~CellularSetupDialog() = default;
-
-void CellularSetupDialog::GetDialogSize(gfx::Size* size) const {
- size->SetSize(kDialogWidthPx, kDialogHeightPx);
-}
-
-void CellularSetupDialog::OnDialogClosed(const std::string& json_retval) {
- DCHECK(this == dialog_instance);
- dialog_instance = nullptr;
-
- // Note: The call below deletes |this|, so there is no further need to keep
- // track of the pointer.
- SystemWebDialogDelegate::OnDialogClosed(json_retval);
-}
-
-CellularSetupDialogUI::CellularSetupDialogUI(content::WebUI* web_ui)
- : ui::MojoWebDialogUI(web_ui) {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUICellularSetupHost);
-
- source->DisableTrustedTypesCSP();
-
- chromeos::cellular_setup::AddLocalizedStrings(source);
- source->UseStringsJs();
- source->SetDefaultResource(IDR_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_HTML);
-
- // Note: The |kCellularSetupResourcesSize| and |kCellularSetupResources|
- // fields are defined in the generated file
- // chrome/grit/cellular_setup_resources_map.h.
- for (size_t i = 0; i < kCellularSetupResourcesSize; ++i) {
- source->AddResourcePath(kCellularSetupResources[i].name,
- kCellularSetupResources[i].value);
- }
-
- content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
-}
-
-CellularSetupDialogUI::~CellularSetupDialogUI() = default;
-
-void CellularSetupDialogUI::BindInterface(
- mojo::PendingReceiver<mojom::CellularSetup> receiver) {
- CellularSetupImpl::CreateAndBindToReciever(std::move(receiver));
-}
-
-WEB_UI_CONTROLLER_TYPE_IMPL(CellularSetupDialogUI)
-
-} // namespace cellular_setup
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h
deleted file mode 100644
index d30bec2c336..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2019 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_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_H_
-
-#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
-#include "chromeos/services/cellular_setup/public/mojom/cellular_setup.mojom-forward.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "ui/web_dialogs/web_dialog_ui.h"
-
-namespace chromeos {
-
-namespace cellular_setup {
-
-// Dialog which displays the cellular setup flow which allows users to
-// activate their un-activated SIM cards. This dialog is only used when the
-// kUpdatedCellularActivationUi flag is enabled; see go/cros-cellular-design.
-class CellularSetupDialog : public SystemWebDialogDelegate {
- protected:
- CellularSetupDialog();
- ~CellularSetupDialog() override;
-
- // ui::WebDialogDelegate
- void GetDialogSize(gfx::Size* size) const override;
- void OnDialogClosed(const std::string& json_retval) override;
-
- private:
- friend void OpenCellularSetupDialog(const std::string& cellular_network_guid);
- static void ShowDialog(const std::string& cellular_network_guid);
-
- DISALLOW_COPY_AND_ASSIGN(CellularSetupDialog);
-};
-
-class CellularSetupDialogUI : public ui::MojoWebDialogUI {
- public:
- explicit CellularSetupDialogUI(content::WebUI* web_ui);
- ~CellularSetupDialogUI() override;
-
- // Instantiates implementor of the mojom::CellularSetup mojo interface
- // passing the pending receiver that will be internally bound.
- void BindInterface(mojo::PendingReceiver<mojom::CellularSetup> receiver);
-
- private:
- WEB_UI_CONTROLLER_TYPE_DECL();
- DISALLOW_COPY_AND_ASSIGN(CellularSetupDialogUI);
-};
-
-} // namespace cellular_setup
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc
index a95ee83f973..c212f68ca6b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc
@@ -4,22 +4,19 @@
#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h"
-#include "base/feature_list.h"
-#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h"
+#include "ash/constants/ash_features.h"
+#include "chrome/browser/ui/ash/system_tray_client.h"
#include "chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h"
-#include "chromeos/constants/chromeos_features.h"
namespace chromeos {
namespace cellular_setup {
void OpenCellularSetupDialog(const std::string& cellular_network_guid) {
- if (base::FeatureList::IsEnabled(
- chromeos::features::kUpdatedCellularActivationUi)) {
- CellularSetupDialog::ShowDialog(cellular_network_guid);
- } else {
+ if (chromeos::features::IsCellularActivationUiEnabled())
+ SystemTrayClient::Get()->ShowSettingsCellularSetup(/*show_psim_flow=*/true);
+ else
MobileSetupDialog::ShowByNetworkId(cellular_network_guid);
- }
}
} // namespace cellular_setup
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc
index 348e6a71341..a7a3a2b0b98 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc
@@ -4,6 +4,11 @@
#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
+#include "ash/constants/ash_features.h"
+#include "base/containers/span.h"
+#include "base/feature_list.h"
+#include "base/no_destructor.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
@@ -12,11 +17,11 @@
#include "ui/base/webui/web_ui_util.h"
namespace chromeos {
-
namespace cellular_setup {
-
namespace {
+const char useExternalEuiccLoadTimeDataName[] = "useExternalEuicc";
+
constexpr webui::LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
{"activationCode", IDS_CELLULAR_SETUP_ESIM_PAGE_ACTIVATION_CODE},
{"cancel", IDS_CANCEL},
@@ -30,6 +35,7 @@ constexpr webui::LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
{"next", IDS_CELLULAR_SETUP_NEXT_LABEL},
{"tryAgain", IDS_CELLULAR_SETUP_TRY_AGAIN_LABEL},
{"skipDiscovery", IDS_CELLULAR_SETUP_SKIP_DISCOVERY_LABEL},
+ {"confirm", IDS_CELLULAR_SETUP_CONFIRM_LABEL},
{"simDetectPageTitle", IDS_CELLULAR_SETUP_SIM_DETECT_PAGE_TITLE},
{"simDetectPageErrorTitle", IDS_CELLULAR_SETUP_SIM_DETECT_PAGE_ERROR_TITLE},
{"simDetectPageErrorMessage",
@@ -49,16 +55,56 @@ constexpr webui::LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
{"finalPageMessage", IDS_CELLULAR_SETUP_FINAL_PAGE_MESSAGE},
{"finalPageErrorTitle", IDS_CELLULAR_SETUP_FINAL_PAGE_ERROR_TITLE},
{"finalPageErrorMessage", IDS_CELLULAR_SETUP_FINAL_PAGE_ERROR_MESSAGE},
+ {"eSimFinalPageMessage", IDS_CELLULAR_SETUP_ESIM_FINAL_PAGE_MESSAGE},
+ {"eSimFinalPageErrorMessage",
+ IDS_CELLULAR_SETUP_ESIM_FINAL_PAGE_ERROR_MESSAGE},
+ {"eSimProfileDetectMessage",
+ IDS_CELLULAR_SETUP_ESIM_PROFILE_DETECT_MESSAGE},
+ {"eSimConnectionWarning", IDS_CELLULAR_SETUP_ESIM_CONNECTION_WARNING},
{"scanQRCode", IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE},
+ {"scanQRCodeNoProfiles",
+ IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_NO_PROFILES},
+ {"scanQRCodeEnterActivationCode",
+ IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_ENTER_ACTIVATION_CODE},
{"switchCamera", IDS_CELLULAR_SETUP_ESIM_PAGE_SWITCH_CAMERA},
{"useCamera", IDS_CELLULAR_SETUP_ESIM_PAGE_USE_CAMERA},
{"scanQRCodeSuccess", IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_SUCCESS},
+ {"qrCodeUseCameraAgain",
+ IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_USE_CAMERA_AGAIN},
+ {"scanQrCodeError", IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_ERROR},
{"qrCodeRetry", IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_RETRY},
- {"profileListPageMessage", IDS_CELLULAR_SETUP_PROFILE_LIST_PAGE_MESSAGE}};
+ {"scanQrCodeLoading", IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE_LOADING},
+ {"profileListPageMessage", IDS_CELLULAR_SETUP_PROFILE_LIST_PAGE_MESSAGE},
+ {"eidPopupTitle", IDS_CELLULAR_SETUP_EID_POPUP_TITLE},
+ {"eidPopupDescription", IDS_CELLULAR_SETUP_EID_POPUP_DESCRIPTION},
+ {"closeEidPopupButtonLabel",
+ IDS_CELLULAR_SETUP_CLOSE_EID_POPUP_BUTTON_LABEL},
+ {"confirmationCodeMessage",
+ IDS_CELLULAR_SETUP_ESIM_PAGE_CONFIRMATION_CODE_MESSAGE},
+ {"confirmationCodeInput",
+ IDS_CELLULAR_SETUP_ESIM_PAGE_CONFIRMATION_CODE_INPUT},
+ {"confirmationCodeError",
+ IDS_CELLULAR_SETUP_ESIM_PAGE_CONFIRMATION_CODE_ERROR},
+ {"confirmationCodeLoading",
+ IDS_CELLULAR_SETUP_ESIM_PAGE_CONFIRMATION_CODE_LOADING}}; // namespace
+
+struct NamedBoolean {
+ const char* name;
+ bool value;
+};
+
+const std::vector<const NamedBoolean>& GetBooleanValues() {
+ static const base::NoDestructor<std::vector<const NamedBoolean>> named_bools({
+ {"updatedCellularActivationUi",
+ chromeos::features::IsCellularActivationUiEnabled()},
+ });
+ return *named_bools;
+}
+
} // namespace
void AddLocalizedStrings(content::WebUIDataSource* html_source) {
- AddLocalizedStringsBulk(html_source, kLocalizedStringsWithoutPlaceholders);
+ html_source->AddLocalizedStrings(kLocalizedStringsWithoutPlaceholders);
}
void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder) {
@@ -66,6 +112,18 @@ void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder) {
builder->Add(entry.name, entry.id);
}
-} // namespace cellular_setup
+void AddNonStringLoadTimeData(content::WebUIDataSource* html_source) {
+ for (const auto& entry : GetBooleanValues())
+ html_source->AddBoolean(entry.name, entry.value);
+ html_source->AddBoolean(useExternalEuiccLoadTimeDataName,
+ base::FeatureList::IsEnabled(
+ chromeos::features::kCellularUseExternalEuicc));
+}
+void AddNonStringLoadTimeDataToDict(base::DictionaryValue* dict) {
+ for (const auto& entry : GetBooleanValues())
+ dict->SetBoolean(entry.name, entry.value);
+}
+
+} // namespace cellular_setup
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h
index 6ab522f5b34..5af2ed196d9 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h
@@ -5,16 +5,19 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_H_
+namespace base {
+class DictionaryValue;
+} // namespace base
+
namespace login {
class LocalizedValuesBuilder;
-}
+} // namespace login
namespace content {
class WebUIDataSource;
-}
+} // namespace content
namespace chromeos {
-
namespace cellular_setup {
// Adds the strings needed for the cellular setup flow to |html_source|.
@@ -23,8 +26,13 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source);
// Same as AddLocalizedStrings() but for a LocalizedValuesBuilder.
void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder);
-} // namespace cellular_setup
+// Adds non-string constants for loadTimeData consumption.
+void AddNonStringLoadTimeData(content::WebUIDataSource* html_source);
+// Same as AddNonStringLoadTimeData() but for a DictionaryValue.
+void AddNonStringLoadTimeDataToDict(base::DictionaryValue* dict);
+
+} // namespace cellular_setup
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_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 c1733e81683..3f6fc91cfeb 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
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/mobile/mobile_activator.h"
+#include "chrome/browser/ash/mobile/mobile_activator.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/common/url_constants.h"
@@ -84,7 +84,8 @@ void MobileSetupDialog::OnCloseContents(content::WebContents* source,
// crash. Note: IsTryingToQuit can be cancelled on other platforms by the
// onbeforeunload handler, except on ChromeOS. So IsTryingToQuit is the
// appropriate check to use here.
- bool running_activation = MobileActivator::GetInstance()->RunningActivation();
+ bool running_activation =
+ ash::MobileActivator::GetInstance()->RunningActivation();
NET_LOG(EVENT) << "Closing MobileSetupDialog. Activation running = "
<< running_activation;
if (!dialog_window() || !running_activation ||
@@ -93,7 +94,7 @@ void MobileSetupDialog::OnCloseContents(content::WebContents* source,
return;
}
- *out_close_dialog = chrome::ShowQuestionMessageBox(
+ *out_close_dialog = chrome::ShowQuestionMessageBoxSync(
dialog_window(), l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE),
l10n_util::GetStringUTF16(IDS_MOBILE_CANCEL_ACTIVATION));
}
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 51af7fb0263..c4480451beb 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
@@ -20,8 +20,8 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/ash/mobile/mobile_activator.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/mobile/mobile_activator.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -73,43 +73,45 @@ const char kNoCellularDeviceError[] = "Mobile network modem is not present.";
const char kNoCellularServiceError[] =
"$1 is unable to connect at this time due to insufficient coverage.";
-bool ActivationErrorRequiresCarrier(MobileActivator::ActivationError error) {
- return error == MobileActivator::ActivationError::kActivationFailed;
+bool ActivationErrorRequiresCarrier(
+ ash::MobileActivator::ActivationError error) {
+ return error == ash::MobileActivator::ActivationError::kActivationFailed;
}
-base::string16 GetActivationErrorMessage(MobileActivator::ActivationError error,
- const std::string& carrier) {
+base::string16 GetActivationErrorMessage(
+ ash::MobileActivator::ActivationError error,
+ const std::string& carrier) {
// If the activation error message requires the carrier name, and none was
// provider, fallback to kNoCellularServiceError.
if (carrier.empty() && ActivationErrorRequiresCarrier(error)) {
CHECK(!ActivationErrorRequiresCarrier(
- MobileActivator::ActivationError::kNoCellularService));
+ ash::MobileActivator::ActivationError::kNoCellularService));
return GetActivationErrorMessage(
- MobileActivator::ActivationError::kNoCellularService, carrier);
+ ash::MobileActivator::ActivationError::kNoCellularService, carrier);
}
switch (error) {
- case MobileActivator::ActivationError::kNone:
+ case ash::MobileActivator::ActivationError::kNone:
return base::string16();
- case MobileActivator::ActivationError::kActivationFailed: {
+ case ash::MobileActivator::ActivationError::kActivationFailed: {
return base::ReplaceStringPlaceholders(
base::UTF8ToUTF16(kDefaultActivationError),
std::vector<base::string16>(
{ui::GetChromeOSDeviceName(), base::UTF8ToUTF16(carrier)}),
nullptr);
}
- case MobileActivator::ActivationError::kCellularDisabled:
+ case ash::MobileActivator::ActivationError::kCellularDisabled:
return base::UTF8ToUTF16(kCellularDisabledError);
- case MobileActivator::ActivationError::kNoCellularDevice:
+ case ash::MobileActivator::ActivationError::kNoCellularDevice:
return base::UTF8ToUTF16(kNoCellularDeviceError);
- case MobileActivator::ActivationError::kNoCellularService:
+ case ash::MobileActivator::ActivationError::kNoCellularService:
return base::ReplaceStringPlaceholders(
base::UTF8ToUTF16(kNoCellularServiceError),
ui::GetChromeOSDeviceName(), nullptr);
}
NOTREACHED() << "Unexpected activation error";
return GetActivationErrorMessage(
- MobileActivator::ActivationError::kActivationFailed, carrier);
+ ash::MobileActivator::ActivationError::kActivationFailed, carrier);
}
void DataRequestFailed(const std::string& service_path,
@@ -196,7 +198,7 @@ class MobileSetupUIHTMLSource : public content::URLDataSource {
// The handler for Javascript messages related to the "register" view.
class MobileSetupHandler : public content::WebUIMessageHandler,
- public MobileActivator::Observer,
+ public ash::MobileActivator::Observer,
public NetworkStateHandlerObserver {
public:
MobileSetupHandler();
@@ -206,11 +208,11 @@ class MobileSetupHandler : public content::WebUIMessageHandler,
void RegisterMessages() override;
void OnJavascriptDisallowed() override;
- // MobileActivator::Observer.
+ // ash::MobileActivator::Observer.
void OnActivationStateChanged(
const NetworkState* network,
- MobileActivator::PlanActivationState new_state,
- MobileActivator::ActivationError error) override;
+ ash::MobileActivator::PlanActivationState new_state,
+ ash::MobileActivator::ActivationError error) override;
private:
enum Type {
@@ -373,8 +375,8 @@ MobileSetupHandler::~MobileSetupHandler() {
void MobileSetupHandler::OnActivationStateChanged(
const NetworkState* network,
- MobileActivator::PlanActivationState state,
- MobileActivator::ActivationError error) {
+ ash::MobileActivator::PlanActivationState state,
+ ash::MobileActivator::ActivationError error) {
DCHECK_EQ(TYPE_ACTIVATION, type_);
if (!web_ui())
return;
@@ -390,7 +392,7 @@ void MobileSetupHandler::OnActivationStateChanged(
base::Value info = GetCellularNetworkInfoValue(network, device);
// Add the current activation flow state.
- info.SetKey(keys::kActivationState, base::Value(state));
+ info.SetKey(keys::kActivationState, base::Value(static_cast<int>(state)));
info.SetKey(keys::kActivationErrorMessage,
base::Value(GetActivationErrorMessage(
error, device ? device->operator_name() : "")));
@@ -408,8 +410,8 @@ void MobileSetupHandler::Reset() {
active_ = false;
if (type_ == TYPE_ACTIVATION) {
- MobileActivator::GetInstance()->RemoveObserver(this);
- MobileActivator::GetInstance()->TerminateActivation();
+ ash::MobileActivator::GetInstance()->RemoveObserver(this);
+ ash::MobileActivator::GetInstance()->TerminateActivation();
} else if (type_ == TYPE_PORTAL_LTE) {
NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
FROM_HERE);
@@ -449,8 +451,8 @@ void MobileSetupHandler::HandleStartActivation(const base::ListValue* args) {
AllowJavascript();
type_ = TYPE_ACTIVATION;
- MobileActivator::GetInstance()->AddObserver(this);
- MobileActivator::GetInstance()->InitiateActivation(path.substr(1));
+ ash::MobileActivator::GetInstance()->AddObserver(this);
+ ash::MobileActivator::GetInstance()->InitiateActivation(path.substr(1));
}
void MobileSetupHandler::HandleSetTransactionStatus(
@@ -467,7 +469,7 @@ void MobileSetupHandler::HandleSetTransactionStatus(
if (!args->GetString(0, &status))
return;
- MobileActivator::GetInstance()->OnSetTransactionStatus(
+ ash::MobileActivator::GetInstance()->OnSetTransactionStatus(
base::LowerCaseEqualsASCII(status, kJsApiResultOK));
}
@@ -484,7 +486,7 @@ void MobileSetupHandler::HandlePaymentPortalLoad(const base::ListValue* args) {
if (!args->GetString(0, &result))
return;
- MobileActivator::GetInstance()->OnPortalLoaded(
+ ash::MobileActivator::GetInstance()->OnPortalLoaded(
base::LowerCaseEqualsASCII(result, kJsApiResultOK));
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA
new file mode 100644
index 00000000000..b3cd94034ff
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Shell>Containers"
+}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/OWNERS
index 3a2b81f71a5..df5ff9b1e09 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/OWNERS
@@ -2,5 +2,3 @@ file://chrome/browser/chromeos/guest_os/OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: UI>Shell>Containers
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc
index 63283954ef9..56475b0d891 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_dialog.cc
@@ -34,7 +34,10 @@ namespace chromeos {
void CrostiniInstallerDialog::Show(Profile* profile,
OnLoadedCallback on_loaded_callback) {
- DCHECK(crostini::CrostiniFeatures::Get()->IsUIAllowed(profile));
+ if (!crostini::CrostiniFeatures::Get()->IsAllowedNow(profile)) {
+ return;
+ }
+
auto* instance = SystemWebDialogDelegate::FindInstance(GetUrl().spec());
if (instance) {
instance->Focus();
@@ -109,8 +112,8 @@ void CrostiniInstallerDialog::OnCloseContents(content::WebContents* source,
void CrostiniInstallerDialog::OnWebContentsFinishedLoad() {
DCHECK(dialog_window());
- dialog_window()->SetTitle(l10n_util::GetStringFUTF16(
- IDS_CROSTINI_INSTALLER_TITLE, ui::GetChromeOSDeviceName()));
+ dialog_window()->SetTitle(
+ l10n_util::GetStringUTF16(IDS_CROSTINI_INSTALLER_TITLE));
if (!on_loaded_callback_.is_null()) {
DCHECK(installer_ui_);
std::move(on_loaded_callback_).Run(installer_ui_);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc
index 306b66c00bd..0586299932d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_page_handler.cc
@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
+#include "ash/constants/ash_features.h"
#include "base/bind.h"
#include "base/optional.h"
#include "base/strings/utf_string_conversions.h"
@@ -19,7 +20,6 @@
#include "chrome/browser/chromeos/crostini/crostini_installer_ui_delegate.h"
#include "chrome/browser/chromeos/crostini/crostini_types.mojom.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
-#include "chromeos/constants/chromeos_features.h"
#include "ui/base/text/bytes_formatting.h"
namespace chromeos {
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 6136342247b..ac58362e360 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
@@ -6,6 +6,7 @@
#include <utility>
+#include "ash/constants/ash_features.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/strings/string16.h"
@@ -21,7 +22,6 @@
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui_data_source.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
@@ -46,6 +46,7 @@ void AddStringResources(content::WebUIDataSource* source) {
{"cancel", IDS_APP_CANCEL},
{"learnMore", IDS_LEARN_MORE},
+ {"promptTitle", IDS_CROSTINI_INSTALLER_TITLE},
{"installingTitle", IDS_CROSTINI_INSTALLER_INSTALLING},
{"cancelingTitle", IDS_CROSTINI_INSTALLER_CANCELING_TITLE},
{"errorTitle", IDS_CROSTINI_INSTALLER_ERROR_TITLE},
@@ -53,6 +54,7 @@ void AddStringResources(content::WebUIDataSource* source) {
{"loadTerminaError", IDS_CROSTINI_INSTALLER_LOAD_TERMINA_ERROR},
{"createDiskImageError", IDS_CROSTINI_INSTALLER_CREATE_DISK_IMAGE_ERROR},
{"startTerminaVmError", IDS_CROSTINI_INSTALLER_START_TERMINA_VM_ERROR},
+ {"startLxdError", IDS_CROSTINI_INSTALLER_START_LXD_ERROR},
{"startContainerError", IDS_CROSTINI_INSTALLER_START_CONTAINER_ERROR},
{"configureContainerError",
IDS_CROSTINI_INSTALLER_CONFIGURE_CONTAINER_ERROR},
@@ -66,6 +68,7 @@ void AddStringResources(content::WebUIDataSource* source) {
IDS_CROSTINI_INSTALLER_CREATE_DISK_IMAGE_MESSAGE},
{"startTerminaVmMessage",
IDS_CROSTINI_INSTALLER_START_TERMINA_VM_MESSAGE},
+ {"startLxdMessage", IDS_CROSTINI_INSTALLER_START_LXD_MESSAGE},
{"startContainerMessage", IDS_CROSTINI_INSTALLER_START_CONTAINER_MESSAGE},
{"configureContainerMessage",
IDS_CROSTINI_INSTALLER_CONFIGURE_CONTAINER_MESSAGE},
@@ -87,13 +90,10 @@ void AddStringResources(content::WebUIDataSource* source) {
IDS_CROSTINI_INSTALLER_USERNAME_NOT_AVAILABLE_ERROR},
{"customDiskSizeLabel", IDS_CROSTINI_INSTALLER_CUSTOM_DISK_SIZE_LABEL},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
base::string16 device_name = ui::GetChromeOSDeviceName();
- source->AddString(
- "promptTitle",
- l10n_util::GetStringFUTF8(IDS_CROSTINI_INSTALLER_TITLE, device_name));
source->AddString("promptMessage",
l10n_util::GetStringFUTF8(
IDS_CROSTINI_INSTALLER_BODY,
@@ -139,10 +139,7 @@ CrostiniInstallerUI::CrostiniInstallerUI(content::WebUI* web_ui)
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUICrostiniInstallerHost);
auto* profile = Profile::FromWebUI(web_ui);
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test 'self';");
- source->DisableTrustedTypesCSP();
+ webui::SetJSModuleDefaults(source);
AddStringResources(source);
source->AddBoolean(
"diskResizingEnabled",
@@ -157,13 +154,9 @@ CrostiniInstallerUI::CrostiniInstallerUI(content::WebUI* web_ui)
IDR_CROSTINI_INSTALLER_MOJO_LITE_JS);
source->AddResourcePath("crostini_types.mojom-lite.js",
IDR_CROSTINI_INSTALLER_TYPES_MOJO_LITE_JS);
- source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
- source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML);
source->AddResourcePath("images/linux_illustration.png",
IDR_LINUX_ILLUSTRATION);
source->SetDefaultResource(IDR_CROSTINI_INSTALLER_INDEX_HTML);
- source->UseStringsJs();
- source->EnableReplaceI18nInJS();
content::WebUIDataSource::Add(profile, source);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA
new file mode 100644
index 00000000000..b3cd94034ff
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Shell>Containers"
+}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/OWNERS
index 3a2b81f71a5..df5ff9b1e09 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/OWNERS
@@ -2,5 +2,3 @@ file://chrome/browser/chromeos/guest_os/OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: UI>Shell>Containers
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc
index f6560a693ec..5875f7a0ac5 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc
@@ -8,7 +8,6 @@
#include "base/metrics/histogram_base.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
-#include "build/branding_buildflags.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_test_helper.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
@@ -16,7 +15,7 @@
#include "chrome/browser/chromeos/guest_os/guest_os_registry_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/views/crostini/crostini_browser_test_util.h"
+#include "chrome/browser/ui/views/crostini/crostini_dialogue_browser_test_util.h"
#include "chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader.mojom.h"
#include "chrome/common/webui_url_constants.h"
#include "chromeos/dbus/cicerone/cicerone_service.pb.h"
@@ -24,8 +23,6 @@
#include "content/public/test/browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
-
constexpr char kDesktopFileId[] = "test_app";
constexpr int kDisplayId = 0;
@@ -119,17 +116,13 @@ IN_PROC_BROWSER_TEST_F(CrostiniUpgraderDialogBrowserTest,
base::BindOnce(
[](base::RunLoop* run_loop, bool* is_successful_app_launch,
bool success, const std::string& failure_reason) {
- // In tests, we don't expect Crostini to restart successfully, but
- // the error message should start as below.
- auto pos = failure_reason.find("crostini restart to launch app");
- *is_successful_app_launch = (pos == 0);
+ EXPECT_TRUE(success) << failure_reason;
run_loop->Quit();
},
&run_loop, &is_successful_app_launch));
run_loop.Run();
ExpectNoDialog();
- EXPECT_TRUE(is_successful_app_launch);
}
IN_PROC_BROWSER_TEST_F(CrostiniUpgraderDialogBrowserTest, ShowsOnAppLaunch) {
@@ -167,5 +160,3 @@ IN_PROC_BROWSER_TEST_F(CrostiniUpgraderDialogBrowserTest, ShowsOnAppLaunch) {
crostini::UpgradeDialogEvent::kDialogShown),
1);
}
-
-#endif // !BUILDFLAG(GOOGLE_CHROME_BRANDING)
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 912699d4384..836be9a4768 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
@@ -6,6 +6,7 @@
#include <utility>
+#include "ash/constants/ash_features.h"
#include "base/bind.h"
#include "base/strings/string16.h"
#include "base/system/sys_info.h"
@@ -18,7 +19,6 @@
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui_data_source.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
@@ -79,7 +79,7 @@ void AddStringResources(content::WebUIDataSource* source) {
{"backupCheckboxMessage", IDS_CROSTINI_UPGRADER_BACKUP_CHECKBOX_MESSAGE},
{"backupChangeLocation", IDS_CROSTINI_UPGRADER_BACKUP_CHANGE_LOCATION},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->AddString("learnMoreUrl",
std::string{chrome::kLinuxAppsLearnMoreURL} +
"&b=" + base::SysInfo::GetLsbReleaseBoard());
@@ -100,10 +100,7 @@ CrostiniUpgraderUI::CrostiniUpgraderUI(content::WebUI* web_ui)
: ui::MojoWebDialogUI{web_ui} {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUICrostiniUpgraderHost);
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test 'self';");
- source->DisableTrustedTypesCSP();
+ webui::SetJSModuleDefaults(source);
AddStringResources(source);
source->AddResourcePath("images/linux_illustration.png",
@@ -117,11 +114,7 @@ CrostiniUpgraderUI::CrostiniUpgraderUI(content::WebUI* web_ui)
IDR_CROSTINI_UPGRADER_BROWSER_PROXY_JS);
source->AddResourcePath("crostini_upgrader.mojom-lite.js",
IDR_CROSTINI_UPGRADER_MOJO_LITE_JS);
- source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
- source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML);
source->SetDefaultResource(IDR_CROSTINI_UPGRADER_INDEX_HTML);
- source->UseStringsJs();
- source->EnableReplaceI18nInJS();
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
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 afd6fa71402..ee577d9eeab 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
@@ -9,6 +9,7 @@
#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/cryptohome/rpc.pb.h"
#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/tpm_manager/tpm_manager_client.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
@@ -32,19 +33,15 @@ void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) {
CryptohomeClient* cryptohome_client = CryptohomeClient::Get();
cryptohome_client->IsMounted(GetCryptohomeBoolCallback("is-mounted"));
- cryptohome_client->TpmIsReady(GetCryptohomeBoolCallback("tpm-is-ready"));
- cryptohome_client->TpmIsEnabled(GetCryptohomeBoolCallback("tpm-is-enabled"));
- cryptohome_client->TpmIsOwned(GetCryptohomeBoolCallback("tpm-is-owned"));
+ TpmManagerClient::Get()->GetTpmNonsensitiveStatus(
+ ::tpm_manager::GetTpmNonsensitiveStatusRequest(),
+ base::BindOnce(&CryptohomeWebUIHandler::OnGetTpmStatus,
+ weak_ptr_factory_.GetWeakPtr()));
cryptohome_client->Pkcs11IsTpmTokenReady(
GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready"));
- cryptohome_client->GetTpmStatus(
- cryptohome::GetTpmStatusRequest(),
- base::BindOnce(&CryptohomeWebUIHandler::OnCryptohomeTpmStatus,
- weak_ptr_factory_.GetWeakPtr()));
-
content::GetIOThreadTaskRunner({})->PostTaskAndReplyWithResult(
- FROM_HERE, base::BindOnce(&crypto::IsTPMTokenReady, base::Closure()),
+ FROM_HERE, base::BindOnce(&crypto::IsTPMTokenReady, base::OnceClosure()),
base::BindOnce(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -63,19 +60,18 @@ DBusMethodCallback<bool> CryptohomeWebUIHandler::GetCryptohomeBoolCallback(
weak_ptr_factory_.GetWeakPtr(), destination_id);
}
-void CryptohomeWebUIHandler::OnCryptohomeTpmStatus(
- base::Optional<cryptohome::BaseReply> reply) {
- if (!reply.has_value() || reply->has_error() ||
- !reply->HasExtension(cryptohome::GetTpmStatusReply::reply)) {
- LOG(ERROR) << "TPM status request failed, error: "
- << (reply.has_value() && reply->has_error() ? reply->error()
- : 0);
+void CryptohomeWebUIHandler::OnGetTpmStatus(
+ const ::tpm_manager::GetTpmNonsensitiveStatusReply& reply) {
+ if (reply.status() != ::tpm_manager::STATUS_SUCCESS) {
+ LOG(ERROR) << "Failed to get TPM status; status: " << reply.status();
return;
}
- auto reply_proto = reply->GetExtension(cryptohome::GetTpmStatusReply::reply);
-
+ // It also means TPM is ready if tpm manager reports TPM is owned.
+ SetCryptohomeProperty("tpm-is-ready", base::Value(reply.is_owned()));
+ SetCryptohomeProperty("tpm-is-enabled", base::Value(reply.is_enabled()));
+ SetCryptohomeProperty("tpm-is-owned", base::Value(reply.is_owned()));
SetCryptohomeProperty("has-reset-lock-permissions",
- base::Value(reply_proto.has_reset_lock_permissions()));
+ base::Value(reply.has_reset_lock_permissions()));
}
void CryptohomeWebUIHandler::OnCryptohomeBoolProperty(
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 855eb2c390e..cab32c5275f 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
@@ -12,6 +12,7 @@
#include "base/optional.h"
#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/dbus_method_call_status.h"
+#include "chromeos/dbus/tpm_manager/tpm_manager.pb.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace base {
@@ -46,8 +47,10 @@ class CryptohomeWebUIHandler : public content::WebUIMessageHandler {
void OnCryptohomeBoolProperty(const std::string& destination_id,
base::Optional<bool> result);
- // This method is called when Cryptohome D-Bus TpmStatus call complete.
- void OnCryptohomeTpmStatus(base::Optional<cryptohome::BaseReply> reply);
+ // This method is called when TpmManager D-Bus GetTpmNonsensitiveStatus call
+ // completes.
+ void OnGetTpmStatus(
+ const ::tpm_manager::GetTpmNonsensitiveStatusReply& reply);
// Sets textcontent of the element whose id is |destination_id| to |value|.
void SetCryptohomeProperty(const std::string& destination_id,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/diagnostics_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/diagnostics_dialog.cc
new file mode 100644
index 00000000000..7978728f56a
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/diagnostics_dialog.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 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/chromeos/diagnostics_dialog.h"
+
+#include <string>
+
+#include "chromeos/components/diagnostics_ui/url_constants.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
+
+namespace chromeos {
+
+// Scale factor for size of the diagnostics dialog, based on display size.
+const float kDiagnosticsDialogScale = .8;
+
+// static
+void DiagnosticsDialog::ShowDialog() {
+ DiagnosticsDialog* dialog = new DiagnosticsDialog();
+ dialog->ShowSystemDialog();
+}
+
+DiagnosticsDialog::DiagnosticsDialog()
+ : SystemWebDialogDelegate(GURL(kChromeUIDiagnosticsAppUrl),
+ /*title=*/base::string16()) {}
+
+DiagnosticsDialog::~DiagnosticsDialog() = default;
+
+const std::string& DiagnosticsDialog::Id() {
+ return id_;
+}
+
+void DiagnosticsDialog::GetDialogSize(gfx::Size* size) const {
+ const display::Display display =
+ display::Screen::GetScreen()->GetPrimaryDisplay();
+
+ gfx::Size display_size = display.size();
+
+ if (display.rotation() == display::Display::ROTATE_90 ||
+ display.rotation() == display::Display::ROTATE_270) {
+ display_size = gfx::Size(display_size.height(), display_size.width());
+ }
+
+ display_size = gfx::Size(display_size.width() * kDiagnosticsDialogScale,
+ display_size.height() * kDiagnosticsDialogScale);
+
+ *size = display_size;
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/diagnostics_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/diagnostics_dialog.h
new file mode 100644
index 00000000000..5a3aad6b8b4
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/diagnostics_dialog.h
@@ -0,0 +1,35 @@
+// Copyright (c) 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_CHROMEOS_DIAGNOSTICS_DIALOG_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_DIAGNOSTICS_DIALOG_H_
+
+#include "base/macros.h"
+#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+
+namespace chromeos {
+
+class DiagnosticsDialog : public SystemWebDialogDelegate {
+ public:
+ static void ShowDialog();
+
+ protected:
+ DiagnosticsDialog();
+ ~DiagnosticsDialog() override;
+
+ DiagnosticsDialog(const DiagnosticsDialog&) = delete;
+ DiagnosticsDialog& operator=(const DiagnosticsDialog&) = delete;
+
+ // SystemWebDialogDelegate
+ const std::string& Id() override;
+
+ // ui::WebDialogDelegate
+ void GetDialogSize(gfx::Size* size) const override;
+
+ private:
+ const std::string id_ = "diagnostics-dialog";
+};
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_DIAGNOSTICS_DIALOG_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
index fc4e9fc26c2..0d8b3dee177 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -41,7 +41,6 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/services/file_util/public/cpp/zip_file_creator.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/download/content/public/all_download_item_notifier.h"
#include "components/download/public/common/download_item.h"
#include "components/drive/drive_notification_manager.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 b4af30e5729..c88265b63d8 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,6 +6,8 @@
#include <utility>
+#include "ash/components/account_manager/account_manager.h"
+#include "ash/components/account_manager/account_manager_factory.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
@@ -19,8 +21,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h"
-#include "chromeos/components/account_manager/account_manager.h"
-#include "chromeos/components/account_manager/account_manager_factory.h"
#include "components/image_fetcher/core/image_fetcher_service.h"
#include "components/image_fetcher/core/request_metadata.h"
#include "components/signin/public/base/avatar_icon_util.h"
@@ -218,10 +218,9 @@ void EduAccountLoginHandler::HandleUpdateEduCoexistenceFlowResult(
void EduAccountLoginHandler::FetchFamilyMembers() {
DCHECK(!family_fetcher_);
Profile* profile = Profile::FromWebUI(web_ui());
- chromeos::AccountManager* account_manager =
- g_browser_process->platform_part()
- ->GetAccountManagerFactory()
- ->GetAccountManager(profile->GetPath().value());
+ auto* account_manager = g_browser_process->platform_part()
+ ->GetAccountManagerFactory()
+ ->GetAccountManager(profile->GetPath().value());
DCHECK(account_manager);
family_fetcher_ = std::make_unique<FamilyInfoFetcher>(
@@ -271,10 +270,9 @@ void EduAccountLoginHandler::FetchReAuthProofTokenForParent(
const std::string& parent_credential) {
DCHECK(!gaia_auth_fetcher_);
Profile* profile = Profile::FromWebUI(web_ui());
- chromeos::AccountManager* account_manager =
- g_browser_process->platform_part()
- ->GetAccountManagerFactory()
- ->GetAccountManager(profile->GetPath().value());
+ auto* account_manager = g_browser_process->platform_part()
+ ->GetAccountManagerFactory()
+ ->GetAccountManager(profile->GetPath().value());
DCHECK(account_manager);
gaia_auth_fetcher_ = std::make_unique<GaiaAuthFetcher>(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/DIR_METADATA
new file mode 100644
index 00000000000..c0ebf855f7d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "FamilyExperiences"
+} \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/OWNERS
new file mode 100644
index 00000000000..5bfa5595b53
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/OWNERS
@@ -0,0 +1,3 @@
+agawronska@chromium.org
+danan@chromium.org
+yilkal@chromium.org \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_browsertest.cc
index 4c0929448eb..b9fef64e6c6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_browsertest.cc
@@ -2,28 +2,28 @@
// 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/edu_coexistence_login_handler_chromeos.h"
+#include "chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h"
#include <memory>
#include <string>
#include "base/callback_helpers.h"
+#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/chromeos/child_accounts/edu_coexistence_tos_store_utils.h"
#include "chrome/browser/chromeos/login/test/fake_gaia_mixin.h"
+#include "chrome/browser/chromeos/login/test/logged_in_user_mixin.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/supervised_user/logged_in_user_mixin.h"
#include "chrome/browser/supervised_user/supervised_user_features.h"
#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.h"
+#include "chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/mixin_based_in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "chromeos/constants/chromeos_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/access_token_info.h"
#include "components/signin/public/identity_manager/account_info.h"
@@ -96,6 +96,21 @@ class EduCoexistenceLoginHandlerBrowserTest
""));
}
+ void ExpectEduCoexistenceState(
+ EduCoexistenceStateTracker::FlowResult result) {
+ const EduCoexistenceStateTracker::FlowState* state =
+ EduCoexistenceStateTracker::Get()->GetInfoForWebUIForTest(web_ui());
+ EXPECT_EQ(state->flow_result, result);
+ }
+
+ void ExpectEduCoexistenceStateHistogram(
+ EduCoexistenceStateTracker::FlowResult result) {
+ histograms_.ExpectUniqueSample(
+ EduCoexistenceStateTracker::Get()->GetInSessionHistogramNameForTest(),
+ result,
+ /* expected count */ 1);
+ }
+
protected:
content::TestWebUI* web_ui() { return &web_ui_; }
@@ -106,6 +121,8 @@ class EduCoexistenceLoginHandlerBrowserTest
&mixin_host_, chromeos::LoggedInUserMixin::LogInType::kChild,
embedded_test_server(), this};
+ base::HistogramTester histograms_;
+
content::TestWebUI web_ui_;
};
@@ -113,6 +130,9 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
HandleInitializeEduCoexistenceArgs) {
constexpr char kCallbackId[] = "coexistence-data-init";
std::unique_ptr<EduCoexistenceLoginHandler> handler = SetUpHandler();
+
+ ExpectEduCoexistenceState(EduCoexistenceStateTracker::FlowResult::kLaunched);
+
base::ListValue list_args;
list_args.Append(kCallbackId);
web_ui()->HandleReceivedMessage("initializeEduArgs", &list_args);
@@ -124,6 +144,12 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
// TODO(yilkal): verify the exact the call arguments.
VerifyJavascriptCallResolved(second_call, kCallbackId, kResponseCallback);
+
+ handler.reset();
+
+ // The recorded state should be "launched" state.
+ ExpectEduCoexistenceStateHistogram(
+ EduCoexistenceStateTracker::FlowResult::kLaunched);
}
IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
@@ -136,6 +162,10 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
web_ui()->HandleReceivedMessage("error", &call_args);
EXPECT_TRUE(handler->in_error_state());
+
+ handler.reset();
+ ExpectEduCoexistenceStateHistogram(
+ EduCoexistenceStateTracker::FlowResult::kError);
}
IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
@@ -160,6 +190,11 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
constexpr char kWebUICallErrorCallback[] = "show-error-screen";
EXPECT_EQ(method_call, kWebUICallErrorCallback);
+
+ handler.reset();
+
+ ExpectEduCoexistenceStateHistogram(
+ EduCoexistenceStateTracker::FlowResult::kError);
}
IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
@@ -168,6 +203,8 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
constexpr char kToSVersion[] = "12345678";
std::unique_ptr<EduCoexistenceLoginHandler> handler = SetUpHandler();
+ SimulateAccessTokenFetched(handler.get());
+
base::ListValue call_args;
call_args.Append(FakeGaiaMixin::kFakeUserEmail);
call_args.Append(kToSVersion);
@@ -177,15 +214,16 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
list_args.Append(std::move(call_args));
web_ui()->HandleReceivedMessage("consentLogged", &list_args);
- SimulateAccessTokenFetched(handler.get());
- const EduCoexistenceConsentTracker::EmailAndCallback* tracker =
- EduCoexistenceConsentTracker::Get()->GetInfoForWebUIForTest(web_ui());
+ const EduCoexistenceStateTracker::FlowState* tracker =
+ EduCoexistenceStateTracker::Get()->GetInfoForWebUIForTest(web_ui());
- // Ensure that the tracker gets the appropriate update.
+ // Expect that the tracker gets the appropriate update.
EXPECT_NE(tracker, nullptr);
EXPECT_TRUE(tracker->received_consent);
EXPECT_EQ(tracker->email, FakeGaiaMixin::kFakeUserEmail);
+ EXPECT_EQ(tracker->flow_result,
+ EduCoexistenceStateTracker::FlowResult::kConsentLogged);
// Simulate account added.
CoreAccountInfo account;
@@ -203,6 +241,11 @@ IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
// TODO(yilkal): verify the exact the call arguments.
VerifyJavascriptCallResolved(second_call, kConsentLoggedCallback,
kResponseCallback);
+
+ handler.reset();
+
+ ExpectEduCoexistenceStateHistogram(
+ EduCoexistenceStateTracker::FlowResult::kAccountAdded);
}
IN_PROC_BROWSER_TEST_F(EduCoexistenceLoginHandlerBrowserTest,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc
index 5075867666d..6e7dffd1bff 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.cc
@@ -2,11 +2,12 @@
// 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/edu_coexistence_login_handler_chromeos.h"
+#include "chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h"
#include <memory>
#include <utility>
+#include "ash/constants/ash_pref_names.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/check.h"
@@ -15,19 +16,21 @@
#include "base/guid.h"
#include "base/metrics/histogram_functions.h"
#include "base/system/sys_info.h"
+#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/child_accounts/edu_coexistence_tos_store_utils.h"
+#include "chrome/browser/chromeos/login/login_pref_names.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/chrome_device_id_helper.h"
#include "chrome/browser/signin/identity_manager_factory.h"
-#include "chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.h"
+#include "chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.h"
#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h"
#include "chrome/common/channel_info.h"
-#include "chromeos/constants/chromeos_pref_names.h"
+#include "chrome/common/chrome_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_core.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "components/prefs/pref_service.h"
@@ -50,7 +53,7 @@ namespace {
constexpr char kEduCoexistenceLoginURLSwitch[] = "edu-coexistence-url";
constexpr char kEduCoexistenceLoginDefaultURL[] =
- "https://families.google.com/supervision/coexistence";
+ "https://families.google.com/supervision/coexistence/intro";
constexpr char kOobe[] = "oobe";
constexpr char kInSession[] = "in_session";
constexpr char kOnErrorWebUIListener[] = "show-error-screen";
@@ -83,14 +86,22 @@ std::string GetSourceUI() {
std::string GetOrCreateEduCoexistenceUserId() {
Profile* profile = ProfileManager::GetActiveUserProfile();
PrefService* pref_service = profile->GetPrefs();
- std::string id = pref_service->GetString(chromeos::prefs::kEduCoexistenceId);
+ std::string id = pref_service->GetString(prefs::kEduCoexistenceId);
if (id.empty()) {
id = base::GenerateGUID();
- pref_service->SetString(chromeos::prefs::kEduCoexistenceId, id);
+ pref_service->SetString(prefs::kEduCoexistenceId, id);
}
return id;
}
+base::Time GetSigninTime() {
+ const Profile* profile = ProfileManager::GetActiveUserProfile();
+ const PrefService* pref_service = profile->GetPrefs();
+ base::Time signin_time = pref_service->GetTime(prefs::kOobeOnboardingTime);
+ DCHECK(!signin_time.is_min());
+ return signin_time;
+}
+
// Tries to get the policy device id for the family link user profile if
// available. The policy device id is used to identify the device login
// timestamp to skip parental reauth for secondary edu account login during
@@ -134,7 +145,7 @@ EduCoexistenceLoginHandler::EduCoexistenceLoginHandler(
OAuth2AccessTokenManager::ScopeSet scopes;
scopes.insert(GaiaConstants::kKidsSupervisionSetupChildOAuth2Scope);
- scopes.insert(GaiaConstants::kPeopleApiReadOnlyOAuth2Scope);
+ scopes.insert(GaiaConstants::kKidManagementOAuth2Scope);
scopes.insert(GaiaConstants::kAccountsReauthOAuth2Scope);
scopes.insert(GaiaConstants::kAuditRecordingOAuth2Scope);
scopes.insert(GaiaConstants::kClearCutOAuth2Scope);
@@ -154,11 +165,17 @@ EduCoexistenceLoginHandler::EduCoexistenceLoginHandler(
EduCoexistenceLoginHandler::~EduCoexistenceLoginHandler() {
identity_manager_->RemoveObserver(this);
- EduCoexistenceConsentTracker::Get()->OnDialogClosed(web_ui());
+ EduCoexistenceStateTracker::Get()->OnDialogClosed(web_ui());
close_dialog_closure_.Run();
}
void EduCoexistenceLoginHandler::RegisterMessages() {
+ // Notifying |EduCoexistenceStateTracker| here instead of in the constructor
+ // because the WebUI has not yet been set there.
+ EduCoexistenceStateTracker::Get()->OnDialogCreated(
+ web_ui(), /* is_onboarding */ session_manager::SessionManager::Get()
+ ->IsUserSessionBlocked());
+
web_ui()->RegisterMessageCallback(
"initializeEduArgs",
base::BindRepeating(&EduCoexistenceLoginHandler::InitializeEduArgs,
@@ -196,6 +213,9 @@ void EduCoexistenceLoginHandler::OnRefreshTokenUpdatedForAccount(
profile, edu_coexistence::UserConsentInfo(
account_info.gaia, terms_of_service_version_number_));
+ EduCoexistenceStateTracker::Get()->OnWebUiStateChanged(
+ web_ui(), EduCoexistenceStateTracker::FlowResult::kAccountAdded);
+
// Otherwise, notify the ui that account addition was successful!!
ResolveJavascriptCallback(base::Value(account_added_callback_),
base::Value(true));
@@ -214,6 +234,9 @@ void EduCoexistenceLoginHandler::OnOAuthAccessTokensFetched(
if (initialize_edu_args_callback_.has_value()) {
FireWebUIListener(kOnErrorWebUIListener);
}
+
+ EduCoexistenceStateTracker::Get()->OnWebUiStateChanged(
+ web_ui(), EduCoexistenceStateTracker::FlowResult::kError);
in_error_state_ = true;
return;
}
@@ -257,7 +280,7 @@ void EduCoexistenceLoginHandler::SendInitializeEduArgs() {
GaiaUrls::GetInstance()->oauth2_chrome_client_id());
params.SetStringKey("sourceUi", GetSourceUI());
- params.SetStringKey("clientVersion", chrome::GetVersionString());
+ params.SetStringKey("clientVersion", chrome::kChromeVersion);
params.SetStringKey("eduCoexistenceAccessToken", oauth_access_token_->token);
params.SetStringKey("eduCoexistenceId", GetOrCreateEduCoexistenceUserId());
params.SetStringKey("platformVersion",
@@ -265,6 +288,8 @@ void EduCoexistenceLoginHandler::SendInitializeEduArgs() {
params.SetStringKey("releaseChannel", chrome::GetChannelName());
params.SetStringKey("deviceId", GetDeviceIdForActiveUserProfile());
+ params.SetDoubleKey("signinTime", GetSigninTime().ToJsTimeIgnoringNull());
+
// If the secondary edu account is being reauthenticated, the email address
// will be provided via the url of the webcontent. Example
// chrome://chrome-signin/edu-coexistence?email=testuser1%40gmail.com
@@ -291,7 +316,8 @@ void EduCoexistenceLoginHandler::SendInitializeEduArgs() {
void EduCoexistenceLoginHandler::ConsentValid(const base::ListValue* args) {
AllowJavascript();
DCHECK(!in_error_state_);
- // TODO(yilkal): Have a state enum to record the progress.
+ EduCoexistenceStateTracker::Get()->OnWebUiStateChanged(
+ web_ui(), EduCoexistenceStateTracker::FlowResult::kConsentValid);
}
void EduCoexistenceLoginHandler::ConsentLogged(const base::ListValue* args) {
@@ -307,8 +333,11 @@ void EduCoexistenceLoginHandler::ConsentLogged(const base::ListValue* args) {
edu_account_email_ = arguments[0].GetString();
terms_of_service_version_number_ = arguments[1].GetString();
- EduCoexistenceConsentTracker::Get()->OnConsentLogged(web_ui(),
- edu_account_email_);
+ EduCoexistenceStateTracker::Get()->OnConsentLogged(web_ui(),
+ edu_account_email_);
+
+ EduCoexistenceStateTracker::Get()->OnWebUiStateChanged(
+ web_ui(), EduCoexistenceStateTracker::FlowResult::kConsentLogged);
}
void EduCoexistenceLoginHandler::OnError(const base::ListValue* args) {
@@ -321,6 +350,9 @@ void EduCoexistenceLoginHandler::OnError(const base::ListValue* args) {
DCHECK(message.is_string());
LOG(ERROR) << message.GetString();
}
+
+ EduCoexistenceStateTracker::Get()->OnWebUiStateChanged(
+ web_ui(), EduCoexistenceStateTracker::FlowResult::kError);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_chromeos.h b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h
index 8b438cb7b02..8a6169527d8 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.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_CHROMEOS_EDU_COEXISTENCE_LOGIN_HANDLER_CHROMEOS_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_LOGIN_HANDLER_CHROMEOS_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_EDU_COEXISTENCE_LOGIN_HANDLER_CHROMEOS_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_EDU_COEXISTENCE_LOGIN_HANDLER_CHROMEOS_H_
#include <string>
@@ -91,4 +91,4 @@ class EduCoexistenceLoginHandler : public content::WebUIMessageHandler,
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_LOGIN_HANDLER_CHROMEOS_H_
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_EDU_COEXISTENCE_LOGIN_HANDLER_CHROMEOS_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.cc
new file mode 100644
index 00000000000..29a00662940
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.cc
@@ -0,0 +1,127 @@
+// 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/chromeos/edu_coexistence/edu_coexistence_state_tracker.h"
+
+#include <utility>
+
+#include "base/containers/contains.h"
+#include "base/logging.h"
+#include "base/metrics/histogram_functions.h"
+#include "content/public/browser/web_ui.h"
+
+namespace chromeos {
+
+namespace {
+
+constexpr char kEduCoexistenceV2InSessionFlowResult[] =
+ "AccountManager.EduCoexistenceV2.InSessionFlowResult";
+
+constexpr char kEduCoexistenceV2OnboardingFlowResult[] =
+ "AccountManager.EduCoexistenceV2.OnboardingFlowResult";
+
+} // namespace
+
+EduCoexistenceStateTracker::FlowState::FlowState() = default;
+
+EduCoexistenceStateTracker::FlowState::~FlowState() = default;
+
+// static
+EduCoexistenceStateTracker* EduCoexistenceStateTracker::Get() {
+ static base::NoDestructor<EduCoexistenceStateTracker> instance;
+ return instance.get();
+}
+
+void EduCoexistenceStateTracker::SetEduConsentCallback(
+ const content::WebUI* web_ui,
+ const std::string& account_email,
+ base::OnceCallback<void(bool)> consent_logged_callback) {
+ DCHECK(base::Contains(state_tracker_, web_ui));
+ FlowState& state = state_tracker_[web_ui];
+
+ if (state.received_consent) {
+ DCHECK_EQ(state.email, account_email);
+ std::move(consent_logged_callback).Run(/* success */ true);
+ return;
+ }
+
+ DCHECK(state.email.empty());
+ state.email = account_email;
+ state.consent_logged_callback = std::move(consent_logged_callback);
+}
+
+void EduCoexistenceStateTracker::OnDialogClosed(const content::WebUI* web_ui) {
+ if (!base::Contains(state_tracker_, web_ui))
+ return;
+
+ FlowState& state = state_tracker_[web_ui];
+
+ // If the consent_logged_callback is still present when the dialog is closed,
+ // then EduCoexistenceLoginHandler has not received a parental consent logged
+ // signal. Notify |EduCoexistenceChildSigninHelper| that we weren't able to
+ // successfully log the parental consent so that it can clean up after itself.
+ if (state.consent_logged_callback)
+ std::move(state.consent_logged_callback).Run(/* success */ false);
+
+ const std::string& histogram_name =
+ state.is_onboarding ? kEduCoexistenceV2OnboardingFlowResult
+ : kEduCoexistenceV2InSessionFlowResult;
+ base::UmaHistogramEnumeration(histogram_name, state.flow_result,
+ FlowResult::kNumStates);
+
+ state_tracker_.erase(web_ui);
+}
+
+void EduCoexistenceStateTracker::OnDialogCreated(const content::WebUI* web_ui,
+ bool is_onboarding) {
+ DCHECK(!base::Contains(state_tracker_, web_ui));
+
+ FlowState& state = state_tracker_[web_ui];
+
+ state.received_consent = false;
+ state.flow_result = FlowResult::kLaunched;
+ state.is_onboarding = is_onboarding;
+}
+
+void EduCoexistenceStateTracker::OnConsentLogged(
+ const content::WebUI* web_ui,
+ const std::string& account_email) {
+ DCHECK(base::Contains(state_tracker_, web_ui));
+
+ if (state_tracker_[web_ui].consent_logged_callback) {
+ DCHECK_EQ(state_tracker_[web_ui].email, account_email);
+ std::move(state_tracker_[web_ui].consent_logged_callback)
+ .Run(/* success */ true);
+ return;
+ }
+
+ state_tracker_[web_ui].received_consent = true;
+ state_tracker_[web_ui].email = account_email;
+}
+
+void EduCoexistenceStateTracker::OnWebUiStateChanged(
+ const content::WebUI* web_ui,
+ FlowResult result) {
+ DCHECK(base::Contains(state_tracker_, web_ui));
+ state_tracker_[web_ui].flow_result = result;
+}
+
+const EduCoexistenceStateTracker::FlowState*
+EduCoexistenceStateTracker::GetInfoForWebUIForTest(
+ const content::WebUI* web_ui) const {
+ if (!base::Contains(state_tracker_, web_ui))
+ return nullptr;
+ return &state_tracker_.at(web_ui);
+}
+
+std::string EduCoexistenceStateTracker::GetInSessionHistogramNameForTest()
+ const {
+ return kEduCoexistenceV2InSessionFlowResult;
+}
+
+EduCoexistenceStateTracker::EduCoexistenceStateTracker() = default;
+
+EduCoexistenceStateTracker::~EduCoexistenceStateTracker() = default;
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.h b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.h
new file mode 100644
index 00000000000..da10ea761dd
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.h
@@ -0,0 +1,126 @@
+// 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_CHROMEOS_EDU_COEXISTENCE_EDU_COEXISTENCE_STATE_TRACKER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_EDU_COEXISTENCE_STATE_TRACKER_H_
+
+#include <map>
+#include <string>
+
+#include "base/callback.h"
+#include "base/no_destructor.h"
+
+namespace content {
+class WebUI;
+} // namespace content
+
+namespace chromeos {
+
+// A tracker used for the communication between
+// `EduCoexistenceChildSigninHelper` and `EduCoexistenceLoginHandler` to allow
+// the SigninHelper to wait until parental consent is logged before upserting
+// the EDU account into AccountManager.
+// A tracker used to record metrics for each educoexistence flow attempt.
+class EduCoexistenceStateTracker {
+ public:
+ // The flow state used to record the status of the flow when it is closed. The
+ // enum values are recorded in histogram therefore, keep it consistent with
+ // FlowResult enum in enums.xml.
+ enum class FlowResult : int {
+ // State when the webui first launches.
+ kLaunched = 0,
+
+ // Received just before gaia login, and after the parental reauth if
+ // applicable
+ kConsentValid = 1,
+
+ // The user has entered the correct passwords for edu account and gaia
+ // authorizes the account.
+ kAccountAuthorized = 2,
+
+ // The parental consent has successfully been logged.
+ kConsentLogged = 3,
+
+ // The edu account has successfully been added to AccountManager.
+ kAccountAdded = 4,
+
+ // An error has occurred and the error screen is showing.
+ kError = 5,
+
+ kNumStates = 6
+ };
+
+ struct FlowState {
+ FlowState();
+ ~FlowState();
+
+ // Whether `EduCoexistenceLoginHandler` has been notified that parental
+ // consent has been logged.
+ bool received_consent = false;
+
+ // Whether the educoexistence flow is being used during onboarding or
+ // in the user session.
+ bool is_onboarding = false;
+
+ // The secondary edu account email being added to the device.
+ std::string email;
+
+ // Callback to notify `EduCoexistenceChildSigninHelper` to upsert the
+ // account into account manager when parental consent is received.
+ base::OnceCallback<void(bool)> consent_logged_callback;
+
+ // Enum tracking the state of the EduCoexistence flow.
+ FlowResult flow_result = FlowResult::kLaunched;
+ };
+
+ static EduCoexistenceStateTracker* Get();
+
+ // Called from `EduCoexistenceChildSigninHelper` to wait for parental consent
+ // logged signal. `consent_logged_callback` is executed when the signal is
+ // received.
+ void SetEduConsentCallback(
+ const content::WebUI* web_ui,
+ const std::string& account_email,
+ base::OnceCallback<void(bool)> consent_logged_callback);
+
+ // Called when `EduCoexistenceLoginHandler` is being destroyed. If the dialog
+ // is closed while there is still a callback for
+ // `EduCoexistenceChildSigninHelper` waiting to be executed, this executes
+ // the `consent_logged_callback` with success=false argument.
+ void OnDialogClosed(const content::WebUI* web_ui);
+
+ // Called with `EduCoexistenceLoginHandler` is created and has access to its
+ // `web_ui`.`is_onboarding` is set to true if the dialog is being shown in
+ // OOBE or in an add person flow.
+ void OnDialogCreated(const content::WebUI* web_ui, bool is_onboarding);
+
+ // Called when the parental consent signal has been logged.
+ void OnConsentLogged(const content::WebUI* web_ui,
+ const std::string& account_email);
+
+ // Called to record the progress of the EduCoexistence flow.
+ void OnWebUiStateChanged(const content::WebUI* web_ui, FlowResult result);
+
+ const FlowState* GetInfoForWebUIForTest(const content::WebUI* web_ui) const;
+ std::string GetInSessionHistogramNameForTest() const;
+
+ private:
+ friend class base::NoDestructor<EduCoexistenceStateTracker>;
+
+ EduCoexistenceStateTracker();
+ EduCoexistenceStateTracker(const EduCoexistenceStateTracker&) = delete;
+ EduCoexistenceStateTracker& operator=(const EduCoexistenceStateTracker&) =
+ delete;
+ ~EduCoexistenceStateTracker();
+
+ // Maps each flow's WebUI's to the corresponding FlowState. While there an
+ // only be one dialog for the EduCoexistence flow, there can potentially be
+ // multiple WebUIs because the user can start the WebUIs from a chrome browser
+ // tab by going to chrome://chrome-signin/edu-coexistence.
+ std::map<const content::WebUI*, FlowState> state_tracker_;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_EDU_COEXISTENCE_STATE_TRACKER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.cc b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.cc
deleted file mode 100644
index f9d082556d0..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.cc
+++ /dev/null
@@ -1,77 +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/chromeos/edu_coexistence_consent_tracker.h"
-
-#include <utility>
-
-#include "base/logging.h"
-#include "base/no_destructor.h"
-#include "base/stl_util.h"
-#include "content/public/browser/web_ui.h"
-
-namespace chromeos {
-
-// static
-EduCoexistenceConsentTracker* EduCoexistenceConsentTracker::Get() {
- static base::NoDestructor<EduCoexistenceConsentTracker> instance;
- return instance.get();
-}
-
-EduCoexistenceConsentTracker::EmailAndCallback::EmailAndCallback() = default;
-
-EduCoexistenceConsentTracker::EmailAndCallback::~EmailAndCallback() = default;
-
-EduCoexistenceConsentTracker::EduCoexistenceConsentTracker() = default;
-
-EduCoexistenceConsentTracker::~EduCoexistenceConsentTracker() = default;
-
-void EduCoexistenceConsentTracker::WaitForEduConsent(
- const content::WebUI* web_ui,
- const std::string& account_email,
- base::OnceCallback<void(bool)> callback) {
- if (consent_tracker_[web_ui].received_consent) {
- DCHECK_EQ(consent_tracker_[web_ui].email, account_email);
- std::move(callback).Run(/* success */ true);
- return;
- }
-
- consent_tracker_[web_ui].email = account_email;
- consent_tracker_[web_ui].callback = std::move(callback);
-}
-
-void EduCoexistenceConsentTracker::OnDialogClosed(
- const content::WebUI* web_ui) {
- if (!base::Contains(consent_tracker_, web_ui))
- return;
-
- if (consent_tracker_.at(web_ui).callback) {
- std::move(consent_tracker_[web_ui].callback).Run(/* success */ false);
- }
-
- consent_tracker_.erase(web_ui);
-}
-
-void EduCoexistenceConsentTracker::OnConsentLogged(
- const content::WebUI* web_ui,
- const std::string& account_email) {
- if (consent_tracker_[web_ui].callback) {
- DCHECK_EQ(consent_tracker_[web_ui].email, account_email);
- std::move(consent_tracker_[web_ui].callback).Run(/* success */ true);
- return;
- }
-
- consent_tracker_[web_ui].received_consent = true;
- consent_tracker_[web_ui].email = account_email;
-}
-
-const EduCoexistenceConsentTracker::EmailAndCallback*
-EduCoexistenceConsentTracker::GetInfoForWebUIForTest(
- const content::WebUI* web_ui) {
- if (!base::Contains(consent_tracker_, web_ui))
- return nullptr;
- return &consent_tracker_[web_ui];
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.h b/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.h
deleted file mode 100644
index 84359a088f1..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.h
+++ /dev/null
@@ -1,68 +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_CHROMEOS_EDU_COEXISTENCE_CONSENT_TRACKER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_CONSENT_TRACKER_H_
-
-#include <map>
-#include <string>
-
-#include "base/callback.h"
-
-namespace content {
-class WebUI;
-} // namespace content
-
-namespace chromeos {
-
-// A tracker used for the communication between
-// |EduCoexistenceChildSigninHelper| and |EduCoexistenceLoginHandler| to allow
-// the SigninHelper to wait until parental consent is logged before upserting
-// the EDU account into AccountManager.
-class EduCoexistenceConsentTracker {
- public:
- struct EmailAndCallback {
- EmailAndCallback();
- ~EmailAndCallback();
-
- bool received_consent = false;
- std::string email;
- base::OnceCallback<void(bool)> callback;
- };
-
- static EduCoexistenceConsentTracker* Get();
-
- // Don't try to instantiate this class. Use the static getter instead.
- EduCoexistenceConsentTracker();
- EduCoexistenceConsentTracker(const EduCoexistenceConsentTracker&) = delete;
- EduCoexistenceConsentTracker& operator=(const EduCoexistenceConsentTracker&) =
- delete;
- ~EduCoexistenceConsentTracker();
-
- // Called from |EduCoexistenceChildSigninHelper| to wait for parental consent
- // logged signal. |callback| is executed when the signal is received.
- void WaitForEduConsent(const content::WebUI* web_ui,
- const std::string& account_email,
- base::OnceCallback<void(bool)> callback);
-
- // Called when |EduCoexistenceLoginHandler| is being destroyed. If the dialog
- // is closed while there is still a |EduCoexistenceChildSigninHelper| callback
- // waiting to be executed, this executes the callback with success=false
- // argument.
- void OnDialogClosed(const content::WebUI* web_ui);
-
- // Called from |EduCoexistenceLoginHandler| when the parental consent signal
- // has been logged.
- void OnConsentLogged(const content::WebUI* web_ui,
- const std::string& account_email);
-
- const EmailAndCallback* GetInfoForWebUIForTest(const content::WebUI* web_ui);
-
- private:
- std::map<const content::WebUI*, EmailAndCallback> consent_tracker_;
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EDU_COEXISTENCE_CONSENT_TRACKER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emoji/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/emoji/DIR_METADATA
new file mode 100644
index 00000000000..ca0e79f905b
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/emoji/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail: {
+ component: "OS>Inputs"
+}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emoji/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/emoji/OWNERS
new file mode 100644
index 00000000000..4e1c393dfcd
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/emoji/OWNERS
@@ -0,0 +1,2 @@
+jopalmer@chromium.org
+keithlee@chromium.org
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.cc
new file mode 100644
index 00000000000..8cc74fd57ea
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.cc
@@ -0,0 +1,91 @@
+// 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.
+
+#include "chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h"
+
+#include "base/strings/utf_string_conversions.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser_dialogs.h"
+#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
+#include "chrome/common/url_constants.h"
+
+#include "ui/aura/window.h"
+#include "ui/base/ime/chromeos/ime_bridge.h"
+
+namespace chromeos {
+
+constexpr gfx::Size kDefaultWindowSize(340, 390);
+
+gfx::NativeWindow EmojiPickerDialog::window = nullptr;
+
+EmojiPickerDialog::EmojiPickerDialog() {
+ set_can_resize(false);
+}
+
+void EmojiPickerDialog::Show() {
+ if (window) {
+ window->Focus();
+ return;
+ }
+ ui::InputMethod* input_method =
+ ui::IMEBridge::Get()->GetInputContextHandler()->GetInputMethod();
+ const ui::TextInputClient* input_client =
+ input_method ? input_method->GetTextInputClient() : nullptr;
+ const gfx::Rect caret_bounds =
+ input_client ? input_client->GetCaretBounds() : gfx::Rect();
+ window = chrome::ShowWebDialog(
+ nullptr, ProfileManager::GetActiveUserProfile(), new EmojiPickerDialog());
+ // For now, this can overflow the screen.
+ if (input_client) {
+ window->SetBounds(gfx::Rect(caret_bounds.x(), caret_bounds.bottom(),
+ kDefaultWindowSize.width(),
+ kDefaultWindowSize.height()));
+ }
+}
+
+ui::ModalType EmojiPickerDialog::GetDialogModalType() const {
+ return ui::MODAL_TYPE_NONE;
+}
+
+base::string16 EmojiPickerDialog::GetDialogTitle() const {
+ return base::UTF8ToUTF16("Emoji Picker");
+}
+
+GURL EmojiPickerDialog::GetDialogContentURL() const {
+ return GURL(chrome::kChromeUIEmojiPickerURL);
+}
+
+void EmojiPickerDialog::GetWebUIMessageHandlers(
+ std::vector<content::WebUIMessageHandler*>* handlers) const {}
+
+void EmojiPickerDialog::GetDialogSize(gfx::Size* size) const {
+ *size = kDefaultWindowSize;
+}
+
+std::string EmojiPickerDialog::GetDialogArgs() const {
+ return "";
+}
+
+void EmojiPickerDialog::OnDialogShown(content::WebUI* webui) {
+ webui_ = webui;
+}
+
+void EmojiPickerDialog::OnDialogClosed(const std::string& json_retval) {
+ window = nullptr;
+ delete this;
+}
+
+void EmojiPickerDialog::OnCloseContents(content::WebContents* source,
+ bool* out_close_dialog) {
+ *out_close_dialog = true;
+}
+
+bool EmojiPickerDialog::ShouldShowDialogTitle() const {
+ return true;
+}
+
+EmojiPickerDialog::~EmojiPickerDialog() = default;
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h
new file mode 100644
index 00000000000..91096097947
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h
@@ -0,0 +1,48 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_DIALOG_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_DIALOG_H_
+
+#include "base/macros.h"
+#include "ui/base/ime/text_input_client.h"
+#include "ui/web_dialogs/web_dialog_delegate.h"
+
+#include "chrome/browser/ui/webui/chromeos/emoji/emoji_handler.h"
+
+namespace chromeos {
+
+class EmojiPickerDialog : public ui::WebDialogDelegate {
+ public:
+ static void Show();
+ ~EmojiPickerDialog() override;
+
+ private:
+ EmojiPickerDialog();
+ // ui::WebDialogDelegate:
+ ui::ModalType GetDialogModalType() const override;
+ base::string16 GetDialogTitle() const override;
+ GURL GetDialogContentURL() const override;
+ void GetWebUIMessageHandlers(
+ std::vector<content::WebUIMessageHandler*>* handlers) const override;
+ void GetDialogSize(gfx::Size* size) const override;
+ std::string GetDialogArgs() const override;
+ void OnDialogShown(content::WebUI* webui) override;
+ void OnDialogClosed(const std::string& json_retval) override;
+ void OnCloseContents(content::WebContents* source,
+ bool* out_close_dialog) override;
+ bool ShouldShowDialogTitle() const override;
+
+ content::WebUI* webui_ = nullptr;
+
+ // Window for the emoji picker. Used by the handler to close the window.
+ static gfx::NativeWindow window;
+ friend class EmojiHandler;
+
+ DISALLOW_COPY_AND_ASSIGN(EmojiPickerDialog);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_DIALOG_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_handler.cc
new file mode 100644
index 00000000000..d8f935b7c91
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_handler.cc
@@ -0,0 +1,83 @@
+// 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.
+
+#include "chrome/browser/ui/webui/chromeos/emoji/emoji_handler.h"
+
+#include "base/logging.h"
+#include "base/metrics/histogram_functions.h"
+#include "base/strings/utf_string_conversions.h"
+
+#include "chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h"
+#include "ui/aura/window.h"
+#include "ui/base/ime/chromeos/ime_bridge.h"
+
+namespace chromeos {
+
+EmojiHandler::EmojiHandler() {}
+EmojiHandler::~EmojiHandler() = default;
+
+// Keep in sync with entry in enums.xml.
+enum class EmojiVariantType {
+ // smaller entries only used by Chrome OS VK
+ kEmojiPickerBase = 4,
+ kEmojiPickerVariant = 5,
+ kMaxValue = kEmojiPickerVariant,
+};
+
+void LogInsertEmoji(bool isVariant) {
+ EmojiVariantType insertValue = isVariant
+ ? EmojiVariantType::kEmojiPickerVariant
+ : EmojiVariantType::kEmojiPickerBase;
+ base::UmaHistogramEnumeration("InputMethod.VirtualKeyboard.Emoji.TriggerType",
+ insertValue);
+}
+
+void EmojiHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "insertEmoji", base::BindRepeating(&EmojiHandler::HandleInsertEmoji,
+ base::Unretained(this)));
+}
+
+void EmojiHandler::HandleInsertEmoji(const base::ListValue* args) {
+ if (args->GetSize() != 2) {
+ DLOG(WARNING)
+ << "insertEmoji called with incorrect number of arguments (expected 2)";
+ return;
+ }
+
+ const std::string& emoji = args->GetList()[0].GetString();
+ LogInsertEmoji(args->GetList()[1].GetBool());
+
+ // Hide emoji picker window to restore focus to original text field
+ if (EmojiPickerDialog::window) {
+ EmojiPickerDialog::window->Hide();
+ EmojiPickerDialog::window = nullptr;
+ }
+
+ ui::InputMethod* input_method =
+ ui::IMEBridge::Get()->GetInputContextHandler()->GetInputMethod();
+ if (!input_method) {
+ LOG(WARNING) << "no input_method found";
+ return;
+ }
+
+ ui::TextInputClient* input_client = input_method->GetTextInputClient();
+
+ if (!input_client) {
+ LOG(WARNING) << "no input_client found";
+ return;
+ }
+
+ if (input_client->GetTextInputType() ==
+ ui::TextInputType::TEXT_INPUT_TYPE_NONE) {
+ LOG(WARNING) << "attempt to insert into input_client with type none";
+ return;
+ }
+
+ input_client->InsertText(
+ base::UTF8ToUTF16(emoji),
+ ui::TextInputClient::InsertTextCursorBehavior::kMoveCursorAfterText);
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_handler.h b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_handler.h
new file mode 100644
index 00000000000..26f74ca74ed
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_handler.h
@@ -0,0 +1,30 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_HANDLER_H_
+
+#include "base/macros.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace chromeos {
+
+// The WebUI message handler for chrome://emoji-picker
+class EmojiHandler : public content::WebUIMessageHandler {
+ public:
+ EmojiHandler();
+ ~EmojiHandler() override;
+
+ private:
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
+
+ void HandleInsertEmoji(const base::ListValue* args);
+
+ DISALLOW_COPY_AND_ASSIGN(EmojiHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_picker.cc b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_picker.cc
new file mode 100644
index 00000000000..227a86315fc
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_picker.cc
@@ -0,0 +1,50 @@
+// 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.
+
+#include "chrome/browser/ui/webui/chromeos/emoji/emoji_picker.h"
+
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/grit/emoji_picker_resources.h"
+#include "chrome/grit/emoji_picker_resources_map.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/resources/grit/webui_generated_resources.h"
+
+#include "chrome/browser/ui/webui/chromeos/emoji/emoji_dialog.h"
+#include "chrome/browser/ui/webui/chromeos/emoji/emoji_handler.h"
+
+namespace chromeos {
+
+EmojiPicker::EmojiPicker(content::WebUI* web_ui)
+ : content::WebUIController(web_ui) {
+ // Set up the chrome://emoji-picker source.
+ std::unique_ptr<content::WebUIDataSource> html_source(
+ content::WebUIDataSource::Create(chrome::kChromeUIEmojiPickerHost));
+
+ // As a demonstration of passing a variable for JS to use we pass in some
+ // emoji.
+ html_source->AddString("emoji",
+ "😀,😃,😄,😁,😆,😅,😂,🤣,😭");
+ html_source->UseStringsJs();
+
+ // Add required resources.
+ webui::SetupWebUIDataSource(
+ html_source.get(),
+ base::make_span(kEmojiPickerResources, kEmojiPickerResourcesSize),
+ IDR_EMOJI_PICKER_INDEX_HTML);
+
+ // Attach message handler to handle emoji click events.
+ web_ui->AddMessageHandler(std::make_unique<EmojiHandler>());
+
+ content::BrowserContext* browser_context =
+ web_ui->GetWebContents()->GetBrowserContext();
+ content::WebUIDataSource::Add(browser_context, html_source.release());
+}
+
+EmojiPicker::~EmojiPicker() {}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_picker.h b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_picker.h
new file mode 100644
index 00000000000..1b462812644
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/emoji/emoji_picker.h
@@ -0,0 +1,26 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_PICKER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_PICKER_H_
+
+#include "base/macros.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "ui/web_dialogs/web_dialog_delegate.h"
+
+namespace chromeos {
+
+// The WebUI for chrome://emoji-picker
+class EmojiPicker : public content::WebUIController {
+ public:
+ explicit EmojiPicker(content::WebUI* web_ui);
+ ~EmojiPicker() override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(EmojiPicker);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_EMOJI_EMOJI_PICKER_H_
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 182656e6db0..9cfbc6d7690 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
@@ -12,8 +12,8 @@
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/system/fake_input_device_settings.h"
-#include "chrome/browser/chromeos/system/input_device_settings.h"
+#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"
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 4d99b157710..e30f5b61dc4 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
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/chromeos/system/pointer_device_observer.h"
+#include "chrome/browser/ash/system/pointer_device_observer.h"
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "device/bluetooth/bluetooth_adapter.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/first_run/OWNERS
deleted file mode 100644
index 2dcc458322f..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-alemate@chromium.org
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.cc b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.cc
deleted file mode 100644
index 0abfadebb2f..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2013 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/first_run/first_run_actor.h"
-
-#include <limits>
-
-#include "base/values.h"
-
-namespace {
-const int kNoneValue = std::numeric_limits<int>::min();
-}
-
-namespace chromeos {
-
-FirstRunActor::StepPosition::StepPosition()
- : top_(kNoneValue),
- right_(kNoneValue),
- bottom_(kNoneValue),
- left_(kNoneValue) {
-}
-
-FirstRunActor::StepPosition& FirstRunActor::StepPosition::SetTop(int top) {
- top_ = top;
- return *this;
-}
-
-FirstRunActor::StepPosition& FirstRunActor::StepPosition::SetRight(int right) {
- right_ = right;
- return *this;
-}
-
-FirstRunActor::StepPosition&
-FirstRunActor::StepPosition::SetBottom(int bottom) {
- bottom_ = bottom;
- return *this;
-}
-
-FirstRunActor::StepPosition& FirstRunActor::StepPosition::SetLeft(int left) {
- left_ = left;
- return *this;
-}
-
-base::DictionaryValue FirstRunActor::StepPosition::AsValue() const {
- base::DictionaryValue result;
- if (top_ != kNoneValue)
- result.SetInteger("top", top_);
- if (right_ != kNoneValue)
- result.SetInteger("right", right_);
- if (bottom_ != kNoneValue)
- result.SetInteger("bottom", bottom_);
- if (left_ != kNoneValue)
- result.SetInteger("left", left_);
- return result;
-}
-
-FirstRunActor::FirstRunActor()
- : delegate_(NULL) {
-}
-
-FirstRunActor::~FirstRunActor() {
- if (delegate())
- delegate()->OnActorDestroyed();
- delegate_ = NULL;
-}
-
-} // namespace chromeos
-
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h
deleted file mode 100644
index 1d879e0a94b..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2013 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_FIRST_RUN_FIRST_RUN_ACTOR_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_ACTOR_H_
-
-#include <memory>
-#include <string>
-
-
-namespace base {
-class DictionaryValue;
-}
-
-namespace chromeos {
-
-class FirstRunActor {
- public:
- class Delegate {
- public:
- virtual ~Delegate() {}
-
- // Called after actor was initialized.
- virtual void OnActorInitialized() = 0;
-
- // Called when user clicked "Next" button in step with name |step_name|.
- virtual void OnNextButtonClicked(const std::string& step_name) = 0;
-
- // Called when user clicked "Keep exploring" button.
- virtual void OnHelpButtonClicked() = 0;
-
- // Called after step with |step_name| has been shown.
- virtual void OnStepShown(const std::string& step_name) = 0;
-
- // Called after step with |step_name| has been shown.
- virtual void OnStepHidden(const std::string& step_name) = 0;
-
- // Called in answer to Finalize() call.
- virtual void OnActorFinalized() = 0;
-
- // Notifies about about actor destruction.
- virtual void OnActorDestroyed() = 0;
- };
-
- class StepPosition {
- public:
- // Initializes fields in "non-set" state.
- StepPosition();
-
- // Setters for properties. Return |*this|.
- StepPosition& SetTop(int top);
- StepPosition& SetRight(int right);
- StepPosition& SetBottom(int bottom);
- StepPosition& SetLeft(int left);
-
- // Returns DictionaryValue containing set properties.
- base::DictionaryValue AsValue() const;
-
- private:
- int top_;
- int right_;
- int bottom_;
- int left_;
- };
-
- FirstRunActor();
- virtual ~FirstRunActor();
-
- // Returns |true| if actor is initialized. Other public methods can be called
- // only if |IsInitialized| returns |true|.
- virtual bool IsInitialized() = 0;
-
- // Changes background visibility.
- virtual void SetBackgroundVisible(bool visible) = 0;
-
- // Adds rectangular hole to background with given position and dimensions.
- virtual void AddRectangularHole(int x, int y, int width, int height) = 0;
-
- // Adds round hole to background with given position and dimensions.
- virtual void AddRoundHole(int x, int y, float radius) = 0;
-
- // Removes all holes from background.
- virtual void RemoveBackgroundHoles() = 0;
-
- // Shows step with given name and position.
- virtual void ShowStepPositioned(const std::string& name,
- const StepPosition& position) = 0;
-
- // Shows step with given name that points to given point.
- virtual void ShowStepPointingTo(const std::string& name,
- int x,
- int y,
- int offset) = 0;
-
- // Hides currently shown step.
- virtual void HideCurrentStep() = 0;
-
- // Hides all the UI.
- virtual void Finalize() = 0;
-
- // Whether actor is finalizing now.
- virtual bool IsFinalizing() = 0;
-
- void set_delegate(Delegate* delegate) { delegate_ = delegate; }
- Delegate* delegate() const { return delegate_; }
-
- private:
- Delegate* delegate_;
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_ACTOR_H_
-
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc
deleted file mode 100644
index 8f67e75b16a..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2013 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/first_run/first_run_handler.h"
-
-#include <utility>
-
-#include "base/bind.h"
-#include "base/values.h"
-#include "chrome/browser/chromeos/assistant/assistant_util.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chromeos/constants/chromeos_switches.h"
-#include "content/public/browser/web_ui.h"
-
-namespace {
-
-bool IsAssistantAllowed() {
- return chromeos::assistant::AssistantAllowedState::ALLOWED ==
- assistant::IsAssistantAllowedForProfile(
- ProfileManager::GetActiveUserProfile());
-}
-
-} // namespace
-
-namespace chromeos {
-
-FirstRunHandler::FirstRunHandler()
- : is_initialized_(false),
- is_finalizing_(false) {
-}
-
-bool FirstRunHandler::IsInitialized() {
- return is_initialized_;
-}
-
-void FirstRunHandler::SetBackgroundVisible(bool visible) {
- web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.setBackgroundVisible",
- base::Value(visible));
-}
-
-void FirstRunHandler::AddRectangularHole(int x, int y, int width, int height) {
- web_ui()->CallJavascriptFunctionUnsafe(
- "cr.FirstRun.addRectangularHole", base::Value(x), base::Value(y),
- base::Value(width), base::Value(height));
-}
-
-void FirstRunHandler::AddRoundHole(int x, int y, float radius) {
- web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.addRoundHole",
- base::Value(x), base::Value(y),
- base::Value(radius));
-}
-
-void FirstRunHandler::RemoveBackgroundHoles() {
- web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.removeHoles");
-}
-
-void FirstRunHandler::ShowStepPositioned(const std::string& name,
- const StepPosition& position) {
- base::DictionaryValue step_params;
- step_params.SetKey("name", base::Value(name));
- step_params.SetKey("position", position.AsValue());
- step_params.SetKey("pointWithOffset", base::Value(base::Value::Type::LIST));
- step_params.SetKey("assistantEnabled", base::Value(IsAssistantAllowed()));
-
- web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.showStep", step_params);
-}
-
-void FirstRunHandler::ShowStepPointingTo(const std::string& name,
- int x,
- int y,
- int offset) {
- base::DictionaryValue step_params;
- step_params.SetKey("name", base::Value(name));
- step_params.SetKey("position", base::Value());
- base::ListValue point_with_offset;
- point_with_offset.AppendInteger(x);
- point_with_offset.AppendInteger(y);
- point_with_offset.AppendInteger(offset);
- step_params.SetKey("pointWithOffset", std::move(point_with_offset));
- step_params.SetKey("assistantEnabled", base::Value(IsAssistantAllowed()));
-
- web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.showStep", step_params);
-}
-
-void FirstRunHandler::HideCurrentStep() {
- web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.hideCurrentStep");
-}
-
-void FirstRunHandler::Finalize() {
- is_finalizing_ = true;
- web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.finalize");
-}
-
-bool FirstRunHandler::IsFinalizing() {
- return is_finalizing_;
-}
-
-void FirstRunHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "initialized", base::BindRepeating(&FirstRunHandler::HandleInitialized,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "nextButtonClicked",
- base::BindRepeating(&FirstRunHandler::HandleNextButtonClicked,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "helpButtonClicked",
- base::BindRepeating(&FirstRunHandler::HandleHelpButtonClicked,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "stepShown", base::BindRepeating(&FirstRunHandler::HandleStepShown,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "stepHidden", base::BindRepeating(&FirstRunHandler::HandleStepHidden,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "finalized", base::BindRepeating(&FirstRunHandler::HandleFinalized,
- base::Unretained(this)));
-}
-
-void FirstRunHandler::HandleInitialized(const base::ListValue* args) {
- is_initialized_ = true;
- if (delegate())
- delegate()->OnActorInitialized();
-}
-
-void FirstRunHandler::HandleNextButtonClicked(const base::ListValue* args) {
- std::string step_name;
- CHECK(args->GetString(0, &step_name));
- if (delegate())
- delegate()->OnNextButtonClicked(step_name);
-}
-
-void FirstRunHandler::HandleHelpButtonClicked(const base::ListValue* args) {
- if (delegate())
- delegate()->OnHelpButtonClicked();
-}
-
-void FirstRunHandler::HandleStepShown(const base::ListValue* args) {
- std::string step_name;
- CHECK(args->GetString(0, &step_name));
- if (delegate())
- delegate()->OnStepShown(step_name);
-}
-
-void FirstRunHandler::HandleStepHidden(const base::ListValue* args) {
- std::string step_name;
- CHECK(args->GetString(0, &step_name));
- if (delegate())
- delegate()->OnStepHidden(step_name);
-}
-
-void FirstRunHandler::HandleFinalized(const base::ListValue* args) {
- is_finalizing_ = false;
- if (delegate())
- delegate()->OnActorFinalized();
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h
deleted file mode 100644
index b5cbce35245..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2013 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_FIRST_RUN_FIRST_RUN_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_HANDLER_H_
-
-#include <string>
-
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace chromeos {
-
-class StepPosition;
-
-class FirstRunHandler : public FirstRunActor,
- public content::WebUIMessageHandler {
- public:
- FirstRunHandler();
- // Overriden from FirstRunActor.
- bool IsInitialized() override;
- void SetBackgroundVisible(bool visible) override;
- void AddRectangularHole(int x, int y, int width, int height) override;
- void AddRoundHole(int x, int y, float radius) override;
- void RemoveBackgroundHoles() override;
- void ShowStepPositioned(const std::string& name,
- const StepPosition& position) override;
- void ShowStepPointingTo(const std::string& name,
- int x,
- int y,
- int offset) override;
- void HideCurrentStep() override;
- void Finalize() override;
- bool IsFinalizing() override;
-
- private:
- // Overriden from content::WebUIMessageHandler.
- void RegisterMessages() override;
-
- // Handlers for calls from JS.
- void HandleInitialized(const base::ListValue* args);
- void HandleNextButtonClicked(const base::ListValue* args);
- void HandleHelpButtonClicked(const base::ListValue* args);
- void HandleStepShown(const base::ListValue* args);
- void HandleStepHidden(const base::ListValue* args);
- void HandleFinalized(const base::ListValue* args);
-
- bool is_initialized_;
- bool is_finalizing_;
-
- DISALLOW_COPY_AND_ASSIGN(FirstRunHandler);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_HANDLER_H_
-
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc
deleted file mode 100644
index 2f9c7d1eb4c..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2013 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/first_run/first_run_ui.h"
-
-#include <memory>
-
-#include "ash/public/cpp/shelf_prefs.h"
-#include "base/command_line.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/browser_resources.h"
-#include "chrome/grit/chromium_strings.h"
-#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.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 "ui/display/display.h"
-#include "ui/display/screen.h"
-
-namespace {
-
-const char kFirstRunJSPath[] = "first_run.js";
-const char kShelfAlignmentBottom[] = "bottom";
-const char kShelfAlignmentLeft[] = "left";
-const char kShelfAlignmentRight[] = "right";
-
-void SetLocalizedStrings(Profile* profile,
- base::DictionaryValue* localized_strings) {
- localized_strings->SetString(
- "appListHeader",
- l10n_util::GetStringUTF16(IDS_FIRST_RUN_APP_LIST_STEP_HEADER));
- localized_strings->SetString(
- "appListText1",
- l10n_util::GetStringUTF16(IDS_FIRST_RUN_APP_LIST_STEP_TEXT_1));
- localized_strings->SetString(
- "appListText2",
- l10n_util::GetStringUTF16(IDS_FIRST_RUN_APP_LIST_STEP_TEXT_2));
- localized_strings->SetString(
- "trayHeader", l10n_util::GetStringUTF16(IDS_FIRST_RUN_TRAY_STEP_HEADER));
- localized_strings->SetString(
- "trayText", l10n_util::GetStringUTF16(IDS_FIRST_RUN_TRAY_STEP_TEXT));
- localized_strings->SetString(
- "helpHeader", l10n_util::GetStringUTF16(IDS_FIRST_RUN_HELP_STEP_HEADER));
- localized_strings->SetString(
- "helpText", l10n_util::GetStringUTF16(IDS_FIRST_RUN_HELP_STEP_TEXT));
- localized_strings->SetString(
- "helpKeepExploringButton",
- l10n_util::GetStringUTF16(IDS_FIRST_RUN_HELP_STEP_KEEP_EXPLORING_BUTTON));
- localized_strings->SetString(
- "helpFinishButton",
- l10n_util::GetStringUTF16(IDS_FIRST_RUN_HELP_STEP_FINISH_BUTTON));
- localized_strings->SetString(
- "nextButton", l10n_util::GetStringUTF16(IDS_FIRST_RUN_NEXT_BUTTON));
- localized_strings->SetString(
- "accessibleTitle",
- l10n_util::GetStringUTF16(IDS_FIRST_RUN_STEP_ACCESSIBLE_TITLE));
- ash::ShelfAlignment alignment = ash::GetShelfAlignmentPref(
- profile->GetPrefs(),
- display::Screen::GetScreen()->GetPrimaryDisplay().id());
- std::string shelf_alignment;
- switch (alignment) {
- case ash::ShelfAlignment::kBottom:
- case ash::ShelfAlignment::kBottomLocked:
- shelf_alignment = kShelfAlignmentBottom;
- break;
- case ash::ShelfAlignment::kLeft:
- shelf_alignment = kShelfAlignmentLeft;
- break;
- case ash::ShelfAlignment::kRight:
- shelf_alignment = kShelfAlignmentRight;
- break;
- }
- localized_strings->SetString("shelfAlignment", shelf_alignment);
-}
-
-content::WebUIDataSource* CreateDataSource(Profile* profile) {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIFirstRunHost);
- source->UseStringsJs();
- source->SetDefaultResource(IDR_FIRST_RUN_HTML);
- source->AddResourcePath(kFirstRunJSPath, IDR_FIRST_RUN_JS);
- base::DictionaryValue localized_strings;
- const std::string& app_locale = g_browser_process->GetApplicationLocale();
- webui::SetLoadTimeDataDefaults(app_locale, &localized_strings);
- SetLocalizedStrings(profile, &localized_strings);
- source->AddLocalizedStrings(localized_strings);
- return source;
-}
-
-} // anonymous namespace
-
-namespace chromeos {
-
-FirstRunUI::FirstRunUI(content::WebUI* web_ui)
- : WebUIController(web_ui),
- actor_(NULL) {
- auto handler = std::make_unique<FirstRunHandler>();
- actor_ = handler.get();
- web_ui->AddMessageHandler(std::move(handler));
- Profile* profile = Profile::FromWebUI(web_ui);
- content::WebUIDataSource::Add(profile, CreateDataSource(profile));
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h
deleted file mode 100644
index e53964d93c2..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2013 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_FIRST_RUN_FIRST_RUN_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_UI_H_
-
-#include "base/macros.h"
-#include "content/public/browser/web_ui_controller.h"
-
-namespace content {
-class WebUI;
-}
-
-namespace chromeos {
-
-class FirstRunActor;
-
-// WebUI controller for first-run tutorial.
-class FirstRunUI : public content::WebUIController {
- public:
- explicit FirstRunUI(content::WebUI* web_ui);
- FirstRunActor* get_actor() { return actor_; }
- private:
- FirstRunActor* actor_;
-
- DISALLOW_COPY_AND_ASSIGN(FirstRunUI);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_FIRST_RUN_FIRST_RUN_UI_H_
-
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 0cab506e700..ffbf3b7d960 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
@@ -9,8 +9,7 @@
#include "base/check.h"
#include "base/macros.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/login/saml/in_session_password_change_manager.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/ash/login/saml/in_session_password_change_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chromeos/login/auth/saml_password_attributes.h"
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 f3104499174..1382ef79ddd 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
@@ -7,7 +7,7 @@
#include "base/memory/weak_ptr.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/login/saml/in_session_password_change_manager.h"
+#include "chrome/browser/ash/login/saml/in_session_password_change_manager.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace chromeos {
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 0275b3f2117..06da296109e 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
@@ -8,6 +8,12 @@
#include "base/bind.h"
#include "base/json/json_writer.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/profiles/profile_helper.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -67,8 +73,25 @@ void LockScreenStartReauthDialog::Show() {
g_dialog->Focus();
return;
}
- g_dialog = new LockScreenStartReauthDialog();
- g_dialog->ShowSystemDialog();
+ g_dialog = this;
+ g_browser_process->profile_manager()->CreateProfileAsync(
+ ProfileHelper::GetLockScreenProfileDir(),
+ base::BindRepeating(&LockScreenStartReauthDialog::OnProfileCreated,
+ weak_factory_.GetWeakPtr()),
+ base::string16(), std::string());
+}
+
+void LockScreenStartReauthDialog::OnProfileCreated(
+ Profile* profile,
+ Profile::CreateStatus status) {
+ if (status == Profile::CREATE_STATUS_INITIALIZED) {
+ g_dialog->ShowSystemDialogForBrowserContext(
+ profile->GetPrimaryOTRProfile());
+ } else if (status != Profile::CREATE_STATUS_CREATED) {
+ // TODO(mohammedabdon): Create some generic way to show an error on the lock
+ // screen.
+ LOG(ERROR) << "Failed to load lockscreen profile";
+ }
}
void LockScreenStartReauthDialog::Dismiss() {
@@ -77,6 +100,16 @@ void LockScreenStartReauthDialog::Dismiss() {
g_dialog->Close();
}
+void LockScreenStartReauthDialog::OnDialogClosed(
+ const std::string& json_retval) {
+ const user_manager::User* user =
+ user_manager::UserManager::Get()->GetActiveUser();
+ Profile* profile = ProfileHelper::Get()->GetProfileByUser(user);
+ InSessionPasswordSyncManager* password_sync_manager =
+ chromeos::InSessionPasswordSyncManagerFactory::GetForProfile(profile);
+ password_sync_manager->ResetDialog();
+}
+
bool LockScreenStartReauthDialog::IsRunning() {
return g_dialog;
}
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 f46252c1240..fccd35b3ffd 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
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_REAUTH_DIALOGS_H_
#include "base/macros.h"
-#include "base/strings/string16.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
#include "ui/web_dialogs/web_dialog_ui.h"
@@ -37,6 +37,12 @@ class LockScreenStartReauthDialog : public BaseLockDialog {
void Show();
void Dismiss();
bool IsRunning();
+
+ private:
+ void OnProfileCreated(Profile* profile, Profile::CreateStatus status);
+ void OnDialogClosed(const std::string& json_retval) override;
+
+ base::WeakPtrFactory<LockScreenStartReauthDialog> weak_factory_{this};
};
} // namespace chromeos
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 58d29d6f3b8..bf4915d9809 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
@@ -4,18 +4,277 @@
#include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h"
+#include "base/notreached.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/browser_process.h"
+#include "chrome/browser/browser_process_platform_part.h"
+#include "chrome/browser/chromeos/login/signin_partition_manager.h"
+#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
+#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
+#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/login/auth/challenge_response/cert_utils.h"
+#include "chromeos/login/auth/cryptohome_key_constants.h"
+#include "components/user_manager/known_user.h"
+#include "content/public/browser/storage_partition.h"
+#include "google_apis/gaia/gaia_auth_util.h"
+#include "google_apis/gaia/gaia_urls.h"
+#include "ui/base/l10n/l10n_util.h"
+
namespace chromeos {
+namespace {
+
+std::vector<std::string> ConvertToVector(const base::ListValue* list) {
+ std::vector<std::string> string_list;
+ if (!list) {
+ return string_list;
+ }
+
+ for (const base::Value& value : *list) {
+ if (value.is_string()) {
+ string_list.push_back(value.GetString());
+ }
+ }
+
+ return string_list;
+}
+
+} // namespace
+
+LockScreenReauthHandler::LockScreenReauthHandler(const std::string& email)
+ : email_(email) {}
-LockScreenReauthHandler::LockScreenReauthHandler() = default;
LockScreenReauthHandler::~LockScreenReauthHandler() = default;
-void LockScreenReauthHandler::HandleInitialize(const base::ListValue* value) {}
+void LockScreenReauthHandler::HandleInitialize(const base::ListValue* value) {
+ LoadAuthenticatorParam();
+}
+
+void LockScreenReauthHandler::HandleAuthenticatorLoaded(
+ const base::ListValue* value) {
+ VLOG(1) << "Authenticator finished loading";
+ authenticator_being_loaded_ = false;
+ // Recreate the client cert usage observer, in order to track only the certs
+ // used during the current sign-in attempt.
+ extension_provided_client_cert_usage_observer_ =
+ std::make_unique<LoginClientCertUsageObserver>();
+}
+
+void LockScreenReauthHandler::LoadAuthenticatorParam() {
+ if (authenticator_being_loaded_) {
+ VLOG(1) << "Skip loading the Authenticator as it's already being loaded ";
+ return;
+ }
+
+ authenticator_being_loaded_ = true;
+ login::GaiaContext context;
+ context.force_reload = true;
+ context.email = email_;
+
+ std::string gaia_id;
+ if (!context.email.empty() &&
+ user_manager::known_user::FindGaiaID(
+ AccountId::FromUserEmail(context.email), &gaia_id)) {
+ context.gaia_id = gaia_id;
+ }
+
+ if (!context.email.empty()) {
+ context.gaps_cookie = user_manager::known_user::GetGAPSCookie(
+ AccountId::FromUserEmail(gaia::CanonicalizeEmail(context.email)));
+ }
+
+ LoadGaia(context);
+}
+
+void LockScreenReauthHandler::LoadGaia(const login::GaiaContext& context) {
+ // Start a new session with SigninPartitionManager, generating a unique
+ // StoragePartition.
+ login::SigninPartitionManager* signin_partition_manager =
+ login::SigninPartitionManager::Factory::GetForBrowserContext(
+ Profile::FromWebUI(web_ui()));
+
+ signin_partition_manager->StartSigninSession(
+ web_ui()->GetWebContents(),
+ base::BindOnce(&LockScreenReauthHandler::LoadGaiaWithPartition,
+ weak_factory_.GetWeakPtr(), context));
+}
+
+void LockScreenReauthHandler::LoadGaiaWithPartition(
+ const login::GaiaContext& context,
+ const std::string& partition_name) {
+ auto callback = base::BindOnce(
+ &LockScreenReauthHandler::OnSetCookieForLoadGaiaWithPartition,
+ weak_factory_.GetWeakPtr(), context, partition_name);
+ if (context.gaps_cookie.empty()) {
+ std::move(callback).Run(net::CookieAccessResult());
+ return;
+ }
+
+ // When the network service is enabled the webRequest API doesn't allow
+ // modification of the cookie header. So manually write the GAPS cookie into
+ // the CookieManager.
+ login::SigninPartitionManager* signin_partition_manager =
+ login::SigninPartitionManager::Factory::GetForBrowserContext(
+ Profile::FromWebUI(web_ui()));
+
+ login::SetCookieForPartition(context, signin_partition_manager,
+ std::move(callback));
+}
+
+void LockScreenReauthHandler::OnSetCookieForLoadGaiaWithPartition(
+ const login::GaiaContext& context,
+ const std::string& partition_name,
+ net::CookieAccessResult result) {
+ base::DictionaryValue params;
+
+ params.SetString("webviewPartitionName", partition_name);
+ signin_partition_name_ = partition_name;
+
+ params.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec());
+ params.SetString("clientId",
+ GaiaUrls::GetInstance()->oauth2_chrome_client_id());
+ params.SetBoolean("dontResizeNonEmbeddedPages", false);
+ params.SetBoolean("enableGaiaActionButtons", false);
+
+ std::string enterprise_enrollment_domain(
+ g_browser_process->platform_part()
+ ->browser_policy_connector_chromeos()
+ ->GetEnterpriseEnrollmentDomain());
+
+ if (enterprise_enrollment_domain.empty()) {
+ enterprise_enrollment_domain = gaia::ExtractDomainName(context.email);
+ }
+
+ params.SetString("enterpriseEnrollmentDomain", enterprise_enrollment_domain);
+
+ const std::string app_locale = g_browser_process->GetApplicationLocale();
+ DCHECK(!app_locale.empty());
+ params.SetString("hl", app_locale);
+ params.SetString("email", context.email);
+ params.SetString("gaiaId", context.gaia_id);
+ params.SetBoolean("extractSamlPasswordAttributes",
+ login::ExtractSamlPasswordAttributesEnabled());
+
+ AllowJavascript();
+ CallJavascriptFunction("$(\'main-element\').loadAuthenticator", params);
+}
+
+void LockScreenReauthHandler::HandleCompleteAuthentication(
+ const base::ListValue* params) {
+ CHECK_EQ(params->GetList().size(), 6);
+ std::string gaia_id, email, password;
+ bool using_saml;
+ const base::ListValue* servicesList;
+ ::login::StringList services = ::login::StringList();
+ const base::DictionaryValue* password_attributes;
+ gaia_id = params->GetList()[0].GetString();
+ email = params->GetList()[1].GetString();
+ password = params->GetList()[2].GetString();
+ using_saml = params->GetList()[3].GetBool();
+ params->GetList(4, &servicesList);
+ services = ConvertToVector(servicesList);
+ params->GetDictionary(5, &password_attributes);
+
+ if (gaia::CanonicalizeEmail(email) != gaia::CanonicalizeEmail(email_)) {
+ // The authenticated user email doesn't match the current user's email.
+ CallJavascriptFunction("$(\'main-element\').resetAuthenticator");
+ return;
+ }
+
+ DCHECK(!email.empty());
+ DCHECK(!gaia_id.empty());
+
+ login::SigninPartitionManager* signin_partition_manager =
+ login::SigninPartitionManager::Factory::GetForBrowserContext(
+ Profile::FromWebUI(web_ui()));
+
+ online_login_helper_ = std::make_unique<OnlineLoginHelper>(
+ signin_partition_name_, signin_partition_manager,
+ base::BindOnce(&LockScreenReauthHandler::OnCookieWaitTimeout,
+ weak_factory_.GetWeakPtr()),
+ base::BindOnce(&LockScreenReauthHandler::CheckCredentials,
+ weak_factory_.GetWeakPtr()));
+
+ std::string error_message;
+ pending_user_context_ = std::make_unique<UserContext>();
+ if (!login::BuildUserContextForGaiaSignIn(
+ login::GetUsertypeFromServicesString(services),
+ user_manager::known_user::GetAccountId(email, gaia_id,
+ AccountType::GOOGLE),
+ using_saml, false /* using_saml_api */, password,
+ SamlPasswordAttributes::FromJs(*password_attributes),
+ /*sync_trusted_vault_keys=*/base::nullopt,
+ *extension_provided_client_cert_usage_observer_,
+ pending_user_context_.get(), &error_message)) {
+ pending_user_context_.reset();
+ NOTREACHED();
+ return;
+ }
+
+ online_login_helper_->SetUserContext(std::move(pending_user_context_));
+ online_login_helper_->RequestCookiesAndCompleteAuthentication();
+}
+
+void LockScreenReauthHandler::OnCookieWaitTimeout() {
+ NOTREACHED() << "Cookie has timed out while attempting to login in.";
+ const user_manager::User* user =
+ user_manager::UserManager::Get()->GetActiveUser();
+ Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(user);
+ chromeos::InSessionPasswordSyncManager* password_sync_manager =
+ chromeos::InSessionPasswordSyncManagerFactory::GetForProfile(profile);
+ password_sync_manager->DismissDialog();
+}
+
+void LockScreenReauthHandler::CheckCredentials(
+ const UserContext& user_context) {
+ Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByAccountId(
+ user_context.GetAccountId());
+ if (!profile) {
+ LOG(ERROR) << "Invalid account id";
+ return;
+ }
+ auto password_changed_callback =
+ base::BindRepeating(&LockScreenReauthHandler::ShowPasswordChangedScreen,
+ weak_factory_.GetWeakPtr());
+ password_sync_manager_ =
+ chromeos::InSessionPasswordSyncManagerFactory::GetForProfile(profile);
+ password_sync_manager_->CheckCredentials(user_context,
+ password_changed_callback);
+}
+
+void LockScreenReauthHandler::HandleUpdateUserPassword(
+ const base::ListValue* value) {
+ std::string old_password;
+ value->GetString(0, &old_password);
+ password_sync_manager_->UpdateUserPassword(old_password);
+}
+
+void LockScreenReauthHandler::ShowPasswordChangedScreen() {
+ CallJavascriptFunction("$(\'main-element\').passwordChanged");
+}
void LockScreenReauthHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"initialize",
base::BindRepeating(&LockScreenReauthHandler::HandleInitialize,
weak_factory_.GetWeakPtr()));
+
+ web_ui()->RegisterMessageCallback(
+ "authenticatorLoaded",
+ base::BindRepeating(&LockScreenReauthHandler::HandleAuthenticatorLoaded,
+ weak_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "completeAuthentication",
+ base::BindRepeating(
+ &LockScreenReauthHandler::HandleCompleteAuthentication,
+ weak_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "updateUserPassword",
+ base::BindRepeating(&LockScreenReauthHandler::HandleUpdateUserPassword,
+ weak_factory_.GetWeakPtr()));
}
-} // namespace chromeos \ No newline at end of file
+} // namespace chromeos
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 f8871e143b7..23c17c883a6 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
@@ -7,22 +7,64 @@
#include "base/memory/weak_ptr.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "components/user_manager/user.h"
+#include "chrome/browser/ui/webui/chromeos/login/online_login_helper.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "net/cookies/cookie_access_result.h"
namespace chromeos {
+class InSessionPasswordSyncManager;
class LockScreenReauthHandler : public content::WebUIMessageHandler {
public:
- LockScreenReauthHandler();
+ explicit LockScreenReauthHandler(const std::string& email);
~LockScreenReauthHandler() override;
void RegisterMessages() override;
+ void ShowPasswordChangedScreen();
+
+ // WebUI message handlers.
void HandleInitialize(const base::ListValue*);
+ void HandleCompleteAuthentication(const base::ListValue*);
+ void HandleAuthenticatorLoaded(const base::ListValue*);
+ void HandleUpdateUserPassword(const base::ListValue*);
private:
+ void LoadAuthenticatorParam();
+
+ void LoadGaia(const login::GaiaContext& context);
+
+ // Callback that loads GAIA after version and stat consent information has
+ // been retrieved.
+ void LoadGaiaWithPartition(const login::GaiaContext& context,
+ const std::string& partition_name);
+
+ // Called after the GAPS cookie, if present, is added to the cookie store.
+ void OnSetCookieForLoadGaiaWithPartition(const login::GaiaContext& context,
+ const std::string& partition_name,
+ net::CookieAccessResult result);
+
+ void OnCookieWaitTimeout();
+
+ void CheckCredentials(const UserContext& user_context);
+
+ // True if the authenticator is still loading.
+ bool authenticator_being_loaded_ = false;
+
+ // User non-canonicalized email for display
+ std::string email_;
+
+ std::string signin_partition_name_;
+
+ InSessionPasswordSyncManager* password_sync_manager_ = nullptr;
+
+ std::unique_ptr<UserContext> pending_user_context_;
+
+ std::unique_ptr<LoginClientCertUsageObserver>
+ extension_provided_client_cert_usage_observer_;
+
+ std::unique_ptr<OnlineLoginHelper> online_login_helper_;
+
base::WeakPtrFactory<LockScreenReauthHandler> weak_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc
index 80217da4c7a..b61eac5fe83 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc
@@ -14,6 +14,7 @@
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/chromeos/devicetype_utils.h"
namespace chromeos {
@@ -21,7 +22,7 @@ LockScreenStartReauthUI::LockScreenStartReauthUI(content::WebUI* web_ui)
: ui::WebDialogUI(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
const user_manager::User* user =
- ProfileHelper::Get()->GetUserByProfile(profile);
+ user_manager::UserManager::Get()->GetActiveUser();
std::string email;
if (user) {
email = user->GetDisplayEmail();
@@ -30,16 +31,20 @@ LockScreenStartReauthUI::LockScreenStartReauthUI(content::WebUI* web_ui)
content::WebUIDataSource* source = content::WebUIDataSource::Create(
chrome::kChromeUILockScreenStartReauthHost);
- web_ui->AddMessageHandler(std::make_unique<LockScreenReauthHandler>());
+ web_ui->AddMessageHandler(std::make_unique<LockScreenReauthHandler>(email));
// TODO(crbug.com/1098690): Trusted Type Polymer
source->DisableTrustedTypesCSP();
+ source->EnableReplaceI18nInJS();
+
source->AddString("lockScreenReauthSubtitile",
l10n_util::GetStringFUTF16(IDS_LOCK_SCREEN_REAUTH_SUBTITLE,
base::UTF8ToUTF16(email)));
- source->AddString("lockScreenReauthSubtitileWithError",
- l10n_util::GetStringFUTF16(IDS_LOCK_SCREEN_WRONG_USER,
+ source->AddString("lockScreenReauthSubtitile1WithError",
+ l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_WRONG_USER_SUBTITLE1));
+ source->AddString("lockScreenReauthSubtitile2WithError",
+ l10n_util::GetStringFUTF16(IDS_LOCK_SCREEN_WRONG_USER_SUBTITLE2,
base::UTF8ToUTF16(email)));
source->AddString("lockScreenVerifyButton",
@@ -49,15 +54,51 @@ LockScreenStartReauthUI::LockScreenStartReauthUI(content::WebUI* web_ui)
l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_VERIFY_AGAIN_BUTTON));
source->AddString("lockScreenCancelButton",
l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_CANCEL_BUTTON));
+ source->AddString("lockScreenCloseButton",
+ l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_CLOSE_BUTTON));
+ source->AddString(
+ "lockScreenNextButton",
+ l10n_util::GetStringUTF16(IDS_LOGIN_SAML_INTERSTITIAL_NEXT_BUTTON_TEXT));
+ source->AddString(
+ "confirmPasswordLabel",
+ l10n_util::GetStringUTF16(IDS_LOGIN_CONFIRM_PASSWORD_LABEL));
+ source->AddString(
+ "manualPasswordInputLabel",
+ l10n_util::GetStringUTF16(IDS_LOGIN_MANUAL_PASSWORD_INPUT_LABEL));
+ source->AddString("passwordChangedIncorrectOldPassword",
+ l10n_util::GetStringUTF16(
+ IDS_LOGIN_PASSWORD_CHANGED_INCORRECT_OLD_PASSWORD));
+ source->AddString(
+ "manualPasswordMismatch",
+ l10n_util::GetStringUTF16(IDS_LOGIN_MANUAL_PASSWORD_MISMATCH));
source->AddString("loginWelcomeMessage",
l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_VERIFY_ACCOUNT));
source->AddString(
"loginWelcomeMessageWithError",
l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_VERIFICATION_FAILED));
+ source->AddString(
+ "manualPasswordSubtitle",
+ l10n_util::GetStringUTF16(IDS_LOCK_MANUAL_PASSWORD_SUBTITLE));
+ source->AddString("confirmPasswordSubtitle",
+ l10n_util::GetStringFUTF16(IDS_LOGIN_CONFIRM_PASSWORD_TITLE,
+ ui::GetChromeOSDeviceName()));
+ source->AddString("samlNotice",
+ l10n_util::GetStringUTF16(IDS_LOCK_SAML_NOTICE));
+ source->AddString("passwordChangedTitle",
+ l10n_util::GetStringUTF16(IDS_LOCK_PASSWORD_CHANGED_TITLE));
+ source->AddString(
+ "passwordChangedSubtitle",
+ l10n_util::GetStringFUTF16(IDS_LOCK_PASSWORD_CHANGED_SUBTITLE,
+ ui::GetChromeOSDeviceName()));
+ source->AddString(
+ "passwordChangedOldPasswordHint",
+ l10n_util::GetStringUTF16(IDS_LOCK_PASSWORD_CHANGED_OLD_PASSWORD_HINT));
source->SetDefaultResource(IDR_LOCK_SCREEN_REAUTH_HTML);
source->AddResourcePath("authenticator.js", IDR_GAIA_AUTH_AUTHENTICATOR_JS);
+ source->AddResourcePath("webview_saml_injected.js",
+ IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS);
source->AddResourcePath("lock_screen_reauth.js", IDR_LOCK_SCREEN_REAUTH_JS);
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 d4c4c277913..5541f632965 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
@@ -9,10 +9,10 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h"
+#include "chrome/browser/ash/login/auth/chrome_cryptohome_authenticator.h"
+#include "chrome/browser/ash/login/saml/in_session_password_change_manager.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/login/login_pref_names.h"
-#include "chrome/browser/chromeos/login/saml/in_session_password_change_manager.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/login/auth/saml_password_attributes.h"
#include "components/prefs/pref_service.h"
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 3eeb1111dd3..214b036b2e6 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,12 +6,13 @@
#include <memory>
+#include "ash/constants/ash_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ash/login/saml/password_expiry_notification.h"
#include "chrome/browser/chromeos/login/login_pref_names.h"
-#include "chrome/browser/chromeos/login/saml/password_expiry_notification.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_dialogs.h"
@@ -21,7 +22,6 @@
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/login/auth/saml_password_attributes.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "components/prefs/pref_service.h"
@@ -99,6 +99,8 @@ PasswordChangeUI::PasswordChangeUI(content::WebUI* web_ui)
source->AddResourcePath("password_change.css", IDR_PASSWORD_CHANGE_CSS);
source->AddResourcePath("authenticator.js",
IDR_PASSWORD_CHANGE_AUTHENTICATOR_JS);
+ source->AddResourcePath("webview_saml_injected.js",
+ IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS);
source->AddResourcePath("password_change.js", IDR_PASSWORD_CHANGE_JS);
content::WebUIDataSource::Add(profile, source);
@@ -131,7 +133,7 @@ ConfirmPasswordChangeUI::ConfirmPasswordChangeUI(content::WebUI* web_ui)
{"matchError", IDS_PASSWORD_CHANGE_PASSWORDS_DONT_MATCH},
{"save", IDS_PASSWORD_CHANGE_CONFIRM_SAVE_BUTTON}};
- AddLocalizedStringsBulk(source, kLocalizedStrings);
+ source->AddLocalizedStrings(kLocalizedStrings);
AddSize(source, "", ConfirmPasswordChangeDialog::GetSize(false, false));
AddSize(source, "Old", ConfirmPasswordChangeDialog::GetSize(true, false));
@@ -175,7 +177,7 @@ UrgentPasswordExpiryNotificationUI::UrgentPasswordExpiryNotificationUI(
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"body", IDS_PASSWORD_EXPIRY_CALL_TO_ACTION_CRITICAL},
{"button", IDS_OK}};
- AddLocalizedStringsBulk(source, kLocalizedStrings);
+ source->AddLocalizedStrings(kLocalizedStrings);
source->UseStringsJs();
source->SetDefaultResource(IDR_URGENT_PASSWORD_EXPIRY_NOTIFICATION_HTML);
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 38b27d06c6b..c5c9edc4f00 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
@@ -8,9 +8,8 @@
#include "base/macros.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/login/saml/in_session_password_change_manager.h"
-#include "chrome/browser/chromeos/login/saml/password_expiry_notification.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/ash/login/saml/in_session_password_change_manager.h"
+#include "chrome/browser/ash/login/saml/password_expiry_notification.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chromeos/login/auth/saml_password_attributes.h"
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 d805793bc76..0acd7b44797 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc
@@ -8,9 +8,12 @@
#include "base/json/json_writer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#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"
@@ -155,14 +158,12 @@ InternetConfigDialogUI::InternetConfigDialogUI(content::WebUI* web_ui)
AddInternetStrings(source);
source->AddLocalizedString("title", IDS_SETTINGS_INTERNET_CONFIG);
source->UseStringsJs();
-#if BUILDFLAG(OPTIMIZE_WEBUI)
- source->SetDefaultResource(IDR_INTERNET_CONFIG_DIALOG_VULCANIZED_HTML);
- source->AddResourcePath("crisper.js", IDR_INTERNET_CONFIG_DIALOG_CRISPER_JS);
-#else
- source->SetDefaultResource(IDR_INTERNET_CONFIG_DIALOG_HTML);
- source->AddResourcePath("internet_config_dialog.js",
- IDR_INTERNET_CONFIG_DIALOG_JS);
-#endif
+
+ webui::SetupWebUIDataSource(
+ source,
+ base::make_span(kInternetConfigDialogResources,
+ kInternetConfigDialogResourcesSize),
+ IDR_INTERNET_CONFIG_DIALOG_INTERNET_CONFIG_DIALOG_CONTAINER_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
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 c2723b03f16..5a75fe002e7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc
@@ -10,14 +10,18 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#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/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"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -139,14 +143,12 @@ InternetDetailDialogUI::InternetDetailDialogUI(content::WebUI* web_ui)
AddInternetStrings(source);
source->AddLocalizedString("title", IDS_SETTINGS_INTERNET_DETAIL);
source->UseStringsJs();
-#if BUILDFLAG(OPTIMIZE_WEBUI)
- source->SetDefaultResource(IDR_INTERNET_DETAIL_DIALOG_VULCANIZED_HTML);
- source->AddResourcePath("crisper.js", IDR_INTERNET_DETAIL_DIALOG_CRISPER_JS);
-#else
- source->SetDefaultResource(IDR_INTERNET_DETAIL_DIALOG_HTML);
- source->AddResourcePath("internet_detail_dialog.js",
- IDR_INTERNET_DETAIL_DIALOG_JS);
-#endif
+
+ webui::SetupWebUIDataSource(
+ source,
+ base::make_span(kInternetDetailDialogResources,
+ kInternetDetailDialogResourcesSize),
+ IDR_INTERNET_DETAIL_DIALOG_INTERNET_DETAIL_DIALOG_CONTAINER_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/login/DIR_METADATA
new file mode 100644
index 00000000000..ad3c5e12240
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Shell>OOBE"
+}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
index 5dbb46f035d..39af14ec6d6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
@@ -6,5 +6,3 @@ rsorokin@chromium.org
achuith@chromium.org
alemate@chromium.org
tbarzic@chromium.org
-
-# COMPONENT: UI>Shell>OOBE
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_login_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_login_screen_handler.cc
index 9fd5b2414f3..bd17bdb9049 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_login_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_login_screen_handler.cc
@@ -4,10 +4,10 @@
#include "chrome/browser/ui/webui/chromeos/login/active_directory_login_screen_handler.h"
+#include "chrome/browser/ash/login/screens/active_directory_login_screen.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/active_directory_login_screen.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chrome/grit/chromium_strings.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
index 1b1f25b9582..9743c6db446 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
@@ -21,10 +21,8 @@ constexpr StaticOobeScreenId ActiveDirectoryPasswordChangeView::kScreenId;
ActiveDirectoryPasswordChangeScreenHandler::
ActiveDirectoryPasswordChangeScreenHandler(
- JSCallsContainer* js_calls_container,
- CoreOobeView* core_oobe_view)
- : BaseScreenHandler(kScreenId, js_calls_container),
- core_oobe_view_(core_oobe_view) {
+ JSCallsContainer* js_calls_container)
+ : BaseScreenHandler(kScreenId, js_calls_container) {
set_user_acted_method_path(
"login.ActiveDirectoryPasswordChangeScreen.userActed");
}
@@ -67,8 +65,8 @@ void ActiveDirectoryPasswordChangeScreenHandler::Unbind() {
void ActiveDirectoryPasswordChangeScreenHandler::ShowSignInError(
const std::string& error_text) {
- core_oobe_view_->ShowSignInError(0, error_text, std::string(),
- HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
+ CallJS("login.ActiveDirectoryPasswordChangeScreen.showErrorDialog",
+ error_text);
}
void ActiveDirectoryPasswordChangeScreenHandler::HandleComplete(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h
index 4e8360f2b31..b807db35ca4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h
@@ -8,13 +8,12 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/screens/active_directory_password_change_screen.h"
+#include "chrome/browser/ash/login/screens/active_directory_password_change_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
class ActiveDirectoryPasswordChangeScreen;
-class CoreOobeView;
// Interface for dependency injection between
// ActiveDirectoryPasswordChangeScreen and its WebUI representation.
@@ -45,8 +44,7 @@ class ActiveDirectoryPasswordChangeScreenHandler
using TView = ActiveDirectoryPasswordChangeView;
ActiveDirectoryPasswordChangeScreenHandler(
- JSCallsContainer* js_calls_container,
- CoreOobeView* core_oobe_view);
+ JSCallsContainer* js_calls_container);
~ActiveDirectoryPasswordChangeScreenHandler() override;
// BaseScreenHandler implementation:
@@ -70,9 +68,6 @@ class ActiveDirectoryPasswordChangeScreenHandler
ActiveDirectoryPasswordChangeScreen* screen_ = nullptr;
- // Non-owned. Used to display signin error.
- CoreOobeView* core_oobe_view_ = nullptr;
-
DISALLOW_COPY_AND_ASSIGN(ActiveDirectoryPasswordChangeScreenHandler);
};
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 c75bc74cd03..49c21cb8123 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
@@ -4,13 +4,15 @@
#include "chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h"
-#include "chrome/browser/chromeos/login/screens/app_downloading_screen.h"
+#include "ash/constants/ash_features.h"
+#include "chrome/browser/ash/login/screens/app_downloading_screen.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/grit/generated_resources.h"
#include "components/arc/arc_prefs.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/chromeos/devicetype_utils.h"
namespace {
@@ -39,14 +41,24 @@ AppDownloadingScreenHandler::~AppDownloadingScreenHandler() {}
void AppDownloadingScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
+ if (features::IsNewOobeLayoutEnabled()) {
+ builder->AddF("appDownloadingScreenDescription",
+ IDS_LOGIN_APP_DOWNLOADING_SCREEN_DESCRIPTION_NEW,
+ ui::GetChromeOSDeviceName());
+ builder->Add("appDownloadingContinueSetup",
+ IDS_LOGIN_APP_DOWNLOADING_SCREEN_NEXT);
+ } else {
+ builder->Add("appDownloadingScreenDescription",
+ IDS_LOGIN_APP_DOWNLOADING_SCREEN_DESCRIPTION);
+ builder->Add("appDownloadingContinueSetup",
+ IDS_LOGIN_APP_DOWNLOADING_CONTINUE_SETUP);
+ }
+ builder->Add("appDownloadingScreenTitle",
+ IDS_LOGIN_APP_DOWNLOADING_SCREEN_TITLE);
builder->Add("appDownloadingScreenTitleSingular",
IDS_LOGIN_APP_DOWNLOADING_SCREEN_TITLE_SINGULAR);
builder->Add("appDownloadingScreenTitlePlural",
IDS_LOGIN_APP_DOWNLOADING_SCREEN_TITLE_PLURAL);
- builder->Add("appDownloadingScreenDescription",
- IDS_LOGIN_APP_DOWNLOADING_SCREEN_DESCRIPTION);
- builder->Add("appDownloadingContinueSetup",
- IDS_LOGIN_APP_DOWNLOADING_CONTINUE_SETUP);
}
void AppDownloadingScreenHandler::RegisterMessages() {
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 271a0a05330..8b1c2ff84e7 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
@@ -7,10 +7,11 @@
#include <memory>
#include <utility>
+#include "ash/public/cpp/login_screen.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/ash/login/screens/network_error.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/network_error.h"
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/grit/chrome_unscaled_resources.h"
@@ -181,6 +182,12 @@ void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() {
error_screen_->Show(nullptr);
}
+void AppLaunchSplashScreenHandler::ShowErrorMessage(
+ KioskAppLaunchError::Error error) {
+ ash::LoginScreen::Get()->ShowKioskAppError(
+ KioskAppLaunchError::GetErrorMessage(error));
+}
+
bool AppLaunchSplashScreenHandler::IsNetworkReady() {
return network_state_informer_->state() == NetworkStateInformer::ONLINE;
}
@@ -240,6 +247,8 @@ int AppLaunchSplashScreenHandler::GetProgressMessageFromState(
return IDS_APP_START_NETWORK_WAIT_MESSAGE;
case APP_LAUNCH_STATE_INSTALLING_APPLICATION:
return IDS_APP_START_APP_WAIT_MESSAGE;
+ case APP_LAUNCH_STATE_INSTALLING_EXTENSION:
+ return IDS_APP_START_EXTENSION_WAIT_MESSAGE;
case APP_LAUNCH_STATE_WAITING_APP_WINDOW:
return IDS_APP_START_WAIT_FOR_APP_WINDOW_MESSAGE;
case APP_LAUNCH_STATE_WAITING_APP_WINDOW_INSTALL_FAILED:
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 1d121525a5f..da4a8dfc829 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
@@ -9,8 +9,9 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_base.h"
-#include "chrome/browser/chromeos/login/screens/error_screen.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_launch_error.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_manager_base.h"
+#include "chrome/browser/ash/login/screens/error_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
@@ -51,6 +52,7 @@ class AppLaunchSplashScreenView {
APP_LAUNCH_STATE_PREPARING_PROFILE,
APP_LAUNCH_STATE_PREPARING_NETWORK,
APP_LAUNCH_STATE_INSTALLING_APPLICATION,
+ APP_LAUNCH_STATE_INSTALLING_EXTENSION,
APP_LAUNCH_STATE_WAITING_APP_WINDOW,
APP_LAUNCH_STATE_WAITING_APP_WINDOW_INSTALL_FAILED,
APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT,
@@ -79,6 +81,9 @@ class AppLaunchSplashScreenView {
// Shows the network error and configure UI.
virtual void ShowNetworkConfigureUI() = 0;
+ // Show a notification bar with error message.
+ virtual void ShowErrorMessage(KioskAppLaunchError::Error error) = 0;
+
// Returns true if the default network has Internet access.
virtual bool IsNetworkReady() = 0;
};
@@ -112,6 +117,7 @@ class AppLaunchSplashScreenHandler
void UpdateAppLaunchState(AppLaunchState state) override;
void SetDelegate(Delegate* controller) override;
void ShowNetworkConfigureUI() override;
+ void ShowErrorMessage(KioskAppLaunchError::Error error) override;
bool IsNetworkReady() override;
// NetworkStateInformer::NetworkStateInformerObserver implementation:
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 a837b01fcdd..c0da934dd28 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
@@ -4,23 +4,23 @@
#include "chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h"
+#include "ash/constants/ash_switches.h"
#include "base/command_line.h"
#include "base/hash/sha1.h"
#include "base/i18n/timezone.h"
+#include "chrome/browser/ash/login/screens/arc_terms_of_service_screen.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler.h"
-#include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/consent_auditor/consent_auditor_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#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/constants/chromeos_switches.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
@@ -83,7 +83,12 @@ void ArcTermsOfServiceScreenHandler::MaybeLoadPlayStoreToS(
if (!ignore_network_state && !default_network)
return;
const std::string country_code = base::CountryCodeForCurrentTimezone();
- CallJS("login.ArcTermsOfServiceScreen.loadPlayStoreToS", country_code);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.ArcTermsOfServiceScreen.loadPlayStoreToS", country_code);
+ } else {
+ LOG(ERROR) << "Silently dropping MaybeLoadPlayStoreToS request.";
+ }
}
void ArcTermsOfServiceScreenHandler::OnCurrentScreenChanged(
@@ -112,7 +117,8 @@ void ArcTermsOfServiceScreenHandler::DeclareLocalizedValues(
builder->Add("arcTermsOfServiceScreenDescription",
IDS_ARC_OOBE_TERMS_DESCRIPTION);
builder->Add("arcTermsOfServiceLoading", IDS_ARC_OOBE_TERMS_LOADING);
- builder->Add("arcTermsOfServiceError", IDS_ARC_OOBE_TERMS_LOAD_ERROR);
+ 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",
IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT);
@@ -295,6 +301,7 @@ void ArcTermsOfServiceScreenHandler::Bind(ArcTermsOfServiceScreen* screen) {
}
void ArcTermsOfServiceScreenHandler::StartNetworkAndTimeZoneObserving() {
+ // TODO(crbug.com/1180291) - Clean up work. Fix this logic.
if (network_time_zone_observing_)
return;
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 49a38743bcf..d01b62f004d 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
@@ -9,10 +9,10 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/metrics/histogram_macros.h"
+#include "chrome/browser/ash/login/screens/assistant_optin_flow_screen.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
@@ -55,7 +55,7 @@ AssistantOptInFlowScreenHandler::AssistantOptInFlowScreenHandler(
}
AssistantOptInFlowScreenHandler::~AssistantOptInFlowScreenHandler() {
- if (voice_match_enrollment_started_)
+ if (assistant::AssistantSettings::Get() && voice_match_enrollment_started_)
StopSpeakerIdEnrollment();
if (ash::AssistantState::Get())
ash::AssistantState::Get()->RemoveObserver(this);
@@ -86,9 +86,10 @@ void AssistantOptInFlowScreenHandler::DeclareLocalizedValues(
IDS_ASSISTANT_SCREEN_CONTEXT_TITLE);
builder->Add("assistantScreenContextDesc", IDS_ASSISTANT_SCREEN_CONTEXT_DESC);
builder->Add("assistantVoiceMatchTitle", IDS_ASSISTANT_VOICE_MATCH_TITLE);
- builder->Add("assistantVoiceMatchMessage", IDS_ASSISTANT_VOICE_MATCH_MESSAGE);
- builder->Add("assistantVoiceMatchNoDspMessage",
- IDS_ASSISTANT_VOICE_MATCH_NO_DSP_MESSAGE);
+ builder->Add("assistantVoiceMatchMessage",
+ chromeos::IsHotwordDspAvailable() && !DeviceHasBattery()
+ ? IDS_ASSISTANT_VOICE_MATCH_MESSAGE
+ : IDS_ASSISTANT_VOICE_MATCH_NO_DSP_MESSAGE);
builder->Add("assistantVoiceMatchRecording",
IDS_ASSISTANT_VOICE_MATCH_RECORDING);
builder->Add("assistantVoiceMatchCompleted",
@@ -163,8 +164,6 @@ void AssistantOptInFlowScreenHandler::RegisterMessages() {
void AssistantOptInFlowScreenHandler::GetAdditionalParameters(
base::DictionaryValue* dict) {
- dict->SetBoolean("hotwordDspAvailable", chromeos::IsHotwordDspAvailable());
- dict->SetBoolean("deviceHasNoBattery", !DeviceHasBattery());
dict->SetBoolean("voiceMatchDisabled",
chromeos::assistant::features::IsVoiceMatchDisabled());
dict->SetBoolean("betterAssistantEnabled",
@@ -571,6 +570,9 @@ void AssistantOptInFlowScreenHandler::HandleVoiceMatchScreenUserAction(
assistant::AssistantSettings::Get()->StartSpeakerIdEnrollment(
flow_type_ == ash::FlowType::kSpeakerIdRetrain,
weak_factory_.GetWeakPtr());
+ } else if (action == kReloadRequested) {
+ if (voice_match_enrollment_started_)
+ StopSpeakerIdEnrollment();
}
}
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 619e5b9ab61..f4e9b63b798 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
@@ -7,7 +7,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen_view.h"
+#include "chrome/browser/ash/login/enrollment/auto_enrollment_check_screen_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc
index e102a083897..17a98b22107 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-#include "chrome/browser/chromeos/login/screens/base_screen.h"
+#include "chrome/browser/ash/login/screens/base_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc
index f74f1b1f364..9a750f5d195 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc
@@ -20,6 +20,7 @@ BaseWebUIHandler::~BaseWebUIHandler() = default;
void BaseWebUIHandler::InitializeBase() {
page_is_ready_ = true;
+ AllowJavascript();
Initialize();
}
@@ -60,6 +61,10 @@ OobeScreenId BaseWebUIHandler::GetCurrentScreen() const {
return oobe_ui->current_screen();
}
+void BaseWebUIHandler::OnJavascriptDisallowed() {
+ javascript_disallowed_ = true;
+}
+
void BaseWebUIHandler::InsertIntoList(std::vector<base::Value>*) {}
void BaseWebUIHandler::MaybeRecordIncomingEvent(
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 3d2db2a34e2..e9207e8d772 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
@@ -83,11 +83,20 @@ class BaseWebUIHandler : public content::WebUIMessageHandler {
}
// Make the call now if the WebUI is loaded.
- if (js_calls_container_->is_initialized())
+ if (js_calls_container_->is_initialized() && !javascript_disallowed_)
web_ui()->CallJavascriptFunctionUnsafe(
function_name, ::login::MakeValue(args).Clone()...);
}
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed
+ // If the JS container hasn't been initialized yet, it is safe to call JS
+ // because the call will be postponed until we receive a message from the
+ // renderer.
+ bool IsSafeToCallJavascript() const {
+ return (js_calls_container_ && !js_calls_container_->is_initialized()) ||
+ IsJavascriptAllowed();
+ }
+
// Register WebUI callbacks. The callbacks will be recorded if recording is
// enabled.
template <typename T>
@@ -130,6 +139,9 @@ class BaseWebUIHandler : public content::WebUIMessageHandler {
// Whether page is ready.
bool page_is_ready() const { return page_is_ready_; }
+ // content::WebUIMessageHandler
+ void OnJavascriptDisallowed() override;
+
private:
friend class OobeUI;
@@ -173,6 +185,12 @@ class BaseWebUIHandler : public content::WebUIMessageHandler {
// Keeps whether page is ready.
bool page_is_ready_ = false;
+ // When there isn't a RenderFrameHost, no JS calls should be made.
+ // This flag becomes true when the renderer is destroyed.
+ // TODO(crbug/1180291) - Remove this custom solution once OOBE's JS
+ // initialisation has been fixed.
+ bool javascript_disallowed_ = false;
+
JSCallsContainer* js_calls_container_ = nullptr; // non-owning pointers.
DISALLOW_COPY_AND_ASSIGN(BaseWebUIHandler);
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 3b98db408ab..ce6f701e5c2 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
@@ -6,6 +6,7 @@
#include <type_traits>
+#include "ash/constants/ash_features.h"
#include "ash/public/ash_interfaces.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/event_rewriter_controller.h"
@@ -17,17 +18,18 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
+#include "chrome/browser/ash/login/demo_mode/demo_session.h"
+#include "chrome/browser/ash/login/demo_mode/demo_setup_controller.h"
+#include "chrome/browser/ash/login/lock/screen_locker.h"
+#include "chrome/browser/ash/login/screens/reset_screen.h"
+#include "chrome/browser/ash/system/input_device_settings.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/login/configuration_keys.h"
-#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
-#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
#include "chrome/browser/chromeos/login/helper.h"
-#include "chrome/browser/chromeos/login/lock/screen_locker.h"
-#include "chrome/browser/chromeos/login/screens/reset_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
+#include "chrome/browser/chromeos/login/ui/oobe_dialog_size_utils.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
-#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h"
#include "chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h"
@@ -40,9 +42,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_constants.h"
-#include "chromeos/constants/chromeos_features.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "components/login/base_screen_handler_utils.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
@@ -124,7 +123,8 @@ void CoreOobeHandler::Initialize() {
version_info_updater_.StartUpdate(false);
#endif
UpdateKeyboardState();
- UpdateClientAreaSize();
+ UpdateClientAreaSize(
+ display::Screen::GetScreen()->GetPrimaryDisplay().size());
}
void CoreOobeHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
@@ -134,6 +134,8 @@ void CoreOobeHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
base::Value(DemoSetupController::IsDemoModeAllowed()));
dict->SetKey("showTechnologyBadge",
base::Value(!ash::features::IsSeparateNetworkIconsEnabled()));
+ dict->SetKey("newLayoutEnabled",
+ base::Value(features::IsNewOobeLayoutEnabled()));
}
void CoreOobeHandler::RegisterMessages() {
@@ -157,6 +159,7 @@ void CoreOobeHandler::RegisterMessages() {
AddCallback("hideOobeDialog", &CoreOobeHandler::HandleHideOobeDialog);
AddCallback("updateOobeUIState", &CoreOobeHandler::HandleUpdateOobeUIState);
+ AddCallback("enableShelfButtons", &CoreOobeHandler::HandleEnableShelfButtons);
}
void CoreOobeHandler::ShowSignInError(
@@ -173,28 +176,14 @@ void CoreOobeHandler::ShowDeviceResetScreen() {
LaunchResetScreen();
}
-void CoreOobeHandler::ShowEnableAdbSideloadingScreen() {
- DCHECK(LoginDisplayHost::default_host());
- LoginDisplayHost::default_host()->StartWizard(
- EnableAdbSideloadingScreenView::kScreenId);
-}
-
-void CoreOobeHandler::ShowSignInUI(const std::string& email) {
- CallJS("cr.ui.Oobe.showSigninUI", email);
+void CoreOobeHandler::FocusReturned(bool reverse) {
+ CallJS("cr.ui.Oobe.focusReturned", reverse);
}
void CoreOobeHandler::ResetSignInUI(bool force_online) {
CallJS("cr.ui.Oobe.resetSigninUI", force_online);
}
-void CoreOobeHandler::ClearUserPodPassword() {
- CallJS("cr.ui.Oobe.clearUserPodPassword");
-}
-
-void CoreOobeHandler::RefocusCurrentPod() {
- CallJS("cr.ui.Oobe.refocusCurrentPod");
-}
-
void CoreOobeHandler::ClearErrors() {
CallJS("cr.ui.Oobe.clearErrors");
}
@@ -205,7 +194,12 @@ void CoreOobeHandler::ReloadContent(const base::DictionaryValue& dictionary) {
void CoreOobeHandler::ReloadEulaContent(
const base::DictionaryValue& dictionary) {
- CallJS("cr.ui.Oobe.reloadEulaContent", dictionary);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("cr.ui.Oobe.reloadEulaContent", dictionary);
+ } else {
+ LOG(ERROR) << "Silently dropping ReloadEulaContent request.";
+ }
}
void CoreOobeHandler::SetVirtualKeyboardShown(bool shown) {
@@ -213,17 +207,45 @@ void CoreOobeHandler::SetVirtualKeyboardShown(bool shown) {
}
void CoreOobeHandler::SetClientAreaSize(int width, int height) {
- CallJS("cr.ui.Oobe.setClientAreaSize", width, height);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("cr.ui.Oobe.setClientAreaSize", width, height);
+ } else {
+ LOG(ERROR) << "Silently dropping SetClientAreaSize request.";
+ }
}
void CoreOobeHandler::SetShelfHeight(int height) {
- CallJS("cr.ui.Oobe.setShelfHeight", height);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("cr.ui.Oobe.setShelfHeight", height);
+ } else {
+ LOG(ERROR) << "Silently dropping SetShelfHeight request.";
+ }
+}
+
+void CoreOobeHandler::SetOrientation(bool is_horizontal) {
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("cr.ui.Oobe.setOrientation", is_horizontal);
+ } else {
+ LOG(ERROR) << "Silently dropping SetOrientation request.";
+ }
+}
+
+void CoreOobeHandler::SetDialogSize(int width, int height) {
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("cr.ui.Oobe.setDialogSize", width, height);
+ } else {
+ LOG(ERROR) << "Silently dropping SetDialogSize request.";
+ }
}
void CoreOobeHandler::HandleInitialized() {
VLOG(3) << "CoreOobeHandler::HandleInitialized";
- GetOobeUI()->InitializeHandlers();
AllowJavascript();
+ GetOobeUI()->InitializeHandlers();
}
void CoreOobeHandler::HandleUpdateCurrentScreen(
@@ -239,6 +261,11 @@ void CoreOobeHandler::HandleHideOobeDialog() {
LoginDisplayHost::default_host()->HideOobeDialog();
}
+void CoreOobeHandler::HandleEnableShelfButtons(bool enable) {
+ if (LoginDisplayHost::default_host())
+ LoginDisplayHost::default_host()->SetShelfButtonsEnabled(enable);
+}
+
void CoreOobeHandler::HandleSkipToLoginForTesting() {
WizardController* controller = WizardController::default_controller();
if (controller && controller->is_initialized())
@@ -319,7 +346,7 @@ void CoreOobeHandler::OnOSVersionLabelTextUpdated(
void CoreOobeHandler::OnEnterpriseInfoUpdated(const std::string& message_text,
const std::string& asset_id) {
- CallJS("cr.ui.Oobe.setEnterpriseInfo", message_text, asset_id);
+ // Not relevant in OOBE mode.
}
void CoreOobeHandler::OnDeviceInfoUpdated(const std::string& bluetooth_name) {
@@ -327,12 +354,17 @@ void CoreOobeHandler::OnDeviceInfoUpdated(const std::string& bluetooth_name) {
}
ui::EventSink* CoreOobeHandler::GetEventSink() {
- return ash::Shell::GetPrimaryRootWindow()->GetHost()->event_sink();
+ return ash::Shell::GetPrimaryRootWindow()->GetHost()->GetEventSink();
}
void CoreOobeHandler::UpdateLabel(const std::string& id,
const std::string& text) {
- CallJS("cr.ui.Oobe.setLabelText", id, text);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("cr.ui.Oobe.setLabelText", id, text);
+ } else {
+ LOG(ERROR) << "Silently dropping UpdateLabel request.";
+ }
}
void CoreOobeHandler::UpdateKeyboardState() {
@@ -349,11 +381,18 @@ void CoreOobeHandler::OnTabletModeEnded() {
CallJS("cr.ui.Oobe.setTabletModeState", false);
}
-void CoreOobeHandler::UpdateClientAreaSize() {
- const gfx::Size size =
- display::Screen::GetScreen()->GetPrimaryDisplay().size();
+void CoreOobeHandler::UpdateClientAreaSize(const gfx::Size& size) {
SetClientAreaSize(size.width(), size.height());
SetShelfHeight(ash::ShelfConfig::Get()->shelf_size());
+ if (features::IsNewOobeLayoutEnabled()) {
+ const gfx::Size display_size =
+ display::Screen::GetScreen()->GetPrimaryDisplay().size();
+ const bool is_horizontal = display_size.width() > display_size.height();
+ SetOrientation(is_horizontal);
+ const gfx::Size dialog_size = CalculateOobeDialogSize(
+ size, ash::ShelfConfig::Get()->shelf_size(), is_horizontal);
+ SetDialogSize(dialog_size.width(), dialog_size.height());
+ }
}
void CoreOobeHandler::SetDialogPaddingMode(
@@ -372,7 +411,12 @@ void CoreOobeHandler::SetDialogPaddingMode(
default:
NOTREACHED();
}
- CallJS("cr.ui.Oobe.setDialogPaddingMode", padding);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("cr.ui.Oobe.setDialogPaddingMode", padding);
+ } else {
+ LOG(ERROR) << "Silently dropping SetDialogPaddingMode request.";
+ }
}
void CoreOobeHandler::OnOobeConfigurationChanged() {
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 415a3e47301..922310b6bc9 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
@@ -54,10 +54,7 @@ class CoreOobeView {
const std::string& error_text,
const std::string& help_link_text,
HelpAppLauncher::HelpTopic help_topic_id) = 0;
- virtual void ShowSignInUI(const std::string& email) = 0;
virtual void ResetSignInUI(bool force_online) = 0;
- virtual void ClearUserPodPassword() = 0;
- virtual void RefocusCurrentPod() = 0;
virtual void ClearErrors() = 0;
virtual void ReloadContent(const base::DictionaryValue& dictionary) = 0;
virtual void ReloadEulaContent(const base::DictionaryValue& dictionary) = 0;
@@ -66,8 +63,11 @@ class CoreOobeView {
virtual void SetShelfHeight(int height) = 0;
virtual void SetDialogPaddingMode(DialogPaddingMode mode) = 0;
virtual void ShowDeviceResetScreen() = 0;
- virtual void ShowEnableAdbSideloadingScreen() = 0;
virtual void UpdateKeyboardState() = 0;
+ virtual void FocusReturned(bool reverse) = 0;
+ virtual void SetOrientation(bool is_horizontal) = 0;
+ virtual void SetDialogSize(int width, int height) = 0;
+ virtual void UpdateClientAreaSize(const gfx::Size& size) = 0;
};
// The core handler for Javascript messages related to the "oobe" view.
@@ -127,10 +127,7 @@ class CoreOobeHandler : public BaseWebUIHandler,
const std::string& error_text,
const std::string& help_link_text,
HelpAppLauncher::HelpTopic help_topic_id) override;
- void ShowSignInUI(const std::string& email) override;
void ResetSignInUI(bool force_online) override;
- void ClearUserPodPassword() override;
- void RefocusCurrentPod() override;
void ClearErrors() override;
void ReloadContent(const base::DictionaryValue& dictionary) override;
void ReloadEulaContent(const base::DictionaryValue& dictionary) override;
@@ -139,7 +136,11 @@ class CoreOobeHandler : public BaseWebUIHandler,
void SetShelfHeight(int height) override;
void SetDialogPaddingMode(CoreOobeView::DialogPaddingMode mode) override;
void ShowDeviceResetScreen() override;
- void ShowEnableAdbSideloadingScreen() override;
+ void FocusReturned(bool reverse) override;
+ void SetOrientation(bool is_horizontal) override;
+ void SetDialogSize(int width, int height) override;
+ // Updates client area size based on the primary screen size.
+ void UpdateClientAreaSize(const gfx::Size& size) override;
void UpdateKeyboardState() override;
@@ -152,6 +153,7 @@ class CoreOobeHandler : public BaseWebUIHandler,
// Handlers for JS WebUI messages.
void HandleHideOobeDialog();
+ void HandleEnableShelfButtons(bool enable);
void HandleInitialized();
void HandleUpdateCurrentScreen(const std::string& screen);
void HandleSkipToLoginForTesting();
@@ -183,9 +185,6 @@ class CoreOobeHandler : public BaseWebUIHandler,
// Updates label with specified id with specified text.
void UpdateLabel(const std::string& id, const std::string& text);
- // Updates client area size based on the primary screen size.
- void UpdateClientAreaSize();
-
// True if we should show OOBE instead of login.
bool show_oobe_ui_ = false;
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 3b050d09e06..1e3c16b8158 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
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.h"
+#include "ash/constants/ash_switches.h"
#include "ash/shell.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
@@ -17,7 +18,7 @@
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "chrome/common/chrome_paths.h"
-#include "chromeos/constants/chromeos_switches.h"
+#include "ui/display/display_switches.h"
#include "ui/snapshot/snapshot.h"
namespace chromeos {
@@ -39,6 +40,8 @@ void StoreScreenshot(const base::FilePath& screenshot_dir,
file_path, reinterpret_cast<const char*>(png_data->front()),
static_cast<int>(png_data->size()))) != png_data->size()) {
LOG(ERROR) << "Failed to save screenshot to " << file_path.value();
+ } else {
+ VLOG(1) << "Saved screenshot to " << file_path.value();
}
}
@@ -80,6 +83,10 @@ DebugOverlayHandler::DebugOverlayHandler(JSCallsContainer* js_calls_container)
}
base_dir = base_dir.Append("OOBE_Screenshots");
}
+
+ add_resolution_to_filename_ =
+ command_line->HasSwitch(::switches::kHostWindowBounds);
+
base::Time::Exploded now;
base::Time::Now().LocalExplode(&now);
std::string series_name =
@@ -118,6 +125,10 @@ void DebugOverlayHandler::HandleCaptureScreenshot(const std::string& name) {
if (root_windows.size() > 1) {
filename.append(base::StringPrintf("- Display %zu", screen));
}
+
+ if (add_resolution_to_filename_)
+ filename.append("_" + rect.size().ToString());
+
filename.append(".png");
ui::GrabWindowSnapshotAsyncPNG(
root_window, rect,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.h
index ca704fe34f6..362eac350d5 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/debug/debug_overlay_handler.h
@@ -31,6 +31,7 @@ class DebugOverlayHandler : public BaseWebUIHandler {
base::FilePath screenshot_dir_;
int screenshot_index_ = 0;
+ bool add_resolution_to_filename_ = false;
};
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc
index 515dad16e0e..fe6bb67ab93 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h"
+#include "chrome/browser/ash/login/screens/demo_preferences_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/demo_preferences_screen.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc
index 8dd97791667..191e9e3edae 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc
@@ -7,10 +7,9 @@
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ash/login/screens/demo_setup_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/demo_setup_screen.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/login/localized_values_builder.h"
namespace chromeos {
@@ -83,10 +82,6 @@ void DemoSetupScreenHandler::DeclareLocalizedValues(
void DemoSetupScreenHandler::GetAdditionalParameters(
base::DictionaryValue* parameters) {
- parameters->SetBoolKey(
- "showStepsInDemoModeSetup",
- base::FeatureList::IsEnabled(features::kShowStepsInDemoModeSetup));
-
parameters->SetPath("demoSetupSteps",
DemoSetupController::GetDemoSetupSteps());
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h
index e21cadb510f..7af6ffd8d52 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEMO_SETUP_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEMO_SETUP_SCREEN_HANDLER_H_
-#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
+#include "chrome/browser/ash/login/demo_mode/demo_setup_controller.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc
index b63e52d4391..4c411120c43 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h"
+#include "chrome/browser/ash/login/screens/device_disabled_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/device_disabled_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h
index ed647dea28b..20980294369 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.h
@@ -60,5 +60,10 @@ class DeviceDisabledScreenHandler : public DeviceDisabledScreenView,
} // namespace chromeos
+// TODO(https://crbug.com/1164001): remove when moved to ash.
+namespace ash {
+using ::chromeos::DeviceDisabledScreenView;
+}
+
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEVICE_DISABLED_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc
deleted file mode 100644
index f3d17c9f2a2..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc
+++ /dev/null
@@ -1,12 +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/login/discover/discover_handler.h"
-
-namespace chromeos {
-
-DiscoverHandler::DiscoverHandler(JSCallsContainer* js_calls_container)
- : BaseWebUIHandler(js_calls_container) {}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h
deleted file mode 100644
index b72962e2a1d..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h
+++ /dev/null
@@ -1,26 +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_LOGIN_DISCOVER_DISCOVER_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_HANDLER_H_
-
-#include <string>
-
-#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
-
-namespace chromeos {
-
-// Base class for Discover modules WebUI message handler.
-class DiscoverHandler : public BaseWebUIHandler {
- public:
- explicit DiscoverHandler(JSCallsContainer* js_calls_container);
- ~DiscoverHandler() override = default;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DiscoverHandler);
-};
-
-} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc
deleted file mode 100644
index aa28d650e14..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc
+++ /dev/null
@@ -1,68 +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/login/discover/discover_manager.h"
-
-#include <algorithm>
-
-#include "base/check_op.h"
-#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h"
-#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h"
-
-namespace chromeos {
-namespace {
-
-// Owned by ChromeBrowserMainPartsChromeos.
-DiscoverManager* g_discover_manager = nullptr;
-
-} // namespace
-
-DiscoverManager::DiscoverManager() {
- DCHECK(!g_discover_manager);
- g_discover_manager = this;
-
- CreateModules();
-}
-
-DiscoverManager::~DiscoverManager() {
- DCHECK_EQ(g_discover_manager, this);
- g_discover_manager = nullptr;
-}
-
-// static
-DiscoverManager* DiscoverManager::Get() {
- return g_discover_manager;
-}
-
-bool DiscoverManager::IsCompleted() const {
- // Returns true if all of the modules are completed.
- return std::all_of(modules_.begin(), modules_.end(),
- [](const auto& module_pair) {
- return module_pair.second->IsCompleted();
- });
-}
-
-void DiscoverManager::CreateModules() {
- modules_[DiscoverModulePinSetup::kModuleName] =
- std::make_unique<DiscoverModulePinSetup>();
-}
-
-std::vector<std::unique_ptr<DiscoverHandler>>
-DiscoverManager::CreateWebUIHandlers(
- JSCallsContainer* js_calls_container) const {
- std::vector<std::unique_ptr<DiscoverHandler>> handlers;
- for (const auto& module_pair : modules_) {
- handlers.emplace_back(
- module_pair.second->CreateWebUIHandler(js_calls_container));
- }
- return handlers;
-}
-
-DiscoverModule* DiscoverManager::GetModuleByName(
- const std::string& module_name) const {
- const auto it = modules_.find(module_name);
- return it == modules_.end() ? nullptr : it->second.get();
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h
deleted file mode 100644
index 8c5577c1aa5..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h
+++ /dev/null
@@ -1,60 +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_LOGIN_DISCOVER_DISCOVER_MANAGER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_MANAGER_H_
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-
-#include "base/callback.h"
-#include "base/macros.h"
-
-namespace chromeos {
-
-class DiscoverHandler;
-class DiscoverModule;
-class JSCallsContainer;
-
-class DiscoverManager {
- public:
- using ModulesMap =
- std::unordered_map<std::string, std::unique_ptr<DiscoverModule>>;
-
- DiscoverManager();
- ~DiscoverManager();
-
- // Returns object instance from platform_parts.
- static DiscoverManager* Get();
-
- // Returns true if there are no modules to be displayed.
- bool IsCompleted() const;
-
- // Returns vector of WebUI message handlers for visible modules.
- std::vector<std::unique_ptr<DiscoverHandler>> CreateWebUIHandlers(
- JSCallsContainer* js_calls_container) const;
-
- template <typename T>
- T* GetModule() {
- return static_cast<T*>(GetModuleByName(T::kModuleName));
- }
-
- const ModulesMap& get_modules() const { return modules_; }
-
- private:
- // Creates all needed modules.
- void CreateModules();
-
- // Returns module by name.
- DiscoverModule* GetModuleByName(const std::string& module_name) const;
-
- ModulesMap modules_;
-
- DISALLOW_COPY_AND_ASSIGN(DiscoverManager);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_MANAGER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_module.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_module.h
deleted file mode 100644
index 271ddd27ec6..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_module.h
+++ /dev/null
@@ -1,40 +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_LOGIN_DISCOVER_DISCOVER_MODULE_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_MODULE_H_
-
-#include <memory>
-#include <string>
-
-#include "base/macros.h"
-
-namespace chromeos {
-
-class DiscoverHandler;
-class JSCallsContainer;
-
-class DiscoverModule {
- public:
- DiscoverModule() = default;
-
- virtual ~DiscoverModule() = default;
-
- // Returns true if module is completed
- virtual bool IsCompleted() const = 0;
-
- // Creates and returns WebUI handler for the module.
- virtual std::unique_ptr<DiscoverHandler> CreateWebUIHandler(
- JSCallsContainer* js_calls_container) = 0;
-
- // Module is also expected to provide static method:
- // static const char* kModuleName;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DiscoverModule);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_MODULE_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc
deleted file mode 100644
index 380b5bf2b5d..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc
+++ /dev/null
@@ -1,115 +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/login/discover/discover_ui.h"
-
-#include "base/check_op.h"
-#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h"
-#include "chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-
-namespace chromeos {
-
-namespace {
-
-// Data to store a reference to DiscoverUI into WebContents.
-class DiscoverUIUserDataPointer : public base::SupportsUserData::Data {
- public:
- static DiscoverUI* Get(const content::WebContents* web_contents) {
- DiscoverUIUserDataPointer* data = static_cast<DiscoverUIUserDataPointer*>(
- web_contents->GetUserData(kKey));
- if (data)
- return data->ptr_;
-
- return nullptr;
- }
-
- static void Attach(DiscoverUI* discover_ui,
- content::WebContents* web_contents) {
- DCHECK(!Get(web_contents));
-
- web_contents->SetUserData(
- kKey, std::make_unique<DiscoverUIUserDataPointer>(discover_ui));
- }
-
- static void Detach(const DiscoverUI* discover_ui,
- content::WebContents* web_contents) {
-#if DCHECK_IS_ON()
- if (Get(web_contents))
- DCHECK_EQ(Get(web_contents), discover_ui);
-#else
- ANALYZER_ALLOW_UNUSED(discover_ui);
-#endif
-
- web_contents->RemoveUserData(kKey);
- }
-
- explicit DiscoverUIUserDataPointer(DiscoverUI* discover_ui)
- : ptr_(discover_ui) {}
-
- ~DiscoverUIUserDataPointer() override = default;
-
- private:
- DiscoverUI* ptr_ = nullptr;
-
- static const char kKey[];
-
- DISALLOW_COPY_AND_ASSIGN(DiscoverUIUserDataPointer);
-};
-
-const char DiscoverUIUserDataPointer::kKey[] = "DiscoverUIKey";
-} // anonymous namespace
-
-DiscoverUI::DiscoverUI() = default;
-
-DiscoverUI::~DiscoverUI() {
- if (web_ui_)
- DiscoverUIUserDataPointer::Detach(this, web_ui_->GetWebContents());
-}
-
-DiscoverUI* DiscoverUI::GetDiscoverUI(
- const content::WebContents* web_contents) {
- return DiscoverUIUserDataPointer::Get(web_contents);
-}
-
-void DiscoverUI::RegisterMessages(content::WebUI* web_ui) {
- DCHECK(!web_ui_);
- web_ui_ = web_ui;
-
- DiscoverUIUserDataPointer::Attach(this, web_ui->GetWebContents());
-
- std::vector<std::unique_ptr<DiscoverHandler>> handlers =
- DiscoverManager::Get()->CreateWebUIHandlers(&js_calls_container_);
- for (auto& handler : handlers) {
- handlers_.push_back(handler.get());
- web_ui->AddMessageHandler(std::move(handler));
- }
- initialized_ = true;
-}
-
-void DiscoverUI::GetAdditionalParameters(base::DictionaryValue* dict) {
- CHECK(initialized_);
- for (DiscoverHandler* handler : handlers_) {
- handler->GetLocalizedStrings(dict);
- }
-}
-
-void DiscoverUI::Initialize() {
- for (Observer& observer : observers_)
- observer.OnInitialized();
- js_calls_container_.ExecuteDeferredJSCalls(web_ui_);
-}
-
-void DiscoverUI::Show() {}
-
-void DiscoverUI::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void DiscoverUI::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.h
deleted file mode 100644
index b290a6721d4..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.h
+++ /dev/null
@@ -1,81 +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_LOGIN_DISCOVER_DISCOVER_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_UI_H_
-
-#include <vector>
-
-#include "base/macros.h"
-#include "base/observer_list.h"
-#include "base/observer_list_types.h"
-#include "base/supports_user_data.h"
-#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
-
-namespace base {
-class DictionaryValue;
-}
-
-namespace content {
-class WebUI;
-class WebContents;
-}
-
-namespace chromeos {
-
-class DiscoverHandler;
-
-class DiscoverUI {
- public:
- class Observer : public base::CheckedObserver {
- public:
- // This is called when Discover UI becomes initialized.
- // (I.e. when JS reports "initialized".)
- virtual void OnInitialized() {}
- };
-
- DiscoverUI();
-
- ~DiscoverUI();
-
- // Pointer to DiscoverUI is attached to WebContents. This method returns
- // stored pointer, or nullptr if no data was found.
- static DiscoverUI* GetDiscoverUI(const content::WebContents* web_contents);
-
- // Register WebUI handlers
- void RegisterMessages(content::WebUI* web_ui);
-
- // Returns localized strings and data.
- void GetAdditionalParameters(base::DictionaryValue* dict);
-
- // This is called when Web UI reports "initialized" state.
- void Initialize();
-
- void Show();
-
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
-
- const content::WebUI* web_ui() const { return web_ui_; }
-
- private:
- bool initialized_ = false;
-
- content::WebUI* web_ui_ = nullptr;
-
- // Non-owninng.
- // Handlers are owned by WebUI, but we need to keep this list to be able to
- // to refresh string resources.
- std::vector<DiscoverHandler*> handlers_;
-
- base::ObserverList<Observer> observers_;
-
- JSCallsContainer js_calls_container_;
-
- DISALLOW_COPY_AND_ASSIGN(DiscoverUI);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc
deleted file mode 100644
index c6fce1fdcd0..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc
+++ /dev/null
@@ -1,163 +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/login/discover/modules/discover_module_pin_setup.h"
-
-#include <vector>
-
-#include "base/bind.h"
-#include "base/i18n/number_formatting.h"
-#include "base/values.h"
-#include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h"
-#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h"
-#include "chrome/grit/browser_resources.h"
-#include "chrome/grit/generated_resources.h"
-#include "components/login/localized_values_builder.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-
-namespace chromeos {
-
-namespace {
-
-class DiscoverModulePinSetupHandler : public DiscoverHandler {
- public:
- DiscoverModulePinSetupHandler(base::WeakPtr<DiscoverModulePinSetup> module,
- JSCallsContainer* js_calls_container);
- ~DiscoverModulePinSetupHandler() override = default;
-
- // BaseWebUIHandler:
- void DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) override;
- void Initialize() override;
- void RegisterMessages() override;
-
- private:
- // Message handlers.
- void HandleGetUserPassword(const std::string& callbackId);
- void HandleGetHasLoginSupport(const std::string& callbackId);
-
- // quick_unlock::PinBackend::HasLoginSupport callback.
- void OnPinLoginAvailable(const std::string& callbackId, bool is_available);
-
- base::WeakPtr<DiscoverModulePinSetup> module_;
-
- base::WeakPtrFactory<DiscoverModulePinSetupHandler> weak_factory_{this};
- DISALLOW_COPY_AND_ASSIGN(DiscoverModulePinSetupHandler);
-};
-
-DiscoverModulePinSetupHandler::DiscoverModulePinSetupHandler(
- base::WeakPtr<DiscoverModulePinSetup> module,
- JSCallsContainer* js_calls_container)
- : DiscoverHandler(js_calls_container), module_(module) {}
-
-void DiscoverModulePinSetupHandler::DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) {
- builder->Add("discoverPinSetup", IDS_DISCOVER_PIN_SETUP);
-
- builder->Add("back", IDS_EULA_BACK_BUTTON);
- builder->Add("next", IDS_EULA_NEXT_BUTTON);
- builder->Add("discoverPinSetupDone", IDS_DISCOVER_PIN_SETUP_DONE);
-
- builder->Add("discoverPinSetupTitle1", IDS_DISCOVER_PIN_SETUP_TITLE1);
- builder->Add("discoverPinSetupSubtitle1", IDS_DISCOVER_PIN_SETUP_SUBTITLE1);
- builder->Add("discoverPinSetupSkip", IDS_DISCOVER_PIN_SETUP_SKIP);
- builder->Add("discoverPinSetupTitle2", IDS_DISCOVER_PIN_SETUP_TITLE2);
- builder->Add("discoverPinSetupTitle3", IDS_DISCOVER_PIN_SETUP_TITLE3);
- builder->Add("discoverPinSetupSubtitle3NoLogin",
- IDS_DISCOVER_PIN_SETUP_SUBTITLE3_NO_LOGIN);
- builder->Add("discoverPinSetupSubtitle3WithLogin",
- IDS_DISCOVER_PIN_SETUP_SUBTITLE3_WITH_LOGIN);
- builder->Add("discoverPinSetupPasswordTitle",
- IDS_DISCOVER_PIN_SETUP_PASSWORD_TITLE);
- builder->Add("discoverPinSetupPasswordSubTitle",
- IDS_DISCOVER_PIN_SETUP_PASSWORD_SUBTITLE);
-
- builder->Add("passwordPromptInvalidPassword",
- IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_INVALID_PASSWORD);
- builder->Add("passwordPromptPasswordLabel",
- IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_PASSWORD_LABEL);
-
- // Format numbers to be used on the pin keyboard.
- for (int j = 0; j <= 9; j++) {
- builder->Add("pinKeyboard" + base::NumberToString(j),
- base::FormatNumber(int64_t{j}));
- }
- builder->Add("pinKeyboardPlaceholderPin", IDS_PIN_KEYBOARD_HINT_TEXT_PIN);
- builder->Add("pinKeyboardPlaceholderPinPassword",
- IDS_PIN_KEYBOARD_HINT_TEXT_PIN_PASSWORD);
- builder->Add("pinKeyboardDeleteAccessibleName",
- IDS_PIN_KEYBOARD_DELETE_ACCESSIBLE_NAME);
- builder->Add("configurePinMismatched",
- IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_MISMATCHED);
- builder->Add("configurePinTooShort",
- IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_TOO_SHORT);
- builder->Add("configurePinTooLong",
- IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_TOO_LONG);
- builder->Add("configurePinWeakPin",
- IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_WEAK_PIN);
-}
-
-void DiscoverModulePinSetupHandler::Initialize() {}
-
-void DiscoverModulePinSetupHandler::RegisterMessages() {
- AddCallback("discover.pinSetup.getUserPassword",
- &DiscoverModulePinSetupHandler::HandleGetUserPassword);
- AddCallback("discover.pinSetup.getHasLoginSupport",
- &DiscoverModulePinSetupHandler::HandleGetHasLoginSupport);
-}
-
-void DiscoverModulePinSetupHandler::HandleGetUserPassword(
- const std::string& callbackId) {
- CallJS("window.discoverReturn", callbackId,
- module_->ConsumePrimaryUserPassword());
- return;
-}
-
-void DiscoverModulePinSetupHandler::OnPinLoginAvailable(
- const std::string& callbackId,
- bool is_available) {
- CallJS("window.discoverReturn", callbackId, is_available);
-}
-
-void DiscoverModulePinSetupHandler::HandleGetHasLoginSupport(
- const std::string& callbackId) {
- chromeos::quick_unlock::PinBackend::GetInstance()->HasLoginSupport(
- base::BindOnce(&DiscoverModulePinSetupHandler::OnPinLoginAvailable,
- weak_factory_.GetWeakPtr(), callbackId));
-}
-
-} // anonymous namespace
-
-/* ***************************************************************** */
-/* Discover PinSetup module implementation below. */
-
-const char DiscoverModulePinSetup::kModuleName[] = "pinSetup";
-
-DiscoverModulePinSetup::DiscoverModulePinSetup() {}
-
-DiscoverModulePinSetup::~DiscoverModulePinSetup() = default;
-
-bool DiscoverModulePinSetup::IsCompleted() const {
- return false;
-}
-
-std::unique_ptr<DiscoverHandler> DiscoverModulePinSetup::CreateWebUIHandler(
- JSCallsContainer* js_calls_container) {
- return std::make_unique<DiscoverModulePinSetupHandler>(
- weak_ptr_factory_.GetWeakPtr(), js_calls_container);
-}
-
-std::string DiscoverModulePinSetup::ConsumePrimaryUserPassword() {
- std::string result;
- std::swap(primary_user_password_, result);
- return result;
-}
-
-void DiscoverModulePinSetup::SetPrimaryUserPassword(
- const std::string& password) {
- primary_user_password_ = password;
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h
deleted file mode 100644
index b27f8a5fa4f..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h
+++ /dev/null
@@ -1,44 +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_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_PIN_SETUP_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_PIN_SETUP_H_
-
-#include <memory>
-
-#include "base/containers/flat_map.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/ui/webui/chromeos/login/discover/discover_module.h"
-
-namespace chromeos {
-
-class DiscoverModulePinSetup : public DiscoverModule {
- public:
- // Module name.
- static const char kModuleName[];
-
- DiscoverModulePinSetup();
- ~DiscoverModulePinSetup() override;
-
- // Returns primary user password, or empty string if not known.
- // Password is kept for newly created user only, and is returned only once.
- // (Empty string will be returned for subsequent calls.)
- std::string ConsumePrimaryUserPassword();
- void SetPrimaryUserPassword(const std::string& password);
-
- // DiscoverModule:
- bool IsCompleted() const override;
- std::unique_ptr<DiscoverHandler> CreateWebUIHandler(
- JSCallsContainer* js_calls_container) override;
-
- private:
- std::string primary_user_password_;
-
- base::WeakPtrFactory<DiscoverModulePinSetup> weak_ptr_factory_{this};
- DISALLOW_COPY_AND_ASSIGN(DiscoverModulePinSetup);
-};
-
-} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_PIN_SETUP_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc
index 0cec0bbd929..e03cabd8733 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enable_adb_sideloading_screen_handler.cc
@@ -6,8 +6,8 @@
#include <string>
+#include "chrome/browser/ash/login/screens/enable_adb_sideloading_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/enable_adb_sideloading_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
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 82683984635..6b628be7f05 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
@@ -6,29 +6,15 @@
#include <string>
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/values.h"
+#include "chrome/browser/ash/login/screens/enable_debugging_screen.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/enable_debugging_screen.h"
-#include "chrome/browser/chromeos/login/ui/login_display_host.h"
-#include "chrome/browser/chromeos/login/ui/login_web_dialog.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
-#include "chromeos/dbus/cryptohome/cryptohome_client.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
-#include "chromeos/dbus/power/power_manager_client.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_registry_simple.h"
-#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
@@ -36,42 +22,30 @@ constexpr StaticOobeScreenId EnableDebuggingScreenView::kScreenId;
EnableDebuggingScreenHandler::EnableDebuggingScreenHandler(
JSCallsContainer* js_calls_container)
- : BaseScreenHandler(kScreenId, js_calls_container) {}
+ : BaseScreenHandler(kScreenId, js_calls_container) {
+ set_user_acted_method_path("login.EnableDebuggingScreen.userActed");
+}
EnableDebuggingScreenHandler::~EnableDebuggingScreenHandler() {
if (screen_)
screen_->OnViewDestroyed(this);
}
-void EnableDebuggingScreenHandler::ShowWithParams() {
- ShowScreen(kScreenId);
-
- UpdateUIState(UI_STATE_WAIT);
-
- DVLOG(1) << "Showing enable debugging screen.";
-
- // Wait for cryptohomed before checking debugd. See http://crbug.com/440506.
- chromeos::CryptohomeClient* client = chromeos::CryptohomeClient::Get();
- client->WaitForServiceToBeAvailable(base::BindOnce(
- &EnableDebuggingScreenHandler::OnCryptohomeDaemonAvailabilityChecked,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
void EnableDebuggingScreenHandler::Show() {
if (!page_is_ready()) {
show_on_init_ = true;
return;
}
- ShowWithParams();
+ DVLOG(1) << "Showing enable debugging screen.";
+ ShowScreen(kScreenId);
}
-void EnableDebuggingScreenHandler::Hide() {
- weak_ptr_factory_.InvalidateWeakPtrs();
-}
+void EnableDebuggingScreenHandler::Hide() {}
void EnableDebuggingScreenHandler::SetDelegate(EnableDebuggingScreen* screen) {
screen_ = screen;
+ BaseScreenHandler::SetBaseScreen(screen_);
if (page_is_ready())
Initialize();
}
@@ -94,8 +68,6 @@ void EnableDebuggingScreenHandler::DeclareLocalizedValues(
IDS_ENABLE_DEBUGGING_LEARN_MORE);
builder->Add("enableDebuggingSetupMessage",
IDS_ENABLE_DEBUGGING_SETUP_MESSAGE);
- builder->Add("enableDebuggingWaitMessage",
- IDS_ENABLE_DEBUGGING_WAIT_MESSAGE);
builder->AddF("enableDebuggingWarningTitle",
IDS_ENABLE_DEBUGGING_SCREEN_WARNING_MSG,
IDS_SHORT_PRODUCT_NAME);
@@ -131,157 +103,18 @@ void EnableDebuggingScreenHandler::Initialize() {
}
void EnableDebuggingScreenHandler::RegisterMessages() {
- AddCallback("enableDebuggingOnCancel",
- &EnableDebuggingScreenHandler::HandleOnCancel);
- AddCallback("enableDebuggingOnDone",
- &EnableDebuggingScreenHandler::HandleOnDone);
- AddCallback("enableDebuggingOnLearnMore",
- &EnableDebuggingScreenHandler::HandleOnLearnMore);
- AddCallback("enableDebuggingOnRemoveRootFSProtection",
- &EnableDebuggingScreenHandler::HandleOnRemoveRootFSProtection);
+ BaseScreenHandler::RegisterMessages();
AddCallback("enableDebuggingOnSetup",
&EnableDebuggingScreenHandler::HandleOnSetup);
}
-void EnableDebuggingScreenHandler::HandleOnCancel() {
- if (screen_)
- screen_->OnExit(false);
-}
-
-void EnableDebuggingScreenHandler::HandleOnDone() {
- if (screen_)
- screen_->OnExit(true);
-}
-
-void EnableDebuggingScreenHandler::HandleOnRemoveRootFSProtection() {
- UpdateUIState(UI_STATE_WAIT);
- chromeos::DebugDaemonClient* client =
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
- client->RemoveRootfsVerification(
- base::BindOnce(&EnableDebuggingScreenHandler::OnRemoveRootfsVerification,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
void EnableDebuggingScreenHandler::HandleOnSetup(
const std::string& password) {
- UpdateUIState(UI_STATE_WAIT);
- chromeos::DebugDaemonClient* client =
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
- client->EnableDebuggingFeatures(
- password,
- base::BindOnce(&EnableDebuggingScreenHandler::OnEnableDebuggingFeatures,
- weak_ptr_factory_.GetWeakPtr()));
+ screen_->HandleSetup(password);
}
-void EnableDebuggingScreenHandler::OnCryptohomeDaemonAvailabilityChecked(
- bool service_is_available) {
- DVLOG(1) << "Enable-debugging-screen: cryptohomed availability="
- << service_is_available;
- if (!service_is_available) {
- LOG(ERROR) << "Crypthomed is not available.";
- UpdateUIState(UI_STATE_ERROR);
- return;
- }
-
- chromeos::DebugDaemonClient* client =
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
- client->WaitForServiceToBeAvailable(base::BindOnce(
- &EnableDebuggingScreenHandler::OnDebugDaemonServiceAvailabilityChecked,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void EnableDebuggingScreenHandler::OnDebugDaemonServiceAvailabilityChecked(
- bool service_is_available) {
- DVLOG(1) << "Enable-debugging-screen: debugd availability="
- << service_is_available;
- if (!service_is_available) {
- LOG(ERROR) << "Debug daemon is not available.";
- UpdateUIState(UI_STATE_ERROR);
- return;
- }
-
- // Check the status of debugging features.
- chromeos::DebugDaemonClient* client =
- chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
- client->QueryDebuggingFeatures(
- base::BindOnce(&EnableDebuggingScreenHandler::OnQueryDebuggingFeatures,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-// Removes rootfs verification, add flag to start with enable debugging features
-// screen and reboots the machine.
-void EnableDebuggingScreenHandler::OnRemoveRootfsVerification(bool success) {
- if (!success) {
- UpdateUIState(UI_STATE_ERROR);
- return;
- }
-
- PrefService* prefs = g_browser_process->local_state();
- prefs->SetBoolean(prefs::kDebuggingFeaturesRequested, true);
- prefs->CommitPendingWrite();
- chromeos::PowerManagerClient::Get()->RequestRestart(
- power_manager::REQUEST_RESTART_OTHER,
- "login debugging screen removing rootfs verification");
-}
-
-void EnableDebuggingScreenHandler::OnEnableDebuggingFeatures(bool success) {
- if (!success) {
- UpdateUIState(UI_STATE_ERROR);
- return;
- }
-
- UpdateUIState(UI_STATE_DONE);
-}
-
-void EnableDebuggingScreenHandler::OnQueryDebuggingFeatures(bool success,
- int features_flag) {
- DVLOG(1) << "Enable-debugging-screen: OnQueryDebuggingFeatures"
- << ", success=" << success
- << ", features=" << features_flag;
- if (!success ||
- features_flag == debugd::DevFeatureFlag::DEV_FEATURES_DISABLED) {
- UpdateUIState(UI_STATE_ERROR);
- return;
- }
-
- if ((features_flag &
- debugd::DevFeatureFlag::DEV_FEATURE_ROOTFS_VERIFICATION_REMOVED) == 0) {
- UpdateUIState(UI_STATE_REMOVE_PROTECTION);
- return;
- }
-
- if ((features_flag & DebugDaemonClient::DEV_FEATURE_ALL_ENABLED) !=
- DebugDaemonClient::DEV_FEATURE_ALL_ENABLED) {
- UpdateUIState(UI_STATE_SETUP);
- } else {
- UpdateUIState(UI_STATE_DONE);
- }
-}
-
-void EnableDebuggingScreenHandler::UpdateUIState(
- EnableDebuggingScreenHandler::UIState state) {
- if (state == UI_STATE_SETUP ||
- state == UI_STATE_ERROR ||
- state == UI_STATE_DONE) {
- PrefService* prefs = g_browser_process->local_state();
- prefs->ClearPref(prefs::kDebuggingFeaturesRequested);
- prefs->CommitPendingWrite();
- }
-
+void EnableDebuggingScreenHandler::UpdateUIState(UIState state) {
CallJS("login.EnableDebuggingScreen.updateState", static_cast<int>(state));
}
-void EnableDebuggingScreenHandler::HandleOnLearnMore() {
- VLOG(1) << "Trying to view the help article about debugging features.";
- const std::string help_content =
- l10n_util::GetStringUTF8(IDS_ENABLE_DEBUGGING_HELP);
- const GURL data_url = GURL("data:text/html;charset=utf-8," + help_content);
-
- LoginWebDialog* dialog =
- new LoginWebDialog(Profile::FromWebUI(web_ui()), NULL,
- LoginDisplayHost::default_host()->GetNativeWindow(),
- base::string16(), data_url);
- dialog->Show();
-}
-
} // 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 88dfc9a0a19..3da031fd71c 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
@@ -8,8 +8,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
class PrefRegistrySimple;
@@ -24,11 +22,20 @@ class EnableDebuggingScreenView {
public:
constexpr static StaticOobeScreenId kScreenId{"debugging"};
+ enum UIState {
+ UI_STATE_ERROR = -1,
+ UI_STATE_REMOVE_PROTECTION = 1,
+ UI_STATE_SETUP = 2,
+ UI_STATE_WAIT = 3,
+ UI_STATE_DONE = 4,
+ };
+
virtual ~EnableDebuggingScreenView() {}
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void SetDelegate(EnableDebuggingScreen* screen) = 0;
+ virtual void UpdateUIState(UIState state) = 0;
};
// WebUI implementation of EnableDebuggingScreenView.
@@ -44,6 +51,7 @@ class EnableDebuggingScreenHandler : public EnableDebuggingScreenView,
void Show() override;
void Hide() override;
void SetDelegate(EnableDebuggingScreen* screen) override;
+ void UpdateUIState(UIState state) override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
@@ -57,48 +65,14 @@ class EnableDebuggingScreenHandler : public EnableDebuggingScreenView,
static void RegisterPrefs(PrefRegistrySimple* registry);
private:
- enum UIState {
- UI_STATE_ERROR = -1,
- UI_STATE_REMOVE_PROTECTION = 1,
- UI_STATE_SETUP = 2,
- UI_STATE_WAIT = 3,
- UI_STATE_DONE = 4,
- };
-
// JS messages handlers.
- void HandleOnCancel();
- void HandleOnDone();
- void HandleOnLearnMore();
- void HandleOnRemoveRootFSProtection();
void HandleOnSetup(const std::string& password);
- void ShowWithParams();
-
- // Callback for CryptohomeClient::WaitForServiceToBeAvailable
- void OnCryptohomeDaemonAvailabilityChecked(bool service_is_available);
-
- // Callback for DebugDaemonClient::WaitForServiceToBeAvailable
- void OnDebugDaemonServiceAvailabilityChecked(bool service_is_available);
-
- // Callback for DebugDaemonClient::EnableDebuggingFeatures().
- void OnEnableDebuggingFeatures(bool success);
-
- // Callback for DebugDaemonClient::QueryDebuggingFeatures().
- void OnQueryDebuggingFeatures(bool success, int features_flag);
-
- // Callback for DebugDaemonClient::RemoveRootfsVerification().
- void OnRemoveRootfsVerification(bool success);
-
- // Updates UI state.
- void UpdateUIState(UIState state);
-
EnableDebuggingScreen* screen_ = nullptr;
// Keeps whether screen should be shown right after initialization.
bool show_on_init_ = false;
- base::WeakPtrFactory<EnableDebuggingScreenHandler> weak_ptr_factory_{this};
-
DISALLOW_COPY_AND_ASSIGN(EnableDebuggingScreenHandler);
};
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 3bc79cc51ea..3dfc503a3c5 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
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h"
#include "base/system/sys_info.h"
-#include "chrome/browser/chromeos/login/screens/encryption_migration_screen.h"
+#include "chrome/browser/ash/login/screens/encryption_migration_screen.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
#include "ui/base/text/bytes_formatting.h"
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 dfefea5c6c1..46cb7912bd1 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
@@ -16,13 +16,13 @@
#include "base/metrics/histogram_functions.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "chrome/browser/ash/login/screens/network_error.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h"
#include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/network_error.h"
#include "chrome/browser/chromeos/login/signin_partition_manager.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
@@ -386,6 +386,10 @@ void EnrollmentScreenHandler::ShowOtherError(
NOTREACHED();
}
+void EnrollmentScreenHandler::Shutdown() {
+ shutdown_ = true;
+}
+
void EnrollmentScreenHandler::ShowEnrollmentStatus(
policy::EnrollmentStatus status) {
switch (status.status()) {
@@ -846,7 +850,11 @@ void EnrollmentScreenHandler::OnGetCookiesForCompleteLogin(
void EnrollmentScreenHandler::OnCookieWaitTimeout() {
LOG(ERROR) << "Timeout waiting for OAuth cookie";
oauth_code_waiter_.reset();
- ShowError(IDS_LOGIN_FATAL_ERROR_NO_AUTH_TOKEN, true);
+
+ // If enrollment ends and the browser is being restarted, the renderers are
+ // killed so we can not talk to them anymore.
+ if (!shutdown_)
+ ShowError(IDS_LOGIN_FATAL_ERROR_NO_AUTH_TOKEN, true);
}
void EnrollmentScreenHandler::HandleAdCompleteLogin(
@@ -928,6 +936,11 @@ void EnrollmentScreenHandler::DoShow() {
void EnrollmentScreenHandler::DoShowWithPartition(
const std::string& partition_name) {
+ // If enrollment ends and the browser is being restarted, the renderers are
+ // killed so we can not talk to them anymore.
+ if (shutdown_)
+ return;
+
base::DictionaryValue screen_data;
screen_data.SetString("webviewPartitionName", partition_name);
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 9a97069d80a..69af212b686 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
@@ -10,9 +10,9 @@
#include <vector>
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/enrollment/enrollment_screen_view.h"
-#include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper.h"
-#include "chrome/browser/chromeos/login/screens/error_screen.h"
+#include "chrome/browser/ash/login/enrollment/enrollment_screen_view.h"
+#include "chrome/browser/ash/login/enrollment/enterprise_enrollment_helper.h"
+#include "chrome/browser/ash/login/screens/error_screen.h"
#include "chrome/browser/chromeos/policy/enrollment_config.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
@@ -88,6 +88,7 @@ class EnrollmentScreenHandler
void ShowEnrollmentStatus(policy::EnrollmentStatus status) override;
void ShowOtherError(
EnterpriseEnrollmentHelper::OtherError error_code) override;
+ void Shutdown() override;
// Implements BaseScreenHandler:
void Initialize() override;
@@ -180,6 +181,10 @@ class EnrollmentScreenHandler
// True when signin screen step is shown.
bool observe_network_failure_ = false;
+ // Set true when chrome is being restarted to pick up enrollment changes. The
+ // renderer processes will be destroyed and can no longer be talked to.
+ bool shutdown_ = false;
+
// Network state informer used to keep signin screen up.
scoped_refptr<NetworkStateInformer> network_state_informer_;
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 e25304e547a..2afa803be73 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
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "base/time/time.h"
-#include "chrome/browser/chromeos/login/screens/error_screen.h"
+#include "chrome/browser/ash/login/screens/error_screen.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
@@ -61,38 +61,87 @@ void ErrorScreenHandler::ShowOobeScreen(OobeScreenId screen) {
void ErrorScreenHandler::SetErrorStateCode(
NetworkError::ErrorState error_state) {
- CallJS("login.ErrorMessageScreen.setErrorState",
- static_cast<int>(error_state));
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.ErrorMessageScreen.setErrorState",
+ static_cast<int>(error_state));
+ } else {
+ LOG(ERROR) << "Silently dropping SetErrorStateNetwork request.";
+ }
}
void ErrorScreenHandler::SetErrorStateNetwork(const std::string& network_name) {
- CallJS("login.ErrorMessageScreen.setErrorStateNetwork", network_name);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.ErrorMessageScreen.setErrorStateNetwork", network_name);
+ } else {
+ LOG(ERROR) << "Silently dropping SetErrorStateNetwork request.";
+ }
}
void ErrorScreenHandler::SetGuestSigninAllowed(bool value) {
- CallJS("login.ErrorMessageScreen.allowGuestSignin", value);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.ErrorMessageScreen.allowGuestSignin", value);
+ } else {
+ LOG(ERROR) << "Silently dropping SetGuestSigninAllowed request.";
+ }
}
void ErrorScreenHandler::SetOfflineSigninAllowed(bool value) {
- CallJS("login.ErrorMessageScreen.allowOfflineLogin", value);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.ErrorMessageScreen.allowOfflineLogin", value);
+ } else {
+ LOG(ERROR) << "Silently dropping SetOfflineSigninAllowed request.";
+ }
}
void ErrorScreenHandler::SetShowConnectingIndicator(bool value) {
- CallJS("login.ErrorMessageScreen.showConnectingIndicator", value);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.ErrorMessageScreen.showConnectingIndicator", value);
+ } else {
+ LOG(ERROR) << "Silently dropping SetShowConnectingIndicator request.";
+ }
}
void ErrorScreenHandler::SetIsPersistentError(bool is_persistent) {
- CallJS("login.ErrorMessageScreen.setIsPersistentError", is_persistent);
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.ErrorMessageScreen.setIsPersistentError", is_persistent);
+ } else {
+ LOG(ERROR) << "Silently dropping SetIsPersistentError request.";
+ }
}
void ErrorScreenHandler::SetUIState(NetworkError::UIState ui_state) {
- CallJS("login.ErrorMessageScreen.setUIState", static_cast<int>(ui_state));
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.ErrorMessageScreen.setUIState", static_cast<int>(ui_state));
+ } else {
+ LOG(ERROR) << "Silently dropping SetUIState request.";
+ }
}
-void ErrorScreenHandler::RegisterMessages() {
- AddCallback("hideCaptivePortal",
- &ErrorScreenHandler::HandleHideCaptivePortal);
- BaseScreenHandler::RegisterMessages();
+// TODO (crbug.com/1168114): We need to handle that fully in C++ once
+// all error screen logic is migrated to Screen object.
+void ErrorScreenHandler::OnCancelButtonClicked() {
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("cr.ui.Oobe.showUserPods");
+ } else {
+ LOG(ERROR) << "Silently dropping OnCancelButtonClicked request.";
+ }
+}
+
+void ErrorScreenHandler::OnReloadGaiaClicked() {
+ // TODO(crbug.com/1180291) - Remove once OOBE JS calls are fixed.
+ if (IsSafeToCallJavascript()) {
+ CallJS("login.GaiaSigninScreen.doReload");
+ } else {
+ LOG(ERROR) << "Silently dropping OnReloadGaiaClicked request.";
+ }
}
void ErrorScreenHandler::DeclareLocalizedValues(
@@ -149,9 +198,4 @@ void ErrorScreenHandler::Initialize() {
}
}
-void ErrorScreenHandler::HandleHideCaptivePortal() {
- if (screen_)
- screen_->HideCaptivePortal();
-}
-
} // 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 9b6e2f3b353..6dff639f7bd 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
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ERROR_SCREEN_HANDLER_H_
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/screens/error_screen.h"
+#include "chrome/browser/ash/login/screens/error_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
@@ -56,6 +56,12 @@ class ErrorScreenView {
// Sets current UI state of the screen.
virtual void SetUIState(NetworkError::UIState ui_state) = 0;
+
+ // Returns to user pods screen.
+ virtual void OnCancelButtonClicked() = 0;
+
+ // Reloads gaia.
+ virtual void OnReloadGaiaClicked() = 0;
};
// A class that handles the WebUI hooks in error screen.
@@ -80,9 +86,8 @@ class ErrorScreenHandler : public BaseScreenHandler, public ErrorScreenView {
void SetShowConnectingIndicator(bool value) override;
void SetIsPersistentError(bool is_persistent) override;
void SetUIState(NetworkError::UIState ui_state) override;
-
- // WebUIMessageHandler:
- void RegisterMessages() override;
+ void OnCancelButtonClicked() override;
+ void OnReloadGaiaClicked() override;
// BaseScreenHandler:
void DeclareLocalizedValues(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc
index 75bc4b30919..979f1f969a6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc
@@ -7,21 +7,21 @@
#include <memory>
#include <string>
+#include "ash/constants/ash_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/strings/stringprintf.h"
+#include "chrome/browser/ash/login/screens/eula_screen.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/eula_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "components/login/localized_values_builder.h"
#include "components/strings/grit/components_strings.h"
#include "rlz/buildflags/buildflags.h"
@@ -139,10 +139,6 @@ void EulaScreenHandler::Initialize() {
}
}
-void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) {
- CallJS("login.EulaScreen.showSecuritySettingsDialog");
-}
-
void EulaScreenHandler::ShowStatsUsageLearnMore() {
if (!help_app_.get())
help_app_ = new HelpAppLauncher(
@@ -154,6 +150,10 @@ void EulaScreenHandler::ShowAdditionalTosDialog() {
CallJS("login.EulaScreen.showAdditionalTosDialog");
}
+void EulaScreenHandler::ShowSecuritySettingsDialog() {
+ CallJS("login.EulaScreen.showSecuritySettingsDialog");
+}
+
void EulaScreenHandler::UpdateLocalizedValues(
::login::SecureModuleUsed secure_module_used) {
base::DictionaryValue updated_secure_module_strings;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h
index 4d746158510..42beb201346 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h
@@ -34,9 +34,9 @@ class EulaView {
virtual void Hide() = 0;
virtual void Bind(EulaScreen* screen) = 0;
virtual void Unbind() = 0;
- virtual void OnPasswordFetched(const std::string& tpm_password) = 0;
virtual void ShowStatsUsageLearnMore() = 0;
virtual void ShowAdditionalTosDialog() = 0;
+ virtual void ShowSecuritySettingsDialog() = 0;
};
// WebUI implementation of EulaScreenView. It is used to interact
@@ -54,9 +54,9 @@ class EulaScreenHandler : public EulaView, public BaseScreenHandler {
void Hide() override;
void Bind(EulaScreen* screen) override;
void Unbind() override;
- void OnPasswordFetched(const std::string& tpm_password) override;
void ShowStatsUsageLearnMore() override;
void ShowAdditionalTosDialog() override;
+ void ShowSecuritySettingsDialog() override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.cc
index c71c00d1277..25a1556c826 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/fake_app_launch_splash_screen_handler.cc
@@ -6,12 +6,32 @@
namespace chromeos {
+void FakeAppLaunchSplashScreenHandler::ShowErrorMessage(
+ KioskAppLaunchError::Error error) {
+ error_message_type_ = error;
+}
+
bool FakeAppLaunchSplashScreenHandler::IsNetworkReady() {
return network_ready_;
}
+KioskAppLaunchError::Error
+FakeAppLaunchSplashScreenHandler::GetErrorMessageType() const {
+ return error_message_type_;
+}
+
void FakeAppLaunchSplashScreenHandler::SetNetworkReady(bool ready) {
network_ready_ = ready;
}
+void FakeAppLaunchSplashScreenHandler::UpdateAppLaunchState(
+ AppLaunchState state) {
+ state_ = state;
+}
+
+AppLaunchSplashScreenHandler::AppLaunchState
+FakeAppLaunchSplashScreenHandler::GetAppLaunchState() {
+ return state_;
+}
+
} // namespace chromeos
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 23d402e7153..b2f6a14b7a7 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
@@ -15,15 +15,21 @@ class FakeAppLaunchSplashScreenHandler : public AppLaunchSplashScreenView {
void SetDelegate(Delegate*) override {}
void Show() override {}
void Hide() override {}
- void UpdateAppLaunchState(AppLaunchState state) override {}
+ void UpdateAppLaunchState(AppLaunchState state) override;
void ToggleNetworkConfig(bool) override {}
void ShowNetworkConfigureUI() override {}
-
+ void ShowErrorMessage(KioskAppLaunchError::Error error) override;
bool IsNetworkReady() override;
+
+ KioskAppLaunchError::Error GetErrorMessageType() const;
void SetNetworkReady(bool ready);
+ AppLaunchState GetAppLaunchState();
private:
+ KioskAppLaunchError::Error error_message_type_ =
+ KioskAppLaunchError::Error::kNone;
bool network_ready_ = false;
+ AppLaunchState state_ = APP_LAUNCH_STATE_PREPARING_PROFILE;
};
} // namespace chromeos
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 a32607165b0..448f04f509e 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
@@ -9,7 +9,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/screens/update_required_screen.h"
+#include "chrome/browser/ash/login/screens/update_required_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h"
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 40b2b7eb480..647ebf4081b 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
@@ -4,8 +4,8 @@
#include "chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.h"
+#include "chrome/browser/ash/login/screens/family_link_notice_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/family_link_notice_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
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 4b26fd4e71e..91b49aa5d50 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
@@ -5,8 +5,8 @@
#include "chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h"
#include "base/strings/string_number_conversions.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
-#include "chrome/browser/chromeos/login/screens/fingerprint_setup_screen.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.h"
+#include "chrome/browser/ash/login/screens/fingerprint_setup_screen.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -25,12 +25,8 @@ FingerprintSetupScreenHandler::~FingerprintSetupScreenHandler() = default;
void FingerprintSetupScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->AddF("setupFingerprintScreenTitle",
- IDS_OOBE_FINGERPINT_SETUP_SCREEN_TITLE,
- ui::GetChromeOSDeviceName());
- builder->AddF("setupFingerprintScreenFooter",
- IDS_OOBE_FINGERPINT_SETUP_SCREEN_ENROLLMENT_FOOTER,
- ui::GetChromeOSDeviceName());
+ builder->Add("setupFingerprintScreenTitle",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_TITLE);
builder->Add("skipFingerprintSetup",
IDS_OOBE_FINGERPINT_SETUP_SCREEN_BUTTON_SKIP);
builder->Add("fingerprintSetupDone",
@@ -75,7 +71,8 @@ void FingerprintSetupScreenHandler::DeclareLocalizedValues(
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_KEYBOARD_TOP_RIGHT_ARIA_LABEL;
break;
}
- builder->Add("setupFingerprintScreenDescription", description_id);
+ builder->AddF("setupFingerprintScreenDescription", description_id,
+ ui::GetChromeOSDeviceName());
builder->Add("setupFingerprintScreenAriaLabel", aria_label_id);
}
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 b901c35566a..625118e5ca0 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
@@ -5,8 +5,8 @@
#include "chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h"
#include "base/values.h"
+#include "chrome/browser/ash/login/screens/gaia_password_changed_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/gaia_password_changed_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
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 ab5892033d2..44a7a713f63 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
@@ -5,7 +5,11 @@
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
#include <memory>
+#include <string>
+#include "ash/constants/ash_features.h"
+#include "ash/constants/ash_switches.h"
+#include "ash/constants/devicetype.h"
#include "ash/public/cpp/login_screen.h"
#include "base/bind.h"
#include "base/callback.h"
@@ -13,6 +17,8 @@
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/guid.h"
+#include "base/i18n/message_formatter.h"
+#include "base/i18n/number_formatting.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
@@ -27,19 +33,19 @@
#include "base/task/thread_pool.h"
#include "base/timer/timer.h"
#include "base/values.h"
+#include "chrome/browser/ash/certificate_provider/certificate_provider_service.h"
+#include "chrome/browser/ash/certificate_provider/certificate_provider_service_factory.h"
+#include "chrome/browser/ash/certificate_provider/pin_dialog_manager.h"
+#include "chrome/browser/ash/login/saml/public_saml_url_fetcher.h"
+#include "chrome/browser/ash/login/saml/saml_metric_utils.h"
+#include "chrome/browser/ash/login/screens/network_error.h"
+#include "chrome/browser/ash/login/screens/signin_fatal_error_screen.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h"
-#include "chrome/browser/chromeos/certificate_provider/certificate_provider_service.h"
-#include "chrome/browser/chromeos/certificate_provider/certificate_provider_service_factory.h"
-#include "chrome/browser/chromeos/certificate_provider/pin_dialog_manager.h"
-#include "chrome/browser/chromeos/language_preferences.h"
-#include "chrome/browser/chromeos/login/lock_screen_utils.h"
#include "chrome/browser/chromeos/login/reauth_stats.h"
-#include "chrome/browser/chromeos/login/saml/public_saml_url_fetcher.h"
-#include "chrome/browser/chromeos/login/saml/saml_metric_utils.h"
-#include "chrome/browser/chromeos/login/screens/network_error.h"
-#include "chrome/browser/chromeos/login/screens/signin_fatal_error_screen.h"
#include "chrome/browser/chromeos/login/signin_partition_manager.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
@@ -48,14 +54,13 @@
#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_network_configuration_updater.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/webui/chromeos/login/cookie_waiter.h"
#include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h"
@@ -66,22 +71,21 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chromeos/components/security_token_pin/constants.h"
-#include "chromeos/constants/chromeos_features.h"
-#include "chromeos/constants/chromeos_switches.h"
-#include "chromeos/constants/devicetype.h"
+#include "chromeos/components/security_token_pin/error_generator.h"
#include "chromeos/dbus/util/version_loader.h"
#include "chromeos/login/auth/challenge_response/cert_utils.h"
#include "chromeos/login/auth/cryptohome_key_constants.h"
#include "chromeos/login/auth/saml_password_attributes.h"
+#include "chromeos/login/auth/sync_trusted_vault_keys.h"
#include "chromeos/login/auth/user_context.h"
#include "chromeos/network/onc/certificate_scope.h"
-#include "chromeos/network/portal_detector/network_portal_detector.h"
#include "chromeos/settings/cros_settings_names.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "components/login/localized_values_builder.h"
#include "components/policy/proto/chrome_device_policy.pb.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
+#include "components/sync/driver/sync_driver_switches.h"
#include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h"
#include "components/version_info/version_info.h"
@@ -95,8 +99,6 @@
#include "net/cert/x509_certificate.h"
#include "services/network/nss_temp_certs_cache_chromeos.h"
#include "services/network/public/mojom/network_context.mojom.h"
-#include "ui/base/ime/chromeos/input_method_manager.h"
-#include "ui/base/ime/chromeos/input_method_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -111,6 +113,11 @@ const char kAuthIframeParentName[] = "signin-frame";
const char kEndpointGen[] = "1.0";
+bool IsSyncTrustedVaultKeysEnabled() {
+ return base::FeatureList::IsEnabled(
+ ::switches::kSyncSupportTrustedVaultPassphraseRecovery);
+}
+
// Must be kept consistent with ChromeOSSamlApiUsed in enums.xml
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused
@@ -133,11 +140,7 @@ void RecordAPILogin(bool is_third_party_idp, bool is_api_used) {
base::UmaHistogramEnumeration("ChromeOS.SAML.APILogin", login_type);
}
-GaiaScreenHandler::GaiaScreenMode GetGaiaScreenMode(const std::string& email,
- bool use_offline) {
- if (use_offline)
- return GaiaScreenHandler::GAIA_SCREEN_MODE_OFFLINE;
-
+GaiaScreenHandler::GaiaScreenMode GetGaiaScreenMode(const std::string& email) {
int authentication_behavior = 0;
CrosSettings::Get()->GetInteger(kLoginAuthenticationBehavior,
&authentication_behavior);
@@ -177,6 +180,12 @@ std::string GetEnterpriseEnrollmentDomain() {
return connector->GetEnterpriseEnrollmentDomain();
}
+std::string GetSSOProfile() {
+ policy::BrowserPolicyConnectorChromeOS* connector =
+ g_browser_process->platform_part()->browser_policy_connector_chromeos();
+ return connector->GetSSOProfile();
+}
+
std::string GetRealm() {
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -225,15 +234,6 @@ void RecordSAMLScrapingVerificationResultInHistogram(bool success) {
UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success);
}
-void PushFrontIMIfNotExists(const std::string& input_method,
- std::vector<std::string>* input_methods) {
- if (input_method.empty())
- return;
-
- if (!base::Contains(*input_methods, input_method))
- input_methods->insert(input_methods->begin(), input_method);
-}
-
bool IsOnline(NetworkPortalDetector::CaptivePortalStatus status) {
return status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE;
}
@@ -244,8 +244,10 @@ void GetVersionAndConsent(std::string* out_version, bool* out_consent) {
}
user_manager::UserType CalculateUserType(const AccountId& account_id) {
- if (user_manager::UserManager::Get()->IsSupervisedAccountId(account_id))
- return user_manager::USER_TYPE_SUPERVISED;
+ if (user_manager::UserManager::Get()->IsDeprecatedSupervisedAccountId(
+ account_id)) {
+ return user_manager::USER_TYPE_SUPERVISED_DEPRECATED;
+ }
if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY)
return user_manager::USER_TYPE_ACTIVE_DIRECTORY;
@@ -274,15 +276,25 @@ PinDialogManager* GetLoginScreenPinDialogManager() {
}
base::Value MakeSecurityTokenPinDialogParameters(
- security_token_pin::CodeType code_type,
bool enable_user_input,
security_token_pin::ErrorLabel error_label,
int attempts_left) {
base::Value params(base::Value::Type::DICTIONARY);
- params.SetIntKey("codeType", static_cast<int>(code_type));
+
params.SetBoolKey("enableUserInput", enable_user_input);
- params.SetIntKey("errorLabel", static_cast<int>(error_label));
- params.SetIntKey("attemptsLeft", attempts_left);
+ params.SetBoolKey("hasError",
+ error_label != security_token_pin::ErrorLabel::kNone);
+ params.SetStringKey(
+ "formattedError",
+ GenerateErrorMessage(error_label, attempts_left, enable_user_input));
+ if (attempts_left == -1) {
+ params.SetStringKey("formattedAttemptsLeft", base::string16());
+ } else {
+ params.SetStringKey(
+ "formattedAttemptsLeft",
+ GenerateErrorMessage(security_token_pin::ErrorLabel::kNone,
+ attempts_left, true));
+ }
return params;
}
@@ -302,34 +314,10 @@ GaiaScreenHandler::GaiaScreenHandler(
}
GaiaScreenHandler::~GaiaScreenHandler() {
- if (network_portal_detector::IsInitialized())
- network_portal_detector::GetInstance()->RemoveObserver(this);
if (is_security_token_pin_enabled_)
GetLoginScreenPinDialogManager()->RemovePinDialogHost(this);
}
-void GaiaScreenHandler::MaybePreloadAuthExtension() {
- // We shall not have network portal detector initialized, which unnecessarily
- // polls captive portal checking URL if we don't need to load gaia. See
- // go/bad-portal for more context.
- if (!signin_screen_handler_->ShouldLoadGaia())
- return;
-
- VLOG(1) << "MaybePreloadAuthExtension";
-
- if (network_portal_detector::IsInitialized())
- network_portal_detector::GetInstance()->AddAndFireObserver(this);
-
- // If cookies clearing was initiated or `dns_clear_task_running_` then auth
- // extension showing has already been initiated and preloading is pointless.
- if (!gaia_silent_load_ && !cookies_cleared_ && !dns_clear_task_running_ &&
- network_state_informer_->state() == NetworkStateInformer::ONLINE) {
- gaia_silent_load_ = true;
- gaia_silent_load_network_ = network_state_informer_->network_path();
- LoadAuthExtension(true /* force */, false /* offline */);
- }
-}
-
void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() {
disable_restrictive_proxy_check_for_test_ = true;
}
@@ -411,14 +399,12 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
UpdateAuthParams(&params, IsRestrictiveProxy());
- screen_mode_ = GetGaiaScreenMode(context.email, context.use_offline);
+ screen_mode_ = GetGaiaScreenMode(context.email);
params.SetInteger("screenMode", screen_mode_);
- if (screen_mode_ != GAIA_SCREEN_MODE_OFFLINE) {
- const std::string app_locale = g_browser_process->GetApplicationLocale();
- if (!app_locale.empty())
- params.SetString("hl", app_locale);
- }
+ const std::string app_locale = g_browser_process->GetApplicationLocale();
+ if (!app_locale.empty())
+ params.SetString("hl", app_locale);
std::string realm(GetRealm());
if (!realm.empty()) {
@@ -429,12 +415,17 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
const std::string enterprise_enrollment_domain(
GetEnterpriseEnrollmentDomain());
const std::string enterprise_domain_manager(GetEnterpriseDomainManager());
+ const std::string sso_profile(GetSSOProfile());
+
if (!enterprise_display_domain.empty())
params.SetString("enterpriseDisplayDomain", enterprise_display_domain);
if (!enterprise_enrollment_domain.empty()) {
params.SetString("enterpriseEnrollmentDomain",
enterprise_enrollment_domain);
}
+ if (!sso_profile.empty()) {
+ params.SetString("ssoProfile", sso_profile);
+ }
if (!enterprise_domain_manager.empty()) {
params.SetString("enterpriseDomainManager", enterprise_domain_manager);
}
@@ -493,6 +484,12 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
.path()
.substr(1));
break;
+ case GaiaPath::kReauth:
+ params.SetString(
+ "gaiaPath",
+ GaiaUrls::GetInstance()->embedded_reauth_chromeos_url().path().substr(
+ 1));
+ break;
}
// We only send `chromeos_board` Gaia URL parameter if user has opted into
@@ -505,7 +502,8 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
params.SetBoolean("extractSamlPasswordAttributes",
login::ExtractSamlPasswordAttributesEnabled());
- params.SetBoolean("enableGaiaActionButtons", true);
+ params.SetBoolean("enableSyncTrustedVaultKeys",
+ IsSyncTrustedVaultKeysEnabled());
if (public_saml_url_fetcher_) {
params.SetBoolean("startsOnSamlPage", true);
@@ -527,6 +525,23 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
}
public_saml_url_fetcher_.reset();
+ bool is_reauth = !context.email.empty();
+ if (is_reauth && features::IsGaiaReauthEndpointEnabled()) {
+ const AccountId account_id =
+ GetAccountId(context.email, context.gaia_id, AccountType::GOOGLE);
+ auto* user = user_manager::UserManager::Get()->FindUser(account_id);
+ DCHECK(user);
+ bool is_child_account = user && user->IsChild();
+ // Enable the new endpoint for supervised account for now. We might expand
+ // it to other account type in the future.
+ if (is_child_account) {
+ params.SetBoolean("isSupervisedUser", is_child_account);
+ params.SetBoolean(
+ "isDeviceOwner",
+ account_id == user_manager::UserManager::Get()->GetOwnerAccountId());
+ }
+ }
+
was_security_token_pin_canceled_ = false;
frame_state_ = FRAME_STATE_LOADING;
@@ -549,11 +564,7 @@ void GaiaScreenHandler::ReloadGaia(bool force_reload) {
signin_screen_handler_->proxy_auth_dialog_need_reload_ = false;
VLOG(1) << "Reloading Gaia.";
frame_state_ = FRAME_STATE_LOADING;
- LoadAuthExtension(force_reload, false /* offline */);
-}
-
-void GaiaScreenHandler::MonitorOfflineIdle(bool is_online) {
- CallJS("login.GaiaSigninScreen.monitorOfflineIdle", is_online);
+ LoadAuthExtension(force_reload);
}
void GaiaScreenHandler::DeclareLocalizedValues(
@@ -572,17 +583,6 @@ void GaiaScreenHandler::DeclareLocalizedValues(
builder->AddF("loginWelcomeMessage", IDS_LOGIN_WELCOME_MESSAGE,
ui::GetChromeOSDeviceTypeResourceId());
- builder->Add("offlineLoginEmail", IDS_OFFLINE_LOGIN_EMAIL);
- builder->Add("offlineLoginPassword", IDS_OFFLINE_LOGIN_PASSWORD);
- builder->Add("offlineLoginInvalidEmail", IDS_OFFLINE_LOGIN_INVALID_EMAIL);
- builder->Add("offlineLoginInvalidPassword",
- IDS_OFFLINE_LOGIN_INVALID_PASSWORD);
- builder->Add("offlineLoginNextBtn", IDS_OFFLINE_LOGIN_NEXT_BUTTON_TEXT);
- builder->Add("offlineLoginForgotPasswordBtn",
- IDS_OFFLINE_LOGIN_FORGOT_PASSWORD_BUTTON_TEXT);
- builder->Add("offlineLoginForgotPasswordDlg",
- IDS_OFFLINE_LOGIN_FORGOT_PASSWORD_DIALOG_TEXT);
- builder->Add("offlineLoginCloseBtn", IDS_OFFLINE_LOGIN_CLOSE_BUTTON_TEXT);
builder->Add("enterpriseInfoMessage", IDS_LOGIN_DEVICE_MANAGED_BY_NOTICE);
builder->Add("samlInterstitialMessage", IDS_LOGIN_SAML_INTERSTITIAL_MESSAGE);
builder->Add("samlInterstitialChangeAccountLink",
@@ -607,20 +607,6 @@ void GaiaScreenHandler::DeclareLocalizedValues(
IDS_SAML_SECURITY_TOKEN_PIN_DIALOG_TITLE);
builder->Add("securityTokenPinDialogSubtitle",
IDS_SAML_SECURITY_TOKEN_PIN_DIALOG_SUBTITLE);
- builder->Add("securityTokenPinDialogTryAgain",
- IDS_SAML_SECURITY_TOKEN_PIN_DIALOG_TRY_AGAIN);
- builder->Add("securityTokenPinDialogAttemptsLeft",
- IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT);
- builder->Add("securityTokenPinDialogErrorAttempts",
- IDS_REQUEST_PIN_DIALOG_ERROR_ATTEMPTS);
- builder->Add("securityTokenPinDialogUnknownError",
- IDS_REQUEST_PIN_DIALOG_UNKNOWN_ERROR);
- builder->Add("securityTokenPinDialogUnknownInvalidPin",
- IDS_REQUEST_PIN_DIALOG_INVALID_PIN_ERROR);
- builder->Add("securityTokenPinDialogUnknownInvalidPuk",
- IDS_REQUEST_PIN_DIALOG_INVALID_PUK_ERROR);
- builder->Add("securityTokenPinDialogUnknownMaxAttemptsExceeded",
- IDS_REQUEST_PIN_DIALOG_MAX_ATTEMPTS_EXCEEDED_ERROR);
}
void GaiaScreenHandler::Initialize() {
@@ -650,8 +636,6 @@ void GaiaScreenHandler::RegisterMessages() {
&GaiaScreenHandler::HandleSamlChallengeMachineKey);
AddCallback("loginWebuiReady", &GaiaScreenHandler::HandleGaiaUIReady);
AddCallback("identifierEntered", &GaiaScreenHandler::HandleIdentifierEntered);
- AddCallback("updateOfflineLogin",
- &GaiaScreenHandler::SetOfflineLoginIsActive);
AddCallback("authExtensionLoaded",
&GaiaScreenHandler::HandleAuthExtensionLoaded);
AddRawCallback("showAddUser", &GaiaScreenHandler::HandleShowAddUser);
@@ -663,6 +647,7 @@ void GaiaScreenHandler::RegisterMessages() {
AddCallback("securityTokenPinEntered",
&GaiaScreenHandler::HandleSecurityTokenPinEntered);
AddCallback("onFatalError", &GaiaScreenHandler::HandleOnFatalError);
+ AddCallback("removeUserByEmail", &GaiaScreenHandler::HandleUserRemoved);
BaseScreenHandler::RegisterMessages();
}
@@ -676,13 +661,12 @@ void GaiaScreenHandler::OnPortalDetectionCompleted(
const NetworkPortalDetector::CaptivePortalStatus previous_status =
captive_portal_status_;
captive_portal_status_ = status;
- if (IsOfflineLoginActive() ||
- IsOnline(captive_portal_status_) == IsOnline(previous_status) ||
+ if (IsOnline(captive_portal_status_) == IsOnline(previous_status) ||
disable_restrictive_proxy_check_for_test_ ||
GetCurrentScreen() != kScreenId)
return;
- LoadAuthExtension(true /* force */, false /* offline */);
+ LoadAuthExtension(true /* force */);
}
void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) {
@@ -764,7 +748,8 @@ void GaiaScreenHandler::HandleCompleteAuthentication(
const std::string& password,
bool using_saml,
const ::login::StringList& services,
- const base::DictionaryValue* password_attributes) {
+ const base::DictionaryValue* password_attributes,
+ const base::DictionaryValue* sync_trusted_vault_keys) {
if (!LoginDisplayHost::default_host())
return;
@@ -801,6 +786,10 @@ void GaiaScreenHandler::HandleCompleteAuthentication(
GetAccountId(email, gaia_id, AccountType::GOOGLE), using_saml,
using_saml_api_, password,
SamlPasswordAttributes::FromJs(*password_attributes),
+ IsSyncTrustedVaultKeysEnabled()
+ ? base::make_optional(
+ SyncTrustedVaultKeys::FromJs(*sync_trusted_vault_keys))
+ : base::nullopt,
*extension_provided_client_cert_usage_observer_,
pending_user_context_.get(), &error_message)) {
core_oobe_view_->ShowSignInError(0, error_message, std::string(),
@@ -823,7 +812,7 @@ void GaiaScreenHandler::HandleCompleteAuthentication(
}
void GaiaScreenHandler::OnCookieWaitTimeout() {
- LoadAuthExtension(true /* force */, false /* offline */);
+ LoadAuthExtension(true /* force */);
core_oobe_view_->ShowSignInError(
0, l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_AUTH_TOKEN),
std::string(), HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
@@ -834,8 +823,7 @@ void GaiaScreenHandler::HandleCompleteLogin(const std::string& gaia_id,
const std::string& password,
bool using_saml) {
VLOG(1) << "HandleCompleteLogin";
- DoCompleteLogin(gaia_id, typed_email, password, using_saml,
- SamlPasswordAttributes());
+ DoCompleteLogin(gaia_id, typed_email, password, using_saml);
}
void GaiaScreenHandler::HandleUsingSAMLAPI(bool is_third_party_idp) {
@@ -878,11 +866,6 @@ void GaiaScreenHandler::HandleSamlChallengeMachineKey(
void GaiaScreenHandler::HandleGaiaUIReady() {
VLOG(1) << "Gaia is loaded";
- // As we could miss and window.onload could already be called, restore
- // focus to current pod (see crbug/175243).
- if (gaia_silent_load_)
- signin_screen_handler_->RefocusCurrentPod();
-
frame_error_ = net::OK;
frame_state_ = FRAME_STATE_LOADED;
@@ -982,22 +965,28 @@ void GaiaScreenHandler::HandleOnFatalError(
params);
}
+void GaiaScreenHandler::HandleUserRemoved(const std::string& email) {
+ const AccountId account_id = user_manager::known_user::GetAccountId(
+ email, /*id=*/std::string(), AccountType::UNKNOWN);
+ if (account_id == user_manager::UserManager::Get()->GetOwnerAccountId()) {
+ // Shows powerwash UI if the user is device owner.
+ DCHECK(LoginDisplayHost::default_host());
+ LoginDisplayHost::default_host()->StartWizard(ResetView::kScreenId);
+ } else {
+ // Removes the account on the device.
+ user_manager::UserManager::Get()->RemoveUser(account_id,
+ nullptr /*delegate*/);
+ }
+}
+
void GaiaScreenHandler::OnShowAddUser() {
- signin_screen_handler_->is_account_picker_showing_first_time_ = false;
- lock_screen_utils::EnforceDevicePolicyInputMethods(std::string());
- LoadGaiaAsync(EmptyAccountId());
- LoginDisplayHost::default_host()->StartWizard(
- chromeos::features::IsChildSpecificSigninEnabled()
- ? UserCreationView::kScreenId
- : GaiaView::kScreenId);
+ LoginDisplayHost::default_host()->ShowGaiaDialog(populated_account_id_);
}
-void GaiaScreenHandler::DoCompleteLogin(
- const std::string& gaia_id,
- const std::string& typed_email,
- const std::string& password,
- bool using_saml,
- const SamlPasswordAttributes& password_attributes) {
+void GaiaScreenHandler::DoCompleteLogin(const std::string& gaia_id,
+ const std::string& typed_email,
+ const std::string& password,
+ bool using_saml) {
if (using_saml && !using_saml_api_)
RecordSAMLScrapingVerificationResultInHistogram(true);
@@ -1015,7 +1004,8 @@ void GaiaScreenHandler::DoCompleteLogin(
if (!login::BuildUserContextForGaiaSignIn(
user ? user->GetType() : CalculateUserType(account_id),
GetAccountId(typed_email, gaia_id, AccountType::GOOGLE), using_saml,
- using_saml_api_, password, password_attributes,
+ using_saml_api_, password, SamlPasswordAttributes(),
+ /*sync_trusted_vault_keys=*/base::nullopt,
*extension_provided_client_cert_usage_observer_, &user_context,
&error_message)) {
core_oobe_view_->ShowSignInError(0, error_message, std::string(),
@@ -1055,21 +1045,21 @@ void GaiaScreenHandler::OnDnsCleared() {
}
void GaiaScreenHandler::StartClearingCookies(
- const base::Closure& on_clear_callback) {
+ base::OnceClosure on_clear_callback) {
cookies_cleared_ = false;
ProfileHelper* profile_helper = ProfileHelper::Get();
LOG_ASSERT(Profile::FromWebUI(web_ui()) ==
profile_helper->GetSigninProfile());
profile_helper->ClearSigninProfile(
- base::Bind(&GaiaScreenHandler::OnCookiesCleared,
- weak_factory_.GetWeakPtr(), on_clear_callback));
+ base::AdaptCallbackForRepeating(base::BindOnce(
+ &GaiaScreenHandler::OnCookiesCleared, weak_factory_.GetWeakPtr(),
+ std::move(on_clear_callback))));
}
-void GaiaScreenHandler::OnCookiesCleared(
- const base::Closure& on_clear_callback) {
+void GaiaScreenHandler::OnCookiesCleared(base::OnceClosure on_clear_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
cookies_cleared_ = true;
- on_clear_callback.Run();
+ std::move(on_clear_callback).Run();
}
void GaiaScreenHandler::SubmitLoginFormForTest() {
@@ -1080,12 +1070,12 @@ void GaiaScreenHandler::SubmitLoginFormForTest() {
// clang-format off
std::string code =
- "document.getElementById('identifier').value = '" + test_user_ + "';"
- "document.getElementById('nextButton').click();";
+ "document.getElementById('identifier').value = '" + test_user_ + "';";
// clang-format on
frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code),
base::NullCallback());
+ CallJS("login.GaiaSigninScreen.clickPrimaryButtonForTesting");
if (!test_services_.empty()) {
// Prefix each doublequote with backslash, so that it will remain correct
@@ -1100,9 +1090,9 @@ void GaiaScreenHandler::SubmitLoginFormForTest() {
if (!test_pass_.empty()) {
code = "document.getElementById('password').value = '" + test_pass_ + "';";
- code += "document.getElementById('nextButton').click();";
frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code),
base::NullCallback());
+ CallJS("login.GaiaSigninScreen.clickPrimaryButtonForTesting");
}
// Test properties are cleared in HandleCompleteAuthentication because the
@@ -1140,24 +1130,18 @@ void GaiaScreenHandler::SetGaiaPath(GaiaScreenHandler::GaiaPath gaia_path) {
}
void GaiaScreenHandler::LoadGaiaAsync(const AccountId& account_id) {
- if (account_id.is_valid())
- populated_account_id_ = account_id;
+ populated_account_id_ = account_id;
if (gaia_silent_load_ && !populated_account_id_.is_valid()) {
dns_cleared_ = true;
cookies_cleared_ = true;
ShowGaiaScreenIfReady();
} else {
StartClearingDnsCache();
- StartClearingCookies(base::Bind(&GaiaScreenHandler::ShowGaiaScreenIfReady,
- weak_factory_.GetWeakPtr()));
+ StartClearingCookies(base::BindOnce(
+ &GaiaScreenHandler::ShowGaiaScreenIfReady, weak_factory_.GetWeakPtr()));
}
}
-void GaiaScreenHandler::LoadOfflineGaia(const AccountId& account_id) {
- populated_account_id_ = account_id;
- LoadAuthExtension(true /* force */, true /* offline */);
-}
-
void GaiaScreenHandler::ShowSigninScreenForTest(const std::string& username,
const std::string& password,
const std::string& services) {
@@ -1203,8 +1187,8 @@ void GaiaScreenHandler::ShowSecurityTokenPinDialog(
std::move(pin_dialog_closed_callback);
CallJS("login.GaiaSigninScreen.showPinDialog",
- MakeSecurityTokenPinDialogParameters(code_type, enable_user_input,
- error_label, attempts_left));
+ MakeSecurityTokenPinDialogParameters(enable_user_input, error_label,
+ attempts_left));
}
void GaiaScreenHandler::CloseSecurityTokenPinDialog() {
@@ -1223,10 +1207,6 @@ void GaiaScreenHandler::CloseSecurityTokenPinDialog() {
CallJS("login.GaiaSigninScreen.closePinDialog");
}
-bool GaiaScreenHandler::IsOfflineLoginActive() const {
- return (screen_mode_ == GAIA_SCREEN_MODE_OFFLINE) || offline_login_is_active_;
-}
-
void GaiaScreenHandler::SetNextSamlChallengeKeyHandlerForTesting(
std::unique_ptr<SamlChallengeKeyHandler> handler_for_test) {
saml_challenge_key_handler_for_test_ = std::move(handler_for_test);
@@ -1258,45 +1238,6 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
gaia_silent_load_ = false;
}
- input_method::InputMethodManager* imm =
- input_method::InputMethodManager::Get();
-
- scoped_refptr<input_method::InputMethodManager::State> gaia_ime_state =
- imm->GetActiveIMEState()->Clone();
- imm->SetState(gaia_ime_state);
- gaia_ime_state->SetUIStyle(input_method::InputMethodManager::UIStyle::kLogin);
-
- // Set Least Recently Used input method for the user.
- if (populated_account_id_.is_valid()) {
- lock_screen_utils::SetUserInputMethod(populated_account_id_,
- gaia_ime_state.get(),
- true /*honor_device_policy*/);
- } else {
- std::vector<std::string> input_methods;
- if (gaia_ime_state->GetAllowedInputMethods().empty()) {
- input_methods =
- imm->GetInputMethodUtil()->GetHardwareLoginInputMethodIds();
- } else {
- input_methods = gaia_ime_state->GetAllowedInputMethods();
- }
- const std::string owner_im = lock_screen_utils::GetUserLastInputMethod(
- user_manager::UserManager::Get()->GetOwnerAccountId());
- const std::string system_im = g_browser_process->local_state()->GetString(
- language_prefs::kPreferredKeyboardLayout);
-
- PushFrontIMIfNotExists(owner_im, &input_methods);
- PushFrontIMIfNotExists(system_im, &input_methods);
-
- gaia_ime_state->EnableLoginLayouts(
- g_browser_process->GetApplicationLocale(), input_methods);
-
- if (!system_im.empty()) {
- gaia_ime_state->ChangeInputMethod(system_im, false /* show_message */);
- } else if (!owner_im.empty()) {
- gaia_ime_state->ChangeInputMethod(owner_im, false /* show_message */);
- }
- }
-
if (!untrusted_authority_certs_cache_) {
// Make additional untrusted authority certificates available for client
// certificate discovery in case a SAML flow is used which requires a client
@@ -1312,7 +1253,7 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
chromeos::onc::CertificateScope::Default()));
}
- LoadAuthExtension(!gaia_silent_load_ /* force */, false /* offline */);
+ LoadAuthExtension(!gaia_silent_load_ /* force */);
signin_screen_handler_->UpdateUIState(
SigninScreenHandler::UI_STATE_GAIA_SIGNIN);
core_oobe_view_->UpdateKeyboardState();
@@ -1348,9 +1289,8 @@ void GaiaScreenHandler::ShowAllowlistCheckFailedError() {
CallJS("login.GaiaSigninScreen.showAllowlistCheckFailedError", true, params);
}
-void GaiaScreenHandler::LoadAuthExtension(bool force, bool offline) {
- VLOG(1) << "LoadAuthExtension, force: " << force << ", offline: " << offline;
-
+void GaiaScreenHandler::LoadAuthExtension(bool force) {
+ VLOG(1) << "LoadAuthExtension, force: " << force;
if (auth_extension_being_loaded_) {
VLOG(1) << "Skip loading the Auth extension as it's already being loaded";
return;
@@ -1359,7 +1299,6 @@ void GaiaScreenHandler::LoadAuthExtension(bool force, bool offline) {
auth_extension_being_loaded_ = true;
login::GaiaContext context;
context.force_reload = force;
- context.use_offline = offline;
context.email = populated_account_id_.GetUserEmail();
std::string gaia_id;
@@ -1379,10 +1318,6 @@ void GaiaScreenHandler::LoadAuthExtension(bool force, bool offline) {
LoadGaia(context);
}
-void GaiaScreenHandler::SetOfflineLoginIsActive(bool is_active) {
- offline_login_is_active_ = is_active;
-}
-
void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) {
if (signin_screen_handler_ && !hidden_)
signin_screen_handler_->UpdateState(reason);
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 b7e7f97f2bc..2b7c92e63d0 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
@@ -11,7 +11,7 @@
#include "base/command_line.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "chrome/browser/chromeos/certificate_provider/security_token_pin_dialog_host.h"
+#include "chrome/browser/ash/certificate_provider/security_token_pin_dialog_host.h"
#include "chrome/browser/chromeos/login/login_client_cert_usage_observer.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
@@ -36,7 +36,6 @@ class NSSTempCertsCacheChromeOS;
namespace chromeos {
-class SamlPasswordAttributes;
class SigninScreenHandler;
class PublicSamlUrlFetcher;
class GaiaScreen;
@@ -47,6 +46,7 @@ class GaiaView {
kDefault,
kChildSignup,
kChildSignin,
+ kReauth,
};
constexpr static StaticOobeScreenId kScreenId{"gaia-signin"};
@@ -54,10 +54,6 @@ class GaiaView {
GaiaView() = default;
virtual ~GaiaView() = default;
- // Decides whether an auth extension should be pre-loaded. If it should,
- // pre-loads it.
- virtual void MaybePreloadAuthExtension() = 0;
-
virtual void DisableRestrictiveProxyCheckForTest() = 0;
// Loads Gaia into the webview. Depending on internal state, the Gaia will
@@ -66,8 +62,6 @@ class GaiaView {
// prefilling information.
virtual void LoadGaiaAsync(const AccountId& account_id) = 0;
- virtual void LoadOfflineGaia(const AccountId& account_id) = 0;
-
// Shows Gaia screen.
virtual void Show() = 0;
virtual void Hide() = 0;
@@ -102,11 +96,8 @@ class GaiaScreenHandler : public BaseScreenHandler,
// Default Gaia authentication will be used.
GAIA_SCREEN_MODE_DEFAULT = 0,
- // Gaia offline mode will be used.
- GAIA_SCREEN_MODE_OFFLINE = 1,
-
// An interstitial page will be used before SAML redirection.
- GAIA_SCREEN_MODE_SAML_INTERSTITIAL = 2,
+ GAIA_SCREEN_MODE_SAML_INTERSTITIAL = 1,
};
enum FrameState {
@@ -123,10 +114,8 @@ class GaiaScreenHandler : public BaseScreenHandler,
~GaiaScreenHandler() override;
// GaiaView:
- void MaybePreloadAuthExtension() override;
void DisableRestrictiveProxyCheckForTest() override;
void LoadGaiaAsync(const AccountId& account_id) override;
- void LoadOfflineGaia(const AccountId& account_id) override;
void Show() override;
void Hide() override;
void Bind(GaiaScreen* screen) override;
@@ -148,10 +137,6 @@ class GaiaScreenHandler : public BaseScreenHandler,
SecurityTokenPinDialogClosedCallback pin_dialog_closed_callback) override;
void CloseSecurityTokenPinDialog() override;
- // Returns true if offline login mode was either required, or reported by the
- // WebUI (i.e. WebUI mignt not have completed transition to the new mode).
- bool IsOfflineLoginActive() const;
-
void SetNextSamlChallengeKeyHandlerForTesting(
std::unique_ptr<SamlChallengeKeyHandler> handler_for_test);
@@ -184,10 +169,6 @@ class GaiaScreenHandler : public BaseScreenHandler,
// not loading right now.
void ReloadGaia(bool force_reload);
- // Turns offline idle detection on or off. Idle detection should only be on if
- // we're using the offline login page but the device is online.
- void MonitorOfflineIdle(bool is_online);
-
// Show error UI at the end of GAIA flow when user is not allowlisted.
void ShowAllowlistCheckFailedError();
@@ -212,7 +193,8 @@ class GaiaScreenHandler : public BaseScreenHandler,
const std::string& password,
bool using_saml,
const ::login::StringList& services,
- const base::DictionaryValue* password_attributes);
+ const base::DictionaryValue* password_attributes,
+ const base::DictionaryValue* sync_trusted_vault_keys);
void HandleCompleteLogin(const std::string& gaia_id,
const std::string& typed_email,
const std::string& password,
@@ -249,18 +231,20 @@ class GaiaScreenHandler : public BaseScreenHandler,
void HandleSecurityTokenPinEntered(const std::string& user_input);
void HandleOnFatalError(int error_code, const base::DictionaryValue* params);
+ // Called when the user is removed.
+ void HandleUserRemoved(const std::string& email);
+
void OnShowAddUser();
// Really handles the complete login message.
void DoCompleteLogin(const std::string& gaia_id,
const std::string& typed_email,
const std::string& password,
- bool using_saml,
- const SamlPasswordAttributes& password_attributes);
+ bool using_saml);
// Kick off cookie / local storage cleanup.
- void StartClearingCookies(const base::Closure& on_clear_callback);
- void OnCookiesCleared(const base::Closure& on_clear_callback);
+ void StartClearingCookies(base::OnceClosure on_clear_callback);
+ void OnCookiesCleared(base::OnceClosure on_clear_callback);
// Kick off DNS cache flushing.
void StartClearingDnsCache();
@@ -277,9 +261,8 @@ class GaiaScreenHandler : public BaseScreenHandler,
void ShowGaiaScreenIfReady();
// Tells webui to load authentication extension. `force` is used to force the
- // extension reloading, if it has already been loaded. `offline` is true when
- // offline version of the extension should be used.
- void LoadAuthExtension(bool force, bool offline);
+ // extension reloading, if it has already been loaded.
+ void LoadAuthExtension(bool force);
// TODO (antrim@): GaiaScreenHandler should implement
// NetworkStateInformer::Observer.
@@ -305,9 +288,6 @@ class GaiaScreenHandler : public BaseScreenHandler,
const std::string& id,
const AccountType& account_type) const;
- // Records whether WebUI is currently in offline mode.
- void SetOfflineLoginIsActive(bool is_active);
-
void OnCookieWaitTimeout();
bool is_security_token_pin_dialog_running() const {
@@ -380,9 +360,6 @@ class GaiaScreenHandler : public BaseScreenHandler,
// signin_screen_handler directly.
SigninScreenHandler* signin_screen_handler_ = nullptr;
- // True if WebUI is currently displaying offline GAIA.
- bool offline_login_is_active_ = false;
-
// True if the authentication extension is still loading.
bool auth_extension_being_loaded_ = false;
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 2aeccdf9329..daca5d09d0f 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
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/login/gesture_navigation_screen_handler.h"
-#include "chrome/browser/chromeos/login/screens/gesture_navigation_screen.h"
+#include "chrome/browser/ash/login/screens/gesture_navigation_screen.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
index 49343bf308e..714d27d2775 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
@@ -9,13 +9,12 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/strings/string16.h"
+#include "chrome/browser/ash/login/screens/hid_detection_screen.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/hid_detection_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
@@ -74,6 +73,10 @@ void HIDDetectionScreenHandler::SetMouseState(const std::string& value) {
CallJS("login.HIDDetectionScreen.setMouseState", value);
}
+void HIDDetectionScreenHandler::SetTouchscreenDetectedState(bool value) {
+ CallJS("login.HIDDetectionScreen.setTouchscreenDetectedState", value);
+}
+
void HIDDetectionScreenHandler::SetKeyboardPinCode(const std::string& value) {
keyboard_pin_code_ = value;
CallJS("login.HIDDetectionScreen.setKeyboardPinCode", value);
@@ -112,6 +115,8 @@ void HIDDetectionScreenHandler::DeclareLocalizedValues(
builder->Add("hidDetectionInvitation", IDS_HID_DETECTION_INVITATION_TEXT);
builder->Add("hidDetectionPrerequisites",
IDS_HID_DETECTION_PRECONDITION_TEXT);
+ builder->Add("hidDetectionPrerequisitesTouchscreen",
+ IDS_HID_DETECTION_PRECONDITION_TOUCHSCREEN_TEXT);
builder->Add("hidDetectionMouseSearching", IDS_HID_DETECTION_SEARCHING_MOUSE);
builder->Add("hidDetectionKeyboardSearching",
IDS_HID_DETECTION_SEARCHING_KEYBOARD);
@@ -135,6 +140,8 @@ void HIDDetectionScreenHandler::DeclareLocalizedValues(
builder->Add("hidDetectionBluetoothKeyboardPaired",
IDS_HID_DETECTION_PAIRED_BLUETOOTH_KEYBOARD);
builder->Add("oobeModalDialogClose", IDS_CHROMEOS_OOBE_CLOSE_DIALOG);
+ builder->Add("hidDetectionTouchscreenDetected",
+ IDS_HID_DETECTION_DETECTED_TOUCHSCREEN);
}
void HIDDetectionScreenHandler::Initialize() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h
index 9fdbd0670b8..60364ab09b3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h
@@ -32,6 +32,7 @@ class HIDDetectionView {
virtual void Unbind() = 0;
virtual void SetKeyboardState(const std::string& value) = 0;
virtual void SetMouseState(const std::string& value) = 0;
+ virtual void SetTouchscreenDetectedState(bool value) = 0;
virtual void SetKeyboardPinCode(const std::string& value) = 0;
virtual void SetPinDialogVisible(bool value) = 0;
virtual void SetNumKeysEnteredPinCode(int value) = 0;
@@ -57,6 +58,7 @@ class HIDDetectionScreenHandler
void Unbind() override;
void SetKeyboardState(const std::string& value) override;
void SetMouseState(const std::string& value) override;
+ void SetTouchscreenDetectedState(bool value) override;
void SetKeyboardPinCode(const std::string& value) override;
void SetPinDialogVisible(bool value) override;
void SetNumKeysEnteredPinCode(int value) override;
@@ -116,4 +118,3 @@ class HIDDetectionScreenHandler
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_
-
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 865def1bf7e..e42af035f6a 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
@@ -8,21 +8,17 @@
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/ash/login/screens/kiosk_autolaunch_screen.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/kiosk_autolaunch_screen.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/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"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_service.h"
#include "ui/base/webui/web_ui_util.h"
namespace chromeos {
@@ -115,11 +111,6 @@ void KioskAutolaunchScreenHandler::HandleOnCancel() {
KioskAppManager::Get()->SetEnableAutoLaunch(false);
if (delegate_)
delegate_->OnExit(false);
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_COMPLETED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
}
void KioskAutolaunchScreenHandler::HandleOnConfirm() {
@@ -127,11 +118,6 @@ void KioskAutolaunchScreenHandler::HandleOnConfirm() {
KioskAppManager::Get()->SetEnableAutoLaunch(true);
if (delegate_)
delegate_->OnExit(true);
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_COMPLETED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
}
void KioskAutolaunchScreenHandler::HandleOnVisible() {
@@ -140,10 +126,6 @@ void KioskAutolaunchScreenHandler::HandleOnVisible() {
is_visible_ = true;
UpdateKioskApp();
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
}
void KioskAutolaunchScreenHandler::OnKioskAppsSettingsChanged() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h
index 8a9d07f41d4..9aec16d3c78 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h
@@ -7,7 +7,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_manager_observer.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
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 c1a89cb6c35..3b670548611 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
@@ -7,8 +7,8 @@
#include <string>
#include "base/bind.h"
+#include "chrome/browser/ash/login/screens/kiosk_enable_screen.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/login/screens/kiosk_enable_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
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 9f32017e8a0..9699a57c308 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
@@ -8,7 +8,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
index 78beeedf823..a1b5c955982 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
@@ -14,12 +14,12 @@
#include "base/bind.h"
#include "base/check_op.h"
+#include "base/containers/contains.h"
#include "base/i18n/rtl.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/notreached.h"
#include "base/sequenced_task_runner.h"
-#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -29,9 +29,9 @@
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/customization/customization_document.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
@@ -303,7 +303,7 @@ void GetAndMergeKeyboardLayoutsForLocale(input_method::InputMethodUtil* util,
// `resolved_locale`.
void GetKeyboardLayoutsForResolvedLocale(
const std::string& requested_locale,
- const GetKeyboardLayoutsForLocaleCallback& callback,
+ GetKeyboardLayoutsForLocaleCallback callback,
const std::string& resolved_locale) {
input_method::InputMethodUtil* util =
input_method::InputMethodManager::Get()->GetInputMethodUtil();
@@ -327,7 +327,7 @@ void GetKeyboardLayoutsForResolvedLocale(
input_methods_list->Append(CreateInputMethodsEntry(*ime, selected));
}
- callback.Run(std::move(input_methods_list));
+ std::move(callback).Run(std::move(input_methods_list));
}
// For "UI Language" drop-down menu at OOBE screen we need to decide which
@@ -351,7 +351,7 @@ void ResolveLanguageListInThreadPool(
std::unique_ptr<chromeos::locale_util::LanguageSwitchResult>
language_switch_result,
const scoped_refptr<base::TaskRunner> task_runner,
- const UILanguageListResolvedCallback& resolved_callback) {
+ UILanguageListResolvedCallback resolved_callback) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
@@ -384,8 +384,9 @@ void ResolveLanguageListInThreadPool(
chromeos::GetUILanguageList(nullptr, selected_code));
task_runner->PostTask(
- FROM_HERE, base::BindOnce(resolved_callback, std::move(language_list),
- list_locale, selected_language));
+ FROM_HERE,
+ base::BindOnce(std::move(resolved_callback), std::move(language_list),
+ list_locale, selected_language));
}
void AdjustUILanguageList(const std::string& selected,
@@ -426,7 +427,7 @@ void AdjustUILanguageList(const std::string& selected,
void ResolveUILanguageList(
std::unique_ptr<chromeos::locale_util::LanguageSwitchResult>
language_switch_result,
- const UILanguageListResolvedCallback& callback) {
+ UILanguageListResolvedCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::ThreadPool::PostTask(
@@ -434,7 +435,8 @@ void ResolveUILanguageList(
base::BindOnce(&ResolveLanguageListInThreadPool,
g_browser_process->GetApplicationLocale(),
std::move(language_switch_result),
- base::SequencedTaskRunnerHandle::Get(), callback));
+ base::SequencedTaskRunnerHandle::Get(),
+ std::move(callback)));
}
std::unique_ptr<base::ListValue> GetMinimalUILanguageList() {
@@ -461,7 +463,7 @@ std::unique_ptr<base::ListValue> GetUILanguageList(
input_method::InputMethodDescriptors descriptors =
manager->GetXkbIMEAsInputMethodDescriptor();
std::unique_ptr<base::ListValue> languages_list(GetLanguageList(
- descriptors, l10n_util::GetAvailableLocales(),
+ descriptors, l10n_util::GetLocalesWithStrings(),
most_relevant_language_codes
? *most_relevant_language_codes
: StartupCustomizationDocument::GetInstance()->configured_locales(),
@@ -566,9 +568,8 @@ std::unique_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts(
return input_methods_list;
}
-void GetKeyboardLayoutsForLocale(
- const GetKeyboardLayoutsForLocaleCallback& callback,
- const std::string& locale) {
+void GetKeyboardLayoutsForLocale(GetKeyboardLayoutsForLocaleCallback callback,
+ const std::string& locale) {
// Resolve `locale` on a background thread, then continue on the current
// thread.
std::string (*get_application_locale)(const std::string&, bool) =
@@ -578,7 +579,8 @@ void GetKeyboardLayoutsForLocale(
{base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
base::BindOnce(get_application_locale, locale,
false /* set_icu_locale */),
- base::BindOnce(&GetKeyboardLayoutsForResolvedLocale, locale, callback));
+ base::BindOnce(&GetKeyboardLayoutsForResolvedLocale, locale,
+ std::move(callback)));
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.h b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.h
index 5ca28b4b4bb..f85f931e96f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.h
@@ -19,7 +19,7 @@ class ListValue;
namespace chromeos {
-typedef base::Callback<void(
+typedef base::OnceCallback<void(
std::unique_ptr<base::ListValue> /* new_language_list */,
const std::string& /* new_language_list_locale */,
const std::string& /* new_selected_language */)>
@@ -50,7 +50,7 @@ std::unique_ptr<base::ListValue> GetUILanguageList(
// correct and has been successfully loaded.
void ResolveUILanguageList(
std::unique_ptr<locale_util::LanguageSwitchResult> language_switch_result,
- const UILanguageListResolvedCallback& callback);
+ UILanguageListResolvedCallback callback);
// Returns a minimal list of UI languages, which consists of active language
// only. It is used as a placeholder until ResolveUILanguageList() finishes
@@ -86,11 +86,10 @@ std::unique_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts(
// followed by a divider and locale-specific keyboard layouts, if any. All
// layouts supported for `locale` are returned, including those that produce
// non-Latin characters by default.
-typedef base::Callback<void(std::unique_ptr<base::ListValue>)>
+typedef base::OnceCallback<void(std::unique_ptr<base::ListValue>)>
GetKeyboardLayoutsForLocaleCallback;
-void GetKeyboardLayoutsForLocale(
- const GetKeyboardLayoutsForLocaleCallback& callback,
- const std::string& locale);
+void GetKeyboardLayoutsForLocale(GetKeyboardLayoutsForLocaleCallback callback,
+ const std::string& locale);
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc
index 63a72505d35..9de0ef44607 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc
@@ -20,15 +20,13 @@ MockInputMethodManagerWithInputMethods::
void MockInputMethodManagerWithInputMethods::AddInputMethod(
const std::string& id,
- const std::string& raw_layout,
+ const std::string& layout,
const std::string& language_code) {
- std::vector<std::string> layouts;
- layouts.push_back(raw_layout);
std::vector<std::string> languages;
languages.push_back(language_code);
descriptors_.push_back(input_method::InputMethodDescriptor(
- id, std::string(), std::string(), layouts, languages, true,
- GURL(), GURL()));
+ id, std::string(), std::string(), layout, languages, true, GURL(),
+ GURL()));
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc
index 25586cf34dd..fe337fe5d58 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc
@@ -19,6 +19,7 @@
#include "chromeos/system/fake_statistics_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ime/chromeos/component_extension_ime_manager.h"
+#include "ui/base/ime/chromeos/mock_component_extension_ime_manager_delegate.h"
namespace chromeos {
@@ -30,8 +31,8 @@ void VerifyOnlyUILanguages(const base::ListValue& list) {
ASSERT_TRUE(list.GetDictionary(i, &dict));
std::string code;
ASSERT_TRUE(dict->GetString("code", &code));
- EXPECT_NE("is", code)
- << "Icelandic is an example language which has input method "
+ EXPECT_NE("ga", code)
+ << "Irish is an example language which has input method "
<< "but can't use it as UI language.";
}
}
@@ -68,8 +69,11 @@ class L10nUtilTest : public testing::Test {
L10nUtilTest::L10nUtilTest()
: input_manager_(new MockInputMethodManagerWithInputMethods) {
chromeos::input_method::InitializeForTesting(input_manager_);
+ auto mock_component_extension_ime_manager_delegate = std::make_unique<
+ input_method::MockComponentExtensionIMEManagerDelegate>();
input_manager_->SetComponentExtensionIMEManager(
- std::make_unique<ComponentExtensionIMEManager>());
+ std::make_unique<ComponentExtensionIMEManager>(
+ std::move(mock_component_extension_ime_manager_delegate)));
base::RunLoop().RunUntilIdle();
}
@@ -82,7 +86,7 @@ void L10nUtilTest::SetInputMethods1() {
input_manager_->AddInputMethod("xkb:us::eng", "us", "en-US");
input_manager_->AddInputMethod("xkb:fr::fra", "fr", "fr");
input_manager_->AddInputMethod("xkb:be::fra", "be", "fr");
- input_manager_->AddInputMethod("xkb:is::ice", "is", "is");
+ input_manager_->AddInputMethod("xkb:ie::ga", "ga", "ga");
}
void L10nUtilTest::SetInputMethods2() {
@@ -90,7 +94,7 @@ void L10nUtilTest::SetInputMethods2() {
input_manager_->AddInputMethod("xkb:ch:fr:fra", "ch(fr)", "fr");
input_manager_->AddInputMethod("xkb:ch::ger", "ch", "de");
input_manager_->AddInputMethod("xkb:it::ita", "it", "it");
- input_manager_->AddInputMethod("xkb:is::ice", "is", "is");
+ input_manager_->AddInputMethod("xkb:ie::ga", "ga", "ga");
}
TEST_F(L10nUtilTest, GetUILanguageList) {
@@ -144,7 +148,7 @@ void InitStartupCustomizationDocumentForTesting(const std::string& manifest) {
const char kStartupManifest[] =
"{\n"
" \"version\": \"1.0\",\n"
- " \"initial_locale\" : \"fr,en-US,de,is,it\",\n"
+ " \"initial_locale\" : \"fr,en-US,de,ga,it\",\n"
" \"initial_timezone\" : \"Europe/Zurich\",\n"
" \"keyboard_layout\" : \"xkb:ch:fr:fra\",\n"
" \"registration_url\" : \"http://www.google.com\",\n"
@@ -165,7 +169,7 @@ TEST_F(L10nUtilTest, GetUILanguageListMulti) {
VerifyOnlyUILanguages(*list);
- // (4 languages (except Icelandic) + divider) = 5 + all other languages
+ // (4 languages (except Irish) + divider) = 5 + all other languages
ASSERT_LE(5u, list->GetSize());
VerifyLanguageCode(*list, 0, "fr");
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
new file mode 100644
index 00000000000..e16069a69a0
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.cc
@@ -0,0 +1,51 @@
+// 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/chromeos/login/locale_switch_screen_handler.h"
+
+#include <string>
+
+#include "base/values.h"
+#include "chrome/browser/ash/login/screens/locale_switch_screen.h"
+#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/js_calls_container.h"
+#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
+
+namespace chromeos {
+
+constexpr StaticOobeScreenId LocaleSwitchView::kScreenId;
+
+LocaleSwitchScreenHandler::LocaleSwitchScreenHandler(
+ JSCallsContainer* js_calls_container,
+ CoreOobeView* core_oobe_view)
+ : BaseScreenHandler(kScreenId, js_calls_container),
+ core_oobe_view_(core_oobe_view) {}
+
+LocaleSwitchScreenHandler::~LocaleSwitchScreenHandler() {
+ if (screen_)
+ screen_->OnViewDestroyed(this);
+}
+
+void LocaleSwitchScreenHandler::Bind(LocaleSwitchScreen* screen) {
+ BaseScreenHandler::SetBaseScreen(screen);
+ screen_ = screen;
+}
+
+void LocaleSwitchScreenHandler::Unbind() {
+ BaseScreenHandler::SetBaseScreen(nullptr);
+ screen_ = nullptr;
+}
+
+void LocaleSwitchScreenHandler::UpdateStrings() {
+ base::DictionaryValue localized_strings;
+ GetOobeUI()->GetLocalizedStrings(&localized_strings);
+ core_oobe_view_->ReloadContent(localized_strings);
+}
+
+void LocaleSwitchScreenHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {}
+
+void LocaleSwitchScreenHandler::Initialize() {}
+
+} // 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
new file mode 100644
index 00000000000..88a8b0ac71f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.h
@@ -0,0 +1,58 @@
+// 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_CHROMEOS_LOGIN_LOCALE_SWITCH_SCREEN_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOCALE_SWITCH_SCREEN_HANDLER_H_
+
+#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/js_calls_container.h"
+
+namespace chromeos {
+
+class LocaleSwitchScreen;
+
+class LocaleSwitchView {
+ public:
+ constexpr static StaticOobeScreenId kScreenId{"locale-switch"};
+
+ LocaleSwitchView() = default;
+ virtual ~LocaleSwitchView() = default;
+
+ LocaleSwitchView(const LocaleSwitchView&) = delete;
+ LocaleSwitchView& operator=(const LocaleSwitchView&) = delete;
+
+ virtual void Bind(LocaleSwitchScreen* screen) = 0;
+ virtual void Unbind() = 0;
+ virtual void UpdateStrings() = 0;
+};
+
+// A class that updates localized strings in Oobe WebUI.
+class LocaleSwitchScreenHandler : public BaseScreenHandler,
+ public LocaleSwitchView {
+ public:
+ using TView = LocaleSwitchView;
+
+ LocaleSwitchScreenHandler(JSCallsContainer* js_calls_container,
+ CoreOobeView* core_oobe_view);
+ ~LocaleSwitchScreenHandler() override;
+
+ // LocaleSwitchView:
+ void Bind(LocaleSwitchScreen* screen) override;
+ void Unbind() override;
+ void UpdateStrings() override;
+
+ // BaseScreenHandler:
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void Initialize() override;
+
+ private:
+ LocaleSwitchScreen* screen_ = nullptr;
+ CoreOobeView* core_oobe_view_ = nullptr;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LOCALE_SWITCH_SCREEN_HANDLER_H_
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 c21f11bee12..2e7a00d5a2b 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
@@ -7,10 +7,9 @@
#include "ash/public/cpp/ash_pref_names.h"
#include "base/command_line.h"
#include "base/metrics/histogram_functions.h"
-#include "chrome/browser/chromeos/login/screens/marketing_opt_in_screen.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 "chromeos/constants/chromeos_switches.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -19,6 +18,10 @@ namespace chromeos {
namespace {
+constexpr char kOptInVisibility[] = "optInVisibility";
+constexpr char kOptInDefaultState[] = "optInDefaultState";
+constexpr char kLegalFooterVisibility[] = "legalFooterVisibility";
+
void RecordShowShelfNavigationButtonsValueChange(bool enabled) {
base::UmaHistogramBoolean(
"Accessibility.CrosShelfNavigationButtonsInTabletModeChanged.OOBE",
@@ -52,8 +55,11 @@ void MarketingOptInScreenHandler::DeclareLocalizedValues(
builder->Add(
"marketingOptInGetChromebookUpdates",
IDS_LOGIN_MARKETING_OPT_IN_SCREEN_GET_CHROMEBOOK_UPDATES_SIGN_ME_UP);
- builder->Add("marketingOptInScreenAllSet",
- IDS_LOGIN_MARKETING_OPT_IN_SCREEN_ALL_SET);
+ builder->Add("marketingOptInScreenAllSet", IDS_LOGIN_GET_STARTED);
+ builder->Add("marketingOptInScreenUnsubscribeShort",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_UNSUBSCRIBE_SHORT);
+ builder->Add("marketingOptInScreenUnsubscribeLong",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_UNSUBSCRIBE_LONG);
builder->Add("marketingOptInA11yButtonLabel",
IDS_MARKETING_OPT_IN_ACCESSIBILITY_BUTTON_LABEL);
builder->Add("finalA11yPageTitle", IDS_MARKETING_OPT_IN_ACCESSIBILITY_TITLE);
@@ -71,8 +77,15 @@ void MarketingOptInScreenHandler::Bind(MarketingOptInScreen* screen) {
BaseScreenHandler::SetBaseScreen(screen);
}
-void MarketingOptInScreenHandler::Show() {
- ShowScreen(kScreenId);
+void MarketingOptInScreenHandler::Show(bool opt_in_visible,
+ bool opt_in_default_state,
+ bool legal_footer_visible) {
+ base::DictionaryValue data;
+ data.SetBoolean(kOptInVisibility, opt_in_visible);
+ data.SetBoolean(kOptInDefaultState, opt_in_default_state);
+ data.SetBoolean(kLegalFooterVisibility, legal_footer_visible);
+
+ ShowScreenWithData(kScreenId, &data);
}
void MarketingOptInScreenHandler::Hide() {
@@ -92,14 +105,6 @@ void MarketingOptInScreenHandler::UpdateA11yShelfNavigationButtonToggle(
enabled);
}
-void MarketingOptInScreenHandler::SetOptInVisibility(bool visible) {
- CallJS("login.MarketingOptInScreen.setOptInVisibility", visible);
-}
-
-void MarketingOptInScreenHandler::SetEmailToggleState(bool checked) {
- CallJS("login.MarketingOptInScreen.setEmailToggleState", checked);
-}
-
void MarketingOptInScreenHandler::Initialize() {}
void MarketingOptInScreenHandler::RegisterMessages() {
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 a4898e6ba0b..84dbdb3e7bd 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
@@ -25,7 +25,9 @@ class MarketingOptInScreenView {
virtual void Bind(MarketingOptInScreen* screen) = 0;
// Shows the contents of the screen.
- virtual void Show() = 0;
+ 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;
@@ -33,15 +35,10 @@ class MarketingOptInScreenView {
// Sets whether the a11y Settings button is visible.
virtual void UpdateA11ySettingsButtonVisibility(bool shown) = 0;
- // Sets whether the a11y setting for showing shelf navigation buttons is
+ // Sets whether the a11y setting for showing shelf navigation buttons is.
// toggled on or off.
virtual void UpdateA11yShelfNavigationButtonToggle(bool enabled) = 0;
- // Sets the visibility of the marketing email opt-in
- virtual void SetOptInVisibility(bool visible) = 0;
-
- // Updates the toggle state for the email opt-in
- virtual void SetEmailToggleState(bool checked) = 0;
};
// The sole implementation of the MarketingOptInScreenView, using WebUI.
@@ -59,12 +56,12 @@ class MarketingOptInScreenHandler : public BaseScreenHandler,
// MarketingOptInScreenView:
void Bind(MarketingOptInScreen* screen) override;
- void Show() override;
+ void Show(bool opt_in_visible,
+ bool opt_in_default_state,
+ bool legal_footer_visible) override;
void Hide() override;
void UpdateA11ySettingsButtonVisibility(bool shown) override;
void UpdateA11yShelfNavigationButtonToggle(bool enabled) override;
- void SetOptInVisibility(bool visible) override;
- void SetEmailToggleState(bool checked) override;
private:
// BaseScreenHandler:
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 030ddf0c146..3e95a109a38 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
@@ -4,7 +4,8 @@
#include "chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h"
-#include "chrome/browser/chromeos/login/screens/multidevice_setup_screen.h"
+#include "ash/constants/ash_features.h"
+#include "chrome/browser/ash/login/screens/multidevice_setup_screen.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
@@ -36,6 +37,12 @@ void MultiDeviceSetupScreenHandler::Show() {
FireWebUIListener("multidevice_setup.initializeSetupFlow");
}
+void MultiDeviceSetupScreenHandler::GetAdditionalParameters(
+ base::DictionaryValue* dict) {
+ dict->SetKey("wifiSyncEnabled",
+ base::Value(ash::features::IsWifiSyncAndroidEnabled()));
+}
+
void MultiDeviceSetupScreenHandler::Hide() {}
void MultiDeviceSetupScreenHandler::Initialize() {}
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 e132f7f536e..5612814d2f6 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
@@ -16,7 +16,7 @@ class MultiDeviceSetupScreen;
// WebUI representation.
class MultiDeviceSetupScreenView {
public:
- constexpr static StaticOobeScreenId kScreenId{"multidevice-setup"};
+ constexpr static StaticOobeScreenId kScreenId{"multidevice-setup-screen"};
virtual ~MultiDeviceSetupScreenView() = default;
@@ -37,6 +37,7 @@ class MultiDeviceSetupScreenHandler : public BaseScreenHandler,
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
+ void GetAdditionalParameters(base::DictionaryValue* dict) override;
// MultiDeviceSetupScreenView:
void Bind(MultiDeviceSetupScreen* screen) override;
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 02031c7bb56..416e9972840 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
@@ -6,7 +6,6 @@
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_type_pattern.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 007078bce68..16b7d10372d 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
@@ -7,9 +7,10 @@
#include <stddef.h>
#include "base/values.h"
-#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
-#include "chrome/browser/chromeos/login/screens/network_screen.h"
+#include "chrome/browser/ash/login/demo_mode/demo_setup_controller.h"
+#include "chrome/browser/ash/login/screens/network_screen.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chrome/grit/generated_resources.h"
@@ -98,10 +99,12 @@ void NetworkScreenHandler::DeclareLocalizedValues(
builder->Add("offlineDemoSetupListItemName",
IDS_NETWORK_OFFLINE_DEMO_SETUP_LIST_ITEM_NAME);
network_element::AddLocalizedValuesToBuilder(builder);
+ cellular_setup::AddLocalizedValuesToBuilder(builder);
}
void NetworkScreenHandler::GetAdditionalParameters(
base::DictionaryValue* dict) {
+ cellular_setup::AddNonStringLoadTimeDataToDict(dict);
}
void NetworkScreenHandler::Initialize() {
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 1e7818bec74..129cb357ffb 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
@@ -6,9 +6,9 @@
#include "base/bind.h"
#include "base/notreached.h"
+#include "chrome/browser/ash/login/screens/network_error.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
-#include "chrome/browser/chromeos/login/screens/network_error.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
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 1459d6cfe9b..7eff618a214 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
@@ -14,7 +14,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
-#include "chrome/browser/chromeos/login/screens/network_error.h"
+#include "chrome/browser/ash/login/screens/network_error.h"
#include "chrome/browser/chromeos/login/ui/captive_portal_window_proxy.h"
#include "chromeos/network/network_state_handler_observer.h"
#include "chromeos/network/portal_detector/network_portal_detector.h"
@@ -104,4 +104,9 @@ class NetworkStateInformer
} // namespace chromeos
+// TODO(https://crbug.com/1164001): remove when moved to ash.
+namespace ash {
+using ::chromeos::NetworkStateInformer;
+}
+
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_STATE_INFORMER_H_
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
new file mode 100644
index 00000000000..9e342677225
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.cc
@@ -0,0 +1,111 @@
+// 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/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"
+#include "components/user_manager/known_user.h"
+#include "google_apis/gaia/gaia_auth_util.h"
+
+namespace chromeos {
+
+constexpr StaticOobeScreenId OfflineLoginView::kScreenId;
+
+OfflineLoginScreenHandler::OfflineLoginScreenHandler(
+ JSCallsContainer* js_calls_container)
+ : BaseScreenHandler(kScreenId, js_calls_container) {
+ set_user_acted_method_path("login.OfflineLoginScreen.userActed");
+}
+
+OfflineLoginScreenHandler::~OfflineLoginScreenHandler() {
+ if (screen_)
+ screen_->OnViewDestroyed(this);
+}
+
+void OfflineLoginScreenHandler::RegisterMessages() {
+ BaseScreenHandler::RegisterMessages();
+ AddCallback("completeOfflineAuthentication",
+ &OfflineLoginScreenHandler::HandleCompleteAuth);
+ AddCallback("OfflineLogin.onEmailSubmitted",
+ &OfflineLoginScreenHandler::HandleEmailSubmitted);
+}
+
+void OfflineLoginScreenHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("offlineLoginEmail", IDS_OFFLINE_LOGIN_EMAIL);
+ builder->Add("offlineLoginPassword", IDS_OFFLINE_LOGIN_PASSWORD);
+ builder->Add("offlineLoginInvalidEmail", IDS_OFFLINE_LOGIN_INVALID_EMAIL);
+ builder->Add("offlineLoginInvalidPassword",
+ IDS_OFFLINE_LOGIN_INVALID_PASSWORD);
+ builder->Add("offlineLoginNextBtn", IDS_OFFLINE_LOGIN_NEXT_BUTTON_TEXT);
+ builder->Add("offlineLoginForgotPasswordBtn",
+ IDS_OFFLINE_LOGIN_FORGOT_PASSWORD_BUTTON_TEXT);
+ builder->Add("offlineLoginForgotPasswordDlg",
+ IDS_OFFLINE_LOGIN_FORGOT_PASSWORD_DIALOG_TEXT);
+ builder->Add("offlineLoginCloseBtn", IDS_OFFLINE_LOGIN_CLOSE_BUTTON_TEXT);
+ builder->Add("offlineLoginWarningTitle", IDS_OFFLINE_LOGIN_WARNING_TITLE);
+ builder->Add("offlineLoginWarning", IDS_OFFLINE_LOGIN_WARNING_TEXT);
+ builder->Add("offlineLoginOkBtn", IDS_OFFLINE_LOGIN_OK_BUTTON_TEXT);
+}
+
+void OfflineLoginScreenHandler::Initialize() {
+ if (show_on_init_) {
+ show_on_init_ = false;
+ Show();
+ }
+}
+
+void OfflineLoginScreenHandler::Show() {
+ if (!page_is_ready()) {
+ show_on_init_ = true;
+ return;
+ }
+ ShowScreen(OfflineLoginView::kScreenId);
+}
+
+void OfflineLoginScreenHandler::Hide() {
+ Reset();
+}
+
+void OfflineLoginScreenHandler::Bind(OfflineLoginScreen* screen) {
+ screen_ = screen;
+ BaseScreenHandler::SetBaseScreen(screen_);
+}
+
+void OfflineLoginScreenHandler::Unbind() {
+ screen_ = nullptr;
+ BaseScreenHandler::SetBaseScreen(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", params);
+}
+
+void OfflineLoginScreenHandler::ShowPasswordPage() {
+ CallJS("login.OfflineLoginScreen.proceedToPasswordPage");
+}
+
+void OfflineLoginScreenHandler::ShowOnlineRequiredDialog() {
+ CallJS("login.OfflineLoginScreen.showOnlineRequiredDialog");
+}
+
+} // 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
new file mode 100644
index 00000000000..2bade6eabd9
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h
@@ -0,0 +1,89 @@
+// 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_CHROMEOS_LOGIN_OFFLINE_LOGIN_SCREEN_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_OFFLINE_LOGIN_SCREEN_HANDLER_H_
+
+#include "chrome/browser/ash/login/screens/offline_login_screen.h"
+#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
+
+namespace chromeos {
+
+class OfflineLoginScreen;
+
+class OfflineLoginView {
+ public:
+ constexpr static StaticOobeScreenId kScreenId{"offline-login"};
+
+ OfflineLoginView() = default;
+ virtual ~OfflineLoginView() = default;
+
+ // Shows the contents of the screen.
+ virtual void Show() = 0;
+
+ // Hide the contents of the screen.
+ virtual void Hide() = 0;
+
+ // Binds |screen| to the view.
+ virtual void Bind(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;
+
+ // Shows error pop-up when the user cannot login offline.
+ virtual void ShowOnlineRequiredDialog() = 0;
+};
+
+class OfflineLoginScreenHandler : public BaseScreenHandler,
+ public OfflineLoginView {
+ public:
+ using TView = OfflineLoginView;
+ explicit OfflineLoginScreenHandler(JSCallsContainer* js_calls_container);
+ ~OfflineLoginScreenHandler() override;
+
+ OfflineLoginScreenHandler(const OfflineLoginScreenHandler&) = delete;
+ OfflineLoginScreenHandler& operator=(const OfflineLoginScreenHandler&) =
+ delete;
+
+ private:
+ void HandleCompleteAuth(const std::string& username,
+ const std::string& password);
+ void HandleEmailSubmitted(const std::string& username);
+
+ // OfflineLoginView:
+ void Show() override;
+ void Hide() override;
+ void Bind(OfflineLoginScreen* screen) override;
+ void Unbind() override;
+ void Reset() override;
+ void LoadParams(base::DictionaryValue& params) override;
+ void ShowPasswordPage() override;
+ void ShowOnlineRequiredDialog() override;
+
+ // BaseScreenHandler:
+ void RegisterMessages() override;
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void Initialize() override;
+
+ OfflineLoginScreen* screen_ = nullptr;
+
+ // Whether the screen should be shown right after initialization.
+ bool show_on_init_ = false;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_OFFLINE_LOGIN_SCREEN_HANDLER_H_
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 0be1575b160..7402f822d68 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
@@ -15,6 +15,7 @@
#include "chromeos/dbus/util/version_loader.h"
#include "chromeos/login/auth/challenge_response/cert_utils.h"
#include "chromeos/login/auth/cryptohome_key_constants.h"
+#include "components/sync/driver/sync_driver_switches.h"
#include "content/public/browser/storage_partition.h"
#include "google_apis/gaia/gaia_urls.h"
#include "ui/base/l10n/l10n_util.h"
@@ -74,6 +75,8 @@ void SetCookieForPartition(
std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create(
gaia_url, gaps_cookie_value, base::Time::Now(),
base::nullopt /* server_time */));
+ if (!cc)
+ return;
const net::CookieOptions options = net::CookieOptions::MakeAllInclusive();
partition->GetCookieManagerForBrowserProcess()->SetCanonicalCookie(
@@ -107,6 +110,7 @@ bool BuildUserContextForGaiaSignIn(
bool using_saml_api,
const std::string& password,
const SamlPasswordAttributes& password_attributes,
+ const base::Optional<SyncTrustedVaultKeys>& sync_trusted_vault_keys,
const LoginClientCertUsageObserver&
extension_provided_client_cert_usage_observer,
UserContext* user_context,
@@ -148,6 +152,11 @@ bool BuildUserContextForGaiaSignIn(
user_context->SetSamlPasswordAttributes(password_attributes);
}
}
+
+ if (sync_trusted_vault_keys.has_value()) {
+ user_context->SetSyncTrustedVaultKeys(*sync_trusted_vault_keys);
+ }
+
return true;
}
@@ -244,4 +253,4 @@ void OnlineLoginHelper::OnGetCookiesForCompleteAuthentication(
std::move(complete_login_callback_).Run(user_context);
}
-} // namespace chromeos \ No newline at end of file
+} // namespace chromeos
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 fbc01560b42..4e00635cf93 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
@@ -7,6 +7,7 @@
#include <string>
+#include "base/optional.h"
#include "chrome/browser/chromeos/login/login_client_cert_usage_observer.h"
#include "chrome/browser/chromeos/login/signin_partition_manager.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
@@ -20,6 +21,10 @@
#include "services/network/public/mojom/cookie_manager.mojom.h"
namespace chromeos {
+
+class SyncTrustedVaultKeys;
+class UserContext;
+
namespace login {
// A class that's used to specify the way how Gaia should be loaded.
@@ -29,9 +34,6 @@ struct GaiaContext {
// Forces Gaia to reload.
bool force_reload = false;
- // Whether Gaia should be loaded in offline mode.
- bool use_offline = false;
-
// Email of the current user.
std::string email;
@@ -73,6 +75,7 @@ bool BuildUserContextForGaiaSignIn(
bool using_saml_api,
const std::string& password,
const SamlPasswordAttributes& password_attributes,
+ const base::Optional<SyncTrustedVaultKeys>& sync_trusted_vault_keys,
const LoginClientCertUsageObserver&
extension_provided_client_cert_usage_observer,
UserContext* user_context,
@@ -133,4 +136,4 @@ class OnlineLoginHelper : public network::mojom::CookieChangeListener {
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ONLINE_LOGIN_HELPER_H_ \ No newline at end of file
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ONLINE_LOGIN_HELPER_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 1fd42972483..c79de4076ba 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
@@ -69,15 +69,17 @@ void OobeDisplayChooser::MaybeMoveToTouchDisplay() {
if (device_data_manager->AreDeviceListsComplete() &&
device_data_manager->AreTouchscreenTargetDisplaysValid()) {
MoveToTouchDisplay();
- } else if (!scoped_observer_.IsObserving(device_data_manager)) {
- scoped_observer_.Add(device_data_manager);
+ } else if (!scoped_observation_.IsObserving()) {
+ scoped_observation_.Observe(device_data_manager);
+ } else {
+ DCHECK(scoped_observation_.IsObservingSource(device_data_manager));
}
}
void OobeDisplayChooser::MoveToTouchDisplay() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- scoped_observer_.RemoveAll();
+ scoped_observation_.Reset();
const ui::DeviceDataManager* device_data_manager =
ui::DeviceDataManager::GetInstance();
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 d6b373c8126..e79cc51208d 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
@@ -8,7 +8,7 @@
#include "ash/public/mojom/cros_display_config.mojom.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/events/devices/device_data_manager.h"
@@ -48,8 +48,8 @@ class OobeDisplayChooser : public ui::InputDeviceEventObserver {
void OnTouchDeviceAssociationChanged() override;
void OnDeviceListsComplete() override;
- ScopedObserver<ui::DeviceDataManager, ui::InputDeviceEventObserver>
- scoped_observer_{this};
+ base::ScopedObservation<ui::DeviceDataManager, ui::InputDeviceEventObserver>
+ scoped_observation_{this};
mojo::Remote<ash::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_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_browsertest.cc
index 5ec23430ca4..191064c03c7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_browsertest.cc
@@ -4,11 +4,11 @@
#include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h"
+#include "ash/constants/ash_switches.h"
#include "ash/shell.h"
#include "base/run_loop.h"
#include "chrome/browser/chromeos/login/test/oobe_base_test.h"
#include "chrome/browser/lifetime/application_lifetime.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "content/public/test/browser_test.h"
#include "ui/display/display.h"
#include "ui/display/manager/display_manager.h"
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 80a7a372799..66f1bac3cd9 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
@@ -10,30 +10,31 @@
#include <string>
#include <utility>
+#include "ash/constants/ash_features.h"
+#include "ash/constants/ash_switches.h"
#include "ash/public/cpp/network_config_service.h"
#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
+#include "chrome/browser/ash/login/enrollment/auto_enrollment_check_screen_view.h"
+#include "chrome/browser/ash/login/enrollment/enrollment_screen_view.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.h"
+#include "chrome/browser/ash/login/screens/error_screen.h"
+#include "chrome/browser/ash/system/input_device_settings.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
-#include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen_view.h"
-#include "chrome/browser/chromeos/login/enrollment/enrollment_screen_view.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
-#include "chrome/browser/chromeos/login/screens/error_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_service_factory.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/enrollment_requisition_manager.h"
-#include "chrome/browser/chromeos/settings/shutdown_policy_handler.h"
-#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -64,11 +65,13 @@
#include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/locale_switch_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.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/chromeos/login/oobe_display_chooser.h"
#include "chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h"
@@ -80,15 +83,16 @@
#include "chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
-#include "chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h"
#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"
#include "chrome/common/chrome_constants.h"
@@ -99,7 +103,6 @@
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/component_extension_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/services/multidevice_setup/multidevice_setup_service.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" // nogncheck
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
@@ -122,11 +125,9 @@ namespace chromeos {
namespace {
-const char* kKnownDisplayTypes[] = {OobeUI::kAppLaunchSplashDisplay,
- OobeUI::kGaiaSigninDisplay,
- OobeUI::kLoginDisplay,
- OobeUI::kOobeDisplay,
- OobeUI::kUserAddingDisplay};
+const char* kKnownDisplayTypes[] = {
+ OobeUI::kAppLaunchSplashDisplay, OobeUI::kGaiaSigninDisplay,
+ OobeUI::kLoginDisplay, OobeUI::kOobeDisplay};
// Sorted
constexpr char kArcAssistantLogoPath[] = "assistant_logo.png";
@@ -144,12 +145,39 @@ constexpr char kOobeJSPath[] = "oobe.js";
constexpr char kProductLogoPath[] = "product-logo.png";
constexpr char kRecommendAppListViewHTMLPath[] = "recommend_app_list_view.html";
constexpr char kRecommendAppListViewJSPath[] = "recommend_app_list_view.js";
+constexpr char kTestAPIJSPath[] = "test_api.js";
+constexpr char kWebviewSamlInjectedJSPath[] = "webview_saml_injected.js";
+
// Components
+constexpr char kOobeSharedVarsCssHTML[] =
+ "components/oobe_shared_vars_css.html";
+constexpr char kOobeCustomVarsCssHTML[] =
+ "components/oobe_custom_vars_css.html";
constexpr char kCommonStylesHTML[] = "components/common_styles.html";
constexpr char kI18nBehaviorHTML[] = "components/oobe_i18n_behavior.html";
constexpr char kI18nBehaviorJS[] = "components/oobe_i18n_behavior.js";
+constexpr char kI18nSetupHTML[] = "components/i18n_setup.html";
+constexpr char kDialogHostBehaviorHTML[] =
+ "components/oobe_dialog_host_behavior.html";
+constexpr char kDialogHostBehaviorJS[] =
+ "components/oobe_dialog_host_behavior.js";
+constexpr char kFocusBehaviorHTML[] = "components/oobe_focus_behavior.html";
+constexpr char kFocusBehaviorJS[] = "components/oobe_focus_behavior.js";
+constexpr char kScrollableBehaviorHTML[] =
+ "components/oobe_scrollable_behavior.html";
+constexpr char kScrollableBehaviorJS[] =
+ "components/oobe_scrollable_behavior.js";
constexpr char kHDIronIconHTML[] = "components/hd_iron_icon.html";
constexpr char kHDIronIconJS[] = "components/hd_iron_icon.js";
+constexpr char kOobeAdaptiveDialogHTML[] =
+ "components/oobe_adaptive_dialog.html";
+constexpr char kOobeAdaptvieDialogJS[] = "components/oobe_adaptive_dialog.js";
+constexpr char kOobeContentDialogHTML[] = "components/oobe_content_dialog.html";
+constexpr char kOobeContentDialogJS[] = "components/oobe_content_dialog.js";
+constexpr char kOobeDialogHTML[] = "components/oobe_dialog.html";
+constexpr char kOobeDialogJS[] = "components/oobe_dialog.js";
+constexpr char kOobeLoadingDialogHTML[] = "components/oobe_loading_dialog.html";
+constexpr char kOobeLoadingDialogJS[] = "components/oobe_loading_dialog.js";
constexpr char kOobeCarouselHTML[] = "components/oobe_carousel.html";
constexpr char kOobeCarouselJS[] = "components/oobe_carousel.js";
constexpr char kOobeSlideHTML[] = "components/oobe_slide.html";
@@ -231,6 +259,8 @@ void AddGestureNavigationResources(content::WebUIDataSource* source) {
void AddMarketingOptInResources(content::WebUIDataSource* source) {
source->AddResourcePath("all_set.json",
IDR_MARKETING_OPT_IN_ALL_SET_ANIMATION);
+ source->AddResourcePath("all_set_new_noloop.json",
+ IDR_MARKETING_OPT_IN_ALL_SET_ANIMATION_NEW_NOLOOP);
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';");
}
@@ -272,6 +302,18 @@ void AddFingerprintResources(content::WebUIDataSource* source) {
source->AddBoolean("useLottieAnimationForFingerprint", is_lottie_animation);
}
+void AddMultiDeviceSetupResources(content::WebUIDataSource* source) {
+ source->AddResourcePath("multidevice_setup.json",
+ IDR_MULTIDEVICE_SETUP_ANIMATION);
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';");
+}
+
+void AddAppDownloadingResources(content::WebUIDataSource* source) {
+ source->AddResourcePath("downloading_apps.json",
+ IDR_APPS_DOWNLOADING_ANIMATION);
+}
+
void AddDebuggerResources(content::WebUIDataSource* source) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool enable_debugger =
@@ -288,6 +330,17 @@ void AddDebuggerResources(content::WebUIDataSource* source) {
}
}
+void AddTestAPIResources(content::WebUIDataSource* source) {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ bool enable_test_api =
+ command_line->HasSwitch(::chromeos::switches::kEnableOobeTestAPI);
+ if (enable_test_api) {
+ source->AddResourcePath(kTestAPIJSPath, IDR_OOBE_TEST_API_JS);
+ } else {
+ source->AddResourcePath(kTestAPIJSPath, IDR_OOBE_TEST_API_STUB_JS);
+ }
+}
+
// Default and non-shared resource definition for kOobeDisplay display type.
// chrome://oobe/oobe
void AddOobeDisplayTypeDefaultResources(content::WebUIDataSource* source) {
@@ -340,9 +393,14 @@ content::WebUIDataSource* CreateOobeUIDataSource(
AddAssistantScreensResources(source);
AddGestureNavigationResources(source);
AddMarketingOptInResources(source);
+ AddMultiDeviceSetupResources(source);
+ AddAppDownloadingResources(source);
AddDebuggerResources(source);
+ AddTestAPIResources(source);
+ source->AddResourcePath(kWebviewSamlInjectedJSPath,
+ IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS);
source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS);
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ObjectSrc, "object-src chrome:;");
@@ -376,7 +434,6 @@ const char OobeUI::kGaiaSigninDisplay[] = "gaia-signin";
const char OobeUI::kLockDisplay[] = "lock";
const char OobeUI::kLoginDisplay[] = "login";
const char OobeUI::kOobeDisplay[] = "oobe";
-const char OobeUI::kUserAddingDisplay[] = "user-adding";
void OobeUI::ConfigureOobeDisplay() {
network_state_informer_ = new NetworkStateInformer();
@@ -435,10 +492,13 @@ void OobeUI::ConfigureOobeDisplay() {
AddScreenHandler(std::make_unique<EnrollmentScreenHandler>(
js_calls_container_.get(), network_state_informer_, error_screen));
- AddScreenHandler(std::make_unique<TermsOfServiceScreenHandler>(
+ AddScreenHandler(std::make_unique<LocaleSwitchScreenHandler>(
js_calls_container_.get(), core_handler_));
AddScreenHandler(
+ std::make_unique<TermsOfServiceScreenHandler>(js_calls_container_.get()));
+
+ AddScreenHandler(
std::make_unique<SyncConsentScreenHandler>(js_calls_container_.get()));
AddScreenHandler(std::make_unique<ArcTermsOfServiceScreenHandler>(
@@ -451,9 +511,6 @@ void OobeUI::ConfigureOobeDisplay() {
std::make_unique<AppDownloadingScreenHandler>(js_calls_container_.get()));
AddScreenHandler(
- std::make_unique<UserBoardScreenHandler>(js_calls_container_.get()));
-
- AddScreenHandler(
std::make_unique<DemoSetupScreenHandler>(js_calls_container_.get()));
AddScreenHandler(std::make_unique<FamilyLinkNoticeScreenHandler>(
@@ -476,7 +533,7 @@ void OobeUI::ConfigureOobeDisplay() {
auto password_change_handler =
std::make_unique<ActiveDirectoryPasswordChangeScreenHandler>(
- js_calls_container_.get(), core_handler_);
+ js_calls_container_.get());
AddScreenHandler(std::make_unique<GaiaScreenHandler>(
js_calls_container_.get(), core_handler_, network_state_informer_));
@@ -484,6 +541,9 @@ void OobeUI::ConfigureOobeDisplay() {
AddScreenHandler(std::make_unique<SignInFatalErrorScreenHandler>(
js_calls_container_.get()));
+ AddScreenHandler(
+ std::make_unique<OfflineLoginScreenHandler>(js_calls_container_.get()));
+
AddScreenHandler(std::move(password_change_handler));
auto signin_screen_handler = std::make_unique<SigninScreenHandler>(
@@ -591,6 +651,7 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
AddScreenHandler(
std::make_unique<PinSetupScreenHandler>(js_calls_container_.get()));
+ web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool enable_debugger =
@@ -604,6 +665,13 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
std::make_unique<DebugOverlayHandler>(js_calls_container_.get()));
}
+ bool enable_test_api =
+ command_line->HasSwitch(::chromeos::switches::kEnableOobeTestAPI);
+ if (enable_test_api) {
+ AddWebUIHandler(
+ std::make_unique<OobeTestAPIHandler>(js_calls_container_.get()));
+ }
+
base::DictionaryValue localized_strings;
GetLocalizedStrings(&localized_strings);
@@ -616,6 +684,7 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
OobeUI::~OobeUI() {
for (Observer& observer : observer_list_)
observer.OnDestroyingOobeUI();
+ VLOG(4) << "~OobeUI";
}
// static
@@ -626,14 +695,78 @@ void OobeUI::AddOobeComponents(content::WebUIDataSource* source,
IDR_OOBE_COMPONENTS_I18N_BEHAVIOR_HTML);
source->AddResourcePath(kI18nBehaviorJS,
IDR_OOBE_COMPONENTS_I18N_BEHAVIOR_JS);
+ source->AddResourcePath(kI18nSetupHTML, IDR_OOBE_COMPONENTS_I18N_SETUP_HTML);
+ source->AddResourcePath(kDialogHostBehaviorHTML,
+ IDR_OOBE_COMPONENTS_DIALOG_HOST_BEHAVIOR_HTML);
+ source->AddResourcePath(kDialogHostBehaviorJS,
+ IDR_OOBE_COMPONENTS_DIALOG_HOST_BEHAVIOR_JS);
+ source->AddResourcePath(kFocusBehaviorHTML,
+ IDR_OOBE_COMPONENTS_FOCUS_BEHAVIOR_HTML);
+ source->AddResourcePath(kFocusBehaviorJS,
+ IDR_OOBE_COMPONENTS_FOCUS_BEHAVIOR_JS);
+ source->AddResourcePath(kScrollableBehaviorHTML,
+ IDR_OOBE_COMPONENTS_SCROLLABLE_BEHAVIOR_HTML);
+ source->AddResourcePath(kScrollableBehaviorJS,
+ IDR_OOBE_COMPONENTS_SCROLLABLE_BEHAVIOR_JS);
source->AddResourcePath(kCommonStylesHTML,
IDR_OOBE_COMPONENTS_COMMON_STYLES_HTML);
+ source->AddResourcePath(kOobeSharedVarsCssHTML,
+ IDR_OOBE_COMPONENTS_OOBE_SHARED_VARS_CSS_HTML);
source->AddResourcePath(kHDIronIconHTML,
IDR_OOBE_COMPONENTS_HD_IRON_ICON_HTML);
source->AddResourcePath(kHDIronIconJS, IDR_OOBE_COMPONENTS_HD_IRON_ICON_JS);
+ source->AddResourcePath(kOobeDialogHTML,
+ IDR_OOBE_COMPONENTS_OOBE_DIALOG_HTML);
+ source->AddResourcePath(kOobeDialogJS, IDR_OOBE_COMPONENTS_OOBE_DIALOG_JS);
+ source->AddResourcePath(kOobeLoadingDialogHTML,
+ IDR_OOBE_COMPONENTS_OOBE_LOADING_DIALOG_HTML);
+ source->AddResourcePath(kOobeLoadingDialogJS,
+ IDR_OOBE_COMPONENTS_OOBE_LOADING_DIALOG_JS);
+
+ if (features::IsNewOobeLayoutEnabled()) {
+ if (policy::EnrollmentRequisitionManager::IsRemoraRequisition()) {
+ source->AddResourcePath(
+ kOobeCustomVarsCssHTML,
+ IDR_OOBE_COMPONENTS_OOBE_CUSTOM_VARS_REMORA_CSS_HTML);
+ } else {
+ source->AddResourcePath(kOobeCustomVarsCssHTML,
+ IDR_OOBE_COMPONENTS_OOBE_CUSTOM_VARS_CSS_HTML);
+ }
+ } else {
+ source->AddResourcePath(kOobeCustomVarsCssHTML,
+ IDR_OOBE_COMPONENTS_OOBE_CUSTOM_VARS_OLD_CSS_HTML);
+ }
+
+ if (features::IsNewOobeLayoutEnabled()) {
+ source->AddResourcePath(kOobeAdaptiveDialogHTML,
+ IDR_OOBE_COMPONENTS_OOBE_ADAPTIVE_DIALOG_HTML);
+ source->AddResourcePath(kOobeAdaptvieDialogJS,
+ IDR_OOBE_COMPONENTS_OOBE_ADAPTIVE_DIALOG_JS);
+ source->AddResourcePath(kOobeContentDialogHTML,
+ IDR_OOBE_COMPONENTS_OOBE_CONTENT_DIALOG_HTML);
+ source->AddResourcePath(kOobeContentDialogJS,
+ IDR_OOBE_COMPONENTS_OOBE_CONTENT_DIALOG_JS);
+
+ source->AddResourcePath("welcome_screen_animation.json",
+ IDR_LOGIN_WELCOME_SCREEN_ANIMATION);
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::WorkerSrc,
+ "worker-src blob: 'self';");
+
+ } else {
+ source->AddResourcePath(kOobeAdaptiveDialogHTML,
+ IDR_OOBE_COMPONENTS_OOBE_ADAPTIVE_DIALOG_OLD_HTML);
+ source->AddResourcePath(kOobeAdaptvieDialogJS,
+ IDR_OOBE_COMPONENTS_OOBE_ADAPTIVE_DIALOG_OLD_JS);
+ source->AddResourcePath(kOobeContentDialogHTML,
+ IDR_OOBE_COMPONENTS_OOBE_CONTENT_DIALOG_OLD_HTML);
+ source->AddResourcePath(kOobeContentDialogJS,
+ IDR_OOBE_COMPONENTS_OOBE_CONTENT_DIALOG_OLD_JS);
+ }
+
source->AddResourcePath(kOobeCarouselHTML,
IDR_OOBE_COMPONENTS_OOBE_CAROUSEL_HTML);
source->AddResourcePath(kOobeCarouselJS,
@@ -680,7 +813,7 @@ void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
localized_strings->SetBoolean(
"changePictureVideoModeEnabled",
- base::FeatureList::IsEnabled(features::kChangePictureVideoMode));
+ base::FeatureList::IsEnabled(::features::kChangePictureVideoMode));
}
void OobeUI::AddWebUIHandler(std::unique_ptr<BaseWebUIHandler> handler) {
@@ -699,9 +832,7 @@ void OobeUI::InitializeHandlers() {
js_calls_container_->ExecuteDeferredJSCalls(web_ui());
ready_ = true;
- for (size_t i = 0; i < ready_callbacks_.size(); ++i)
- ready_callbacks_[i].Run();
- ready_callbacks_.clear();
+ ready_callbacks_.Notify();
for (BaseWebUIHandler* handler : webui_only_handlers_)
handler->InitializeBase();
@@ -727,9 +858,9 @@ bool OobeUI::IsScreenInitialized(OobeScreenId screen) {
return false;
}
-bool OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) {
+bool OobeUI::IsJSReady(base::OnceClosure display_is_ready_callback) {
if (!ready_)
- ready_callbacks_.push_back(display_is_ready_callback);
+ ready_callbacks_.AddUnsafe(std::move(display_is_ready_callback));
return ready_;
}
@@ -760,10 +891,6 @@ void OobeUI::ForwardAccelerator(std::string accelerator_name) {
core_handler_->ForwardAccelerator(accelerator_name);
}
-void OobeUI::ResetSigninScreenHandlerDelegate() {
- signin_screen_handler_->SetDelegate(nullptr);
-}
-
gfx::NativeView OobeUI::GetNativeView() {
return web_ui()->GetWebContents()->GetNativeView();
}
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 f25e7211fef..79ef6ec761b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
@@ -45,13 +45,12 @@ class SigninScreenHandlerDelegate;
class OobeUI : public ui::MojoWebUIController {
public:
// List of known types of OobeUI. Type added as path in chrome://oobe url, for
- // example chrome://oobe/user-adding.
+ // example chrome://oobe/login.
static const char kAppLaunchSplashDisplay[];
static const char kGaiaSigninDisplay[];
static const char kLockDisplay[];
static const char kLoginDisplay[];
static const char kOobeDisplay[];
- static const char kUserAddingDisplay[];
class Observer {
public:
@@ -83,7 +82,7 @@ class OobeUI : public ui::MojoWebUIController {
bool IsScreenInitialized(OobeScreenId screen);
- bool IsJSReady(const base::Closure& display_is_ready_callback);
+ bool IsJSReady(base::OnceClosure display_is_ready_callback);
// Shows or hides OOBE UI elements.
void ShowOobeUI(bool show);
@@ -94,9 +93,6 @@ class OobeUI : public ui::MojoWebUIController {
// Forwards an accelerator to the webui to be handled.
void ForwardAccelerator(std::string accelerator_name);
- // Resets the delegate set in ShowSigninScreen.
- void ResetSigninScreenHandlerDelegate();
-
gfx::NativeView GetNativeView();
gfx::NativeWindow GetTopLevelNativeWindow();
@@ -207,7 +203,7 @@ class OobeUI : public ui::MojoWebUIController {
bool ready_ = false;
// Callbacks to notify when JS part is fully loaded and ready to accept calls.
- std::vector<base::Closure> ready_callbacks_;
+ base::OnceClosureList ready_callbacks_;
// List of registered observers.
base::ObserverList<Observer>::Unchecked observer_list_;
@@ -225,4 +221,9 @@ class OobeUI : public ui::MojoWebUIController {
} // namespace chromeos
+// TODO(https://crbug.com/1164001): remove when moved to ash.
+namespace ash {
+using ::chromeos::OobeUI;
+}
+
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_OOBE_UI_H_
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 c5083dfc154..9ee09aac98d 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
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/login/packaged_license_screen_handler.h"
-#include "chrome/browser/chromeos/login/screens/packaged_license_screen.h"
+#include "chrome/browser/ash/login/screens/packaged_license_screen.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
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 e57488b893e..190aa4ce0a6 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
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/login/parental_handoff_screen_handler.h"
-#include "chrome/browser/chromeos/login/screens/parental_handoff_screen.h"
+#include "chrome/browser/ash/login/screens/parental_handoff_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/js_calls_container.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
@@ -15,8 +15,7 @@ namespace chromeos {
namespace {
-constexpr char kTitle[] = "title";
-constexpr char kSubTitle[] = "subtitle";
+constexpr char kUsername[] = "username";
} // namespace
@@ -38,15 +37,17 @@ void ParentalHandoffScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("parentalHandoffDialogNextButton",
IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_NEXT_BUTTON);
+ builder->Add("parentalHandoffDialogTitle",
+ IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_TITLE);
+ builder->Add("parentalHandoffDialogSubtitle",
+ IDS_LOGIN_PARENTAL_HANDOFF_SCREEN_SUBTITLE);
}
void ParentalHandoffScreenHandler::Initialize() {}
-void ParentalHandoffScreenHandler::Show(const base::string16& title,
- const base::string16& subtitle) {
+void ParentalHandoffScreenHandler::Show(const base::string16& username) {
base::DictionaryValue data;
- data.SetString(kTitle, title);
- data.SetString(kSubTitle, subtitle);
+ data.SetString(kUsername, username);
ShowScreenWithData(kScreenId, &data);
}
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 91fbdee3b62..498ea0f493e 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
@@ -26,8 +26,7 @@ class ParentalHandoffScreenView {
virtual ~ParentalHandoffScreenView() = default;
// Shows the contents of the screen.
- virtual void Show(const base::string16& title,
- const base::string16& subtitle) = 0;
+ virtual void Show(const base::string16& username) = 0;
// Binds |screen| to the view.
virtual void Bind(ParentalHandoffScreen* screen) = 0;
@@ -54,8 +53,7 @@ class ParentalHandoffScreenHandler : public BaseScreenHandler,
void Initialize() override;
// Shows the contents of the screen.
- void Show(const base::string16& title,
- const base::string16& subtitle) override;
+ void Show(const base::string16& username) override;
void Bind(ParentalHandoffScreen* screen) override;
void Unbind() override;
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 685df64e848..3ea3bd0afe5 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
@@ -4,7 +4,11 @@
#include "chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h"
-#include "chrome/browser/chromeos/login/screens/pin_setup_screen.h"
+#include "base/i18n/number_formatting.h"
+#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/ash/login/screens/pin_setup_screen.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
namespace chromeos {
@@ -19,17 +23,50 @@ PinSetupScreenHandler::PinSetupScreenHandler(
PinSetupScreenHandler::~PinSetupScreenHandler() {}
void PinSetupScreenHandler::DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) {}
+ ::login::LocalizedValuesBuilder* builder) {
+ // TODO(crbug.com/1104120): clean up constant names
+ builder->Add("discoverPinSetup", IDS_DISCOVER_PIN_SETUP);
+
+ builder->Add("back", IDS_EULA_BACK_BUTTON);
+ builder->Add("next", IDS_EULA_NEXT_BUTTON);
+ builder->Add("discoverPinSetupDone", IDS_DISCOVER_PIN_SETUP_DONE);
+
+ builder->Add("discoverPinSetupTitle1", IDS_DISCOVER_PIN_SETUP_TITLE1);
+ builder->Add("discoverPinSetupSubtitle1", IDS_DISCOVER_PIN_SETUP_SUBTITLE1);
+ builder->Add("discoverPinSetupSkip", IDS_DISCOVER_PIN_SETUP_SKIP);
+ builder->Add("discoverPinSetupTitle2", IDS_DISCOVER_PIN_SETUP_TITLE2);
+ builder->Add("discoverPinSetupTitle3", IDS_DISCOVER_PIN_SETUP_TITLE3);
+ builder->Add("discoverPinSetupSubtitle3NoLogin",
+ IDS_DISCOVER_PIN_SETUP_SUBTITLE3_NO_LOGIN);
+ builder->Add("discoverPinSetupSubtitle3WithLogin",
+ IDS_DISCOVER_PIN_SETUP_SUBTITLE3_WITH_LOGIN);
+
+ // Format numbers to be used on the pin keyboard.
+ for (int j = 0; j <= 9; j++) {
+ builder->Add("pinKeyboard" + base::NumberToString(j),
+ base::FormatNumber(int64_t{j}));
+ }
+ builder->Add("pinKeyboardPlaceholderPin", IDS_PIN_KEYBOARD_HINT_TEXT_PIN);
+ builder->Add("pinKeyboardPlaceholderPinPassword",
+ IDS_PIN_KEYBOARD_HINT_TEXT_PIN_PASSWORD);
+ builder->Add("pinKeyboardDeleteAccessibleName",
+ IDS_PIN_KEYBOARD_DELETE_ACCESSIBLE_NAME);
+ builder->Add("configurePinMismatched",
+ IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_MISMATCHED);
+ builder->Add("configurePinTooShort",
+ IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_TOO_SHORT);
+ builder->Add("configurePinTooLong",
+ IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_TOO_LONG);
+ builder->Add("configurePinWeakPin",
+ IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_WEAK_PIN);
+}
void PinSetupScreenHandler::RegisterMessages() {
BaseScreenHandler::RegisterMessages();
- discover_ui_.RegisterMessages(web_ui());
}
void PinSetupScreenHandler::GetAdditionalParameters(
- base::DictionaryValue* dict) {
- discover_ui_.GetAdditionalParameters(dict);
-}
+ base::DictionaryValue* dict) {}
void PinSetupScreenHandler::Bind(PinSetupScreen* screen) {
screen_ = screen;
@@ -39,12 +76,16 @@ void PinSetupScreenHandler::Bind(PinSetupScreen* screen) {
void PinSetupScreenHandler::Hide() {}
void PinSetupScreenHandler::Initialize() {
- discover_ui_.Initialize();
}
-void PinSetupScreenHandler::Show() {
- ShowScreen(kScreenId);
- discover_ui_.Show();
+void PinSetupScreenHandler::Show(const std::string& token) {
+ base::DictionaryValue data;
+ data.SetKey("auth_token", base::Value(token));
+ ShowScreenWithData(kScreenId, &data);
+}
+
+void PinSetupScreenHandler::SetLoginSupportAvailable(bool available) {
+ CallJS("login.PinSetupScreen.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 ebd8121e350..40da7e0d372 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,7 +7,6 @@
#include "base/macros.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-#include "chrome/browser/ui/webui/chromeos/login/discover/discover_ui.h"
namespace chromeos {
@@ -17,18 +16,20 @@ class PinSetupScreen;
// WebUI representation.
class PinSetupScreenView {
public:
- constexpr static StaticOobeScreenId kScreenId{"discover"};
+ constexpr static StaticOobeScreenId kScreenId{"pin-setup"};
virtual ~PinSetupScreenView() = default;
// Sets screen this view belongs to.
virtual void Bind(PinSetupScreen* screen) = 0;
- // Shows the contents of the screen.
- virtual void Show() = 0;
+ // Shows the contents of the screen, using |token| to access QuickUnlock API.
+ virtual void Show(const std::string& token) = 0;
// Hides the contents of the screen.
virtual void Hide() = 0;
+
+ virtual void SetLoginSupportAvailable(bool available) = 0;
};
// The sole implementation of the PinSetupScreenView, using WebUI.
@@ -50,13 +51,12 @@ class PinSetupScreenHandler : public BaseScreenHandler,
void Bind(PinSetupScreen* screen) override;
void Hide() override;
void Initialize() override;
- void Show() override;
+ void Show(const std::string& token) override;
+ void SetLoginSupportAvailable(bool available) override;
private:
PinSetupScreen* screen_ = nullptr;
- DiscoverUI discover_ui_;
-
DISALLOW_COPY_AND_ASSIGN(PinSetupScreenHandler);
};
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 dfd147e9663..66401258fc4 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
@@ -5,8 +5,8 @@
#include "chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h"
#include "base/metrics/histogram_macros.h"
+#include "chrome/browser/ash/login/screens/recommend_apps_screen.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
-#include "chrome/browser/chromeos/login/screens/recommend_apps_screen.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/app_list/arc/arc_fast_app_reinstall_starter.h"
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 05c653c27dc..7e5f63d76f6 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
@@ -7,10 +7,10 @@
#include <string>
#include "base/values.h"
+#include "chrome/browser/ash/login/screens/reset_screen.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/reset_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/dbus/session_manager/session_manager_client.h"
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 c1cc8571268..b44ce664bdd 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
@@ -9,8 +9,8 @@
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/values.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/chromeos/attestation/tpm_challenge_key_result.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/login/login_state/login_state.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc b/chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc
index 90d0b92ed63..cd60f58de95 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h"
-#include "chrome/browser/chromeos/login/lock/screen_locker.h"
+#include "chrome/browser/ash/login/lock/screen_locker.h"
#include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_provider.h"
#include "chrome/common/url_constants.h"
#include "net/base/escape.h"
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 59a74bd3daf..06fdba60f0d 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
@@ -3,11 +3,12 @@
// found in the LICENSE file.
#include "chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h"
+
#include <string>
#include "base/values.h"
+#include "chrome/browser/ash/login/screens/signin_fatal_error_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/signin_fatal_error_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
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 708ba65939f..c77770994db 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
@@ -8,7 +8,7 @@
#include <string>
#include "base/values.h"
-#include "chrome/browser/chromeos/login/screens/signin_fatal_error_screen.h"
+#include "chrome/browser/ash/login/screens/signin_fatal_error_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
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 4835a74f51a..d0b9880c1f7 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,6 @@
#include <vector>
#include "ash/public/cpp/login_constants.h"
-#include "ash/public/cpp/tablet_mode.h"
-#include "ash/public/cpp/wallpaper_types.h"
#include "ash/public/mojom/tray_action.mojom.h"
#include "base/bind.h"
#include "base/i18n/number_formatting.h"
@@ -29,58 +27,51 @@
#include "base/system/sys_info.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/ash/login/demo_mode/demo_session.h"
+#include "chrome/browser/ash/login/easy_unlock/easy_unlock_service.h"
+#include "chrome/browser/ash/login/lock/screen_locker.h"
+#include "chrome/browser/ash/login/screens/gaia_screen.h"
+#include "chrome/browser/ash/login/screens/network_error.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
+#include "chrome/browser/ash/system/system_clock.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part_chromeos.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/language_preferences.h"
-#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
-#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h"
#include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/hwid_checker.h"
-#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/login/lock_screen_utils.h"
-#include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
#include "chrome/browser/chromeos/login/reauth_stats.h"
-#include "chrome/browser/chromeos/login/screens/gaia_screen.h"
-#include "chrome/browser/chromeos/login/screens/network_error.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
#include "chrome/browser/chromeos/login/ui/login_display_webui.h"
-#include "chrome/browser/chromeos/login/ui/login_feedback.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/chromeos/policy/minimum_version_policy_handler.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/chromeos/system/system_clock.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/ui/ash/ime_controller_client.h"
#include "chrome/browser/ui/ash/session_controller_client_impl.h"
-#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#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/components/proximity_auth/screenlock_bridge.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/login/auth/key.h"
#include "chromeos/login/auth/user_context.h"
#include "chromeos/network/network_state.h"
@@ -102,7 +93,6 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/api/extensions_api_client.h"
-#include "extensions/browser/api/feedback_private/feedback_private_delegate.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/ime/chromeos/ime_keyboard.h"
@@ -135,25 +125,21 @@ constexpr base::TimeDelta kConnectingTimeout = base::TimeDelta::FromSeconds(60);
// Max number of Gaia Reload to Show Proxy Auth Dialog.
const int kMaxGaiaReloadForProxyAuthDialog = 3;
-// Type of the login screen UI that is currently presented to user.
-const char kSourceGaiaSignin[] = "gaia-signin";
-const char kSourceAccountPicker[] = "account-picker";
-
class CallOnReturn {
public:
- explicit CallOnReturn(const base::Closure& callback)
- : callback_(callback), call_scheduled_(false) {}
+ explicit CallOnReturn(base::OnceClosure callback)
+ : callback_(std::move(callback)), call_scheduled_(false) {}
~CallOnReturn() {
if (call_scheduled_ && !callback_.is_null())
- callback_.Run();
+ std::move(callback_).Run();
}
void CancelScheduledCall() { call_scheduled_ = false; }
void ScheduleCall() { call_scheduled_ = true; }
private:
- base::Closure callback_;
+ base::OnceClosure callback_;
bool call_scheduled_;
DISALLOW_COPY_AND_ASSIGN(CallOnReturn);
@@ -190,24 +176,7 @@ bool IsProxyError(NetworkStateInformer::State state,
}
bool IsSigninScreen(const OobeScreenId screen) {
- return screen == GaiaView::kScreenId ||
- screen == OobeScreen::SCREEN_ACCOUNT_PICKER;
-}
-
-bool IsSigninScreenError(NetworkError::ErrorState error_state) {
- return error_state == NetworkError::ERROR_STATE_PORTAL ||
- error_state == NetworkError::ERROR_STATE_OFFLINE ||
- error_state == NetworkError::ERROR_STATE_PROXY ||
- error_state == NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT;
-}
-
-// Returns network name by service path.
-std::string GetNetworkName(const std::string& service_path) {
- const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
- GetNetworkState(service_path);
- if (!network)
- return std::string();
- return network->name();
+ return screen == GaiaView::kScreenId;
}
} // namespace
@@ -243,35 +212,10 @@ SigninScreenHandler::SigninScreenHandler(
registrar_.Add(this,
chrome::NOTIFICATION_AUTH_CANCELLED,
content::NotificationService::AllSources());
-
- chromeos::PowerManagerClient::Get()->AddObserver(this);
-
- chromeos::input_method::ImeKeyboard* keyboard =
- chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard();
- if (keyboard)
- keyboard->AddObserver(this);
-
- ash::TabletMode* tablet_mode = ash::TabletMode::Get();
- tablet_mode->AddObserver(this);
- OnTabletModeToggled(tablet_mode->InTabletMode());
-
- WallpaperControllerClient::Get()->AddObserver(this);
}
SigninScreenHandler::~SigninScreenHandler() {
- if (auto* wallpaper_controller_client = WallpaperControllerClient::Get())
- wallpaper_controller_client->RemoveObserver(this);
// Ash maybe released before us.
- if (ash::TabletMode::Get())
- ash::TabletMode::Get()->RemoveObserver(this);
- OobeUI* oobe_ui = GetOobeUI();
- if (oobe_ui && oobe_ui_observer_added_)
- oobe_ui->RemoveObserver(this);
- chromeos::PowerManagerClient::Get()->RemoveObserver(this);
- chromeos::input_method::ImeKeyboard* keyboard =
- chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard();
- if (keyboard)
- keyboard->RemoveObserver(this);
if (ImeControllerClient::Get()) // Can be null in tests.
ImeControllerClient::Get()->SetImesManagedByPolicy(false);
weak_factory_.InvalidateWeakPtrs();
@@ -369,10 +313,6 @@ void SigninScreenHandler::DeclareLocalizedValues(
builder->Add("removeUserWarningTextCalculating", base::string16());
builder->Add("removeUserWarningTextSyncNoStats", base::string16());
builder->Add("removeUserWarningTextSyncCalculating", base::string16());
- builder->AddF("removeLegacySupervisedUserWarningText",
- IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING,
- base::UTF8ToUTF16(
- chrome::kLegacySupervisedUserManagementDisplayURL));
builder->Add("removeNonOwnerUserWarningText",
IDS_LOGIN_POD_NON_OWNER_USER_REMOVE_WARNING);
builder->Add("removeUserWarningButtonTitle",
@@ -403,41 +343,26 @@ void SigninScreenHandler::DeclareLocalizedValues(
}
void SigninScreenHandler::RegisterMessages() {
+ // TODO (crbug.com/1168114): This is only used by authenticateForTesting now.
+ // Need to migrate to testing API and remove it.
AddCallback("authenticateUser", &SigninScreenHandler::HandleAuthenticateUser);
- AddCallback("completeOfflineAuthentication",
- &SigninScreenHandler::HandleCompleteOfflineAuthentication);
AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito);
AddCallback("launchSAMLPublicSession",
&SigninScreenHandler::HandleLaunchSAMLPublicSession);
AddRawCallback("offlineLogin", &SigninScreenHandler::HandleOfflineLogin);
+ // TODO(crbug.com/1100910): migrate logic to dedicated test api.
AddCallback("toggleEnrollmentScreen",
&SigninScreenHandler::HandleToggleEnrollmentScreen);
- AddCallback("toggleKioskEnableScreen",
- &SigninScreenHandler::HandleToggleKioskEnableScreen);
- AddCallback("accountPickerReady",
- &SigninScreenHandler::HandleAccountPickerReady);
AddCallback("openInternetDetailDialog",
&SigninScreenHandler::HandleOpenInternetDetailDialog);
AddCallback("loginVisible", &SigninScreenHandler::HandleLoginVisible);
- AddCallback("cancelUserAdding", &SigninScreenHandler::HandleCancelUserAdding);
+
+ // TODO(crbug.com/1168114): This is also called by GAIA screen,
+ // but might not be needed anymore
AddCallback("loginUIStateChanged",
&SigninScreenHandler::HandleLoginUIStateChanged);
AddCallback("showLoadingTimeoutError",
&SigninScreenHandler::HandleShowLoadingTimeoutError);
- AddCallback("focusPod", &SigninScreenHandler::HandleFocusPod);
- AddCallback("noPodFocused", &SigninScreenHandler::HandleNoPodFocused);
- AddCallback("getPublicSessionKeyboardLayouts",
- &SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts);
- AddCallback("getTabletModeState",
- &SigninScreenHandler::HandleGetTabletModeState);
- AddCallback("getDemoModeState", &SigninScreenHandler::HandleGetDemoModeState);
- AddCallback("logRemoveUserWarningShown",
- &SigninScreenHandler::HandleLogRemoveUserWarningShown);
- AddCallback("firstIncorrectPasswordAttempt",
- &SigninScreenHandler::HandleFirstIncorrectPasswordAttempt);
- AddCallback("maxIncorrectPasswordAttempts",
- &SigninScreenHandler::HandleMaxIncorrectPasswordAttempts);
- AddCallback("sendFeedback", &SigninScreenHandler::HandleSendFeedback);
}
void SigninScreenHandler::Show(bool oobe_ui) {
@@ -456,11 +381,6 @@ void SigninScreenHandler::SetDelegate(SigninScreenHandlerDelegate* delegate) {
delegate_->SetWebUIHandler(this);
}
-void SigninScreenHandler::OnNetworkReady() {
- VLOG(1) << "OnNetworkReady() call.";
- gaia_screen_handler_->MaybePreloadAuthExtension();
-}
-
void SigninScreenHandler::UpdateState(NetworkError::ErrorReason reason) {
// ERROR_REASON_FRAME_ERROR is an explicit signal from GAIA frame so it shoud
// force network error UI update.
@@ -474,6 +394,8 @@ void SigninScreenHandler::SetOfflineTimeoutForTesting(
offline_timeout_for_test_ = offline_timeout;
}
+// TODO (crbug.com/1168114): Such method should be implemented in
+// native-view-based UI, and be removed here.
bool SigninScreenHandler::GetKeyboardRemappedPrefValue(
const std::string& pref_name,
int* value) {
@@ -493,26 +415,7 @@ void SigninScreenHandler::ShowImpl() {
if (!ime_state_.get())
ime_state_ = input_method::InputMethodManager::Get()->GetActiveIMEState();
- if (!oobe_ui_observer_added_) {
- oobe_ui_observer_added_ = true;
- GetOobeUI()->AddObserver(this);
- }
-
- if (oobe_ui_) {
- // Shows new user sign-in for OOBE.
- gaia_screen_handler_->OnShowAddUser();
- } else {
- // Populates account picker. Animation is turned off for now until we
- // figure out how to make it fast enough. This will call LoadUsers.
- delegate_->HandleGetUsers();
-
- // Reset Caps Lock state when login screen is shown.
- input_method::InputMethodManager::Get()
- ->GetImeKeyboard()
- ->SetCapsLockEnabled(false);
-
- UpdateUIState(UI_STATE_ACCOUNT_PICKER);
- }
+ gaia_screen_handler_->OnShowAddUser();
}
void SigninScreenHandler::UpdateUIState(UIState ui_state) {
@@ -520,10 +423,6 @@ void SigninScreenHandler::UpdateUIState(UIState ui_state) {
case UI_STATE_GAIA_SIGNIN:
ui_state_ = UI_STATE_GAIA_SIGNIN;
break;
- case UI_STATE_ACCOUNT_PICKER:
- ui_state_ = UI_STATE_ACCOUNT_PICKER;
- ShowScreen(OobeScreen::SCREEN_ACCOUNT_PICKER);
- break;
default:
NOTREACHED();
break;
@@ -545,28 +444,27 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
NetworkStateInformer::State state = network_state_informer_->state();
const std::string network_path = network_state_informer_->network_path();
- const std::string network_name = GetNetworkName(network_path);
+ const std::string network_name =
+ NetworkStateInformer::GetNetworkName(network_path);
// Skip "update" notification about OFFLINE state from
// NetworkStateInformer if previous notification already was
// delayed.
if ((state == NetworkStateInformer::OFFLINE ||
network_state_ignored_until_proxy_auth_) &&
- !force_update && !update_state_closure_.IsCancelled()) {
+ !force_update && !update_state_callback_.IsCancelled()) {
return;
}
- update_state_closure_.Cancel();
+ update_state_callback_.Cancel();
if ((state == NetworkStateInformer::OFFLINE && !force_update) ||
network_state_ignored_until_proxy_auth_) {
- update_state_closure_.Reset(
- base::Bind(&SigninScreenHandler::UpdateStateInternal,
- weak_factory_.GetWeakPtr(),
- reason,
- true));
+ update_state_callback_.Reset(
+ base::BindOnce(&SigninScreenHandler::UpdateStateInternal,
+ weak_factory_.GetWeakPtr(), reason, true));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, update_state_closure_.callback(),
+ FROM_HERE, update_state_callback_.callback(),
is_offline_timeout_for_test_set_ ? offline_timeout_for_test_
: kOfflineTimeout);
return;
@@ -574,19 +472,17 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
// Don't show or hide error screen if we're in connecting state.
if (state == NetworkStateInformer::CONNECTING && !force_update) {
- if (connecting_closure_.IsCancelled()) {
+ if (connecting_callback_.IsCancelled()) {
// First notification about CONNECTING state.
- connecting_closure_.Reset(
- base::Bind(&SigninScreenHandler::UpdateStateInternal,
- weak_factory_.GetWeakPtr(),
- reason,
- true));
+ connecting_callback_.Reset(
+ base::BindOnce(&SigninScreenHandler::UpdateStateInternal,
+ weak_factory_.GetWeakPtr(), reason, true));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, connecting_closure_.callback(), kConnectingTimeout);
+ FROM_HERE, connecting_callback_.callback(), kConnectingTimeout);
}
return;
}
- connecting_closure_.Cancel();
+ connecting_callback_.Cancel();
const bool is_online = IsOnline(state, reason);
const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason);
@@ -595,10 +491,7 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
const bool is_gaia_error =
FrameError() != net::OK && FrameError() != net::ERR_NETWORK_CHANGED;
const bool is_gaia_signin = IsGaiaVisible() || IsGaiaHiddenByError();
- const bool offline_login_active =
- gaia_screen_handler_->IsOfflineLoginActive();
- const bool error_screen_should_overlay =
- !offline_login_active && IsGaiaVisible();
+ const bool error_screen_should_overlay = IsGaiaVisible();
const bool from_not_online_to_online_transition =
is_online && last_network_state_ != NetworkStateInformer::ONLINE;
last_network_state_ = state;
@@ -607,8 +500,8 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
(state == NetworkStateInformer::PROXY_AUTH_REQUIRED) &&
(proxy_auth_dialog_reload_times_ > 0);
- CallOnReturn reload_gaia(base::Bind(
- &SigninScreenHandler::ReloadGaia, weak_factory_.GetWeakPtr(), true));
+ CallOnReturn reload_gaia(base::BindOnce(&SigninScreenHandler::ReloadGaia,
+ weak_factory_.GetWeakPtr(), true));
if (is_online || !is_behind_captive_portal)
error_screen_->HideCaptivePortal();
@@ -621,10 +514,6 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
return;
}
- // Use the online login page if the user has not used the machine for awhile.
- if (offline_login_active)
- gaia_screen_handler_->MonitorOfflineIdle(is_online);
-
// Reload frame if network state is changed from {!ONLINE} -> ONLINE state.
if (reason == NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED &&
from_not_online_to_online_transition) {
@@ -662,9 +551,12 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
reload_gaia.ScheduleCall();
}
- if ((!is_online || is_gaia_loading_timeout || is_gaia_error) &&
- !offline_login_active) {
- SetupAndShowOfflineMessage(state, reason);
+ if (!is_online || is_gaia_loading_timeout || is_gaia_error) {
+ if (GetCurrentScreen() != ErrorScreenView::kScreenId) {
+ error_screen_->SetParentScreen(GaiaView::kScreenId);
+ error_screen_->ShowNetworkErrorMessage(state, reason);
+ histogram_helper_->OnErrorShow(error_screen_->GetErrorState());
+ }
} else {
HideOfflineMessage(state, reason);
@@ -673,57 +565,6 @@ void SigninScreenHandler::UpdateStateInternal(NetworkError::ErrorReason reason,
}
}
-void SigninScreenHandler::SetupAndShowOfflineMessage(
- NetworkStateInformer::State state,
- NetworkError::ErrorReason reason) {
- const std::string network_path = network_state_informer_->network_path();
- const bool is_behind_captive_portal = IsBehindCaptivePortal(state, reason);
- const bool is_proxy_error = IsProxyError(state, reason, FrameError());
- const bool is_gaia_loading_timeout =
- (reason == NetworkError::ERROR_REASON_LOADING_TIMEOUT);
-
- if (is_proxy_error) {
- error_screen_->SetErrorState(NetworkError::ERROR_STATE_PROXY,
- std::string());
- } else if (is_behind_captive_portal) {
- // Do not bother a user with obsessive captive portal showing. This
- // check makes captive portal being shown only once: either when error
- // screen is shown for the first time or when switching from another
- // error screen (offline, proxy).
- if (IsGaiaVisible() ||
- (error_screen_->GetErrorState() != NetworkError::ERROR_STATE_PORTAL)) {
- LoginDisplayHost::default_host()->HandleDisplayCaptivePortal();
- }
- const std::string network_name = GetNetworkName(network_path);
- error_screen_->SetErrorState(NetworkError::ERROR_STATE_PORTAL,
- network_name);
- } else if (is_gaia_loading_timeout) {
- error_screen_->SetErrorState(NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT,
- std::string());
- } else {
- error_screen_->SetErrorState(NetworkError::ERROR_STATE_OFFLINE,
- std::string());
- }
-
- bool guest_signin_allowed = false;
- bool offline_login_allowed = false;
- if (IsSigninScreenError(error_screen_->GetErrorState())) {
- guest_signin_allowed =
- user_manager::UserManager::Get()->IsGuestSessionAllowed();
- offline_login_allowed = error_screen_->GetErrorState() !=
- NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT;
- }
- error_screen_->AllowGuestSignin(guest_signin_allowed);
- error_screen_->AllowOfflineLogin(offline_login_allowed);
-
- if (GetCurrentScreen() != ErrorScreenView::kScreenId) {
- error_screen_->SetUIState(NetworkError::UI_STATE_SIGNIN);
- error_screen_->SetParentScreen(GaiaView::kScreenId);
- error_screen_->Show(nullptr);
- histogram_helper_->OnErrorShow(error_screen_->GetErrorState());
- }
-}
-
void SigninScreenHandler::HideOfflineMessage(NetworkStateInformer::State state,
NetworkError::ErrorReason reason) {
if (!IsSigninScreenHiddenByError())
@@ -744,17 +585,6 @@ void SigninScreenHandler::ReloadGaia(bool force_reload) {
}
void SigninScreenHandler::Initialize() {
- // Preload PIN keyboard if any of the users can authenticate via PIN.
- if (user_manager::UserManager::IsInitialized()) {
- for (user_manager::User* user :
- user_manager::UserManager::Get()->GetUnlockUsers()) {
- quick_unlock::PinBackend::GetInstance()->CanAuthenticate(
- user->GetAccountId(),
- base::BindOnce(&SigninScreenHandler::PreloadPinKeyboard,
- weak_factory_.GetWeakPtr()));
- }
- }
-
// `delegate_` is null when we are preloading the lock screen.
if (delegate_ && show_on_init_) {
show_on_init_ = false;
@@ -766,76 +596,10 @@ void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(prefs::kUsersLastInputMethod);
}
-void SigninScreenHandler::OnCurrentScreenChanged(OobeScreenId current_screen,
- OobeScreenId new_screen) {
- if (new_screen == OobeScreen::SCREEN_ACCOUNT_PICKER) {
- // Restore active IME state if returning to user pod row screen.
- input_method::InputMethodManager::Get()->SetState(ime_state_);
- }
-}
-
-void SigninScreenHandler::OnWallpaperColorsChanged() {
- // Updates the color of the scrollable container on account picker screen,
- // based on wallpaper color extraction results.
- auto colors = WallpaperControllerClient::Get()->GetWallpaperColors();
- SkColor dark_muted_color =
- colors[static_cast<int>(ash::ColorProfileType::DARK_MUTED)];
- if (dark_muted_color == ash::kInvalidWallpaperColor)
- dark_muted_color = ash::login_constants::kDefaultBaseColor;
-
- dark_muted_color = SkColorSetA(dark_muted_color, 0xFF);
- SkColor base_color = color_utils::GetResultingPaintColor(
- SkColorSetA(ash::login_constants::kDefaultBaseColor,
- ash::login_constants::kTranslucentColorDarkenAlpha),
- dark_muted_color);
- SkColor scroll_color =
- SkColorSetA(base_color, ash::login_constants::kScrollTranslucentAlpha);
- CallJS("login.AccountPickerScreen.setOverlayColors",
- color_utils::SkColorToRgbaString(dark_muted_color),
- color_utils::SkColorToRgbaString(scroll_color));
-}
-
-void SigninScreenHandler::OnWallpaperBlurChanged() {
- const bool show_pod_background =
- !WallpaperControllerClient::Get()->IsWallpaperBlurred();
- CallJS("login.AccountPickerScreen.togglePodBackground", show_pod_background);
-}
-
void SigninScreenHandler::ClearAndEnablePassword() {
core_oobe_view_->ResetSignInUI(false);
}
-void SigninScreenHandler::ClearUserPodPassword() {
- core_oobe_view_->ClearUserPodPassword();
-}
-
-void SigninScreenHandler::RefocusCurrentPod() {
- core_oobe_view_->RefocusCurrentPod();
-}
-
-void SigninScreenHandler::UpdatePinKeyboardState(const AccountId& account_id) {
- quick_unlock::PinBackend::GetInstance()->CanAuthenticate(
- account_id, base::BindOnce(&SigninScreenHandler::SetPinEnabledForUser,
- weak_factory_.GetWeakPtr(), account_id));
-}
-
-void SigninScreenHandler::SetPinEnabledForUser(const AccountId& account_id,
- bool is_enabled) {
- CallJS("login.AccountPickerScreen.setPinEnabledForUser", account_id,
- is_enabled);
-}
-
-void SigninScreenHandler::PreloadPinKeyboard(bool should_preload) {
- if (should_preload)
- CallJS("cr.ui.Oobe.preloadPinKeyboard");
-}
-
-void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) {
- if (page_is_ready()) {
- CallJS("login.AccountPickerScreen.updateUserImage", user.GetAccountId());
- }
-}
-
void SigninScreenHandler::OnPreferencesChanged() {
// Make sure that one of the login UI is fully functional now, otherwise
// preferences update would be picked up next time it will be shown.
@@ -850,17 +614,6 @@ void SigninScreenHandler::OnPreferencesChanged() {
if (!delegate_)
return;
- // Send the updated user list to the UI.
- delegate_->HandleGetUsers();
- if (GetCurrentScreen() == OobeScreen::SCREEN_ACCOUNT_PICKER &&
- delegate_->ShowUsersHasChanged() &&
- !delegate_->IsShowUsers()) {
- // We are at the account picker screen and the POD setting has changed
- // to be disabled. We need to show the add user page.
- gaia_screen_handler_->HandleShowAddUser(nullptr);
- return;
- }
-
if (delegate_->AllowNewUserChanged() || ui_state_ == UI_STATE_UNKNOWN) {
// We need to reload GAIA if UI_STATE_UNKNOWN or the allow new user setting
// has changed so that reloaded GAIA shows/hides the option to create a new
@@ -871,9 +624,6 @@ void SigninScreenHandler::OnPreferencesChanged() {
}
}
-void SigninScreenHandler::ResetSigninScreenHandlerDelegate() {
- SetDelegate(nullptr);
-}
void SigninScreenHandler::ShowError(int login_attempts,
const std::string& error_text,
@@ -883,10 +633,6 @@ void SigninScreenHandler::ShowError(int login_attempts,
help_topic_id);
}
-void SigninScreenHandler::ShowSigninUI(const std::string& email) {
- core_oobe_view_->ShowSignInUI(email);
-}
-
void SigninScreenHandler::ShowAllowlistCheckFailedError() {
gaia_screen_handler_->ShowAllowlistCheckFailedError();
}
@@ -903,14 +649,14 @@ void SigninScreenHandler::Observe(int type,
if (IsGaiaHiddenByError()) {
// Start listening to network state notifications immediately, hoping
// that the network will switch to ONLINE soon.
- update_state_closure_.Cancel();
+ update_state_callback_.Cancel();
ReenableNetworkStateUpdatesAfterProxyAuth();
} else {
// Gaia is not hidden behind an error yet. Discard last cached network
// state notification and wait for `kProxyAuthTimeout` before
// considering network update notifications again (hoping the network
// will become ONLINE by then).
- update_state_closure_.Cancel();
+ update_state_callback_.Cancel();
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(
@@ -921,7 +667,7 @@ void SigninScreenHandler::Observe(int type,
break;
}
case chrome::NOTIFICATION_AUTH_CANCELLED: {
- update_state_closure_.Cancel();
+ update_state_callback_.Cancel();
ReenableNetworkStateUpdatesAfterProxyAuth();
break;
}
@@ -934,33 +680,6 @@ void SigninScreenHandler::ReenableNetworkStateUpdatesAfterProxyAuth() {
network_state_ignored_until_proxy_auth_ = false;
}
-void SigninScreenHandler::SuspendDone(const base::TimeDelta& sleep_duration) {
- for (user_manager::User* user :
- user_manager::UserManager::Get()->GetUnlockUsers()) {
- UpdatePinKeyboardState(user->GetAccountId());
- }
-}
-
-void SigninScreenHandler::OnTabletModeStarted() {
- OnTabletModeToggled(true);
-}
-
-void SigninScreenHandler::OnTabletModeEnded() {
- OnTabletModeToggled(false);
-}
-
-void SigninScreenHandler::OnTabletModeToggled(bool enabled) {
- CallJS("login.AccountPickerScreen.setTabletModeState", enabled);
-}
-
-bool SigninScreenHandler::ShouldLoadGaia() const {
- // Fetching of the extension is not started before account picker page is
- // loaded because it can affect the loading speed.
- // Do not load the extension for the screen locker, see crosbug.com/25018.
- return !ScreenLocker::default_screen_locker() &&
- is_account_picker_showing_first_time_;
-}
-
void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin) {
@@ -1003,30 +722,6 @@ void SigninScreenHandler::AuthenticateExistingUser(const AccountId& account_id,
}
delegate_->Login(user_context, SigninSpecifics());
-
- UpdatePinKeyboardState(account_id);
-}
-
-void SigninScreenHandler::HandleCompleteOfflineAuthentication(
- const std::string& email,
- const std::string& password) {
- const std::string sanitized_email = gaia::SanitizeEmail(email);
- const AccountId account_id = user_manager::known_user::GetAccountId(
- sanitized_email, std::string() /* id */, AccountType::UNKNOWN);
- const user_manager::User* user =
- user_manager::UserManager::Get()->FindUser(account_id);
- if (!user) {
- LOG(ERROR)
- << "HandleCompleteOfflineAuthentication: User not found! account type="
- << AccountId::AccountTypeToString(account_id.GetAccountType());
- LoginDisplayHost::default_host()->GetLoginDisplay()->ShowError(
- IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, 1,
- HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
- return;
- }
-
- AuthenticateExistingUser(account_id, password,
- false /* authenticated_by_pin */);
}
void SigninScreenHandler::HandleLaunchIncognito() {
@@ -1055,12 +750,12 @@ void SigninScreenHandler::HandleOfflineLogin(const base::ListValue* args) {
std::string email;
args->GetString(0, &email);
- GaiaScreen* gaia_screen =
- WizardController::default_controller()->GetScreen<GaiaScreen>();
- gaia_screen->LoadOffline(AccountId::FromUserEmail(email));
+ auto* offline_login_screen =
+ WizardController::default_controller()->GetScreen<OfflineLoginScreen>();
+ offline_login_screen->LoadOffline(email);
HideOfflineMessage(NetworkStateInformer::OFFLINE,
NetworkError::ERROR_REASON_NONE);
- LoginDisplayHost::default_host()->StartWizard(GaiaView::kScreenId);
+ LoginDisplayHost::default_host()->StartWizard(OfflineLoginView::kScreenId);
UpdateUIState(UI_STATE_GAIA_SIGNIN);
}
@@ -1070,61 +765,11 @@ void SigninScreenHandler::HandleToggleEnrollmentScreen() {
delegate_->ShowEnterpriseEnrollmentScreen();
}
-void SigninScreenHandler::HandleToggleKioskEnableScreen() {
- if (delegate_ && !webui::IsEnterpriseManaged() &&
- KioskAppManager::IsConsumerKioskEnabled() &&
- LoginDisplayHost::default_host()) {
- delegate_->ShowKioskEnableScreen();
- }
-}
-
void SigninScreenHandler::HandleToggleKioskAutolaunchScreen() {
if (delegate_ && !webui::IsEnterpriseManaged())
delegate_->ShowKioskAutolaunchScreen();
}
-void SigninScreenHandler::LoadUsers(const user_manager::UserList& users,
- const base::ListValue& users_list) {
- CallJS("login.AccountPickerScreen.loadUsers", users_list);
-
- // Enable pin for any users who can use it.
- // TODO(jdufault): Cache pin state in BrowserProcess::local_state() so we
- // don't need to query cryptohome every time we show login. See
- // https://crbug.com/721938.
- for (user_manager::User* user : users)
- UpdatePinKeyboardState(user->GetAccountId());
-}
-
-void SigninScreenHandler::HandleAccountPickerReady() {
- VLOG(0) << "Login WebUI >> AccountPickerReady";
-
- if (delegate_ && !ScreenLocker::default_screen_locker() &&
- !chromeos::IsMachineHWIDCorrect() &&
- !oobe_ui_) {
- delegate_->ShowWrongHWIDScreen();
- return;
- }
-
- is_account_picker_showing_first_time_ = true;
-
- // The wallpaper may have been set before the instance is initialized, so make
- // sure the colors and blur state are updated.
- OnWallpaperColorsChanged();
- OnWallpaperBlurChanged();
-
- session_manager::SessionManager* session_manager =
- session_manager::SessionManager::Get();
- if (session_manager->session_state() == session_manager::SessionState::OOBE) {
- // This updates post-OOBE shelf UI. Changes the color of shelf buttons and
- // displays additional buttons that should only be shown in the login screen
- session_manager->SetSessionState(
- session_manager::SessionState::LOGIN_PRIMARY);
- }
-
- if (delegate_)
- delegate_->OnSigninScreenReady();
-}
-
void SigninScreenHandler::HandleOpenInternetDetailDialog() {
// Empty string opens the internet detail dialog for the default network.
InternetDetailDialog::ShowDialog("");
@@ -1150,11 +795,6 @@ void SigninScreenHandler::HandleLoginVisible(const std::string& source) {
OnPreferencesChanged();
}
-void SigninScreenHandler::HandleCancelUserAdding() {
- if (delegate_)
- delegate_->CancelUserAdding();
-}
-
void SigninScreenHandler::HandleLoginUIStateChanged(const std::string& source,
bool active) {
VLOG(0) << "Login WebUI >> active: " << active << ", "
@@ -1171,128 +811,15 @@ void SigninScreenHandler::HandleLoginUIStateChanged(const std::string& source,
return;
}
- if (source == kSourceGaiaSignin) {
- ui_state_ = UI_STATE_GAIA_SIGNIN;
- } else if (source == kSourceAccountPicker) {
- ui_state_ = UI_STATE_ACCOUNT_PICKER;
- } else {
- NOTREACHED();
- return;
- }
+ ui_state_ = UI_STATE_GAIA_SIGNIN;
}
void SigninScreenHandler::HandleShowLoadingTimeoutError() {
UpdateState(NetworkError::ERROR_REASON_LOADING_TIMEOUT);
}
-void SigninScreenHandler::HandleFocusPod(const AccountId& account_id,
- bool is_large_pod) {
- proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(account_id);
- const bool is_same_pod_focused =
- focused_pod_account_id_ && *focused_pod_account_id_ == account_id;
-
- if (delegate_ && !is_same_pod_focused)
- delegate_->CheckUserStatus(account_id);
-
- focused_pod_account_id_ = std::make_unique<AccountId>(account_id);
-
- const user_manager::User* user =
- user_manager::UserManager::Get()->FindUser(account_id);
- // `user` may be nullptr in kiosk mode or unit tests.
- if (user && user->is_logged_in() && !user->is_active()) {
- SessionControllerClientImpl::DoSwitchActiveUser(account_id);
- return;
- }
-
- if (LoginDisplayHost::default_host() && is_large_pod)
- LoginDisplayHost::default_host()->LoadWallpaper(account_id);
-
- if (is_same_pod_focused)
- return;
-
- // TODO(https://crbug.com/1071779): Migrate KioskTest to Views Account picker.
- // DCHECK_EQ(session_manager::SessionManager::Get()->session_state(),
- // session_manager::SessionState::LOGIN_SECONDARY);
- lock_screen_utils::SetUserInputMethod(account_id, ime_state_.get(),
- false /*honor_device_policy*/);
- lock_screen_utils::SetKeyboardSettings(account_id);
-
- bool use_24hour_clock = false;
- if (!user_manager::known_user::GetBooleanPref(
- account_id, prefs::kUse24HourClock, &use_24hour_clock)) {
- focused_user_clock_type_.reset();
- return;
- }
-
- base::HourClockType clock_type =
- use_24hour_clock ? base::k24HourClock : base::k12HourClock;
-
- if (focused_user_clock_type_.has_value()) {
- focused_user_clock_type_->UpdateClockType(clock_type);
- } else {
- focused_user_clock_type_ = g_browser_process->platform_part()
- ->GetSystemClock()
- ->CreateScopedHourClockType(clock_type);
- }
-}
-
void SigninScreenHandler::HandleNoPodFocused() {
focused_pod_account_id_.reset();
- focused_user_clock_type_.reset();
-}
-
-void SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts(
- const AccountId& account_id,
- const std::string& locale) {
- GetKeyboardLayoutsForLocale(
- base::Bind(&SigninScreenHandler::SendPublicSessionKeyboardLayouts,
- weak_factory_.GetWeakPtr(), account_id, locale),
- locale);
-}
-
-void SigninScreenHandler::SendPublicSessionKeyboardLayouts(
- const AccountId& account_id,
- const std::string& locale,
- std::unique_ptr<base::ListValue> keyboard_layouts) {
- CallJS("login.AccountPickerScreen.setPublicSessionKeyboardLayouts",
- account_id, locale, *keyboard_layouts);
-}
-
-void SigninScreenHandler::HandleGetTabletModeState() {
- CallJS("login.AccountPickerScreen.setTabletModeState",
- ash::TabletMode::Get()->InTabletMode());
-}
-
-void SigninScreenHandler::HandleGetDemoModeState() {
- CallJS("login.AccountPickerScreen.setDemoModeState",
- DemoSession::IsDeviceInDemoMode());
-}
-
-void SigninScreenHandler::HandleLogRemoveUserWarningShown() {
- ProfileMetrics::LogProfileDeleteUser(
- ProfileMetrics::DELETE_PROFILE_USER_MANAGER_SHOW_WARNING);
-}
-
-void SigninScreenHandler::HandleFirstIncorrectPasswordAttempt(
- const AccountId& account_id) {
- // TODO(ginkage): Fix this case once crbug.com/469987 is ready.
- /*
- if (user_manager::known_user::IsUsingSAML(email))
- RecordReauthReason(email, ReauthReason::INCORRECT_SAML_PASSWORD_ENTERED);
- */
-}
-
-void SigninScreenHandler::HandleMaxIncorrectPasswordAttempts(
- const AccountId& account_id) {
- RecordReauthReason(account_id, ReauthReason::INCORRECT_PASSWORD_ENTERED);
-}
-
-void SigninScreenHandler::HandleSendFeedback() {
- login_feedback_ =
- std::make_unique<LoginFeedback>(Profile::FromWebUI(web_ui()));
- login_feedback_->Request(
- std::string(), base::BindOnce(&SigninScreenHandler::OnFeedbackFinished,
- weak_factory_.GetWeakPtr()));
}
bool SigninScreenHandler::AllAllowlistedUsersPresent() {
@@ -1347,13 +874,4 @@ net::Error SigninScreenHandler::FrameError() const {
return gaia_screen_handler_->frame_error();
}
-void SigninScreenHandler::OnCapsLockChanged(bool enabled) {
- if (page_is_ready())
- CallJS("login.AccountPickerScreen.setCapsLockState", enabled);
-}
-
-void SigninScreenHandler::OnFeedbackFinished() {
- login_feedback_.reset();
-}
-
} // namespace chromeos
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 1b706189fcf..f61d4fb49d5 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
@@ -10,31 +10,24 @@
#include <set>
#include <string>
-#include "ash/public/cpp/tablet_mode_observer.h"
-#include "ash/public/cpp/wallpaper_controller_observer.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
-#include "chrome/browser/chromeos/login/screens/error_screen.h"
+#include "chrome/browser/ash/login/screens/error_screen.h"
#include "chrome/browser/chromeos/login/signin_specifics.h"
#include "chrome/browser/chromeos/login/ui/login_display.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/chromeos/system/system_clock.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
-#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/network/portal_detector/network_portal_detector.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui.h"
#include "net/base/net_errors.h"
-#include "ui/base/ime/chromeos/ime_keyboard.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/events/event_handler.h"
@@ -55,26 +48,18 @@ namespace chromeos {
class CoreOobeView;
class ErrorScreensHistogramHelper;
class GaiaScreenHandler;
-class LoginFeedback;
-class User;
class UserContext;
// An interface for WebUILoginDisplay to call SigninScreenHandler.
class LoginDisplayWebUIHandler {
public:
virtual void ClearAndEnablePassword() = 0;
- virtual void ClearUserPodPassword() = 0;
- virtual void OnUserImageChanged(const user_manager::User& user) = 0;
virtual void OnPreferencesChanged() = 0;
- virtual void ResetSigninScreenHandlerDelegate() = 0;
virtual void ShowError(int login_attempts,
const std::string& error_text,
const std::string& help_link_text,
HelpAppLauncher::HelpTopic help_topic_id) = 0;
- virtual void ShowSigninUI(const std::string& email) = 0;
virtual void ShowAllowlistCheckFailedError() = 0;
- virtual void LoadUsers(const user_manager::UserList& users,
- const base::ListValue& users_list) = 0;
protected:
virtual ~LoginDisplayWebUIHandler() {}
@@ -99,9 +84,6 @@ class SigninScreenHandlerDelegate {
// Shows Enterprise Enrollment screen.
virtual void ShowEnterpriseEnrollmentScreen() = 0;
- // Shows Kiosk Enable screen.
- virtual void ShowKioskEnableScreen() = 0;
-
// Shows Reset screen.
virtual void ShowKioskAutolaunchScreen() = 0;
@@ -115,25 +97,12 @@ class SigninScreenHandlerDelegate {
// Let the delegate know about the handler it is supposed to be using.
virtual void SetWebUIHandler(LoginDisplayWebUIHandler* webui_handler) = 0;
- // Whether to show the user pods or only GAIA sign in.
- // Public sessions are always shown.
- virtual bool IsShowUsers() const = 0;
-
- // Whether the show user pods setting has changed.
- virtual bool ShowUsersHasChanged() const = 0;
-
// Whether the allow new user setting has changed.
virtual bool AllowNewUserChanged() const = 0;
// Whether user sign in has completed.
virtual bool IsUserSigninCompleted() const = 0;
- // Request to (re)load user list.
- virtual void HandleGetUsers() = 0;
-
- // Runs an OAuth token validation check for user.
- virtual void CheckUserStatus(const AccountId& account_id) = 0;
-
protected:
virtual ~SigninScreenHandlerDelegate() {}
};
@@ -144,12 +113,7 @@ class SigninScreenHandler
: public BaseWebUIHandler,
public LoginDisplayWebUIHandler,
public content::NotificationObserver,
- public NetworkStateInformer::NetworkStateInformerObserver,
- public PowerManagerClient::Observer,
- public input_method::ImeKeyboard::Observer,
- public ash::TabletModeObserver,
- public OobeUI::Observer,
- public ash::WallpaperControllerObserver {
+ public NetworkStateInformer::NetworkStateInformerObserver {
public:
SigninScreenHandler(
JSCallsContainer* js_calls_container,
@@ -169,21 +133,11 @@ class SigninScreenHandler
void SetDelegate(SigninScreenHandlerDelegate* delegate);
// NetworkStateInformer::NetworkStateInformerObserver implementation:
- void OnNetworkReady() override;
void UpdateState(NetworkError::ErrorReason reason) override;
// Required Local State preferences.
static void RegisterPrefs(PrefRegistrySimple* registry);
- // OobeUI::Observer implementation:
- void OnCurrentScreenChanged(OobeScreenId current_screen,
- OobeScreenId new_screen) override;
- void OnDestroyingOobeUI() override {}
-
- // ash::WallpaperControllerObserver implementation:
- void OnWallpaperColorsChanged() override;
- void OnWallpaperBlurChanged() override;
-
// To avoid spurious error messages on flaky networks, the offline message is
// only shown if the network is offline for a threshold number of seconds.
// This method provides an ability to reduce the threshold to zero, allowing
@@ -197,10 +151,11 @@ class SigninScreenHandler
bool GetKeyboardRemappedPrefValue(const std::string& pref_name, int* value);
private:
+ // TODO (crbug.com/1168114): check if it makes sense anymore, as we're always
+ // showing GAIA
enum UIState {
UI_STATE_UNKNOWN = 0,
UI_STATE_GAIA_SIGNIN,
- UI_STATE_ACCOUNT_PICKER,
};
friend class GaiaScreenHandler;
@@ -230,96 +185,45 @@ class SigninScreenHandler
// LoginDisplayWebUIHandler implementation:
void ClearAndEnablePassword() override;
- void ClearUserPodPassword() override;
- void OnUserImageChanged(const user_manager::User& user) override;
void OnPreferencesChanged() override;
- void ResetSigninScreenHandlerDelegate() override;
void ShowError(int login_attempts,
const std::string& error_text,
const std::string& help_link_text,
HelpAppLauncher::HelpTopic help_topic_id) override;
- void ShowSigninUI(const std::string& email) override;
void ShowAllowlistCheckFailedError() override;
- void LoadUsers(const user_manager::UserList& users,
- const base::ListValue& users_list) override;
// content::NotificationObserver implementation:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
- // PowerManagerClient::Observer implementation:
- void SuspendDone(const base::TimeDelta& sleep_duration) override;
-
- // ash::TabletModeObserver:
- void OnTabletModeStarted() override;
- void OnTabletModeEnded() override;
-
- void OnTabletModeToggled(bool enabled);
-
- // Restore input focus to current user pod.
- void RefocusCurrentPod();
-
- // Enable or disable the pin keyboard for the given account.
- void UpdatePinKeyboardState(const AccountId& account_id);
- void SetPinEnabledForUser(const AccountId& account_id, bool is_enabled);
- // Callback run by PinBackend. If `should_preload` is true the PIN keyboard is
- // preloaded.
- void PreloadPinKeyboard(bool should_preload);
-
// WebUI message handlers.
void HandleAuthenticateUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin);
- void HandleCompleteOfflineAuthentication(const std::string& email,
- const std::string& password);
void HandleLaunchIncognito();
void HandleLaunchSAMLPublicSession(const std::string& email);
void HandleOfflineLogin(const base::ListValue* args);
void HandleToggleEnrollmentScreen();
- void HandleToggleKioskEnableScreen();
void HandleToggleResetScreen();
void HandleToggleKioskAutolaunchScreen();
- // TODO(crbug.com/943720): Change to views account-picker screen in post-OOBE
- // flow.
- // WebUI account-picker screen is shown:
- // * After OOBE enrollment when policy contains device local accounts.
- // * On multiple sign-in account selection.
- void HandleAccountPickerReady();
void HandleOpenInternetDetailDialog();
void HandleLoginVisible(const std::string& source);
- void HandleCancelUserAdding();
void HandleLoginUIStateChanged(const std::string& source, bool active);
void HandleLoginScreenUpdate();
void HandleShowLoadingTimeoutError();
- void HandleFocusPod(const AccountId& account_id, bool is_large_pod);
void HandleNoPodFocused();
void HandleHardlockPod(const std::string& user_id);
void HandleLaunchKioskApp(const AccountId& app_account_id,
bool diagnostic_mode);
void HandleLaunchArcKioskApp(const AccountId& app_account_id);
- void HandleGetPublicSessionKeyboardLayouts(const AccountId& account_id,
- const std::string& locale);
- void HandleGetTabletModeState();
- void HandleGetDemoModeState();
- void HandleLogRemoveUserWarningShown();
- void HandleFirstIncorrectPasswordAttempt(const AccountId& account_id);
- void HandleMaxIncorrectPasswordAttempts(const AccountId& account_id);
- void HandleSendFeedback();
// Implements user sign-in.
void AuthenticateExistingUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin);
- // Sends the list of `keyboard_layouts` available for the `locale` that is
- // currently selected for the public session identified by `user_id`.
- void SendPublicSessionKeyboardLayouts(
- const AccountId& account_id,
- const std::string& locale,
- std::unique_ptr<base::ListValue> keyboard_layouts);
-
// Returns true iff
// (i) log in is restricted to some user list,
// (ii) all users in the restricted list are present.
@@ -336,16 +240,8 @@ class SigninScreenHandler
// screen.
bool IsSigninScreenHiddenByError() const;
- bool ShouldLoadGaia() const;
-
net::Error FrameError() const;
- // input_method::ImeKeyboard::Observer implementation:
- void OnCapsLockChanged(bool enabled) override;
- void OnLayoutChanging(const std::string& layout_name) override {}
-
- // Callback invoked after the feedback is finished.
- void OnFeedbackFinished();
// After proxy auth information has been supplied, this function re-enables
// responding to network state notifications.
@@ -363,9 +259,6 @@ class SigninScreenHandler
// Keeps whether screen should be shown for OOBE.
bool oobe_ui_ = false;
- // Is account picker being shown for the first time.
- bool is_account_picker_showing_first_time_ = false;
-
// Network state informer used to keep signin screen up.
scoped_refptr<NetworkStateInformer> network_state_informer_;
@@ -379,8 +272,8 @@ class SigninScreenHandler
NetworkStateInformer::State last_network_state_ =
NetworkStateInformer::UNKNOWN;
- base::CancelableClosure update_state_closure_;
- base::CancelableClosure connecting_closure_;
+ base::CancelableOnceCallback<void()> update_state_callback_;
+ base::CancelableOnceCallback<void()> connecting_callback_;
content::NotificationRegistrar registrar_;
@@ -410,19 +303,14 @@ class SigninScreenHandler
// Input Method Engine state used at signin screen.
scoped_refptr<input_method::InputMethodManager::State> ime_state_;
- // True if SigninScreenHandler has already been added to OobeUI observers.
- bool oobe_ui_observer_added_ = false;
-
bool is_offline_timeout_for_test_set_ = false;
base::TimeDelta offline_timeout_for_test_;
std::unique_ptr<ErrorScreensHistogramHelper> histogram_helper_;
- std::unique_ptr<LoginFeedback> login_feedback_;
-
+ // TODO (crbug.com/1168114): Only needed for GetKeyboardRemappedPrefValue that
+ // should be migrated.
std::unique_ptr<AccountId> focused_pod_account_id_;
- base::Optional<system::SystemClock::ScopedHourClockType>
- focused_user_clock_type_;
base::WeakPtrFactory<SigninScreenHandler> weak_factory_{this};
@@ -431,4 +319,9 @@ class SigninScreenHandler
} // namespace chromeos
+// TODO(https://crbug.com/1164001): remove when moved to ash.
+namespace ash {
+using ::chromeos::SigninScreenHandler;
+}
+
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
index 6eb50149d50..57d2d696a51 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
@@ -8,11 +8,11 @@
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
-#include "chrome/browser/chromeos/login/screens/user_selection_screen.h"
+#include "chrome/browser/ash/login/screens/user_selection_screen.h"
+#include "chrome/browser/ash/settings/scoped_cros_settings_test_helper.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller_delegate.h"
-#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc
index befd7e5eea4..a8db5d3b4c8 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc
@@ -8,12 +8,12 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
+#include "chrome/browser/ash/login/screens/supervision_transition_screen.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/supervision_transition_screen.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/ash/system_tray_client.h"
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 10dc2255775..def45bc8a6f 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
@@ -4,12 +4,12 @@
#include "chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h"
+#include "ash/constants/ash_features.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/login/screens/sync_consent_screen.h"
+#include "chrome/browser/ash/login/screens/sync_consent_screen.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/login/localized_values_builder.h"
#include "components/user_manager/user_manager.h"
#include "ui/base/l10n/l10n_util.h"
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 a771cd408b2..82a2e7bff86 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
@@ -11,19 +11,16 @@
#include "base/callback_helpers.h"
#include "base/strings/string_split.h"
#include "base/values.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/chromeos/base/locale_util.h"
-#include "chrome/browser/chromeos/login/screens/terms_of_service_screen.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "components/language/core/browser/pref_names.h"
-#include "components/language/core/common/locale_util.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user.h"
@@ -36,10 +33,8 @@ namespace chromeos {
constexpr StaticOobeScreenId TermsOfServiceScreenView::kScreenId;
TermsOfServiceScreenHandler::TermsOfServiceScreenHandler(
- JSCallsContainer* js_calls_container,
- CoreOobeView* core_oobe_view)
- : BaseScreenHandler(kScreenId, js_calls_container),
- core_oobe_view_(core_oobe_view) {
+ JSCallsContainer* js_calls_container)
+ : BaseScreenHandler(kScreenId, js_calls_container) {
set_user_acted_method_path("login.TermsOfServiceScreen.userActed");
}
@@ -54,8 +49,6 @@ void TermsOfServiceScreenHandler::DeclareLocalizedValues(
IDS_TERMS_OF_SERVICE_SCREEN_HEADING);
builder->Add("termsOfServiceScreenSubheading",
IDS_TERMS_OF_SERVICE_SCREEN_SUBHEADING);
- builder->Add("termsOfServiceContentHeading",
- IDS_TERMS_OF_SERVICE_SCREEN_CONTENT_HEADING);
builder->Add("termsOfServiceLoading", IDS_TERMS_OF_SERVICE_SCREEN_LOADING);
builder->Add("termsOfServiceError", IDS_TERMS_OF_SERVICE_SCREEN_ERROR);
builder->Add("termsOfServiceTryAgain", IDS_TERMS_OF_SERVICE_SCREEN_TRY_AGAIN);
@@ -77,38 +70,15 @@ void TermsOfServiceScreenHandler::Show() {
show_on_init_ = true;
return;
}
-
- std::string locale =
- ProfileHelper::Get()
- ->GetProfileByUserUnsafe(
- user_manager::UserManager::Get()->GetActiveUser())
- ->GetPrefs()
- ->GetString(language::prefs::kApplicationLocale);
- language::ConvertToActualUILocale(&locale);
-
- if (locale.empty() || locale == g_browser_process->GetApplicationLocale()) {
- // If the user has not chosen a UI locale yet or the chosen locale matches
- // the current UI locale, show the screen immediately.
- DoShow();
- return;
- }
-
- // Switch to the user's UI locale before showing the screen.
- locale_util::SwitchLanguageCallback callback(
- base::Bind(&TermsOfServiceScreenHandler::OnLanguageChangedCallback,
- base::Unretained(this)));
- locale_util::SwitchLanguage(locale,
- true, // enable_locale_keyboard_layouts
- false, // login_layouts_only
- callback, ProfileManager::GetActiveUserProfile());
+ DoShow();
}
void TermsOfServiceScreenHandler::Hide() {
}
-void TermsOfServiceScreenHandler::SetDomain(const std::string& domain) {
- domain_ = domain;
- UpdateDomainInUI();
+void TermsOfServiceScreenHandler::SetManager(const std::string& manager) {
+ manager_ = manager;
+ UpdateManagerInUI();
}
void TermsOfServiceScreenHandler::OnLoadError() {
@@ -135,16 +105,6 @@ void TermsOfServiceScreenHandler::Initialize() {
}
}
-void TermsOfServiceScreenHandler::OnLanguageChangedCallback(
- const locale_util::LanguageSwitchResult& result) {
- // Update the screen contents to the new locale.
- base::DictionaryValue localized_strings;
- GetOobeUI()->GetLocalizedStrings(&localized_strings);
- core_oobe_view_->ReloadContent(localized_strings);
-
- DoShow();
-}
-
void TermsOfServiceScreenHandler::DoShow() {
// Determine the user's most preferred input method.
std::vector<std::string> input_methods = base::SplitString(
@@ -165,8 +125,8 @@ void TermsOfServiceScreenHandler::DoShow() {
input_methods.front(), false /* show_message */);
}
- // Updates the domain name shown in the UI.
- UpdateDomainInUI();
+ // Updates the manager name shown in the UI.
+ UpdateManagerInUI();
// Update the UI to show an error message or the Terms of Service.
UpdateTermsOfServiceInUI();
@@ -174,9 +134,9 @@ void TermsOfServiceScreenHandler::DoShow() {
ShowScreen(kScreenId);
}
-void TermsOfServiceScreenHandler::UpdateDomainInUI() {
+void TermsOfServiceScreenHandler::UpdateManagerInUI() {
if (page_is_ready())
- CallJS("login.TermsOfServiceScreen.setDomain", domain_);
+ CallJS("login.TermsOfServiceScreen.setManager", manager_);
}
void TermsOfServiceScreenHandler::UpdateTermsOfServiceInUI() {
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 bd02d6caaa0..900ef753bf8 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
@@ -14,7 +14,6 @@
namespace chromeos {
-class CoreOobeView;
class TermsOfServiceScreen;
// Interface for dependency injection between TermsOfServiceScreen and its
@@ -34,8 +33,8 @@ class TermsOfServiceScreenView {
// Hides the contents of the screen.
virtual void Hide() = 0;
- // Sets the domain name whose Terms of Service are being shown.
- virtual void SetDomain(const std::string& domain) = 0;
+ // Sets the manager whose Terms of Service are being shown.
+ virtual void SetManager(const std::string& manager) = 0;
// Called when the download of the Terms of Service fails. Show an error
// message to the user.
@@ -55,8 +54,7 @@ class TermsOfServiceScreenHandler : public BaseScreenHandler,
public:
using TView = TermsOfServiceScreenView;
- TermsOfServiceScreenHandler(JSCallsContainer* js_calls_container,
- CoreOobeView* core_oobe_view);
+ explicit TermsOfServiceScreenHandler(JSCallsContainer* js_calls_container);
~TermsOfServiceScreenHandler() override;
// BaseScreenHandler:
@@ -67,7 +65,7 @@ class TermsOfServiceScreenHandler : public BaseScreenHandler,
void SetScreen(TermsOfServiceScreen* screen) override;
void Show() override;
void Hide() override;
- void SetDomain(const std::string& domain) override;
+ void SetManager(const std::string& manager) override;
void OnLoadError() override;
void OnLoadSuccess(const std::string& terms_of_service) override;
bool AreTermsLoaded() override;
@@ -76,17 +74,13 @@ class TermsOfServiceScreenHandler : public BaseScreenHandler,
// BaseScreenHandler:
void Initialize() override;
- // Callback invoked after the UI locale has been changed.
- void OnLanguageChangedCallback(
- const locale_util::LanguageSwitchResult& result);
-
// Switch to the user's preferred input method and show the screen. This
// method is called after it has been ensured that the current UI locale
// matches the UI locale chosen by the user.
void DoShow();
- // Update the domain name shown in the UI.
- void UpdateDomainInUI();
+ // Update the manager shown in the UI.
+ void UpdateManagerInUI();
// 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
@@ -95,13 +89,11 @@ class TermsOfServiceScreenHandler : public BaseScreenHandler,
TermsOfServiceScreen* screen_ = nullptr;
- CoreOobeView* core_oobe_view_ = nullptr;
-
// Whether the screen should be shown right after initialization.
bool show_on_init_ = false;
- // The domain name whose Terms of Service are being shown.
- std::string domain_;
+ // 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;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_browsertest.cc
new file mode 100644
index 00000000000..a359b4e0c8e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_browsertest.cc
@@ -0,0 +1,54 @@
+// 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 "ash/constants/ash_switches.h"
+#include "build/branding_buildflags.h"
+#include "chrome/browser/chromeos/login/test/oobe_base_test.h"
+#include "chrome/browser/chromeos/login/test/test_condition_waiter.h"
+#include "content/public/test/browser_test.h"
+
+namespace chromeos {
+
+class OobeTestApiTest : public OobeBaseTest {
+ public:
+ OobeTestApiTest() {}
+ ~OobeTestApiTest() override {}
+
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ command_line->AppendSwitch(switches::kEnableOobeTestAPI);
+ OobeBaseTest::SetUpCommandLine(command_line);
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(OobeTestApiTest, OobeAPI) {
+ test::OobeJS().CreateWaiter("window.OobeAPI")->Wait();
+ test::OobeJS()
+ .CreateWaiter("OobeAPI.screens.WelcomeScreen.isVisible()")
+ ->Wait();
+ test::OobeJS().Evaluate("OobeAPI.screens.WelcomeScreen.clickNext()");
+ test::OobeJS()
+ .CreateWaiter("OobeAPI.screens.NetworkScreen.isVisible()")
+ ->Wait();
+ test::OobeJS().Evaluate("OobeAPI.screens.NetworkScreen.clickNext()");
+
+#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
+ test::OobeJS().ExpectFalse("OobeAPI.screens.EulaScreen.shouldSkip()");
+ test::OobeJS().CreateWaiter("OobeAPI.screens.EulaScreen.isVisible()")->Wait();
+ test::OobeJS().Evaluate("OobeAPI.screens.EulaScreen.clickNext()");
+#else
+ test::OobeJS().ExpectTrue("OobeAPI.screens.EulaScreen.shouldSkip()");
+#endif
+}
+
+class NoOobeTestApiTest : public OobeBaseTest {
+ public:
+ NoOobeTestApiTest() {}
+ ~NoOobeTestApiTest() override {}
+};
+
+IN_PROC_BROWSER_TEST_F(NoOobeTestApiTest, NoOobeAPI) {
+ test::OobeJS().ExpectFalse("window.OobeAPI");
+}
+
+} // 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
new file mode 100644
index 00000000000..5c3beb73aac
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.cc
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 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/login/testapi/oobe_test_api_handler.h"
+
+#include "build/branding_buildflags.h"
+
+namespace chromeos {
+
+OobeTestAPIHandler::OobeTestAPIHandler(JSCallsContainer* js_calls_container)
+ : BaseWebUIHandler(js_calls_container) {
+ DCHECK(js_calls_container);
+}
+
+OobeTestAPIHandler::~OobeTestAPIHandler() {}
+
+void OobeTestAPIHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {}
+
+void OobeTestAPIHandler::Initialize() {}
+
+void OobeTestAPIHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
+ dict->SetBoolean("isBrandedBuild", BUILDFLAG(GOOGLE_CHROME_BRANDING));
+}
+
+} // namespace chromeos
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
new file mode 100644
index 00000000000..220776d7580
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/testapi/oobe_test_api_handler.h
@@ -0,0 +1,29 @@
+// Copyright (c) 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_CHROMEOS_LOGIN_TESTAPI_OOBE_TEST_API_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TESTAPI_OOBE_TEST_API_HANDLER_H_
+
+#include "base/values.h"
+#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
+
+namespace chromeos {
+
+class OobeTestAPIHandler : public BaseWebUIHandler {
+ public:
+ explicit OobeTestAPIHandler(JSCallsContainer* js_calls_container);
+ ~OobeTestAPIHandler() override;
+ OobeTestAPIHandler(const OobeTestAPIHandler&) = delete;
+ OobeTestAPIHandler& operator=(const OobeTestAPIHandler&) = delete;
+
+ // WebUIMessageHandler implementation:
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void Initialize() override;
+ void GetAdditionalParameters(base::DictionaryValue* dict) override;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_TESTAPI_OOBE_TEST_API_HANDLER_H_
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 16f1e686924..59ed5d33950 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,8 +5,8 @@
#include "chrome/browser/ui/webui/chromeos/login/tpm_error_screen_handler.h"
#include "base/values.h"
+#include "chrome/browser/ash/login/screens/tpm_error_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/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"
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 410e58309f4..baa15c2bba7 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
@@ -7,8 +7,8 @@
#include <memory>
#include "base/values.h"
+#include "chrome/browser/ash/login/screens/update_required_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/update_required_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
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 2e8c51fa017..4876181939a 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
@@ -9,7 +9,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/screens/update_required_screen.h"
+#include "chrome/browser/ash/login/screens/update_required_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc
index aac46d69af4..1a37036cf4f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc
@@ -6,14 +6,13 @@
#include <memory>
+#include "ash/constants/ash_features.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
+#include "chrome/browser/ash/login/screens/update_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/update_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/login/localized_values_builder.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -21,14 +20,26 @@ namespace chromeos {
constexpr StaticOobeScreenId UpdateView::kScreenId;
+namespace {
+
+constexpr bool strings_equal(char const* a, char const* b) {
+ return *a == *b && (*a == '\0' || strings_equal(a + 1, b + 1));
+}
+static_assert(strings_equal(UpdateView::kScreenId.name, "oobe-update"),
+ "The update screen id must never change");
+
+// These values must be kept in sync with UIState in JS code.
+constexpr const char kCheckingForUpdate[] = "checking";
+constexpr const char kUpdateInProgress[] = "update";
+constexpr const char kRestartInProgress[] = "restart";
+constexpr const char kManualReboot[] = "reboot";
+constexpr const char kCellularPermission[] = "cellular";
+
+} // namespace
+
UpdateScreenHandler::UpdateScreenHandler(JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
set_user_acted_method_path("login.UpdateScreen.userActed");
- AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
- CHECK(accessibility_manager);
- accessibility_subscription_ = accessibility_manager->RegisterCallback(
- base::Bind(&UpdateScreenHandler::OnAccessibilityStatusChanged,
- base::Unretained(this)));
}
UpdateScreenHandler::~UpdateScreenHandler() {
@@ -56,19 +67,28 @@ void UpdateScreenHandler::Unbind() {
BaseScreenHandler::SetBaseScreen(nullptr);
}
-void UpdateScreenHandler::OnAccessibilityStatusChanged(
- const AccessibilityStatusEventDetails& details) {
- if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) {
- accessibility_subscription_.reset();
- return;
+void UpdateScreenHandler::SetUpdateState(UpdateView::UIState value) {
+ switch (value) {
+ case UpdateView::UIState::kCheckingForUpdate:
+ CallJS("login.UpdateScreen.setUpdateState",
+ std::string(kCheckingForUpdate));
+ break;
+ case UpdateView::UIState::kUpdateInProgress:
+ CallJS("login.UpdateScreen.setUpdateState",
+ std::string(kUpdateInProgress));
+ break;
+ case UpdateView::UIState::kRestartInProgress:
+ CallJS("login.UpdateScreen.setUpdateState",
+ std::string(kRestartInProgress));
+ break;
+ case UpdateView::UIState::kManualReboot:
+ CallJS("login.UpdateScreen.setUpdateState", std::string(kManualReboot));
+ break;
+ case UpdateView::UIState::kCellularPermission:
+ CallJS("login.UpdateScreen.setUpdateState",
+ std::string(kCellularPermission));
+ break;
}
-
- CallJS("login.UpdateScreen.setAutoTransition",
- !AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
-}
-
-void UpdateScreenHandler::SetUIState(UpdateView::UIState value) {
- CallJS("login.UpdateScreen.setUIState", static_cast<int>(value));
}
void UpdateScreenHandler::SetUpdateStatus(
@@ -79,60 +99,26 @@ void UpdateScreenHandler::SetUpdateStatus(
timeleft_message);
}
-void UpdateScreenHandler::SetEstimatedTimeLeft(int value) {
- CallJS("login.UpdateScreen.setEstimatedTimeLeft", value);
-}
-
-void UpdateScreenHandler::SetShowEstimatedTimeLeft(bool value) {
- CallJS("login.UpdateScreen.showEstimatedTimeLeft", value);
-}
-
-void UpdateScreenHandler::SetUpdateCompleted(bool value) {
- CallJS("login.UpdateScreen.setUpdateCompleted", value);
-}
-
-void UpdateScreenHandler::SetShowCurtain(bool value) {
- CallJS("login.UpdateScreen.showUpdateCurtain", value);
-}
-
-void UpdateScreenHandler::SetProgressMessage(const base::string16& value) {
- CallJS("login.UpdateScreen.setProgressMessage", value);
-}
-
-void UpdateScreenHandler::SetProgress(int value) {
- CallJS("login.UpdateScreen.setUpdateProgress", value);
+void UpdateScreenHandler::ShowLowBatteryWarningMessage(bool value) {
+ CallJS("login.UpdateScreen.showLowBatteryWarningMessage", value);
}
-void UpdateScreenHandler::SetRequiresPermissionForCellular(bool value) {
- CallJS("login.UpdateScreen.setRequiresPermissionForCellular", value);
+void UpdateScreenHandler::SetAutoTransition(bool value) {
+ CallJS("login.UpdateScreen.setAutoTransition", value);
}
void UpdateScreenHandler::SetCancelUpdateShortcutEnabled(bool value) {
CallJS("login.UpdateScreen.setCancelUpdateShortcutEnabled", value);
}
-void UpdateScreenHandler::ShowLowBatteryWarningMessage(bool value) {
- CallJS("login.UpdateScreen.showLowBatteryWarningMessage", value);
-}
-
void UpdateScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->Add("checkingForUpdatesMsg", IDS_CHECKING_FOR_UPDATE_MSG);
- builder->AddF("installingUpdateDesc", IDS_UPDATE_MSG,
- ui::GetChromeOSDeviceName());
builder->Add("updateCompeletedMsg", IDS_UPDATE_COMPLETED);
builder->Add("updateCompeletedRebootingMsg", IDS_UPDATE_COMPLETED_REBOOTING);
builder->Add("updateStatusTitle", IDS_UPDATE_STATUS_TITLE);
builder->Add("updateScreenAccessibleTitle",
IDS_UPDATE_SCREEN_ACCESSIBLE_TITLE);
builder->Add("checkingForUpdates", IDS_CHECKING_FOR_UPDATES);
- builder->Add("downloading", IDS_DOWNLOADING);
- builder->Add("downloadingTimeLeftLong", IDS_DOWNLOADING_TIME_LEFT_LONG);
- builder->Add("downloadingTimeLeftStatusOneHour",
- IDS_DOWNLOADING_TIME_LEFT_STATUS_ONE_HOUR);
- builder->Add("downloadingTimeLeftStatusMinutes",
- IDS_DOWNLOADING_TIME_LEFT_STATUS_MINUTES);
- builder->Add("downloadingTimeLeftSmall", IDS_DOWNLOADING_TIME_LEFT_SMALL);
builder->Add("slideUpdateTitle", IDS_UPDATE_SLIDE_UPDATE_TITLE);
builder->Add("slideUpdateText", IDS_UPDATE_SLIDE_UPDATE_TEXT);
@@ -162,15 +148,6 @@ void UpdateScreenHandler::DeclareLocalizedValues(
IDS_UPDATE_OVER_CELLULAR_PROMPT_TITLE);
builder->Add("updateOverCellularPromptMessage",
IDS_UPDATE_OVER_CELLULAR_PROMPT_MESSAGE);
-
- // For Material Design OOBE
- builder->Add("updatingScreenTitle", IDS_UPDATING_SCREEN_TITLE);
-}
-
-void UpdateScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
- dict->SetBoolKey("betterUpdateScreenFeatureEnabled",
- chromeos::features::IsBetterUpdateEnabled());
- BaseScreenHandler::GetAdditionalParameters(dict);
}
void UpdateScreenHandler::Initialize() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h
index 049ef45c262..75e035d0d7e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h
@@ -10,7 +10,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
+#include "chrome/browser/ash/accessibility/accessibility_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
@@ -26,13 +26,12 @@ class UpdateView {
// versions.
constexpr static StaticOobeScreenId kScreenId{"oobe-update"};
- // Enumeration of UI states. These values must be kept in sync with
- // UpdateUIState in JS code.
enum class UIState {
kCheckingForUpdate = 0,
- KUpdateInProgress = 1,
+ kUpdateInProgress = 1,
kRestartInProgress = 2,
kManualReboot = 3,
+ kCellularPermission = 4,
};
virtual ~UpdateView() {}
@@ -49,20 +48,13 @@ class UpdateView {
// Unbinds the screen from the view.
virtual void Unbind() = 0;
- virtual void SetUIState(UIState value) = 0;
+ virtual void SetUpdateState(UIState value) = 0;
virtual void SetUpdateStatus(int percent,
const base::string16& percent_message,
const base::string16& timeleft_message) = 0;
- // Set the estimated time left, in seconds.
- virtual void SetEstimatedTimeLeft(int value) = 0;
- virtual void SetShowEstimatedTimeLeft(bool value) = 0;
- virtual void SetUpdateCompleted(bool value) = 0;
- virtual void SetShowCurtain(bool value) = 0;
- virtual void SetProgressMessage(const base::string16& value) = 0;
- virtual void SetProgress(int value) = 0;
- virtual void SetRequiresPermissionForCellular(bool value) = 0;
- virtual void SetCancelUpdateShortcutEnabled(bool value) = 0;
virtual void ShowLowBatteryWarningMessage(bool value) = 0;
+ virtual void SetAutoTransition(bool value) = 0;
+ virtual void SetCancelUpdateShortcutEnabled(bool value) = 0;
};
class UpdateScreenHandler : public UpdateView, public BaseScreenHandler {
@@ -79,34 +71,24 @@ class UpdateScreenHandler : public UpdateView, public BaseScreenHandler {
void Bind(UpdateScreen* screen) override;
void Unbind() override;
- void SetUIState(UpdateView::UIState value) override;
+ void SetUpdateState(UpdateView::UIState value) override;
void SetUpdateStatus(int percent,
const base::string16& percent_message,
const base::string16& timeleft_message) override;
- void SetEstimatedTimeLeft(int value) override;
- void SetShowEstimatedTimeLeft(bool value) override;
- void SetUpdateCompleted(bool value) override;
- void SetShowCurtain(bool value) override;
- void SetProgressMessage(const base::string16& value) override;
- void SetProgress(int value) override;
- void SetRequiresPermissionForCellular(bool value) override;
- void SetCancelUpdateShortcutEnabled(bool value) override;
void ShowLowBatteryWarningMessage(bool value) override;
+ void SetAutoTransition(bool value) override;
+ void SetCancelUpdateShortcutEnabled(bool value) override;
- // Notification of a change in the accessibility settings.
void OnAccessibilityStatusChanged(
- const AccessibilityStatusEventDetails& details);
+ const ash::AccessibilityStatusEventDetails& details);
// BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void GetAdditionalParameters(base::DictionaryValue* dict) override;
void Initialize() override;
UpdateScreen* screen_ = nullptr;
- std::unique_ptr<AccessibilityStatusSubscription> accessibility_subscription_;
-
// If true, Initialize() will call Show().
bool show_on_init_ = false;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc
deleted file mode 100644
index e11e262c626..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2013 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/login/user_board_screen_handler.h"
-
-#include "chrome/browser/chromeos/login/screens/user_selection_screen.h"
-#include "components/login/localized_values_builder.h"
-
-namespace chromeos {
-
-constexpr StaticOobeScreenId UserBoardView::kScreenId;
-
-UserBoardScreenHandler::UserBoardScreenHandler(
- JSCallsContainer* js_calls_container)
- : BaseScreenHandler(kScreenId, js_calls_container) {}
-
-UserBoardScreenHandler::~UserBoardScreenHandler() {
-}
-
-void UserBoardScreenHandler::DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) {
-}
-
-void UserBoardScreenHandler::RegisterMessages() {
- AddCallback("attemptUnlock", &UserBoardScreenHandler::HandleAttemptUnlock);
- AddCallback("hardlockPod", &UserBoardScreenHandler::HandleHardlockPod);
-}
-
-void UserBoardScreenHandler::Initialize() {
-}
-
-//----------------- Handlers
-
-void UserBoardScreenHandler::HandleHardlockPod(const AccountId& account_id) {
- CHECK(screen_);
- screen_->HardLockPod(account_id);
-}
-
-void UserBoardScreenHandler::HandleAttemptUnlock(const AccountId& account_id) {
- CHECK(screen_);
- screen_->AttemptEasyUnlock(account_id);
-}
-
-//----------------- API
-
-void UserBoardScreenHandler::SetPublicSessionDisplayName(
- const AccountId& account_id,
- const std::string& display_name) {
- CallJS("login.AccountPickerScreen.setPublicSessionDisplayName", account_id,
- display_name);
-}
-
-void UserBoardScreenHandler::SetPublicSessionLocales(
- const AccountId& account_id,
- std::unique_ptr<base::ListValue> locales,
- const std::string& default_locale,
- bool multiple_recommended_locales) {
- CallJS("login.AccountPickerScreen.setPublicSessionLocales", account_id,
- *locales, default_locale, multiple_recommended_locales);
-}
-
-void UserBoardScreenHandler::SetPublicSessionShowFullManagementDisclosure(
- bool show_full_management_disclosure) {
- // This method is only called from browser_tests and shouldn't do anything.
-}
-
-void UserBoardScreenHandler::ShowBannerMessage(const base::string16& message,
- bool is_warning) {
- CallJS("login.AccountPickerScreen.showBannerMessage", message, is_warning);
-}
-
-void UserBoardScreenHandler::ShowUserPodCustomIcon(
- const AccountId& account_id,
- const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
- icon_options) {
- std::unique_ptr<base::DictionaryValue> icon =
- icon_options.ToDictionaryValue();
- if (!icon || icon->empty())
- return;
- CallJS("login.AccountPickerScreen.showUserPodCustomIcon", account_id, *icon);
-}
-
-void UserBoardScreenHandler::HideUserPodCustomIcon(
- const AccountId& account_id) {
- CallJS("login.AccountPickerScreen.hideUserPodCustomIcon", account_id);
-}
-
-void UserBoardScreenHandler::SetAuthType(
- const AccountId& account_id,
- proximity_auth::mojom::AuthType auth_type,
- const base::string16& initial_value) {
- CallJS("login.AccountPickerScreen.setAuthType", account_id,
- static_cast<int>(auth_type), base::Value(initial_value));
-}
-
-void UserBoardScreenHandler::SetTpmLockedState(const AccountId& account_id,
- bool is_locked,
- base::TimeDelta time_left) {}
-
-void UserBoardScreenHandler::Bind(UserSelectionScreen* screen) {
- screen_ = screen;
- SetBaseScreen(screen_);
-}
-
-void UserBoardScreenHandler::Unbind() {
- screen_ = nullptr;
- SetBaseScreen(nullptr);
-}
-
-base::WeakPtr<UserBoardView> UserBoardScreenHandler::GetWeakPtr() {
- return weak_factory_.GetWeakPtr();
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h
deleted file mode 100644
index 247a17484b3..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2013 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_LOGIN_USER_BOARD_SCREEN_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_BOARD_SCREEN_HANDLER_H_
-
-#include <memory>
-
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "base/values.h"
-#include "chrome/browser/chromeos/login/ui/views/user_board_view.h"
-#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-
-namespace chromeos {
-
-// TODO(jdufault): Rename to UserSelectionScreenHandler and ensure this in the
-// right directory. See crbug.com/672142.
-
-// A class that handles WebUI hooks in Gaia screen.
-class UserBoardScreenHandler : public BaseScreenHandler, public UserBoardView {
- public:
- using TView = UserBoardView;
-
- explicit UserBoardScreenHandler(JSCallsContainer* js_calls_container);
- ~UserBoardScreenHandler() override;
-
- private:
- // BaseScreenHandler implementation:
- void DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) override;
-
- // WebUIMessageHandler implementation:
- void RegisterMessages() override;
- void Initialize() override;
-
- // Handlers
- void HandleHardlockPod(const AccountId& account_id);
- void HandleAttemptUnlock(const AccountId& account_id);
-
- // UserBoardView implementation:
- void SetPublicSessionDisplayName(const AccountId& account_id,
- const std::string& display_name) override;
- void SetPublicSessionLocales(const AccountId& account_id,
- std::unique_ptr<base::ListValue> locales,
- const std::string& default_locale,
- bool multiple_recommended_locales) override;
- void SetPublicSessionShowFullManagementDisclosure(
- bool show_full_management_disclosure) override;
- void ShowBannerMessage(const base::string16& message,
- bool is_warning) override;
- void ShowUserPodCustomIcon(
- const AccountId& account_id,
- const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
- icon_options) override;
- void HideUserPodCustomIcon(const AccountId& account_id) override;
- void SetAuthType(const AccountId& account_id,
- proximity_auth::mojom::AuthType auth_type,
- const base::string16& initial_value) override;
- void SetTpmLockedState(const AccountId& account_id,
- bool is_locked,
- base::TimeDelta time_left) override;
-
- void Bind(UserSelectionScreen* screen) override;
- void Unbind() override;
- base::WeakPtr<UserBoardView> GetWeakPtr() override;
-
- UserSelectionScreen* screen_ = nullptr;
- base::WeakPtrFactory<UserBoardScreenHandler> weak_factory_{this};
-
- DISALLOW_COPY_AND_ASSIGN(UserBoardScreenHandler);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_BOARD_SCREEN_HANDLER_H_
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 a7725f5d37c..6e7c725553a 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
@@ -5,8 +5,8 @@
#include "chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h"
#include "base/values.h"
+#include "chrome/browser/ash/login/screens/user_creation_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/user_creation_screen.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
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 68083543860..ce8f3aa1d20 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
@@ -11,23 +11,25 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
+#include "base/metrics/histogram_functions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner_util.h"
#include "base/values.h"
+#include "chrome/browser/ash/accessibility/accessibility_manager.h"
+#include "chrome/browser/ash/accessibility/magnification_manager.h"
+#include "chrome/browser/ash/login/demo_mode/demo_session.h"
+#include "chrome/browser/ash/login/screens/welcome_screen.h"
+#include "chrome/browser/ash/system/input_device_settings.h"
+#include "chrome/browser/ash/system/timezone_util.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
-#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
-#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
-#include "chrome/browser/chromeos/login/screens/welcome_screen.h"
#include "chrome/browser/chromeos/login/ui/input_events_blocker.h"
-#include "chrome/browser/chromeos/system/input_device_settings.h"
-#include "chrome/browser/chromeos/system/timezone_util.h"
+#include "chrome/browser/chromeos/policy/enrollment_requisition_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
+#include "chromeos/dbus/constants/dbus_switches.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
@@ -36,9 +38,13 @@
#include "ui/base/ime/chromeos/component_extension_ime_manager.h"
#include "ui/base/ime/chromeos/extension_ime_util.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
+#include "ui/chromeos/devicetype_utils.h"
namespace chromeos {
+using ::ash::AccessibilityManager;
+using ::ash::MagnificationManager;
+
constexpr StaticOobeScreenId WelcomeView::kScreenId;
// WelcomeScreenHandler, public: -----------------------------------------------
@@ -53,8 +59,8 @@ WelcomeScreenHandler::WelcomeScreenHandler(JSCallsContainer* js_calls_container,
AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
CHECK(accessibility_manager);
accessibility_subscription_ = accessibility_manager->RegisterCallback(
- base::Bind(&WelcomeScreenHandler::OnAccessibilityStatusChanged,
- base::Unretained(this)));
+ base::BindRepeating(&WelcomeScreenHandler::OnAccessibilityStatusChanged,
+ base::Unretained(this)));
}
WelcomeScreenHandler::~WelcomeScreenHandler() {
@@ -126,10 +132,19 @@ void WelcomeScreenHandler::ShowRemoraRequisitionDialog() {
void WelcomeScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation())
+ if (policy::EnrollmentRequisitionManager::IsRemoraRequisition()) {
+ builder->Add("newWelcomeScreenGreeting", IDS_REMORA_CONFIRM_MESSAGE);
+ builder->Add("newWelcomeScreenGreetingSubtitle", IDS_EMPTY_STRING);
builder->Add("welcomeScreenGreeting", IDS_REMORA_CONFIRM_MESSAGE);
- else
+ } else {
+ builder->AddF("newWelcomeScreenGreeting", IDS_NEW_WELCOME_SCREEN_GREETING,
+ ui::GetChromeOSDeviceTypeResourceId());
+ builder->Add("newWelcomeScreenGreetingSubtitle",
+ IDS_WELCOME_SCREEN_GREETING_SUBTITLE);
builder->Add("welcomeScreenGreeting", IDS_WELCOME_SCREEN_GREETING);
+ }
+
+ builder->Add("welcomeScreenGetStarted", IDS_LOGIN_GET_STARTED);
// MD-OOBE (oobe-welcome-element)
builder->Add("debuggingFeaturesLink", IDS_WELCOME_ENABLE_DEV_FEATURES_LINK);
@@ -184,6 +199,15 @@ void WelcomeScreenHandler::DeclareLocalizedValues(
IDS_ENABLE_DEMO_MODE_DIALOG_CONFIRM);
builder->Add("enableDemoModeDialogCancel",
IDS_ENABLE_DEMO_MODE_DIALOG_CANCEL);
+
+ // Strings for ChromeVox hint.
+ builder->Add("activateChromeVox", IDS_OOBE_ACTIVATE_CHROMEVOX);
+ builder->Add("continueWithoutChromeVox", IDS_OOBE_CONTINUE_WITHOUT_CHROMEVOX);
+ builder->Add("chromeVoxHintText", IDS_OOBE_CHROMEVOX_HINT_TEXT);
+ builder->Add("chromeVoxHintAnnouncementTextLaptop",
+ IDS_OOBE_CHROMEVOX_HINT_ANNOUNCEMENT_TEXT_LAPTOP);
+ builder->Add("chromeVoxHintAnnouncementTextTablet",
+ IDS_OOBE_CHROMEVOX_HINT_ANNOUNCEMENT_TEXT_TABLET);
}
void WelcomeScreenHandler::DeclareJSCallbacks() {
@@ -195,10 +219,31 @@ void WelcomeScreenHandler::DeclareJSCallbacks() {
&WelcomeScreenHandler::HandleSetTimezoneId);
AddCallback("WelcomeScreen.setDeviceRequisition",
&WelcomeScreenHandler::HandleSetDeviceRequisition);
+ AddCallback("WelcomeScreen.recordChromeVoxHintSpokenSuccess",
+ &WelcomeScreenHandler::HandleRecordChromeVoxHintSpokenSuccess);
}
void WelcomeScreenHandler::GetAdditionalParameters(
base::DictionaryValue* dict) {
+ // GetAdditionalParameters() is called when OOBE language is updated.
+ // This happens in two different cases:
+ //
+ // 1) User selects new locale on OOBE screen. We need to sync active input
+ // methods with locale.
+ //
+ // 2) After user session started and user preferences applied.
+ // Either signin to public session: user has selected some locale & input
+ // method on "Public Session User pod". After "Login" button is pressed,
+ // new user session is created, locale & input method are changed (both
+ // asynchronously).
+ // Or signin to Gaia account which might trigger language change from the
+ // user locale or synced application locale.
+ // For the case 2) we might just skip this setup - welcome screen is not
+ // needed anymore.
+
+ if (user_manager::UserManager::Get()->IsUserLoggedIn())
+ return;
+
const std::string application_locale =
g_browser_process->GetApplicationLocale();
const std::string selected_input_method =
@@ -220,27 +265,7 @@ void WelcomeScreenHandler::GetAdditionalParameters(
if (!language_list)
language_list = GetMinimalUILanguageList();
- // GetAdditionalParameters() is called when OOBE language is updated.
- // This happens in two different cases:
- //
- // 1) User selects new locale on OOBE screen. We need to sync active input
- // methods with locale, so EnableLoginLayouts() is needed.
- //
- // 2) This is signin to public session. User has selected some locale & input
- // method on "Public Session User POD". After "Login" button is pressed,
- // new user session is created, locale & input method are changed (both
- // asynchronously).
- // But after public user session is started, "Terms of Service" dialog is
- // shown. It is a part of OOBE UI screens, so it initiates reload of UI
- // strings in new locale. It also happens asynchronously, that leads to race
- // between "locale change", "input method change" and
- // "EnableLoginLayouts()". This way EnableLoginLayouts() happens after user
- // input method has been changed, resetting input method to hardware default.
- //
- // So we need to disable activation of login layouts if we are already in
- // active user session.
- const bool enable_layouts =
- !user_manager::UserManager::Get()->IsUserLoggedIn();
+ const bool enable_layouts = true;
dict->Set("languageList", std::move(language_list));
dict->Set("inputMethodsList",
@@ -287,12 +312,25 @@ void WelcomeScreenHandler::HandleSetDeviceRequisition(
screen_->SetDeviceRequisition(requisition);
}
+void WelcomeScreenHandler::GiveChromeVoxHint() {
+ // Show the ChromeVox hint dialog and give a spoken announcement with
+ // instructions for activating ChromeVox.
+ CallJS("login.WelcomeScreen.maybeGiveChromeVoxHint");
+}
+
+void WelcomeScreenHandler::HandleRecordChromeVoxHintSpokenSuccess() {
+ base::UmaHistogramBoolean("OOBE.WelcomeScreen.ChromeVoxHintSpokenSuccess",
+ true);
+}
+
void WelcomeScreenHandler::OnAccessibilityStatusChanged(
- const AccessibilityStatusEventDetails& details) {
- if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN)
- accessibility_subscription_.reset();
- else
+ const ash::AccessibilityStatusEventDetails& details) {
+ if (details.notification_type ==
+ ash::AccessibilityNotificationType::kManagerShutdown) {
+ accessibility_subscription_ = {};
+ } else {
UpdateA11yState();
+ }
}
void WelcomeScreenHandler::UpdateA11yState() {
@@ -312,6 +350,8 @@ void WelcomeScreenHandler::UpdateA11yState() {
MagnificationManager::Get()->IsDockedMagnifierEnabled());
a11y_info.SetBoolean("virtualKeyboardEnabled",
AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
+ if (screen_ && AccessibilityManager::Get()->IsSpokenFeedbackEnabled())
+ screen_->CancelChromeVoxHintTimer();
CallJS("login.WelcomeScreen.refreshA11yInfo", a11y_info);
}
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 38c505d089d..6c2279ba45a 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
@@ -9,7 +9,7 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
+#include "chrome/browser/ash/accessibility/accessibility_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace base {
@@ -50,6 +50,9 @@ class WelcomeView {
virtual void ShowDemoModeConfirmationDialog() = 0;
virtual void ShowEditRequisitionDialog(const std::string& requisition) = 0;
virtual void ShowRemoraRequisitionDialog() = 0;
+
+ // ChromeVox hint.
+ virtual void GiveChromeVoxHint() = 0;
};
// WebUI implementation of WelcomeScreenView. It is used to interact with
@@ -72,6 +75,7 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler {
void ShowDemoModeConfirmationDialog() override;
void ShowEditRequisitionDialog(const std::string& requisition) override;
void ShowRemoraRequisitionDialog() override;
+ void GiveChromeVoxHint() override;
// BaseScreenHandler:
void DeclareLocalizedValues(
@@ -93,10 +97,11 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler {
void HandleEnableSelectToSpeak(bool /* enabled */);
void HandleEnableDockedMagnifier(bool /* enabled */);
void HandleSetDeviceRequisition(const std::string& requisition);
+ void HandleRecordChromeVoxHintSpokenSuccess();
// Notification of a change in the accessibility settings.
void OnAccessibilityStatusChanged(
- const AccessibilityStatusEventDetails& details);
+ const ash::AccessibilityStatusEventDetails& details);
// Updates a11y menu state based on the current a11y features state(on/off).
void UpdateA11yState();
@@ -110,7 +115,7 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler {
// Keeps whether screen should be shown right after initialization.
bool show_on_init_ = false;
- std::unique_ptr<AccessibilityStatusSubscription> accessibility_subscription_;
+ base::CallbackListSubscription accessibility_subscription_;
DISALLOW_COPY_AND_ASSIGN(WelcomeScreenHandler);
};
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 22167c3d0b2..1689f7afcb3 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
@@ -4,8 +4,8 @@
#include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h"
+#include "chrome/browser/ash/login/screens/wrong_hwid_screen.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/wrong_hwid_screen.h"
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_browsertest.cc
index 602fffb89a3..0bb888659b1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_browsertest.cc
@@ -9,8 +9,10 @@
#include "chromeos/services/machine_learning/public/cpp/fake_service_connection.h"
#include "chromeos/services/machine_learning/public/cpp/service_connection.h"
-MachineLearningInternalsBrowserTest::MachineLearningInternalsBrowserTest() = default;
-MachineLearningInternalsBrowserTest::~MachineLearningInternalsBrowserTest() = default;
+MachineLearningInternalsBrowserTest::MachineLearningInternalsBrowserTest() =
+ default;
+MachineLearningInternalsBrowserTest::~MachineLearningInternalsBrowserTest() =
+ default;
void MachineLearningInternalsBrowserTest::SetupFakeConnectionAndOutput(
double fake_output) {
@@ -18,6 +20,7 @@ void MachineLearningInternalsBrowserTest::SetupFakeConnectionAndOutput(
new chromeos::machine_learning::FakeServiceConnectionImpl();
fake_client->SetOutputValue(std::vector<int64_t>{1L},
std::vector<double>{fake_output});
- chromeos::machine_learning::ServiceConnection
- ::UseFakeServiceConnectionForTesting(fake_client);
+ chromeos::machine_learning::ServiceConnection::
+ UseFakeServiceConnectionForTesting(fake_client);
+ chromeos::machine_learning::ServiceConnection::GetInstance()->Initialize();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_page_handler.cc
index fb01a11f91f..85524e366e2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_page_handler.cc
@@ -23,8 +23,10 @@ void MachineLearningInternalsPageHandler::LoadBuiltinModel(
mojom::BuiltinModelSpecPtr spec,
mojo::PendingReceiver<mojom::Model> receiver,
LoadBuiltinModelCallback callback) {
- ServiceConnection::GetInstance()->LoadBuiltinModel(
- std::move(spec), std::move(receiver), std::move(callback));
+ ServiceConnection::GetInstance()
+ ->GetMachineLearningService()
+ .LoadBuiltinModel(std::move(spec), std::move(receiver),
+ std::move(callback));
}
} // namespace machine_learning
diff --git a/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc
index b84b0101053..fe60a5c19dd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/machine_learning/machine_learning_internals_ui.cc
@@ -43,6 +43,9 @@ MachineLearningInternalsUI::MachineLearningInternalsUI(
{IDR_MACHINE_LEARNING_INTERNALS_PAGE_HANDLER_MOJO_JS,
"chrome/browser/ui/webui/chromeos/machine_learning/"
"machine_learning_internals_page_handler.mojom-lite.js"},
+ {IDR_MACHINE_LEARNING_INTERNALS_SODA_MOJO_JS,
+ "chromeos/services/machine_learning/public/mojom/"
+ "soda.mojom-lite.js"},
{IDR_MACHINE_LEARNING_INTERNALS_TENSOR_MOJO_JS,
"chromeos/services/machine_learning/public/mojom/tensor.mojom-lite.js"},
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/DIR_METADATA
new file mode 100644
index 00000000000..ea7ecb01697
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "OS>Systems>Multidevice"
+}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/OWNERS
index 649f3f847cb..3e9667e3f87 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/OWNERS
@@ -1,2 +1 @@
-file://chromeos/components/multidevice/OWNERS
-# COMPONENT: OS>Systems>Multidevice
+file://chromeos/components/multidevice/OWNERS \ No newline at end of file
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 837677c7b72..990f81e6658 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
@@ -39,7 +39,7 @@ base::Value LogMessageToDictionary(
} // namespace
-MultideviceLogsHandler::MultideviceLogsHandler() : observer_(this) {}
+MultideviceLogsHandler::MultideviceLogsHandler() {}
MultideviceLogsHandler::~MultideviceLogsHandler() = default;
@@ -51,11 +51,11 @@ void MultideviceLogsHandler::RegisterMessages() {
}
void MultideviceLogsHandler::OnJavascriptAllowed() {
- observer_.Add(multidevice::LogBuffer::GetInstance());
+ observation_.Observe(multidevice::LogBuffer::GetInstance());
}
void MultideviceLogsHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void MultideviceLogsHandler::HandleGetLogMessages(const base::ListValue* args) {
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 e8cb0a8caee..92289bb47cd 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
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_LOGS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_LOGS_HANDLER_H_
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chromeos/components/multidevice/logging/log_buffer.h"
#include "chromeos/components/multidevice/logging/logging.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -45,8 +45,9 @@ class MultideviceLogsHandler : public content::WebUIMessageHandler,
// Message handler callback that clears the Log Buffer.
void ClearLogBuffer(const base::ListValue* args);
- ScopedObserver<multidevice::LogBuffer, multidevice::LogBuffer::Observer>
- observer_{this};
+ base::ScopedObservation<multidevice::LogBuffer,
+ multidevice::LogBuffer::Observer>
+ observation_{this};
};
} // namespace multidevice
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 d3846a46c9d..f26c58b1330 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
@@ -205,51 +205,24 @@ void MultidevicePhoneHubHandler::OnJavascriptDisallowed() {
}
void MultidevicePhoneHubHandler::AddObservers() {
- notification_manager_observer_.Add(
+ notification_manager_observation_.Observe(
fake_phone_hub_manager_->fake_notification_manager());
- do_not_disturb_controller_observer_.Add(
+ do_not_disturb_controller_observation_.Observe(
fake_phone_hub_manager_->fake_do_not_disturb_controller());
- find_my_device_controller_oberserver_.Add(
+ find_my_device_controller_observation_.Observe(
fake_phone_hub_manager_->fake_find_my_device_controller());
- tether_controller_observer_.Add(
+ tether_controller_observation_.Observe(
fake_phone_hub_manager_->fake_tether_controller());
- onboarding_ui_tracker_observer_.Add(
+ onboarding_ui_tracker_observation_.Observe(
fake_phone_hub_manager_->fake_onboarding_ui_tracker());
}
void MultidevicePhoneHubHandler::RemoveObservers() {
- phonehub::FakeNotificationManager* fake_notification_manager =
- fake_phone_hub_manager_->fake_notification_manager();
- if (notification_manager_observer_.IsObserving(fake_notification_manager)) {
- notification_manager_observer_.Remove(fake_notification_manager);
- }
-
- phonehub::FakeDoNotDisturbController* fake_do_not_disturb_controller =
- fake_phone_hub_manager_->fake_do_not_disturb_controller();
- if (do_not_disturb_controller_observer_.IsObserving(
- fake_do_not_disturb_controller)) {
- do_not_disturb_controller_observer_.Remove(fake_do_not_disturb_controller);
- }
-
- phonehub::FakeFindMyDeviceController* fake_find_my_device_controller =
- fake_phone_hub_manager_->fake_find_my_device_controller();
- if (find_my_device_controller_oberserver_.IsObserving(
- fake_find_my_device_controller)) {
- find_my_device_controller_oberserver_.Remove(
- fake_find_my_device_controller);
- }
-
- phonehub::FakeTetherController* fake_tether_controller =
- fake_phone_hub_manager_->fake_tether_controller();
- if (tether_controller_observer_.IsObserving(fake_tether_controller)) {
- tether_controller_observer_.Remove(fake_tether_controller);
- }
-
- phonehub::OnboardingUiTracker* fake_onboarding_ui_tracker =
- fake_phone_hub_manager_->fake_onboarding_ui_tracker();
- if (onboarding_ui_tracker_observer_.IsObserving(fake_onboarding_ui_tracker)) {
- onboarding_ui_tracker_observer_.Remove(fake_onboarding_ui_tracker);
- }
+ notification_manager_observation_.Reset();
+ do_not_disturb_controller_observation_.Reset();
+ find_my_device_controller_observation_.Reset();
+ tether_controller_observation_.Reset();
+ onboarding_ui_tracker_observation_.Reset();
}
void MultidevicePhoneHubHandler::OnNotificationsRemoved(
@@ -538,7 +511,8 @@ void MultidevicePhoneHubHandler::HandleSetNotification(
}
auto notification = phonehub::Notification(
- id, app_metadata, timestamp, importance, inline_reply_id, opt_title,
+ id, app_metadata, timestamp, importance, inline_reply_id,
+ phonehub::Notification::InteractionBehavior::kNone, opt_title,
opt_text_content, opt_shared_image, opt_contact_image);
PA_LOG(VERBOSE) << "Set notification" << notification;
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 e0ec4f05211..07a1242ab91 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
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_PHONE_HUB_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_PHONE_HUB_HANDLER_H_
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chromeos/components/phonehub/do_not_disturb_controller.h"
#include "chromeos/components/phonehub/find_my_device_controller.h"
#include "chromeos/components/phonehub/notification_manager.h"
@@ -79,21 +79,21 @@ class MultidevicePhoneHubHandler
void RemoveObservers();
std::unique_ptr<phonehub::FakePhoneHubManager> fake_phone_hub_manager_;
- ScopedObserver<phonehub::NotificationManager,
- phonehub::NotificationManager::Observer>
- notification_manager_observer_{this};
- ScopedObserver<phonehub::DoNotDisturbController,
- phonehub::DoNotDisturbController::Observer>
- do_not_disturb_controller_observer_{this};
- ScopedObserver<phonehub::FindMyDeviceController,
- phonehub::FindMyDeviceController::Observer>
- find_my_device_controller_oberserver_{this};
- ScopedObserver<phonehub::TetherController,
- phonehub::TetherController::Observer>
- tether_controller_observer_{this};
- ScopedObserver<phonehub::OnboardingUiTracker,
- phonehub::OnboardingUiTracker::Observer>
- onboarding_ui_tracker_observer_{this};
+ base::ScopedObservation<phonehub::NotificationManager,
+ phonehub::NotificationManager::Observer>
+ notification_manager_observation_{this};
+ base::ScopedObservation<phonehub::DoNotDisturbController,
+ phonehub::DoNotDisturbController::Observer>
+ do_not_disturb_controller_observation_{this};
+ base::ScopedObservation<phonehub::FindMyDeviceController,
+ phonehub::FindMyDeviceController::Observer>
+ find_my_device_controller_observation_{this};
+ base::ScopedObservation<phonehub::TetherController,
+ phonehub::TetherController::Observer>
+ tether_controller_observation_{this};
+ base::ScopedObservation<phonehub::OnboardingUiTracker,
+ phonehub::OnboardingUiTracker::Observer>
+ onboarding_ui_tracker_observation_{this};
};
} // namespace multidevice
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.cc
index a71007911fc..4198f65dc83 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.h"
+#include "ash/constants/ash_features.h"
#include "base/containers/span.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h"
@@ -12,20 +13,12 @@
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/multidevice_internals_resources.h"
#include "chrome/grit/multidevice_internals_resources_map.h"
-#include "chromeos/constants/chromeos_features.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 {
-namespace {
-
-constexpr char kMultideviceInternalsGeneratedPath[] =
- "@out_folder@/gen/chrome/browser/resources/chromeos/multidevice_internals/";
-
-} // namespace
-
MultideviceInternalsUI::MultideviceInternalsUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true) {
content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
@@ -36,7 +29,7 @@ MultideviceInternalsUI::MultideviceInternalsUI(content::WebUI* web_ui)
html_source,
base::make_span(kMultideviceInternalsResources,
kMultideviceInternalsResourcesSize),
- kMultideviceInternalsGeneratedPath, IDR_MULTIDEVICE_INTERNALS_INDEX_HTML);
+ IDR_MULTIDEVICE_INTERNALS_INDEX_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
web_ui->AddMessageHandler(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/DIR_METADATA b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/DIR_METADATA
new file mode 100644
index 00000000000..ea7ecb01697
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "OS>Systems>Multidevice"
+}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/OWNERS
index 8eaf92b23b5..7027ab73e02 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/OWNERS
@@ -1,3 +1 @@
file://chromeos/components/multidevice/OWNERS
-
-# COMPONENT: OS>Systems>Multidevice
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc
index bf9bac61193..98b2ab7eca7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc
@@ -4,12 +4,14 @@
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h"
+#include "ash/constants/ash_features.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/window_backdrop.h"
#include "ash/public/cpp/window_properties.h"
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
+#include "chrome/browser/chromeos/login/ui/oobe_dialog_size_utils.h"
#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -17,6 +19,7 @@
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h"
#include "chrome/browser/ui/webui/metrics_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/generated_resources.h"
@@ -28,6 +31,7 @@
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "net/base/url_util.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/native_widget_types.h"
@@ -41,26 +45,35 @@ namespace {
constexpr int kPreferredDialogHeightPx = 640;
constexpr int kPreferredDialogWidthPx = 768;
+constexpr char kOobeDialogHeightParamKey[] = "dialog-height";
+constexpr char kOobeDialogWidthParamKey[] = "dialog-width";
+
} // namespace
// static
MultiDeviceSetupDialog* MultiDeviceSetupDialog::current_instance_ = nullptr;
// static
+gfx::NativeWindow MultiDeviceSetupDialog::containing_window_ = nullptr;
+
+// static
void MultiDeviceSetupDialog::Show() {
- // The dialog is already showing, so there is nothing to do.
- if (current_instance_)
+ // Focus the window hosting the dialog that has already been created.
+ if (containing_window_) {
+ DCHECK(current_instance_);
+ containing_window_->Focus();
return;
+ }
current_instance_ = new MultiDeviceSetupDialog();
- gfx::NativeWindow window = chrome::ShowWebDialog(
+ containing_window_ = chrome::ShowWebDialog(
nullptr /* parent */, ProfileManager::GetActiveUserProfile(),
current_instance_);
// Remove the black backdrop behind the dialog window which appears in tablet
// and full-screen mode.
- ash::WindowBackdrop::Get(window)->SetBackdropMode(
- ash::WindowBackdrop::BackdropMode::kDisabled);
+ ash::WindowBackdrop::Get(containing_window_)
+ ->SetBackdropMode(ash::WindowBackdrop::BackdropMode::kDisabled);
}
// static
@@ -79,28 +92,44 @@ void MultiDeviceSetupDialog::AddOnCloseCallback(base::OnceClosure callback) {
}
MultiDeviceSetupDialog::MultiDeviceSetupDialog()
- : SystemWebDialogDelegate(GURL(chrome::kChromeUIMultiDeviceSetupUrl),
- base::string16()) {}
+ : SystemWebDialogDelegate(CreateMultiDeviceSetupURL(), base::string16()) {}
MultiDeviceSetupDialog::~MultiDeviceSetupDialog() {
for (auto& callback : on_close_callbacks_)
std::move(callback).Run();
}
+GURL MultiDeviceSetupDialog::CreateMultiDeviceSetupURL() {
+ GURL gurl(chrome::kChromeUIMultiDeviceSetupUrl);
+ gfx::Size size;
+ GetDialogSize(&size);
+ gurl = net::AppendQueryParameter(gurl, kOobeDialogHeightParamKey,
+ base::NumberToString(size.height()));
+ gurl = net::AppendQueryParameter(gurl, kOobeDialogWidthParamKey,
+ base::NumberToString(size.width()));
+ return gurl;
+}
+
void MultiDeviceSetupDialog::GetDialogSize(gfx::Size* size) const {
- // Note: The size is calculated once based on the current screen orientation
- // and is not ever updated. It might be possible to resize the dialog upon
- // each screen rotation, but https://crbug.com/1030993 prevents this from
- // working.
- // TODO(https://crbug.com/1030993): Explore resizing the dialog dynamically.
- static const gfx::Size dialog_size = ComputeDialogSizeForInternalScreen(
- gfx::Size(kPreferredDialogWidthPx, kPreferredDialogHeightPx));
- size->SetSize(dialog_size.width(), dialog_size.height());
+ if (features::IsNewOobeLayoutEnabled()) {
+ const gfx::Size dialog_size = CalculateOobeDialogSizeForPrimrayDisplay();
+ size->SetSize(dialog_size.width(), dialog_size.height());
+ } else {
+ // Note: The size is calculated once based on the current screen orientation
+ // and is not ever updated. It might be possible to resize the dialog upon
+ // each screen rotation, but https://crbug.com/1030993 prevents this from
+ // working.
+ // TODO(https://crbug.com/1030993): Explore resizing the dialog dynamically.
+ static const gfx::Size dialog_size = ComputeDialogSizeForInternalScreen(
+ gfx::Size(kPreferredDialogWidthPx, kPreferredDialogHeightPx));
+ size->SetSize(dialog_size.width(), dialog_size.height());
+ }
}
void MultiDeviceSetupDialog::OnDialogClosed(const std::string& json_retval) {
DCHECK(this == current_instance_);
current_instance_ = nullptr;
+ containing_window_ = nullptr;
// Note: The call below deletes |this|, so there is no further need to keep
// track of the pointer.
@@ -116,16 +145,12 @@ MultiDeviceSetupDialogUI::MultiDeviceSetupDialogUI(content::WebUI* web_ui)
chromeos::multidevice_setup::AddLocalizedStrings(source);
source->UseStringsJs();
- source->SetDefaultResource(
- IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_DIALOG_HTML);
- // Note: The |kMultiDeviceSetupResourcesSize| and |kMultideviceSetupResources|
- // fields are defined in the generated file
- // chrome/grit/multidevice_setup_resources_map.h.
- for (size_t i = 0; i < kMultideviceSetupResourcesSize; ++i) {
- source->AddResourcePath(kMultideviceSetupResources[i].name,
- kMultideviceSetupResources[i].value);
- }
+ webui::SetupWebUIDataSource(
+ source,
+ base::make_span(kMultideviceSetupResources,
+ kMultideviceSetupResourcesSize),
+ IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_DIALOG_HTML);
web_ui->AddMessageHandler(std::make_unique<MultideviceSetupHandler>());
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h
index 18a4359bdf0..ea3625867d6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h
@@ -46,7 +46,10 @@ class MultiDeviceSetupDialog : public SystemWebDialogDelegate {
void OnDialogClosed(const std::string& json_retval) override;
private:
+ GURL CreateMultiDeviceSetupURL();
+
static MultiDeviceSetupDialog* current_instance_;
+ static gfx::NativeWindow containing_window_;
// List of callbacks that have registered themselves to be invoked once this
// dialog is closed.
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 64ec9cc6f09..e4aa7fc4a6b 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
@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/settings_window_manager_chromeos.h"
#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc
index 53bab12b446..f0f69009431 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h"
+#include "ash/constants/ash_features.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
@@ -13,16 +14,17 @@
#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/multidevice_setup_resources.h"
#include "chrome/grit/multidevice_setup_resources_map.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/grit/chromeos_resources.h"
#include "chromeos/services/multidevice_setup/public/cpp/url_provider.h"
#include "components/login/localized_values_builder.h"
#include "components/strings/grit/components_strings.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 "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -126,7 +128,7 @@ GetLocalizedStringsWithPlaceholders() {
} // namespace
void AddLocalizedStrings(content::WebUIDataSource* html_source) {
- AddLocalizedStringsBulk(html_source, kLocalizedStringsWithoutPlaceholders);
+ html_source->AddLocalizedStrings(kLocalizedStringsWithoutPlaceholders);
html_source->AddBoolean(
"phoneHubEnabled",
@@ -136,8 +138,16 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
"wifiSyncEnabled",
base::FeatureList::IsEnabled(chromeos::features::kWifiSyncAndroid));
+ html_source->AddBoolean("newLayoutEnabled",
+ chromeos::features::IsNewOobeLayoutEnabled());
+
for (const auto& entry : GetLocalizedStringsWithPlaceholders())
html_source->AddString(entry.name, entry.localized_string);
+
+ html_source->AddResourcePath("multidevice_setup.json",
+ IDR_MULTIDEVICE_SETUP_ANIMATION);
+ html_source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';");
}
void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc
index 32a4f0846b1..a247bb838f0 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc
@@ -13,6 +13,7 @@
#include "chrome/grit/generated_resources.h"
#include "chromeos/login/login_state/login_state.h"
#include "chromeos/network/network_connection_handler.h"
+#include "chromeos/strings/grit/chromeos_strings.h"
#include "components/login/localized_values_builder.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -43,11 +44,17 @@ constexpr webui::LocalizedString kElementLocalizedStrings[] = {
IDS_NETWORK_LIST_ITEM_SUBPAGE_BUTTON_LABEL},
{"networkListItemLabel", IDS_NETWORK_LIST_ITEM_LABEL},
{"networkListItemLabelCellular", IDS_NETWORK_LIST_ITEM_LABEL_CELLULAR},
+ {"networkListItemLabelCellularWithProviderName",
+ IDS_NETWORK_LIST_ITEM_LABEL_CELLULAR_WITH_PROVIDER_NAME},
{"networkListItemLabelCellularManaged",
IDS_NETWORK_LIST_ITEM_LABEL_CELLULAR_MANAGED},
+ {"networkListItemLabelCellularManagedWithProviderName",
+ IDS_NETWORK_LIST_ITEM_LABEL_CELLULAR_MANAGED_WITH_PROVIDER_NAME},
{"networkListItemLabelEthernetManaged",
IDS_NETWORK_LIST_ITEM_LABEL_ETHERNET_MANAGED},
{"networkListItemLabelTether", IDS_NETWORK_LIST_ITEM_LABEL_TETHER},
+ {"networkListItemLabelTetherWithProviderName",
+ IDS_NETWORK_LIST_ITEM_LABEL_TETHER_WITH_PROVIDER_NAME},
{"networkListItemLabelWifi", IDS_NETWORK_LIST_ITEM_LABEL_WIFI},
{"networkListItemLabelWifiManaged",
IDS_NETWORK_LIST_ITEM_LABEL_WIFI_MANAGED},
@@ -57,14 +64,28 @@ constexpr webui::LocalizedString kElementLocalizedStrings[] = {
IDS_NETWORK_LIST_ITEM_LABEL_ETHERNET_MANAGED_WITH_CONNECTION_STATUS},
{"networkListItemLabelCellularWithConnectionStatus",
IDS_NETWORK_LIST_ITEM_LABEL_CELLULAR_WITH_CONNECTION_STATUS},
+ {"networkListItemLabelCellularWithConnectionStatusAndProviderName",
+ IDS_NETWORK_LIST_ITEM_LABEL_CELLULAR_WITH_CONNECTION_STATUS_AND_PROVIDER_NAME},
{"networkListItemLabelCellularManagedWithConnectionStatus",
IDS_NETWORK_LIST_ITEM_LABEL_CELLULAR_MANAGED_WITH_CONNECTION_STATUS},
+ {"networkListItemLabelCellularManagedWithConnectionStatusAndProviderName",
+ IDS_NETWORK_LIST_ITEM_LABEL_CELLULAR_MANAGED_WITH_CONNECTION_STATUS_AND_PROVIDER_NAME},
{"networkListItemLabelWifiWithConnectionStatus",
IDS_NETWORK_LIST_ITEM_LABEL_WIFI_WITH_CONNECTION_STATUS},
{"networkListItemLabelWifiManagedWithConnectionStatus",
IDS_NETWORK_LIST_ITEM_LABEL_WIFI_MANAGED_WITH_CONNECTION_STATUS},
{"networkListItemLabelTetherWithConnectionStatus",
IDS_NETWORK_LIST_ITEM_LABEL_TETHER_WITH_CONNECTION_STATUS},
+ {"networkListItemLabelTetherWithConnectionStatusAndProviderName",
+ IDS_NETWORK_LIST_ITEM_LABEL_TETHER_WITH_CONNECTION_STATUS_AND_PROVIDER_NAME},
+ {"networkListItemLabelESimPendingProfile",
+ IDS_NETWORK_LIST_ITEM_LABEL_ESIM_PENDING_PROFILE},
+ {"networkListItemLabelESimPendingProfileWithProviderName",
+ IDS_NETWORK_LIST_ITEM_LABEL_ESIM_PENDING_PROFILE_WITH_PROVIDER_NAME},
+ {"networkListItemLabelESimPendingProfileInstalling",
+ IDS_NETWORK_LIST_ITEM_LABEL_ESIM_PENDING_PROFILE_INSTALLING},
+ {"networkListItemLabelESimPendingProfileWithProviderNameInstalling",
+ IDS_NETWORK_LIST_ITEM_LABEL_ESIM_PENDING_PROFILE_WITH_PROVIDER_NAME_INSTALLING},
{"wifiNetworkStatusSecured", IDS_WIFI_NETWORK_STATUS_SECURED},
{"wifiNetworkStatusUnsecured", IDS_WIFI_NETWORK_STATUS_UNSECURED},
{"networkListItemNotAvailable", IDS_NETWORK_LIST_NOT_AVAILABLE},
@@ -72,6 +93,8 @@ constexpr webui::LocalizedString kElementLocalizedStrings[] = {
{"networkListItemSimCardLocked", IDS_NETWORK_LIST_SIM_CARD_LOCKED},
{"networkListItemNotConnected", IDS_NETWORK_LIST_NOT_CONNECTED},
{"networkListItemNoNetwork", IDS_NETWORK_LIST_NO_NETWORK},
+ {"networkListItemDownload", IDS_NETWORK_LIST_ITEM_DOWNLOAD},
+ {"networkListItemAddingProfile", IDS_NETWORK_LIST_ITEM_ADDING_PROFILE},
{"vpnNameTemplate", IDS_NETWORK_LIST_THIRD_PARTY_VPN_NAME_TEMPLATE},
{"networkIconLabelEthernet", IDS_NETWORK_ICON_LABEL_ETHERNET},
{"networkIconLabelVpn", IDS_NETWORK_ICON_LABEL_VPN},
@@ -85,7 +108,7 @@ constexpr webui::LocalizedString kElementLocalizedStrings[] = {
} // namespace
void AddLocalizedStrings(content::WebUIDataSource* html_source) {
- AddLocalizedStringsBulk(html_source, kElementLocalizedStrings);
+ html_source->AddLocalizedStrings(kElementLocalizedStrings);
}
void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder) {
@@ -209,7 +232,7 @@ void AddOncLocalizedStrings(content::WebUIDataSource* html_source) {
{"Oncipv4-Netmask", IDS_ONC_IPV4_NETMASK},
{"Oncipv6-IPAddress", IDS_ONC_IPV6_ADDRESS},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddDetailsLocalizedStrings(content::WebUIDataSource* html_source) {
@@ -280,12 +303,20 @@ void AddDetailsLocalizedStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_INTERNET_NETWORK_SIM_RE_ENTER_NEW_PIN},
{"networkSimErrorIncorrectPin",
IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_INCORRECT_PIN},
+ {"networkSimErrorIncorrectPinPlural",
+ IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_INCORRECT_PIN_PLURAL},
{"networkSimErrorIncorrectPuk",
IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_INCORRECT_PUK},
+ {"networkSimErrorIncorrectPukPlural",
+ IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_INCORRECT_PUK_PLURAL},
{"networkSimErrorInvalidPin",
IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_INVALID_PIN},
+ {"networkSimErrorInvalidPinPlural",
+ IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_INVALID_PIN_PLURAL},
{"networkSimErrorInvalidPuk",
IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_INVALID_PUK},
+ {"networkSimErrorInvalidPukPlural",
+ IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_INVALID_PUK_PLURAL},
{"networkSimErrorPinMismatch",
IDS_SETTINGS_INTERNET_NETWORK_SIM_ERROR_PIN_MISMATCH},
{"networkSimUnlock", IDS_SETTINGS_INTERNET_NETWORK_SIM_BUTTON_UNLOCK},
@@ -313,7 +344,7 @@ void AddDetailsLocalizedStrings(content::WebUIDataSource* html_source) {
{"networkProxyWpadNone", IDS_SETTINGS_INTERNET_NETWORK_PROXY_WPAD_NONE},
{"remove", IDS_REMOVE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddConfigLocalizedStrings(content::WebUIDataSource* html_source) {
@@ -335,7 +366,7 @@ void AddConfigLocalizedStrings(content::WebUIDataSource* html_source) {
{"hidePassword", IDS_SETTINGS_PASSWORD_HIDE},
{"showPassword", IDS_SETTINGS_PASSWORD_SHOW},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean(
"showHiddenNetworkWarning",
@@ -364,7 +395,7 @@ void AddErrorLocalizedStrings(content::WebUIDataSource* html_source) {
{"networkErrorNotHardwareBacked",
IDS_SETTINGS_INTERNET_NETWORK_REQUIRE_HARDWARE_BACKED},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
// Include Shill errors.
const char* const shill_errors[] = {
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 423901dfc52..2a1a1244eb0 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
@@ -11,9 +11,9 @@
#include "base/system/sys_info.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
+#include "chrome/browser/ash/system_logs/debug_log_writer.h"
+#include "chrome/browser/ash/system_logs/system_logs_writer.h"
#include "chrome/browser/chromeos/file_manager/filesystem_api_util.h"
-#include "chrome/browser/chromeos/system_logs/debug_log_writer.h"
-#include "chrome/browser/chromeos/system_logs/system_logs_writer.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/policy/chrome_policy_conversions_client.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
index 2482ea8a4c0..c6dc9aa87f1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
@@ -14,20 +14,24 @@
#include "base/memory/weak_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/net/network_health/network_health_localized_strings.h"
#include "chrome/browser/chromeos/net/network_health/network_health_service.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chrome/browser/ui/webui/chromeos/network_logs_message_handler.h"
#include "chrome/browser/ui/webui/chromeos/onc_import_message_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/components/connectivity_diagnostics/network_diagnostics_resource_provider.h"
+#include "chrome/grit/network_ui_resources.h"
+#include "chrome/grit/network_ui_resources_map.h"
+#include "chromeos/components/network_ui/network_diagnostics_resource_provider.h"
+#include "chromeos/components/network_ui/network_health_resource_provider.h"
#include "chromeos/network/device_state.h"
#include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_device_handler.h"
@@ -533,24 +537,17 @@ NetworkUI::NetworkUI(content::WebUI* web_ui)
html->DisableTrustedTypesCSP();
html->AddLocalizedStrings(localized_strings);
- network_health::AddLocalizedStrings(html);
+ network_health::AddResources(html);
network_diagnostics::AddResources(html);
-
+ cellular_setup::AddLocalizedStrings(html);
+ cellular_setup::AddNonStringLoadTimeData(html);
network_element::AddLocalizedStrings(html);
network_element::AddOncLocalizedStrings(html);
html->UseStringsJs();
- html->AddResourcePath("network_ui_browser_proxy.html",
- IDR_NETWORK_UI_BROWSER_PROXY_HTML);
- html->AddResourcePath("network_ui_browser_proxy.js",
- IDR_NETWORK_UI_BROWSER_PROXY_JS);
- html->AddResourcePath("network_ui.html", IDR_NETWORK_UI_HTML);
- html->AddResourcePath("network_ui.js", IDR_NETWORK_UI_JS);
- html->AddResourcePath("network_state_ui.html", IDR_NETWORK_STATE_UI_HTML);
- html->AddResourcePath("network_state_ui.js", IDR_NETWORK_STATE_UI_JS);
- html->AddResourcePath("network_logs_ui.html", IDR_NETWORK_LOGS_UI_HTML);
- html->AddResourcePath("network_logs_ui.js", IDR_NETWORK_LOGS_UI_JS);
- html->SetDefaultResource(IDR_NETWORK_UI_PAGE_HTML);
+ webui::SetupWebUIDataSource(
+ html, base::make_span(kNetworkUiResources, kNetworkUiResourcesSize),
+ IDR_NETWORK_UI_NETWORK_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
html);
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 f4c572b0684..4fdc47bf01a 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
@@ -8,7 +8,7 @@
#include "base/callback_helpers.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/net/nss_context.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/network/onc/onc_certificate_importer_impl.h"
@@ -99,7 +99,8 @@ void OncImportMessageHandler::ImportONCToNSSDB(const std::string& callback_id,
has_error = true;
result += "Some certificates could not be parsed.\n";
}
- cert_importer->ImportAllCertificatesUserInitiated(
+ auto* const cert_importer_ptr = cert_importer.get();
+ cert_importer_ptr->ImportAllCertificatesUserInitiated(
certs->server_or_authority_certificates(), certs->client_certificates(),
base::BindOnce(&OncImportMessageHandler::OnCertificatesImported,
weak_factory_.GetWeakPtr(), std::move(cert_importer),
diff --git a/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
index a5aeea6f591..9a33cae8728 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
@@ -257,7 +257,7 @@ PowerUI::PowerUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
{"frequencyStateOccupancyPercentageHeader",
IDS_ABOUT_POWER_CPU_FREQ_STATE_OCCUPANCY_PERCENTAGE},
};
- AddLocalizedStringsBulk(html, kStrings);
+ html->AddLocalizedStrings(kStrings);
html->UseStringsJs();
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 3fffeae11df..7425e78b754 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
@@ -14,12 +14,12 @@
#include "base/build_time.h"
#include "base/callback_helpers.h"
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/values.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
+#include "chrome/browser/ash/system/timezone_util.h"
#include "chrome/browser/chromeos/child_accounts/parent_access_code/parent_access_service.h"
#include "chrome/browser/chromeos/set_time_dialog.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/chromeos/system/timezone_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
@@ -69,13 +69,13 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
}
void OnJavascriptAllowed() override {
- clock_observer_.Add(SystemClockClient::Get());
- timezone_observer_.Add(system::TimezoneSettings::GetInstance());
+ clock_observation_.Observe(SystemClockClient::Get());
+ timezone_observation_.Observe(system::TimezoneSettings::GetInstance());
}
void OnJavascriptDisallowed() override {
- clock_observer_.RemoveAll();
- timezone_observer_.RemoveAll();
+ clock_observation_.Reset();
+ timezone_observation_.Reset();
}
private:
@@ -157,10 +157,11 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
FireWebUIListener("validation-complete");
}
- ScopedObserver<SystemClockClient, SystemClockClient::Observer>
- clock_observer_{this};
- ScopedObserver<system::TimezoneSettings, system::TimezoneSettings::Observer>
- timezone_observer_{this};
+ base::ScopedObservation<SystemClockClient, SystemClockClient::Observer>
+ clock_observation_{this};
+ base::ScopedObservation<system::TimezoneSettings,
+ system::TimezoneSettings::Observer>
+ timezone_observation_{this};
base::WeakPtrFactory<SetTimeMessageHandler> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(SetTimeMessageHandler);
@@ -174,11 +175,7 @@ SetTimeUI::SetTimeUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
// Set up the chrome://set-time source.
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUISetTimeHost);
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test 'self';");
- source->DisableTrustedTypesCSP();
-
+ webui::SetJSModuleDefaults(source);
static constexpr webui::LocalizedString kStrings[] = {
{"setTimeTitle", IDS_SET_TIME_TITLE},
{"prompt", IDS_SET_TIME_PROMPT},
@@ -187,7 +184,7 @@ SetTimeUI::SetTimeUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
{"timeLabel", IDS_SET_TIME_TIME_LABEL},
{"doneButton", IDS_DONE},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
base::DictionaryValue values;
// List of list of strings: [[ID, name], [ID, name], ...]
@@ -201,17 +198,12 @@ SetTimeUI::SetTimeUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
values.SetDouble("buildTime", base::GetBuildTime().ToJsTime());
source->AddLocalizedStrings(values);
- source->UseStringsJs();
- source->EnableReplaceI18nInJS();
source->AddResourcePath("set_time_browser_proxy.js",
IDR_SET_TIME_BROWSER_PROXY_JS);
source->AddResourcePath("set_time_dialog.js", IDR_SET_TIME_DIALOG_JS);
source->SetDefaultResource(IDR_SET_TIME_HTML);
- source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
- source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML);
-
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
index c6e2ec675ef..53df03e13b1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
@@ -51,7 +51,7 @@ content::WebUIDataSource* CreateSlowUIHTMLSource() {
{"slowDescription", IDS_SLOW_DESCRIPTION},
{"slowWarning", IDS_SLOW_WARNING},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->AddResourcePath("slow.js", IDR_SLOW_JS);
source->AddResourcePath("slow.css", IDR_SLOW_CSS);
@@ -103,9 +103,9 @@ void SlowHandler::RegisterMessages() {
user_pref_registrar_ = std::make_unique<PrefChangeRegistrar>();
user_pref_registrar_->Init(profile_->GetPrefs());
- user_pref_registrar_->Add(prefs::kPerformanceTracingEnabled,
- base::Bind(&SlowHandler::UpdatePage,
- base::Unretained(this)));
+ user_pref_registrar_->Add(
+ prefs::kPerformanceTracingEnabled,
+ base::BindRepeating(&SlowHandler::UpdatePage, base::Unretained(this)));
}
void SlowHandler::HandleDisable(const base::ListValue* args) {
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 794839142d2..cbc178fc35e 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
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/smb_client/smb_service.h"
#include "chrome/browser/chromeos/smb_client/smb_service_factory.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_shares_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_shares_localized_strings_provider.cc
index dc49d9b1f3f..272f46ffe08 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_shares_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_shares_localized_strings_provider.cc
@@ -49,7 +49,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
{"smbShareDiscoveryMessage",
IDS_SETTINGS_DOWNLOADS_ADD_SHARE_DISCOVERY_MESSAGE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
} // namespace smb_dialog
diff --git a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc
index 05a93407f25..7eee3fbbb14 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc
@@ -14,7 +14,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/account_id/account_id.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/render_view_host.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h
index 4a20108d60e..e455eb94b3b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h
@@ -107,6 +107,8 @@ class SystemWebDialogDelegate : public ui::WebDialogDelegate {
// A setter for modal type.
void set_modal_type(ui::ModalType modal_type) { modal_type_ = modal_type; }
+ content::WebUI* webui() { return webui_; }
+
private:
GURL gurl_;
base::string16 title_;
diff --git a/chromium/chrome/browser/ui/webui/commander/OWNERS b/chromium/chrome/browser/ui/webui/commander/OWNERS
index 475a305ce5e..d7b99b6cd95 100644
--- a/chromium/chrome/browser/ui/webui/commander/OWNERS
+++ b/chromium/chrome/browser/ui/webui/commander/OWNERS
@@ -1,4 +1 @@
-lgrey@chromium.org
-ellyjones@chromium.org
-
-# COMPONENT: UI>Browser
+file://chrome/browser/ui/commander/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/commander/commander_ui.cc b/chromium/chrome/browser/ui/webui/commander/commander_ui.cc
index c3ea45c4bec..9562b55edc8 100644
--- a/chromium/chrome/browser/ui/webui/commander/commander_ui.cc
+++ b/chromium/chrome/browser/ui/webui/commander/commander_ui.cc
@@ -24,7 +24,7 @@ CommanderUI::CommanderUI(content::WebUI* web_ui)
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUICommanderHost);
webui::SetupWebUIDataSource(
- source, base::make_span(kCommanderResources, kCommanderResourcesSize), "",
+ source, base::make_span(kCommanderResources, kCommanderResourcesSize),
IDR_COMMANDER_COMMANDER_HTML);
Profile* profile = Profile::FromWebUI(web_ui);
diff --git a/chromium/chrome/browser/ui/webui/components/components_handler.cc b/chromium/chrome/browser/ui/webui/components/components_handler.cc
index 12e81ddff40..1f9014bcda6 100644
--- a/chromium/chrome/browser/ui/webui/components/components_handler.cc
+++ b/chromium/chrome/browser/ui/webui/components/components_handler.cc
@@ -34,11 +34,11 @@ void ComponentsHandler::RegisterMessages() {
}
void ComponentsHandler::OnJavascriptAllowed() {
- observer_.Add(component_updater_);
+ observation_.Observe(component_updater_);
}
void ComponentsHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void ComponentsHandler::HandleRequestComponentsData(
diff --git a/chromium/chrome/browser/ui/webui/components/components_handler.h b/chromium/chrome/browser/ui/webui/components/components_handler.h
index 5ed5d43d2a5..4f2f38fb192 100644
--- a/chromium/chrome/browser/ui/webui/components/components_handler.h
+++ b/chromium/chrome/browser/ui/webui/components/components_handler.h
@@ -8,7 +8,7 @@
#include <memory>
#include <string>
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/strings/string16.h"
#include "components/component_updater/component_updater_service.h"
#include "components/update_client/update_client.h"
@@ -53,9 +53,9 @@ class ComponentsHandler : public content::WebUIMessageHandler,
// Weak pointer; injected for testing.
component_updater::ComponentUpdateService* const component_updater_;
- ScopedObserver<component_updater::ComponentUpdateService,
- component_updater::ComponentUpdateService::Observer>
- observer_{this};
+ base::ScopedObservation<component_updater::ComponentUpdateService,
+ component_updater::ComponentUpdateService::Observer>
+ observation_{this};
};
#endif // CHROME_BROWSER_UI_WEBUI_COMPONENTS_COMPONENTS_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/components/components_ui.cc b/chromium/chrome/browser/ui/webui/components/components_ui.cc
index 49b84001460..cfe77aa2838 100644
--- a/chromium/chrome/browser/ui/webui/components/components_ui.cc
+++ b/chromium/chrome/browser/ui/webui/components/components_ui.cc
@@ -16,6 +16,7 @@
#include "base/macros.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/components/components_handler.h"
@@ -31,7 +32,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/user_manager/user_manager.h"
#endif
@@ -57,11 +58,11 @@ content::WebUIDataSource* CreateComponentsUIHTMLSource(Profile* profile) {
{"statusLabel", IDS_COMPONENTS_STATUS_LABEL},
{"checkingLabel", IDS_COMPONENTS_CHECKING_LABEL},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->AddBoolean(
"isGuest",
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
user_manager::UserManager::Get()->IsLoggedInAsPublicAccount()
#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 216140d5518..cce00377ec9 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc
@@ -7,6 +7,7 @@
#include <string>
#include <utility>
+#include "base/strings/string_util.h"
#include "base/values.h"
#include "base/win/windows_version.h"
#include "chrome/browser/win/conflicts/module_database.h"
@@ -16,7 +17,7 @@
#if defined(GOOGLE_CHROME_BUILD)
#include "base/win/win_util.h"
#include "chrome/browser/win/conflicts/incompatible_applications_updater.h"
-#include "chrome/browser/win/conflicts/module_blacklist_cache_updater.h"
+#include "chrome/browser/win/conflicts/module_blocklist_cache_updater.h"
#endif
namespace {
@@ -73,7 +74,7 @@ void AppendString(base::StringPiece input, std::string* output) {
// Returns a string describing the current module blocking status: loaded or
// not, blocked or not, was in blocklist cache or not, bypassed blocking or not.
std::string GetBlockingStatusString(
- const ModuleBlacklistCacheUpdater::ModuleBlockingState& blocking_state) {
+ const ModuleBlocklistCacheUpdater::ModuleBlockingState& blocking_state) {
std::string status;
// Output status regarding the blocklist cache, current blocking, and
@@ -82,9 +83,9 @@ std::string GetBlockingStatusString(
status = "Blocked";
if (!blocking_state.was_loaded)
AppendString(kNotLoaded, &status);
- else if (blocking_state.was_in_blacklist_cache)
+ else if (blocking_state.was_in_blocklist_cache)
AppendString("Bypassed blocking", &status);
- if (blocking_state.was_in_blacklist_cache)
+ if (blocking_state.was_in_blocklist_cache)
AppendString("In blocklist cache", &status);
return status;
@@ -94,9 +95,9 @@ std::string GetBlockingStatusString(
// returns the empty string to indicate that the warning decision description
// should be used instead.
std::string GetBlockingDecisionString(
- const ModuleBlacklistCacheUpdater::ModuleBlockingState& blocking_state,
+ const ModuleBlocklistCacheUpdater::ModuleBlockingState& blocking_state,
IncompatibleApplicationsUpdater* incompatible_applications_updater) {
- using BlockingDecision = ModuleBlacklistCacheUpdater::ModuleBlockingDecision;
+ using BlockingDecision = ModuleBlocklistCacheUpdater::ModuleBlockingDecision;
// Append status regarding the logic that will be applied during the next
// startup.
@@ -163,7 +164,7 @@ std::string GetModuleWarningDecisionString(
return kAllowedSameDirectory;
case WarningDecision::kAllowedMicrosoft:
return kAllowedMicrosoftModule;
- case WarningDecision::kAllowedWhitelisted:
+ case WarningDecision::kAllowedAllowlisted:
return kAllowedAllowlisted;
case WarningDecision::kNotAnalyzed:
return kNotAnalyzed;
@@ -171,7 +172,7 @@ std::string GetModuleWarningDecisionString(
return "Tolerated - Could not tie to an installed application";
case WarningDecision::kIncompatible:
return "Incompatible";
- case WarningDecision::kAddedToBlacklist:
+ case WarningDecision::kAddedToBlocklist:
case WarningDecision::kUnknown:
NOTREACHED();
break;
@@ -183,7 +184,7 @@ std::string GetModuleWarningDecisionString(
std::string GetModuleStatusString(
const ModuleInfoKey& module_key,
IncompatibleApplicationsUpdater* incompatible_applications_updater,
- ModuleBlacklistCacheUpdater* module_blocklist_cache_updater) {
+ ModuleBlocklistCacheUpdater* module_blocklist_cache_updater) {
if (!incompatible_applications_updater && !module_blocklist_cache_updater)
return std::string();
@@ -191,7 +192,7 @@ std::string GetModuleStatusString(
// The blocking status is shown over the warning status.
if (module_blocklist_cache_updater) {
- const ModuleBlacklistCacheUpdater::ModuleBlockingState& blocking_state =
+ const ModuleBlocklistCacheUpdater::ModuleBlockingState& blocking_state =
module_blocklist_cache_updater->GetModuleBlockingState(module_key);
status = GetBlockingStatusString(blocking_state);
@@ -272,7 +273,7 @@ ThirdPartyFeaturesStatus GetThirdPartyFeaturesStatus(
return kPolicyDisabled;
if (!IncompatibleApplicationsUpdater::IsWarningEnabled() &&
- !ModuleBlacklistCacheUpdater::IsBlockingEnabled()) {
+ !ModuleBlocklistCacheUpdater::IsBlockingEnabled()) {
return kFeatureDisabled;
}
@@ -443,7 +444,7 @@ void ConflictsDataFetcher::OnNewModuleFound(const ModuleInfoKey& module_key,
auto* module_blocklist_cache_updater =
ModuleDatabase::GetInstance()
->third_party_conflicts_manager()
- ->module_blacklist_cache_updater();
+ ->module_blocklist_cache_updater();
data->SetString(
"third_party_module_status",
diff --git a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
index f78e91f96a1..f0d925e1f13 100644
--- a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc
@@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -66,7 +67,7 @@ class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest {
ConstrainedWebDialogBrowserTest() {}
// Runs the current MessageLoop until |condition| is true or timeout.
- bool RunLoopUntil(const base::Callback<bool()>& condition) {
+ bool RunLoopUntil(base::RepeatingCallback<bool()> condition) {
const base::TimeTicks start_time = base::TimeTicks::Now();
while (!condition.Run()) {
const base::TimeTicks current_time = base::TimeTicks::Now();
@@ -149,7 +150,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
// Tests that dialog autoresizes based on web contents when autoresizing
// is enabled.
// Flaky on CrOS: http://crbug.com/928924
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_ContentResizeInAutoResizingDialog \
DISABLED_ContentResizeInAutoResizingDialog
#else
@@ -203,34 +204,26 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
ASSERT_TRUE(IsShowingWebContentsModalDialog(web_contents));
// Resize to content's originally set dimensions.
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- gfx::Size(initial_size, initial_size),
- dialog_delegate)));
+ ASSERT_TRUE(RunLoopUntil(base::BindRepeating(
+ &IsEqualSizes, gfx::Size(initial_size, initial_size), dialog_delegate)));
// Resize to dimensions within expected bounds.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(175)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- gfx::Size(new_size, new_size),
- dialog_delegate)));
+ ASSERT_TRUE(RunLoopUntil(base::BindRepeating(
+ &IsEqualSizes, gfx::Size(new_size, new_size), dialog_delegate)));
// Resize to dimensions smaller than the minimum bounds.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(50)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- min_size,
- dialog_delegate)));
+ ASSERT_TRUE(RunLoopUntil(
+ base::BindRepeating(&IsEqualSizes, min_size, dialog_delegate)));
// Resize to dimensions greater than the maximum bounds.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(250)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- max_size,
- dialog_delegate)));
+ ASSERT_TRUE(RunLoopUntil(
+ base::BindRepeating(&IsEqualSizes, max_size, dialog_delegate)));
}
// Tests that dialog does not autoresize when autoresizing is not enabled.
@@ -262,16 +255,12 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
// Resize <body> to dimension smaller than dialog.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(100)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- initial_dialog_size,
- dialog_delegate)));
+ ASSERT_TRUE(RunLoopUntil(base::BindRepeating(
+ &IsEqualSizes, initial_dialog_size, dialog_delegate)));
// Resize <body> to dimension larger than dialog.
EXPECT_TRUE(ExecuteScript(dialog_delegate->GetWebContents(),
GetChangeDimensionsScript(500)));
- ASSERT_TRUE(RunLoopUntil(base::Bind(
- &IsEqualSizes,
- initial_dialog_size,
- dialog_delegate)));
+ ASSERT_TRUE(RunLoopUntil(base::BindRepeating(
+ &IsEqualSizes, initial_dialog_size, dialog_delegate)));
}
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 f12d382118c..6e2f1df27f4 100644
--- a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc
+++ b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc
@@ -8,8 +8,8 @@
#include <utility>
#include <vector>
+#include "base/containers/contains.h"
#include "base/i18n/time_formatting.h"
-#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -18,7 +18,6 @@
#include "build/build_config.h"
#include "chrome/browser/browsing_data/cookies_tree_model.h"
#include "chrome/grit/generated_resources.h"
-#include "content/public/browser/cache_storage_context.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/storage_usage_info.h"
#include "extensions/buildflags/buildflags.h"
diff --git a/chromium/chrome/browser/ui/webui/crashes_ui.cc b/chromium/chrome/browser/ui/webui/crashes_ui.cc
index 4c857f49354..060e272a99c 100644
--- a/chromium/chrome/browser/ui/webui/crashes_ui.cc
+++ b/chromium/chrome/browser/ui/webui/crashes_ui.cc
@@ -18,6 +18,7 @@
#include "base/system/sys_info.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/crash_upload_list/crash_upload_list.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/metrics/metrics_reporting_state.h"
@@ -37,7 +38,7 @@
#include "google_apis/gaia/gaia_auth_util.h"
#include "ui/base/resource/resource_bundle.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
#endif
@@ -91,7 +92,7 @@ class CrashesDOMHandler : public WebUIMessageHandler {
// Asynchronously fetches the list of crashes. Called from JS.
void HandleRequestCrashes(const base::ListValue* args);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Asynchronously triggers crash uploading. Called from JS.
void HandleRequestUploads(const base::ListValue* args);
#endif
@@ -126,7 +127,7 @@ void CrashesDOMHandler::RegisterMessages() {
base::BindRepeating(&CrashesDOMHandler::HandleRequestCrashes,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
crash_reporter::kCrashesUIRequestCrashUpload,
base::BindRepeating(&CrashesDOMHandler::HandleRequestUploads,
@@ -151,7 +152,7 @@ void CrashesDOMHandler::HandleRequestCrashes(const base::ListValue* args) {
}
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void CrashesDOMHandler::HandleRequestUploads(const base::ListValue* args) {
chromeos::DebugDaemonClient* debugd_client =
chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
@@ -176,7 +177,7 @@ void CrashesDOMHandler::UpdateUI() {
ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
bool system_crash_reporter = false;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
// Chrome OS has a system crash reporter.
system_crash_reporter = true;
#endif
@@ -184,7 +185,9 @@ void CrashesDOMHandler::UpdateUI() {
bool using_crashpad = false;
#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_ANDROID)
using_crashpad = true;
-#elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
+// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
+// of lacros-chrome is complete.
+#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
// ChromeOS uses crash_sender instead of Crashpad for uploads even when
// Crashpad is enabled for dump generation.
using_crashpad = crash_reporter::IsCrashpadEnabled();
@@ -195,7 +198,8 @@ void CrashesDOMHandler::UpdateUI() {
IdentityManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()));
if (identity_manager) {
is_internal = gaia::IsGoogleInternalAccountEmail(
- identity_manager->GetPrimaryAccountInfo().email);
+ identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
+ .email);
}
// Manual uploads currently are supported only for Crashpad-using platforms
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 ae5bc2e9cc9..d226af395ce 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
@@ -50,10 +50,14 @@ ChromeCustomizeThemesHandler::~ChromeCustomizeThemesHandler() {
void ChromeCustomizeThemesHandler::ApplyAutogeneratedTheme(
SkColor frame_color) {
+ chrome_colors::ChromeColorsService::RecordColorAppliedHistogram(
+ chrome_colors::kOtherColorId);
chrome_colors_service_->ApplyAutogeneratedTheme(frame_color, web_contents_);
}
void ChromeCustomizeThemesHandler::ApplyDefaultTheme() {
+ chrome_colors::ChromeColorsService::RecordColorAppliedHistogram(
+ chrome_colors::kDefaultColorId);
chrome_colors_service_->ApplyDefaultTheme(web_contents_);
}
@@ -66,6 +70,7 @@ void ChromeCustomizeThemesHandler::ApplyChromeTheme(int32_t id) {
});
if (result == end)
return;
+ chrome_colors::ChromeColorsService::RecordColorAppliedHistogram(id);
chrome_colors_service_->ApplyAutogeneratedTheme(result->color, web_contents_);
}
@@ -116,7 +121,8 @@ void ChromeCustomizeThemesHandler::UpdateTheme() {
if (theme_service_->UsingDefaultTheme() ||
theme_service_->UsingSystemTheme()) {
theme->type = customize_themes::mojom::ThemeType::kDefault;
- theme->info = customize_themes::mojom::ThemeInfo::NewChromeThemeId(-1);
+ theme->info = customize_themes::mojom::ThemeInfo::NewChromeThemeId(
+ chrome_colors::kDefaultColorId);
} else if (theme_service_->UsingExtensionTheme()) {
theme->type = customize_themes::mojom::ThemeType::kThirdParty;
auto info = customize_themes::mojom::ThirdPartyThemeInfo::New();
@@ -134,7 +140,7 @@ void ChromeCustomizeThemesHandler::UpdateTheme() {
DCHECK(theme_service_->UsingAutogeneratedTheme());
int color_id = chrome_colors::ChromeColorsService::GetColorId(
theme_service_->GetAutogeneratedThemeColor());
- if (color_id > 0) {
+ if (color_id != chrome_colors::kOtherColorId) {
theme->type = customize_themes::mojom::ThemeType::kChrome;
theme->info =
customize_themes::mojom::ThemeInfo::NewChromeThemeId(color_id);
diff --git a/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler_unittest.cc b/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler_unittest.cc
index 200d800e7f0..15cbf20c014 100644
--- a/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler_unittest.cc
@@ -13,6 +13,7 @@
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
+#include "base/test/metrics/histogram_tester.h"
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/test_extension_environment.h"
@@ -291,3 +292,19 @@ TEST_F(ChromeCustomizeThemesHandlerTest, ResetHandler) {
EXPECT_EQ(kAutogeneratedThemeColor,
theme_service()->GetAutogeneratedThemeColor());
}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, RecordColorAppliedHistogram) {
+ base::HistogramTester histogram_tester;
+ const char kHistogramName[] = "ChromeColors.ColorApplied";
+
+ constexpr SkColor kAutogeneratedThemeColor = SK_ColorBLUE;
+ handler()->ApplyAutogeneratedTheme(kAutogeneratedThemeColor);
+ histogram_tester.ExpectBucketCount(kHistogramName, 0, 1);
+
+ constexpr int kChromeThemeId = 4;
+ handler()->ApplyChromeTheme(kChromeThemeId);
+ histogram_tester.ExpectBucketCount(kHistogramName, kChromeThemeId, 1);
+
+ handler()->ApplyDefaultTheme();
+ histogram_tester.ExpectBucketCount(kHistogramName, -1, 1);
+}
diff --git a/chromium/chrome/browser/ui/webui/device_log_ui.cc b/chromium/chrome/browser/ui/webui/device_log_ui.cc
index 3e12d4174e6..ef938507396 100644
--- a/chromium/chrome/browser/ui/webui/device_log_ui.cc
+++ b/chromium/chrome/browser/ui/webui/device_log_ui.cc
@@ -90,9 +90,10 @@ DeviceLogUI::DeviceLogUI(content::WebUI* web_ui)
{"logTypePrinterText", IDS_DEVICE_LOG_TYPE_PRINTER},
{"logTypeFidoText", IDS_DEVICE_LOG_TYPE_FIDO},
{"logTypeSerialText", IDS_DEVICE_LOG_TYPE_SERIAL},
+ {"logTypeCameraText", IDS_DEVICE_LOG_TYPE_CAMERA},
{"logEntryFormat", IDS_DEVICE_LOG_ENTRY},
};
- AddLocalizedStringsBulk(html, kStrings);
+ html->AddLocalizedStrings(kStrings);
html->UseStringsJs();
html->AddResourcePath("device_log_ui.css", IDR_DEVICE_LOG_UI_CSS);
diff --git a/chromium/chrome/browser/ui/webui/devtools_ui.cc b/chromium/chrome/browser/ui/webui/devtools_ui.cc
index a8fcfb6fa5d..9f2ce2caf2c 100644
--- a/chromium/chrome/browser/ui/webui/devtools_ui.cc
+++ b/chromium/chrome/browser/ui/webui/devtools_ui.cc
@@ -13,6 +13,7 @@
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
+#include "content/public/common/bindings_policy.h"
#include "content/public/common/user_agent.h"
#include "net/base/load_flags.h"
@@ -62,7 +63,7 @@ bool DevToolsUI::IsFrontendResourceURL(const GURL& url) {
DevToolsUI::DevToolsUI(content::WebUI* web_ui)
: WebUIController(web_ui), bindings_(web_ui->GetWebContents()) {
- web_ui->SetBindings(0);
+ web_ui->SetBindings(content::BINDINGS_POLICY_NONE);
auto factory = content::BrowserContext::GetDefaultStoragePartition(
web_ui->GetWebContents()->GetBrowserContext())
->GetURLLoaderFactoryForBrowserProcess();
diff --git a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
index 2a015abe9ad..76b86987e1c 100644
--- a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
+++ b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
@@ -14,7 +14,6 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h"
@@ -32,6 +31,7 @@
#include "chrome/grit/browser_resources.h"
#include "components/favicon_base/favicon_url_parser.h"
#include "components/performance_manager/public/performance_manager.h"
+#include "components/site_engagement/content/site_engagement_service.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/url_data_source.h"
@@ -86,12 +86,11 @@ double GetSiteEngagementScore(content::WebContents* contents) {
auto* nav_entry = controller.GetEntryAtIndex(current_entry_index);
DCHECK(nav_entry);
- auto* engagement_svc = SiteEngagementService::Get(
+ auto* engagement_svc = site_engagement::SiteEngagementService::Get(
Profile::FromBrowserContext(contents->GetBrowserContext()));
return engagement_svc->GetDetails(nav_entry->GetURL()).total_score;
}
-
class DiscardsDetailsProviderImpl : public discards::mojom::DetailsProvider {
public:
// This instance is deleted when the supplied pipe is destroyed.
@@ -219,7 +218,7 @@ DiscardsUI::DiscardsUI(content::WebUI* web_ui)
"script-src chrome://resources chrome://test 'self';");
source->DisableTrustedTypesCSP();
- const GritResourceMap kResources[] = {
+ const webui::ResourcePath kResources[] = {
{"discards.js", IDR_DISCARDS_JS},
{"discards_main.js", IDR_DISCARDS_DISCARDS_MAIN_JS},
{"database_tab.js", IDR_DISCARDS_DATABASE_TAB_JS},
@@ -236,7 +235,7 @@ DiscardsUI::DiscardsUI(content::WebUI* web_ui)
{"chrome/browser/ui/webui/discards/site_data.mojom-webui.js",
IDR_DISCARDS_SITE_DATA_MOJOM_WEBUI_JS},
};
- webui::SetupWebUIDataSource(source.get(), kResources, "", IDR_DISCARDS_HTML);
+ webui::SetupWebUIDataSource(source.get(), kResources, IDR_DISCARDS_HTML);
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, source.release());
diff --git a/chromium/chrome/browser/ui/webui/discards/graph_dump_impl.h b/chromium/chrome/browser/ui/webui/discards/graph_dump_impl.h
index 063dfc34c57..734037ed90e 100644
--- a/chromium/chrome/browser/ui/webui/discards/graph_dump_impl.h
+++ b/chromium/chrome/browser/ui/webui/discards/graph_dump_impl.h
@@ -73,10 +73,6 @@ class DiscardsGraphDumpImpl : public discards::mojom::GraphDump,
// Ignored.
void OnFrameLifecycleStateChanged(
const performance_manager::FrameNode* frame_node) override {}
- // Ignored.
- void OnOriginTrialFreezePolicyChanged(
- const performance_manager::FrameNode* frame_node,
- const InterventionPolicy& previous_value) override {}
void OnURLChanged(const performance_manager::FrameNode* frame_node,
const GURL& previous_value) override;
// Ignored.
@@ -105,10 +101,13 @@ class DiscardsGraphDumpImpl : public discards::mojom::GraphDump,
void OnFirstContentfulPaint(
const performance_manager::FrameNode* frame_node,
base::TimeDelta time_since_navigation_start) override {}
+ // Ignored.
void OnViewportIntersectionChanged(
const performance_manager::FrameNode* frame_node) override {}
+ // Ignored.
void OnFrameVisibilityChanged(
- const performance_manager::FrameNode* frame_node) override {}
+ const performance_manager::FrameNode* frame_node,
+ performance_manager::FrameNode::Visibility previous_value) override {}
// PageNodeObserver implementation:
void OnPageNodeAdded(const performance_manager::PageNode* page_node) override;
@@ -118,19 +117,20 @@ class DiscardsGraphDumpImpl : public discards::mojom::GraphDump,
const performance_manager::PageNode* page_node,
const performance_manager::FrameNode* previous_opener,
OpenedType previous_opened_type) override;
+ // Ignored.
void OnIsVisibleChanged(
- const performance_manager::PageNode* page_node) override {} // Ignored.
+ const performance_manager::PageNode* page_node) override {}
+ // Ignored.
void OnIsAudibleChanged(
- const performance_manager::PageNode* page_node) override {} // Ignored.
- void OnIsLoadingChanged(
- const performance_manager::PageNode* page_node) override {} // Ignored.
- void OnUkmSourceIdChanged(
- const performance_manager::PageNode* page_node) override {} // Ignored.
+ const performance_manager::PageNode* page_node) override {}
// Ignored.
- void OnPageLifecycleStateChanged(
+ void OnLoadingStateChanged(
+ const performance_manager::PageNode* page_node) override {}
+ // Ignored.
+ void OnUkmSourceIdChanged(
const performance_manager::PageNode* page_node) override {}
// Ignored.
- void OnPageOriginTrialFreezePolicyChanged(
+ void OnPageLifecycleStateChanged(
const performance_manager::PageNode* page_node) override {}
// Ignored.
void OnPageIsHoldingWebLockChanged(
@@ -143,12 +143,18 @@ class DiscardsGraphDumpImpl : public discards::mojom::GraphDump,
// Ignored.
void OnMainFrameDocumentChanged(
const performance_manager::PageNode* page_node) override {}
+ // Ignored.
void OnHadFormInteractionChanged(
const performance_manager::PageNode* page_node) override {}
+ // Ignored.
void OnTitleUpdated(const performance_manager::PageNode* page_node) override {
- } // Ignored.
+ }
void OnFaviconUpdated(
const performance_manager::PageNode* page_node) override;
+ // Ignored.
+ void OnFreezingVoteChanged(
+ const performance_manager::PageNode* page_node,
+ base::Optional<performance_manager::freezing::FreezingVote>) override {}
// ProcessNodeObserver implementation:
void OnProcessNodeAdded(
diff --git a/chromium/chrome/browser/ui/webui/discards/graph_dump_impl_unittest.cc b/chromium/chrome/browser/ui/webui/discards/graph_dump_impl_unittest.cc
index 96fed66c984..c16a03bccac 100644
--- a/chromium/chrome/browser/ui/webui/discards/graph_dump_impl_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/discards/graph_dump_impl_unittest.cc
@@ -8,9 +8,9 @@
#include <set>
#include <utility>
+#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "base/run_loop.h"
-#include "base/stl_util.h"
#include "base/test/bind.h"
#include "base/time/time.h"
#include "chrome/browser/ui/webui/discards/discards.mojom.h"
diff --git a/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc b/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc
index 6aa875b3190..8424e4b4a4e 100644
--- a/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.cc
@@ -32,29 +32,43 @@ DomainReliabilityInternalsUI::DomainReliabilityInternalsUI(
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;
- web_ui->RegisterMessageCallback(
+DomainReliabilityInternalsHandler::DomainReliabilityInternalsHandler() =
+ default;
+DomainReliabilityInternalsHandler::~DomainReliabilityInternalsHandler() =
+ default;
+
+void DomainReliabilityInternalsHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
"updateData",
- base::BindRepeating(&DomainReliabilityInternalsUI::UpdateData,
+ base::BindRepeating(&DomainReliabilityInternalsHandler::HandleUpdateData,
base::Unretained(this)));
-
- Profile* profile = Profile::FromWebUI(web_ui);
- content::WebUIDataSource::Add(profile, html_source);
}
-DomainReliabilityInternalsUI::~DomainReliabilityInternalsUI() {}
+void DomainReliabilityInternalsHandler::HandleUpdateData(
+ const base::ListValue* args) {
+ DCHECK_EQ(1u, args->GetSize());
+ AllowJavascript();
+ callback_id_ = args->GetList()[0].GetString();
-void DomainReliabilityInternalsUI::UpdateData(const base::ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui());
network::mojom::NetworkContext* network_context =
content::BrowserContext::GetDefaultStoragePartition(profile)
->GetNetworkContext();
network_context->GetDomainReliabilityJSON(
- base::BindOnce(&DomainReliabilityInternalsUI::OnDataUpdated,
+ base::BindOnce(&DomainReliabilityInternalsHandler::OnDataUpdated,
weak_factory_.GetWeakPtr()));
}
-void DomainReliabilityInternalsUI::OnDataUpdated(base::Value data) const {
- web_ui()->CallJavascriptFunctionUnsafe(
- "DomainReliabilityInternals.onDataUpdated", data);
+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
index 384474ea70b..1c08e86088c 100644
--- a/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/domain_reliability_internals_ui.h
@@ -6,10 +6,12 @@
#define CHROME_BROWSER_UI_WEBUI_DOMAIN_RELIABILITY_INTERNALS_UI_H_
#include <memory>
+#include <string>
#include "base/macros.h"
#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;
@@ -22,13 +24,25 @@ class DomainReliabilityInternalsUI : public content::WebUIController {
explicit DomainReliabilityInternalsUI(content::WebUI* web_ui);
~DomainReliabilityInternalsUI() override;
+ DISALLOW_COPY_AND_ASSIGN(DomainReliabilityInternalsUI);
+};
+
+class DomainReliabilityInternalsHandler : public content::WebUIMessageHandler {
+ public:
+ DomainReliabilityInternalsHandler();
+ ~DomainReliabilityInternalsHandler() override;
+
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
+
private:
- void UpdateData(const base::ListValue* args);
- void OnDataUpdated(base::Value data) const;
+ void HandleUpdateData(const base::ListValue* args);
+ void OnDataUpdated(base::Value data);
- base::WeakPtrFactory<DomainReliabilityInternalsUI> weak_factory_{this};
+ std::string callback_id_;
+ base::WeakPtrFactory<DomainReliabilityInternalsHandler> weak_factory_{this};
- DISALLOW_COPY_AND_ASSIGN(DomainReliabilityInternalsUI);
+ DISALLOW_COPY_AND_ASSIGN(DomainReliabilityInternalsHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_DOMAIN_RELIABILITY_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/downloads/DIR_METADATA b/chromium/chrome/browser/ui/webui/downloads/DIR_METADATA
new file mode 100644
index 00000000000..6bf7cbfb89f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/downloads/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>Downloads"
+}
diff --git a/chromium/chrome/browser/ui/webui/downloads/OWNERS b/chromium/chrome/browser/ui/webui/downloads/OWNERS
index 81029b10bbf..d9feb6cf048 100644
--- a/chromium/chrome/browser/ui/webui/downloads/OWNERS
+++ b/chromium/chrome/browser/ui/webui/downloads/OWNERS
@@ -2,5 +2,3 @@ file://components/download/OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: UI>Browser>Downloads
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 16f77f8e99a..ee3461ee5cb 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_dom_handler.cc
@@ -399,8 +399,8 @@ void DownloadsDOMHandler::ShowDangerPrompt(
download::DownloadItem* dangerous_item) {
DownloadDangerPrompt* danger_prompt = DownloadDangerPrompt::Create(
dangerous_item, GetWebUIWebContents(), false,
- base::Bind(&DownloadsDOMHandler::DangerPromptDone,
- weak_ptr_factory_.GetWeakPtr(), dangerous_item->GetId()));
+ base::BindOnce(&DownloadsDOMHandler::DangerPromptDone,
+ weak_ptr_factory_.GetWeakPtr(), dangerous_item->GetId()));
// danger_prompt will delete itself.
DCHECK(danger_prompt);
}
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 c3dd6226b73..bc04a96c341 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
@@ -82,13 +82,13 @@ const char* GetDangerTypeString(download::DownloadDangerType danger_type) {
case download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS:
case download::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT:
case download::DOWNLOAD_DANGER_TYPE_USER_VALIDATED:
- case download::DOWNLOAD_DANGER_TYPE_WHITELISTED_BY_POLICY:
+ case download::DOWNLOAD_DANGER_TYPE_ALLOWLISTED_BY_POLICY:
case download::DOWNLOAD_DANGER_TYPE_MAX:
break;
}
// Don't return a danger type string if it is NOT_DANGEROUS,
- // MAYBE_DANGEROUS_CONTENT, or USER_VALIDATED, or WHITELISTED_BY_POLICY.
+ // MAYBE_DANGEROUS_CONTENT, or USER_VALIDATED, or ALLOWLISTED_BY_POLICY.
return "";
}
@@ -200,10 +200,10 @@ void DownloadsListTracker::OnDownloadRemoved(DownloadManager* manager,
DownloadsListTracker::DownloadsListTracker(
DownloadManager* download_manager,
mojo::PendingRemote<downloads::mojom::Page> page,
- base::Callback<bool(const DownloadItem&)> should_show)
+ base::RepeatingCallback<bool(const DownloadItem&)> should_show)
: main_notifier_(download_manager, this),
page_(std::move(page)),
- should_show_(should_show) {
+ should_show_(std::move(should_show)) {
DCHECK(page_);
Init();
}
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.h b/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.h
index a54c75f995c..13d045b8db5 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.h
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.h
@@ -63,9 +63,10 @@ class DownloadsListTracker
protected:
// Testing constructor.
- DownloadsListTracker(content::DownloadManager* download_manager,
- mojo::PendingRemote<downloads::mojom::Page> page,
- base::Callback<bool(const download::DownloadItem&)>);
+ DownloadsListTracker(
+ content::DownloadManager* download_manager,
+ mojo::PendingRemote<downloads::mojom::Page> page,
+ base::RepeatingCallback<bool(const download::DownloadItem&)>);
// Creates a dictionary value that's sent to the page as JSON.
virtual downloads::mojom::DataPtr CreateDownloadData(
@@ -114,7 +115,7 @@ class DownloadsListTracker
// Callback used to determine if an item should show on the page. Set to
// |ShouldShow()| in default constructor, passed in while testing.
- base::Callback<bool(const download::DownloadItem&)> should_show_;
+ base::RepeatingCallback<bool(const download::DownloadItem&)> should_show_;
// When this is true, all changes to downloads that affect the page are sent
// via JavaScript.
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc b/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
index b5413d4a0c5..e545f734772 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
@@ -10,12 +10,14 @@
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/singleton.h"
+#include "base/metrics/histogram_functions.h"
#include "base/strings/string_piece.h"
#include "base/threading/thread.h"
#include "base/values.h"
#include "chrome/browser/defaults.h"
-#include "chrome/browser/enterprise/connectors/connectors_manager.h"
+#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h"
#include "chrome/browser/ui/webui/downloads/downloads.mojom.h"
@@ -34,6 +36,7 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/prefs/pref_service.h"
+#include "components/profile_metrics/browser_profile_type.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
@@ -57,7 +60,7 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIDownloadsHost);
webui::SetupWebUIDataSource(
- source, base::make_span(kDownloadsResources, kDownloadsResourcesSize), "",
+ source, base::make_span(kDownloadsResources, kDownloadsResourcesSize),
IDR_DOWNLOADS_DOWNLOADS_HTML);
bool requests_ap_verdicts =
@@ -117,7 +120,7 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
{"toastRemovedFromList", IDS_DOWNLOAD_TOAST_REMOVED_FROM_LIST},
{"undo", IDS_DOWNLOAD_UNDO},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->AddLocalizedString("dangerDownloadDesc",
IDS_BLOCK_REASON_DANGEROUS_DOWNLOAD);
@@ -153,7 +156,8 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
source->AddBoolean(
"allowOpenNow",
- !enterprise_connectors::ConnectorsManager::GetInstance()
+ !enterprise_connectors::ConnectorsServiceFactory::GetForBrowserContext(
+ profile)
->DelayUntilVerdict(
enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED));
@@ -178,6 +182,9 @@ DownloadsUI::DownloadsUI(content::WebUI* web_ui)
ManagedUIHandler::Initialize(web_ui, source);
content::WebUIDataSource::Add(profile, source);
content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
+
+ base::UmaHistogramEnumeration("Download.OpenDownloads.PerProfileType",
+ ProfileMetrics::GetBrowserProfileType(profile));
}
WEB_UI_CONTROLLER_TYPE_IMPL(DownloadsUI)
diff --git a/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc b/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc
index 5e620f6bd67..7781c93a744 100644
--- a/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc
+++ b/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc
@@ -12,10 +12,10 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/macros.h"
-#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/dev_ui_browser_resources.h"
+#include "components/site_engagement/content/site_engagement_service.h"
#include "components/site_engagement/core/mojom/site_engagement_details.mojom.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller.h"
@@ -26,32 +26,37 @@
namespace {
-// Implementation of mojom::SiteEngagementDetailsProvider that gets information
-// from the SiteEngagementService to provide data for the WebUI.
+// Implementation of site_engagement::mojom::SiteEngagementDetailsProvider that
+// gets information from the site_engagement::SiteEngagementService to provide
+// data for the WebUI.
class SiteEngagementDetailsProviderImpl
- : public mojom::SiteEngagementDetailsProvider {
+ : public site_engagement::mojom::SiteEngagementDetailsProvider {
public:
// Instance is deleted when the supplied pipe is destroyed.
SiteEngagementDetailsProviderImpl(
Profile* profile,
- mojo::PendingReceiver<mojom::SiteEngagementDetailsProvider> receiver)
+ mojo::PendingReceiver<
+ site_engagement::mojom::SiteEngagementDetailsProvider> receiver)
: profile_(profile), receiver_(this, std::move(receiver)) {
DCHECK(profile_);
}
~SiteEngagementDetailsProviderImpl() override {}
- // mojom::SiteEngagementDetailsProvider overrides:
+ // site_engagement::mojom::SiteEngagementDetailsProvider overrides:
void GetSiteEngagementDetails(
GetSiteEngagementDetailsCallback callback) override {
- SiteEngagementService* service = SiteEngagementService::Get(profile_);
- std::vector<mojom::SiteEngagementDetails> scores = service->GetAllDetails();
+ site_engagement::SiteEngagementService* service =
+ site_engagement::SiteEngagementService::Get(profile_);
+ std::vector<site_engagement::mojom::SiteEngagementDetails> scores =
+ service->GetAllDetails();
- std::vector<mojom::SiteEngagementDetailsPtr> engagement_info;
+ std::vector<site_engagement::mojom::SiteEngagementDetailsPtr>
+ engagement_info;
engagement_info.reserve(scores.size());
for (const auto& info : scores) {
- mojom::SiteEngagementDetailsPtr origin_info(
- mojom::SiteEngagementDetails::New());
+ site_engagement::mojom::SiteEngagementDetailsPtr origin_info(
+ site_engagement::mojom::SiteEngagementDetails::New());
*origin_info = std::move(info);
engagement_info.push_back(std::move(origin_info));
}
@@ -62,11 +67,13 @@ class SiteEngagementDetailsProviderImpl
void SetSiteEngagementBaseScoreForUrl(const GURL& origin,
double score) override {
if (!origin.is_valid() || score < 0 ||
- score > SiteEngagementService::GetMaxPoints() || std::isnan(score)) {
+ score > site_engagement::SiteEngagementService::GetMaxPoints() ||
+ std::isnan(score)) {
return;
}
- SiteEngagementService* service = SiteEngagementService::Get(profile_);
+ site_engagement::SiteEngagementService* service =
+ site_engagement::SiteEngagementService::Get(profile_);
service->ResetBaseScoreForURL(origin, score);
}
@@ -74,7 +81,8 @@ class SiteEngagementDetailsProviderImpl
// The Profile* handed to us in our constructor.
Profile* profile_;
- mojo::Receiver<mojom::SiteEngagementDetailsProvider> receiver_;
+ mojo::Receiver<site_engagement::mojom::SiteEngagementDetailsProvider>
+ receiver_;
DISALLOW_COPY_AND_ASSIGN(SiteEngagementDetailsProviderImpl);
};
@@ -101,7 +109,8 @@ WEB_UI_CONTROLLER_TYPE_IMPL(SiteEngagementUI)
SiteEngagementUI::~SiteEngagementUI() {}
void SiteEngagementUI::BindInterface(
- mojo::PendingReceiver<mojom::SiteEngagementDetailsProvider> receiver) {
+ mojo::PendingReceiver<site_engagement::mojom::SiteEngagementDetailsProvider>
+ receiver) {
ui_handler_ = std::make_unique<SiteEngagementDetailsProviderImpl>(
Profile::FromWebUI(web_ui()), std::move(receiver));
}
diff --git a/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h b/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h
index bf3a19f7353..fb679644672 100644
--- a/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h
+++ b/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h
@@ -19,10 +19,12 @@ class SiteEngagementUI : public ui::MojoWebUIController {
// Instantiates the implementor of the mojom::SiteEngagementDetailsProvider
// mojo interface passing the pending receiver that will be internally bound.
void BindInterface(
- mojo::PendingReceiver<mojom::SiteEngagementDetailsProvider> receiver);
+ mojo::PendingReceiver<
+ site_engagement::mojom::SiteEngagementDetailsProvider> receiver);
private:
- std::unique_ptr<mojom::SiteEngagementDetailsProvider> ui_handler_;
+ std::unique_ptr<site_engagement::mojom::SiteEngagementDetailsProvider>
+ ui_handler_;
WEB_UI_CONTROLLER_TYPE_DECL();
diff --git a/chromium/chrome/browser/ui/webui/extensions/DIR_METADATA b/chromium/chrome/browser/ui/webui/extensions/DIR_METADATA
new file mode 100644
index 00000000000..81a57a13916
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/extensions/DIR_METADATA
@@ -0,0 +1,4 @@
+monorail {
+ component: "Platform>Extensions"
+}
+team_email: "extensions-dev@chromium.org"
diff --git a/chromium/chrome/browser/ui/webui/extensions/OWNERS b/chromium/chrome/browser/ui/webui/extensions/OWNERS
index 9f96570c5ab..e9f4e1c77db 100644
--- a/chromium/chrome/browser/ui/webui/extensions/OWNERS
+++ b/chromium/chrome/browser/ui/webui/extensions/OWNERS
@@ -1,5 +1,2 @@
finnur@chromium.org
rdevlin.cronin@chromium.org
-
-# TEAM: extensions-dev@chromium.org
-# COMPONENT: Platform>Extensions
diff --git a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
index 2f9d3d733fd..12275a0fad2 100644
--- a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
@@ -18,11 +18,10 @@
#include "base/strings/string_util.h"
#include "base/system/sys_info.h"
#include "base/values.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/profiles/profile.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/settings/cros_settings_names.h"
#include "components/crx_file/id_util.h"
#include "components/strings/grit/components_strings.h"
@@ -175,7 +174,7 @@ void KioskAppsHandler::OnKioskExtensionDownloadFailed(
void KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus(
const std::string& callback_id,
- chromeos::KioskAppManager::ConsumerKioskAutoLaunchStatus status) {
+ ash::KioskAppManager::ConsumerKioskAutoLaunchStatus status) {
initialized_ = true;
if (KioskAppManager::IsConsumerKioskEnabled()) {
if (!base::SysInfo::IsRunningOnChromeOS()) {
@@ -187,7 +186,7 @@ void KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus(
is_kiosk_enabled_ =
ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
is_auto_launch_enabled_ =
- status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED;
+ status == KioskAppManager::ConsumerKioskAutoLaunchStatus::kEnabled;
}
} else {
// Otherwise, consumer kiosk is disabled.
@@ -201,7 +200,6 @@ void KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus(
ResolveJavascriptCallback(base::Value(callback_id), kiosk_params);
}
-
void KioskAppsHandler::OnKioskAppsSettingsChanged() {
FireWebUIListener("kiosk-app-settings-changed", *GetSettingsDictionary());
}
diff --git a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h
index aeb28325109..9e87133e5c6 100644
--- a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h
+++ b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h
@@ -10,8 +10,8 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/ash/app_mode/kiosk_app_manager_observer.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace base {
@@ -20,7 +20,6 @@ class ListValue;
namespace chromeos {
-class KioskAppManager;
class OwnerSettingsServiceChromeOS;
class KioskAppsHandler : public content::WebUIMessageHandler,
@@ -61,7 +60,7 @@ class KioskAppsHandler : public content::WebUIMessageHandler,
// Callback for KioskAppManager::GetConsumerKioskModeStatus().
void OnGetConsumerKioskAutoLaunchStatus(
const std::string& callback_id,
- chromeos::KioskAppManager::ConsumerKioskAutoLaunchStatus status);
+ KioskAppManager::ConsumerKioskAutoLaunchStatus status);
KioskAppManager* kiosk_app_manager_; // not owned.
bool initialized_;
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
index 41c46b82e26..043c4dd6325 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -15,6 +15,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/chrome_extension_browser_constants.h"
#include "chrome/browser/extensions/extension_checkup.h"
@@ -46,7 +47,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h"
#endif
@@ -69,7 +70,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost);
webui::SetupWebUIDataSource(
source, base::make_span(kExtensionsResources, kExtensionsResourcesSize),
- "", IDR_EXTENSIONS_EXTENSIONS_HTML);
+ IDR_EXTENSIONS_EXTENSIONS_HTML);
static constexpr webui::LocalizedString kLocalizedStrings[] = {
// Add common strings.
@@ -227,6 +228,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
{"packDialogKeyFile", IDS_EXTENSIONS_PACK_DIALOG_KEY_FILE_LABEL},
{"packDialogContent", IDS_EXTENSION_PACK_DIALOG_HEADING},
{"packDialogConfirm", IDS_EXTENSIONS_PACK_DIALOG_CONFIRM_BUTTON},
+ {"editShortcut", IDS_EXTENSIONS_EDIT_SHORTCUT},
{"shortcutNotSet", IDS_EXTENSIONS_SHORTCUT_NOT_SET},
{"shortcutScopeGlobal", IDS_EXTENSIONS_SHORTCUT_SCOPE_GLOBAL},
{"shortcutScopeLabel", IDS_EXTENSIONS_SHORTCUT_SCOPE_LABEL},
@@ -253,7 +255,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
{"viewIframe", IDS_EXTENSIONS_VIEW_IFRAME},
{"viewServiceWorker", IDS_EXTENSIONS_SERVICE_WORKER_BACKGROUND},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"manageKioskApp", IDS_EXTENSIONS_MANAGE_KIOSK_APP},
{"kioskAddApp", IDS_EXTENSIONS_KIOSK_ADD_APP},
{"kioskAddAppHint", IDS_EXTENSIONS_KIOSK_ADD_APP_HINT},
@@ -267,7 +269,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
IDS_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_TITLE},
#endif
};
- AddLocalizedStringsBulk(source, kLocalizedStrings);
+ source->AddLocalizedStrings(kLocalizedStrings);
source->AddString("errorLinesNotShownSingular",
l10n_util::GetPluralStringFUTF16(
@@ -286,7 +288,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
GURL(chrome::kRemoveNonCWSExtensionURL),
g_browser_process->GetApplicationLocale())
.spec()));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
source->AddString(
"kioskDisableBailoutWarningBody",
l10n_util::GetStringFUTF16(
@@ -362,7 +364,7 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui)
source = CreateMdExtensionsSource(profile, *in_dev_mode_);
ManagedUIHandler::Initialize(web_ui, source);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
auto kiosk_app_handler = std::make_unique<chromeos::KioskAppsHandler>(
chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(
profile));
diff --git a/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.cc
index 2665254f0ff..2f71cd828c4 100644
--- a/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.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/supervised_user_internals_message_handler.h"
+#include "chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h"
#include <memory>
#include <utility>
@@ -35,7 +35,7 @@ using content::BrowserThread;
namespace {
-// Creates a 'section' for display on about:supervised-user-internals,
+// Creates a 'section' for display on about:family-link-user-internals,
// 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.
@@ -89,7 +89,8 @@ std::string FilteringBehaviorToString(
}
std::string FilteringBehaviorToString(
- SupervisedUserURLFilter::FilteringBehavior behavior, bool uncertain) {
+ SupervisedUserURLFilter::FilteringBehavior behavior,
+ bool uncertain) {
std::string result = FilteringBehaviorToString(behavior);
if (uncertain)
result += " (Uncertain)";
@@ -104,11 +105,11 @@ std::string FilteringBehaviorReasonToString(
case supervised_user_error_page::ASYNC_CHECKER:
return "AsyncChecker";
case supervised_user_error_page::DENYLIST:
- return "Blacklist";
+ return "Denylist";
case supervised_user_error_page::MANUAL:
return "Manual";
case supervised_user_error_page::ALLOWLIST:
- return "Whitelist";
+ return "Allowlist";
case supervised_user_error_page::NOT_SIGNED_IN:
// Should never happen, only used for requests from WebView
NOTREACHED();
@@ -118,63 +119,70 @@ std::string FilteringBehaviorReasonToString(
} // namespace
-SupervisedUserInternalsMessageHandler::SupervisedUserInternalsMessageHandler() =
+FamilyLinkUserInternalsMessageHandler::FamilyLinkUserInternalsMessageHandler() =
default;
-SupervisedUserInternalsMessageHandler::
- ~SupervisedUserInternalsMessageHandler() = default;
+FamilyLinkUserInternalsMessageHandler::
+ ~FamilyLinkUserInternalsMessageHandler() = default;
-void SupervisedUserInternalsMessageHandler::RegisterMessages() {
+void FamilyLinkUserInternalsMessageHandler::RegisterMessages() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
web_ui()->RegisterMessageCallback(
"registerForEvents",
base::BindRepeating(
- &SupervisedUserInternalsMessageHandler::HandleRegisterForEvents,
+ &FamilyLinkUserInternalsMessageHandler::HandleRegisterForEvents,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getBasicInfo",
base::BindRepeating(
- &SupervisedUserInternalsMessageHandler::HandleGetBasicInfo,
+ &FamilyLinkUserInternalsMessageHandler::HandleGetBasicInfo,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"tryURL",
- base::BindRepeating(&SupervisedUserInternalsMessageHandler::HandleTryURL,
+ base::BindRepeating(&FamilyLinkUserInternalsMessageHandler::HandleTryURL,
base::Unretained(this)));
}
-void SupervisedUserInternalsMessageHandler::OnURLFilterChanged() {
+void FamilyLinkUserInternalsMessageHandler::OnJavascriptDisallowed() {
+ scoped_observation_.Reset();
+ weak_factory_.InvalidateWeakPtrs();
+}
+
+void FamilyLinkUserInternalsMessageHandler::OnURLFilterChanged() {
SendBasicInfo();
}
SupervisedUserService*
-SupervisedUserInternalsMessageHandler::GetSupervisedUserService() {
+FamilyLinkUserInternalsMessageHandler::GetSupervisedUserService() {
Profile* profile = Profile::FromWebUI(web_ui());
return SupervisedUserServiceFactory::GetForProfile(
profile->GetOriginalProfile());
}
-void SupervisedUserInternalsMessageHandler::HandleRegisterForEvents(
+void FamilyLinkUserInternalsMessageHandler::HandleRegisterForEvents(
const base::ListValue* args) {
DCHECK(args->empty());
- if (scoped_observer_.IsObservingSources())
+ AllowJavascript();
+ if (scoped_observation_.IsObserving())
return;
- scoped_observer_.Add(GetSupervisedUserService()->GetURLFilter());
+ scoped_observation_.Observe(GetSupervisedUserService()->GetURLFilter());
}
-void SupervisedUserInternalsMessageHandler::HandleGetBasicInfo(
+void FamilyLinkUserInternalsMessageHandler::HandleGetBasicInfo(
const base::ListValue* args) {
SendBasicInfo();
}
-void SupervisedUserInternalsMessageHandler::HandleTryURL(
+void FamilyLinkUserInternalsMessageHandler::HandleTryURL(
const base::ListValue* args) {
- DCHECK_EQ(1u, args->GetSize());
+ DCHECK_EQ(2u, args->GetSize());
+ std::string callback_id;
std::string url_str;
- if (!args->GetString(0, &url_str))
+ if (!args->GetString(0, &callback_id) || !args->GetString(1, &url_str))
return;
GURL url = url_formatter::FixupURL(url_str, std::string());
@@ -195,12 +203,12 @@ void SupervisedUserInternalsMessageHandler::HandleTryURL(
filter->GetMatchingAllowlistTitles(url);
filter->GetFilteringBehaviorForURLWithAsyncChecks(
url,
- base::BindOnce(&SupervisedUserInternalsMessageHandler::OnTryURLResult,
- weak_factory_.GetWeakPtr(), allowlists),
+ base::BindOnce(&FamilyLinkUserInternalsMessageHandler::OnTryURLResult,
+ weak_factory_.GetWeakPtr(), allowlists, callback_id),
skip_manual_parent_filter);
}
-void SupervisedUserInternalsMessageHandler::SendBasicInfo() {
+void FamilyLinkUserInternalsMessageHandler::SendBasicInfo() {
std::unique_ptr<base::ListValue> section_list(new base::ListValue);
base::ListValue* section_general = AddSection(section_list.get(), "General");
@@ -211,19 +219,17 @@ void SupervisedUserInternalsMessageHandler::SendBasicInfo() {
base::ListValue* section_profile = AddSection(section_list.get(), "Profile");
AddSectionEntry(section_profile, "Account", profile->GetProfileUserName());
- AddSectionEntry(section_profile, "Legacy Supervised",
- profile->IsLegacySupervised());
AddSectionEntry(section_profile, "Child", profile->IsChild());
SupervisedUserURLFilter* filter = GetSupervisedUserService()->GetURLFilter();
base::ListValue* section_filter = AddSection(section_list.get(), "Filter");
- AddSectionEntry(section_filter, "Blacklist active", filter->HasDenylist());
+ AddSectionEntry(section_filter, "Denylist active", filter->HasDenylist());
AddSectionEntry(section_filter, "Online checks active",
filter->HasAsyncURLChecker());
- AddSectionEntry(section_filter, "Default behavior",
- FilteringBehaviorToString(
- filter->GetDefaultFilteringBehavior()));
+ AddSectionEntry(
+ section_filter, "Default behavior",
+ FilteringBehaviorToString(filter->GetDefaultFilteringBehavior()));
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile);
@@ -232,8 +238,8 @@ void SupervisedUserInternalsMessageHandler::SendBasicInfo() {
for (const auto& account :
identity_manager
->GetExtendedAccountInfoForAccountsWithRefreshToken()) {
- base::ListValue* section_user = AddSection(section_list.get(),
- "User Information for " + account.full_name);
+ base::ListValue* section_user = AddSection(
+ section_list.get(), "User Information for " + account.full_name);
AddSectionEntry(section_user, "Account id",
account.account_id.ToString());
AddSectionEntry(section_user, "Gaia", account.gaia);
@@ -248,27 +254,27 @@ void SupervisedUserInternalsMessageHandler::SendBasicInfo() {
base::DictionaryValue result;
result.Set("sections", std::move(section_list));
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.supervised_user_internals.receiveBasicInfo", result);
+ FireWebUIListener("basic-info-received", result);
// Trigger retrieval of the user settings
SupervisedUserSettingsService* settings_service =
SupervisedUserSettingsServiceFactory::GetForKey(profile->GetProfileKey());
user_settings_subscription_ =
- settings_service->SubscribeForSettingsChange(base::Bind(
- &SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings,
+ settings_service->SubscribeForSettingsChange(base::BindRepeating(
+ &FamilyLinkUserInternalsMessageHandler::SendFamilyLinkUserSettings,
weak_factory_.GetWeakPtr()));
}
-void SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings(
+void FamilyLinkUserInternalsMessageHandler::SendFamilyLinkUserSettings(
const base::DictionaryValue* settings) {
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.supervised_user_internals.receiveUserSettings",
+ FireWebUIListener(
+ "user-settings-received",
*(settings ? settings : std::make_unique<base::Value>().get()));
}
-void SupervisedUserInternalsMessageHandler::OnTryURLResult(
+void FamilyLinkUserInternalsMessageHandler::OnTryURLResult(
const std::map<std::string, base::string16>& allowlists,
+ const std::string& callback_id,
SupervisedUserURLFilter::FilteringBehavior behavior,
supervised_user_error_page::FilteringBehaviorReason reason,
bool uncertain) {
@@ -284,14 +290,13 @@ void SupervisedUserInternalsMessageHandler::OnTryURLResult(
FilteringBehaviorToString(behavior, uncertain));
result.SetBoolean("manual", reason == supervised_user_error_page::MANUAL &&
behavior == SupervisedUserURLFilter::ALLOW);
- result.SetString("whitelists", allowlists_str);
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.supervised_user_internals.receiveTryURLResult", result);
+ result.SetString("allowlists", allowlists_str);
+ ResolveJavascriptCallback(base::Value(callback_id), result);
}
-void SupervisedUserInternalsMessageHandler::OnSiteListUpdated() {}
+void FamilyLinkUserInternalsMessageHandler::OnSiteListUpdated() {}
-void SupervisedUserInternalsMessageHandler::OnURLChecked(
+void FamilyLinkUserInternalsMessageHandler::OnURLChecked(
const GURL& url,
SupervisedUserURLFilter::FilteringBehavior behavior,
supervised_user_error_page::FilteringBehaviorReason reason,
@@ -301,6 +306,5 @@ void SupervisedUserInternalsMessageHandler::OnURLChecked(
result.SetString("url", url.possibly_invalid_spec());
result.SetString("result", FilteringBehaviorToString(behavior, uncertain));
result.SetString("reason", FilteringBehaviorReasonToString(reason));
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.supervised_user_internals.receiveFilteringResult", result);
+ FireWebUIListener("filtering-result-received", result);
}
diff --git a/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.h b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h
index cb4f576cc8f..b21f6c8173c 100644
--- a/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h
@@ -2,13 +2,13 @@
// 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_SUPERVISED_USER_INTERNALS_MESSAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SUPERVISED_USER_INTERNALS_MESSAGE_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_FAMILY_LINK_USER_INTERNALS_FAMILY_LINK_USER_INTERNALS_MESSAGE_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_FAMILY_LINK_USER_INTERNALS_FAMILY_LINK_USER_INTERNALS_MESSAGE_HANDLER_H_
#include "base/callback_list.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/supervised_user/supervised_user_error_page/supervised_user_error_page.h"
#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/supervised_user/supervised_user_service_observer.h"
@@ -19,18 +19,19 @@ namespace base {
class ListValue;
} // namespace base
-// The implementation for the chrome://supervised-user-internals page.
-class SupervisedUserInternalsMessageHandler
+// The implementation for the chrome://family-link-user-internals page.
+class FamilyLinkUserInternalsMessageHandler
: public content::WebUIMessageHandler,
public SupervisedUserServiceObserver,
public SupervisedUserURLFilter::Observer {
public:
- SupervisedUserInternalsMessageHandler();
- ~SupervisedUserInternalsMessageHandler() override;
+ FamilyLinkUserInternalsMessageHandler();
+ ~FamilyLinkUserInternalsMessageHandler() override;
private:
// content::WebUIMessageHandler:
void RegisterMessages() override;
+ void OnJavascriptDisallowed() override;
// SupervisedUserServiceObserver:
void OnURLFilterChanged() override;
@@ -42,10 +43,11 @@ class SupervisedUserInternalsMessageHandler
void HandleTryURL(const base::ListValue* args);
void SendBasicInfo();
- void SendSupervisedUserSettings(const base::DictionaryValue* settings);
+ void SendFamilyLinkUserSettings(const base::DictionaryValue* settings);
void OnTryURLResult(
const std::map<std::string, base::string16>& allowlists,
+ const std::string& callback_id,
SupervisedUserURLFilter::FilteringBehavior behavior,
supervised_user_error_page::FilteringBehaviorReason reason,
bool uncertain);
@@ -57,17 +59,16 @@ class SupervisedUserInternalsMessageHandler
supervised_user_error_page::FilteringBehaviorReason reason,
bool uncertain) override;
- std::unique_ptr<
- base::CallbackList<void(const base::DictionaryValue*)>::Subscription>
- user_settings_subscription_;
+ base::CallbackListSubscription user_settings_subscription_;
- ScopedObserver<SupervisedUserURLFilter, SupervisedUserURLFilter::Observer>
- scoped_observer_{this};
+ base::ScopedObservation<SupervisedUserURLFilter,
+ SupervisedUserURLFilter::Observer>
+ scoped_observation_{this};
- base::WeakPtrFactory<SupervisedUserInternalsMessageHandler> weak_factory_{
+ base::WeakPtrFactory<FamilyLinkUserInternalsMessageHandler> weak_factory_{
this};
- DISALLOW_COPY_AND_ASSIGN(SupervisedUserInternalsMessageHandler);
+ DISALLOW_COPY_AND_ASSIGN(FamilyLinkUserInternalsMessageHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_SUPERVISED_USER_INTERNALS_MESSAGE_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_FAMILY_LINK_USER_INTERNALS_FAMILY_LINK_USER_INTERNALS_MESSAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/supervised_user_internals_ui.cc b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.cc
index 2102059f487..92b5d0a168b 100644
--- a/chromium/chrome/browser/ui/webui/supervised_user_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.cc
@@ -2,12 +2,12 @@
// 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/supervised_user_internals_ui.h"
+#include "chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.h"
#include <memory>
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/supervised_user_internals_message_handler.h"
+#include "chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_message_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/dev_ui_browser_resources.h"
#include "content/public/browser/web_ui.h"
@@ -16,9 +16,9 @@
namespace {
-content::WebUIDataSource* CreateSupervisedUserInternalsHTMLSource() {
+content::WebUIDataSource* CreateFamilyLinkUserInternalsHTMLSource() {
content::WebUIDataSource* source = content::WebUIDataSource::Create(
- chrome::kChromeUISupervisedUserInternalsHost);
+ chrome::kChromeUIFamilyLinkUserInternalsHost);
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
"script-src chrome://resources 'self' 'unsafe-eval';");
@@ -26,24 +26,24 @@ content::WebUIDataSource* CreateSupervisedUserInternalsHTMLSource() {
network::mojom::CSPDirectiveName::TrustedTypes,
"trusted-types jstemplate;");
- source->AddResourcePath("supervised_user_internals.js",
- IDR_SUPERVISED_USER_INTERNALS_JS);
- source->AddResourcePath("supervised_user_internals.css",
- IDR_SUPERVISED_USER_INTERNALS_CSS);
- source->SetDefaultResource(IDR_SUPERVISED_USER_INTERNALS_HTML);
+ source->AddResourcePath("family_link_user_internals.js",
+ IDR_FAMILY_LINK_USER_INTERNALS_JS);
+ source->AddResourcePath("family_link_user_internals.css",
+ IDR_FAMILY_LINK_USER_INTERNALS_CSS);
+ source->SetDefaultResource(IDR_FAMILY_LINK_USER_INTERNALS_HTML);
return source;
}
} // namespace
-SupervisedUserInternalsUI::SupervisedUserInternalsUI(content::WebUI* web_ui)
+FamilyLinkUserInternalsUI::FamilyLinkUserInternalsUI(content::WebUI* web_ui)
: WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile,
- CreateSupervisedUserInternalsHTMLSource());
+ CreateFamilyLinkUserInternalsHTMLSource());
web_ui->AddMessageHandler(
- std::make_unique<SupervisedUserInternalsMessageHandler>());
+ std::make_unique<FamilyLinkUserInternalsMessageHandler>());
}
-SupervisedUserInternalsUI::~SupervisedUserInternalsUI() {}
+FamilyLinkUserInternalsUI::~FamilyLinkUserInternalsUI() {}
diff --git a/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.h b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.h
new file mode 100644
index 00000000000..0a129dfb8ab
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/family_link_user_internals/family_link_user_internals_ui.h
@@ -0,0 +1,21 @@
+// Copyright 2015 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_FAMILY_LINK_USER_INTERNALS_FAMILY_LINK_USER_INTERNALS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_FAMILY_LINK_USER_INTERNALS_FAMILY_LINK_USER_INTERNALS_UI_H_
+
+#include "base/macros.h"
+#include "content/public/browser/web_ui_controller.h"
+
+// The implementation for the chrome://family-link-user-internals page.
+class FamilyLinkUserInternalsUI : public content::WebUIController {
+ public:
+ explicit FamilyLinkUserInternalsUI(content::WebUI* web_ui);
+ ~FamilyLinkUserInternalsUI() override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FamilyLinkUserInternalsUI);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_FAMILY_LINK_USER_INTERNALS_FAMILY_LINK_USER_INTERNALS_UI_H_
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 38d97b0ac21..f9d9312ec64 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom
@@ -123,10 +123,11 @@ interface PageHandler {
// This allows for testing the Feed against a development server.
OverrideFeedHost(url.mojom.Url host);
- // Overrides the URL used to upload actions.
+ // Overrides the scheme, host, and port used to make Discover API requests.
+ // Other URL components, like the path, are ignored.
// Empty to clear override.
// This allows for testing the Feed against a development server.
- OverrideActionUploadEndpoint(url.mojom.Url endpoint_url);
+ OverrideDiscoverApiEndpoint(url.mojom.Url endpoint_url);
// Overrides the feed stream data with the payload inside a feedui::Slice for
// testing purpose. See go/feed-stream-data-testing for more details.
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc
deleted file mode 100644
index a14a4f09450..00000000000
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc
+++ /dev/null
@@ -1,189 +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/feed_internals/feed_internals_page_handler.h"
-
-#include <string>
-#include <utility>
-
-#include "base/feature_list.h"
-#include "base/metrics/statistics_recorder.h"
-#include "base/time/time.h"
-#include "chrome/browser/android/feed/feed_debugging_bridge.h"
-#include "chrome/browser/android/feed/feed_lifecycle_bridge.h"
-#include "chrome/browser/ui/webui/feed_internals/feed_internals.mojom.h"
-#include "components/feed/content/feed_host_service.h"
-#include "components/feed/content/feed_offline_host.h"
-#include "components/feed/core/common/pref_names.h"
-#include "components/feed/core/common/user_classifier.h"
-#include "components/feed/core/feed_scheduler_host.h"
-#include "components/feed/core/shared_prefs/pref_names.h"
-#include "components/feed/feed_feature_list.h"
-#include "components/offline_pages/core/prefetch/prefetch_prefs.h"
-#include "components/offline_pages/core/prefetch/suggestions_provider.h"
-#include "components/prefs/pref_service.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "mojo/public/cpp/bindings/receiver.h"
-#include "url/gurl.h"
-
-namespace {
-
-const char kFeedHistogramPrefix[] = "ContentSuggestions.Feed.";
-
-// Converts |t| to a delta from the JS epoch, or 0 if |t| is null.
-base::TimeDelta ToJsTimeDelta(base::Time t) {
- return t.is_null() ? base::TimeDelta() : t - base::Time::UnixEpoch();
-}
-
-std::string TriggerTypeToString(feed::TriggerType* trigger) {
- if (trigger == nullptr)
- return "Not set";
- switch (*trigger) {
- case feed::TriggerType::kNtpShown:
- return "NTP Shown";
- case feed::TriggerType::kForegrounded:
- return "Foregrounded";
- case feed::TriggerType::kFixedTimer:
- return "Fixed Timer";
- }
-}
-
-} // namespace
-
-FeedInternalsPageHandler::FeedInternalsPageHandler(
- mojo::PendingReceiver<feed_internals::mojom::PageHandler> receiver,
- feed::FeedHostService* feed_host_service,
- PrefService* pref_service)
- : receiver_(this, std::move(receiver)),
- feed_scheduler_host_(feed_host_service->GetSchedulerHost()),
- feed_offline_host_(feed_host_service->GetOfflineHost()),
- pref_service_(pref_service) {}
-
-FeedInternalsPageHandler::~FeedInternalsPageHandler() = default;
-
-void FeedInternalsPageHandler::GetGeneralProperties(
- GetGeneralPropertiesCallback callback) {
- auto properties = feed_internals::mojom::Properties::New();
-
- properties->is_feed_enabled = true;
- properties->is_feed_visible =
- pref_service_->GetBoolean(feed::prefs::kArticlesListVisible);
- properties->is_feed_allowed = IsFeedAllowed();
- properties->is_prefetching_enabled =
- offline_pages::prefetch_prefs::IsEnabled(pref_service_);
- properties->feed_fetch_url = feed::GetFeedFetchUrlForDebugging();
-
- std::move(callback).Run(std::move(properties));
-}
-
-void FeedInternalsPageHandler::GetUserClassifierProperties(
- GetUserClassifierPropertiesCallback callback) {
- auto properties = feed_internals::mojom::UserClassifier::New();
-
- feed::UserClassifier* user_classifier =
- feed_scheduler_host_->GetUserClassifierForDebugging();
-
- properties->user_class_description =
- user_classifier->GetUserClassDescriptionForDebugging();
- properties->avg_hours_between_views = user_classifier->GetEstimatedAvgTime(
- feed::UserClassifier::Event::kSuggestionsViewed);
- properties->avg_hours_between_uses = user_classifier->GetEstimatedAvgTime(
- feed::UserClassifier::Event::kSuggestionsUsed);
-
- std::move(callback).Run(std::move(properties));
-}
-
-void FeedInternalsPageHandler::GetLastFetchProperties(
- GetLastFetchPropertiesCallback callback) {
- auto properties = feed_internals::mojom::LastFetchProperties::New();
-
- properties->last_fetch_status =
- feed_scheduler_host_->GetLastFetchStatusForDebugging();
- properties->last_fetch_trigger = TriggerTypeToString(
- feed_scheduler_host_->GetLastFetchTriggerTypeForDebugging());
- properties->last_fetch_time =
- ToJsTimeDelta(pref_service_->GetTime(feed::prefs::kLastFetchAttemptTime));
- properties->refresh_suppress_time = ToJsTimeDelta(
- feed_scheduler_host_->GetSuppressRefreshesUntilForDebugging());
- properties->last_bless_nonce =
- pref_service_->GetString(feed::prefs::kHostOverrideBlessNonce);
-
- std::move(callback).Run(std::move(properties));
-}
-
-void FeedInternalsPageHandler::ClearUserClassifierProperties() {
- feed_scheduler_host_->GetUserClassifierForDebugging()
- ->ClearClassificationForDebugging();
-}
-
-void FeedInternalsPageHandler::ClearCachedDataAndRefreshFeed() {
- feed::FeedLifecycleBridge::ClearCachedData();
-}
-
-void FeedInternalsPageHandler::RefreshFeed() {
- feed::TriggerRefreshForDebugging();
-}
-
-void FeedInternalsPageHandler::GetCurrentContent(
- GetCurrentContentCallback callback) {
- if (!IsFeedAllowed()) {
- std::move(callback).Run(
- std::vector<feed_internals::mojom::SuggestionPtr>());
- return;
- }
-
- feed_offline_host_->GetCurrentArticleSuggestions(base::BindOnce(
- &FeedInternalsPageHandler::OnGetCurrentArticleSuggestionsDone,
- weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
-}
-
-void FeedInternalsPageHandler::OnGetCurrentArticleSuggestionsDone(
- GetCurrentContentCallback callback,
- std::vector<offline_pages::PrefetchSuggestion> results) {
- std::vector<feed_internals::mojom::SuggestionPtr> suggestions;
-
- for (offline_pages::PrefetchSuggestion result : results) {
- auto suggestion = feed_internals::mojom::Suggestion::New();
- suggestion->title = std::move(result.article_title);
- suggestion->url = std::move(result.article_url);
- suggestion->publisher_name = std::move(result.article_attribution);
- suggestion->image_url = std::move(result.thumbnail_url);
- suggestion->favicon_url = std::move(result.favicon_url);
-
- suggestions.push_back(std::move(suggestion));
- }
-
- std::move(callback).Run(std::move(suggestions));
-}
-
-void FeedInternalsPageHandler::GetFeedProcessScopeDump(
- GetFeedProcessScopeDumpCallback callback) {
- std::move(callback).Run(feed::GetFeedProcessScopeDumpForDebugging());
-}
-
-bool FeedInternalsPageHandler::IsFeedAllowed() {
- return pref_service_->GetBoolean(feed::prefs::kEnableSnippets);
-}
-
-void FeedInternalsPageHandler::GetFeedHistograms(
- GetFeedHistogramsCallback callback) {
- std::string log;
- base::StatisticsRecorder::WriteGraph(kFeedHistogramPrefix, &log);
- std::move(callback).Run(log);
-}
-
-void FeedInternalsPageHandler::OverrideFeedHost(const GURL& host) {
- pref_service_->SetString(feed::prefs::kHostOverrideHost,
- host.is_valid() ? host.spec() : std::string());
-}
-
-void FeedInternalsPageHandler::OverrideActionUploadEndpoint(
- const GURL& endpoint_url) {
- // Not implemented for Feed v1.
-}
-
-void FeedInternalsPageHandler::OverrideFeedStreamData(
- const std::vector<uint8_t>& data) {
- // Not implemented for Feed v1.
-}
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h
deleted file mode 100644
index 9877243b475..00000000000
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h
+++ /dev/null
@@ -1,71 +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_FEED_INTERNALS_FEED_INTERNALS_PAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_FEED_INTERNALS_FEED_INTERNALS_PAGE_HANDLER_H_
-
-#include <vector>
-
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/ui/webui/feed_internals/feed_internals.mojom.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "mojo/public/cpp/bindings/receiver.h"
-
-class PrefService;
-
-namespace feed {
-class FeedHostService;
-class FeedOfflineHost;
-class FeedSchedulerHost;
-} // namespace feed
-
-namespace offline_pages {
-struct PrefetchSuggestion;
-} // namespace offline_pages
-
-// Concrete implementation of feed_internals::mojom::PageHandler.
-class FeedInternalsPageHandler : public feed_internals::mojom::PageHandler {
- public:
- FeedInternalsPageHandler(
- mojo::PendingReceiver<feed_internals::mojom::PageHandler> receiver,
- feed::FeedHostService* feed_host_service,
- PrefService* pref_service);
- ~FeedInternalsPageHandler() override;
-
- // feed_internals::mojom::PageHandler
- void GetGeneralProperties(GetGeneralPropertiesCallback) override;
- void GetUserClassifierProperties(
- GetUserClassifierPropertiesCallback) override;
- void ClearUserClassifierProperties() override;
- void GetLastFetchProperties(GetLastFetchPropertiesCallback) override;
- void ClearCachedDataAndRefreshFeed() override;
- void RefreshFeed() override;
- void GetCurrentContent(GetCurrentContentCallback) override;
- void GetFeedProcessScopeDump(GetFeedProcessScopeDumpCallback) override;
- void GetFeedHistograms(GetFeedHistogramsCallback) override;
- void OverrideFeedHost(const GURL& host) override;
- void OverrideActionUploadEndpoint(const GURL& endpoint_url) override;
- void OverrideFeedStreamData(const std::vector<uint8_t>& data) override;
-
- private:
- mojo::Receiver<feed_internals::mojom::PageHandler> receiver_;
-
- void OnGetCurrentArticleSuggestionsDone(
- GetCurrentContentCallback callback,
- std::vector<offline_pages::PrefetchSuggestion> suggestions);
-
- bool IsFeedAllowed();
-
- // Services that provide the data and functionality.
- feed::FeedSchedulerHost* feed_scheduler_host_;
- feed::FeedOfflineHost* feed_offline_host_;
- PrefService* pref_service_;
-
- base::WeakPtrFactory<FeedInternalsPageHandler> weak_ptr_factory_{this};
-
- DISALLOW_COPY_AND_ASSIGN(FeedInternalsPageHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_FEED_INTERNALS_FEED_INTERNALS_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc
index 1783824bfd2..a5c249eb902 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/feature_list.h"
-#include "chrome/browser/android/feed/feed_host_service_factory.h"
#include "chrome/browser/android/feed/v2/feed_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/feed_internals/feed_internals.mojom.h"
@@ -19,10 +18,6 @@
#include "content/public/browser/web_ui_data_source.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
-#if BUILDFLAG(ENABLE_FEED_V1)
-#include "chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h"
-#endif
-
#if BUILDFLAG(ENABLE_FEED_V2)
#include "chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.h"
#endif
@@ -47,20 +42,10 @@ FeedInternalsUI::~FeedInternalsUI() = default;
void FeedInternalsUI::BindInterface(
mojo::PendingReceiver<feed_internals::mojom::PageHandler> receiver) {
-#if BUILDFLAG(ENABLE_FEED_V1)
- if (feed::IsV1Enabled()) {
- page_handler_ = std::make_unique<FeedInternalsPageHandler>(
- std::move(receiver),
- feed::FeedHostServiceFactory::GetForBrowserContext(profile_),
- profile_->GetPrefs());
- }
-#endif
#if BUILDFLAG(ENABLE_FEED_V2)
- if (feed::IsV2Enabled()) {
- v2_page_handler_ = std::make_unique<FeedV2InternalsPageHandler>(
- std::move(receiver),
- feed::FeedServiceFactory::GetForBrowserContext(profile_),
- profile_->GetPrefs());
- }
+ v2_page_handler_ = std::make_unique<FeedV2InternalsPageHandler>(
+ std::move(receiver),
+ feed::FeedServiceFactory::GetForBrowserContext(profile_),
+ profile_->GetPrefs());
#endif
}
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.h b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.h
index 7af4ddbe0fc..fc850b4edd1 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.h
@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "chrome/browser/ui/webui/feed_internals/feed_internals.mojom-forward.h"
-#include "chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h"
#include "components/feed/buildflags.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/webui/mojo_web_ui_controller.h"
@@ -36,12 +35,7 @@ class FeedInternalsUI : public ui::MojoWebUIController {
private:
Profile* profile_;
-#if BUILDFLAG(ENABLE_FEED_V1)
- std::unique_ptr<FeedInternalsPageHandler> page_handler_;
-#endif
-#if BUILDFLAG(ENABLE_FEED_V2)
std::unique_ptr<FeedV2InternalsPageHandler> v2_page_handler_;
-#endif
WEB_UI_CONTROLLER_TYPE_DECL();
DISALLOW_COPY_AND_ASSIGN(FeedInternalsUI);
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 32e9a9dbbf5..b80adb787c8 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
@@ -11,7 +11,6 @@
#include "base/time/time.h"
#include "chrome/browser/ui/webui/feed_internals/feed_internals.mojom.h"
#include "components/feed/core/common/pref_names.h"
-#include "components/feed/core/common/user_classifier.h"
#include "components/feed/core/proto/v2/ui.pb.h"
#include "components/feed/core/shared_prefs/pref_names.h"
#include "components/feed/core/v2/public/feed_service.h"
@@ -143,10 +142,10 @@ void FeedV2InternalsPageHandler::OverrideFeedHost(const GURL& host) {
feed::prefs::kHostOverrideHost,
host.is_valid() ? host.spec() : std::string());
}
-void FeedV2InternalsPageHandler::OverrideActionUploadEndpoint(
+void FeedV2InternalsPageHandler::OverrideDiscoverApiEndpoint(
const GURL& endpoint_url) {
return pref_service_->SetString(
- feed::prefs::kActionsEndpointOverride,
+ feed::prefs::kDiscoverAPIEndpointOverride,
endpoint_url.is_valid() ? endpoint_url.spec() : std::string());
}
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 9600ef1f067..57acac7ded1 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
@@ -45,7 +45,7 @@ class FeedV2InternalsPageHandler : public feed_internals::mojom::PageHandler {
void GetFeedProcessScopeDump(GetFeedProcessScopeDumpCallback) override;
void GetFeedHistograms(GetFeedHistogramsCallback) override;
void OverrideFeedHost(const GURL& host) override;
- void OverrideActionUploadEndpoint(const GURL& endpoint_url) override;
+ void OverrideDiscoverApiEndpoint(const GURL& endpoint_url) override;
void OverrideFeedStreamData(const std::vector<uint8_t>& data) override;
private:
diff --git a/chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc b/chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc
new file mode 100644
index 00000000000..1cf72910228
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/feedback/feedback_ui.cc
@@ -0,0 +1,77 @@
+// 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.
+
+#include "chrome/browser/ui/webui/feedback/feedback_ui.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/webui_url_constants.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"
+#include "content/public/browser/web_ui_data_source.h"
+
+void AddStringResources(content::WebUIDataSource* source) {
+ static constexpr webui::LocalizedString kStrings[] = {
+ {"additionalInfo", IDS_FEEDBACK_ADDITIONAL_INFO_LABEL},
+ {"anonymousUser", IDS_FEEDBACK_ANONYMOUS_EMAIL_OPTION},
+ {"appTitle", IDS_FEEDBACK_REPORT_APP_TITLE},
+ {"assistantInfo", IDS_FEEDBACK_INCLUDE_ASSISTANT_INFORMATION_CHKBOX},
+ {"assistantLogsMessage", IDS_FEEDBACK_ASSISTANT_LOGS_MESSAGE},
+ {"attachFileLabel", IDS_FEEDBACK_ATTACH_FILE_LABEL},
+ {"attachFileNote", IDS_FEEDBACK_ATTACH_FILE_NOTE},
+ {"attachFileToBig", IDS_FEEDBACK_ATTACH_FILE_TO_BIG},
+ {"bluetoothLogsInfo", IDS_FEEDBACK_BLUETOOTH_LOGS_CHECKBOX},
+ {"bluetoothLogsMessage", IDS_FEEDBACK_BLUETOOTH_LOGS_MESSAGE},
+ {"cancel", IDS_CANCEL},
+ {"closeBtnLabel", IDS_FEEDBACK_CLOSE_BUTTON_LABEL},
+ {"freeFormText", IDS_FEEDBACK_FREE_TEXT_LABEL},
+ {"minimizeBtnLabel", IDS_FEEDBACK_MINIMIZE_BUTTON_LABEL},
+ {"noDescription", IDS_FEEDBACK_NO_DESCRIPTION},
+ {"pageTitle", IDS_FEEDBACK_REPORT_PAGE_TITLE},
+ {"pageUrl", IDS_FEEDBACK_REPORT_URL_LABEL},
+ {"performanceTrace", IDS_FEEDBACK_INCLUDE_PERFORMANCE_TRACE_CHECKBOX},
+ {"privacyNote", IDS_FEEDBACK_PRIVACY_NOTE},
+ {"screenshot", IDS_FEEDBACK_SCREENSHOT_LABEL},
+ {"screenshotA11y", IDS_FEEDBACK_SCREENSHOT_A11Y_TEXT},
+ {"sendReport", IDS_FEEDBACK_SEND_REPORT},
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ {"sysInfo", IDS_FEEDBACK_INCLUDE_SYSTEM_INFORMATION_AND_METRICS_CHKBOX},
+#else
+ {"sysInfo", IDS_FEEDBACK_INCLUDE_SYSTEM_INFORMATION_CHKBOX},
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+ {"sysinfoPageCollapseAllBtn", IDS_ABOUT_SYS_COLLAPSE_ALL},
+ {"sysinfoPageCollapseBtn", IDS_ABOUT_SYS_COLLAPSE},
+ {"sysinfoPageDescription", IDS_ABOUT_SYS_DESC},
+ {"sysinfoPageExpandAllBtn", IDS_ABOUT_SYS_EXPAND_ALL},
+ {"sysinfoPageExpandBtn", IDS_ABOUT_SYS_EXPAND},
+ {"sysinfoPageStatusLoading", IDS_FEEDBACK_SYSINFO_PAGE_LOADING},
+ {"sysinfoPageTableTitle", IDS_ABOUT_SYS_TABLE_TITLE},
+ {"sysinfoPageTitle", IDS_FEEDBACK_SYSINFO_PAGE_TITLE},
+ {"userEmail", IDS_FEEDBACK_USER_EMAIL_LABEL},
+ };
+
+ source->AddLocalizedStrings(kStrings);
+}
+
+content::WebUIDataSource* CreateFeedbackHTMLSource() {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIFeedbackHost);
+ source->AddResourcePaths(
+ base::make_span(kFeedbackResources, kFeedbackResourcesSize));
+ source->AddResourcePath("", IDR_FEEDBACK_DEFAULT_HTML);
+ source->UseStringsJs();
+
+ AddStringResources(source);
+
+ return source;
+}
+
+FeedbackUI::FeedbackUI(content::WebUI* web_ui) : WebUIController(web_ui) {
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, CreateFeedbackHTMLSource());
+}
+
+FeedbackUI::~FeedbackUI() = default;
diff --git a/chromium/chrome/browser/ui/webui/feedback/feedback_ui.h b/chromium/chrome/browser/ui/webui/feedback/feedback_ui.h
new file mode 100644
index 00000000000..550c150717d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/feedback/feedback_ui.h
@@ -0,0 +1,21 @@
+// 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_FEEDBACK_FEEDBACK_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_FEEDBACK_FEEDBACK_UI_H_
+
+#include "base/macros.h"
+#include "content/public/browser/web_ui_controller.h"
+
+// The implementation for the chrome://feedback page.
+class FeedbackUI : public content::WebUIController {
+ public:
+ explicit FeedbackUI(content::WebUI* web_ui);
+ ~FeedbackUI() override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FeedbackUI);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_FEEDBACK_FEEDBACK_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/flags_ui.cc b/chromium/chrome/browser/ui/webui/flags/flags_ui.cc
index 14c44937fda..671020a5b84 100644
--- a/chromium/chrome/browser/ui/webui/flags_ui.cc
+++ b/chromium/chrome/browser/ui/webui/flags/flags_ui.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/flags_ui.h"
+#include "chrome/browser/ui/webui/flags/flags_ui.h"
#include <memory>
#include <string>
@@ -14,9 +14,10 @@
#include "base/memory/ref_counted_memory.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/flags_ui_handler.h"
+#include "chrome/browser/ui/webui/flags/flags_ui_handler.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "components/flags_ui/flags_ui_constants.h"
@@ -37,17 +38,18 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/constants/ash_switches.h"
#include "base/command_line.h"
#include "base/system/sys_info.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
+#include "chrome/browser/ash/settings/owner_flags_storage.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/chromeos/settings/owner_flags_storage.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "components/account_id/account_id.h"
#include "components/infobars/core/simple_alert_infobar_delegate.h"
#include "components/pref_registry/pref_registry_syncable.h"
@@ -71,7 +73,7 @@ content::WebUIDataSource* CreateFlagsUIHTMLSource() {
"trusted-types jstemplate;");
source->AddString(flags_ui::kVersion, version_info::GetVersionNumber());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (!user_manager::UserManager::Get()->IsCurrentUserOwner() &&
base::SysInfo::IsRunningOnChromeOS()) {
// Set the string to show which user can actually change the flags.
@@ -92,7 +94,7 @@ content::WebUIDataSource* CreateFlagsUIHTMLSource() {
return source;
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// On ChromeOS verifying if the owner is signed in is async operation and only
// after finishing it the UI can be properly populated. This function is the
// callback for whether the owner is signed in. It will respectively pick the
@@ -134,6 +136,16 @@ void FinishInitialization(base::WeakPtr<T> flags_ui,
l10n_util::GetStringUTF16(IDS_FLAGS_IGNORED_DUE_TO_CRASHY_CHROME),
/*auto_expire=*/false, /*should_animate=*/true);
}
+
+ // Show a warning info bar for secondary users.
+ if (!chromeos::ProfileHelper::IsPrimaryProfile(profile)) {
+ SimpleAlertInfoBarDelegate::Create(
+ InfoBarService::FromWebContents(flags_ui->web_ui()->GetWebContents()),
+ infobars::InfoBarDelegate::BAD_FLAGS_INFOBAR_DELEGATE,
+ &vector_icons::kWarningIcon,
+ l10n_util::GetStringUTF16(IDS_FLAGS_IGNORED_SECONDARY_USERS),
+ /*auto_expire=*/false, /*should_animate=*/true);
+ }
}
#endif
@@ -162,6 +174,7 @@ void FlagsUI::AddStrings(content::WebUIDataSource* source) {
source->AddLocalizedString("reset", IDS_FLAGS_UI_PAGE_RESET);
source->AddLocalizedString("reset-acknowledged",
IDS_FLAGS_UI_RESET_ACKNOWLEDGED);
+ source->AddLocalizedString("search-label", IDS_FLAGS_UI_SEARCH_LABEL);
source->AddLocalizedString("search-placeholder",
IDS_FLAGS_UI_SEARCH_PLACEHOLDER);
source->AddLocalizedString("title", IDS_FLAGS_UI_TITLE);
@@ -196,6 +209,7 @@ void FlagsDeprecatedUI::AddStrings(content::WebUIDataSource* source) {
source->AddLocalizedString("reset", IDS_DEPRECATED_FEATURES_PAGE_RESET);
source->AddLocalizedString("reset-acknowledged",
IDS_DEPRECATED_UI_RESET_ACKNOWLEDGED);
+ source->AddLocalizedString("search-label", IDS_FLAGS_UI_SEARCH_LABEL);
source->AddLocalizedString("search-placeholder",
IDS_DEPRECATED_FEATURES_SEARCH_PLACEHOLDER);
source->AddLocalizedString("title", IDS_DEPRECATED_FEATURES_TITLE);
@@ -215,7 +229,7 @@ FlagsUIHandler* InitializeHandler(content::WebUI* web_ui,
FlagsUIHandler* handler = handler_owner.get();
web_ui->AddMessageHandler(std::move(handler_owner));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Bypass possible incognito profile.
Profile* original_profile = profile->GetOriginalProfile();
if (base::SysInfo::IsRunningOnChromeOS() &&
@@ -252,12 +266,11 @@ FlagsUI::FlagsUI(content::WebUI* web_ui)
content::WebUIDataSource::Add(profile, source);
}
-FlagsUI::~FlagsUI() {
-}
+FlagsUI::~FlagsUI() {}
// static
base::RefCountedMemory* FlagsUI::GetFaviconResourceBytes(
- ui::ScaleFactor scale_factor) {
+ ui::ScaleFactor scale_factor) {
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
IDR_FLAGS_FAVICON, scale_factor);
}
diff --git a/chromium/chrome/browser/ui/webui/flags_ui.h b/chromium/chrome/browser/ui/webui/flags/flags_ui.h
index 3809b15190d..0a23e7f057d 100644
--- a/chromium/chrome/browser/ui/webui/flags_ui.h
+++ b/chromium/chrome/browser/ui/webui/flags/flags_ui.h
@@ -2,19 +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_FLAGS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_FLAGS_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_FLAGS_FLAGS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_FLAGS_FLAGS_UI_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "content/public/browser/web_ui_controller.h"
#include "ui/base/layout.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/settings/device_settings_service.h"
-#endif
-
namespace base {
class RefCountedMemory;
}
@@ -51,4 +48,4 @@ class FlagsDeprecatedUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(FlagsDeprecatedUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_FLAGS_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_FLAGS_FLAGS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/flags_ui_handler.cc b/chromium/chrome/browser/ui/webui/flags/flags_ui_handler.cc
index 6746f3bd319..0549859b043 100644
--- a/chromium/chrome/browser/ui/webui/flags_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/flags/flags_ui_handler.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/flags_ui_handler.h"
+#include "chrome/browser/ui/webui/flags/flags_ui_handler.h"
#include "base/bind.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/common/channel_info.h"
@@ -12,7 +13,7 @@
#include "components/flags_ui/flags_ui_constants.h"
#include "components/version_info/channel.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/system/sys_info.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "components/account_id/account_id.h"
@@ -90,7 +91,7 @@ void FlagsUIHandler::HandleRequestExperimentalFeatures(
results.SetBoolean(flags_ui::kShowOwnerWarning,
access_ == flags_ui::kGeneralAccessFlagsOnly);
-#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_CHROMEOS)
+#if defined(OS_WIN) || defined(OS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH)
version_info::Channel channel = chrome::GetChannel();
results.SetBoolean(
flags_ui::kShowBetaChannelPromotion,
@@ -147,7 +148,7 @@ void FlagsUIHandler::HandleSetOriginListFlagMessage(
void FlagsUIHandler::HandleRestartBrowser(const base::ListValue* args) {
DCHECK(flags_storage_);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// On ChromeOS be less intrusive and restart inside the user session after
// we apply the newly selected flags.
base::CommandLine user_flags(base::CommandLine::NO_PROGRAM);
diff --git a/chromium/chrome/browser/ui/webui/flags_ui_handler.h b/chromium/chrome/browser/ui/webui/flags/flags_ui_handler.h
index f76e2847a3e..743a601adea 100644
--- a/chromium/chrome/browser/ui/webui/flags_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/flags/flags_ui_handler.h
@@ -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/flags_ui.h"
+#include "chrome/browser/ui/webui/flags/flags_ui.h"
#include "build/build_config.h"
#include "components/flags_ui/feature_entry.h"
#include "components/flags_ui/flags_state.h"
#include "content/public/browser/web_ui_message_handler.h"
-#ifndef CHROME_BROWSER_UI_WEBUI_FLAGS_UI_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_FLAGS_UI_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_FLAGS_FLAGS_UI_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_FLAGS_FLAGS_UI_HANDLER_H_
namespace flags_ui {
class FlagsStorage;
@@ -59,4 +59,4 @@ class FlagsUIHandler : public content::WebUIMessageHandler {
DISALLOW_COPY_AND_ASSIGN(FlagsUIHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_FLAGS_UI_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_FLAGS_FLAGS_UI_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/flags_ui_unittest.cc b/chromium/chrome/browser/ui/webui/flags/flags_ui_unittest.cc
index 59c33e0e212..ebdc04d08ec 100644
--- a/chromium/chrome/browser/ui/webui/flags_ui_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/flags/flags_ui_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/flags_ui.h"
+#include "chrome/browser/ui/webui/flags/flags_ui.h"
#include "base/values.h"
#include "content/public/test/browser_task_environment.h"
diff --git a/chromium/chrome/browser/ui/webui/gcm_internals_ui.cc b/chromium/chrome/browser/ui/webui/gcm_internals_ui.cc
index d65975650a1..49ec6e12428 100644
--- a/chromium/chrome/browser/ui/webui/gcm_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/gcm_internals_ui.cc
@@ -126,7 +126,7 @@ void GcmInternalsUIMessageHandler::SetRecording(const base::ListValue* args) {
}
// Get fresh stats after changing recording setting.
profile_service->driver()->SetGCMRecording(
- base::Bind(
+ base::BindRepeating(
&GcmInternalsUIMessageHandler::RequestGCMStatisticsFinished,
weak_ptr_factory_.GetWeakPtr()),
recording);
diff --git a/chromium/chrome/browser/ui/webui/help/help_utils_chromeos.cc b/chromium/chrome/browser/ui/webui/help/help_utils_chromeos.cc
index df7511c1397..cfddc576e74 100644
--- a/chromium/chrome/browser/ui/webui/help/help_utils_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/help/help_utils_chromeos.cc
@@ -8,10 +8,10 @@
#include <algorithm>
+#include "ash/constants/ash_switches.h"
#include "base/logging.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chromeos/constants/chromeos_switches.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chromeos/settings/cros_settings_names.h"
namespace help_utils_chromeos {
diff --git a/chromium/chrome/browser/ui/webui/help/test_version_updater.cc b/chromium/chrome/browser/ui/webui/help/test_version_updater.cc
index b159078b28a..43212689e9c 100644
--- a/chromium/chrome/browser/ui/webui/help/test_version_updater.cc
+++ b/chromium/chrome/browser/ui/webui/help/test_version_updater.cc
@@ -8,8 +8,8 @@ TestVersionUpdater::TestVersionUpdater() = default;
TestVersionUpdater::~TestVersionUpdater() = default;
-void TestVersionUpdater::CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) {
+void TestVersionUpdater::CheckForUpdate(StatusCallback callback,
+ PromoteCallback) {
callback.Run(status_, progress_, rollback_, powerwash_, version_,
update_size_, message_);
}
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 82fcef9b79c..f413068100b 100644
--- a/chromium/chrome/browser/ui/webui/help/test_version_updater.h
+++ b/chromium/chrome/browser/ui/webui/help/test_version_updater.h
@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/help/version_updater.h"
// A very simple VersionUpdater implementation that immediately invokes the
@@ -18,8 +19,7 @@ class TestVersionUpdater : public VersionUpdater {
TestVersionUpdater();
~TestVersionUpdater() override;
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override;
+ void CheckForUpdate(StatusCallback callback, PromoteCallback) override;
void SetReturnedStatus(Status status) { status_ = status; }
@@ -27,13 +27,13 @@ class TestVersionUpdater : public VersionUpdater {
#if defined(OS_MAC)
void PromoteUpdater() const override {}
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void SetChannel(const std::string& channel,
bool is_powerwash_allowed) override {}
- void GetChannel(bool get_current_channel,
- const ChannelCallback& callback) override {}
+ void GetChannel(bool get_current_channel, ChannelCallback callback) override {
+ }
void GetEolInfo(EolInfoCallback callback) override {}
- void SetUpdateOverCellularOneTimePermission(const StatusCallback& callback,
+ void SetUpdateOverCellularOneTimePermission(StatusCallback callback,
const std::string& update_version,
int64_t update_size) override {}
#endif
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater.h b/chromium/chrome/browser/ui/webui/help/version_updater.h
index bab320ef9c3..d98449dd899 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater.h
+++ b/chromium/chrome/browser/ui/webui/help/version_updater.h
@@ -10,11 +10,12 @@
#include "base/callback.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/dbus/update_engine_client.h"
#include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace content {
class WebContents;
@@ -47,8 +48,8 @@ class VersionUpdater {
// TODO(jhawkins): Use a delegate interface instead of multiple callback
// types.
-#if defined(OS_CHROMEOS)
- typedef base::Callback<void(const std::string&)> ChannelCallback;
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ typedef base::OnceCallback<void(const std::string&)> ChannelCallback;
using EolInfoCallback =
base::OnceCallback<void(chromeos::UpdateEngineClient::EolInfo eol_info)>;
#endif
@@ -64,17 +65,17 @@ class VersionUpdater {
// |update_size| is the size of the available update in bytes and should be 0
// when update is not available.
// |message| is a message explaining a failure.
- typedef base::Callback<void(Status status,
- int progress,
- bool rollback,
- bool powerwash,
- const std::string& version,
- int64_t update_size,
- const base::string16& message)>
+ typedef base::RepeatingCallback<void(Status status,
+ int progress,
+ bool rollback,
+ bool powerwash,
+ const std::string& version,
+ int64_t update_size,
+ const base::string16& message)>
StatusCallback;
// Used to show or hide the promote UI elements. Mac-only.
- typedef base::Callback<void(PromotionState)> PromoteCallback;
+ typedef base::RepeatingCallback<void(PromotionState)> PromoteCallback;
virtual ~VersionUpdater() {}
@@ -88,19 +89,19 @@ class VersionUpdater {
// |status_callback| is called for each status update. |promote_callback|
// (which is only used on the Mac) can be used to show or hide the promote UI
// elements.
- virtual void CheckForUpdate(const StatusCallback& status_callback,
- const PromoteCallback& promote_callback) = 0;
+ virtual void CheckForUpdate(StatusCallback status_callback,
+ PromoteCallback promote_callback) = 0;
#if defined(OS_MAC)
// Make updates available for all users.
virtual void PromoteUpdater() const = 0;
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
virtual void SetChannel(const std::string& channel,
bool is_powerwash_allowed) = 0;
virtual void GetChannel(bool get_current_channel,
- const ChannelCallback& callback) = 0;
+ ChannelCallback callback) = 0;
// Get the End of Life (Auto Update Expiration) Date.
virtual void GetEolInfo(EolInfoCallback callback) = 0;
@@ -114,7 +115,7 @@ class VersionUpdater {
// there's a new update available or a delta update becomes a full update with
// a larger size.
virtual void SetUpdateOverCellularOneTimePermission(
- const StatusCallback& callback,
+ StatusCallback callback,
const std::string& update_version,
int64_t update_size) = 0;
#endif
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_basic.cc b/chromium/chrome/browser/ui/webui/help/version_updater_basic.cc
index 2a4c334e2ea..dd5eae782f6 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_basic.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_basic.cc
@@ -7,9 +7,8 @@
#include "base/strings/string16.h"
#include "chrome/browser/upgrade_detector/upgrade_detector.h"
-void VersionUpdaterBasic::CheckForUpdate(
- const StatusCallback& status_callback,
- const PromoteCallback&) {
+void VersionUpdaterBasic::CheckForUpdate(StatusCallback status_callback,
+ PromoteCallback) {
const Status status = UpgradeDetector::GetInstance()->notify_upgrade()
? NEARLY_UPDATED
: DISABLED;
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_basic.h b/chromium/chrome/browser/ui/webui/help/version_updater_basic.h
index 8fbb47a79ef..4c28e47047e 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_basic.h
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_basic.h
@@ -13,8 +13,8 @@
class VersionUpdaterBasic : public VersionUpdater {
public:
// VersionUpdater implementation.
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override;
+ void CheckForUpdate(StatusCallback callback, PromoteCallback) override;
+
protected:
friend class VersionUpdater;
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 c84cefd3bb6..20164bc2360 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc
@@ -10,12 +10,12 @@
#include "base/callback_helpers.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -25,6 +25,7 @@
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_type_pattern.h"
#include "chromeos/settings/cros_settings_names.h"
+#include "chromeos/strings/grit/chromeos_strings.h"
#include "content/public/browser/web_contents.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"
@@ -135,11 +136,11 @@ VersionUpdater* VersionUpdater::Create(content::WebContents* web_contents) {
return new VersionUpdaterCros(web_contents);
}
-void VersionUpdaterCros::GetUpdateStatus(const StatusCallback& callback) {
- callback_ = callback;
+void VersionUpdaterCros::GetUpdateStatus(StatusCallback callback) {
+ callback_ = std::move(callback);
// User is not actively checking for updates.
- if (!EnsureCanUpdate(false /* interactive */, callback))
+ if (!EnsureCanUpdate(false /* interactive */, callback_))
return;
UpdateEngineClient* update_engine_client =
@@ -151,12 +152,12 @@ void VersionUpdaterCros::GetUpdateStatus(const StatusCallback& callback) {
DBusThreadManager::Get()->GetUpdateEngineClient()->GetLastStatus());
}
-void VersionUpdaterCros::CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) {
- callback_ = callback;
+void VersionUpdaterCros::CheckForUpdate(StatusCallback callback,
+ PromoteCallback) {
+ callback_ = std::move(callback);
// User is actively checking for updates.
- if (!EnsureCanUpdate(true /* interactive */, callback))
+ if (!EnsureCanUpdate(true /* interactive */, callback_))
return;
UpdateEngineClient* update_engine_client =
@@ -194,10 +195,10 @@ void VersionUpdaterCros::SetChannel(const std::string& channel,
}
void VersionUpdaterCros::SetUpdateOverCellularOneTimePermission(
- const StatusCallback& callback,
+ StatusCallback callback,
const std::string& update_version,
int64_t update_size) {
- callback_ = callback;
+ callback_ = std::move(callback);
DBusThreadManager::Get()
->GetUpdateEngineClient()
->SetUpdateOverCellularOneTimePermission(
@@ -222,20 +223,21 @@ void VersionUpdaterCros::OnSetUpdateOverCellularOneTimePermission(
}
void VersionUpdaterCros::GetChannel(bool get_current_channel,
- const ChannelCallback& cb) {
+ 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(
- get_current_channel, base::BindOnce(&VersionUpdaterCros::OnGetChannel,
- weak_ptr_factory_.GetWeakPtr(), cb));
+ get_current_channel,
+ base::BindOnce(&VersionUpdaterCros::OnGetChannel,
+ weak_ptr_factory_.GetWeakPtr(), std::move(cb)));
}
-void VersionUpdaterCros::OnGetChannel(const ChannelCallback& cb,
+void VersionUpdaterCros::OnGetChannel(ChannelCallback cb,
const std::string& current_channel) {
- cb.Run(current_channel);
+ std::move(cb).Run(current_channel);
}
void VersionUpdaterCros::GetEolInfo(EolInfoCallback cb) {
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 057881513d2..6c4b051539d 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.h
@@ -19,19 +19,17 @@ class VersionUpdaterCros : public VersionUpdater,
public chromeos::UpdateEngineClient::Observer {
public:
// VersionUpdater implementation.
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override;
+ void CheckForUpdate(StatusCallback callback, PromoteCallback) override;
void SetChannel(const std::string& channel,
bool is_powerwash_allowed) override;
- void GetChannel(bool get_current_channel,
- const ChannelCallback& callback) override;
+ void GetChannel(bool get_current_channel, ChannelCallback callback) override;
void GetEolInfo(EolInfoCallback callback) override;
- void SetUpdateOverCellularOneTimePermission(const StatusCallback& callback,
+ void SetUpdateOverCellularOneTimePermission(StatusCallback callback,
const std::string& update_version,
int64_t update_size) override;
// Gets the last update status, without triggering a new check or download.
- void GetUpdateStatus(const StatusCallback& callback);
+ void GetUpdateStatus(StatusCallback callback);
protected:
friend class VersionUpdater;
@@ -51,8 +49,7 @@ class VersionUpdaterCros : public VersionUpdater,
void OnSetUpdateOverCellularOneTimePermission(bool success);
// Callback from UpdateEngineClient::GetChannel().
- void OnGetChannel(const ChannelCallback& cb,
- const std::string& current_channel);
+ void OnGetChannel(ChannelCallback cb, const std::string& current_channel);
// Callback from UpdateEngineClient::GetEolInfo().
void OnGetEolInfo(EolInfoCallback cb,
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 999a1a67722..5cfa1b71f6c 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
@@ -11,8 +11,8 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
+#include "chrome/browser/ash/settings/scoped_cros_settings_test_helper.h"
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
-#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_update_engine_client.h"
#include "chromeos/dbus/shill/shill_service_client.h"
@@ -126,7 +126,7 @@ TEST_F(VersionUpdaterCrosTest, TwoOverlappingSetChannelRequests) {
EXPECT_EQ(0, fake_update_engine_client_->request_update_check_call_count());
// IDLE -> DOWNLOADING transition after update check.
- version_updater_->CheckForUpdate(base::Bind(&CheckNotification),
+ version_updater_->CheckForUpdate(base::BindRepeating(&CheckNotification),
VersionUpdater::PromoteCallback());
EXPECT_EQ(1, fake_update_engine_client_->request_update_check_call_count());
@@ -150,7 +150,7 @@ TEST_F(VersionUpdaterCrosTest, TwoOverlappingSetChannelRequests) {
fake_update_engine_client_->NotifyObserversThatStatusChanged(status);
}
- version_updater_->CheckForUpdate(base::Bind(&CheckNotification),
+ version_updater_->CheckForUpdate(base::BindRepeating(&CheckNotification),
VersionUpdater::PromoteCallback());
EXPECT_EQ(1, fake_update_engine_client_->request_update_check_call_count());
@@ -172,7 +172,7 @@ TEST_F(VersionUpdaterCrosTest, TwoOverlappingSetChannelRequests) {
TEST_F(VersionUpdaterCrosTest, InteractiveCellularUpdateAllowed) {
SetCellularService();
EXPECT_EQ(0, fake_update_engine_client_->request_update_check_call_count());
- version_updater_->CheckForUpdate(base::Bind(&CheckNotification),
+ version_updater_->CheckForUpdate(base::BindRepeating(&CheckNotification),
VersionUpdater::PromoteCallback());
EXPECT_EQ(1, fake_update_engine_client_->request_update_check_call_count());
}
@@ -185,7 +185,7 @@ TEST_F(VersionUpdaterCrosTest, CellularUpdateOneTimePermission) {
const std::string& update_version = "9999.0.0";
const int64_t update_size = 99999;
version_updater_->SetUpdateOverCellularOneTimePermission(
- base::Bind(&CheckNotification), update_version, update_size);
+ base::BindRepeating(&CheckNotification), update_version, update_size);
EXPECT_EQ(1, fake_update_engine_client_->request_update_check_call_count());
}
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 f00e08be0a3..54a81d93a9b 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_mac.h
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_mac.h
@@ -27,8 +27,8 @@ class BrowserUpdaterClient;
class VersionUpdaterMac : public VersionUpdater {
public:
// VersionUpdater implementation.
- void CheckForUpdate(const StatusCallback& status_callback,
- const PromoteCallback& promote_callback) override;
+ void CheckForUpdate(StatusCallback status_callback,
+ PromoteCallback promote_callback) override;
void PromoteUpdater() const override;
// Process status updates received from Keystone. The dictionary will contain
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 0cdd1f82661..cd5af02d88a 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_mac.mm
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_mac.mm
@@ -78,7 +78,7 @@ int GetDownloadProgress(int64_t downloaded_bytes, int64_t total_bytes) {
}
void UpdateStatusFromChromiumUpdater(
- const VersionUpdater::StatusCallback& status_callback,
+ VersionUpdater::StatusCallback status_callback,
updater::UpdateService::UpdateState update_state) {
VersionUpdater::Status status = VersionUpdater::Status::CHECKING;
int progress = 0;
@@ -135,19 +135,18 @@ VersionUpdaterMac::VersionUpdaterMac()
VersionUpdaterMac::~VersionUpdaterMac() {}
-void VersionUpdaterMac::CheckForUpdate(
- const StatusCallback& status_callback,
- const PromoteCallback& promote_callback) {
+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(&UpdateStatusFromChromiumUpdater, status_callback));
+ update_client_->CheckForUpdate(base::BindRepeating(
+ &UpdateStatusFromChromiumUpdater, std::move(status_callback)));
return;
#else
- status_callback_ = status_callback;
- promote_callback_ = promote_callback;
+ status_callback_ = std::move(status_callback);
+ promote_callback_ = std::move(promote_callback);
KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue];
if (keystone_glue && ![keystone_glue isOnReadOnlyFilesystem]) {
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_win.cc b/chromium/chrome/browser/ui/webui/help/version_updater_win.cc
index be910614a29..3bf62c5821c 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_win.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_win.cc
@@ -26,10 +26,10 @@ VersionUpdaterWin::VersionUpdaterWin(gfx::AcceleratedWidget owner_widget)
VersionUpdaterWin::~VersionUpdaterWin() {
}
-void VersionUpdaterWin::CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) {
+void VersionUpdaterWin::CheckForUpdate(StatusCallback callback,
+ PromoteCallback) {
// There is no supported integration with Google Update for Chromium.
- callback_ = callback;
+ callback_ = std::move(callback);
callback_.Run(CHECKING, 0, false, false, std::string(), 0, base::string16());
DoBeginUpdateCheck(false /* !install_update_if_possible */);
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_win.h b/chromium/chrome/browser/ui/webui/help/version_updater_win.h
index f225a231811..c0207fc97ff 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_win.h
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_win.h
@@ -25,8 +25,7 @@ class VersionUpdaterWin : public VersionUpdater,
~VersionUpdaterWin() override;
// VersionUpdater:
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override;
+ void CheckForUpdate(StatusCallback callback, PromoteCallback) override;
// UpdateCheckDelegate:
void OnUpdateCheckComplete(const base::string16& new_version) override;
diff --git a/chromium/chrome/browser/ui/webui/history/DIR_METADATA b/chromium/chrome/browser/ui/webui/history/DIR_METADATA
new file mode 100644
index 00000000000..9b08ae7f369
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/history/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>History"
+}
diff --git a/chromium/chrome/browser/ui/webui/history/OWNERS b/chromium/chrome/browser/ui/webui/history/OWNERS
index a0c62451c7e..e75cb39c7eb 100644
--- a/chromium/chrome/browser/ui/webui/history/OWNERS
+++ b/chromium/chrome/browser/ui/webui/history/OWNERS
@@ -1,3 +1 @@
file://chrome/browser/resources/history/OWNERS
-
-# COMPONENT: UI>Browser>History
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 7007cd96f5a..82a7b826eab 100644
--- a/chromium/chrome/browser/ui/webui/history/browsing_history_handler.cc
+++ b/chromium/chrome/browser/ui/webui/history/browsing_history_handler.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/check_op.h"
+#include "base/feature_list.h"
#include "base/i18n/rtl.h"
#include "base/i18n/time_formatting.h"
#include "base/notreached.h"
@@ -37,6 +38,7 @@
#include "components/favicon/core/large_icon_service.h"
#include "components/favicon_base/favicon_url_parser.h"
#include "components/keyed_service/core/service_access_type.h"
+#include "components/memories/core/memories_features.h"
#include "components/prefs/pref_service.h"
#include "components/query_parser/snippet.h"
#include "components/strings/grit/components_strings.h"
@@ -133,6 +135,21 @@ void SetHistoryEntryUrlAndTitle(
result->SetStringKey("title", title_to_set);
}
+// Helper function to check if entry is present in local database (local-side
+// history).
+bool IsUrlInLocalDatabase(const BrowsingHistoryService::HistoryEntry& entry) {
+ switch (entry.entry_type) {
+ case BrowsingHistoryService::HistoryEntry::EntryType::EMPTY_ENTRY:
+ case BrowsingHistoryService::HistoryEntry::EntryType::REMOTE_ENTRY:
+ return false;
+ case BrowsingHistoryService::HistoryEntry::EntryType::LOCAL_ENTRY:
+ case BrowsingHistoryService::HistoryEntry::EntryType::COMBINED_ENTRY:
+ return true;
+ }
+ NOTREACHED();
+ return false;
+}
+
// Helper function to check if entry is present in user remote data (server-side
// history).
bool IsEntryInRemoteUserData(
@@ -247,6 +264,16 @@ base::Value HistoryEntryToValue(
result.SetStringKey("remoteIconUrlForUma",
entry.remote_icon_url_for_uma.spec());
+ // Additional debugging fields that are only shown if the memories::kDebug
+ // feature is enabled.
+ if (base::FeatureList::IsEnabled(memories::kDebug)) {
+ base::Value debug(base::Value::Type::DICTIONARY);
+ debug.SetBoolKey("isUrlInLocalDatabase", IsUrlInLocalDatabase(entry));
+ debug.SetIntKey("visitCount", entry.visit_count);
+ debug.SetIntKey("typedCount", entry.typed_count);
+ result.SetKey("debug", std::move(debug));
+ }
+
return result;
}
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 9a1234fff8e..80ad31e385f 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
@@ -155,7 +155,7 @@ class BrowsingHistoryHandlerTest : public ChromeRenderViewHostTestHarness {
// Tests that BrowsingHistoryHandler is informed about WebHistoryService
// deletions.
TEST_F(BrowsingHistoryHandlerTest, ObservingWebHistoryDeletions) {
- base::Callback<void(bool)> callback = base::DoNothing();
+ base::RepeatingCallback<void(bool)> callback = base::DoNothing();
// BrowsingHistoryHandler is informed about WebHistoryService history
// deletions.
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 7e249a63410..0766177760b 100644
--- a/chromium/chrome/browser/ui/webui/history/foreign_session_handler.h
+++ b/chromium/chrome/browser/ui/webui/history/foreign_session_handler.h
@@ -101,8 +101,7 @@ class ForeignSessionHandler : public content::WebUIMessageHandler {
base::Value initial_session_list_;
- std::unique_ptr<base::CallbackList<void()>::Subscription>
- foreign_session_updated_subscription_;
+ base::CallbackListSubscription foreign_session_updated_subscription_;
DISALLOW_COPY_AND_ASSIGN(ForeignSessionHandler);
};
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 2ba72ea1874..437d806058c 100644
--- a/chromium/chrome/browser/ui/webui/history/history_login_handler.cc
+++ b/chromium/chrome/browser/ui/webui/history/history_login_handler.cc
@@ -17,8 +17,8 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
-HistoryLoginHandler::HistoryLoginHandler(const base::Closure& signin_callback)
- : signin_callback_(signin_callback) {}
+HistoryLoginHandler::HistoryLoginHandler(base::RepeatingClosure signin_callback)
+ : signin_callback_(std::move(signin_callback)) {}
HistoryLoginHandler::~HistoryLoginHandler() {}
@@ -37,8 +37,8 @@ void HistoryLoginHandler::RegisterMessages() {
void HistoryLoginHandler::OnJavascriptAllowed() {
profile_info_watcher_ = std::make_unique<ProfileInfoWatcher>(
Profile::FromWebUI(web_ui()),
- base::Bind(&HistoryLoginHandler::ProfileInfoChanged,
- base::Unretained(this)));
+ base::BindRepeating(&HistoryLoginHandler::ProfileInfoChanged,
+ base::Unretained(this)));
ProfileInfoChanged();
}
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 96b23d599bf..c10c6dbdb85 100644
--- a/chromium/chrome/browser/ui/webui/history/history_login_handler.h
+++ b/chromium/chrome/browser/ui/webui/history/history_login_handler.h
@@ -16,7 +16,7 @@ class ProfileInfoWatcher;
// The handler for login-related messages from chrome://history.
class HistoryLoginHandler : public content::WebUIMessageHandler {
public:
- explicit HistoryLoginHandler(const base::Closure& signin_callback);
+ explicit HistoryLoginHandler(base::RepeatingClosure signin_callback);
~HistoryLoginHandler() override;
// WebUIMessageHandler implementation.
@@ -38,7 +38,7 @@ class HistoryLoginHandler : public content::WebUIMessageHandler {
// changes).
std::unique_ptr<ProfileInfoWatcher> profile_info_watcher_;
- base::Closure signin_callback_;
+ base::RepeatingClosure signin_callback_;
DISALLOW_COPY_AND_ASSIGN(HistoryLoginHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/history/history_ui.cc b/chromium/chrome/browser/ui/webui/history/history_ui.cc
index 4f7e554e9f4..bc021965173 100644
--- a/chromium/chrome/browser/ui/webui/history/history_ui.cc
+++ b/chromium/chrome/browser/ui/webui/history/history_ui.cc
@@ -47,7 +47,8 @@ constexpr char kIsUserSignedInKey[] = "isUserSignedIn";
bool IsUserSignedIn(Profile* profile) {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile);
- return identity_manager && identity_manager->HasPrimaryAccount();
+ return identity_manager &&
+ identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync);
}
content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
@@ -73,6 +74,7 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
{"historyMenuButton", IDS_HISTORY_HISTORY_MENU_DESCRIPTION},
{"historyMenuItem", IDS_HISTORY_HISTORY_MENU_ITEM},
{"itemsSelected", IDS_HISTORY_ITEMS_SELECTED},
+ {"itemsUnselected", IDS_HISTORY_ITEMS_UNSELECTED},
{"loading", IDS_HISTORY_LOADING},
{"menu", IDS_MENU},
{"moreFromSite", IDS_HISTORY_MORE_FROM_SITE},
@@ -92,7 +94,7 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
{"signInPromoDesc", IDS_HISTORY_SIGN_IN_PROMO_DESC},
{"title", IDS_HISTORY_TITLE},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->AddString(
"sidebarFooter",
@@ -112,7 +114,7 @@ content::WebUIDataSource* CreateHistoryUIHTMLSource(Profile* profile) {
source->AddBoolean(kIsUserSignedInKey, IsUserSignedIn(profile));
webui::SetupWebUIDataSource(
- source, base::make_span(kHistoryResources, kHistoryResourcesSize), "",
+ source, base::make_span(kHistoryResources, kHistoryResourcesSize),
IDR_HISTORY_HISTORY_HTML);
return source;
@@ -140,9 +142,9 @@ HistoryUI::HistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
foreign_session_handler.get();
web_ui->AddMessageHandler(std::move(foreign_session_handler));
foreign_session_handler_ptr->InitializeForeignSessions();
- web_ui->AddMessageHandler(std::make_unique<HistoryLoginHandler>(
- base::Bind(&HistoryUI::UpdateDataSource, base::Unretained(this))));
-
+ web_ui->AddMessageHandler(
+ std::make_unique<HistoryLoginHandler>(base::BindRepeating(
+ &HistoryUI::UpdateDataSource, base::Unretained(this))));
}
HistoryUI::~HistoryUI() {}
diff --git a/chromium/chrome/browser/ui/webui/identity_internals_ui.cc b/chromium/chrome/browser/ui/webui/identity_internals_ui.cc
index 6d1977a9b39..0d6ab3cdc3a 100644
--- a/chromium/chrome/browser/ui/webui/identity_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/identity_internals_ui.cc
@@ -29,8 +29,8 @@
namespace {
// RevokeToken message parameter offsets.
-const int kRevokeTokenExtensionOffset = 0;
-const int kRevokeTokenTokenOffset = 1;
+const int kRevokeTokenExtensionOffset = 1;
+const int kRevokeTokenTokenOffset = 2;
class IdentityInternalsTokenRevoker;
@@ -43,7 +43,8 @@ class IdentityInternalsUIMessageHandler : public content::WebUIMessageHandler {
// Ensures that a proper clean up happens after a token is revoked. That
// includes deleting the |token_revoker|, removing the token from Identity API
// cache and updating the UI that the token is gone.
- void OnTokenRevokerDone(IdentityInternalsTokenRevoker* token_revoker);
+ void OnTokenRevokerDone(IdentityInternalsTokenRevoker* token_revoker,
+ const std::string& callback_id);
// WebUIMessageHandler implementation.
void RegisterMessages() override;
@@ -99,6 +100,7 @@ class IdentityInternalsTokenRevoker : public GaiaAuthConsumer {
// notified when revocation succeeds via |OnTokenRevokerDone()|.
IdentityInternalsTokenRevoker(const std::string& extension_id,
const std::string& access_token,
+ const std::string& callback_id,
Profile* profile,
IdentityInternalsUIMessageHandler* consumer);
~IdentityInternalsTokenRevoker() override;
@@ -120,6 +122,8 @@ class IdentityInternalsTokenRevoker : public GaiaAuthConsumer {
const std::string extension_id_;
// The access token to revoke.
const std::string access_token_;
+ // The JS callback to resolve when revoking is done.
+ const std::string callback_id_;
// An object that needs to be notified once the access token is revoked.
IdentityInternalsUIMessageHandler* consumer_; // weak.
@@ -131,7 +135,8 @@ IdentityInternalsUIMessageHandler::IdentityInternalsUIMessageHandler() {}
IdentityInternalsUIMessageHandler::~IdentityInternalsUIMessageHandler() {}
void IdentityInternalsUIMessageHandler::OnTokenRevokerDone(
- IdentityInternalsTokenRevoker* token_revoker) {
+ IdentityInternalsTokenRevoker* token_revoker,
+ const std::string& callback_id) {
extensions::IdentityAPI* api =
extensions::IdentityAPI::GetFactoryInstance()->Get(
Profile::FromWebUI(web_ui()));
@@ -145,10 +150,8 @@ void IdentityInternalsUIMessageHandler::OnTokenRevokerDone(
token_revoker->access_token());
// Update view about the token being removed.
- base::ListValue result;
- result.AppendString(token_revoker->access_token());
- web_ui()->CallJavascriptFunctionUnsafe("identity_internals.tokenRevokeDone",
- result);
+ ResolveJavascriptCallback(base::Value(callback_id),
+ base::Value(token_revoker->access_token()));
// Erase the revoker.
for (auto iter = token_revokers_.begin(); iter != token_revokers_.end();
@@ -184,7 +187,6 @@ std::unique_ptr<base::ListValue> IdentityInternalsUIMessageHandler::GetScopes(
std::string IdentityInternalsUIMessageHandler::GetStatus(
const extensions::IdentityTokenCacheValue& token_cache_value) {
switch (token_cache_value.status()) {
- case extensions::IdentityTokenCacheValue::CACHE_STATUS_ADVICE:
case extensions::IdentityTokenCacheValue::CACHE_STATUS_REMOTE_CONSENT:
case extensions::IdentityTokenCacheValue::
CACHE_STATUS_REMOTE_CONSENT_APPROVED:
@@ -222,6 +224,11 @@ IdentityInternalsUIMessageHandler::GetInfoForToken(
void IdentityInternalsUIMessageHandler::GetInfoForAllTokens(
const base::ListValue* args) {
+ std::string callback_id;
+ CHECK(args->GetString(0, &callback_id));
+ CHECK(!callback_id.empty());
+
+ AllowJavascript();
base::ListValue results;
extensions::IdentityTokenCache::AccessTokensCache tokens;
// The API can be null in incognito.
@@ -235,9 +242,7 @@ void IdentityInternalsUIMessageHandler::GetInfoForAllTokens(
results.Append(GetInfoForToken(key_tokens.first, token));
}
}
-
- web_ui()->CallJavascriptFunctionUnsafe("identity_internals.returnTokens",
- results);
+ ResolveJavascriptCallback(base::Value(callback_id), results);
}
void IdentityInternalsUIMessageHandler::RegisterMessages() {
@@ -256,20 +261,27 @@ void IdentityInternalsUIMessageHandler::RevokeToken(
const base::ListValue* args) {
std::string extension_id;
std::string access_token;
+ std::string callback_id;
+ CHECK(args->GetString(0, &callback_id));
+ CHECK(!callback_id.empty());
+
args->GetString(kRevokeTokenExtensionOffset, &extension_id);
args->GetString(kRevokeTokenTokenOffset, &access_token);
token_revokers_.push_back(std::make_unique<IdentityInternalsTokenRevoker>(
- extension_id, access_token, Profile::FromWebUI(web_ui()), this));
+ extension_id, access_token, callback_id, Profile::FromWebUI(web_ui()),
+ this));
}
IdentityInternalsTokenRevoker::IdentityInternalsTokenRevoker(
const std::string& extension_id,
const std::string& access_token,
+ const std::string& callback_id,
Profile* profile,
IdentityInternalsUIMessageHandler* consumer)
: fetcher_(this, gaia::GaiaSource::kChrome, profile->GetURLLoaderFactory()),
extension_id_(extension_id),
access_token_(access_token),
+ callback_id_(callback_id),
consumer_(consumer) {
DCHECK(consumer_);
fetcher_.StartRevokeOAuth2Token(access_token);
@@ -279,7 +291,7 @@ IdentityInternalsTokenRevoker::~IdentityInternalsTokenRevoker() {}
void IdentityInternalsTokenRevoker::OnOAuth2RevokeTokenCompleted(
GaiaAuthConsumer::TokenRevocationStatus status) {
- consumer_->OnTokenRevokerDone(this);
+ consumer_->OnTokenRevokerDone(this, callback_id_);
}
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.js b/chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.js
index 76110ff5dd1..290d3ea3214 100644
--- a/chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.js
+++ b/chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.js
@@ -263,15 +263,13 @@ IdentityInternalsWebUITestAsync.prototype = {
TEST_F('IdentityInternalsWebUITestAsync', 'revokeToken', function() {
const tokenListBefore = this.getTokens();
expectEquals(2, tokenListBefore.length);
- const tokenRevokeDone = identity_internals.tokenRevokeDone;
- identity_internals.tokenRevokeDone = this.continueTest(
- WhenTestDone.ALWAYS, function(accessTokens) {
- tokenRevokeDone.call(identity_internals, accessTokens);
- identity_internals.tokenRevokeDone = tokenRevokeDone;
- const tokenListAfter = this.getTokens();
- expectEquals(1, tokenListAfter.length);
- expectEquals(this.getAccessToken(tokenListBefore[0]),
- this.getAccessToken(tokenListAfter[0]));
- }.bind(this));
+ const tokenList = document.querySelector('#token-list');
+ tokenList.addEventListener('token-removed-for-test', e => {
+ const tokenListAfter = this.getTokens();
+ expectEquals(1, tokenListAfter.length);
+ expectEquals(this.getAccessToken(tokenListBefore[0]),
+ this.getAccessToken(tokenListAfter[0]));
+ testDone();
+ });
this.getRevokeButton(tokenListBefore[1]).click();
});
diff --git a/chromium/chrome/browser/ui/webui/inspect_ui.cc b/chromium/chrome/browser/ui/webui/inspect_ui.cc
index 2912fe7cc05..4f6ab10cab3 100644
--- a/chromium/chrome/browser/ui/webui/inspect_ui.cc
+++ b/chromium/chrome/browser/ui/webui/inspect_ui.cc
@@ -24,12 +24,8 @@
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
-#include "content/public/browser/web_contents_observer.h"
#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"
@@ -372,7 +368,7 @@ void DevToolsUIBindingsEnabler::DidFinishNavigation(
// InspectUI --------------------------------------------------------
InspectUI::InspectUI(content::WebUI* web_ui)
- : WebUIController(web_ui) {
+ : WebUIController(web_ui), WebContentsObserver(web_ui->GetWebContents()) {
web_ui->AddMessageHandler(std::make_unique<InspectMessageHandler>(this));
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, CreateInspectUIHTMLSource());
@@ -495,14 +491,11 @@ void InspectUI::InspectDevices(Browser* browser) {
NavigateParams params(GetSingletonTabNavigateParams(
browser, GURL(chrome::kChromeUIInspectURL)));
params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE;
- ShowSingletonTabOverwritingNTP(browser, std::move(params));
+ ShowSingletonTabOverwritingNTP(browser, &params);
}
-void InspectUI::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (source == content::Source<WebContents>(web_ui()->GetWebContents()))
- StopListeningNotifications();
+void InspectUI::WebContentsDestroyed() {
+ StopListeningNotifications();
}
void InspectUI::StartListeningNotifications() {
@@ -512,7 +505,7 @@ void InspectUI::StartListeningNotifications() {
Profile* profile = Profile::FromWebUI(web_ui());
DevToolsTargetsUIHandler::Callback callback =
- base::Bind(&InspectUI::PopulateTargets, base::Unretained(this));
+ base::BindRepeating(&InspectUI::PopulateTargets, base::Unretained(this));
PopulateAdditionalTargets(GetUiDevToolsTargets());
@@ -525,31 +518,32 @@ void InspectUI::StartListeningNotifications() {
DevToolsTargetsUIHandler::CreateForAdb(callback, profile));
}
- port_status_serializer_.reset(
- new PortForwardingStatusSerializer(
- base::Bind(&InspectUI::PopulatePortStatus, base::Unretained(this)),
- profile));
-
- notification_registrar_.Add(this,
- content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
- content::NotificationService::AllSources());
+ port_status_serializer_ = std::make_unique<PortForwardingStatusSerializer>(
+ base::BindRepeating(&InspectUI::PopulatePortStatus,
+ base::Unretained(this)),
+ profile);
pref_change_registrar_.Init(profile->GetPrefs());
- pref_change_registrar_.Add(prefs::kDevToolsDiscoverUsbDevicesEnabled,
- base::Bind(&InspectUI::UpdateDiscoverUsbDevicesEnabled,
- base::Unretained(this)));
- pref_change_registrar_.Add(prefs::kDevToolsPortForwardingEnabled,
- base::Bind(&InspectUI::UpdatePortForwardingEnabled,
- base::Unretained(this)));
- pref_change_registrar_.Add(prefs::kDevToolsPortForwardingConfig,
- base::Bind(&InspectUI::UpdatePortForwardingConfig,
- base::Unretained(this)));
- pref_change_registrar_.Add(prefs::kDevToolsDiscoverTCPTargetsEnabled,
- base::Bind(&InspectUI::UpdateTCPDiscoveryEnabled,
- base::Unretained(this)));
- pref_change_registrar_.Add(prefs::kDevToolsTCPDiscoveryConfig,
- base::Bind(&InspectUI::UpdateTCPDiscoveryConfig,
- base::Unretained(this)));
+ pref_change_registrar_.Add(
+ prefs::kDevToolsDiscoverUsbDevicesEnabled,
+ base::BindRepeating(&InspectUI::UpdateDiscoverUsbDevicesEnabled,
+ base::Unretained(this)));
+ pref_change_registrar_.Add(
+ prefs::kDevToolsPortForwardingEnabled,
+ base::BindRepeating(&InspectUI::UpdatePortForwardingEnabled,
+ base::Unretained(this)));
+ pref_change_registrar_.Add(
+ prefs::kDevToolsPortForwardingConfig,
+ base::BindRepeating(&InspectUI::UpdatePortForwardingConfig,
+ base::Unretained(this)));
+ pref_change_registrar_.Add(
+ prefs::kDevToolsDiscoverTCPTargetsEnabled,
+ base::BindRepeating(&InspectUI::UpdateTCPDiscoveryEnabled,
+ base::Unretained(this)));
+ pref_change_registrar_.Add(
+ prefs::kDevToolsTCPDiscoveryConfig,
+ base::BindRepeating(&InspectUI::UpdateTCPDiscoveryConfig,
+ base::Unretained(this)));
}
void InspectUI::StopListeningNotifications() {
@@ -560,7 +554,6 @@ void InspectUI::StopListeningNotifications() {
port_status_serializer_.reset();
- notification_registrar_.RemoveAll();
pref_change_registrar_.RemoveAll();
}
diff --git a/chromium/chrome/browser/ui/webui/inspect_ui.h b/chromium/chrome/browser/ui/webui/inspect_ui.h
index 679f509d3ee..2537c923c42 100644
--- a/chromium/chrome/browser/ui/webui/inspect_ui.h
+++ b/chromium/chrome/browser/ui/webui/inspect_ui.h
@@ -13,8 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "components/prefs/pref_change_registrar.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -32,7 +31,7 @@ class DevToolsTargetsUIHandler;
class PortForwardingStatusSerializer;
class InspectUI : public content::WebUIController,
- public content::NotificationObserver {
+ public content::WebContentsObserver {
public:
explicit InspectUI(content::WebUI* web_ui);
~InspectUI() override;
@@ -56,10 +55,8 @@ class InspectUI : public content::WebUIController,
static void InspectDevices(Browser* browser);
private:
- // content::NotificationObserver overrides.
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
+ // content::WebContentsObserver:
+ void WebContentsDestroyed() override;
void StartListeningNotifications();
void StopListeningNotifications();
@@ -93,9 +90,6 @@ class InspectUI : public content::WebUIController,
void ShowIncognitoWarning();
- // A scoped container for notification registries.
- content::NotificationRegistrar notification_registrar_;
-
// A scoped container for preference change registries.
PrefChangeRegistrar pref_change_registrar_;
diff --git a/chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc b/chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc
index 9b7c35fb1c1..056ed9c832e 100644
--- a/chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.cc
@@ -38,18 +38,21 @@ void QueryTilesInternalsUIMessageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"getServiceStatus",
- base::Bind(&QueryTilesInternalsUIMessageHandler::HandleGetServiceStatus,
- weak_ptr_factory_.GetWeakPtr()));
+ base::BindRepeating(
+ &QueryTilesInternalsUIMessageHandler::HandleGetServiceStatus,
+ weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
"getTileData",
- base::Bind(&QueryTilesInternalsUIMessageHandler::HandleGetTileData,
- weak_ptr_factory_.GetWeakPtr()));
+ base::BindRepeating(
+ &QueryTilesInternalsUIMessageHandler::HandleGetTileData,
+ weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
"setServerUrl",
- base::Bind(&QueryTilesInternalsUIMessageHandler::HandleSetServerUrl,
- weak_ptr_factory_.GetWeakPtr()));
+ base::BindRepeating(
+ &QueryTilesInternalsUIMessageHandler::HandleSetServerUrl,
+ weak_ptr_factory_.GetWeakPtr()));
}
void QueryTilesInternalsUIMessageHandler::HandleGetTileData(
@@ -102,9 +105,9 @@ void QueryTilesInternalsUIMessageHandler::OnTileDataAvailable(
}
void QueryTilesInternalsUIMessageHandler::OnJavascriptAllowed() {
- logger_observer_.Add(tile_service_->GetLogger());
+ logger_observation_.Observe(tile_service_->GetLogger());
}
void QueryTilesInternalsUIMessageHandler::OnJavascriptDisallowed() {
- logger_observer_.RemoveAll();
+ logger_observation_.Reset();
}
diff --git a/chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h b/chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h
index f896b566675..dc1cb455d61 100644
--- a/chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/internals/query_tiles/query_tiles_internals_ui_message_handler.h
@@ -7,7 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "components/query_tiles/logger.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -46,8 +46,8 @@ class QueryTilesInternalsUIMessageHandler
query_tiles::TileService* tile_service_;
- ScopedObserver<query_tiles::Logger, query_tiles::Logger::Observer>
- logger_observer_{this};
+ base::ScopedObservation<query_tiles::Logger, query_tiles::Logger::Observer>
+ logger_observation_{this};
base::WeakPtrFactory<QueryTilesInternalsUIMessageHandler> weak_ptr_factory_{
this};
diff --git a/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals.mojom b/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals.mojom
index 0a05fcafaca..67f25f3753e 100644
--- a/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals.mojom
+++ b/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals.mojom
@@ -15,6 +15,54 @@ struct WebApp {
string debug_info;
};
+struct DisabledConfig {
+ // The string representation of the config.
+ string config;
+
+ // The reason the config was disabled.
+ string reason;
+};
+
+struct InstallResult {
+ // The install_url of the config being installed.
+ string install_url;
+
+ // The InstallResultCode returned by the installation process.
+ string install_result_code;
+
+ // Whether the installation uninstalled and replaced an old app.
+ bool did_uninstall_and_replace;
+};
+
+struct UninstallResult {
+ // The install_url of the config being uninstalled.
+ string install_url;
+
+ // Whether the uninstallation was successful.
+ bool is_success;
+};
+
+struct PreinstalledWebAppDebugInfo {
+ // Whether preinstalled web apps have completed start up synchronization.
+ bool is_start_up_task_complete;
+
+ // Errors encountered when parsing preinstalled web app configs.
+ array<string> parse_errors;
+
+ // String representations of enabled preinstalled app configs.
+ array<string> enabled_configs;
+
+ // String representations of disabled preinstalled app configs plus the reason
+ // why they are disabled.
+ array<DisabledConfig> disabled_configs;
+
+ // The results of any new preinstalled app installations.
+ array<InstallResult> install_results;
+
+ // The results of any preinstalled app removals.
+ array<UninstallResult> uninstall_results;
+};
+
// Provides access to browser side internal information about installed web apps
// (also known as PWAs) for chrome://internals/web-app.
interface WebAppInternalsPageHandler {
@@ -24,6 +72,9 @@ interface WebAppInternalsPageHandler {
// Returns details of all the installed web apps for the current profile.
GetWebApps() => (array<WebApp> web_app_list);
+ // Returns debug information about the state of preinstalled web apps.
+ GetPreinstalledWebAppDebugInfo() => (PreinstalledWebAppDebugInfo? status);
+
// Returns the prefs used for keeping track of non-user installed web apps.
GetExternallyInstalledWebAppPrefs() =>
(string externally_installed_web_app_prefs);
diff --git a/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc b/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc
index 8fe88cabf7c..67bf112d7fe 100644
--- a/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc
+++ b/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc
@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <sstream>
-
#include "chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.h"
+#include <sstream>
+#include <utility>
+
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/web_applications/components/web_app_provider_base.h"
+#include "chrome/browser/web_applications/components/web_app_constants.h"
+#include "chrome/browser/web_applications/external_web_app_manager.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/chrome_features.h"
#include "chrome/common/pref_names.h"
@@ -16,6 +19,17 @@
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui_data_source.h"
+namespace {
+
+template <typename T>
+std::string ConvertToString(const T& value) {
+ std::stringstream ss;
+ ss << value;
+ return ss.str();
+}
+
+} // namespace
+
WebAppInternalsPageHandlerImpl::WebAppInternalsPageHandlerImpl(Profile* profile)
: profile_(profile) {}
@@ -37,7 +51,7 @@ void WebAppInternalsPageHandlerImpl::IsBmoEnabled(
}
void WebAppInternalsPageHandlerImpl::GetWebApps(GetWebAppsCallback callback) {
- auto* provider = web_app::WebAppProviderBase::GetProviderBase(profile_);
+ auto* provider = web_app::WebAppProvider::Get(profile_);
if (!provider) {
std::move(callback).Run({});
return;
@@ -52,22 +66,75 @@ void WebAppInternalsPageHandlerImpl::GetWebApps(GetWebAppsCallback callback) {
std::vector<mojom::web_app_internals::WebAppPtr> result;
for (const web_app::WebApp& web_app : registrar->GetAppsIncludingStubs()) {
- mojom::web_app_internals::WebAppPtr info(
- mojom::web_app_internals::WebApp::New());
+ auto info = mojom::web_app_internals::WebApp::New();
info->name = web_app.name();
info->id = web_app.app_id();
- std::stringstream ss;
- ss << web_app;
- info->debug_info = ss.str();
+ info->debug_info = ConvertToString(web_app);
result.push_back(std::move(info));
}
std::move(callback).Run(std::move(result));
}
+void WebAppInternalsPageHandlerImpl::GetPreinstalledWebAppDebugInfo(
+ GetPreinstalledWebAppDebugInfoCallback callback) {
+ auto* provider = web_app::WebAppProvider::Get(profile_);
+ if (!provider) {
+ std::move(callback).Run({});
+ return;
+ }
+
+ const web_app::ExternalWebAppManager::DebugInfo* debug_info =
+ provider->external_web_app_manager().debug_info();
+ if (!debug_info) {
+ std::move(callback).Run({});
+ return;
+ }
+
+ auto info = mojom::web_app_internals::PreinstalledWebAppDebugInfo::New();
+
+ info->is_start_up_task_complete = debug_info->is_start_up_task_complete;
+
+ info->parse_errors = debug_info->parse_errors;
+
+ for (const web_app::ExternalInstallOptions& config :
+ debug_info->enabled_configs) {
+ info->enabled_configs.push_back(ConvertToString(config));
+ }
+
+ for (const std::pair<web_app::ExternalInstallOptions, std::string>&
+ disabled_config : debug_info->disabled_configs) {
+ auto disabled_config_info = mojom::web_app_internals::DisabledConfig::New();
+ disabled_config_info->config = ConvertToString(disabled_config.first);
+ disabled_config_info->reason = disabled_config.second;
+ info->disabled_configs.push_back(std::move(disabled_config_info));
+ }
+
+ for (std::pair<const GURL&, const web_app::PendingAppManager::InstallResult&>
+ install_result : debug_info->install_results) {
+ auto install_result_info = mojom::web_app_internals::InstallResult::New();
+ install_result_info->install_url = install_result.first.spec();
+ install_result_info->install_result_code =
+ ConvertToString(install_result.second.code);
+ install_result_info->did_uninstall_and_replace =
+ install_result.second.did_uninstall_and_replace;
+ info->install_results.push_back(std::move(install_result_info));
+ }
+
+ for (std::pair<const GURL&, const bool&> uninstall_result :
+ debug_info->uninstall_results) {
+ auto uninstall_result_info =
+ mojom::web_app_internals::UninstallResult::New();
+ uninstall_result_info->install_url = uninstall_result.first.spec();
+ uninstall_result_info->is_success = uninstall_result.second;
+ info->uninstall_results.push_back(std::move(uninstall_result_info));
+ }
+
+ std::move(callback).Run(std::move(info));
+}
+
void WebAppInternalsPageHandlerImpl::GetExternallyInstalledWebAppPrefs(
GetExternallyInstalledWebAppPrefsCallback callback) {
- std::stringstream ss;
- ss << *profile_->GetPrefs()->GetDictionary(prefs::kWebAppsExtensionIDs);
- std::move(callback).Run(ss.str());
+ std::move(callback).Run(ConvertToString(
+ *profile_->GetPrefs()->GetDictionary(prefs::kWebAppsExtensionIDs)));
}
diff --git a/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.h b/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.h
index ac2d034f03d..b962b6f3fa1 100644
--- a/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.h
+++ b/chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.h
@@ -29,6 +29,8 @@ class WebAppInternalsPageHandlerImpl
// mojom::web_app_internals::WebAppInternalsPageHandler:
void IsBmoEnabled(IsBmoEnabledCallback callback) override;
void GetWebApps(GetWebAppsCallback callback) override;
+ void GetPreinstalledWebAppDebugInfo(
+ GetPreinstalledWebAppDebugInfoCallback callback) override;
void GetExternallyInstalledWebAppPrefs(
GetExternallyInstalledWebAppPrefsCallback callback) override;
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/BUILD.gn b/chromium/chrome/browser/ui/webui/interventions_internals/BUILD.gn
deleted file mode 100644
index cf7280f55a1..00000000000
--- a/chromium/chrome/browser/ui/webui/interventions_internals/BUILD.gn
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2017 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 = [ "interventions_internals.mojom" ]
-
- public_deps = [ "//url/mojom:url_mojom_gurl" ]
-}
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom
deleted file mode 100644
index 4b4101df90b..00000000000
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2017 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 mojom;
-
-import "url/mojom/url.mojom";
-
-struct PreviewsStatus {
- // The human readable description of the status that will be displayed on
- // chrome://interventions-internals.
- string description;
- bool enabled;
-
- // The ID of the html DOM element.
- string htmlId;
-};
-
-struct PreviewsFlag {
- // The human readable description of the flag that will be displayed on
- // chrome://interventions-internals.
- string description;
-
- // The link to this flag in chrome://flags.
- string link;
-
- // The string representation of the flag value.
- string value;
-
- // The ID of the html DOM element.
- string htmlId;
-};
-
-struct MessageLog {
- // The tye of event message (E.g. "Navigation").
- string type;
-
- // The human readable description of the event.
- string description;
-
- // The url that associated with the event.
- url.mojom.Url url;
-
- // The time when the event happened in millisecond since Unix epoch.
- int64 time;
-
- // The ID associated with the request, for grouping log messages in the UI. If
- // |id| is 0, then they will not be grouped, since pageId values start at 1.
- uint64 page_id;
-};
-
-
-interface InterventionsInternalsPageHandler {
- // Returns a map of previews modes statuses.
- GetPreviewsEnabled() => (array<PreviewsStatus> statuses);
-
- // Returns a map of previews related flags details.
- GetPreviewsFlagsDetails() => (array<PreviewsFlag> flags);
-
- // Inject the client side page object.
- SetClientPage(pending_remote<InterventionsInternalsPage> page);
-
- // Change the status of ignoring blocklist to |ignored|. |ignored| will
- // indicate whether the blocklist decision would be ignored when deciding if a
- // preview should be shown or not.
- SetIgnorePreviewsBlocklistDecision(bool ignored);
-};
-
-interface InterventionsInternalsPage {
- // Pushes a new log message to the page. This is called by
- // InterventionsInternalsPageHandler when it receives a new MessageLog, and
- // publishes it on the javscript side.
- LogNewMessage(MessageLog log);
-
- // Notify the page that |host| has been blocklisted at |time|. The method is
- // called by InterventionsInternalsPageHandler when PreviewsUIService receives
- // new blocklisted host.
- OnBlocklistedHost(string host, int64 time);
-
- // Notify the page that user blocklisted status has changed to |blocklisted|.
- // The method is called by InterventionsInternalsPageHandler when user's
- // blocklist status changes.
- OnUserBlocklistedStatusChange(bool blocklisted);
-
- // Notify the page that the blocklist is cleared at |time|. The method is
- // called by InterventionsInternalsPageHandler when PreviewsUIService clears
- // the blocklist.
- OnBlocklistCleared(int64 time);
-
- // Notify the page on the new estimated effective connection type is |type|.
- // Also reports the session's maximum intervention effective connection type
- // |max_intervention_type| for slow pages. This method is called by
- // InterventionsInternalsPageHandler when the estimate network quality
- // changes.
- UpdateEffectiveConnectionType(string type, string max_intervention_type);
-
- // Notify the page on whether the blocklist decision is considered or ignored.
- // This method is called by InterventionsInternalsPageHandler when the status
- // of ignore blocklist decision is updated to |ignored|.
- OnIgnoreBlocklistDecisionStatusChanged(bool ignored);
-};
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc
deleted file mode 100644
index 87c31b3843e..00000000000
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc
+++ /dev/null
@@ -1,316 +0,0 @@
-// Copyright 2017 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/interventions_internals/interventions_internals_page_handler.h"
-
-#include <utility>
-#include <vector>
-
-#include "base/base_switches.h"
-#include "base/command_line.h"
-#include "base/metrics/field_trial_params.h"
-#include "base/time/time.h"
-#include "build/build_config.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/flag_descriptions.h"
-#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom.h"
-#include "chrome/common/chrome_switches.h"
-#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
-#include "components/previews/core/previews_experiments.h"
-#include "components/previews/core/previews_switches.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"
-#include "net/base/features.h"
-#include "net/nqe/network_quality_estimator_params.h"
-#include "services/network/public/cpp/network_quality_tracker.h"
-#include "services/network/public/cpp/network_switches.h"
-
-namespace {
-
-// HTML DOM ID used in the JavaScript code. The IDs are generated here so that
-// the DOM would have sensible name instead of autogenerated IDs.
-const char kPreviewsAllowedHtmlId[] = "previews-allowed-status";
-const char kNoScriptPreviewsHtmlId[] = "noscript-preview-status";
-const char kResourceLoadingHintsHtmlId[] = "resource-loading-hints-status";
-const char kDeferAllScriptPreviewsHtmlId[] = "defer-all-script-preview-status";
-
-// Descriptions for previews.
-const char kPreviewsAllowedDescription[] = "Previews Allowed";
-const char kNoScriptDescription[] = "NoScript Previews";
-const char kResourceLoadingHintsDescription[] = "ResourceLoadingHints Previews";
-const char kDeferAllScriptPreviewsDescription[] = "DeferAllScript Previews";
-
-// Flag feature name.
-const char kPreviewsAllowedFeatureName[] = "Previews";
-const char kNoScriptFeatureName[] = "NoScriptPreviews";
-const char kResourceLoadingHintsFeatureName[] = "ResourceLoadingHints";
-const char kDeferAllScriptFeatureName[] = "DeferAllScript";
-
-// HTML DOM ID used in the JavaScript code. The IDs are generated here so that
-// the DOM would have sensible name instead of autogenerated IDs.
-const char kPreviewsAllowedFlagHtmlId[] = "previews-flag";
-const char kResourceLoadingHintsFlagHtmlId[] = "resource-loading-hints-flag";
-const char kDeferAllScriptFlagHtmlId[] = "defer-all-script-flag";
-const char kNoScriptFlagHtmlId[] = "noscript-flag";
-const char kEctFlagHtmlId[] = "ect-flag";
-const char kIgnorePreviewsBlocklistFlagHtmlId[] = "ignore-previews-blocklist";
-const char kDataSaverAltConfigHtmlId[] =
- "data-reduction-proxy-server-experiment";
-
-// Links to flags in chrome://flags.
-// TODO(thanhdle): Refactor into vector of structs. crbug.com/787010.
-const char kPreviewsAllowedFlagLink[] = "chrome://flags/#allow-previews";
-const char kResourceLoadingHintsFlagLink[] =
- "chrome://flags/#enable-resource-loading-hints";
-const char kDeferAllScriptFlagLink[] =
- "chrome://flags/#enable-defer-all-script";
-const char kNoScriptFlagLink[] = "chrome://flags/#enable-noscript-previews";
-const char kEctFlagLink[] = "chrome://flags/#force-effective-connection-type";
-const char kIgnorePreviewsBlocklistLink[] =
- "chrome://flags/#ignore-previews-blocklist";
-const char kDataSaverAltConfigLink[] =
- "chrome://flags/#enable-data-reduction-proxy-server-experiment";
-
-const char kDefaultFlagValue[] = "Default";
-
-// Check if the flag status of the flag is a forced value or not.
-std::string GetFeatureFlagStatus(const std::string& feature_name) {
- std::string enabled_features =
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kEnableFeatures);
- if (enabled_features.find(feature_name) != std::string::npos) {
- return "Enabled";
- }
- std::string disabled_features =
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kDisableFeatures);
- if (disabled_features.find(feature_name) != std::string::npos) {
- return "Disabled";
- }
- return kDefaultFlagValue;
-}
-
-std::string GetNonFlagEctValue() {
- std::map<std::string, std::string> nqe_params;
- base::GetFieldTrialParamsByFeature(net::features::kNetworkQualityEstimator,
- &nqe_params);
- if (nqe_params.find(net::kForceEffectiveConnectionType) != nqe_params.end()) {
- return "Fieldtrial forced " +
- nqe_params[net::kForceEffectiveConnectionType];
- }
- return kDefaultFlagValue;
-}
-
-// Check if the switch flag is enabled or disabled via flag/command-line.
-std::string GetEnabledStateForSwitch(const std::string& switch_name) {
- return base::CommandLine::ForCurrentProcess()->HasSwitch(switch_name)
- ? "Enabled"
- : "Disabled";
-}
-
-} // namespace
-
-InterventionsInternalsPageHandler::InterventionsInternalsPageHandler(
- mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler> receiver,
- previews::PreviewsUIService* previews_ui_service,
- network::NetworkQualityTracker* network_quality_tracker)
- : receiver_(this, std::move(receiver)),
- previews_ui_service_(previews_ui_service),
- network_quality_tracker_(network_quality_tracker),
- current_estimated_ect_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
- logger_ = previews_ui_service_->previews_logger();
- DCHECK(logger_);
-}
-
-InterventionsInternalsPageHandler::~InterventionsInternalsPageHandler() {
- DCHECK(logger_);
- logger_->RemoveObserver(this);
- (network_quality_tracker_ ? network_quality_tracker_
- : g_browser_process->network_quality_tracker())
- ->RemoveEffectiveConnectionTypeObserver(this);
-}
-
-void InterventionsInternalsPageHandler::SetClientPage(
- mojo::PendingRemote<mojom::InterventionsInternalsPage> page) {
- page_.Bind(std::move(page));
- DCHECK(page_);
- logger_->AddAndNotifyObserver(this);
- (network_quality_tracker_ ? network_quality_tracker_
- : g_browser_process->network_quality_tracker())
- ->AddEffectiveConnectionTypeObserver(this);
-}
-
-void InterventionsInternalsPageHandler::OnEffectiveConnectionTypeChanged(
- net::EffectiveConnectionType type) {
- current_estimated_ect_ = type;
- if (!page_) {
- // Don't try to notify the page if |page_| is not ready.
- return;
- }
- std::string ect_name = net::GetNameForEffectiveConnectionType(type);
- std::string max_intervention_ect_name =
- net::GetNameForEffectiveConnectionType(
- previews::params::GetSessionMaxECTThreshold());
- page_->UpdateEffectiveConnectionType(ect_name, max_intervention_ect_name);
-
- // Log change ECT event.
- previews::PreviewsLogger::MessageLog message(
- "ECT Changed" /* event_type */,
- "Effective Connection Type changed to " + ect_name, GURL(""),
- base::Time::Now(), 0 /* page_id */);
- OnNewMessageLogAdded(message);
-}
-
-void InterventionsInternalsPageHandler::OnNewMessageLogAdded(
- const previews::PreviewsLogger::MessageLog& message) {
- mojom::MessageLogPtr mojo_message_ptr(mojom::MessageLog::New());
-
- mojo_message_ptr->type = message.event_type;
- mojo_message_ptr->description = message.event_description;
- mojo_message_ptr->url = message.url;
- mojo_message_ptr->time = message.time.ToJavaTime();
- mojo_message_ptr->page_id = message.page_id;
-
- page_->LogNewMessage(std::move(mojo_message_ptr));
-}
-
-void InterventionsInternalsPageHandler::SetIgnorePreviewsBlocklistDecision(
- bool ignored) {
- previews_ui_service_->SetIgnorePreviewsBlocklistDecision(ignored);
-}
-
-void InterventionsInternalsPageHandler::OnLastObserverRemove() {
- // Reset the status of ignoring PreviewsBlockList decisions to default value.
- previews_ui_service_->SetIgnorePreviewsBlocklistDecision(
- previews::switches::ShouldIgnorePreviewsBlocklist());
-}
-
-void InterventionsInternalsPageHandler::OnIgnoreBlocklistDecisionStatusChanged(
- bool ignored) {
- page_->OnIgnoreBlocklistDecisionStatusChanged(ignored);
-}
-
-void InterventionsInternalsPageHandler::OnNewBlocklistedHost(
- const std::string& host,
- base::Time time) {
- page_->OnBlocklistedHost(host, time.ToJavaTime());
-}
-
-void InterventionsInternalsPageHandler::OnUserBlocklistedStatusChange(
- bool blocklisted) {
- page_->OnUserBlocklistedStatusChange(blocklisted);
-}
-
-void InterventionsInternalsPageHandler::OnBlocklistCleared(base::Time time) {
- page_->OnBlocklistCleared(time.ToJavaTime());
-}
-
-void InterventionsInternalsPageHandler::GetPreviewsEnabled(
- GetPreviewsEnabledCallback callback) {
- std::vector<mojom::PreviewsStatusPtr> statuses;
-
- auto previews_allowed_status = mojom::PreviewsStatus::New();
- previews_allowed_status->description = kPreviewsAllowedDescription;
- previews_allowed_status->enabled = previews::params::ArePreviewsAllowed();
- previews_allowed_status->htmlId = kPreviewsAllowedHtmlId;
- statuses.push_back(std::move(previews_allowed_status));
-
- auto resource_loading_hints_status = mojom::PreviewsStatus::New();
- resource_loading_hints_status->description = kResourceLoadingHintsDescription;
- resource_loading_hints_status->enabled =
- previews::params::IsResourceLoadingHintsEnabled();
- resource_loading_hints_status->htmlId = kResourceLoadingHintsHtmlId;
- statuses.push_back(std::move(resource_loading_hints_status));
-
- auto defer_all_script_preview_status = mojom::PreviewsStatus::New();
- defer_all_script_preview_status->description =
- kDeferAllScriptPreviewsDescription;
- defer_all_script_preview_status->enabled =
- previews::params::IsDeferAllScriptPreviewsEnabled();
- defer_all_script_preview_status->htmlId = kDeferAllScriptPreviewsHtmlId;
- statuses.push_back(std::move(defer_all_script_preview_status));
-
- auto noscript_status = mojom::PreviewsStatus::New();
- noscript_status->description = kNoScriptDescription;
- noscript_status->enabled = previews::params::IsNoScriptPreviewsEnabled();
- noscript_status->htmlId = kNoScriptPreviewsHtmlId;
- statuses.push_back(std::move(noscript_status));
-
- std::move(callback).Run(std::move(statuses));
-}
-
-void InterventionsInternalsPageHandler::GetPreviewsFlagsDetails(
- GetPreviewsFlagsDetailsCallback callback) {
- std::vector<mojom::PreviewsFlagPtr> flags;
-
- auto previews_allowed_status = mojom::PreviewsFlag::New();
- previews_allowed_status->description =
- flag_descriptions::kPreviewsAllowedName;
- previews_allowed_status->link = kPreviewsAllowedFlagLink;
- previews_allowed_status->value =
- GetFeatureFlagStatus(kPreviewsAllowedFeatureName);
- previews_allowed_status->htmlId = kPreviewsAllowedFlagHtmlId;
- flags.push_back(std::move(previews_allowed_status));
-
- auto resource_loading_hints_status = mojom::PreviewsFlag::New();
- resource_loading_hints_status->description =
- flag_descriptions::kEnableResourceLoadingHintsName;
- resource_loading_hints_status->link = kResourceLoadingHintsFlagLink;
- resource_loading_hints_status->value =
- GetFeatureFlagStatus(kResourceLoadingHintsFeatureName);
- resource_loading_hints_status->htmlId = kResourceLoadingHintsFlagHtmlId;
- flags.push_back(std::move(resource_loading_hints_status));
-
- auto defer_all_script_status = mojom::PreviewsFlag::New();
- defer_all_script_status->description =
- flag_descriptions::kEnableDeferAllScriptName;
- defer_all_script_status->link = kDeferAllScriptFlagLink;
- defer_all_script_status->value =
- GetFeatureFlagStatus(kDeferAllScriptFeatureName);
- defer_all_script_status->htmlId = kDeferAllScriptFlagHtmlId;
- flags.push_back(std::move(defer_all_script_status));
-
- auto noscript_status = mojom::PreviewsFlag::New();
- noscript_status->description = flag_descriptions::kEnableNoScriptPreviewsName;
- noscript_status->link = kNoScriptFlagLink;
- noscript_status->value = GetFeatureFlagStatus(kNoScriptFeatureName);
- noscript_status->htmlId = kNoScriptFlagHtmlId;
- flags.push_back(std::move(noscript_status));
-
- auto ect_status = mojom::PreviewsFlag::New();
- ect_status->description =
- flag_descriptions::kForceEffectiveConnectionTypeName;
- ect_status->link = kEctFlagLink;
- std::string ect_value =
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- network::switches::kForceEffectiveConnectionType);
- ect_status->value = ect_value.empty() ? GetNonFlagEctValue() : ect_value;
- ect_status->htmlId = kEctFlagHtmlId;
- flags.push_back(std::move(ect_status));
-
- auto ignore_previews_blocklist = mojom::PreviewsFlag::New();
- ignore_previews_blocklist->description =
- flag_descriptions::kIgnorePreviewsBlocklistName;
- ignore_previews_blocklist->link = kIgnorePreviewsBlocklistLink;
- ignore_previews_blocklist->value =
- GetEnabledStateForSwitch(previews::switches::kIgnorePreviewsBlocklist);
- ignore_previews_blocklist->htmlId = kIgnorePreviewsBlocklistFlagHtmlId;
- flags.push_back(std::move(ignore_previews_blocklist));
-
- auto alt_config_status = mojom::PreviewsFlag::New();
- alt_config_status->description =
- flag_descriptions::kEnableDataReductionProxyServerExperimentDescription;
- alt_config_status->link = kDataSaverAltConfigLink;
- alt_config_status->value =
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- data_reduction_proxy::switches::kDataReductionProxyExperiment);
- if (alt_config_status->value.empty())
- alt_config_status->value = kDefaultFlagValue;
- alt_config_status->htmlId = kDataSaverAltConfigHtmlId;
- flags.push_back(std::move(alt_config_status));
-
- std::move(callback).Run(std::move(flags));
-}
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h
deleted file mode 100644
index c47656ccd0e..00000000000
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2017 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_INTERVENTIONS_INTERNALS_INTERVENTIONS_INTERNALS_PAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_INTERVENTIONS_INTERNALS_INTERVENTIONS_INTERNALS_PAGE_HANDLER_H_
-
-#include <string>
-
-#include "base/macros.h"
-#include "base/time/time.h"
-#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom.h"
-#include "components/previews/content/previews_ui_service.h"
-#include "components/previews/core/previews_logger.h"
-#include "components/previews/core/previews_logger_observer.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"
-#include "net/nqe/effective_connection_type.h"
-#include "services/network/public/cpp/network_quality_tracker.h"
-
-class InterventionsInternalsPageHandler
- : public previews::PreviewsLoggerObserver,
- public network::NetworkQualityTracker::EffectiveConnectionTypeObserver,
- public mojom::InterventionsInternalsPageHandler {
- public:
- InterventionsInternalsPageHandler(
- mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler> receiver,
- previews::PreviewsUIService* previews_ui_service,
- network::NetworkQualityTracker* network_quality_tracker);
- ~InterventionsInternalsPageHandler() override;
-
- // mojom::InterventionsInternalsPageHandler:
- void GetPreviewsEnabled(GetPreviewsEnabledCallback callback) override;
- void GetPreviewsFlagsDetails(
- GetPreviewsFlagsDetailsCallback callback) override;
- void SetClientPage(
- mojo::PendingRemote<mojom::InterventionsInternalsPage> page) override;
- void SetIgnorePreviewsBlocklistDecision(bool ignore) override;
-
- // previews::PreviewsLoggerObserver:
- void OnNewMessageLogAdded(
- const previews::PreviewsLogger::MessageLog& message) override;
- void OnNewBlocklistedHost(const std::string& host, base::Time time) override;
- void OnUserBlocklistedStatusChange(bool blocklisted) override;
- void OnBlocklistCleared(base::Time time) override;
- void OnIgnoreBlocklistDecisionStatusChanged(bool ignored) override;
- void OnLastObserverRemove() override;
-
- private:
- // network::NetworkQualityTracker::EffectiveConnectionTypeObserver:
- void OnEffectiveConnectionTypeChanged(
- net::EffectiveConnectionType type) override;
-
- mojo::Receiver<mojom::InterventionsInternalsPageHandler> receiver_;
-
- // The PreviewsLogger that this handler is listening to, and guaranteed to
- // outlive |this|.
- previews::PreviewsLogger* logger_;
-
- // A pointer to the PreviewsUIService associated with this handler, and
- // guaranteed to outlive |this|.
- previews::PreviewsUIService* previews_ui_service_;
-
- // Passed in during construction. If null, the main browser process tracker
- // will be used instead.
- network::NetworkQualityTracker* network_quality_tracker_;
-
- // The current estimated effective connection type.
- net::EffectiveConnectionType current_estimated_ect_;
-
- // Handle back to the page by which we can pass in new log messages.
- mojo::Remote<mojom::InterventionsInternalsPage> page_;
-
- DISALLOW_COPY_AND_ASSIGN(InterventionsInternalsPageHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_INTERVENTIONS_INTERNALS_INTERVENTIONS_INTERNALS_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc
deleted file mode 100644
index 55255ef8302..00000000000
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc
+++ /dev/null
@@ -1,834 +0,0 @@
-// Copyright 2017 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/interventions_internals/interventions_internals_page_handler.h"
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-#include <utility>
-#include <vector>
-
-#include "base/base_switches.h"
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/macros.h"
-#include "base/metrics/field_trial.h"
-#include "base/metrics/field_trial_params.h"
-#include "base/run_loop.h"
-#include "base/test/scoped_command_line.h"
-#include "base/test/scoped_feature_list.h"
-#include "base/test/task_environment.h"
-#include "base/time/default_clock.h"
-#include "build/build_config.h"
-#include "chrome/browser/flag_descriptions.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/test/base/testing_browser_process.h"
-#include "chrome/test/base/testing_profile.h"
-#include "chrome/test/base/testing_profile_manager.h"
-#include "components/blocklist/opt_out_blocklist/opt_out_blocklist_data.h"
-#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
-#include "components/previews/content/previews_decider_impl.h"
-#include "components/previews/content/previews_ui_service.h"
-#include "components/previews/core/previews_features.h"
-#include "components/previews/core/previews_logger.h"
-#include "components/previews/core/previews_logger_observer.h"
-#include "components/previews/core/previews_switches.h"
-#include "content/public/test/browser_task_environment.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 "net/base/features.h"
-#include "net/nqe/effective_connection_type.h"
-#include "net/nqe/network_quality_estimator_params.h"
-#include "services/network/public/cpp/network_switches.h"
-#include "services/network/test/test_network_quality_tracker.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-// The HTML DOM ID used in Javascript.
-constexpr char kPreviewsAllowedHtmlId[] = "previews-allowed-status";
-constexpr char kResourceLoadingHintsHtmlId[] = "resource-loading-hints-status";
-constexpr char kDeferAllScriptPreviewsHtmlId[] =
- "defer-all-script-preview-status";
-constexpr char kNoScriptPreviewsHtmlId[] = "noscript-preview-status";
-
-// Descriptions for previews.
-constexpr char kPreviewsAllowedDescription[] = "Previews Allowed";
-constexpr char kResourceLoadingHintsDescription[] =
- "ResourceLoadingHints Previews";
-constexpr char kDeferAllScriptPreviewsDescription[] = "DeferAllScript Previews";
-constexpr char kNoScriptDescription[] = "NoScript Previews";
-
-// The HTML DOM ID used in Javascript.
-constexpr char kResourceLoadingHintsFlagHtmlId[] =
- "resource-loading-hints-flag";
-constexpr char kDeferAllScriptFlagHtmlId[] = "defer-all-script-flag";
-constexpr char kNoScriptFlagHtmlId[] = "noscript-flag";
-constexpr char kEctFlagHtmlId[] = "ect-flag";
-constexpr char kIgnorePreviewsBlocklistFlagHtmlId[] =
- "ignore-previews-blocklist";
-constexpr char kDataSaverAltConfigHtmlId[] =
- "data-reduction-proxy-server-experiment";
-
-// Links to flags in chrome://flags.
-constexpr char kResourceLoadingHintsFlagLink[] =
- "chrome://flags/#enable-resource-loading-hints";
-constexpr char kDeferAllScriptFlagLink[] =
- "chrome://flags/#enable-defer-all-script";
-constexpr char kNoScriptFlagLink[] = "chrome://flags/#enable-noscript-previews";
-constexpr char kEctFlagLink[] =
- "chrome://flags/#force-effective-connection-type";
-constexpr char kIgnorePreviewsBlocklistLink[] =
- "chrome://flags/#ignore-previews-blocklist";
-constexpr char kDataSaverAltConfigLink[] =
- "chrome://flags/#enable-data-reduction-proxy-server-experiment";
-
-// Flag features names.
-constexpr char kResourceLoadingHintsFeatureName[] = "ResourceLoadingHints";
-constexpr char kDeferAllScriptFeatureName[] = "DeferAllScriptPreviews";
-constexpr char kNoScriptFeatureName[] = "NoScriptPreviews";
-
-constexpr char kDefaultFlagValue[] = "Default";
-constexpr char kEnabledFlagValue[] = "Enabled";
-constexpr char kDisabledFlagValue[] = "Disabled";
-
-// The map that would be passed to the callback in GetPreviewsEnabledCallback.
-std::unordered_map<std::string, mojom::PreviewsStatusPtr> passed_in_modes;
-
-// The map that would be passed to the callback in
-// GetPreviewsFlagsDetailsCallback.
-std::unordered_map<std::string, mojom::PreviewsFlagPtr> passed_in_flags;
-
-// Mocked call back method to test GetPreviewsEnabledCallback.
-void MockGetPreviewsEnabledCallback(
- std::vector<mojom::PreviewsStatusPtr> params) {
- passed_in_modes.clear();
- for (size_t i = 0; i < params.size(); i++) {
- passed_in_modes[params[i]->htmlId] = std::move(params[i]);
- }
-}
-
-// Mocked call back method to test GetPreviewsFlagsDetailsCallback.
-void MockGetPreviewsFlagsCallback(std::vector<mojom::PreviewsFlagPtr> params) {
- passed_in_flags.clear();
- for (size_t i = 0; i < params.size(); i++) {
- passed_in_flags[params[i]->htmlId] = std::move(params[i]);
- }
-}
-
-// Dummy method for creating TestPreviewsUIService.
-bool MockedPreviewsIsEnabled(previews::PreviewsType type) {
- return true;
-}
-
-// Mock class that would be pass into the InterventionsInternalsPageHandler by
-// calling its SetClientPage method. Used to test that the PageHandler
-// actually invokes the page's LogNewMessage method with the correct message.
-class TestInterventionsInternalsPage
- : public mojom::InterventionsInternalsPage {
- public:
- TestInterventionsInternalsPage(
- mojo::PendingReceiver<mojom::InterventionsInternalsPage> receiver)
- : receiver_(this, std::move(receiver)), blocklist_ignored_(false) {}
-
- ~TestInterventionsInternalsPage() override = default;
-
- // mojom::InterventionsInternalsPage:
- void LogNewMessage(mojom::MessageLogPtr message) override {
- message_ = std::make_unique<mojom::MessageLogPtr>(std::move(message));
- }
- void OnBlocklistedHost(const std::string& host, int64_t time) override {
- host_blocklisted_ = host;
- host_blocklisted_time_ = time;
- }
- void OnUserBlocklistedStatusChange(bool blocklisted) override {
- user_blocklisted_ = blocklisted;
- }
- void OnBlocklistCleared(int64_t time) override {
- blocklist_cleared_time_ = time;
- }
- void UpdateEffectiveConnectionType(
- const std::string& type,
- const std::string& max_intervention_type) override {
- // Ignore.
- // TODO(thanhdle): Add integration test to test behavior of the pipeline end
- // to end. crbug.com/777936
- }
- void OnIgnoreBlocklistDecisionStatusChanged(bool ignored) override {
- blocklist_ignored_ = ignored;
- }
-
- // Expose passed in message in LogNewMessage for testing.
- mojom::MessageLogPtr* message() const { return message_.get(); }
-
- // Expose passed in blocklist events info for testing.
- std::string host_blocklisted() const { return host_blocklisted_; }
- int64_t host_blocklisted_time() const { return host_blocklisted_time_; }
- bool user_blocklisted() const { return user_blocklisted_; }
- int64_t blocklist_cleared_time() const { return blocklist_cleared_time_; }
-
- // Expose the passed in blocklist ignore status for testing.
- bool blocklist_ignored() const { return blocklist_ignored_; }
-
- private:
- mojo::Receiver<mojom::InterventionsInternalsPage> receiver_;
-
- // The MessageLogPtr passed in LogNewMessage method.
- std::unique_ptr<mojom::MessageLogPtr> message_;
-
- // Received blocklist events info.
- std::string host_blocklisted_;
- int64_t host_blocklisted_time_;
- int64_t user_blocklisted_;
- int64_t blocklist_cleared_time_;
-
- // Whether to ignore previews blocklist decisions.
- bool blocklist_ignored_;
-};
-
-// Mock class to test interaction between the PageHandler and the
-// PreviewsLogger.
-class TestPreviewsLogger : public previews::PreviewsLogger {
- public:
- TestPreviewsLogger() : PreviewsLogger(), remove_is_called_(false) {}
-
- // PreviewsLogger:
- void RemoveObserver(previews::PreviewsLoggerObserver* obs) override {
- remove_is_called_ = true;
- }
-
- bool RemovedObserverIsCalled() const { return remove_is_called_; }
-
- private:
- bool remove_is_called_;
-};
-
-// A dummy class to setup PreviewsUIService.
-class TestPreviewsDeciderImpl : public previews::PreviewsDeciderImpl {
- public:
- TestPreviewsDeciderImpl()
- : PreviewsDeciderImpl(base::DefaultClock::GetInstance()) {}
-
- // previews::PreviewsDeciderImpl:
- void Initialize(
- previews::PreviewsUIService* previews_ui_service,
- std::unique_ptr<blocklist::OptOutStore> previews_opt_out_store,
- std::unique_ptr<previews::PreviewsOptimizationGuide> previews_opt_guide,
- const previews::PreviewsIsEnabledCallback& is_enabled_callback,
- blocklist::BlocklistData::AllowedTypesAndVersions allowed_previews)
- override {}
-};
-
-// Mocked TestPreviewsService for testing InterventionsInternalsPageHandler.
-class TestPreviewsUIService : public previews::PreviewsUIService {
- public:
- TestPreviewsUIService(
- std::unique_ptr<previews::PreviewsDeciderImpl> previews_decider_impl,
- std::unique_ptr<previews::PreviewsLogger> logger,
- network::TestNetworkQualityTracker* test_network_quality_tracker)
- : previews::PreviewsUIService(
- std::move(previews_decider_impl),
- nullptr, /* previews_opt_out_store */
- nullptr, /* previews_opt_guide */
- base::BindRepeating(&MockedPreviewsIsEnabled),
- std::move(logger),
- blocklist::BlocklistData::AllowedTypesAndVersions(),
- test_network_quality_tracker),
- blocklist_ignored_(false) {}
- ~TestPreviewsUIService() override = default;
-
- // previews::PreviewsUIService:
- void SetIgnorePreviewsBlocklistDecision(bool ignored) override {
- blocklist_ignored_ = ignored;
- }
-
- // Exposed blocklist ignored state.
- bool blocklist_ignored() const { return blocklist_ignored_; }
-
- private:
- // Whether the blocklist decisions are ignored or not.
- bool blocklist_ignored_;
-};
-
-class InterventionsInternalsPageHandlerTest : public testing::Test {
- public:
- InterventionsInternalsPageHandlerTest()
- : profile_manager_(TestingBrowserProcess::GetGlobal()) {}
-
- ~InterventionsInternalsPageHandlerTest() override {}
-
- void SetUp() override {
- std::unique_ptr<TestPreviewsLogger> logger =
- std::make_unique<TestPreviewsLogger>();
- logger_ = logger.get();
-
- previews_ui_service_ = std::make_unique<TestPreviewsUIService>(
- std::make_unique<TestPreviewsDeciderImpl>(), std::move(logger),
- &test_network_quality_tracker_);
-
- ASSERT_TRUE(profile_manager_.SetUp());
-
- mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler>
- handler_receiver =
- mojo::PendingRemote<mojom::InterventionsInternalsPageHandler>()
- .InitWithNewPipeAndPassReceiver();
- page_handler_ = std::make_unique<InterventionsInternalsPageHandler>(
- std::move(handler_receiver), previews_ui_service_.get(),
- &test_network_quality_tracker_);
-
- mojo::PendingRemote<mojom::InterventionsInternalsPage> page;
- mojo::PendingReceiver<mojom::InterventionsInternalsPage> page_receiver =
- page.InitWithNewPipeAndPassReceiver();
- page_ = std::make_unique<TestInterventionsInternalsPage>(
- std::move(page_receiver));
-
- page_handler_->SetClientPage(std::move(page));
-
- scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
- }
-
- void TearDown() override {
- profile_manager_.DeleteAllTestingProfiles();
- page_handler_.reset();
- page_.reset();
- }
-
- content::BrowserTaskEnvironment task_environment_;
-
- protected:
- TestingProfileManager profile_manager_;
-
- TestPreviewsLogger* logger_;
- network::TestNetworkQualityTracker test_network_quality_tracker_;
- std::unique_ptr<TestPreviewsUIService> previews_ui_service_;
-
- // InterventionsInternalPageHandler's variables.
- std::unique_ptr<InterventionsInternalsPageHandler> page_handler_;
-
- // InterventionsInternalPage's variables.
- std::unique_ptr<TestInterventionsInternalsPage> page_;
-
- std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_;
-};
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetPreviewsEnabledCount) {
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
-
- constexpr size_t expected = 4;
- EXPECT_EQ(expected, passed_in_modes.size());
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, PreviewsAllowedDisabled) {
- // Init with kPreviews disabled.
- scoped_feature_list_->InitWithFeatures({}, {previews::features::kPreviews});
-
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
- auto previews_allowed = passed_in_modes.find(kPreviewsAllowedHtmlId);
- ASSERT_NE(passed_in_modes.end(), previews_allowed);
- EXPECT_EQ(kPreviewsAllowedDescription, previews_allowed->second->description);
- EXPECT_FALSE(previews_allowed->second->enabled);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, PreviewsAllowedEnabled) {
- // Init with kPreviews enabled.
- scoped_feature_list_->InitWithFeatures({previews::features::kPreviews}, {});
-
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
- auto previews_allowed = passed_in_modes.find(kPreviewsAllowedHtmlId);
- ASSERT_NE(passed_in_modes.end(), previews_allowed);
- EXPECT_EQ(kPreviewsAllowedDescription, previews_allowed->second->description);
- EXPECT_TRUE(previews_allowed->second->enabled);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, NoScriptDisabled) {
- // Init with kNoScript disabled.
- scoped_feature_list_->InitWithFeatures(
- {}, {previews::features::kNoScriptPreviews});
-
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
- auto noscript = passed_in_modes.find(kNoScriptPreviewsHtmlId);
- ASSERT_NE(passed_in_modes.end(), noscript);
- EXPECT_EQ(kNoScriptDescription, noscript->second->description);
- EXPECT_FALSE(noscript->second->enabled);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, NoScriptEnabled) {
- // Init with kNoScript enabled.
- scoped_feature_list_->InitWithFeatures(
- {previews::features::kNoScriptPreviews}, {});
-
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
- auto noscript = passed_in_modes.find(kNoScriptPreviewsHtmlId);
- ASSERT_NE(passed_in_modes.end(), noscript);
- EXPECT_EQ(kNoScriptDescription, noscript->second->description);
- EXPECT_TRUE(noscript->second->enabled);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, ResourceLoadingHintsDisabled) {
- // Init with kResourceLoadingHints disabled.
- scoped_feature_list_->InitWithFeatures(
- {}, {previews::features::kResourceLoadingHints});
-
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
- auto resource_loading_hints =
- passed_in_modes.find(kResourceLoadingHintsHtmlId);
- ASSERT_NE(passed_in_modes.end(), resource_loading_hints);
- EXPECT_EQ(kResourceLoadingHintsDescription,
- resource_loading_hints->second->description);
- EXPECT_FALSE(resource_loading_hints->second->enabled);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, ResourceLoadingHintsEnabled) {
- // Init with kResourceLoadingHints enabled.
- scoped_feature_list_->InitWithFeatures(
- {previews::features::kResourceLoadingHints}, {});
-
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
- auto resource_loading_hints =
- passed_in_modes.find(kResourceLoadingHintsHtmlId);
- ASSERT_NE(passed_in_modes.end(), resource_loading_hints);
- EXPECT_EQ(kResourceLoadingHintsDescription,
- resource_loading_hints->second->description);
- EXPECT_TRUE(resource_loading_hints->second->enabled);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, DeferAllScriptPreviewsDisabled) {
- // Init with kDeferAllScriptPreviews disabled.
- scoped_feature_list_->InitWithFeatures(
- {}, {previews::features::kDeferAllScriptPreviews});
-
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
- auto defer_all_script = passed_in_modes.find(kDeferAllScriptPreviewsHtmlId);
- ASSERT_NE(passed_in_modes.end(), defer_all_script);
- EXPECT_EQ(kDeferAllScriptPreviewsDescription,
- defer_all_script->second->description);
- EXPECT_FALSE(defer_all_script->second->enabled);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, DeferAllScriptPreviewsEnabled) {
- // Init with kDeferAllScriptPreviews enabled.
- scoped_feature_list_->InitWithFeatures(
- {previews::features::kDeferAllScriptPreviews}, {});
-
- page_handler_->GetPreviewsEnabled(
- base::BindOnce(&MockGetPreviewsEnabledCallback));
- auto defer_all_script = passed_in_modes.find(kDeferAllScriptPreviewsHtmlId);
- ASSERT_NE(passed_in_modes.end(), defer_all_script);
- EXPECT_EQ(kDeferAllScriptPreviewsDescription,
- defer_all_script->second->description);
- EXPECT_TRUE(defer_all_script->second->enabled);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsCount) {
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
-
- constexpr size_t expected = 7;
- EXPECT_EQ(expected, passed_in_flags.size());
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsEctDefaultValue) {
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto ect_flag = passed_in_flags.find(kEctFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), ect_flag);
- EXPECT_EQ(flag_descriptions::kForceEffectiveConnectionTypeName,
- ect_flag->second->description);
- EXPECT_EQ(kDefaultFlagValue, ect_flag->second->value);
- EXPECT_EQ(kEctFlagLink, ect_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsForceEctValue) {
- std::string expected_ects[] = {
- net::kEffectiveConnectionTypeUnknown,
- net::kEffectiveConnectionTypeOffline,
- net::kEffectiveConnectionTypeSlow2G,
- net::kEffectiveConnectionType3G,
- net::kEffectiveConnectionType4G,
- };
-
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- for (auto expected_ect : expected_ects) {
- command_line->AppendSwitchASCII(
- network::switches::kForceEffectiveConnectionType, expected_ect);
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto ect_flag = passed_in_flags.find(kEctFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), ect_flag);
- EXPECT_EQ(flag_descriptions::kForceEffectiveConnectionTypeName,
- ect_flag->second->description);
- EXPECT_EQ(expected_ect, ect_flag->second->value);
- EXPECT_EQ(kEctFlagLink, ect_flag->second->link);
- }
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsEctForceFieldtrialValue) {
- const std::string trial_name = "NetworkQualityEstimator";
- const std::string group_name = "Enabled";
- const std::string expected_ect = "Slow-2G";
-
- std::map<std::string, std::string> params;
- params[net::kForceEffectiveConnectionType] = expected_ect;
- scoped_feature_list_->InitAndEnableFeatureWithParameters(
- net::features::kNetworkQualityEstimator, params);
-
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
-
- auto ect_flag = passed_in_flags.find(kEctFlagHtmlId);
- ASSERT_NE(passed_in_flags.end(), ect_flag);
- EXPECT_EQ(flag_descriptions::kForceEffectiveConnectionTypeName,
- ect_flag->second->description);
- EXPECT_EQ("Fieldtrial forced " + expected_ect, ect_flag->second->value);
- EXPECT_EQ(kEctFlagLink, ect_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- GetFlagsIgnorePreviewsBlocklistDisabledValue) {
- // Disabled by default.
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto ignore_previews_blocklist =
- passed_in_flags.find(kIgnorePreviewsBlocklistFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), ignore_previews_blocklist);
- EXPECT_EQ(flag_descriptions::kIgnorePreviewsBlocklistName,
- ignore_previews_blocklist->second->description);
- EXPECT_EQ(kDisabledFlagValue, ignore_previews_blocklist->second->value);
- EXPECT_EQ(kIgnorePreviewsBlocklistLink,
- ignore_previews_blocklist->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsNoScriptDisabledValue) {
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto ignore_previews_blocklist =
- passed_in_flags.find(kIgnorePreviewsBlocklistFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), ignore_previews_blocklist);
- EXPECT_EQ(flag_descriptions::kIgnorePreviewsBlocklistName,
- ignore_previews_blocklist->second->description);
- EXPECT_EQ(kDisabledFlagValue, ignore_previews_blocklist->second->value);
- EXPECT_EQ(kIgnorePreviewsBlocklistLink,
- ignore_previews_blocklist->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsNoScriptDefaultValue) {
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto noscript_flag = passed_in_flags.find(kNoScriptFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), noscript_flag);
- EXPECT_EQ(flag_descriptions::kEnableNoScriptPreviewsName,
- noscript_flag->second->description);
- EXPECT_EQ(kDefaultFlagValue, noscript_flag->second->value);
- EXPECT_EQ(kNoScriptFlagLink, noscript_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsNoScriptEnabled) {
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- command_line->AppendSwitchASCII(switches::kEnableFeatures,
- kNoScriptFeatureName);
-
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto noscript_flag = passed_in_flags.find(kNoScriptFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), noscript_flag);
- EXPECT_EQ(flag_descriptions::kEnableNoScriptPreviewsName,
- noscript_flag->second->description);
- EXPECT_EQ(kEnabledFlagValue, noscript_flag->second->value);
- EXPECT_EQ(kNoScriptFlagLink, noscript_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsNoScriptDisabled) {
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- command_line->AppendSwitchASCII(switches::kDisableFeatures,
- kNoScriptFeatureName);
-
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto noscript_flag = passed_in_flags.find(kNoScriptFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), noscript_flag);
- EXPECT_EQ(flag_descriptions::kEnableNoScriptPreviewsName,
- noscript_flag->second->description);
- EXPECT_EQ(kDisabledFlagValue, noscript_flag->second->value);
- EXPECT_EQ(kNoScriptFlagLink, noscript_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- GetFlagsResourceLoadingHintsDefaultValue) {
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto resource_loading_hints_flag =
- passed_in_flags.find(kResourceLoadingHintsFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), resource_loading_hints_flag);
- EXPECT_EQ(flag_descriptions::kEnableResourceLoadingHintsName,
- resource_loading_hints_flag->second->description);
- EXPECT_EQ(kDefaultFlagValue, resource_loading_hints_flag->second->value);
- EXPECT_EQ(kResourceLoadingHintsFlagLink,
- resource_loading_hints_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- GetFlagsResourceLoadingHintsEnabled) {
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- command_line->AppendSwitchASCII(switches::kEnableFeatures,
- kResourceLoadingHintsFeatureName);
-
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto resource_loading_hints_flag =
- passed_in_flags.find(kResourceLoadingHintsFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), resource_loading_hints_flag);
- EXPECT_EQ(flag_descriptions::kEnableResourceLoadingHintsName,
- resource_loading_hints_flag->second->description);
- EXPECT_EQ(kEnabledFlagValue, resource_loading_hints_flag->second->value);
- EXPECT_EQ(kResourceLoadingHintsFlagLink,
- resource_loading_hints_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- GetFlagsResourceLoadingHintsDisabled) {
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- command_line->AppendSwitchASCII(switches::kDisableFeatures,
- kResourceLoadingHintsFeatureName);
-
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto resource_loading_hints_flag =
- passed_in_flags.find(kResourceLoadingHintsFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), resource_loading_hints_flag);
- EXPECT_EQ(flag_descriptions::kEnableResourceLoadingHintsName,
- resource_loading_hints_flag->second->description);
- EXPECT_EQ(kDisabledFlagValue, resource_loading_hints_flag->second->value);
- EXPECT_EQ(kResourceLoadingHintsFlagLink,
- resource_loading_hints_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- GetFlagsDeferAllScriptDefaultValue) {
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto defer_all_script_flag = passed_in_flags.find(kDeferAllScriptFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), defer_all_script_flag);
- EXPECT_EQ(flag_descriptions::kEnableDeferAllScriptName,
- defer_all_script_flag->second->description);
- EXPECT_EQ(kDefaultFlagValue, defer_all_script_flag->second->value);
- EXPECT_EQ(kDeferAllScriptFlagLink, defer_all_script_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsDeferAllScriptEnabled) {
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- command_line->AppendSwitchASCII(switches::kEnableFeatures,
- kDeferAllScriptFeatureName);
-
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto defer_all_script_flag = passed_in_flags.find(kDeferAllScriptFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), defer_all_script_flag);
- EXPECT_EQ(flag_descriptions::kEnableDeferAllScriptName,
- defer_all_script_flag->second->description);
- EXPECT_EQ(kEnabledFlagValue, defer_all_script_flag->second->value);
- EXPECT_EQ(kDeferAllScriptFlagLink, defer_all_script_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsDeferAllScriptDisabled) {
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- command_line->AppendSwitchASCII(switches::kDisableFeatures,
- kDeferAllScriptFeatureName);
-
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto defer_all_script_flag = passed_in_flags.find(kDeferAllScriptFlagHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), defer_all_script_flag);
- EXPECT_EQ(flag_descriptions::kEnableDeferAllScriptName,
- defer_all_script_flag->second->description);
- EXPECT_EQ(kDisabledFlagValue, defer_all_script_flag->second->value);
- EXPECT_EQ(kDeferAllScriptFlagLink, defer_all_script_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsAltConfigCustomValue) {
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- std::string flag_value = "alt-porg";
- command_line->AppendSwitchASCII(
- data_reduction_proxy::switches::kDataReductionProxyExperiment,
- flag_value);
-
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto alt_config_flag = passed_in_flags.find(kDataSaverAltConfigHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), alt_config_flag);
- EXPECT_EQ(
- flag_descriptions::kEnableDataReductionProxyServerExperimentDescription,
- alt_config_flag->second->description);
- EXPECT_EQ(flag_value, alt_config_flag->second->value);
- EXPECT_EQ(kDataSaverAltConfigLink, alt_config_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsAltConfigCustomDefault) {
- page_handler_->GetPreviewsFlagsDetails(
- base::BindOnce(&MockGetPreviewsFlagsCallback));
- auto alt_config_flag = passed_in_flags.find(kDataSaverAltConfigHtmlId);
-
- ASSERT_NE(passed_in_flags.end(), alt_config_flag);
- EXPECT_EQ(
- flag_descriptions::kEnableDataReductionProxyServerExperimentDescription,
- alt_config_flag->second->description);
- EXPECT_EQ(kDefaultFlagValue, alt_config_flag->second->value);
- EXPECT_EQ(kDataSaverAltConfigLink, alt_config_flag->second->link);
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, OnNewMessageLogAddedPostToPage) {
- const previews::PreviewsLogger::MessageLog expected_messages[] = {
- previews::PreviewsLogger::MessageLog(
- "Event_a", "Some description a", GURL("http://www.url_a.com/url_a"),
- base::Time::Now(), 1234UL /* page_id */),
- previews::PreviewsLogger::MessageLog(
- "Event_b", "Some description b", GURL("http://www.url_b.com/url_b"),
- base::Time::Now(), 4321UL /* page_id */),
- previews::PreviewsLogger::MessageLog(
- "Event_c", "Some description c", GURL("http://www.url_c.com/url_c"),
- base::Time::Now(), 6789UL /* page_id */),
- };
-
- for (auto message : expected_messages) {
- page_handler_->OnNewMessageLogAdded(message);
- base::RunLoop().RunUntilIdle();
-
- mojom::MessageLogPtr* actual = page_->message();
- // Discard any messages generated by network quality tracker.
- while ((*actual)->type == "ECT Changed") {
- page_handler_->OnNewMessageLogAdded(message);
- base::RunLoop().RunUntilIdle();
-
- actual = page_->message();
- }
- EXPECT_EQ(message.event_type, (*actual)->type);
- EXPECT_EQ(message.event_description, (*actual)->description);
- EXPECT_EQ(message.url, (*actual)->url);
- int64_t expected_time = message.time.ToJavaTime();
- EXPECT_EQ(expected_time, (*actual)->time);
- EXPECT_EQ(message.page_id, (*actual)->page_id);
- }
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, ObserverIsRemovedWhenDestroyed) {
- EXPECT_FALSE(logger_->RemovedObserverIsCalled());
- page_handler_.reset();
- EXPECT_TRUE(logger_->RemovedObserverIsCalled());
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, OnNewBlocklistedHostPostToPage) {
- const std::string hosts[] = {
- "example_0.com",
- "example_1.com",
- "example_2.com",
- };
-
- for (auto expected_host : hosts) {
- base::Time expected_time = base::Time::Now();
- page_handler_->OnNewBlocklistedHost(expected_host, expected_time);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(expected_host, page_->host_blocklisted());
- EXPECT_EQ(expected_time.ToJavaTime(), page_->host_blocklisted_time());
- }
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, OnUserBlocklistedPostToPage) {
- page_handler_->OnUserBlocklistedStatusChange(true /* blocklisted */);
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(page_->user_blocklisted());
-
- page_handler_->OnUserBlocklistedStatusChange(false /* blocklisted */);
- base::RunLoop().RunUntilIdle();
- EXPECT_FALSE(page_->user_blocklisted());
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest, OnBlocklistClearedPostToPage) {
- base::Time times[] = {
- base::Time::FromJsTime(-413696806000), // Nov 21 1956 20:13:14 UTC
- base::Time::FromJsTime(758620800000), // Jan 15 1994 08:00:00 UTC
- base::Time::FromJsTime(1581696550000), // Feb 14 2020 16:09:10 UTC
- };
- for (auto expected_time : times) {
- page_handler_->OnBlocklistCleared(expected_time);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(expected_time.ToJavaTime(), page_->blocklist_cleared_time());
- }
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- SetIgnorePreviewsBlocklistDecisionCallsUIServiceCorrectly) {
- page_handler_->SetIgnorePreviewsBlocklistDecision(true /* ignored */);
- EXPECT_TRUE(previews_ui_service_->blocklist_ignored());
-
- page_handler_->SetIgnorePreviewsBlocklistDecision(false /* ignored */);
- EXPECT_FALSE(previews_ui_service_->blocklist_ignored());
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- PageUpdateOnBlocklistIgnoredChange) {
- page_handler_->OnIgnoreBlocklistDecisionStatusChanged(true /* ignored */);
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(page_->blocklist_ignored());
-
- page_handler_->OnIgnoreBlocklistDecisionStatusChanged(false /* ignored */);
- base::RunLoop().RunUntilIdle();
- EXPECT_FALSE(page_->blocklist_ignored());
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- IgnoreBlocklistReversedOnLastObserverRemovedCalled) {
- ASSERT_FALSE(previews::switches::ShouldIgnorePreviewsBlocklist());
- page_handler_->OnLastObserverRemove();
- base::RunLoop().RunUntilIdle();
- EXPECT_FALSE(page_->blocklist_ignored());
-}
-
-TEST_F(InterventionsInternalsPageHandlerTest,
- IgnoreBlocklistReversedOnLastObserverRemovedCalledIgnoreViaFlag) {
- base::test::ScopedCommandLine scoped_command_line;
- base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
- command_line->AppendSwitch(previews::switches::kIgnorePreviewsBlocklist);
- ASSERT_TRUE(previews::switches::ShouldIgnorePreviewsBlocklist());
- page_handler_->OnLastObserverRemove();
- base::RunLoop().RunUntilIdle();
- EXPECT_FALSE(page_->blocklist_ignored());
-}
-
-} // namespace
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc
deleted file mode 100644
index b8bdba5f0af..00000000000
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2017 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/interventions_internals/interventions_internals_ui.h"
-
-#include <memory>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "base/bind.h"
-#include "chrome/browser/previews/previews_service.h"
-#include "chrome/browser/previews/previews_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/dev_ui_browser_resources.h"
-#include "components/previews/content/previews_ui_service.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-
-namespace {
-
-content::WebUIDataSource* GetSource() {
- content::WebUIDataSource* source = content::WebUIDataSource::Create(
- chrome::kChromeUIInterventionsInternalsHost);
- source->AddResourcePath("index.js", IDR_INTERVENTIONS_INTERNALS_INDEX_JS);
- source->AddResourcePath(
- "chrome/browser/ui/webui/interventions_internals/"
- "interventions_internals.mojom-lite.js",
- IDR_INTERVENTIONS_INTERNALS_MOJOM_LITE_JS);
- source->SetDefaultResource(IDR_INTERVENTIONS_INTERNALS_INDEX_HTML);
- return source;
-}
-
-content::WebUIDataSource* GetUnsupportedSource() {
- content::WebUIDataSource* source = content::WebUIDataSource::Create(
- chrome::kChromeUIInterventionsInternalsHost);
- source->SetDefaultResource(IDR_INTERVENTIONS_INTERNALS_UNSUPPORTED_PAGE_HTML);
- return source;
-}
-
-} // namespace
-
-InterventionsInternalsUI::InterventionsInternalsUI(content::WebUI* web_ui)
- : ui::MojoWebUIController(web_ui), previews_ui_service_(nullptr) {
- // Set up the chrome://interventions-internals/ source.
- Profile* profile = Profile::FromWebUI(web_ui);
-
- PreviewsService* previews_service =
- PreviewsServiceFactory::GetForProfile(profile);
- if (!previews_service) {
- // In Guest Mode or Incognito Mode.
- content::WebUIDataSource::Add(profile, GetUnsupportedSource());
- return;
- }
- content::WebUIDataSource::Add(profile, GetSource());
- previews_ui_service_ = previews_service->previews_ui_service();
-}
-
-WEB_UI_CONTROLLER_TYPE_IMPL(InterventionsInternalsUI)
-
-InterventionsInternalsUI::~InterventionsInternalsUI() {}
-
-void InterventionsInternalsUI::BindInterface(
- mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler> receiver) {
- DCHECK(previews_ui_service_);
- page_handler_ = std::make_unique<InterventionsInternalsPageHandler>(
- std::move(receiver), previews_ui_service_, nullptr);
-}
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h
deleted file mode 100644
index 9d4bd6fdd19..00000000000
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2017 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_INTERVENTIONS_INTERNALS_INTERVENTIONS_INTERNALS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_INTERVENTIONS_INTERNALS_INTERVENTIONS_INTERNALS_UI_H_
-
-#include "base/macros.h"
-#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom-forward.h"
-#include "chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "ui/webui/mojo_web_ui_controller.h"
-
-namespace previews {
-class PreviewsUIService;
-} // namespace previews
-
-// The WebUI for chrome://interventions-internals.
-class InterventionsInternalsUI : public ui::MojoWebUIController {
- public:
- explicit InterventionsInternalsUI(content::WebUI* web_ui);
- ~InterventionsInternalsUI() override;
-
- // Instantiates implementor of the mojom::InterventionsInternalsPageHandler
- // mojo interface passing the pending receiver that will be internally bound.
- void BindInterface(
- mojo::PendingReceiver<mojom::InterventionsInternalsPageHandler> receiver);
-
- private:
- // The PreviewsUIService associated with this UI.
- previews::PreviewsUIService* previews_ui_service_;
-
- std::unique_ptr<InterventionsInternalsPageHandler> page_handler_;
-
- WEB_UI_CONTROLLER_TYPE_DECL();
-
- DISALLOW_COPY_AND_ASSIGN(InterventionsInternalsUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_INTERVENTIONS_INTERNALS_INTERVENTIONS_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc b/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.cc
index e4843d061d5..5653f0c43e7 100644
--- a/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.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/invalidations_message_handler.h"
+#include "chrome/browser/ui/webui/invalidations/invalidations_message_handler.h"
#include <utility>
@@ -21,7 +21,6 @@ namespace invalidation {
class InvalidationLogger;
} // namespace invalidation
-
namespace {
invalidation::ProfileInvalidationProvider* GetInvalidationProvider(
@@ -34,10 +33,7 @@ invalidation::ProfileInvalidationProvider* GetInvalidationProvider(
InvalidationsMessageHandler::InvalidationsMessageHandler() : logger_(nullptr) {}
-InvalidationsMessageHandler::~InvalidationsMessageHandler() {
- if (logger_)
- logger_->UnregisterObserver(this);
-}
+InvalidationsMessageHandler::~InvalidationsMessageHandler() = default;
void InvalidationsMessageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
@@ -50,12 +46,18 @@ void InvalidationsMessageHandler::RegisterMessages() {
base::Unretained(this)));
}
+void InvalidationsMessageHandler::OnJavascriptDisallowed() {
+ if (logger_)
+ logger_->UnregisterObserver(this);
+}
+
void InvalidationsMessageHandler::UIReady(const base::ListValue* args) {
+ AllowJavascript();
invalidation::ProfileInvalidationProvider* invalidation_provider =
GetInvalidationProvider(Profile::FromWebUI(web_ui()));
if (invalidation_provider) {
- logger_ = invalidation_provider->GetInvalidationService()->
- GetInvalidationLogger();
+ logger_ = invalidation_provider->GetInvalidationService()
+ ->GetInvalidationLogger();
}
if (logger_ && !logger_->IsObserverRegistered(this))
logger_->RegisterObserver(this);
@@ -85,22 +87,20 @@ void InvalidationsMessageHandler::OnRegistrationChange(
++it) {
list_of_handlers.AppendString(*it);
}
- web_ui()->CallJavascriptFunctionUnsafe("chrome.invalidations.updateHandlers",
- list_of_handlers);
+ FireWebUIListener("handlers-updated", list_of_handlers);
}
void InvalidationsMessageHandler::OnStateChange(
- const syncer::InvalidatorState& new_state,
+ const invalidation::InvalidatorState& new_state,
const base::Time& last_changed_timestamp) {
- std::string state(syncer::InvalidatorStateToString(new_state));
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.invalidations.updateInvalidatorState", base::Value(state),
- base::Value(last_changed_timestamp.ToJsTime()));
+ std::string state(invalidation::InvalidatorStateToString(new_state));
+ FireWebUIListener("state-updated", base::Value(state),
+ base::Value(last_changed_timestamp.ToJsTime()));
}
void InvalidationsMessageHandler::OnUpdatedTopics(
const std::string& handler_name,
- const syncer::TopicCountMap& topics) {
+ const invalidation::TopicCountMap& topics) {
base::ListValue list_of_objects;
for (const auto& topic_item : topics) {
std::unique_ptr<base::DictionaryValue> dic(new base::DictionaryValue());
@@ -113,23 +113,19 @@ void InvalidationsMessageHandler::OnUpdatedTopics(
dic->SetInteger("totalCount", topic_item.second);
list_of_objects.Append(std::move(dic));
}
- web_ui()->CallJavascriptFunctionUnsafe("chrome.invalidations.updateIds",
- base::Value(handler_name),
- list_of_objects);
+ FireWebUIListener("update-ids", base::Value(handler_name), list_of_objects);
}
void InvalidationsMessageHandler::OnDebugMessage(
const base::DictionaryValue& details) {}
void InvalidationsMessageHandler::OnInvalidation(
- const syncer::TopicInvalidationMap& new_invalidations) {
+ const invalidation::TopicInvalidationMap& new_invalidations) {
std::unique_ptr<base::ListValue> invalidations_list =
new_invalidations.ToValue();
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.invalidations.logInvalidations", *invalidations_list);
+ FireWebUIListener("log-invalidations", *invalidations_list);
}
void InvalidationsMessageHandler::OnDetailedStatus(
const base::DictionaryValue& network_details) {
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.invalidations.updateDetailedStatus", network_details);
+ FireWebUIListener("detailed-status-updated", network_details);
}
diff --git a/chromium/chrome/browser/ui/webui/invalidations_message_handler.h b/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.h
index c51938f5fb7..9847011878b 100644
--- a/chromium/chrome/browser/ui/webui/invalidations_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/invalidations/invalidations_message_handler.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_INVALIDATIONS_MESSAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_INVALIDATIONS_MESSAGE_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_INVALIDATIONS_MESSAGE_HANDLER_H_
#include <memory>
@@ -30,17 +30,19 @@ class InvalidationsMessageHandler
// Implementation of InvalidationLoggerObserver.
void OnRegistrationChange(
const std::multiset<std::string>& registered_handlers) override;
- void OnStateChange(const syncer::InvalidatorState& new_state,
+ void OnStateChange(const invalidation::InvalidatorState& new_state,
const base::Time& last_change_timestamp) override;
- void OnUpdatedTopics(const std::string& handler_name,
- const syncer::TopicCountMap& topics_counts) override;
+ void OnUpdatedTopics(
+ const std::string& handler_name,
+ const invalidation::TopicCountMap& topics_counts) override;
void OnDebugMessage(const base::DictionaryValue& details) override;
void OnInvalidation(
- const syncer::TopicInvalidationMap& new_invalidations) override;
+ const invalidation::TopicInvalidationMap& new_invalidations) override;
void OnDetailedStatus(const base::DictionaryValue& network_details) override;
// Implementation of WebUIMessageHandler.
void RegisterMessages() override;
+ void OnJavascriptDisallowed() override;
// Triggers the logger to send the current state and objects ids.
void UpdateContent(const base::ListValue* args);
@@ -62,4 +64,4 @@ class InvalidationsMessageHandler
DISALLOW_COPY_AND_ASSIGN(InvalidationsMessageHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_MESSAGE_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_INVALIDATIONS_MESSAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/invalidations_ui.cc b/chromium/chrome/browser/ui/webui/invalidations/invalidations_ui.cc
index b711477704d..c5c9eaa93b9 100644
--- a/chromium/chrome/browser/ui/webui/invalidations_ui.cc
+++ b/chromium/chrome/browser/ui/webui/invalidations/invalidations_ui.cc
@@ -2,18 +2,21 @@
// 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/invalidations_ui.h"
+#include "chrome/browser/ui/webui/invalidations/invalidations_ui.h"
#include <memory>
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/invalidations_message_handler.h"
+#include "chrome/browser/ui/webui/invalidations/invalidations_message_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/invalidations_resources.h"
+#include "chrome/grit/invalidations_resources_map.h"
#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 "services/network/public/mojom/content_security_policy.mojom.h"
+#include "ui/resources/grit/webui_generated_resources.h"
content::WebUIDataSource* CreateInvalidationsHTMLSource() {
// This is done once per opening of the page
@@ -22,12 +25,13 @@ content::WebUIDataSource* CreateInvalidationsHTMLSource() {
content::WebUIDataSource::Create(chrome::kChromeUIInvalidationsHost);
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources 'self' 'unsafe-eval';");
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::TrustedTypes,
- "trusted-types jstemplate;");
- source->AddResourcePath("about_invalidations.js", IDR_ABOUT_INVALIDATIONS_JS);
- source->SetDefaultResource(IDR_ABOUT_INVALIDATIONS_HTML);
+ "script-src chrome://resources chrome://test 'self' 'unsafe-eval';");
+ source->AddResourcePath("test_loader_util.js",
+ IDR_WEBUI_JS_TEST_LOADER_UTIL_JS);
+ source->DisableTrustedTypesCSP();
+ source->AddResourcePaths(
+ base::make_span(kInvalidationsResources, kInvalidationsResourcesSize));
+ source->SetDefaultResource(IDR_INVALIDATIONS_ABOUT_INVALIDATIONS_HTML);
return source;
}
@@ -40,4 +44,4 @@ InvalidationsUI::InvalidationsUI(content::WebUI* web_ui)
}
}
-InvalidationsUI::~InvalidationsUI() { }
+InvalidationsUI::~InvalidationsUI() {}
diff --git a/chromium/chrome/browser/ui/webui/invalidations_ui.h b/chromium/chrome/browser/ui/webui/invalidations/invalidations_ui.h
index f4a9cf405bb..83176b47dd9 100644
--- a/chromium/chrome/browser/ui/webui/invalidations_ui.h
+++ b/chromium/chrome/browser/ui/webui/invalidations/invalidations_ui.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_INVALIDATIONS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_INVALIDATIONS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_INVALIDATIONS_UI_H_
#include "base/macros.h"
#include "content/public/browser/web_ui_controller.h"
@@ -18,4 +18,4 @@ class InvalidationsUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(InvalidationsUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_INVALIDATIONS_INVALIDATIONS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/local_state/local_state_ui.cc b/chromium/chrome/browser/ui/webui/local_state/local_state_ui.cc
index cf464ded925..7fa518ee129 100644
--- a/chromium/chrome/browser/ui/webui/local_state/local_state_ui.cc
+++ b/chromium/chrome/browser/ui/webui/local_state/local_state_ui.cc
@@ -12,6 +12,7 @@
#include "base/strings/string_util.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
@@ -27,11 +28,11 @@ namespace {
// On ChromeOS, the local state file contains some information about other
// user accounts which we don't want to expose to other users. Use an allowlist
// to only show variations and UMA related fields which don't contain PII.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#define ENABLE_FILTERING true
#else
#define ENABLE_FILTERING false
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// UI Handler for chrome://local-state. Displays the Local State file as JSON.
class LocalStateUIHandler : public content::WebUIMessageHandler {
@@ -69,8 +70,8 @@ void LocalStateUIHandler::HandleRequestJson(const base::ListValue* args) {
g_browser_process->local_state()->GetPreferenceValues(
PrefService::EXCLUDE_DEFAULTS);
if (ENABLE_FILTERING) {
- std::vector<std::string> allowlisted_prefixes = {
- "variations", "user_experience_metrics", "uninstall_metrics"};
+ std::vector<std::string> allowlisted_prefixes = {"variations",
+ "user_experience_metrics"};
internal::FilterPrefs(allowlisted_prefixes, local_state_values);
}
std::string json;
diff --git a/chromium/chrome/browser/ui/webui/managed_ui_handler.cc b/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
index cee83090aae..0f997898926 100644
--- a/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
@@ -112,7 +113,7 @@ std::unique_ptr<base::DictionaryValue> ManagedUIHandler::GetDataSourceUpdate()
auto update = std::make_unique<base::DictionaryValue>();
update->SetKey("browserManagedByOrg",
base::Value(chrome::GetManagedUiWebUILabel(profile_)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
update->SetKey("deviceManagedByOrg",
base::Value(chrome::GetDeviceManagedUiWebUILabel()));
#endif
diff --git a/chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc
index cc1126ac212..218dcbc4684 100644
--- a/chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc
@@ -6,6 +6,7 @@
#include "base/token.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/testing_profile.h"
@@ -19,9 +20,9 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/policy/core/browser/browser_policy_connector_base.h"
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
class TestManagedUIHandler : public ManagedUIHandler {
public:
@@ -111,7 +112,7 @@ TEST_F(ManagedUIHandlerTest, ManagedUIBecomesEnabledByProfile) {
EXPECT_TRUE(IsSourceManaged());
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ManagedUIHandlerTest, ManagedUIDisabledForChildAccount) {
profile_policy_connector()->OverrideIsManagedForTesting(true);
profile()->SetSupervisedUserId("supervised");
diff --git a/chromium/chrome/browser/ui/webui/management/DIR_METADATA b/chromium/chrome/browser/ui/webui/management/DIR_METADATA
new file mode 100644
index 00000000000..f37723a9791
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/management/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail: {
+ component: "Enterprise"
+}
diff --git a/chromium/chrome/browser/ui/webui/management/OWNERS b/chromium/chrome/browser/ui/webui/management/OWNERS
new file mode 100644
index 00000000000..f22fa361bed
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/management/OWNERS
@@ -0,0 +1 @@
+file://components/policy/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/management_a11y_browsertest.cc b/chromium/chrome/browser/ui/webui/management/management_a11y_browsertest.cc
index 72fcdec7d2e..2a5415deffe 100644
--- a/chromium/chrome/browser/ui/webui/management_a11y_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_a11y_browsertest.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/management_a11y_browsertest.h"
+#include "chrome/browser/ui/webui/management/management_a11y_browsertest.h"
#include "base/path_service.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
diff --git a/chromium/chrome/browser/ui/webui/management_a11y_browsertest.h b/chromium/chrome/browser/ui/webui/management/management_a11y_browsertest.h
index 57c25b9b710..2da62a7ecb5 100644
--- a/chromium/chrome/browser/ui/webui/management_a11y_browsertest.h
+++ b/chromium/chrome/browser/ui/webui/management/management_a11y_browsertest.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_MANAGEMENT_A11Y_BROWSERTEST_H_
-#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_A11Y_BROWSERTEST_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_A11Y_BROWSERTEST_H_
+#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_A11Y_BROWSERTEST_H_
#include "base/files/file_path.h"
#include "base/macros.h"
@@ -20,4 +20,4 @@ class ManagementA11yUIBrowserTest : public WebUIBrowserTest {
const base::FilePath test_data_dir_;
};
-#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_A11Y_BROWSERTEST_H_
+#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_A11Y_BROWSERTEST_H_
diff --git a/chromium/chrome/browser/ui/webui/management_ui.cc b/chromium/chrome/browser/ui/webui/management/management_ui.cc
index 7db259edf4d..946dfdf4454 100644
--- a/chromium/chrome/browser/ui/webui/management_ui.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_ui.cc
@@ -2,37 +2,37 @@
// 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/management_ui.h"
+#include "chrome/browser/ui/webui/management/management_ui.h"
#include <memory>
#include "base/strings/utf_string_conversions.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/management_ui_handler.h"
+#include "chrome/browser/ui/webui/management/management_ui_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/theme_resources.h"
-#include "components/safe_browsing/core/common/safebrowsing_constants.h"
#include "components/strings/grit/components_strings.h"
#include "extensions/buildflags/buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/grit/chromium_strings.h"
#include "ui/chromeos/devicetype_utils.h"
-#else // defined(OS_CHROMEOS)
+#else // BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/browser_process.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace {
@@ -46,7 +46,7 @@ content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
ManagementUI::GetManagementPageSubtitle(profile));
static constexpr webui::LocalizedString kLocalizedStrings[] = {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"learnMore", IDS_LEARN_MORE},
{"localTrustRoots", IDS_MANAGEMENT_LOCAL_TRUST_ROOTS},
{"managementTrustRootsConfigured", IDS_MANAGEMENT_TRUST_ROOTS_CONFIGURED},
@@ -74,7 +74,7 @@ content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
IDS_MANAGEMENT_REPORT_ANDROID_APPLICATIONS},
{"proxyServerPrivacyDisclosure",
IDS_MANAGEMENT_PROXY_SERVER_PRIVACY_DISCLOSURE},
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
{"browserReporting", IDS_MANAGEMENT_BROWSER_REPORTING},
{"browserReportingExplanation",
IDS_MANAGEMENT_BROWSER_REPORTING_EXPLANATION},
@@ -122,13 +122,9 @@ content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
IDS_MANAGEMENT_PAGE_VISITED_VISIBLE_DATA},
};
- AddLocalizedStringsBulk(source, kLocalizedStrings);
+ source->AddLocalizedStrings(kLocalizedStrings);
- source->AddString(kManagementExtensionReportSafeBrowsingWarnings,
- l10n_util::GetStringFUTF16(
- IDS_MANAGEMENT_EXTENSION_REPORT_SAFE_BROWSING_WARNINGS,
- base::UTF8ToUTF16(safe_browsing::kSafeBrowsingUrl)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
source->AddString("managementDeviceLearnMoreUrl",
chrome::kLearnMoreEnterpriseURL);
source->AddString("managementAccountLearnMoreUrl",
@@ -137,7 +133,7 @@ content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
l10n_util::GetStringFUTF16(
IDS_MANAGEMENT_REPORT_PLUGIN_VM,
l10n_util::GetStringUTF16(IDS_PLUGIN_VM_APP_NAME)));
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
source->UseStringsJs();
source->EnableReplaceI18nInJS();
@@ -161,7 +157,7 @@ base::RefCountedMemory* ManagementUI::GetFaviconResourceBytes(
// static
base::string16 ManagementUI::GetManagementPageSubtitle(Profile* profile) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
const auto device_type = ui::GetChromeOSDeviceTypeResourceId();
@@ -184,7 +180,7 @@ base::string16 ManagementUI::GetManagementPageSubtitle(Profile* profile) {
return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY,
l10n_util::GetStringUTF16(device_type),
base::UTF8ToUTF16(account_manager));
-#else // defined(OS_CHROMEOS)
+#else // BUILDFLAG(IS_CHROMEOS_ASH)
const auto account_manager = ManagementUIHandler::GetAccountManager(profile);
const auto managed =
profile->GetProfilePolicyConnector()->IsManaged() ||
@@ -199,7 +195,7 @@ base::string16 ManagementUI::GetManagementPageSubtitle(Profile* profile) {
base::UTF8ToUTF16(account_manager));
}
return l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
ManagementUI::ManagementUI(content::WebUI* web_ui) : WebUIController(web_ui) {
diff --git a/chromium/chrome/browser/ui/webui/management_ui.h b/chromium/chrome/browser/ui/webui/management/management_ui.h
index 86f66238d9b..a0ebd2e2d12 100644
--- a/chromium/chrome/browser/ui/webui/management_ui.h
+++ b/chromium/chrome/browser/ui/webui/management/management_ui.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_MANAGEMENT_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_H_
#include "base/macros.h"
#include "chrome/browser/profiles/profile.h"
@@ -33,4 +33,4 @@ class ManagementUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(ManagementUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/management_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/management/management_ui_browsertest.cc
index 806e9c15829..403dff1816a 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_browsertest.cc
@@ -4,12 +4,13 @@
#include "base/json/json_reader.h"
#include "base/strings/utf_string_conversions.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/webui/management_ui.h"
-#include "chrome/browser/ui/webui/management_ui_handler.h"
+#include "chrome/browser/ui/webui/management/management_ui.h"
+#include "chrome/browser/ui/webui/management/management_ui_handler.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/policy/core/browser/browser_policy_connector.h"
@@ -26,8 +27,10 @@ class ManagementUITest : public InProcessBrowserTest {
~ManagementUITest() override = default;
void SetUpInProcessBrowserTestFixture() override {
- EXPECT_CALL(provider_, IsInitializationComplete(testing::_))
- .WillRepeatedly(testing::Return(true));
+ ON_CALL(provider_, IsInitializationComplete(testing::_))
+ .WillByDefault(testing::Return(true));
+ ON_CALL(provider_, IsFirstPolicyLoadComplete(testing::_))
+ .WillByDefault(testing::Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
}
@@ -48,12 +51,12 @@ class ManagementUITest : public InProcessBrowserTest {
}
private:
- policy::MockConfigurationPolicyProvider provider_;
+ testing::NiceMock<policy::MockConfigurationPolicyProvider> provider_;
DISALLOW_COPY_AND_ASSIGN(ManagementUITest);
};
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(ManagementUITest, ManagementStateChange) {
profile_policy_connector()->OverrideIsManagedForTesting(false);
ui_test_utils::NavigateToURL(browser(), GURL("chrome://management"));
@@ -116,4 +119,4 @@ IN_PROC_BROWSER_TEST_F(ManagementUITest, ManagementStateChange) {
VerifyTexts(managed_value_ptr.get(), expected_managed_values);
}
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler.cc b/chromium/chrome/browser/ui/webui/management/management_ui_handler.cc
index 856a8a0ed3f..f812f8e304f 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_handler.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/management_ui_handler.h"
+#include "chrome/browser/ui/webui/management/management_ui_handler.h"
#include <algorithm>
#include <memory>
@@ -38,7 +38,9 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/profiles/profile_helper.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/chromeos/crostini/crostini_features.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_pref_names.h"
@@ -52,9 +54,7 @@
#include "chrome/browser/chromeos/policy/status_uploader.h"
#include "chrome/browser/chromeos/policy/system_log_uploader.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/ui/webui/management_ui_handler_chromeos.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/network/network_state_handler.h"
@@ -67,8 +67,9 @@
#include "ui/chromeos/devicetype_utils.h"
#else
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/common/extensions/permissions/chrome_permission_message_provider.h"
#include "components/policy/core/common/policy_map.h"
@@ -87,13 +88,11 @@ const char kOnPremReportingExtensionStableId[] =
"emahakmocgideepebncgnmlmliepgpgb";
const char kOnPremReportingExtensionBetaId[] =
"kigjhoekjcpdfjpimbdjegmgecmlicaf";
-const char kCloudReportingExtensionId[] = "oempjldejiginopiohodkdoklcjklbaa";
const char kPolicyKeyReportMachineIdData[] = "report_machine_id_data";
const char kPolicyKeyReportUserIdData[] = "report_user_id_data";
const char kPolicyKeyReportVersionData[] = "report_version_data";
const char kPolicyKeyReportPolicyData[] = "report_policy_data";
const char kPolicyKeyReportExtensionsData[] = "report_extensions_data";
-const char kPolicyKeyReportSafeBrowsingData[] = "report_safe_browsing_data";
const char kPolicyKeyReportSystemTelemetryData[] =
"report_system_telemetry_data";
const char kPolicyKeyReportUserBrowsingData[] = "report_user_browsing_data";
@@ -108,8 +107,6 @@ const char kManagementExtensionReportVersion[] =
"managementExtensionReportVersion";
const char kManagementExtensionReportExtensionsPlugin[] =
"managementExtensionReportExtensionsPlugin";
-const char kManagementExtensionReportSafeBrowsingWarnings[] =
- "managementExtensionReportSafeBrowsingWarnings";
const char kManagementExtensionReportPerfCrash[] =
"managementExtensionReportPerfCrash";
const char kManagementExtensionReportUserBrowsingData[] =
@@ -157,7 +154,7 @@ enum class ReportingType {
kUserActivity
};
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
const char kManagementLogUploadEnabled[] = "managementLogUploadEnabled";
const char kManagementReportActivityTimes[] = "managementReportActivityTimes";
const char kManagementReportHardwareStatus[] = "managementReportHardwareStatus";
@@ -177,7 +174,7 @@ const char kManagementCrostiniContainerConfiguration[] =
const char kAccountManagedInfo[] = "accountManagedInfo";
const char kDeviceManagedInfo[] = "deviceManagedInfo";
const char kOverview[] = "overview";
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
const char kCustomerLogo[] = "customerLogo";
@@ -189,20 +186,20 @@ bool IsProfileManaged(Profile* profile) {
return profile->GetProfilePolicyConnector()->IsManaged();
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
bool IsDeviceManaged() {
return webui::IsEnterpriseManaged();
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
bool IsBrowserManaged() {
return g_browser_process->browser_policy_connector()
->HasMachineLevelPolicies();
}
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
enum class DeviceReportingType {
kSupervisedUser,
@@ -260,7 +257,7 @@ void AddDeviceReportingElement(base::Value* report_sources,
data.SetKey("reportingType", base::Value(ToJSDeviceReportingType(type)));
report_sources->Append(std::move(data));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
std::vector<base::Value> GetPermissionsForExtension(
scoped_refptr<const extensions::Extension> extension) {
@@ -346,13 +343,13 @@ std::string ManagementUIHandler::GetAccountManager(Profile* profile) {
if (!IsProfileManaged(profile))
return std::string();
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
const policy::UserCloudPolicyManagerChromeOS* user_cloud_policy_manager =
profile->GetUserCloudPolicyManagerChromeOS();
#else
const policy::UserCloudPolicyManager* user_cloud_policy_manager =
profile->GetUserCloudPolicyManager();
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
if (user_cloud_policy_manager) {
const enterprise_management::PolicyData* policy =
@@ -367,8 +364,7 @@ std::string ManagementUIHandler::GetAccountManager(Profile* profile) {
ManagementUIHandler::ManagementUIHandler() {
reporting_extension_ids_ = {kOnPremReportingExtensionStableId,
- kOnPremReportingExtensionBetaId,
- kCloudReportingExtensionId};
+ kOnPremReportingExtensionBetaId};
}
ManagementUIHandler::~ManagementUIHandler() {
@@ -385,12 +381,12 @@ void ManagementUIHandler::InitializeInternal(content::WebUI* web_ui,
Profile* profile) {
auto handler = std::make_unique<ManagementUIHandler>();
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
handler->account_managed_ = IsProfileManaged(profile);
handler->device_managed_ = IsDeviceManaged();
#else
handler->account_managed_ = IsProfileManaged(profile) || IsBrowserManaged();
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
web_ui->AddMessageHandler(std::move(handler));
}
@@ -404,7 +400,7 @@ void ManagementUIHandler::RegisterMessages() {
"getExtensions",
base::BindRepeating(&ManagementUIHandler::HandleGetExtensions,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
"getLocalTrustRootsInfo",
base::BindRepeating(&ManagementUIHandler::HandleGetLocalTrustRootsInfo,
@@ -418,7 +414,7 @@ void ManagementUIHandler::RegisterMessages() {
base::BindRepeating(
&ManagementUIHandler::HandleGetPluginVmDataCollectionStatus,
base::Unretained(this)));
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
"getThreatProtectionInfo",
base::BindRepeating(&ManagementUIHandler::HandleGetThreatProtectionInfo,
@@ -438,9 +434,6 @@ void ManagementUIHandler::OnJavascriptDisallowed() {
}
void ManagementUIHandler::AddReportingInfo(base::Value* report_sources) {
- const extensions::Extension* cloud_reporting_extension =
- GetEnabledExtension(kCloudReportingExtensionId);
-
const policy::PolicyService* policy_service = GetPolicyService();
const policy::PolicyNamespace
@@ -463,8 +456,6 @@ void ManagementUIHandler::AddReportingInfo(base::Value* report_sources) {
&on_prem_reporting_extension_stable_policy_map,
&on_prem_reporting_extension_beta_policy_map};
- const bool cloud_reporting_extension_installed =
- cloud_reporting_extension != nullptr;
const auto* cloud_reporting_policy_value =
GetPolicyService()
->GetPolicies(policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME,
@@ -481,25 +472,19 @@ void ManagementUIHandler::AddReportingInfo(base::Value* report_sources) {
const bool enabled_by_default;
} report_definitions[] = {
{kPolicyKeyReportMachineIdData, kManagementExtensionReportMachineName,
- ReportingType::kDevice,
- cloud_reporting_extension_installed || cloud_reporting_policy_enabled},
+ ReportingType::kDevice, cloud_reporting_policy_enabled},
{kPolicyKeyReportMachineIdData,
kManagementExtensionReportMachineNameAddress, ReportingType::kDevice,
false},
{kPolicyKeyReportVersionData, kManagementExtensionReportVersion,
- ReportingType::kDevice,
- cloud_reporting_extension_installed || cloud_reporting_policy_enabled},
+ ReportingType::kDevice, cloud_reporting_policy_enabled},
{kPolicyKeyReportSystemTelemetryData, kManagementExtensionReportPerfCrash,
ReportingType::kDevice, false},
{kPolicyKeyReportUserIdData, kManagementExtensionReportUsername,
- ReportingType::kUser,
- cloud_reporting_extension_installed || cloud_reporting_policy_enabled},
- {kPolicyKeyReportSafeBrowsingData,
- kManagementExtensionReportSafeBrowsingWarnings, ReportingType::kSecurity,
- cloud_reporting_extension_installed},
+ ReportingType::kUser, cloud_reporting_policy_enabled},
{kPolicyKeyReportExtensionsData,
kManagementExtensionReportExtensionsPlugin, ReportingType::kExtensions,
- cloud_reporting_extension_installed || cloud_reporting_policy_enabled},
+ cloud_reporting_policy_enabled},
{kPolicyKeyReportUserBrowsingData,
kManagementExtensionReportUserBrowsingData, ReportingType::kUserActivity,
false},
@@ -545,7 +530,7 @@ void ManagementUIHandler::AddReportingInfo(base::Value* report_sources) {
}
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
const policy::DeviceCloudPolicyManagerChromeOS*
ManagementUIHandler::GetDeviceCloudPolicyManager() const {
// Only check for report status in managed environment.
@@ -604,7 +589,7 @@ void ManagementUIHandler::AddDeviceReportingInfo(
DeviceReportingType::kPrint);
}
- if (crostini::CrostiniFeatures::Get()->IsAllowed(profile)) {
+ if (crostini::CrostiniFeatures::Get()->IsAllowedNow(profile)) {
if (!profile->GetPrefs()
->GetFilePath(crostini::prefs::kCrostiniAnsiblePlaybookFilePath)
.empty()) {
@@ -691,7 +676,7 @@ void ManagementUIHandler::AddProxyServerPrivacyDisclosure(
base::Value ManagementUIHandler::GetContextualManagedData(Profile* profile) {
base::Value response(base::Value::Type::DICTIONARY);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
std::string enterprise_manager = GetDeviceManager();
if (enterprise_manager.empty())
enterprise_manager = GetAccountManager(profile);
@@ -713,7 +698,7 @@ base::Value ManagementUIHandler::GetContextualManagedData(Profile* profile) {
"extensionReportingTitle",
l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED));
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
response.SetStringPath(
"pageSubtitle", l10n_util::GetStringUTF16(
managed_() ? IDS_MANAGEMENT_SUBTITLE
@@ -728,7 +713,7 @@ base::Value ManagementUIHandler::GetContextualManagedData(Profile* profile) {
: l10n_util::GetStringFUTF16(
IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE,
l10n_util::GetStringUTF16(device_type)));
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
} else {
response.SetStringPath(
@@ -736,7 +721,7 @@ base::Value ManagementUIHandler::GetContextualManagedData(Profile* profile) {
l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY,
base::UTF8ToUTF16(enterprise_manager)));
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
response.SetStringPath(
"pageSubtitle",
managed_()
@@ -754,7 +739,7 @@ base::Value ManagementUIHandler::GetContextualManagedData(Profile* profile) {
: l10n_util::GetStringFUTF16(
IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE,
l10n_util::GetStringUTF16(device_type)));
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
}
response.SetBoolPath("managed", managed_());
GetManagementStatus(profile, &response);
@@ -822,13 +807,13 @@ base::Value ManagementUIHandler::GetThreatProtectionInfo(
info.Append(std::move(value));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
std::string enterprise_manager = GetDeviceManager();
if (enterprise_manager.empty())
enterprise_manager = GetAccountManager(profile);
#else
std::string enterprise_manager = GetAccountManager(profile);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
base::Value result(base::Value::Type::DICTIONARY);
result.SetStringKey("description",
@@ -848,15 +833,8 @@ policy::PolicyService* ManagementUIHandler::GetPolicyService() const {
->policy_service();
}
-const extensions::Extension* ManagementUIHandler::GetEnabledExtension(
- const std::string& extensionId) const {
- return extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))
- ->GetExtensionById(kCloudReportingExtensionId,
- extensions::ExtensionRegistry::ENABLED);
-}
-
void ManagementUIHandler::AsyncUpdateLogo() {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
const auto url = connector->GetCustomerLogoURL();
@@ -871,7 +849,7 @@ void ManagementUIHandler::AsyncUpdateLogo() {
->GetURLLoaderFactoryForBrowserProcess()
.get());
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void ManagementUIHandler::OnFetchComplete(const GURL& url,
@@ -884,7 +862,7 @@ void ManagementUIHandler::OnFetchComplete(const GURL& url,
FireWebUIListener("managed_data_changed");
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void AddStatusOverviewManagedDeviceAndAccount(
base::Value* status,
bool device_managed,
@@ -927,11 +905,11 @@ const std::string ManagementUIHandler::GetDeviceManager() const {
return device_domain;
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void ManagementUIHandler::GetManagementStatus(Profile* profile,
base::Value* status) const {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
status->SetKey(kDeviceManagedInfo, base::Value());
status->SetKey(kAccountManagedInfo, base::Value());
status->SetKey(kOverview, base::Value());
@@ -957,7 +935,7 @@ void ManagementUIHandler::GetManagementStatus(Profile* profile,
AddStatusOverviewManagedDeviceAndAccount(
status, device_managed_, account_managed_ || primary_user_managed,
device_manager, account_manager);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void ManagementUIHandler::HandleGetExtensions(const base::ListValue* args) {
@@ -978,7 +956,7 @@ void ManagementUIHandler::HandleGetExtensions(const base::ListValue* args) {
powerful_extensions);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void ManagementUIHandler::HandleGetLocalTrustRootsInfo(
const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
@@ -1029,7 +1007,7 @@ void ManagementUIHandler::HandleGetPluginVmDataCollectionStatus(
plugin_vm_data_collection_enabled);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void ManagementUIHandler::HandleGetContextualManagedData(
const base::ListValue* args) {
@@ -1062,14 +1040,14 @@ void ManagementUIHandler::NotifyBrowserReportingInfoUpdated() {
FireWebUIListener("browser-reporting-info-updated", report_sources);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void ManagementUIHandler::NotifyPluginVmDataCollectionUpdated() {
FireWebUIListener(
"plugin-vm-data-collection-updated",
base::Value(Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean(
plugin_vm::prefs::kPluginVmDataCollectionAllowed)));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void ManagementUIHandler::NotifyThreatProtectionInfoUpdated() {
FireWebUIListener("threat-protection-info-updated",
@@ -1098,7 +1076,7 @@ void ManagementUIHandler::OnExtensionUnloaded(
void ManagementUIHandler::UpdateManagedState() {
auto* profile = Profile::FromWebUI(web_ui());
bool managed_state_changed = false;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
managed_state_changed |= account_managed_ != IsProfileManaged(profile);
managed_state_changed |= device_managed_ != IsDeviceManaged();
account_managed_ = IsProfileManaged(profile);
@@ -1107,7 +1085,7 @@ void ManagementUIHandler::UpdateManagedState() {
managed_state_changed |=
account_managed_ != (IsProfileManaged(profile) || IsBrowserManaged());
account_managed_ = IsProfileManaged(profile) || IsBrowserManaged();
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
if (managed_state_changed)
FireWebUIListener("managed_data_changed");
@@ -1142,13 +1120,13 @@ void ManagementUIHandler::AddObservers() {
base::BindRepeating(&ManagementUIHandler::UpdateManagedState,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
pref_registrar_.Add(
plugin_vm::prefs::kPluginVmDataCollectionAllowed,
base::BindRepeating(
&ManagementUIHandler::NotifyPluginVmDataCollectionUpdated,
base::Unretained(this)));
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void ManagementUIHandler::RemoveObservers() {
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler.h b/chromium/chrome/browser/ui/webui/management/management_ui_handler.h
index 476e81b5bd3..c1507025850 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_handler.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_MANAGEMENT_UI_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_HANDLER_H_
#include <memory>
#include <set>
@@ -12,6 +12,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/strings/string16.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
#include "chrome/common/url_constants.h"
#include "components/policy/core/common/policy_service.h"
@@ -24,7 +25,7 @@
#include "extensions/common/extension_id.h"
#include "url/gurl.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Constants defining the IDs for the localized strings sent to the page as
// load time data.
extern const char kManagementLogUploadEnabled[];
@@ -39,9 +40,8 @@ extern const char kManagementCrostini[];
extern const char kManagementCrostiniContainerConfiguration[];
extern const char kManagementReportExtensions[];
extern const char kManagementReportAndroidApplications[];
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-extern const char kCloudReportingExtensionId[];
extern const char kOnPremReportingExtensionStableId[];
extern const char kOnPremReportingExtensionBetaId[];
@@ -50,7 +50,6 @@ extern const char kManagementExtensionReportMachineNameAddress[];
extern const char kManagementExtensionReportUsername[];
extern const char kManagementExtensionReportVersion[];
extern const char kManagementExtensionReportExtensionsPlugin[];
-extern const char kManagementExtensionReportSafeBrowsingWarnings[];
extern const char kManagementExtensionReportPerfCrash[];
extern const char kManagementExtensionReportUserBrowsingData[];
@@ -75,7 +74,6 @@ extern const char kPolicyKeyReportUserIdData[];
extern const char kPolicyKeyReportVersionData[];
extern const char kPolicyKeyReportPolicyData[];
extern const char kPolicyKeyReportExtensionsData[];
-extern const char kPolicyKeyReportSafeBrowsingData[];
extern const char kPolicyKeyReportSystemTelemetryData[];
extern const char kPolicyKeyReportUserBrowsingData[];
@@ -142,10 +140,8 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
base::Value GetContextualManagedData(Profile* profile);
base::Value GetThreatProtectionInfo(Profile* profile) const;
virtual policy::PolicyService* GetPolicyService() const;
- virtual const extensions::Extension* GetEnabledExtension(
- const std::string& extensionId) const;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Protected for testing.
virtual const std::string GetDeviceManager() const;
virtual const policy::DeviceCloudPolicyManagerChromeOS*
@@ -165,15 +161,15 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
// the admin. If true, a warning will be added to the transparency panel to
// inform the user that the admin may be able to see their network traffic.
void AddProxyServerPrivacyDisclosure(base::Value* response) const;
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
private:
void GetManagementStatus(Profile* profile, base::Value* status) const;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void HandleGetDeviceReportingInfo(const base::ListValue* args);
void HandleGetPluginVmDataCollectionStatus(const base::ListValue* args);
void HandleGetLocalTrustRootsInfo(const base::ListValue* args);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void HandleGetExtensions(const base::ListValue* args);
void HandleGetContextualManagedData(const base::ListValue* args);
@@ -186,9 +182,9 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
void OnFetchComplete(const GURL& url, const SkBitmap* bitmap) override;
void NotifyBrowserReportingInfoUpdated();
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void NotifyPluginVmDataCollectionUpdated();
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void NotifyThreatProtectionInfoUpdated();
// extensions::ExtensionRegistryObserver implementation.
@@ -226,4 +222,4 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
DISALLOW_COPY_AND_ASSIGN(ManagementUIHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/management/management_ui_handler_chromeos.cc
index 2702f506396..64634b17951 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_handler_chromeos.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/management_ui_handler_chromeos.h"
+#include "chrome/browser/ui/webui/management/management_ui_handler_chromeos.h"
net::NetworkTrafficAnnotationTag GetManagementUICustomerLogoAnnotation() {
return net::DefineNetworkTrafficAnnotation("management_ui_customer_logo", R"(
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler_chromeos.h b/chromium/chrome/browser/ui/webui/management/management_ui_handler_chromeos.h
index b2deb928e03..8d9e9ecdbb2 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_handler_chromeos.h
@@ -2,11 +2,11 @@
// 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_MANAGEMENT_UI_HANDLER_CHROMEOS_H_
-#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_HANDLER_CHROMEOS_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_HANDLER_CHROMEOS_H_
+#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_HANDLER_CHROMEOS_H_
#include "net/traffic_annotation/network_traffic_annotation.h"
net::NetworkTrafficAnnotationTag GetManagementUICustomerLogoAnnotation();
-#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_HANDLER_CHROMEOS_H_
+#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_MANAGEMENT_UI_HANDLER_CHROMEOS_H_
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc
index e75c078222c..dc2f507f36a 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc
@@ -12,7 +12,8 @@
#include "base/memory/scoped_refptr.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/ui/webui/management_ui_handler.h"
+#include "build/chromeos_buildflags.h"
+#include "chrome/browser/ui/webui/management/management_ui_handler.h"
#include "chrome/test/base/testing_profile.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
@@ -29,11 +30,13 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/files/file_path.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_simple_task_runner.h"
#include "base/time/time.h"
+#include "chrome/browser/ash/settings/device_settings_test_helper.h"
+#include "chrome/browser/ash/settings/scoped_testing_cros_settings.h"
#include "chrome/browser/chromeos/crostini/crostini_features.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/fake_crostini_features.h"
@@ -45,18 +48,15 @@
#include "chrome/browser/chromeos/policy/status_uploader.h"
#include "chrome/browser/chromeos/policy/system_log_uploader.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
-#include "chrome/browser/chromeos/settings/device_settings_service.h"
-#include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
-#include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
-#include "chromeos/cryptohome/async_method_caller.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/dbus/shill/shill_service_client.h"
+#include "chromeos/network/network_metadata_store.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/proxy/proxy_config_handler.h"
#include "chromeos/network/proxy/ui_proxy_config_service.h"
@@ -84,7 +84,7 @@
#include "components/policy/core/common/cloud/mock_user_cloud_policy_store.h"
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#include "services/network/test/test_network_connection_tracker.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
using testing::_;
using testing::AnyNumber;
@@ -97,13 +97,13 @@ using testing::ReturnRef;
struct ContextualManagementSourceUpdate {
base::string16 extension_reporting_title;
base::string16 subtitle;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
base::string16 management_overview;
base::string16 update_required_eol;
bool show_proxy_server_privacy_disclosure;
#else
base::string16 browser_management_notice;
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
bool managed;
};
@@ -111,12 +111,12 @@ namespace {
const char kDomain[] = "domain.com";
const char kUser[] = "user@domain.com";
const char kManager[] = "manager@domain.com";
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
const char kGaiaId[] = "gaia_id";
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// This class is just to mock the behaviour of the few flags we need for
// simulating the behaviour of the policy::DeviceStatusCollector.
// The expected flags are passed to the constructor.
@@ -153,8 +153,7 @@ class TestDeviceStatusCollector : public policy::DeviceStatusCollector {
// empty methods that need to be implemented but are of no use for this
// case.
- void GetStatusAsync(
- const policy::StatusCollectorCallback& callback) override {}
+ void GetStatusAsync(policy::StatusCollectorCallback callback) override {}
void OnSubmittedSuccessfully() override {}
private:
@@ -180,7 +179,7 @@ class TestDeviceCloudPolicyManagerChromeOS
}
~TestDeviceCloudPolicyManagerChromeOS() override = default;
};
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
class TestManagementUIHandler : public ManagementUIHandler {
public:
@@ -189,10 +188,6 @@ class TestManagementUIHandler : public ManagementUIHandler {
: policy_service_(policy_service) {}
~TestManagementUIHandler() override = default;
- void EnableCloudReportingExtension(bool enable) {
- cloud_reporting_extension_exists_ = enable;
- }
-
void EnableUpdateRequiredEolInfo(bool enable) {
update_required_eol_ = enable;
}
@@ -215,14 +210,7 @@ class TestManagementUIHandler : public ManagementUIHandler {
return policy_service_;
}
- const extensions::Extension* GetEnabledExtension(
- const std::string& extensionId) const override {
- if (cloud_reporting_extension_exists_)
- return extensions::ExtensionBuilder("dummy").SetID("id").Build().get();
- return nullptr;
- }
-
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
MOCK_METHOD(policy::DeviceCloudPolicyManagerChromeOS*,
GetDeviceCloudPolicyManager,
(),
@@ -241,10 +229,9 @@ class TestManagementUIHandler : public ManagementUIHandler {
const std::string GetDeviceManager() const override { return device_domain; }
void SetDeviceDomain(const std::string& domain) { device_domain = domain; }
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
private:
- bool cloud_reporting_extension_exists_ = false;
policy::PolicyService* policy_service_ = nullptr;
bool update_required_eol_ = false;
std::string device_domain = "devicedomain.com";
@@ -253,14 +240,14 @@ class TestManagementUIHandler : public ManagementUIHandler {
// We need to use a different base class for ChromeOS and non ChromeOS case.
// TODO(marcgrimme): refactor so that ChromeOS and non ChromeOS part is better
// separated.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
using TestingBaseClass = chromeos::DeviceSettingsTestBase;
#else
using TestingBaseClass = testing::Test;
#endif
class ManagementUIHandlerTests : public TestingBaseClass {
public:
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
ManagementUIHandlerTests()
: TestingBaseClass(),
handler_(&policy_service_),
@@ -321,7 +308,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
extracted_.extension_reporting_title =
ExtractPathFromDict(data, "extensionReportingTitle");
extracted_.subtitle = ExtractPathFromDict(data, "pageSubtitle");
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
extracted_.management_overview = ExtractPathFromDict(data, "overview");
extracted_.update_required_eol = ExtractPathFromDict(data, "eolMessage");
base::Optional<bool> showProxyDisclosure =
@@ -331,7 +318,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
#else
extracted_.browser_management_notice =
ExtractPathFromDict(data, "browserManagementNotice");
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
base::Optional<bool> managed = data.FindBoolPath("managed");
extracted_.managed = managed.has_value() && managed.value();
}
@@ -377,7 +364,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
setup_config_.device_domain = "devicedomain.com";
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void SetUp() override {
DeviceSettingsTestBase::SetUp();
install_attributes_ =
@@ -388,6 +375,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
crostini_features_ = std::make_unique<crostini::FakeCrostiniFeatures>();
SetUpConnectManager();
chromeos::NetworkHandler::Initialize();
+ chromeos::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
@@ -441,7 +429,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
profile_->GetPrefs()->SetFilePath(
crostini::prefs::kCrostiniAnsiblePlaybookFilePath,
GetTestConfig().crostini_ansible_playbook_filepath);
- crostini_features()->set_allowed(true);
+ crostini_features()->set_is_allowed_now(true);
const policy::SystemLogUploader* system_uploader =
new policy::SystemLogUploader(/*syslog_delegate=*/nullptr,
@@ -452,7 +440,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
return handler_.GetDeviceReportingInfo(manager_.get(), status_collector,
system_uploader, GetProfile());
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void SetUpProfileAndHandler() {
TestingProfile::Builder builder;
@@ -463,7 +451,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
profile_ = builder.Build();
handler_.SetAccountManagedForTesting(GetTestConfig().managed_account);
handler_.SetDeviceManagedForTesting(GetTestConfig().managed_device);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
handler_.SetDeviceDomain(GetTestConfig().device_domain);
#endif
base::Value data =
@@ -473,7 +461,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
bool GetManaged() const { return extracted_.managed; }
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
base::string16 GetManagementOverview() const {
return extracted_.management_overview;
}
@@ -510,7 +498,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
TestConfig& GetTestConfig() { return setup_config_; }
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void OnFatalError() { DCHECK(false); }
std::unique_ptr<policy::UserCloudPolicyManagerChromeOS>
@@ -550,7 +538,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
base::ThreadTaskRunnerHandle::Get(),
network::TestNetworkConnectionTracker::CreateGetter());
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
protected:
TestConfig setup_config_;
@@ -559,7 +547,7 @@ class ManagementUIHandlerTests : public TestingBaseClass {
policy::PolicyMap empty_policy_map_;
base::string16 device_domain_;
ContextualManagementSourceUpdate extracted_;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<chromeos::ScopedStubInstallAttributes> install_attributes_;
std::unique_ptr<crostini::FakeCrostiniFeatures> crostini_features_;
TestingPrefServiceSimple local_state_;
@@ -604,7 +592,7 @@ AssertionResult MessagesToBeEQ(const char* infolist_expr,
return AssertionSuccess();
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
AssertionResult ReportingElementsToBeEQ(
const char* elements_expr,
const char* expected_elements_expr,
@@ -656,7 +644,7 @@ AssertionResult ReportingElementsToBeEQ(
}
#endif
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ManagementUIHandlerTests,
ManagementContextualSourceUpdateUnmanagedNoDomain) {
ResetTestConfig();
@@ -765,9 +753,9 @@ TEST_F(ManagementUIHandlerTests,
EXPECT_TRUE(GetManaged());
}
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ManagementUIHandlerTests,
ManagementContextualSourceUpdateManagedAccountKnownDomain) {
const std::string domain = "manager.com";
@@ -1066,28 +1054,11 @@ TEST_F(ManagementUIHandlerTests, HideProxyServerDisclosureForDirectProxy) {
#endif
TEST_F(ManagementUIHandlerTests, ExtensionReportingInfoNoPolicySetNoMessage) {
- handler_.EnableCloudReportingExtension(false);
auto reporting_info = handler_.GetExtensionReportingInfo();
EXPECT_EQ(reporting_info.GetList().size(), 0u);
}
-TEST_F(ManagementUIHandlerTests,
- ExtensionReportingInfoCloudExtensionAddsDefaultPolicies) {
- handler_.EnableCloudReportingExtension(true);
-
- const std::set<std::string> expected_messages = {
- kManagementExtensionReportMachineName, kManagementExtensionReportUsername,
- kManagementExtensionReportVersion,
- kManagementExtensionReportExtensionsPlugin,
- kManagementExtensionReportSafeBrowsingWarnings};
-
- ASSERT_PRED_FORMAT2(MessagesToBeEQ,
- handler_.GetExtensionReportingInfo().GetList(),
- expected_messages);
-}
-
TEST_F(ManagementUIHandlerTests, CloudReportingPolicy) {
- handler_.EnableCloudReportingExtension(false);
policy::PolicyMap chrome_policies;
const policy::PolicyNamespace chrome_policies_namespace =
@@ -1105,7 +1076,6 @@ TEST_F(ManagementUIHandlerTests, CloudReportingPolicy) {
handler_.GetExtensionReportingInfo().GetList(),
expected_messages);
}
-
TEST_F(ManagementUIHandlerTests, ExtensionReportingInfoPoliciesMerge) {
policy::PolicyMap on_prem_reporting_extension_beta_policies;
policy::PolicyMap on_prem_reporting_extension_stable_policies;
@@ -1121,8 +1091,6 @@ TEST_F(ManagementUIHandlerTests, ExtensionReportingInfoPoliciesMerge) {
EnablePolicy(kPolicyKeyReportMachineIdData,
on_prem_reporting_extension_stable_policies);
- EnablePolicy(kPolicyKeyReportSafeBrowsingData,
- on_prem_reporting_extension_stable_policies);
EnablePolicy(kPolicyKeyReportSystemTelemetryData,
on_prem_reporting_extension_stable_policies);
EnablePolicy(kPolicyKeyReportUserBrowsingData,
@@ -1144,20 +1112,18 @@ TEST_F(ManagementUIHandlerTests, ExtensionReportingInfoPoliciesMerge) {
EXPECT_CALL(policy_service_,
GetPolicies(on_prem_reporting_extension_beta_policy_namespace))
.WillOnce(ReturnRef(on_prem_reporting_extension_beta_policies));
- policy::PolicyMap empty_policy_map;
+ policy::PolicyMap chrome_policies;
EXPECT_CALL(policy_service_,
GetPolicies(policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME,
std::string())))
- .WillOnce(ReturnRef(empty_policy_map));
-
- handler_.EnableCloudReportingExtension(true);
+ .WillOnce(ReturnRef(chrome_policies));
+ SetPolicyValue(policy::key::kCloudReportingEnabled, true, chrome_policies);
std::set<std::string> expected_messages = {
kManagementExtensionReportMachineNameAddress,
kManagementExtensionReportUsername,
kManagementExtensionReportVersion,
kManagementExtensionReportExtensionsPlugin,
- kManagementExtensionReportSafeBrowsingWarnings,
kManagementExtensionReportUserBrowsingData,
kManagementExtensionReportPerfCrash};
@@ -1178,9 +1144,9 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
builder_known_domain.SetProfileName("managed@manager.com");
auto profile_known_domain = builder_known_domain.Build();
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
handler_.SetDeviceDomain("");
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
EXPECT_CALL(policy_service_, GetPolicies(chrome_policies_namespace))
.WillRepeatedly(ReturnRef(chrome_policies));
@@ -1275,7 +1241,7 @@ TEST_F(ManagementUIHandlerTests, GetAccountManager) {
builder_managed_user.SetProfileName(kUser);
builder_managed_user.OverridePolicyConnectorIsManagedForTesting(true);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr);
std::unique_ptr<TestingProfileManager> profile_manager =
std::make_unique<TestingProfileManager>(
@@ -1288,7 +1254,7 @@ TEST_F(ManagementUIHandlerTests, GetAccountManager) {
#endif
auto managed_user = builder_managed_user.Build();
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
policy::UserCloudPolicyManagerChromeOS* policy_manager =
managed_user->GetUserCloudPolicyManagerChromeOS();
policy::MockCloudPolicyStore* mock_store =
diff --git a/chromium/chrome/browser/ui/webui/media/DIR_METADATA b/chromium/chrome/browser/ui/webui/media/DIR_METADATA
new file mode 100644
index 00000000000..85c8924d1fe
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/media/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "Internals>Media>UI"
+}
diff --git a/chromium/chrome/browser/ui/webui/media/OWNERS b/chromium/chrome/browser/ui/webui/media/OWNERS
index 77384f3c0f9..8e63383c5ab 100644
--- a/chromium/chrome/browser/ui/webui/media/OWNERS
+++ b/chromium/chrome/browser/ui/webui/media/OWNERS
@@ -1,8 +1,5 @@
# For Media Engagement
mlamouri@chromium.org
-beccahughes@chromium.org
# For WebRTC
per-file webrtc_*=file://third_party/webrtc_overrides/OWNERS
-
-# COMPONENT: Internals>Media>UI
diff --git a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
index 2c749047aa0..5a0d1af56b6 100644
--- a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
@@ -84,7 +84,6 @@ class MediaEngagementScoreDetailsProviderImpl
base::FeatureList::IsEnabled(media::kPreloadMediaEngagementData),
base::FeatureList::IsEnabled(media::kMediaEngagementHTTPSOnly),
base::FeatureList::IsEnabled(media::kAutoplayDisableSettings),
- base::FeatureList::IsEnabled(media::kAutoplayWhitelistSettings),
GetBlockAutoplayPref(),
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAutoplayPolicy),
@@ -145,10 +144,9 @@ MediaEngagementUI::MediaEngagementUI(content::WebUI* web_ui)
// Setup the data source behind chrome://media-engagement.
std::unique_ptr<content::WebUIDataSource> source(
content::WebUIDataSource::Create(chrome::kChromeUIMediaEngagementHost));
- source->AddResourcePath("media-engagement.js", IDR_MEDIA_ENGAGEMENT_JS);
- source->AddResourcePath(
- "chrome/browser/media/media_engagement_score_details.mojom-lite.js",
- IDR_MEDIA_ENGAGEMENT_SCORE_DETAILS_MOJOM_LITE_JS);
+ source->AddResourcePath("media_engagement.js", IDR_MEDIA_ENGAGEMENT_JS);
+ source->AddResourcePath("media_engagement_score_details.mojom-lite.js",
+ IDR_MEDIA_ENGAGEMENT_SCORE_DETAILS_MOJOM_LITE_JS);
source->SetDefaultResource(IDR_MEDIA_ENGAGEMENT_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source.release());
}
diff --git a/chromium/chrome/browser/ui/webui/media/media_feeds_ui.cc b/chromium/chrome/browser/ui/webui/media/media_feeds_ui.cc
index 5ef3915cd3f..96be7482240 100644
--- a/chromium/chrome/browser/ui/webui/media/media_feeds_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/media_feeds_ui.cc
@@ -33,16 +33,14 @@ MediaFeedsUI::MediaFeedsUI(content::WebUI* web_ui)
// Setup the data source behind chrome://media-feeds.
std::unique_ptr<content::WebUIDataSource> source(
content::WebUIDataSource::Create(chrome::kChromeUIMediaFeedsHost));
- source->AddResourcePath("media-data-table.js", IDR_MEDIA_DATA_TABLE_JS);
- source->AddResourcePath("media-feeds.js", IDR_MEDIA_FEEDS_JS);
- source->AddResourcePath(
- "services/media_session/public/mojom/media_session.mojom-lite.js",
- IDR_MEDIA_SESSION_MOJOM_LITE_JS);
+ source->AddResourcePath("media_data_table.js", IDR_MEDIA_DATA_TABLE_JS);
+ source->AddResourcePath("media_feeds.js", IDR_MEDIA_FEEDS_JS);
+ source->AddResourcePath("media_session.mojom-lite.js",
+ IDR_MEDIA_SESSION_MOJOM_LITE_JS);
source->AddResourcePath("ui/gfx/geometry/mojom/geometry.mojom-lite.js",
IDR_UI_GEOMETRY_MOJOM_LITE_JS);
- source->AddResourcePath(
- "chrome/browser/media/feeds/media_feeds_store.mojom-lite.js",
- IDR_MEDIA_FEEDS_STORE_MOJOM_LITE_JS);
+ source->AddResourcePath("media_feeds_store.mojom-lite.js",
+ IDR_MEDIA_FEEDS_STORE_MOJOM_LITE_JS);
source->SetDefaultResource(IDR_MEDIA_FEEDS_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source.release());
}
diff --git a/chromium/chrome/browser/ui/webui/media/media_history_ui.cc b/chromium/chrome/browser/ui/webui/media/media_history_ui.cc
index 6f432397756..46035f47334 100644
--- a/chromium/chrome/browser/ui/webui/media/media_history_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/media_history_ui.cc
@@ -25,16 +25,14 @@ MediaHistoryUI::MediaHistoryUI(content::WebUI* web_ui)
// Setup the data source behind chrome://media-history.
std::unique_ptr<content::WebUIDataSource> source(
content::WebUIDataSource::Create(chrome::kChromeUIMediaHistoryHost));
- source->AddResourcePath("media-data-table.js", IDR_MEDIA_DATA_TABLE_JS);
- source->AddResourcePath("media-history.js", IDR_MEDIA_HISTORY_JS);
- source->AddResourcePath(
- "services/media_session/public/mojom/media_session.mojom-lite.js",
- IDR_MEDIA_SESSION_MOJOM_LITE_JS);
+ source->AddResourcePath("media_data_table.js", IDR_MEDIA_DATA_TABLE_JS);
+ source->AddResourcePath("media_history.js", IDR_MEDIA_HISTORY_JS);
+ source->AddResourcePath("media_session.mojom-lite.js",
+ IDR_MEDIA_SESSION_MOJOM_LITE_JS);
source->AddResourcePath("ui/gfx/geometry/mojom/geometry.mojom-lite.js",
IDR_UI_GEOMETRY_MOJOM_LITE_JS);
- source->AddResourcePath(
- "chrome/browser/media/history/media_history_store.mojom-lite.js",
- IDR_MEDIA_HISTORY_STORE_MOJOM_LITE_JS);
+ source->AddResourcePath("media_history_store.mojom-lite.js",
+ IDR_MEDIA_HISTORY_STORE_MOJOM_LITE_JS);
source->SetDefaultResource(IDR_MEDIA_HISTORY_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source.release());
}
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 dd531c8f1f7..33b26103982 100644
--- a/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
@@ -19,6 +19,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/webrtc/webrtc_event_log_manager.h"
#include "chrome/browser/profiles/profile.h"
@@ -26,6 +27,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/webrtc_logs_resources.h"
+#include "chrome/grit/webrtc_logs_resources_map.h"
#include "components/prefs/pref_service.h"
#include "components/upload_list/upload_list.h"
#include "components/version_info/version_info.h"
@@ -37,10 +39,6 @@
#include "content/public/browser/web_ui_message_handler.h"
#include "ui/base/webui/web_ui_util.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#endif
-
using content::WebContents;
using content::WebUIMessageHandler;
@@ -74,11 +72,12 @@ content::WebUIDataSource* CreateWebRtcLogsUIHTMLSource() {
{"noTextLogsMessage", IDS_WEBRTC_LOGS_NO_TEXT_LOGS_MESSAGE},
{"noEventLogsMessage", IDS_WEBRTC_LOGS_NO_EVENT_LOGS_MESSAGE},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->UseStringsJs();
- source->AddResourcePath("webrtc_logs.js", IDR_WEBRTC_LOGS_JS);
- source->SetDefaultResource(IDR_WEBRTC_LOGS_HTML);
+ source->AddResourcePaths(
+ base::make_span(kWebrtcLogsResources, kWebrtcLogsResourcesSize));
+ source->SetDefaultResource(IDR_WEBRTC_LOGS_WEBRTC_LOGS_HTML);
return source;
}
@@ -265,11 +264,12 @@ void WebRtcLogsDOMHandler::UpdateUIWithTextLogs(
value_w = base::TimeFormatFriendlyDateAndTime(i->upload_time);
upload->SetString("upload_time", value_w);
- base::FilePath::StringType value;
- if (!i->local_id.empty())
+ std::string value;
+ if (!i->local_id.empty()) {
value = text_log_dir_.AppendASCII(i->local_id)
.AddExtension(FILE_PATH_LITERAL(".gz"))
- .value();
+ .AsUTF8Unsafe();
+ }
upload->SetString("local_file", value);
// In october 2015, capture time was added to the log list, previously the
@@ -352,7 +352,7 @@ std::unique_ptr<base::DictionaryValue> WebRtcLogsDOMHandler::FromPendingLog(
log->SetString("capture_time",
base::TimeFormatFriendlyDateAndTime(info.capture_time));
log->SetString("local_file",
- event_log_dir_.AppendASCII(info.local_id).value());
+ event_log_dir_.AppendASCII(info.local_id).AsUTF8Unsafe());
return log;
}
@@ -371,7 +371,7 @@ WebRtcLogsDOMHandler::FromActivelyUploadedLog(
log->SetString("capture_time",
base::TimeFormatFriendlyDateAndTime(info.capture_time));
log->SetString("local_file",
- event_log_dir_.AppendASCII(info.local_id).value());
+ event_log_dir_.AppendASCII(info.local_id).AsUTF8Unsafe());
return log;
}
diff --git a/chromium/chrome/browser/ui/webui/media_router/DIR_METADATA b/chromium/chrome/browser/ui/webui/media_router/DIR_METADATA
new file mode 100644
index 00000000000..dd4ac9a4df1
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/media_router/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "Internals>Cast>UI"
+}
diff --git a/chromium/chrome/browser/ui/webui/media_router/OWNERS b/chromium/chrome/browser/ui/webui/media_router/OWNERS
index fda51ea2bfc..dd66178316e 100644
--- a/chromium/chrome/browser/ui/webui/media_router/OWNERS
+++ b/chromium/chrome/browser/ui/webui/media_router/OWNERS
@@ -1,3 +1 @@
file://chrome/browser/media/router/OWNERS
-
-# COMPONENT: Internals>Cast>UI
diff --git a/chromium/chrome/browser/ui/webui/memories/BUILD.gn b/chromium/chrome/browser/ui/webui/memories/BUILD.gn
new file mode 100644
index 00000000000..5546bb266a9
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/memories/BUILD.gn
@@ -0,0 +1,11 @@
+# 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.
+
+import("//mojo/public/tools/bindings/mojom.gni")
+
+mojom("mojo_bindings") {
+ sources = [ "memories.mojom" ]
+ webui_module_path = "/chrome/browser/ui/webui/memories"
+ public_deps = [ "//components/memories/core:mojo_bindings" ]
+}
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/OWNERS b/chromium/chrome/browser/ui/webui/memories/OWNERS
index 0c12544c8aa..d9c10308fea 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/memories/OWNERS
@@ -1,6 +1,4 @@
-file://components/data_reduction_proxy/OWNERS
+file://components/memories/OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: Blink>Previews
diff --git a/chromium/chrome/browser/ui/webui/memories/memories.mojom b/chromium/chrome/browser/ui/webui/memories/memories.mojom
new file mode 100644
index 00000000000..e644c7a9978
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/memories/memories.mojom
@@ -0,0 +1,37 @@
+// 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.
+
+module memories.mojom;
+
+import "components/memories/core/memories.mojom";
+import "mojo/public/mojom/base/string16.mojom";
+import "url/mojom/url.mojom";
+
+// Represents a set of Memories returned by the browser in response to a request
+// for Memories related to a given query or within a given timespan.
+// Optionally accompanied by a title and a thumbnail representing the Memoires
+// in the set.
+struct MemoriesResult {
+ // Optional human readable title representing the Memories in the result set.
+ mojo_base.mojom.String16? title;
+ // Optional externally hosted thumbnail representing the Memories in the
+ // result set.
+ url.mojom.Url? thumbnail_url;
+ // The Memories in the result set.
+ array<memories.mojom.Memory> memories;
+};
+
+// Browser-side handler for requests from WebUI page.
+interface PageHandler {
+ // The MemoriesBrowserProxy singleton calls this when it's first initialized.
+ SetPage(pending_remote<Page> page);
+
+ // Returns sample Memories related to |query| for experimentation with a POC.
+ // TODO(crbug.com/1179069): Remove this when real Memories are available.
+ GetSampleMemories(string query) => (MemoriesResult result);
+};
+
+// WebUI-side handler for requests from the browser.
+interface Page {
+};
diff --git a/chromium/chrome/browser/ui/webui/memories/memories_handler.cc b/chromium/chrome/browser/ui/webui/memories/memories_handler.cc
new file mode 100644
index 00000000000..92cb5dbb908
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/memories/memories_handler.cc
@@ -0,0 +1,216 @@
+// 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.
+
+#include "chrome/browser/ui/webui/memories/memories_handler.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/web_contents.h"
+
+#if !defined(OFFICIAL_BUILD)
+#include "base/bind.h"
+#include "base/containers/contains.h"
+#include "base/containers/flat_map.h"
+#include "base/i18n/case_conversion.h"
+#include "base/i18n/time_formatting.h"
+#include "base/stl_util.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/time/time.h"
+#include "base/unguessable_token.h"
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/history/history_service_factory.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/tabs/tab_group.h"
+#include "chrome/browser/ui/tabs/tab_group_model.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "components/bookmarks/browser/bookmark_model.h"
+#include "components/bookmarks/browser/url_and_title.h"
+#include "components/history/core/browser/history_service.h"
+#include "components/history/core/browser/history_types.h"
+#include "components/search_engines/template_url_service.h"
+#include "components/tab_groups/tab_group_id.h"
+#endif
+
+MemoriesHandler::MemoriesHandler(
+ mojo::PendingReceiver<memories::mojom::PageHandler> pending_page_handler,
+ Profile* profile,
+ content::WebContents* web_contents)
+ : profile_(profile),
+ web_contents_(web_contents),
+ page_handler_(this, std::move(pending_page_handler)) {
+ DCHECK(profile_);
+ DCHECK(web_contents_);
+}
+
+MemoriesHandler::~MemoriesHandler() = default;
+
+void MemoriesHandler::SetPage(
+ mojo::PendingRemote<memories::mojom::Page> pending_page) {
+ page_.Bind(std::move(pending_page));
+}
+
+void MemoriesHandler::GetSampleMemories(const std::string& query,
+ MemoriesResultCallback callback) {
+#if defined(OFFICIAL_BUILD)
+ std::move(callback).Run({});
+ return;
+#else
+ // Query HistoryService for URLs containing |query|.
+ history::HistoryService* history_service =
+ HistoryServiceFactory::GetForProfile(profile_,
+ ServiceAccessType::EXPLICIT_ACCESS);
+ history::QueryOptions query_options;
+ query_options.duplicate_policy = history::QueryOptions::KEEP_ALL_DUPLICATES;
+ query_options.SetRecentDayRange(90);
+ history_service->QueryHistory(
+ base::UTF8ToUTF16(query), query_options,
+ base::BindOnce(&MemoriesHandler::OnHistoryQueryResults,
+ weak_ptr_factory_.GetWeakPtr(), query,
+ std::move(callback)),
+ &history_task_tracker_);
+}
+
+void MemoriesHandler::OnHistoryQueryResults(const std::string& query,
+ MemoriesResultCallback callback,
+ history::QueryResults results) {
+ auto memories_result_mojom = memories::mojom::MemoriesResult::New();
+ memories_result_mojom->title =
+ base::UTF8ToUTF16("Related to \"" + query + "\"");
+ memories_result_mojom->thumbnail_url =
+ GURL("https://via.placeholder.com/200");
+
+ auto memory_mojom = memories::mojom::Memory::New();
+ memory_mojom->id = base::UnguessableToken::Create();
+
+ const TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ const TemplateURL* default_search_provider =
+ template_url_service->GetDefaultSearchProvider();
+ const SearchTermsData& search_terms_data =
+ template_url_service->search_terms_data();
+
+ for (const auto& result : results) {
+ // Last visit time of the Memory is that of the most recently visited URL.
+ if (memory_mojom->last_visit_time.is_null()) {
+ memory_mojom->last_visit_time = result.visit_time();
+ }
+
+ // Keep track of all the visited URLs.
+ auto webpage = memories::mojom::WebPage::New();
+ webpage->url = result.url();
+ webpage->title = result.title();
+ webpage->thumbnail_url = GURL("https://via.placeholder.com/200");
+ memory_mojom->pages[result.url()] = std::move(webpage);
+
+ // Check if the URL is a valid search URL.
+ base::string16 search_terms;
+ bool is_valid_search_url =
+ default_search_provider &&
+ default_search_provider->ExtractSearchTermsFromURL(
+ result.url(), search_terms_data, &search_terms) &&
+ !search_terms.empty();
+ if (is_valid_search_url) {
+ // If the URL is a valid search URL, try to create a related search query.
+ const base::string16& search_query =
+ base::i18n::ToLower(base::CollapseWhitespace(search_terms, false));
+
+ // Skip duplicate search queries.
+ if (base::Contains(memory_mojom->related_searches, search_query,
+ [](const auto& search_query_ptr) {
+ return search_query_ptr->query;
+ })) {
+ continue;
+ }
+
+ TemplateURLRef::SearchTermsArgs search_terms_args(search_query);
+ const TemplateURLRef& search_url_ref = default_search_provider->url_ref();
+ const std::string& search_url = search_url_ref.ReplaceSearchTerms(
+ search_terms_args, search_terms_data);
+ auto search_query_mojom = memories::mojom::SearchQuery::New();
+ search_query_mojom->query = search_query;
+ search_query_mojom->url = GURL(search_url);
+ memory_mojom->related_searches.push_back(std::move(search_query_mojom));
+ } else { // !is_valid_search_url
+ // If the URL is not a search URL, try to add the visit to the top visits.
+ auto visit = memories::mojom::Visit::New();
+ // TOOD(mahmadi): URLResult does not contain visit_id.
+ visit->url = result.url();
+ visit->time = result.visit_time();
+
+ std::function<void(std::vector<memories::mojom::VisitPtr>&, bool)>
+ add_visit;
+ add_visit = [&visit, &add_visit](auto& visits, bool are_top_visits) {
+ // Count |visit| toward duplicate visits if the same URL is seen before.
+ auto duplicate_visit_it = std::find_if(
+ visits.begin(), visits.end(), [&visit](const auto& visit_ptr) {
+ return visit_ptr->url == visit->url;
+ });
+ if (duplicate_visit_it != visits.end()) {
+ (*duplicate_visit_it)->num_duplicate_visits++;
+ return;
+ }
+ // For the top visits, if the domain name is seen before, add |visit| to
+ // the related visits of the respective top visit recursively.
+ if (are_top_visits) {
+ auto related_visit_it = std::find_if(
+ visits.begin(), visits.end(), [&visit](const auto& visit_ptr) {
+ return visit_ptr->url.host() == visit->url.host();
+ });
+ if (related_visit_it != visits.end()) {
+ add_visit((*related_visit_it)->related_visits, false);
+ return;
+ }
+ }
+ // Otherwise, simply add |visit| to the list of visits.
+ visits.push_back(std::move(visit));
+ };
+ add_visit(memory_mojom->top_visits, true);
+ }
+ }
+
+ // Add related tab groups (tab groups containing any of the visited URLs).
+ Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
+ if (browser) {
+ const TabStripModel* tab_strip_model = browser->tab_strip_model();
+ const TabGroupModel* group_model = tab_strip_model->group_model();
+ for (const auto& group_id : group_model->ListTabGroups()) {
+ std::vector<GURL> related_tab_group_urls;
+ const TabGroup* tab_group = group_model->GetTabGroup(group_id);
+ gfx::Range tabs = tab_group->ListTabs();
+ for (uint32_t index = tabs.start(); index < tabs.end(); ++index) {
+ content::WebContents* web_contents =
+ tab_strip_model->GetWebContentsAt(index);
+ const GURL& url = web_contents->GetLastCommittedURL();
+ if (base::Contains(memory_mojom->pages, url)) {
+ related_tab_group_urls.push_back(url);
+ }
+ }
+ if (!related_tab_group_urls.empty()) {
+ auto tab_group_mojom = memories::mojom::TabGroup::New();
+ tab_group_mojom->id = tab_group->id().token();
+ tab_group_mojom->title = tab_group->visual_data()->title();
+ tab_group_mojom->urls = related_tab_group_urls;
+ memory_mojom->related_tab_groups.push_back(std::move(tab_group_mojom));
+ }
+ }
+ }
+
+ // Add related bookmarks (bookmarked URLs among the visited URLs).
+ bookmarks::BookmarkModel* model =
+ BookmarkModelFactory::GetForBrowserContext(profile_);
+ if (model && model->loaded()) {
+ std::vector<bookmarks::UrlAndTitle> bookmarks;
+ model->GetBookmarks(&bookmarks);
+ for (const auto& bookmark : bookmarks) {
+ if (base::Contains(memory_mojom->pages, bookmark.url)) {
+ memory_mojom->bookmarks.push_back(bookmark.url);
+ }
+ }
+ }
+
+ memories_result_mojom->memories.push_back(std::move(memory_mojom));
+ std::move(callback).Run(std::move(memories_result_mojom));
+#endif
+}
diff --git a/chromium/chrome/browser/ui/webui/memories/memories_handler.h b/chromium/chrome/browser/ui/webui/memories/memories_handler.h
new file mode 100644
index 00000000000..f8079b32f8d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/memories/memories_handler.h
@@ -0,0 +1,72 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_MEMORIES_MEMORIES_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_MEMORIES_MEMORIES_HANDLER_H_
+
+#include "chrome/browser/ui/webui/memories/memories.mojom.h"
+#include "components/memories/core/memories.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"
+
+#if !defined(OFFICIAL_BUILD)
+#include "base/memory/weak_ptr.h"
+#include "base/task/cancelable_task_tracker.h"
+#endif
+
+class Profile;
+
+namespace content {
+class WebContents;
+} // namespace content
+
+#if !defined(OFFICIAL_BUILD)
+namespace history {
+class QueryResults;
+} // namespace history
+#endif
+
+// Handles bidirectional communication between memories page and the browser.
+class MemoriesHandler : public memories::mojom::PageHandler {
+ public:
+ MemoriesHandler(
+ mojo::PendingReceiver<memories::mojom::PageHandler> pending_page_handler,
+ Profile* profile,
+ content::WebContents* web_contents);
+ ~MemoriesHandler() override;
+
+ MemoriesHandler(const MemoriesHandler&) = delete;
+ MemoriesHandler& operator=(const MemoriesHandler&) = delete;
+
+ // memories::mojom::PageHandler:
+ void SetPage(
+ mojo::PendingRemote<memories::mojom::Page> pending_page) override;
+
+ using MemoriesResultCallback =
+ base::OnceCallback<void(memories::mojom::MemoriesResultPtr)>;
+ void GetSampleMemories(const std::string& query,
+ MemoriesResultCallback callback) override;
+
+ private:
+#if !defined(OFFICIAL_BUILD)
+ void OnHistoryQueryResults(const std::string& query,
+ MemoriesResultCallback callback,
+ history::QueryResults results);
+#endif
+
+ Profile* profile_;
+ content::WebContents* web_contents_;
+
+ mojo::Remote<memories::mojom::Page> page_;
+ mojo::Receiver<memories::mojom::PageHandler> page_handler_;
+
+#if !defined(OFFICIAL_BUILD)
+ base::CancelableTaskTracker history_task_tracker_;
+ base::WeakPtrFactory<MemoriesHandler> weak_ptr_factory_{this};
+#endif
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_MEMORIES_MEMORIES_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/memories/memories_ui.cc b/chromium/chrome/browser/ui/webui/memories/memories_ui.cc
new file mode 100644
index 00000000000..2b355e73412
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/memories/memories_ui.cc
@@ -0,0 +1,59 @@
+// 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.
+
+#include "chrome/browser/ui/webui/memories/memories_ui.h"
+
+#include "base/logging.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/memories/memories_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/memories_resources.h"
+#include "chrome/grit/memories_resources_map.h"
+#include "components/strings/grit/components_strings.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/base/webui/web_ui_util.h"
+
+namespace {
+
+content::WebUIDataSource* CreateAndSetupWebUIDataSource() {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIMemoriesHost);
+
+ static constexpr webui::LocalizedString kStrings[] = {
+ {"title", IDS_MEMORIES_PAGE_TITLE},
+ };
+ source->AddLocalizedStrings(kStrings);
+
+ webui::SetupWebUIDataSource(
+ source, base::make_span(kMemoriesResources, kMemoriesResourcesSize),
+ IDR_MEMORIES_MEMORIES_HTML);
+
+ return source;
+}
+
+} // namespace
+
+MemoriesUI::MemoriesUI(content::WebUI* web_ui)
+ : ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true),
+ profile_(Profile::FromWebUI(web_ui)),
+ web_contents_(web_ui->GetWebContents()) {
+ DCHECK(profile_);
+ DCHECK(web_contents_);
+
+ auto* source = CreateAndSetupWebUIDataSource();
+ content::WebUIDataSource::Add(profile_, source);
+}
+
+WEB_UI_CONTROLLER_TYPE_IMPL(MemoriesUI)
+
+MemoriesUI::~MemoriesUI() = default;
+
+void MemoriesUI::BindInterface(
+ mojo::PendingReceiver<memories::mojom::PageHandler> pending_page_handler) {
+ memories_handler_ = std::make_unique<MemoriesHandler>(
+ std::move(pending_page_handler), profile_, web_contents_);
+}
diff --git a/chromium/chrome/browser/ui/webui/memories/memories_ui.h b/chromium/chrome/browser/ui/webui/memories/memories_ui.h
new file mode 100644
index 00000000000..df7f2a0a24f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/memories/memories_ui.h
@@ -0,0 +1,42 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_MEMORIES_MEMORIES_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_MEMORIES_MEMORIES_UI_H_
+
+#include "chrome/browser/ui/webui/memories/memories.mojom-forward.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "ui/webui/mojo_web_ui_controller.h"
+
+class Profile;
+class MemoriesHandler;
+
+namespace content {
+class WebContents;
+class WebUI;
+} // namespace content
+
+// The UI for chrome://memories/
+class MemoriesUI : public ui::MojoWebUIController {
+ public:
+ explicit MemoriesUI(content::WebUI* contents);
+ ~MemoriesUI() override;
+
+ MemoriesUI(const MemoriesUI&) = delete;
+ MemoriesUI& operator=(const MemoriesUI&) = delete;
+
+ // Instantiates the implementor of the memories::mojom::PageHandler mojo
+ // interface passing to it the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<memories::mojom::PageHandler> pending_page_handler);
+
+ private:
+ Profile* profile_;
+ content::WebContents* web_contents_;
+ std::unique_ptr<MemoriesHandler> memories_handler_;
+
+ WEB_UI_CONTROLLER_TYPE_DECL();
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_MEMORIES_MEMORIES_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/nacl_ui.cc b/chromium/chrome/browser/ui/webui/nacl_ui.cc
index 0f1501d383d..fb64c79f136 100644
--- a/chromium/chrome/browser/ui/webui/nacl_ui.cc
+++ b/chromium/chrome/browser/ui/webui/nacl_ui.cc
@@ -88,6 +88,7 @@ class NaClDomHandler : public WebUIMessageHandler {
// WebUIMessageHandler implementation.
void RegisterMessages() override;
+ void OnJavascriptDisallowed() override;
private:
// Callback for the "requestNaClInfo" message.
@@ -136,7 +137,6 @@ class NaClDomHandler : public WebUIMessageHandler {
bool pnacl_path_exists_;
std::string pnacl_version_string_;
- // Factory for the creating refs in callbacks.
base::WeakPtrFactory<NaClDomHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NaClDomHandler);
@@ -146,12 +146,9 @@ NaClDomHandler::NaClDomHandler()
: has_plugin_info_(false),
pnacl_path_validated_(false),
pnacl_path_exists_(false) {
- PluginService::GetInstance()->GetPlugins(base::BindOnce(
- &NaClDomHandler::OnGotPlugins, weak_ptr_factory_.GetWeakPtr()));
}
-NaClDomHandler::~NaClDomHandler() {
-}
+NaClDomHandler::~NaClDomHandler() = default;
void NaClDomHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
@@ -160,6 +157,10 @@ void NaClDomHandler::RegisterMessages() {
base::Unretained(this)));
}
+void NaClDomHandler::OnJavascriptDisallowed() {
+ weak_ptr_factory_.InvalidateWeakPtrs();
+}
+
void AddPair(base::ListValue* list,
const base::string16& key,
const base::string16& value) {
@@ -305,6 +306,11 @@ void NaClDomHandler::HandleRequestNaClInfo(const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
callback_id_ = args->GetList()[0].GetString();
+ if (!has_plugin_info_) {
+ PluginService::GetInstance()->GetPlugins(base::BindOnce(
+ &NaClDomHandler::OnGotPlugins, weak_ptr_factory_.GetWeakPtr()));
+ }
+
// Force re-validation of PNaCl's path in the next call to
// MaybeRespondToPage(), in case PNaCl went from not-installed
// to installed since the request.
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/DIR_METADATA b/chromium/chrome/browser/ui/webui/nearby_internals/DIR_METADATA
new file mode 100644
index 00000000000..76bc6b2fa76
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "OS>Systems>Multidevice>Nearby"
+}
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/OWNERS b/chromium/chrome/browser/ui/webui/nearby_internals/OWNERS
index 19414dc942a..b76a3f65088 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/OWNERS
@@ -1,4 +1,2 @@
file://chrome/browser/nearby_sharing/OWNERS
khorimoto@chromium.org
-
-# COMPONENT: OS>Systems>Multidevice>Nearby
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 1264b4b2e7b..4e0f1fd14fa 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
@@ -104,14 +104,14 @@ void NearbyInternalsContactHandler::OnJavascriptAllowed() {
NearbySharingService* service_ =
NearbySharingServiceFactory::GetForBrowserContext(context_);
if (service_) {
- observer_.Add(service_->GetContactManager());
+ observation_.Observe(service_->GetContactManager());
} else {
NS_LOG(ERROR) << "No NearbyShareService instance to call.";
}
}
void NearbyInternalsContactHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void NearbyInternalsContactHandler::InitializeContents(
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h
index 02a568fe996..a5bd632a996 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h
@@ -11,7 +11,7 @@
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/nearby_sharing/contacts/nearby_share_contact_manager.h"
#include "chrome/browser/nearby_sharing/proto/rpc_resources.pb.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -57,8 +57,9 @@ class NearbyInternalsContactHandler
void HandleDownloadContacts(const base::ListValue* args);
content::BrowserContext* context_;
- ScopedObserver<NearbyShareContactManager, NearbyShareContactManager::Observer>
- observer_{this};
+ base::ScopedObservation<NearbyShareContactManager,
+ NearbyShareContactManager::Observer>
+ observation_{this};
base::WeakPtrFactory<NearbyInternalsContactHandler> weak_ptr_factory_{this};
};
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 6d0f2427615..83260cefe88 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
@@ -96,14 +96,14 @@ void NearbyInternalsHttpHandler::OnJavascriptAllowed() {
NearbySharingService* service_ =
NearbySharingServiceFactory::GetForBrowserContext(context_);
if (service_) {
- observer_.Add(service_->GetHttpNotifier());
+ observation_.Observe(service_->GetHttpNotifier());
} else {
NS_LOG(ERROR) << "No NearbyShareService instance to call.";
}
}
void NearbyInternalsHttpHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void NearbyInternalsHttpHandler::InitializeContents(
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h
index da37e13c58b..62bfaaabcbe 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_NEARBY_INTERNALS_NEARBY_INTERNALS_HTTP_HANDLER_H_
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/nearby_sharing/client/nearby_share_http_notifier.h"
#include "chrome/browser/nearby_sharing/proto/certificate_rpc.pb.h"
#include "chrome/browser/nearby_sharing/proto/contact_rpc.pb.h"
@@ -67,8 +67,9 @@ class NearbyInternalsHttpHandler : public content::WebUIMessageHandler,
void ListContactPeople(const base::ListValue* args);
content::BrowserContext* const context_;
- ScopedObserver<NearbyShareHttpNotifier, NearbyShareHttpNotifier::Observer>
- observer_{this};
+ base::ScopedObservation<NearbyShareHttpNotifier,
+ NearbyShareHttpNotifier::Observer>
+ observation_{this};
base::WeakPtrFactory<NearbyInternalsHttpHandler> weak_ptr_factory_{this};
};
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 ba44fc29716..e72da2fb837 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
@@ -31,7 +31,7 @@ base::Value LogMessageToDictionary(const LogBuffer::LogMessage& log_message) {
}
} // namespace
-NearbyInternalsLogsHandler::NearbyInternalsLogsHandler() : observer_(this) {}
+NearbyInternalsLogsHandler::NearbyInternalsLogsHandler() {}
NearbyInternalsLogsHandler::~NearbyInternalsLogsHandler() = default;
@@ -43,11 +43,11 @@ void NearbyInternalsLogsHandler::RegisterMessages() {
}
void NearbyInternalsLogsHandler::OnJavascriptAllowed() {
- observer_.Add(LogBuffer::GetInstance());
+ observation_.Observe(LogBuffer::GetInstance());
}
void NearbyInternalsLogsHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void NearbyInternalsLogsHandler::HandleGetLogMessages(
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 3ba482bdf15..48b69272700 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
@@ -5,7 +5,7 @@
#define CHROME_BROWSER_UI_WEBUI_NEARBY_INTERNALS_NEARBY_INTERNALS_LOGS_HANDLER_H_
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/values.h"
#include "chrome/browser/nearby_sharing/logging/log_buffer.h"
#include "chrome/browser/nearby_sharing/logging/logging.h"
@@ -42,7 +42,7 @@ class NearbyInternalsLogsHandler : public content::WebUIMessageHandler,
// Message handler callback that clears the Log Buffer.
void ClearLogBuffer(const base::ListValue* args);
- ScopedObserver<LogBuffer, LogBuffer::Observer> observer_{this};
+ 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.cc b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui.cc
index 61d2599fbb1..5da4c4360bd 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui.cc
@@ -37,7 +37,7 @@ NearbyInternalsUI::NearbyInternalsUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource(
html_source,
base::make_span(kNearbyInternalsResources, kNearbyInternalsResourcesSize),
- /*generated_path=*/std::string(), IDR_NEARBY_INTERNALS_INDEX_HTML);
+ IDR_NEARBY_INTERNALS_INDEX_HTML);
content::WebUIDataSource::Add(profile, html_source);
content::BrowserContext* context =
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 4bec9d0c14f..8ff79d7046e 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
@@ -28,6 +28,15 @@ const char kStatusCodeKey[] = "statusCode";
const char kTriggerEventKey[] = "triggerEvent";
const char kTransferUpdateMetaDataKey[] = "transfer_metadataStatus";
+// Keys in the JSON representation of a dictiory send to UITriggerTab for
+// the state of the transfer.
+const char kIsConnecting[] = "isConnecting";
+const char kIsInHighVisibility[] = "isInHighVisibility";
+const char kIsReceiving[] = "isReceiving";
+const char kIsScanning[] = "isScanning";
+const char kIsSending[] = "isSending";
+const char kIsTransferring[] = "isTransferring";
+
// TriggerEvents in alphabetical order.
enum class TriggerEvent {
kAccept,
@@ -61,6 +70,8 @@ std::string StatusCodeToString(
return "STATUS ALREADY STOPPED";
case NearbySharingService::StatusCodes::kTransferAlreadyInProgress:
return "TRANSFER ALREADY IN PROGRESS";
+ case NearbySharingService::StatusCodes::kNoAvailableConnectionMedium:
+ return "NO AVAILABLE CONNECTION MEDIUM";
}
}
@@ -182,6 +193,23 @@ base::Value TransferUpdateToDictionary(
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 dictionary(base::Value::Type::DICTIONARY);
+ dictionary.SetBoolKey(kIsScanning, is_scanning);
+ dictionary.SetBoolKey(kIsTransferring, is_transferring);
+ dictionary.SetBoolKey(kIsSending, is_sending_files);
+ dictionary.SetBoolKey(kIsReceiving, is_receiving_files);
+ dictionary.SetBoolKey(kIsConnecting, is_conecting);
+ dictionary.SetBoolKey(kIsInHighVisibility, is_in_high_visibility);
+ dictionary.SetKey(kTimeStampKey, GetJavascriptTimestamp());
+ return dictionary;
+}
+
} // namespace
NearbyInternalsUiTriggerHandler::NearbyInternalsUiTriggerHandler(
@@ -241,6 +269,10 @@ void NearbyInternalsUiTriggerHandler::RegisterMessages() {
base::BindRepeating(
&NearbyInternalsUiTriggerHandler::UnregisterReceiveSurface,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getStates",
+ base::BindRepeating(&NearbyInternalsUiTriggerHandler::GetState,
+ base::Unretained(this)));
}
void NearbyInternalsUiTriggerHandler::InitializeContents(
@@ -421,7 +453,8 @@ void NearbyInternalsUiTriggerHandler::SendText(const base::ListValue* args) {
std::vector<std::unique_ptr<Attachment>> attachments;
attachments.push_back(std::make_unique<TextAttachment>(
- TextAttachment::Type::kText, kPayloadExample));
+ TextAttachment::Type::kText, kPayloadExample, /*title=*/base::nullopt,
+ /*mime_type=*/base::nullopt));
const base::Value& callback_id = args->GetList()[0];
ResolveJavascriptCallback(
@@ -517,3 +550,20 @@ void NearbyInternalsUiTriggerHandler::Cancel(const base::ListValue* args) {
base::BindOnce(&NearbyInternalsUiTriggerHandler::OnCancelCalled,
weak_ptr_factory_.GetWeakPtr()));
}
+
+void NearbyInternalsUiTriggerHandler::GetState(const base::ListValue* args) {
+ NearbySharingService* service_ =
+ NearbySharingServiceFactory::GetForBrowserContext(context_);
+ if (!service_) {
+ NS_LOG(ERROR) << "No NearbyShareService instance to call.";
+ return;
+ }
+
+ const base::Value& callback_id = args->GetList()[0];
+ ResolveJavascriptCallback(
+ callback_id,
+ StatusBooleansToDictionary(
+ service_->IsScanning(), service_->IsTransferring(),
+ service_->IsReceivingFile(), service_->IsSendingFile(),
+ service_->IsConnecting(), service_->IsInHighVisibility()));
+}
diff --git a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.h b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.h
index 5a82f7bc2f9..96fef187c4e 100644
--- a/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.h
+++ b/chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.h
@@ -108,6 +108,12 @@ class NearbyInternalsUiTriggerHandler : public content::WebUIMessageHandler,
// the receive surface to be unregistered.
void UnregisterReceiveSurface(const base::ListValue* args);
+ // Message handler callback that calls IsScanning, IsTransferring,
+ // IsReceivingFile, IsSendingFile, IsConnecting, and IsInHighVisibility in the
+ // NearbySharingService and passes booleans to JavaScript to eventually be
+ // displayed.
+ void GetState(const base::ListValue* args);
+
content::BrowserContext* const context_;
base::flat_map<std::string, ShareTarget> id_to_share_target_map_;
base::WeakPtrFactory<NearbyInternalsUiTriggerHandler> weak_ptr_factory_{this};
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn b/chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn
index c709cfcf236..46ce9035c11 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn
@@ -6,10 +6,15 @@ import("//mojo/public/tools/bindings/mojom.gni")
assert(is_chromeos, "Nearby Share is CrOS only")
+mojom("share_type") {
+ sources = [ "nearby_share_share_type.mojom" ]
+}
+
mojom("mojom") {
sources = [ "nearby_share.mojom" ]
public_deps = [
+ ":share_type",
"//chromeos/services/nearby/public/mojom:nearby_share_target_types",
"//mojo/public/mojom/base",
]
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/DIR_METADATA b/chromium/chrome/browser/ui/webui/nearby_share/DIR_METADATA
new file mode 100644
index 00000000000..7ed7d6b3222
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/nearby_share/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>Sharing>Nearby"
+}
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/OWNERS b/chromium/chrome/browser/ui/webui/nearby_share/OWNERS
index 407a180cff2..407222bd288 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/OWNERS
+++ b/chromium/chrome/browser/ui/webui/nearby_share/OWNERS
@@ -4,5 +4,3 @@ per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: UI>Browser>Sharing>Nearby
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share.mojom b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share.mojom
index dd9df89b50a..38fd1bd1844 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share.mojom
+++ b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share.mojom
@@ -4,9 +4,26 @@
module nearby_share.mojom;
+import "chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom";
import "chromeos/services/nearby/public/mojom/nearby_share_target_types.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
+// Contains the minimum amount of information needed to show the user a preview
+// of their share when they are confirming a send or receive with a share
+// target.
+struct PayloadPreview {
+ // A description that is different for each sharing case:
+ // 1) For a text share this is a limited/redacted preview of the full text.
+ // 2) For a single file share this is the file name.
+ // 3) For a multiple file share this contains the first file name. This will
+ // be used in a translation template like this 'file.ext and N other files'
+ string description;
+ // 0 for a direct text share, or the number of files being shared.
+ int32 file_count;
+ // The type of share so the UI knows how to preview it.
+ ShareType share_type;
+};
+
// Describes a nearby device that is able to receive data via Nearby Share.
struct ShareTarget {
// Unique identifier during the current discovery session. The same physical
@@ -16,6 +33,8 @@ struct ShareTarget {
string name;
// Device type of this share target.
ShareTargetType type;
+ // Payload preview for the attachment(s).
+ PayloadPreview payload_preview;
};
// Result of selecting a share target.
@@ -101,64 +120,53 @@ interface TransferUpdateListener {
OnTransferUpdate(TransferStatus status, string? token);
};
-// This enum combines both text and file share attachment types into a single
-// enum that more directly maps to what is shown to user for preview.
-enum ShareType {
- // A generic non-file text share.
- kText,
- // A text share representing a url, opened in browser.
- kUrl,
- // A text share representing a phone number, opened in dialer.
- kPhone,
- // A text share representing an address, opened in browser.
- kAddress,
- // Multiple files are being shared, we don't capture the specific types.
- kMultipleFiles,
- // Single file attachment with a mime type of 'image/*'.
- kImageFile,
- // Single file attachment with a mime type of 'video/*'.
- kVideoFile,
- // Single file attachment with a mime type of 'audio/*'.
- kAudioFile,
- // Single file attachment with a mime type of 'application/pdf'.
- kPdfFile,
- // Single file attachment with a mime type of
- // 'application/vnd.google-apps.document'.
- kGoogleDocsFile,
- // Single file attachment with a mime type of
- // 'application/vnd.google-apps.spreadsheet'.
- kGoogleSheetsFile,
- // Single file attachment with a mime type of
- // 'application/vnd.google-apps.presentation'.
- kGoogleSlidesFile,
- // Single file attachment with un-matched mime type.
- kUnknownFile,
+// This enum contains the results from attempting to to start nearby discovery.
+enum StartDiscoveryResult {
+ // Nearby was able to start its discovery process sucessfully.
+ kSuccess,
+ // Nearby cannot start discovery because there is an existing file transfer
+ // in progress.
+ kErrorInProgressTransferring,
+ // Generic error for failing to start the nearby discovery process.
+ kErrorGeneric,
};
-// Contains the minimum amount of information needed to show the user a preview
-// of their share when they are confirming a send to a share target.
-struct SendPreview {
- // A description that is different for each sharing case:
- // 1) For a text share this is a limited/redacted preview of the full text.
- // 2) For a single file share this is the file name.
- // 3) For a multiple file share this contains the first file name. This will
- // be used in a translation template like this 'file.ext and N other files'
- string description;
- // 0 for a direct text share, or the number of files being shared.
- int32 file_count;
- // The type of share so the UI knows how to preview it.
- ShareType share_type;
+// This enum represents the different possible results when registering a
+// Receive Surface.
+enum RegisterReceiveSurfaceResult {
+ // Succeeded.
+ kSuccess,
+ // Failed.
+ kFailure,
+ // Bluetooth and Wi-Fi are unavailable.
+ kNoConnectionMedium,
+ // There is already a transfer in progress.
+ kTransferInProgress,
+};
+
+// Observer interface to receive updates when the Nearby utility process stops.
+// Implemented on the browser process and used by UI surfaces.
+interface DiscoveryObserver {
+ // Called when the Nearby utility process stops.
+ OnNearbyProcessStopped();
+
+ // Called when discovery has started.
+ OnStartDiscoveryResult(bool success);
};
// Manager interface for nearby device discovery. Implemented on the browser
// process and used by UI surfaces. The discovery manager is also responsible
-// for previewing the current share with GetSendPreview() so the user can verify
-// the attachments being sent before calling SelectShareTarget().
+// for previewing the current share with GetPayloadPreview() so the user can
+// verify the attachments being sent before calling SelectShareTarget().
interface DiscoveryManager {
+ // Allows the caller to observe DiscoveryManager events.
+ AddDiscoveryObserver(pending_remote<DiscoveryObserver> observer);
+
// Starts discovering nearby devices. The passed |listener| will be called
- // with any discovered devices.
+ // with any discovered devices. Returns before discovery has actually
+ // started; see |DiscoveryObserver.OnStartDiscoveryResult()|.
StartDiscovery(pending_remote<ShareTargetListener> listener)
- => (bool success);
+ => (StartDiscoveryResult result);
// Select a previously discovered |share_target_id| to send data to. On
// success this will return valid ConfirmationManager and
@@ -169,9 +177,9 @@ interface DiscoveryManager {
pending_receiver<TransferUpdateListener>? transfer_update_listener,
pending_remote<ConfirmationManager>? confirmation_manager);
- // Gets the SendPreview so the UI can show the user what they are about to
+ // Gets the PayloadPreview so the UI can show the user what they are about to
// share.
- GetSendPreview() => (SendPreview send_preview);
+ GetPayloadPreview() => (PayloadPreview payload_preview);
};
// Manager interface for the Nearby Share confirmation screen. Implemented on
@@ -198,6 +206,9 @@ interface ReceiveObserver {
// Called when the status of the current transfer changes.
OnTransferUpdate(ShareTarget share_target, TransferMetadata metadata);
+
+ // Called when the Nearby utility process stops.
+ OnNearbyProcessStopped();
};
// Allows the caller to observe changes to or query high visibility, or
@@ -215,11 +226,11 @@ interface ReceiveManager {
IsInHighVisibility() => (bool in_high_visibility);
// Attempt to register the receive manager as a foreground receive surface.
- // If |success| is true, then the surface has been registered; otherwise it
+ // If |result| is kSuccess, then the surface has been registered; otherwise it
// has not been registered. The foreground surface receives incoming
// shares, and once one is registered, high visibility will become active
// after a short while. Calling multiple times will have no additional effect.
- RegisterForegroundReceiveSurface() => (bool success);
+ RegisterForegroundReceiveSurface() => (RegisterReceiveSurfaceResult result);
// Attempt to unregister the receive manager as a foreground receive surface.
// If |success| is true, then the surface is no longer registered; otherwise,
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.cc b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.cc
index dc53918a430..960593faca1 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/nearby_sharing/text_attachment.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/nearby_share/shared_resources.h"
+#include "chrome/browser/ui/webui/plural_string_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
@@ -37,8 +38,8 @@ namespace nearby_share {
NearbyShareDialogUI::NearbyShareDialogUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true) {
Profile* profile = Profile::FromWebUI(web_ui);
- // Nearby Share is not available to incognito or guest profiles.
- DCHECK(profile->IsRegularProfile());
+ DCHECK(NearbySharingServiceFactory::IsNearbyShareSupportedForBrowserContext(
+ profile));
nearby_service_ = NearbySharingServiceFactory::GetForBrowserContext(profile);
@@ -48,7 +49,6 @@ NearbyShareDialogUI::NearbyShareDialogUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource(html_source,
base::make_span(kNearbyShareDialogResources,
kNearbyShareDialogResourcesSize),
- /*generated_path=*/std::string(),
IDR_NEARBY_SHARE_DIALOG_NEARBY_SHARE_DIALOG_HTML);
// To use lottie, the worker-src CSP needs to be updated for the web ui that
@@ -66,6 +66,12 @@ NearbyShareDialogUI::NearbyShareDialogUI(content::WebUI* web_ui)
"close", base::BindRepeating(&NearbyShareDialogUI::HandleClose,
base::Unretained(this)));
+ auto plural_string_handler = std::make_unique<PluralStringHandler>();
+ plural_string_handler->AddLocalizedString(
+ "nearbyShareContactVisibilityNumUnreachable",
+ IDS_NEARBY_CONTACT_VISIBILITY_NUM_UNREACHABLE);
+ web_ui->AddMessageHandler(std::move(plural_string_handler));
+
content::WebUIDataSource::Add(profile, html_source);
const GURL& url = web_ui->GetWebContents()->GetVisibleURL();
@@ -128,8 +134,9 @@ void NearbyShareDialogUI::SetAttachmentFromQueryParameter(const GURL& url) {
{"phone", TextAttachment::Type::kPhoneNumber},
{"text", TextAttachment::Type::kText}}) {
if (net::GetValueForKeyInQuery(url, text_type.first, &value)) {
- attachments.push_back(
- std::make_unique<TextAttachment>(text_type.second, value));
+ attachments.push_back(std::make_unique<TextAttachment>(
+ text_type.second, value, /*title=*/base::nullopt,
+ /*mime_type=*/base::nullopt));
SetAttachments(std::move(attachments));
return;
}
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.cc b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.cc
index 7c41287a854..6d40f2e840b 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.cc
@@ -3,7 +3,11 @@
// found in the LICENSE file.
#include "chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.h"
+
#include "base/notreached.h"
+#include "chrome/browser/nearby_sharing/attachment.h"
+#include "chrome/browser/nearby_sharing/file_attachment.h"
+#include "chrome/browser/nearby_sharing/text_attachment.h"
namespace mojo {
@@ -28,6 +32,42 @@ StructTraits<nearby_share::mojom::ShareTargetDataView, ShareTarget>::type(
}
// static
+nearby_share::mojom::PayloadPreviewPtr
+StructTraits<nearby_share::mojom::ShareTargetDataView,
+ ShareTarget>::payload_preview(const ShareTarget& share_target) {
+ // TODO(crbug.com/1158627): Extract this which is very similar to logic in
+ // NearbyPerSessionDiscoveryManager.
+ nearby_share::mojom::PayloadPreviewPtr payload_preview =
+ nearby_share::mojom::PayloadPreview::New();
+ payload_preview->file_count = share_target.file_attachments.size();
+ payload_preview->share_type = nearby_share::mojom::ShareType::kText;
+
+ // Retrieve the attachment that we'll use for the default description.
+ const Attachment* attachment = nullptr;
+ if (!share_target.file_attachments.empty()) {
+ attachment = &share_target.file_attachments[0];
+ } else if (!share_target.text_attachments.empty()) {
+ attachment = &share_target.text_attachments[0];
+ }
+
+ // If there are no attachments, return an empty text preview.
+ if (!attachment)
+ return payload_preview;
+
+ payload_preview->description = attachment->GetDescription();
+
+ // Determine the share type.
+ if (payload_preview->file_count > 1) {
+ payload_preview->share_type =
+ nearby_share::mojom::ShareType::kMultipleFiles;
+ } else {
+ payload_preview->share_type = attachment->GetShareType();
+ }
+
+ return payload_preview;
+}
+
+// static
bool StructTraits<nearby_share::mojom::ShareTargetDataView, ShareTarget>::Read(
nearby_share::mojom::ShareTargetDataView data,
ShareTarget* out) {
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.h b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.h
index 41b742175db..e3e9525b54d 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.h
+++ b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_mojom_traits.h
@@ -19,6 +19,8 @@ struct StructTraits<nearby_share::mojom::ShareTargetDataView, ShareTarget> {
static std::string name(const ShareTarget& share_target);
static nearby_share::mojom::ShareTargetType type(
const ShareTarget& share_target);
+ static nearby_share::mojom::PayloadPreviewPtr payload_preview(
+ const ShareTarget& share_target);
static bool Read(nearby_share::mojom::ShareTargetDataView data,
ShareTarget* out);
};
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom
new file mode 100644
index 00000000000..2ffea52ba29
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_share_type.mojom
@@ -0,0 +1,39 @@
+// 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.
+
+module nearby_share.mojom;
+
+// This enum combines both text and file share attachment types into a single
+// enum that more directly maps to what is shown to user for preview.
+enum ShareType {
+ // A generic non-file text share.
+ kText,
+ // A text share representing a url, opened in browser.
+ kUrl,
+ // A text share representing a phone number, opened in dialer.
+ kPhone,
+ // A text share representing an address, opened in browser.
+ kAddress,
+ // Multiple files are being shared, we don't capture the specific types.
+ kMultipleFiles,
+ // Single file attachment with a mime type of 'image/*'.
+ kImageFile,
+ // Single file attachment with a mime type of 'video/*'.
+ kVideoFile,
+ // Single file attachment with a mime type of 'audio/*'.
+ kAudioFile,
+ // Single file attachment with a mime type of 'application/pdf'.
+ kPdfFile,
+ // Single file attachment with a mime type of
+ // 'application/vnd.google-apps.document'.
+ kGoogleDocsFile,
+ // Single file attachment with a mime type of
+ // 'application/vnd.google-apps.spreadsheet'.
+ kGoogleSheetsFile,
+ // Single file attachment with a mime type of
+ // 'application/vnd.google-apps.presentation'.
+ kGoogleSlidesFile,
+ // Single file attachment with un-matched mime type.
+ kUnknownFile,
+};
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom b/chromium/chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom
index a6498d12e40..c04e69887e1 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom
+++ b/chromium/chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom
@@ -19,7 +19,9 @@ enum DataUsage {
};
// TODO(crbug.com/1110098): Remove kUnknown.
-// Represents who the user has chosen to be visible to.
+// Represents who the user has chosen to be visible to. Note: These values are
+// persisted to logs. Entries should not be renumbered and numeric values
+// should never be reused.
enum Visibility {
kUnknown = 0,
// The user is not advertising to anyone.
@@ -68,6 +70,8 @@ interface NearbyShareSettings {
GetEnabled() => (bool enabled);
// Set the enabled state for the Nearby Share feature.
SetEnabled(bool enabled);
+ // Get the onboarding completion state for the Nearby Share feature.
+ IsOnboardingComplete() => (bool completed);
// Get the device name shown to a sender when this device is available as
// a share target. |device_name| is the new device name.
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/shared_resources.cc b/chromium/chrome/browser/ui/webui/nearby_share/shared_resources.cc
index 66a7ed0278e..8f5363befc7 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/shared_resources.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_share/shared_resources.cc
@@ -8,14 +8,18 @@
#include "base/containers/span.h"
#include "base/logging.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/webui/web_ui_util.h"
void RegisterNearbySharedStrings(content::WebUIDataSource* data_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"nearbyShareAccountRowLabel", IDS_NEARBY_ACCOUNT_ROW_LABEL},
+ {"nearbyShareActionsAccept", IDS_NEARBY_ACTIONS_ACCEPT},
{"nearbyShareActionsCancel", IDS_NEARBY_ACTIONS_CANCEL},
+ {"nearbyShareActionsClose", IDS_NEARBY_ACTIONS_CLOSE},
{"nearbyShareActionsConfirm", IDS_NEARBY_ACTIONS_CONFIRM},
{"nearbyShareActionsNext", IDS_NEARBY_ACTIONS_NEXT},
{"nearbyShareActionsReject", IDS_NEARBY_ACTIONS_REJECT},
@@ -38,26 +42,18 @@ void RegisterNearbySharedStrings(content::WebUIDataSource* data_source) {
{"nearbyShareContactVisibilityNone", IDS_NEARBY_VISIBLITY_HIDDEN},
{"nearbyShareContactVisibilityNoneDescription",
IDS_NEARBY_VISIBLITY_HIDDEN_DESCRIPTION},
- {"nearbyShareContactVisibilityOthers",
- IDS_NEARBY_CONTACT_VISIBILITY_OTHERS},
- {"nearbyShareContactVisibilityOthersTitle",
- IDS_NEARBY_CONTACT_VISIBILITY_OTHERS_TITLE},
{"nearbyShareContactVisibilityOwnAll",
IDS_NEARBY_CONTACT_VISIBILITY_OWN_ALL},
{"nearbyShareContactVisibilityOwnNone",
IDS_NEARBY_CONTACT_VISIBILITY_OWN_NONE},
{"nearbyShareContactVisibilityOwnSome",
IDS_NEARBY_CONTACT_VISIBILITY_OWN_SOME},
- {"nearbyShareContactVisibilityOwnTitle",
- IDS_NEARBY_CONTACT_VISIBILITY_OWN_TITLE},
{"nearbyShareContactVisibilitySome", IDS_NEARBY_VISIBLITY_SOME_CONTACTS},
{"nearbyShareContactVisibilitySomeDescription",
IDS_NEARBY_VISIBLITY_SOME_CONTACTS_DESCRIPTION},
{"nearbyShareContactVisibilityUnknown", IDS_NEARBY_VISIBLITY_UNKNOWN},
{"nearbyShareContactVisibilityUnknownDescription",
IDS_NEARBY_VISIBLITY_UNKNOWN_DESCRIPTION},
- {"nearbyShareContactVisibilityZeroStateInfo",
- IDS_NEARBY_CONTACT_VISIBILITY_ZERO_STATE_INFO},
{"nearbyShareContactVisibilityZeroStateText",
IDS_NEARBY_CONTACT_VISIBILITY_ZERO_STATE_TEXT},
{"nearbyShareDeviceNameEmptyError", IDS_NEARBY_DEVICE_NAME_EMPTY_ERROR},
@@ -70,22 +66,31 @@ void RegisterNearbySharedStrings(content::WebUIDataSource* data_source) {
IDS_NEARBY_DISCOVERY_PAGE_PLACEHOLDER},
{"nearbyShareDiscoveryPageSubtitle", IDS_NEARBY_DISCOVERY_PAGE_SUBTITLE},
{"nearbyShareDiscoveryPageTitle", IDS_NEARBY_DISCOVERY_PAGE_TITLE},
+ {"nearbyShareErrorCancelled", IDS_NEARBY_ERROR_CANCELLED},
+ {"nearbyShareErrorCantReceive", IDS_NEARBY_ERROR_CANT_RECEIVE},
{"nearbyShareErrorCantShare", IDS_NEARBY_ERROR_CANT_SHARE},
{"nearbyShareErrorNoResponse", IDS_NEARBY_ERROR_NO_RESPONSE},
+ {"nearbyShareErrorNotEnoughSpace", IDS_NEARBY_ERROR_NOT_ENOUGH_SPACE},
+ {"nearbyShareErrorTransferInProgress",
+ IDS_NEARBY_ERROR_TRANSFER_IN_PROGRESS},
{"nearbyShareErrorRejected", IDS_NEARBY_ERROR_REJECTED},
{"nearbyShareErrorSomethingWrong", IDS_NEARBY_ERROR_SOMETHING_WRONG},
{"nearbyShareErrorTimeOut", IDS_NEARBY_ERROR_TIME_OUT},
+ {"nearbyShareErrorTryAgain", IDS_NEARBY_ERROR_TRY_AGAIN},
{"nearbyShareErrorUnsupportedFileType",
IDS_NEARBY_ERROR_UNSUPPORTED_FILE_TYPE},
{"nearbyShareFeatureName", IDS_NEARBY_SHARE_FEATURE_NAME},
{"nearbyShareOnboardingPageDeviceName",
IDS_NEARBY_ONBOARDING_PAGE_DEVICE_NAME},
+ {"nearbyShareOnboardingPageDeviceNameHelp",
+ IDS_NEARBY_ONBOARDING_PAGE_DEVICE_NAME_HELP},
{"nearbyShareOnboardingPageSubtitle",
IDS_NEARBY_ONBOARDING_PAGE_SUBTITLE},
{"nearbyShareOnboardingPageTitle", IDS_NEARBY_ONBOARDING_PAGE_TITLE},
{"nearbySharePreviewMultipleFileTitle",
IDS_NEARBY_PREVIEW_TITLE_MULTIPLE_FILE},
{"nearbyShareSecureConnectionId", IDS_NEARBY_SECURE_CONNECTION_ID},
+ {"nearbyShareSettingsHelpCaption", IDS_NEARBY_SETTINGS_HELP_CAPTION},
{"nearbyShareVisibilityPageManageContacts",
IDS_NEARBY_VISIBILITY_PAGE_MANAGE_CONTACTS},
{"nearbyShareVisibilityPageSubtitle",
@@ -93,9 +98,32 @@ void RegisterNearbySharedStrings(content::WebUIDataSource* data_source) {
{"nearbyShareVisibilityPageTitle", IDS_NEARBY_VISIBILITY_PAGE_TITLE},
{"nearbyShareHighVisibilitySubTitle",
IDS_NEARBY_HIGH_VISIBILITY_SUB_TITLE},
+ {"nearbyShareHighVisibilitySubTitleMinutes",
+ IDS_NEARBY_HIGH_VISIBILITY_SUB_TITLE_MINUTES},
+ {"nearbyShareHighVisibilitySubTitleSeconds",
+ IDS_NEARBY_HIGH_VISIBILITY_SUB_TITLE_SECONDS},
{"nearbyShareHighVisibilityHelpText",
IDS_NEARBY_HIGH_VISIBILITY_HELP_TEXT},
+ {"nearbyShareHighVisibilityTimeoutText",
+ IDS_NEARBY_HIGH_VISIBILITY_TIMEOUT_TEXT},
{"nearbyShareReceiveConfirmPageTitle",
- IDS_NEARBY_RECEIVE_CONFIRM_PAGE_TITLE}};
- webui::AddLocalizedStringsBulk(data_source, kLocalizedStrings);
+ IDS_NEARBY_RECEIVE_CONFIRM_PAGE_TITLE},
+ {"nearbyShareReceiveConfirmPageConnectionId",
+ IDS_NEARBY_RECEIVE_CONFIRM_PAGE_CONNECTION_ID},
+ {"nearbyShareErrorNoConnectionMedium",
+ IDS_NEARBY_HIGH_VISIBILITY_CONNECTION_MEDIUM_ERROR},
+ {"nearbyShareErrorNoConnectionMediumDescription",
+ IDS_NEARBY_HIGH_VISIBILITY_CONNECTION_MEDIUM_DESCRIPTION},
+ {"nearbyShareErrorTransferInProgressTitle",
+ IDS_NEARBY_HIGH_VISIBILITY_TRANSFER_IN_PROGRESS_ERROR},
+ {"nearbyShareErrorTransferInProgressDescription",
+ IDS_NEARBY_HIGH_VISIBILITY_TRANSFER_IN_PROGRESS_DESCRIPTION}};
+ data_source->AddLocalizedStrings(kLocalizedStrings);
+
+ data_source->AddString("nearbyShareLearnMoreLink",
+ base::ASCIIToUTF16(chrome::kNearbyShareLearnMoreURL));
+
+ data_source->AddString(
+ "nearbyShareManageContactsUrl",
+ base::ASCIIToUTF16(chrome::kNearbyShareManageContactsURL));
}
diff --git a/chromium/chrome/browser/ui/webui/net_export_ui.cc b/chromium/chrome/browser/ui/webui/net_export_ui.cc
index f27414c4189..a23323638a1 100644
--- a/chromium/chrome/browser/ui/webui/net_export_ui.cc
+++ b/chromium/chrome/browser/ui/webui/net_export_ui.cc
@@ -16,7 +16,7 @@
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -139,9 +139,9 @@ class NetExportMessageHandler
// Cached pointer to SystemNetworkContextManager's NetExportFileWriter.
net_log::NetExportFileWriter* file_writer_;
- ScopedObserver<net_log::NetExportFileWriter,
- net_log::NetExportFileWriter::StateObserver>
- state_observer_manager_;
+ base::ScopedObservation<net_log::NetExportFileWriter,
+ net_log::NetExportFileWriter::StateObserver>
+ state_observation_manager_{this};
// The capture mode and file size bound that the user chose in the UI when
// logging started is cached here and is read after a file path is chosen in
@@ -159,8 +159,7 @@ class NetExportMessageHandler
NetExportMessageHandler::NetExportMessageHandler()
: file_writer_(g_browser_process->system_network_context_manager()
- ->GetNetExportFileWriter()),
- state_observer_manager_(this) {
+ ->GetNetExportFileWriter()) {
file_writer_->Initialize();
}
@@ -204,8 +203,8 @@ void NetExportMessageHandler::RegisterMessages() {
void NetExportMessageHandler::OnEnableNotifyUIWithState(
const base::ListValue* list) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (!state_observer_manager_.IsObservingSources()) {
- state_observer_manager_.Add(file_writer_);
+ if (!state_observation_manager_.IsObserving()) {
+ state_observation_manager_.Observe(file_writer_);
}
NotifyUIWithState(file_writer_->GetState());
}
diff --git a/chromium/chrome/browser/ui/webui/net_internals/DIR_METADATA b/chromium/chrome/browser/ui/webui/net_internals/DIR_METADATA
new file mode 100644
index 00000000000..83a0f7e5d2c
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/net_internals/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "Internals>Network>Logging"
+}
diff --git a/chromium/chrome/browser/ui/webui/net_internals/OWNERS b/chromium/chrome/browser/ui/webui/net_internals/OWNERS
index ad60e1e824c..53e68eb7787 100644
--- a/chromium/chrome/browser/ui/webui/net_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/net_internals/OWNERS
@@ -1,3 +1 @@
mmenke@chromium.org
-
-# COMPONENT: Internals>Network>Logging
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 524e1533409..6f8158dd7be 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
@@ -17,9 +17,11 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/net_export_helper.h"
#include "chrome/browser/profiles/profile.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/net_internals_resources.h"
+#include "chrome/grit/net_internals_resources_map.h"
#include "components/prefs/pref_member.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
@@ -33,6 +35,7 @@
#include "services/network/expect_ct_reporter.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
+#include "ui/resources/grit/webui_generated_resources.h"
using content::BrowserThread;
@@ -41,10 +44,15 @@ namespace {
content::WebUIDataSource* CreateNetInternalsHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUINetInternalsHost);
-
+ source->AddResourcePaths(
+ base::make_span(kNetInternalsResources, kNetInternalsResourcesSize));
source->SetDefaultResource(IDR_NET_INTERNALS_INDEX_HTML);
- source->AddResourcePath("index.js", IDR_NET_INTERNALS_INDEX_JS);
- source->UseStringsJs();
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::ScriptSrc,
+ "script-src chrome://resources chrome://test 'self';");
+ source->AddResourcePath("test_loader_util.js",
+ IDR_WEBUI_JS_TEST_LOADER_UTIL_JS);
+ source->DisableTrustedTypesCSP();
return source;
}
@@ -53,9 +61,7 @@ void IgnoreBoolCallback(bool result) {}
// 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.
-class NetInternalsMessageHandler
- : public content::WebUIMessageHandler,
- public base::SupportsWeakPtr<NetInternalsMessageHandler> {
+class NetInternalsMessageHandler : public content::WebUIMessageHandler {
public:
explicit NetInternalsMessageHandler(content::WebUI* web_ui);
~NetInternalsMessageHandler() override = default;
@@ -63,15 +69,18 @@ class NetInternalsMessageHandler
protected:
// WebUIMessageHandler implementation:
void RegisterMessages() override;
+ void OnJavascriptDisallowed() override;
private:
network::mojom::NetworkContext* GetNetworkContext();
- // Calls g_browser.receive in the renderer, passing in |command| and |arg|.
+ // Resolve JS |callback_id| with |result|.
// If the renderer is displaying a log file, the message will be ignored.
- void SendJavascriptCommand(const std::string& command, base::Value arg);
+ void ResolveCallbackWithResult(const std::string& callback_id,
+ base::Value result);
- void OnExpectCTTestReportCallback(bool success);
+ void OnExpectCTTestReportCallback(const std::string& callback_id,
+ bool success);
//--------------------------------
// Javascript message handlers:
@@ -90,6 +99,7 @@ class NetInternalsMessageHandler
void OnFlushSocketPools(const base::ListValue* list);
content::WebUI* web_ui_;
+ base::WeakPtrFactory<NetInternalsMessageHandler> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NetInternalsMessageHandler);
};
@@ -145,13 +155,8 @@ void NetInternalsMessageHandler::RegisterMessages() {
base::Unretained(this)));
}
-void NetInternalsMessageHandler::SendJavascriptCommand(
- const std::string& command,
- base::Value arg) {
- std::unique_ptr<base::Value> command_value(new base::Value(command));
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive",
- *command_value.get(), arg);
+void NetInternalsMessageHandler::OnJavascriptDisallowed() {
+ weak_factory_.InvalidateWeakPtrs();
}
void NetInternalsMessageHandler::OnReloadProxySettings(
@@ -184,14 +189,23 @@ void NetInternalsMessageHandler::OnDomainSecurityPolicyDelete(
}
void NetInternalsMessageHandler::OnHSTSQuery(const base::ListValue* list) {
- // |list| should be: [<domain to query>].
+ std::string callback_id;
+ bool get_callback_id = list->GetString(0, &callback_id);
std::string domain;
- bool get_domain_result = list->GetString(0, &domain);
- DCHECK(get_domain_result);
+ bool get_domain_result = list->GetString(1, &domain);
+ DCHECK(get_domain_result && get_callback_id);
+ AllowJavascript();
GetNetworkContext()->GetHSTSState(
- domain, base::BindOnce(&NetInternalsMessageHandler::SendJavascriptCommand,
- this->AsWeakPtr(), "receivedHSTSResult"));
+ domain,
+ base::BindOnce(&NetInternalsMessageHandler::ResolveCallbackWithResult,
+ weak_factory_.GetWeakPtr(), callback_id));
+}
+
+void NetInternalsMessageHandler::ResolveCallbackWithResult(
+ const std::string& callback_id,
+ base::Value result) {
+ ResolveJavascriptCallback(base::Value(callback_id), result);
}
void NetInternalsMessageHandler::OnHSTSAdd(const base::ListValue* list) {
@@ -214,19 +228,22 @@ void NetInternalsMessageHandler::OnHSTSAdd(const base::ListValue* list) {
}
void NetInternalsMessageHandler::OnExpectCTQuery(const base::ListValue* list) {
- // |list| should be: [<domain to query>].
+ std::string callback_id;
std::string domain;
- bool result = list->GetString(0, &domain);
- DCHECK(result);
+ bool callback_result = list->GetString(0, &callback_id);
+ bool result = list->GetString(1, &domain);
+
+ DCHECK(result && callback_result);
url::Origin origin = url::Origin::Create(GURL("https://" + domain));
+ AllowJavascript();
GetNetworkContext()->GetExpectCTState(
domain,
net::NetworkIsolationKey(origin /* top_frame_site */,
origin /* frame_site */),
- base::BindOnce(&NetInternalsMessageHandler::SendJavascriptCommand,
- this->AsWeakPtr(), "receivedExpectCTResult"));
+ base::BindOnce(&NetInternalsMessageHandler::ResolveCallbackWithResult,
+ weak_factory_.GetWeakPtr(), callback_id));
}
void NetInternalsMessageHandler::OnExpectCTAdd(const base::ListValue* list) {
@@ -259,24 +276,29 @@ void NetInternalsMessageHandler::OnExpectCTAdd(const base::ListValue* list) {
void NetInternalsMessageHandler::OnExpectCTTestReport(
const base::ListValue* list) {
- // |list| should be: [<report URI>].
+ std::string callback_id;
std::string report_uri_str;
- bool result = list->GetString(0, &report_uri_str);
- DCHECK(result);
+ bool callback_result = list->GetString(0, &callback_id);
+ bool result = list->GetString(1, &report_uri_str);
+ DCHECK(result && callback_result);
GURL report_uri(report_uri_str);
- if (!report_uri.is_valid())
+ AllowJavascript();
+ if (!report_uri.is_valid()) {
+ ResolveCallbackWithResult(callback_id, base::Value("invalid"));
return;
+ }
GetNetworkContext()->SetExpectCTTestReport(
report_uri,
base::BindOnce(&NetInternalsMessageHandler::OnExpectCTTestReportCallback,
- this->AsWeakPtr()));
+ weak_factory_.GetWeakPtr(), callback_id));
}
-void NetInternalsMessageHandler::OnExpectCTTestReportCallback(bool success) {
- SendJavascriptCommand(
- "receivedExpectCTTestReportResult",
- success ? base::Value("success") : base::Value("failure"));
+void NetInternalsMessageHandler::OnExpectCTTestReportCallback(
+ const std::string& callback_id,
+ bool success) {
+ ResolveCallbackWithResult(
+ callback_id, success ? base::Value("success") : base::Value("failure"));
}
void NetInternalsMessageHandler::OnFlushSocketPools(
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 63a0b22c1ce..57de4d495f5 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
@@ -210,7 +210,7 @@ void NetInternalsTest::MessageHandler::GetTestServerURL(
void NetInternalsTest::MessageHandler::SetUpTestReportURI(
const base::ListValue* list_value) {
net_internals_test_->embedded_test_server()->RegisterRequestHandler(
- base::Bind(&HandleExpectCTReportPreflight));
+ base::BindRepeating(&HandleExpectCTReportPreflight));
ASSERT_TRUE(net_internals_test_->embedded_test_server()->Start());
base::Value report_uri_value(
net_internals_test_->embedded_test_server()->GetURL("/").spec());
diff --git a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h
index a3d2845b98c..002e0338806 100644
--- a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h
+++ b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h
@@ -11,7 +11,7 @@
#include "chrome/test/base/web_ui_browser_test.h"
class NetInternalsTest : public WebUIBrowserTest {
- protected:
+ public:
NetInternalsTest();
~NetInternalsTest() override;
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 8b08d4bec1a..d4db0e36de6 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/BUILD.gn
@@ -8,7 +8,7 @@ mojom("mojo_bindings") {
sources = [ "new_tab_page.mojom" ]
public_deps = [
- "//chrome/common/search:mojo_bindings",
+ "//chrome/browser/ui/webui/realbox:mojo_bindings",
"//mojo/public/mojom/base",
"//skia/public/mojom",
"//url/mojom:url_mojom_gurl",
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/DIR_METADATA b/chromium/chrome/browser/ui/webui/new_tab_page/DIR_METADATA
new file mode 100644
index 00000000000..77ca58fb9b4
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>NewTabPage"
+}
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/OWNERS b/chromium/chrome/browser/ui/webui/new_tab_page/OWNERS
index 13fc0b307a0..8bd6249e0b3 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/OWNERS
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/OWNERS
@@ -4,5 +4,3 @@ tiborg@chromium.org
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: UI>Browser>NewTabPage
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/foo/DIR_METADATA b/chromium/chrome/browser/ui/webui/new_tab_page/foo/DIR_METADATA
new file mode 100644
index 00000000000..77ca58fb9b4
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/foo/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>NewTabPage"
+}
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/foo/OWNERS b/chromium/chrome/browser/ui/webui/new_tab_page/foo/OWNERS
index e58e892662d..f4bffc1920f 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/foo/OWNERS
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/foo/OWNERS
@@ -2,5 +2,3 @@ file://chrome/browser/ui/webui/new_tab_page/OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: UI>Browser>NewTabPage \ No newline at end of file
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 83178b99c53..1783caf2084 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
@@ -4,7 +4,7 @@
module new_tab_page.mojom;
-import "chrome/common/search/omnibox.mojom";
+import "chrome/browser/ui/webui/realbox/realbox.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/text_direction.mojom";
import "mojo/public/mojom/base/time.mojom";
@@ -66,24 +66,6 @@ struct CollectionImage {
url.mojom.Url preview_image_url;
};
-// Theme settings for the NTP realbox.
-struct SearchBoxTheme {
- skia.mojom.SkColor bg;
- skia.mojom.SkColor icon;
- skia.mojom.SkColor icon_selected;
- skia.mojom.SkColor placeholder;
- skia.mojom.SkColor results_bg;
- skia.mojom.SkColor results_bg_hovered;
- skia.mojom.SkColor results_bg_selected;
- skia.mojom.SkColor results_dim;
- skia.mojom.SkColor results_dim_selected;
- skia.mojom.SkColor results_text;
- skia.mojom.SkColor results_text_selected;
- skia.mojom.SkColor results_url;
- skia.mojom.SkColor results_url_selected;
- skia.mojom.SkColor text;
-};
-
// The background image URL and styling.
struct BackgroundImage {
// URL to the background image. Can point to untrusted content.
@@ -126,7 +108,7 @@ struct Theme {
url.mojom.Url? background_image_attribution_url;
// Theme settings for the NTP realbox. Matching those of the Omnibox.
- SearchBoxTheme search_box;
+ realbox.mojom.SearchBoxTheme search_box;
};
// Specifies look of the doodle share button.
@@ -324,10 +306,6 @@ interface PageHandler {
GetBackgroundCollections() => (array<BackgroundCollection> collections);
// Returns the images of a collection identified by |collection_id|.
GetBackgroundImages(string collection_id) => (array<CollectionImage> images);
- // Invisibly focuses the omnibox.
- FocusOmnibox();
- // Pastes |text| into the omnibox.
- PasteIntoOmnibox(string text);
// Gets current doodle if there is one.
GetDoodle() => (Doodle? doodle);
// Choose custom background from local file system.
@@ -344,8 +322,10 @@ interface PageHandler {
OnRestoreModule(string module_id);
// If |visible| the modules will be shown.
SetModulesVisible(bool visible);
- // Triggers a call to |SetModulesVisible| with the current visibility setting.
- UpdateModulesVisible();
+ // Disables module with ID |module_id| if |disabled|. Enables otherwise.
+ SetModuleDisabled(string module_id, bool disabled);
+ // Triggers a call to |SetDisabledModules|.
+ UpdateDisabledModules();
// ======= METRICS =======
// Logs that |tiles| were displayed / updated at |time|. The first instance of
@@ -397,48 +377,16 @@ interface PageHandler {
// Logs a module impression. Called when a module is loaded and can be seen by
// the user (scrolled into view).
OnModuleImpression(string module_id, double time);
- // Logs when a module is loaded with data.
- OnModuleLoaded(string module_id, double time);
+ // Logs that a module loaded data for |duration| and finished successfully at
+ // |time|.
+ OnModuleLoaded(string module_id, mojo_base.mojom.TimeDelta duration,
+ double time);
// Logs when a user interacts with a module which will result in a navigation.
OnModuleUsage(string module_id);
// Logs that the modules have been shown at |time|.
OnModulesRendered(double time);
// Logs that the <ntp-app> element's |ready| callback method was called.
OnAppRendered(double time);
-
- // ======= REALBOX =======
- // Queries autocomplete matches from the browser.
- QueryAutocomplete(mojo_base.mojom.String16 input,
- bool prevent_inline_autocomplete);
- // Cancels the current autocomplete query. Clears the result set if
- // |clear_result| is true.
- StopAutocomplete(bool clear_result);
- // Handles navigation to an autocomplete match (i.e. an item in the realbox's
- // list of matches). Note: |url| is passed solely to verify that the browser
- // and renderer are in sync; don't trust this content or use it for anything
- // other than verification purposes (i.e. is the URL still the same?).
- // TODO(crbug.com/1076604): replace |url| with an unguessable token.
- // |mouse_button| indicates which mouse button was pressed on the match. See
- // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
- OpenAutocompleteMatch(uint8 line,
- url.mojom.Url url,
- bool are_matches_showing,
- mojo_base.mojom.TimeDelta time_elapsed_since_last_focus,
- uint8 mouse_button,
- bool alt_key,
- bool ctrl_key,
- bool meta_key,
- bool shift_key);
- // Deletes the AutocompleteMatch in the current results by |line| number if
- // it is deletable.
- DeleteAutocompleteMatch(uint8 line);
- // Tells the browser to allow suggestions with the given suggestion group ID
- // to appear in the results if they currently are not allowed to or to prevent
- // them from appearing in the results if they are currently permitted to.
- ToggleSuggestionGroupIdVisibility(int32 suggestion_group_id);
- // Logs the time it took in milliseconds since the first character (in a
- // series of characters) was typed until Autocomplete results were painted.
- LogCharTypedToRepaintLatency(mojo_base.mojom.TimeDelta latency);
};
// WebUI-side handler for requests from the browser.
@@ -448,20 +396,7 @@ interface Page {
SetMostVisitedInfo(MostVisitedInfo info);
// Sets the current theme.
SetTheme(Theme theme);
- // If |focused| fakes focus on the fakebox.
- SetFakeboxFocused(bool focused);
- // If |visible| shows the fakebox.
- SetFakeboxVisible(bool visible);
- // Updates the module visibility.
- SetModulesVisible(bool visible);
-
- // ======= REALBOX =======
- // Updates the NTP realbox with the autocomplete results.
- AutocompleteResultChanged(search.mojom.AutocompleteResult result);
- // Updates the NTP realbox popup with the image or favicon data URL for the
- // given |match_index| and |url| where |url| is an AutocompleteMatch image_url
- // or destination_url for an entity or a navigation suggestion respectively.
- AutocompleteMatchImageAvailable(uint32 match_index,
- url.mojom.Url url,
- string data_url);
+ // Disables the modules in |ids|. If |all|, disables all modules and passes an
+ // empty list for |ids|.
+ SetDisabledModules(bool all, array<string> ids);
};
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 ad34303eb12..a1c923bcf04 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
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h"
+#include <algorithm>
+
#include "base/base64.h"
#include "base/bind.h"
#include "base/containers/flat_map.h"
@@ -14,23 +16,12 @@
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
-#include "base/metrics/user_metrics.h"
-#include "base/metrics/user_metrics_action.h"
#include "base/strings/strcat.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
-#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
-#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
-#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/browser_features.h"
-#include "chrome/browser/favicon/favicon_service_factory.h"
-#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/profiles/profile.h"
-#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/search/background/ntp_background_service.h"
#include "chrome/browser/search/background/ntp_background_service_factory.h"
#include "chrome/browser/search/instant_service.h"
@@ -38,37 +29,23 @@
#include "chrome/browser/search/promos/promo_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/ui/bookmarks/bookmark_stats.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
-#include "chrome/browser/ui/search/ntp_user_data_logger.h"
-#include "chrome/browser/ui/search/omnibox_mojo_utils.h"
-#include "chrome/browser/ui/search/omnibox_utils.h"
+#include "chrome/browser/ui/webui/realbox/realbox.mojom.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/search/instant_types.h"
+#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "components/bookmarks/browser/bookmark_model.h"
#include "components/keyed_service/core/service_access_type.h"
-#include "components/navigation_metrics/navigation_metrics.h"
-#include "components/omnibox/browser/autocomplete_classifier.h"
-#include "components/omnibox/browser/autocomplete_input.h"
-#include "components/omnibox/browser/autocomplete_match.h"
-#include "components/omnibox/browser/autocomplete_match_type.h"
-#include "components/omnibox/browser/omnibox_controller_emitter.h"
-#include "components/omnibox/browser/omnibox_event_global_tracker.h"
-#include "components/omnibox/browser/omnibox_log.h"
-#include "components/omnibox/browser/omnibox_prefs.h"
#include "components/prefs/pref_service.h"
+#include "components/prefs/scoped_user_pref_update.h"
#include "components/search/ntp_features.h"
-#include "components/search_engines/omnibox_focus_type.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_provider_logos/logo_service.h"
#include "components/search_provider_logos/switches.h"
-#include "components/sessions/content/session_tab_helper.h"
#include "content/public/browser/storage_partition.h"
-#include "net/cookies/cookie_util.h"
+#include "content/public/browser/web_contents.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/color_utils.h"
namespace {
@@ -180,7 +157,7 @@ new_tab_page::mojom::ThemePtr MakeTheme(const NtpTheme& ntp_theme) {
theme->daily_refresh_collection_id = ntp_theme.collection_id;
}
- auto search_box = new_tab_page::mojom::SearchBoxTheme::New();
+ auto search_box = realbox::mojom::SearchBoxTheme::New();
search_box->bg = ntp_theme.search_box.bg;
search_box->icon = ntp_theme.search_box.icon;
search_box->icon_selected = ntp_theme.search_box.icon_selected;
@@ -237,6 +214,7 @@ new_tab_page::mojom::ImageDoodlePtr MakeImageDoodle(
int share_button_y,
const std::string& share_button_icon,
const std::string& share_button_bg,
+ double share_button_opacity,
GURL log_url,
GURL cta_log_url) {
auto doodle = new_tab_page::mojom::ImageDoodle::New();
@@ -256,7 +234,9 @@ new_tab_page::mojom::ImageDoodlePtr MakeImageDoodle(
doodle->share_button->y = share_button_y;
doodle->share_button->icon_url = GURL(base::StringPrintf(
"data:image/png;base64,%s", share_button_icon.c_str()));
- doodle->share_button->background_color = ParseHexColor(share_button_bg);
+ doodle->share_button->background_color =
+ SkColorSetA(ParseHexColor(share_button_bg),
+ std::max(0.0, std::min(share_button_opacity, 1.0)) * 255.0);
}
if (type == search_provider_logos::LogoType::ANIMATED) {
doodle->image_impression_log_url = cta_log_url;
@@ -352,7 +332,6 @@ NewTabPageHandler::NewTabPageHandler(
Profile* profile,
InstantService* instant_service,
content::WebContents* web_contents,
- NTPUserDataLogger* logger,
const base::Time& ntp_navigation_start_time)
: instant_service_(instant_service),
ntp_background_service_(
@@ -361,17 +340,9 @@ NewTabPageHandler::NewTabPageHandler(
one_google_bar_service_(
OneGoogleBarServiceFactory::GetForProfile(profile)),
profile_(profile),
- favicon_cache_(FaviconServiceFactory::GetForProfile(
- profile,
- ServiceAccessType::EXPLICIT_ACCESS),
- HistoryServiceFactory::GetForProfile(
- profile,
- ServiceAccessType::EXPLICIT_ACCESS)),
- bitmap_fetcher_service_(
- BitmapFetcherServiceFactory::GetForBrowserContext(profile)),
web_contents_(web_contents),
ntp_navigation_start_time_(ntp_navigation_start_time),
- logger_(logger),
+ logger_(profile, GURL(chrome::kChromeUINewTabPageURL)),
promo_service_(PromoServiceFactory::GetForProfile(profile)),
page_{std::move(pending_page)},
receiver_{this, std::move(pending_page_handler)} {
@@ -381,28 +352,18 @@ NewTabPageHandler::NewTabPageHandler(
CHECK(one_google_bar_service_);
CHECK(promo_service_);
CHECK(web_contents_);
- CHECK(logger_);
instant_service_->AddObserver(this);
ntp_background_service_->AddObserver(this);
instant_service_->UpdateNtpTheme();
- OmniboxTabHelper::CreateForWebContents(web_contents);
- OmniboxTabHelper::FromWebContents(web_contents_)->AddObserver(this);
- promo_service_observer_.Add(promo_service_);
- one_google_bar_service_observer_.Add(one_google_bar_service_);
- logger_->SetModulesVisible(
+ promo_service_observation_.Observe(promo_service_);
+ one_google_bar_service_observation_.Observe(one_google_bar_service_);
+ logger_.SetModulesVisible(
profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesVisible));
}
NewTabPageHandler::~NewTabPageHandler() {
instant_service_->RemoveObserver(this);
ntp_background_service_->RemoveObserver(this);
- if (auto* helper = OmniboxTabHelper::FromWebContents(web_contents_)) {
- helper->RemoveObserver(this);
- }
- // Clear pending bitmap requests.
- for (auto bitmap_request_id : bitmap_request_ids_) {
- bitmap_fetcher_service_->CancelRequest(bitmap_request_id);
- }
if (select_file_dialog_) {
select_file_dialog_->ListenerDestroyed();
}
@@ -411,6 +372,7 @@ NewTabPageHandler::~NewTabPageHandler() {
// static
void NewTabPageHandler::RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kNtpModulesVisible, true);
+ registry->RegisterListPref(prefs::kNtpDisabledModules, true);
}
void NewTabPageHandler::AddMostVisitedTile(
@@ -419,16 +381,14 @@ void NewTabPageHandler::AddMostVisitedTile(
AddMostVisitedTileCallback callback) {
bool success = instant_service_->AddCustomLink(url, title);
std::move(callback).Run(success);
- NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_)
- ->LogEvent(NTP_CUSTOMIZE_SHORTCUT_ADD, base::TimeDelta() /* unused */);
+ logger_.LogEvent(NTP_CUSTOMIZE_SHORTCUT_ADD, base::TimeDelta() /* unused */);
}
void NewTabPageHandler::DeleteMostVisitedTile(const GURL& url) {
if (instant_service_->IsCustomLinksEnabled()) {
instant_service_->DeleteCustomLink(url);
- NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_)
- ->LogEvent(NTP_CUSTOMIZE_SHORTCUT_REMOVE,
- base::TimeDelta() /* unused */);
+ logger_.LogEvent(NTP_CUSTOMIZE_SHORTCUT_REMOVE,
+ base::TimeDelta() /* unused */);
} else {
instant_service_->DeleteMostVisitedItem(url);
last_blocklisted_ = url;
@@ -438,9 +398,8 @@ void NewTabPageHandler::DeleteMostVisitedTile(const GURL& url) {
void NewTabPageHandler::RestoreMostVisitedDefaults() {
if (instant_service_->IsCustomLinksEnabled()) {
instant_service_->ResetCustomLinks();
- NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_)
- ->LogEvent(NTP_CUSTOMIZE_SHORTCUT_RESTORE_ALL,
- base::TimeDelta() /* unused */);
+ logger_.LogEvent(NTP_CUSTOMIZE_SHORTCUT_RESTORE_ALL,
+ base::TimeDelta() /* unused */);
} else {
instant_service_->UndoAllMostVisitedDeletions();
}
@@ -465,23 +424,21 @@ void NewTabPageHandler::SetMostVisitedSettings(bool custom_links_enabled,
if (old_visible != visible) {
instant_service_->ToggleShortcutsVisibility(
/* do_notify= */ !toggleCustomLinksEnabled);
- NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_)
- ->LogEvent(NTP_CUSTOMIZE_SHORTCUT_TOGGLE_VISIBILITY,
- base::TimeDelta() /* unused */);
+ logger_.LogEvent(NTP_CUSTOMIZE_SHORTCUT_TOGGLE_VISIBILITY,
+ base::TimeDelta() /* unused */);
}
if (toggleCustomLinksEnabled) {
instant_service_->ToggleMostVisitedOrCustomLinks();
- NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_)
- ->LogEvent(NTP_CUSTOMIZE_SHORTCUT_TOGGLE_TYPE,
- base::TimeDelta() /* unused */);
+ logger_.LogEvent(NTP_CUSTOMIZE_SHORTCUT_TOGGLE_TYPE,
+ base::TimeDelta() /* unused */);
}
}
void NewTabPageHandler::UndoMostVisitedTileAction() {
if (instant_service_->IsCustomLinksEnabled()) {
instant_service_->UndoCustomLinkAction();
- NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_)
- ->LogEvent(NTP_CUSTOMIZE_SHORTCUT_UNDO, base::TimeDelta() /* unused */);
+ logger_.LogEvent(NTP_CUSTOMIZE_SHORTCUT_UNDO,
+ base::TimeDelta() /* unused */);
} else if (last_blocklisted_.is_valid()) {
instant_service_->UndoMostVisitedDeletion(last_blocklisted_);
last_blocklisted_ = GURL();
@@ -532,8 +489,8 @@ void NewTabPageHandler::UpdateMostVisitedTile(
bool success = instant_service_->UpdateCustomLink(
url, new_url != url ? new_url : GURL(), new_title);
std::move(callback).Run(success);
- NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_)
- ->LogEvent(NTP_CUSTOMIZE_SHORTCUT_UPDATE, base::TimeDelta() /* unused */);
+ logger_.LogEvent(NTP_CUSTOMIZE_SHORTCUT_UPDATE,
+ base::TimeDelta() /* unused */);
}
void NewTabPageHandler::GetBackgroundCollections(
@@ -566,14 +523,6 @@ void NewTabPageHandler::GetBackgroundImages(
ntp_background_service_->FetchCollectionImageInfo(collection_id);
}
-void NewTabPageHandler::FocusOmnibox() {
- search::FocusOmnibox(true, web_contents_);
-}
-
-void NewTabPageHandler::PasteIntoOmnibox(const std::string& text) {
- search::PasteIntoOmnibox(base::UTF8ToUTF16(text), web_contents_);
-}
-
void NewTabPageHandler::GetDoodle(GetDoodleCallback callback) {
search_provider_logos::LogoCallbacks callbacks;
std::string fresh_doodle_param;
@@ -625,7 +574,8 @@ void NewTabPageHandler::GetOneGoogleBarParts(
bool wait_for_refresh =
one_google_bar_service_->SetAdditionalQueryParams(query_params);
if (one_google_bar_service_->one_google_bar_data().has_value() &&
- !wait_for_refresh) {
+ !wait_for_refresh &&
+ base::FeatureList::IsEnabled(ntp_features::kCacheOneGoogleBar)) {
OnOneGoogleBarDataUpdated();
}
one_google_bar_load_start_time_ = base::TimeTicks::Now();
@@ -681,12 +631,34 @@ void NewTabPageHandler::OnRestoreModule(const std::string& module_id) {
void NewTabPageHandler::SetModulesVisible(bool visible) {
profile_->GetPrefs()->SetBoolean(prefs::kNtpModulesVisible, visible);
- UpdateModulesVisible();
+ UpdateDisabledModules();
}
-void NewTabPageHandler::UpdateModulesVisible() {
- page_->SetModulesVisible(
- profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesVisible));
+void NewTabPageHandler::SetModuleDisabled(const std::string& module_id,
+ bool disabled) {
+ ListPrefUpdate update(profile_->GetPrefs(), prefs::kNtpDisabledModules);
+ if (disabled) {
+ update->AppendIfNotPresent(std::make_unique<base::Value>(module_id));
+ } else {
+ update->EraseListValue(base::Value(module_id));
+ }
+ UpdateDisabledModules();
+}
+
+void NewTabPageHandler::UpdateDisabledModules() {
+ std::vector<std::string> module_ids;
+ // 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) {
+ module_ids.push_back(id.GetString());
+ }
+ }
+ page_->SetDisabledModules(
+ !profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesVisible),
+ std::move(module_ids));
}
void NewTabPageHandler::OnPromoDataUpdated() {
@@ -723,36 +695,36 @@ void NewTabPageHandler::OnPromoDataUpdated() {
}
void NewTabPageHandler::OnPromoServiceShuttingDown() {
- promo_service_observer_.RemoveAll();
+ promo_service_observation_.Reset();
promo_service_ = nullptr;
}
void NewTabPageHandler::OnAppRendered(double time) {
- logger_->LogEvent(NTP_APP_RENDERED,
- base::Time::FromJsTime(time) - ntp_navigation_start_time_);
+ logger_.LogEvent(NTP_APP_RENDERED,
+ base::Time::FromJsTime(time) - ntp_navigation_start_time_);
}
void NewTabPageHandler::OnMostVisitedTilesRendered(
std::vector<new_tab_page::mojom::MostVisitedTilePtr> tiles,
double time) {
for (size_t i = 0; i < tiles.size(); i++) {
- logger_->LogMostVisitedImpression(MakeNTPTileImpression(*tiles[i], i));
+ logger_.LogMostVisitedImpression(MakeNTPTileImpression(*tiles[i], i));
}
// This call flushes all most visited impression logs to UMA histograms.
// Therefore, it must come last.
- logger_->LogEvent(NTP_ALL_TILES_LOADED,
- base::Time::FromJsTime(time) - ntp_navigation_start_time_);
+ logger_.LogEvent(NTP_ALL_TILES_LOADED,
+ base::Time::FromJsTime(time) - ntp_navigation_start_time_);
}
void NewTabPageHandler::OnOneGoogleBarRendered(double time) {
- logger_->LogEvent(NTP_ONE_GOOGLE_BAR_SHOWN,
- base::Time::FromJsTime(time) - ntp_navigation_start_time_);
+ logger_.LogEvent(NTP_ONE_GOOGLE_BAR_SHOWN,
+ base::Time::FromJsTime(time) - ntp_navigation_start_time_);
}
void NewTabPageHandler::OnPromoRendered(double time,
const base::Optional<GURL>& log_url) {
- logger_->LogEvent(NTP_MIDDLE_SLOT_PROMO_SHOWN,
- base::Time::FromJsTime(time) - ntp_navigation_start_time_);
+ logger_.LogEvent(NTP_MIDDLE_SLOT_PROMO_SHOWN,
+ base::Time::FromJsTime(time) - ntp_navigation_start_time_);
if (log_url.has_value() && log_url->is_valid()) {
Fetch(*log_url, base::BindOnce([](bool, std::unique_ptr<std::string>) {}));
}
@@ -766,7 +738,7 @@ void NewTabPageHandler::OnMostVisitedTileNavigation(
bool ctrl_key,
bool meta_key,
bool shift_key) {
- logger_->LogMostVisitedNavigation(MakeNTPTileImpression(*tile, index));
+ logger_.LogMostVisitedNavigation(MakeNTPTileImpression(*tile, index));
if (!base::FeatureList::IsEnabled(
ntp_features::kNtpHandleMostVisitedNavigationExplicitly))
@@ -877,11 +849,10 @@ void NewTabPageHandler::OnDoodleImageRendered(
OnDoodleImageRenderedCallback callback) {
if (type == new_tab_page::mojom::DoodleImageType::kCta ||
type == new_tab_page::mojom::DoodleImageType::kStatic) {
- logger_->LogEvent(
- type == new_tab_page::mojom::DoodleImageType::kCta
- ? NTP_CTA_LOGO_SHOWN_FROM_CACHE
- : NTP_STATIC_LOGO_SHOWN_FROM_CACHE,
- base::Time::FromJsTime(time) - ntp_navigation_start_time_);
+ logger_.LogEvent(type == new_tab_page::mojom::DoodleImageType::kCta
+ ? NTP_CTA_LOGO_SHOWN_FROM_CACHE
+ : NTP_STATIC_LOGO_SHOWN_FROM_CACHE,
+ base::Time::FromJsTime(time) - ntp_navigation_start_time_);
}
Fetch(log_url,
base::BindOnce(&NewTabPageHandler::OnLogFetchResult,
@@ -997,220 +968,25 @@ void NewTabPageHandler::OnVoiceSearchError(
void NewTabPageHandler::OnModuleImpression(const std::string& module_id,
double time) {
- logger_->LogModuleImpression(
+ logger_.LogModuleImpression(
module_id, base::Time::FromJsTime(time) - ntp_navigation_start_time_);
}
void NewTabPageHandler::OnModuleLoaded(const std::string& module_id,
+ base::TimeDelta duration,
double time) {
- logger_->LogModuleLoaded(
- module_id, base::Time::FromJsTime(time) - ntp_navigation_start_time_);
+ logger_.LogModuleLoaded(
+ module_id, base::Time::FromJsTime(time) - ntp_navigation_start_time_,
+ duration);
}
void NewTabPageHandler::OnModuleUsage(const std::string& module_id) {
- logger_->LogModuleUsage(module_id);
+ logger_.LogModuleUsage(module_id);
}
void NewTabPageHandler::OnModulesRendered(double time) {
- logger_->LogEvent(NTP_MODULES_SHOWN,
- base::Time::FromJsTime(time) - ntp_navigation_start_time_);
-}
-
-void NewTabPageHandler::QueryAutocomplete(const base::string16& input,
- bool prevent_inline_autocomplete) {
- if (!autocomplete_controller_) {
- autocomplete_controller_ = std::make_unique<AutocompleteController>(
- std::make_unique<ChromeAutocompleteProviderClient>(profile_),
- AutocompleteClassifier::DefaultOmniboxProviders());
- autocomplete_controller_->AddObserver(this);
-
- OmniboxControllerEmitter* emitter =
- OmniboxControllerEmitter::GetForBrowserContext(profile_);
- if (emitter)
- autocomplete_controller_->AddObserver(emitter);
- }
-
- if (time_of_first_autocomplete_query_.is_null() && !input.empty())
- time_of_first_autocomplete_query_ = base::TimeTicks::Now();
-
- AutocompleteInput autocomplete_input(
- input, metrics::OmniboxEventProto::NTP_REALBOX,
- ChromeAutocompleteSchemeClassifier(profile_));
- // TODO(tommycli): We use the input being empty as a signal we are requesting
- // on-focus suggestions. It would be nice if we had a more explicit signal.
- autocomplete_input.set_focus_type(input.empty() ? OmniboxFocusType::ON_FOCUS
- : OmniboxFocusType::DEFAULT);
- autocomplete_input.set_prevent_inline_autocomplete(
- prevent_inline_autocomplete);
-
- // We do not want keyword matches for the NTP realbox, which has no UI
- // facilities to support them.
- autocomplete_input.set_prefer_keyword(false);
- autocomplete_input.set_allow_exact_keyword_match(false);
-
- autocomplete_controller_->Start(autocomplete_input);
-}
-
-void NewTabPageHandler::StopAutocomplete(bool clear_result) {
- if (!autocomplete_controller_)
- return;
-
- autocomplete_controller_->Stop(clear_result);
-
- if (clear_result)
- time_of_first_autocomplete_query_ = base::TimeTicks();
-}
-
-void NewTabPageHandler::OpenAutocompleteMatch(
- uint8_t line,
- const GURL& url,
- bool are_matches_showing,
- base::TimeDelta time_elapsed_since_last_focus,
- uint8_t mouse_button,
- bool alt_key,
- bool ctrl_key,
- bool meta_key,
- bool shift_key) {
- if (autocomplete_controller_->result().size() <= line) {
- return;
- }
-
- AutocompleteMatch match(autocomplete_controller_->result().match_at(line));
- if (match.destination_url != url) {
- // TODO(https://crbug.com/1020025): this could be malice or staleness.
- // Either way: don't navigate.
- return;
- }
-
- // TODO(crbug.com/1041129): The following logic for recording Omnibox metrics
- // is largely copied from SearchTabHelper::OpenAutocompleteMatch(). Make sure
- // any changes here is reflected there until one code path is obsolete.
-
- const auto now = base::TimeTicks::Now();
- base::TimeDelta elapsed_time_since_first_autocomplete_query =
- now - time_of_first_autocomplete_query_;
- autocomplete_controller_->UpdateMatchDestinationURLWithQueryFormulationTime(
- elapsed_time_since_first_autocomplete_query, &match);
-
- LOCAL_HISTOGRAM_BOOLEAN("Omnibox.EventCount", true);
-
- UMA_HISTOGRAM_MEDIUM_TIMES("Omnibox.FocusToOpenTimeAnyPopupState3",
- time_elapsed_since_last_focus);
-
- if (ui::PageTransitionTypeIncludingQualifiersIs(match.transition,
- ui::PAGE_TRANSITION_TYPED)) {
- navigation_metrics::RecordOmniboxURLNavigation(match.destination_url);
- }
- // The following histogram should be recorded for both TYPED and pasted
- // URLs, but should still exclude reloads.
- if (ui::PageTransitionTypeIncludingQualifiersIs(match.transition,
- ui::PAGE_TRANSITION_TYPED) ||
- ui::PageTransitionTypeIncludingQualifiersIs(match.transition,
- ui::PAGE_TRANSITION_LINK)) {
- net::cookie_util::RecordCookiePortOmniboxHistograms(match.destination_url);
- }
-
- SuggestionAnswer::LogAnswerUsed(match.answer);
-
- TemplateURLService* template_url_service =
- TemplateURLServiceFactory::GetForProfile(profile_);
- if (template_url_service &&
- template_url_service->IsSearchResultsPageFromDefaultSearchProvider(
- match.destination_url)) {
- // Note: will always be false for the realbox.
- UMA_HISTOGRAM_BOOLEAN("Omnibox.Search.OffTheRecord",
- profile_->IsOffTheRecord());
- base::RecordAction(
- base::UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP"));
- }
-
- AutocompleteMatch::LogSearchEngineUsed(match, template_url_service);
-
- auto* bookmark_model = BookmarkModelFactory::GetForBrowserContext(profile_);
- if (bookmark_model->IsBookmarked(match.destination_url)) {
- RecordBookmarkLaunch(BOOKMARK_LAUNCH_LOCATION_OMNIBOX,
- ProfileMetrics::GetBrowserProfileType(profile_));
- }
-
- const AutocompleteInput& input = autocomplete_controller_->input();
- WindowOpenDisposition disposition = ui::DispositionFromClick(
- /*middle_button=*/mouse_button == 1, alt_key, ctrl_key, meta_key,
- shift_key);
-
- base::TimeDelta default_time_delta = base::TimeDelta::FromMilliseconds(-1);
-
- if (time_of_first_autocomplete_query_.is_null())
- elapsed_time_since_first_autocomplete_query = default_time_delta;
-
- base::TimeDelta elapsed_time_since_last_change_to_default_match =
- !autocomplete_controller_->last_time_default_match_changed().is_null()
- ? now - autocomplete_controller_->last_time_default_match_changed()
- : default_time_delta;
-
- OmniboxLog log(
- /*text=*/input.focus_type() != OmniboxFocusType::DEFAULT
- ? base::string16()
- : input.text(),
- /*just_deleted_text=*/input.prevent_inline_autocomplete(),
- /*input_type=*/input.type(),
- /*in_keyword_mode=*/false,
- /*entry_method=*/metrics::OmniboxEventProto::INVALID,
- /*is_popup_open=*/are_matches_showing,
- /*selected_index=*/line,
- /*disposition=*/disposition,
- /*is_paste_and_go=*/false,
- /*tab_id=*/sessions::SessionTabHelper::IdForTab(web_contents_),
- /*current_page_classification=*/metrics::OmniboxEventProto::NTP_REALBOX,
- /*elapsed_time_since_user_first_modified_omnibox=*/
- elapsed_time_since_first_autocomplete_query,
- /*completed_length=*/match.allowed_to_be_default_match
- ? match.inline_autocompletion.length()
- : base::string16::npos,
- /*elapsed_time_since_last_change_to_default_match=*/
- elapsed_time_since_last_change_to_default_match,
- /*result=*/autocomplete_controller_->result());
- autocomplete_controller_->AddProviderAndTriggeringLogs(&log);
-
- OmniboxEventGlobalTracker::GetInstance()->OnURLOpened(&log);
-
- predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_)
- ->OnOmniboxOpenedUrl(log);
-
- web_contents_->OpenURL(
- content::OpenURLParams(match.destination_url, content::Referrer(),
- disposition, match.transition, false));
-}
-
-void NewTabPageHandler::DeleteAutocompleteMatch(uint8_t line) {
- if (autocomplete_controller_->result().size() <= line ||
- !autocomplete_controller_->result().match_at(line).SupportsDeletion()) {
- return;
- }
-
- const auto& match = autocomplete_controller_->result().match_at(line);
- if (match.SupportsDeletion()) {
- autocomplete_controller_->Stop(false);
- autocomplete_controller_->DeleteMatch(match);
- }
-}
-
-void NewTabPageHandler::ToggleSuggestionGroupIdVisibility(
- int32_t suggestion_group_id) {
- 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);
-}
-
-void NewTabPageHandler::LogCharTypedToRepaintLatency(base::TimeDelta latency) {
- UMA_HISTOGRAM_TIMES("NewTabPage.Realbox.CharTypedToRepaintLatency.ToPaint",
- latency);
+ logger_.LogEvent(NTP_MODULES_SHOWN,
+ base::Time::FromJsTime(time) - ntp_navigation_start_time_);
}
void NewTabPageHandler::NtpThemeChanged(const NtpTheme& ntp_theme) {
@@ -1327,21 +1103,6 @@ void NewTabPageHandler::OnNtpBackgroundServiceShuttingDown() {
ntp_background_service_ = nullptr;
}
-void NewTabPageHandler::OnOmniboxInputStateChanged() {
- // This handler was added for the local NTP to show the fakebox when pressing
- // escape while the omnibox has focus. The WebUI NTP only shows the fakebox
- // when blurring the omnibox. Thus, we do nothing here.
-}
-
-void NewTabPageHandler::OnOmniboxFocusChanged(OmniboxFocusState state,
- OmniboxFocusChangeReason reason) {
- page_->SetFakeboxFocused(state == OMNIBOX_FOCUS_INVISIBLE);
- // Don't make fakebox re-appear for a short moment before navigating away.
- if (web_contents_->GetController().GetPendingEntry() == nullptr) {
- page_->SetFakeboxVisible(reason != OMNIBOX_FOCUS_CHANGE_TYPING);
- }
-}
-
void NewTabPageHandler::OnOneGoogleBarDataUpdated() {
base::Optional<OneGoogleBarData> data =
one_google_bar_service_->one_google_bar_data();
@@ -1371,7 +1132,7 @@ void NewTabPageHandler::OnOneGoogleBarDataUpdated() {
}
void NewTabPageHandler::OnOneGoogleBarServiceShuttingDown() {
- one_google_bar_service_observer_.RemoveAll();
+ one_google_bar_service_observation_.Reset();
one_google_bar_service_ = nullptr;
}
@@ -1401,49 +1162,6 @@ void NewTabPageHandler::FileSelectionCanceled(void* params) {
std::move(choose_local_custom_background_callback_).Run(false);
}
-void NewTabPageHandler::OnResultChanged(AutocompleteController* controller,
- bool default_match_changed) {
- DCHECK(controller == autocomplete_controller_.get());
-
- page_->AutocompleteResultChanged(omnibox::CreateAutocompleteResult(
- autocomplete_controller_->input().text(),
- autocomplete_controller_->result(), profile_->GetPrefs()));
-
- // Clear pending bitmap requests before requesting new ones.
- for (auto bitmap_request_id : bitmap_request_ids_) {
- bitmap_fetcher_service_->CancelRequest(bitmap_request_id);
- }
- bitmap_request_ids_.clear();
-
- int match_index = -1;
- for (const auto& match : autocomplete_controller_->result()) {
- match_index++;
-
- // Request bitmaps for matche images.
- if (!match.image_url.is_empty()) {
- bitmap_request_ids_.push_back(bitmap_fetcher_service_->RequestImage(
- match.image_url,
- base::BindOnce(&NewTabPageHandler::OnRealboxBitmapFetched,
- weak_ptr_factory_.GetWeakPtr(), match_index,
- match.image_url)));
- }
-
- // Request favicons for navigational matches.
- // TODO(crbug.com/1075848): Investigate using chrome://favicon2.
- if (!AutocompleteMatch::IsSearchType(match.type) &&
- match.type != AutocompleteMatchType::DOCUMENT_SUGGESTION) {
- gfx::Image favicon = favicon_cache_.GetLargestFaviconForPageUrl(
- match.destination_url,
- base::BindOnce(&NewTabPageHandler::OnRealboxFaviconFetched,
- weak_ptr_factory_.GetWeakPtr(), match_index,
- match.destination_url));
- if (!favicon.IsEmpty()) {
- OnRealboxFaviconFetched(match_index, match.destination_url, favicon);
- }
- }
- }
-}
-
void NewTabPageHandler::OnLogoAvailable(
GetDoodleCallback callback,
search_provider_logos::LogoCallbackReason type,
@@ -1466,7 +1184,8 @@ void NewTabPageHandler::OnLogoAvailable(
logo->metadata.width_px, logo->metadata.height_px, "#ffffff",
logo->metadata.share_button_x, logo->metadata.share_button_y,
logo->metadata.share_button_icon, logo->metadata.share_button_bg,
- logo->metadata.log_url, logo->metadata.cta_log_url);
+ logo->metadata.share_button_opacity, logo->metadata.log_url,
+ logo->metadata.cta_log_url);
if (logo->dark_encoded_image) {
image_doodle->dark = MakeImageDoodle(
logo->metadata.type, logo->dark_encoded_image->data(),
@@ -1476,7 +1195,8 @@ void NewTabPageHandler::OnLogoAvailable(
logo->metadata.dark_share_button_x,
logo->metadata.dark_share_button_y,
logo->metadata.dark_share_button_icon,
- logo->metadata.dark_share_button_bg, logo->metadata.dark_log_url,
+ logo->metadata.dark_share_button_bg,
+ logo->metadata.dark_share_button_opacity, logo->metadata.dark_log_url,
logo->metadata.dark_cta_log_url);
}
image_doodle->on_click_url = logo->metadata.on_click_url;
@@ -1497,29 +1217,8 @@ void NewTabPageHandler::OnLogoAvailable(
std::move(callback).Run(std::move(doodle));
}
-void NewTabPageHandler::OnRealboxBitmapFetched(int match_index,
- const GURL& image_url,
- const SkBitmap& bitmap) {
- auto data = gfx::Image::CreateFrom1xBitmap(bitmap).As1xPNGBytes();
- std::string data_url =
- webui::GetPngDataUrl(data->front_as<unsigned char>(), data->size());
-
- page_->AutocompleteMatchImageAvailable(match_index, image_url, data_url);
-}
-
-void NewTabPageHandler::OnRealboxFaviconFetched(int match_index,
- const GURL& page_url,
- const gfx::Image& favicon) {
- DCHECK(!favicon.IsEmpty());
- auto data = favicon.As1xPNGBytes();
- std::string data_url =
- webui::GetPngDataUrl(data->front_as<unsigned char>(), data->size());
-
- page_->AutocompleteMatchImageAvailable(match_index, page_url, data_url);
-}
-
void NewTabPageHandler::LogEvent(NTPLoggingEventType event) {
- logger_->LogEvent(event, base::TimeDelta() /* unused */);
+ logger_.LogEvent(event, base::TimeDelta() /* unused */);
}
void NewTabPageHandler::Fetch(const GURL& url,
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 66ababb9fb9..865b53850a5 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
@@ -11,21 +11,18 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/time/time.h"
-#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"
#include "chrome/browser/search/background/ntp_background_service_observer.h"
#include "chrome/browser/search/instant_service_observer.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service_observer.h"
#include "chrome/browser/search/promos/promo_service.h"
#include "chrome/browser/search/promos/promo_service_observer.h"
-#include "chrome/browser/ui/omnibox/omnibox_tab_helper.h"
+#include "chrome/browser/ui/search/ntp_user_data_logger.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom.h"
#include "chrome/common/search/instant_types.h"
#include "chrome/common/search/ntp_logging_events.h"
-#include "components/omnibox/browser/autocomplete_controller.h"
-#include "components/omnibox/browser/favicon_cache.h"
#include "components/search_provider_logos/logo_common.h"
#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@@ -51,10 +48,8 @@ class LogoService;
class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
public InstantServiceObserver,
public NtpBackgroundServiceObserver,
- public OmniboxTabHelper::Observer,
public OneGoogleBarServiceObserver,
public ui::SelectFileDialog::Listener,
- public AutocompleteController::Observer,
public PromoServiceObserver {
public:
NewTabPageHandler(mojo::PendingReceiver<new_tab_page::mojom::PageHandler>
@@ -63,7 +58,6 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
Profile* profile,
InstantService* instant_service,
content::WebContents* web_contents,
- NTPUserDataLogger* logger,
const base::Time& ntp_navigation_start_time);
~NewTabPageHandler() override;
@@ -97,8 +91,6 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
GetBackgroundCollectionsCallback callback) override;
void GetBackgroundImages(const std::string& collection_id,
GetBackgroundImagesCallback callback) override;
- void FocusOmnibox() override;
- void PasteIntoOmnibox(const std::string& text) override;
void GetDoodle(GetDoodleCallback callback) override;
void ChooseLocalCustomBackground(
ChooseLocalCustomBackgroundCallback callback) override;
@@ -108,7 +100,8 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
void OnDismissModule(const std::string& module_id) override;
void OnRestoreModule(const std::string& module_id) override;
void SetModulesVisible(bool visible) override;
- void UpdateModulesVisible() override;
+ void SetModuleDisabled(const std::string& module_id, bool disabled) override;
+ void UpdateDisabledModules() override;
void OnAppRendered(double time) override;
void OnMostVisitedTilesRendered(
std::vector<new_tab_page::mojom::MostVisitedTilePtr> tiles,
@@ -139,24 +132,11 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
new_tab_page::mojom::VoiceSearchAction action) override;
void OnVoiceSearchError(new_tab_page::mojom::VoiceSearchError error) override;
void OnModuleImpression(const std::string& module_id, double time) override;
- void OnModuleLoaded(const std::string& module_id, double time) override;
+ void OnModuleLoaded(const std::string& module_id,
+ base::TimeDelta duration,
+ double time) override;
void OnModuleUsage(const std::string& module_id) override;
void OnModulesRendered(double time) override;
- void QueryAutocomplete(const base::string16& input,
- bool prevent_inline_autocomplete) override;
- void StopAutocomplete(bool clear_result) override;
- void OpenAutocompleteMatch(uint8_t line,
- const GURL& url,
- bool are_matches_showing,
- base::TimeDelta time_elapsed_since_last_focus,
- uint8_t mouse_button,
- bool alt_key,
- bool ctrl_key,
- bool meta_key,
- bool shift_key) override;
- void DeleteAutocompleteMatch(uint8_t line) override;
- void ToggleSuggestionGroupIdVisibility(int32_t suggestion_group_id) override;
- void LogCharTypedToRepaintLatency(base::TimeDelta latency) override;
private:
// InstantServiceObserver:
@@ -169,11 +149,6 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
void OnNextCollectionImageAvailable() override;
void OnNtpBackgroundServiceShuttingDown() override;
- // OmniboxTabHelper::Observer:
- void OnOmniboxInputStateChanged() override;
- void OnOmniboxFocusChanged(OmniboxFocusState state,
- OmniboxFocusChangeReason reason) override;
-
// OneGoogleBarServiceObserver:
void OnOneGoogleBarDataUpdated() override;
void OnOneGoogleBarServiceShuttingDown() override;
@@ -188,22 +163,11 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
void* params) override;
void FileSelectionCanceled(void* params) override;
- // AutocompleteController::Observer:
- void OnResultChanged(AutocompleteController* controller,
- bool default_match_changed) override;
-
void OnLogoAvailable(
GetDoodleCallback callback,
search_provider_logos::LogoCallbackReason type,
const base::Optional<search_provider_logos::EncodedLogo>& logo);
- void OnRealboxBitmapFetched(int match_index,
- const GURL& image_url,
- const SkBitmap& bitmap);
- void OnRealboxFaviconFetched(int match_index,
- const GURL& page_url,
- const gfx::Image& favicon);
-
void LogEvent(NTPLoggingEventType event);
typedef base::OnceCallback<void(bool success,
@@ -229,26 +193,21 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
base::TimeTicks background_images_request_start_time_;
std::vector<GetOneGoogleBarPartsCallback> one_google_bar_parts_callbacks_;
OneGoogleBarService* one_google_bar_service_;
- ScopedObserver<OneGoogleBarService, OneGoogleBarServiceObserver>
- one_google_bar_service_observer_{this};
+ base::ScopedObservation<OneGoogleBarService, OneGoogleBarServiceObserver>
+ one_google_bar_service_observation_{this};
base::Optional<base::TimeTicks> one_google_bar_load_start_time_;
Profile* profile_;
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
- std::unique_ptr<AutocompleteController> autocomplete_controller_;
- FaviconCache favicon_cache_;
- BitmapFetcherService* bitmap_fetcher_service_;
- std::vector<BitmapFetcherService::RequestId> bitmap_request_ids_;
- base::TimeTicks time_of_first_autocomplete_query_;
content::WebContents* web_contents_;
base::Time ntp_navigation_start_time_;
- NTPUserDataLogger* logger_;
+ NTPUserDataLogger logger_;
std::unordered_map<const network::SimpleURLLoader*,
std::unique_ptr<network::SimpleURLLoader>>
loader_map_;
std::vector<GetPromoCallback> promo_callbacks_;
PromoService* promo_service_;
- ScopedObserver<PromoService, PromoServiceObserver> promo_service_observer_{
- this};
+ base::ScopedObservation<PromoService, PromoServiceObserver>
+ promo_service_observation_{this};
base::Optional<base::TimeTicks> promo_load_start_time_;
// These are located at the end of the list of member variables to ensure the
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 1b7460da19c..242d755a8bf 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
@@ -5,9 +5,9 @@
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/search/instant_service.h"
-#include "chrome/browser/ui/search/ntp_user_data_logger.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom.h"
#include "chrome/common/search/omnibox.mojom.h"
+#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_web_contents_factory.h"
@@ -20,6 +20,8 @@
namespace {
+using testing::DoAll;
+
class MockInstantService : public InstantService {
public:
explicit MockInstantService(Profile* profile) : InstantService(profile) {}
@@ -29,12 +31,6 @@ class MockInstantService : public InstantService {
MOCK_METHOD0(UpdateNtpTheme, void());
};
-class MockNTPUserDataLogger : public NTPUserDataLogger {
- public:
- MockNTPUserDataLogger() : NTPUserDataLogger(nullptr) {}
- ~MockNTPUserDataLogger() override = default;
-};
-
class MockPage : public new_tab_page::mojom::Page {
public:
MockPage() = default;
@@ -48,9 +44,7 @@ class MockPage : public new_tab_page::mojom::Page {
MOCK_METHOD1(SetMostVisitedInfo,
void(new_tab_page::mojom::MostVisitedInfoPtr));
MOCK_METHOD1(SetTheme, void(new_tab_page::mojom::ThemePtr));
- MOCK_METHOD1(SetFakeboxFocused, void(bool));
- MOCK_METHOD1(SetFakeboxVisible, void(bool));
- MOCK_METHOD1(SetModulesVisible, void(bool));
+ MOCK_METHOD2(SetDisabledModules, void(bool, const std::vector<std::string>&));
MOCK_METHOD1(AutocompleteResultChanged,
void(search::mojom::AutocompleteResultPtr));
MOCK_METHOD3(AutocompleteMatchImageAvailable,
@@ -76,7 +70,7 @@ class NewTabPageHandlerTest : public testing::Test {
handler_ = std::make_unique<NewTabPageHandler>(
mojo::PendingReceiver<new_tab_page::mojom::PageHandler>(),
mock_page_.BindAndGetRemote(), &profile_, &mock_instant_service_,
- web_contents_, &logger_, base::Time::Now());
+ web_contents_, base::Time::Now());
EXPECT_EQ(handler_.get(), instant_service_observer_);
}
@@ -90,7 +84,6 @@ class NewTabPageHandlerTest : public testing::Test {
MockInstantService mock_instant_service_;
content::TestWebContentsFactory factory_;
content::WebContents* web_contents_; // Weak. Owned by factory_.
- MockNTPUserDataLogger logger_;
base::HistogramTester histogram_tester_;
std::unique_ptr<NewTabPageHandler> handler_;
InstantServiceObserver* instant_service_observer_;
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 2960060a306..375fcec9f9e 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
@@ -8,21 +8,20 @@
#include <utility>
#include "chrome/browser/buildflags.h"
-#include "chrome/browser/media/kaleidoscope/constants.h"
-#include "chrome/browser/media/kaleidoscope/kaleidoscope_data_provider_impl.h"
-#include "chrome/browser/media/kaleidoscope/kaleidoscope_ui.h"
+#include "chrome/browser/cart/cart_handler.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search/drive/drive_handler.h"
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search/task_module/task_module_handler.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/browser/ui/search/ntp_user_data_logger.h"
#include "chrome/browser/ui/search/omnibox_mojo_utils.h"
#include "chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h"
#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h"
#include "chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.h"
#include "chrome/browser/ui/webui/new_tab_page/untrusted_source.h"
+#include "chrome/browser/ui/webui/realbox/realbox_handler.h"
#include "chrome/browser/ui/webui/sanitized_image_source.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/browser/ui/webui/webui_util.h"
@@ -46,7 +45,7 @@
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
-#include "ui/resources/grit/webui_resources.h"
+#include "ui/resources/grit/webui_generated_resources.h"
#include "url/url_util.h"
#if !defined(OFFICIAL_BUILD)
@@ -58,9 +57,6 @@ using content::WebContents;
namespace {
-constexpr char kGeneratedPath[] =
- "@out_folder@/gen/chrome/browser/resources/new_tab_page/";
-
content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUINewTabPageHost);
@@ -76,7 +72,6 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
.spec());
// Realbox.
- source->AddBoolean("realboxEnabled", true);
source->AddBoolean(
"realboxMatchOmniboxTheme",
base::FeatureList::IsEnabled(ntp_features::kRealboxMatchOmniboxTheme));
@@ -85,6 +80,8 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
base::FeatureList::IsEnabled(ntp_features::kRealboxUseGoogleGIcon)
? omnibox::kGoogleGIconResourceName
: omnibox::kSearchIconResourceName);
+ source->AddString("realboxHint", l10n_util::GetStringUTF8(
+ IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT_MD));
source->AddBoolean(
"handleMostVisitedNavigationExplicitly",
@@ -98,11 +95,17 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
"oneGoogleBarModalOverlaysEnabled",
base::FeatureList::IsEnabled(ntp_features::kOneGoogleBarModalOverlays));
+ source->AddBoolean("shortcutsEnabled",
+ base::FeatureList::IsEnabled(ntp_features::kNtpShortcuts));
+ source->AddBoolean("logoEnabled",
+ base::FeatureList::IsEnabled(ntp_features::kNtpLogo));
source->AddBoolean(
- "themeModeDoodlesEnabled",
- base::FeatureList::IsEnabled(ntp_features::kWebUIThemeModeDoodles));
+ "middleSlotPromoEnabled",
+ base::FeatureList::IsEnabled(ntp_features::kNtpMiddleSlotPromo));
source->AddBoolean("modulesEnabled",
base::FeatureList::IsEnabled(ntp_features::kModules));
+ source->AddInteger("modulesLoadTimeout",
+ ntp_features::GetModulesLoadTimeout().InMilliseconds());
static constexpr webui::LocalizedString kStrings[] = {
{"doneButton", IDS_DONE},
@@ -126,6 +129,7 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{"nameField", IDS_NTP_CUSTOM_LINKS_NAME},
{"restoreDefaultLinks", IDS_NTP_CONFIRM_MSG_RESTORE_DEFAULTS},
{"restoreThumbnailsShort", IDS_NEW_TAB_RESTORE_THUMBNAILS_SHORT_LINK},
+ {"shortcutAlreadyExists", IDS_NTP_CUSTOM_LINKS_ALREADY_EXISTS},
{"urlField", IDS_NTP_CUSTOM_LINKS_URL},
// Customize button and dialog.
@@ -140,8 +144,8 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{"defaultThemeLabel", IDS_NTP_CUSTOMIZE_DEFAULT_LABEL},
{"hideShortcuts", IDS_NTP_CUSTOMIZE_HIDE_SHORTCUTS_LABEL},
{"hideShortcutsDesc", IDS_NTP_CUSTOMIZE_HIDE_SHORTCUTS_DESC},
- {"hideModules", IDS_NTP_CUSTOMIZE_HIDE_MODULES_LABEL},
- {"hideModulesDesc", IDS_NTP_CUSTOMIZE_HIDE_MODULES_DESC},
+ {"hideAllCards", IDS_NTP_CUSTOMIZE_HIDE_ALL_CARDS_LABEL},
+ {"customizeCards", IDS_NTP_CUSTOMIZE_CUSTOMIZE_CARDS_LABEL},
{"mostVisited", IDS_NTP_CUSTOMIZE_MOST_VISITED_LABEL},
{"myShortcuts", IDS_NTP_CUSTOMIZE_MY_SHORTCUTS_LABEL},
{"noBackground", IDS_NTP_CUSTOMIZE_NO_BACKGROUND_LABEL},
@@ -177,6 +181,8 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{"searchBoxHint", IDS_GOOGLE_SEARCH_BOX_EMPTY_HINT_MD},
{"realboxSeparator", IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR},
{"removeSuggestion", IDS_OMNIBOX_REMOVE_SUGGESTION},
+ {"removeSuggestionA11ySuffix", IDS_ACC_REMOVE_SUGGESTION_SUFFIX},
+ {"removeSuggestionA11yPrefix", IDS_ACC_REMOVE_SUGGESTION_FOCUSED_PREFIX},
{"hideSuggestions", IDS_TOOLTIP_HEADER_HIDE_SUGGESTIONS_BUTTON},
{"showSuggestions", IDS_TOOLTIP_HEADER_SHOW_SUGGESTIONS_BUTTON},
{"hideSection", IDS_ACC_HEADER_HIDE_SUGGESTIONS_BUTTON},
@@ -195,15 +201,43 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
// Modules.
{"dismissModuleToastMessage", IDS_NTP_MODULES_DISMISS_TOAST_MESSAGE},
+ {"disableModuleToastMessage", IDS_NTP_MODULES_DISABLE_TOAST_MESSAGE},
{"moduleInfoButtonTitle", IDS_NTP_MODULES_INFO_BUTTON_TITLE},
- {"moduleDismissButtonTitle", IDS_NTP_MODULES_DISMISS_BUTTON_TITLE},
+ {"modulesDismissButtonText", IDS_NTP_MODULES_DISMISS_BUTTON_TEXT},
+ {"modulesDisableButtonText", IDS_NTP_MODULES_DISABLE_BUTTON_TEXT},
+ {"modulesCustomizeButtonText", IDS_NTP_MODULES_CUSTOMIZE_BUTTON_TEXT},
+ {"modulesShoppingTasksSentence", IDS_NTP_MODULES_SHOPPING_TASKS_SENTENCE},
+ {"modulesShoppingTasksLower", IDS_NTP_MODULES_SHOPPING_TASKS_LOWER},
+ {"modulesRecipeTasksSentence", IDS_NTP_MODULES_RECIPE_TASKS_SENTENCE},
+ {"modulesRecipeTasksLower", IDS_NTP_MODULES_RECIPE_TASKS_LOWER},
+ {"modulesRecipeTasksLowerThese",
+ IDS_NTP_MODULES_RECIPE_TASKS_LOWER_THESE},
+ {"modulesCartSentence", IDS_NTP_MODULES_CART_SENTENCE},
+ {"modulesCartLower", IDS_NTP_MODULES_CART_LOWER},
+ {"modulesCartLowerThese", IDS_NTP_MODULES_CART_LOWER_THESE},
+ {"modulesCartLowerYour", IDS_NTP_MODULES_CART_LOWER_YOUR},
+ {"modulesDriveSentence", IDS_NTP_MODULES_DRIVE_SENTENCE},
+ {"modulesDummyLower", IDS_NTP_MODULES_DUMMY_LOWER},
+ {"modulesDriveTitle", IDS_NTP_MODULES_DRIVE_TITLE},
{"modulesDummyTitle", IDS_NTP_MODULES_DUMMY_TITLE},
{"modulesDummy2Title", IDS_NTP_MODULES_DUMMY2_TITLE},
{"modulesKaleidoscopeTitle", IDS_NTP_MODULES_KALEIDOSCOPE_TITLE},
{"modulesTasksInfoTitle", IDS_NTP_MODULES_SHOPPING_TASKS_INFO_TITLE},
{"modulesTasksInfoClose", IDS_NTP_MODULES_SHOPPING_TASKS_INFO_CLOSE},
+ {"modulesCartHeaderNew", IDS_NTP_MODULES_CART_HEADER_CHIP_NEW},
+ {"modulesCartWarmWelcome", IDS_NTP_MODULES_CART_WARM_WELCOME},
+ {"modulesCartModuleMenuHideToastMessage",
+ IDS_NTP_MODULES_CART_MODULE_MENU_HIDE_TOAST_MESSAGE},
+ {"modulesCartCartMenuHideMerchant",
+ IDS_NTP_MODULES_CART_CART_MENU_HIDE_MERCHANT},
+ {"modulesCartCartMenuHideMerchantToastMessage",
+ IDS_NTP_MODULES_CART_CART_MENU_HIDE_MERCHANT_TOAST_MESSAGE},
+ {"modulesCartCartMenuRemoveMerchant",
+ IDS_NTP_MODULES_CART_CART_MENU_REMOVE_MERCHANT},
+ {"modulesCartCartMenuRemoveMerchantToastMessage",
+ IDS_NTP_MODULES_CART_CART_MENU_REMOVE_MERCHANT_TOAST_MESSAGE},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->AddString("modulesTasksInfo1",
l10n_util::GetStringFUTF16(
@@ -218,7 +252,7 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
// are set in Javascript.
static constexpr webui::ResourcePath kImages[] = {
{omnibox::kGoogleGIconResourceName,
- IDR_WEBUI_IMAGES_200_LOGO_GOOGLE_G_PNG},
+ IDR_WEBUI_IMAGES_200_LOGO_GOOGLEG_PNG},
{omnibox::kBookmarkIconResourceName, IDR_LOCAL_NTP_ICONS_BOOKMARK},
{omnibox::kCalculatorIconResourceName, IDR_LOCAL_NTP_ICONS_CALCULATOR},
{omnibox::kClockIconResourceName, IDR_LOCAL_NTP_ICONS_CLOCK},
@@ -236,44 +270,23 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{omnibox::kPageIconResourceName, IDR_LOCAL_NTP_ICONS_PAGE},
{omnibox::kSearchIconResourceName, IDR_WEBUI_IMAGES_ICON_SEARCH_SVG},
{omnibox::kTrendingUpIconResourceName, IDR_LOCAL_NTP_ICONS_TRENDING_UP}};
- webui::AddResourcePathsBulk(source, kImages);
-
-#if BUILDFLAG(ENABLE_KALEIDOSCOPE)
- source->AddBoolean("kaleidoscopeModuleEnabled",
- base::FeatureList::IsEnabled(media::kKaleidoscopeModule));
-#else
- source->AddBoolean("kaleidoscopeModuleEnabled", false);
-#endif // BUILDFLAG(ENABLE_KALEIDOSCOPE)
+ source->AddResourcePaths(kImages);
+
source->AddBoolean(
"recipeTasksModuleEnabled",
base::FeatureList::IsEnabled(ntp_features::kNtpRecipeTasksModule));
source->AddBoolean(
"shoppingTasksModuleEnabled",
base::FeatureList::IsEnabled(ntp_features::kNtpShoppingTasksModule));
+ source->AddBoolean(
+ "chromeCartModuleEnabled",
+ base::FeatureList::IsEnabled(ntp_features::kNtpChromeCartModule));
+ source->AddBoolean("driveModuleEnabled", base::FeatureList::IsEnabled(
+ ntp_features::kNtpDriveModule));
- source->AddResourcePath("new_tab_page.mojom-lite.js",
- IDR_NEW_TAB_PAGE_MOJO_LITE_JS);
- source->AddResourcePath("omnibox.mojom-lite.js",
- IDR_NEW_TAB_PAGE_OMNIBOX_MOJO_LITE_JS);
- source->AddResourcePath("promo_browser_command.mojom-lite.js",
- IDR_NEW_TAB_PAGE_PROMO_BROWSER_COMMAND_MOJO_LITE_JS);
- source->AddResourcePath(
- "modules/task_module/task_module.mojom-lite.js",
- IDR_NEW_TAB_PAGE_MODULES_TASK_MODULE_TASK_MODULE_MOJO_LITE_JS);
-#if !defined(OFFICIAL_BUILD)
- source->AddResourcePath("foo.mojom-lite.js",
- IDR_NEW_TAB_PAGE_FOO_MOJO_LITE_JS);
-#endif
-#if BUILDFLAG(OPTIMIZE_WEBUI)
- source->AddResourcePath("new_tab_page.js",
- IDR_NEW_TAB_PAGE_NEW_TAB_PAGE_ROLLUP_JS);
- source->AddResourcePath("shared.rollup.js",
- IDR_NEW_TAB_PAGE_SHARED_ROLLUP_JS);
- source->AddResourcePath("lazy_load.js", IDR_NEW_TAB_PAGE_LAZY_LOAD_ROLLUP_JS);
-#endif // BUILDFLAG(OPTIMIZE_WEBUI)
webui::SetupWebUIDataSource(
source, base::make_span(kNewTabPageResources, kNewTabPageResourcesSize),
- kGeneratedPath, IDR_NEW_TAB_PAGE_NEW_TAB_PAGE_HTML);
+ IDR_NEW_TAB_PAGE_NEW_TAB_PAGE_HTML);
// Allows creating <script> and inlining as well as network requests to
// support inlining the OneGoogleBar.
@@ -282,17 +295,15 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
// script-src.
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test chrome://kaleidoscope "
+ "script-src chrome://resources chrome://test "
"'self' 'unsafe-inline' https:;");
// Allow embedding of iframes from the One Google Bar and
- // chrome-untrusted://new-tab-page for other external content and resources
- // and chrome-untrusted://kaleidoscope for Kaleidoscope.
+ // chrome-untrusted://new-tab-page for other external content and resources.
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ChildSrc,
- base::StringPrintf("child-src https: %s %s %s;",
+ base::StringPrintf("child-src https: %s %s;",
google_util::CommandLineGoogleBaseURL().spec().c_str(),
- chrome::kChromeUIUntrustedNewTabPageUrl,
- kKaleidoscopeUntrustedContentUIURL));
+ chrome::kChromeUIUntrustedNewTabPageUrl));
return source;
}
@@ -330,12 +341,6 @@ NewTabPageUI::NewTabPageUI(content::WebUI* web_ui)
profile_,
std::make_unique<ThemeSource>(profile_, /*serve_untrusted=*/true));
- content::WebUIDataSource::Add(profile_,
- KaleidoscopeUI::CreateWebUIDataSource());
-
- content::WebUIDataSource::Add(
- profile_, KaleidoscopeUI::CreateUntrustedWebUIDataSource());
-
web_ui->AddRequestableScheme(content::kChromeUIUntrustedScheme);
instant_service_->AddObserver(this);
@@ -364,6 +369,12 @@ void NewTabPageUI::BindInterface(
}
void NewTabPageUI::BindInterface(
+ mojo::PendingReceiver<realbox::mojom::PageHandler> pending_page_handler) {
+ realbox_handler_ = std::make_unique<RealboxHandler>(
+ std::move(pending_page_handler), profile_, web_contents_);
+}
+
+void NewTabPageUI::BindInterface(
mojo::PendingReceiver<promo_browser_command::mojom::CommandHandler>
pending_page_handler) {
promo_browser_command_handler_ = std::make_unique<PromoBrowserCommandHandler>(
@@ -381,18 +392,18 @@ void NewTabPageUI::BindInterface(
}
void NewTabPageUI::BindInterface(
- mojo::PendingReceiver<media::mojom::KaleidoscopeDataProvider>
- pending_page_handler) {
- kaleidoscope_data_provider_ = std::make_unique<KaleidoscopeDataProviderImpl>(
- std::move(pending_page_handler), profile_, nullptr);
-}
-
-void NewTabPageUI::BindInterface(
mojo::PendingReceiver<task_module::mojom::TaskModuleHandler>
pending_receiver) {
task_module_handler_ = std::make_unique<TaskModuleHandler>(
std::move(pending_receiver), profile_);
}
+
+void NewTabPageUI::BindInterface(
+ mojo::PendingReceiver<drive::mojom::DriveHandler> pending_receiver) {
+ drive_handler_ =
+ std::make_unique<DriveHandler>(std::move(pending_receiver), profile_);
+}
+
#if !defined(OFFICIAL_BUILD)
void NewTabPageUI::BindInterface(
mojo::PendingReceiver<foo::mojom::FooHandler> pending_page_handler) {
@@ -400,6 +411,13 @@ void NewTabPageUI::BindInterface(
}
#endif
+void NewTabPageUI::BindInterface(
+ mojo::PendingReceiver<chrome_cart::mojom::CartHandler>
+ pending_page_handler) {
+ cart_handler_ =
+ std::make_unique<CartHandler>(std::move(pending_page_handler), profile_);
+}
+
void NewTabPageUI::CreatePageHandler(
mojo::PendingRemote<new_tab_page::mojom::Page> pending_page,
mojo::PendingReceiver<new_tab_page::mojom::PageHandler>
@@ -408,7 +426,6 @@ void NewTabPageUI::CreatePageHandler(
page_handler_ = std::make_unique<NewTabPageHandler>(
std::move(pending_page_handler), std::move(pending_page), profile_,
instant_service_, web_contents_,
- NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_),
navigation_start_time_);
}
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 4aecfe26095..513ae0e4856 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
@@ -6,14 +6,16 @@
#define CHROME_BROWSER_UI_WEBUI_NEW_TAB_PAGE_NEW_TAB_PAGE_UI_H_
#include "base/macros.h"
-#include "chrome/browser/media/kaleidoscope/mojom/kaleidoscope.mojom.h"
+#include "chrome/browser/cart/chrome_cart.mojom.h"
#include "chrome/browser/promo_browser_command/promo_browser_command.mojom-forward.h"
+#include "chrome/browser/search/drive/drive.mojom.h"
#include "chrome/browser/search/instant_service_observer.h"
#include "chrome/browser/search/task_module/task_module.mojom.h"
#if !defined(OFFICIAL_BUILD)
#include "chrome/browser/ui/webui/new_tab_page/foo/foo.mojom.h" // nogncheck crbug.com/1125897
#endif
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom.h"
+#include "chrome/browser/ui/webui/realbox/realbox.mojom-forward.h"
#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
@@ -33,11 +35,13 @@ class FooHandler;
#endif
class GURL;
class InstantService;
-class KaleidoscopeDataProviderImpl;
class NewTabPageHandler;
class Profile;
class PromoBrowserCommandHandler;
+class RealboxHandler;
class TaskModuleHandler;
+class CartHandler;
+class DriveHandler;
class NewTabPageUI
: public ui::MojoWebUIController,
@@ -57,6 +61,11 @@ class NewTabPageUI
mojo::PendingReceiver<new_tab_page::mojom::PageHandlerFactory>
pending_receiver);
+ // Instantiates the implementor of the realbox::mojom::PageHandler mojo
+ // interface passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<realbox::mojom::PageHandler> pending_page_handler);
+
// Instantiates the implementor of the
// promo_browser_command::mojom::CommandHandler mojo interface passing the
// pending receiver that will be internally bound.
@@ -72,19 +81,17 @@ class NewTabPageUI
pending_receiver);
// Instantiates the implementor of the
- // media::mojom::KaleidoscopeNTPDataProvider mojo interface passing the
- // pending receiver that will be internally bound.
- void BindInterface(
- mojo::PendingReceiver<media::mojom::KaleidoscopeDataProvider>
- pending_receiver);
-
- // Instantiates the implementor of the
// shopping_tasks::mojom::ShoppingTasksHandler mojo interface passing the
// pending receiver that will be internally bound.
void BindInterface(
mojo::PendingReceiver<task_module::mojom::TaskModuleHandler>
pending_receiver);
+ // Instantiates the implementor of drive::mojom::DriveHandler mojo interface
+ // passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<drive::mojom::DriveHandler> 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.
@@ -92,6 +99,11 @@ class NewTabPageUI
mojo::PendingReceiver<foo::mojom::FooHandler> pending_receiver);
#endif
+ // Instantiates the implementor of the chrome_cart::mojom::CartHandler
+ // mojo interface passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<chrome_cart::mojom::CartHandler> pending_receiver);
+
private:
// new_tab_page::mojom::PageHandlerFactory:
void CreatePageHandler(
@@ -126,9 +138,11 @@ class NewTabPageUI
mojo::Receiver<customize_themes::mojom::CustomizeThemesHandlerFactory>
customize_themes_factory_receiver_;
std::unique_ptr<PromoBrowserCommandHandler> promo_browser_command_handler_;
+ std::unique_ptr<RealboxHandler> realbox_handler_;
#if !defined(OFFICIAL_BUILD)
std::unique_ptr<FooHandler> foo_handler_;
#endif
+ std::unique_ptr<CartHandler> cart_handler_;
Profile* profile_;
InstantService* instant_service_;
content::WebContents* web_contents_;
@@ -137,8 +151,8 @@ class NewTabPageUI
base::Time navigation_start_time_;
// Mojo implementations for modules:
- std::unique_ptr<KaleidoscopeDataProviderImpl> kaleidoscope_data_provider_;
std::unique_ptr<TaskModuleHandler> task_module_handler_;
+ std::unique_ptr<DriveHandler> drive_handler_;
WEB_UI_CONTROLLER_TYPE_DECL();
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 41d892c2c09..b2b90542d67 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
@@ -71,7 +71,7 @@ UntrustedSource::UntrustedSource(Profile* profile)
// |one_google_bar_service_| is null in incognito, or when the feature is
// disabled.
if (one_google_bar_service_) {
- one_google_bar_service_observer_.Add(one_google_bar_service_);
+ one_google_bar_service_observation_.Observe(one_google_bar_service_);
}
}
@@ -117,11 +117,14 @@ void UntrustedSource::StartDataRequest(
one_google_bar_service_->SetAdditionalQueryParams(query_params);
one_google_bar_callbacks_.push_back(std::move(callback));
if (one_google_bar_service_->one_google_bar_data().has_value() &&
- !wait_for_refresh) {
+ !wait_for_refresh &&
+ base::FeatureList::IsEnabled(ntp_features::kCacheOneGoogleBar)) {
OnOneGoogleBarDataUpdated();
}
- one_google_bar_load_start_time_ = base::TimeTicks::Now();
- one_google_bar_service_->Refresh();
+ if (one_google_bar_callbacks_.size() == 1) {
+ one_google_bar_load_start_time_ = base::TimeTicks::Now();
+ one_google_bar_service_->Refresh();
+ }
return;
}
if (path == "one_google_bar.js") {
@@ -262,14 +265,15 @@ void UntrustedSource::OnOneGoogleBarDataUpdated() {
html = FormatTemplate(IDR_NEW_TAB_PAGE_UNTRUSTED_ONE_GOOGLE_BAR_HTML,
replacements);
}
+ auto html_ref_counted = base::RefCountedString::TakeString(&html);
for (auto& callback : one_google_bar_callbacks_) {
- std::move(callback).Run(base::RefCountedString::TakeString(&html));
+ std::move(callback).Run(html_ref_counted);
}
one_google_bar_callbacks_.clear();
}
void UntrustedSource::OnOneGoogleBarServiceShuttingDown() {
- one_google_bar_service_observer_.RemoveAll();
+ one_google_bar_service_observation_.Reset();
one_google_bar_service_ = nullptr;
}
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 420a55cb7f8..03fd3bd70cb 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
@@ -8,7 +8,7 @@
#include <string>
#include <vector>
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service_observer.h"
#include "content/public/browser/url_data_source.h"
@@ -79,8 +79,8 @@ class UntrustedSource : public content::URLDataSource,
std::vector<content::URLDataSource::GotDataCallback>
one_google_bar_callbacks_;
OneGoogleBarService* one_google_bar_service_;
- ScopedObserver<OneGoogleBarService, OneGoogleBarServiceObserver>
- one_google_bar_service_observer_{this};
+ base::ScopedObservation<OneGoogleBarService, OneGoogleBarServiceObserver>
+ one_google_bar_service_observation_{this};
base::Optional<base::TimeTicks> one_google_bar_load_start_time_;
Profile* profile_;
};
diff --git a/chromium/chrome/browser/ui/webui/ntp/DIR_METADATA b/chromium/chrome/browser/ui/webui/ntp/DIR_METADATA
new file mode 100644
index 00000000000..685524d3466
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/ntp/DIR_METADATA
@@ -0,0 +1,4 @@
+monorail {
+ component: "UI>Browser>NewTabPage"
+}
+team_email: "ntp-dev@chromium.org"
diff --git a/chromium/chrome/browser/ui/webui/ntp/OWNERS b/chromium/chrome/browser/ui/webui/ntp/OWNERS
index f2a2683d406..691d934420e 100644
--- a/chromium/chrome/browser/ui/webui/ntp/OWNERS
+++ b/chromium/chrome/browser/ui/webui/ntp/OWNERS
@@ -2,6 +2,3 @@ file://components/search/OWNERS
estade@chromium.org
per-file app_launcher_handler.*=dmurph@chromium.org
-
-# TEAM: ntp-dev@chromium.org
-# COMPONENT: UI>Browser>NewTabPage
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 763b8fd1b24..1af2c59a4cd 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -13,17 +13,16 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
+#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/i18n/rtl.h"
-#include "base/metrics/field_trial.h"
#include "base/metrics/histogram_functions.h"
-#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
-#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
+#include "build/build_config.h"
#include "chrome/browser/apps/app_service/app_icon_source.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
@@ -37,7 +36,6 @@
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
-#include "chrome/browser/installable/installable_metrics.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/browser_dialogs.h"
@@ -75,6 +73,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/webapps/browser/installable/installable_metrics.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_ui.h"
#include "extensions/browser/app_sorting.h"
@@ -130,7 +129,7 @@ const int kWebAppIconSmallNonDefault = 16;
// These Run on OS Login mode strings need to be in sync with
// chrome/browser/resources/ntp4/apps_page.js:RUN_ON_OS_LOGIN_MODE enum.
-const char kRunOnOsLoginModeNone[] = "run_on_os_login_mode_none";
+const char kRunOnOsLoginModeNotRun[] = "run_on_os_login_mode_not_run";
const char kRunOnOsLoginModeWindowed[] = "run_on_os_login_mode_windowed";
// The Youtube app is incorrectly harded to be a 'bookmark app'. However, it is
@@ -279,15 +278,22 @@ void AppLauncherHandler::CreateWebAppInfo(const web_app::AppId& app_id,
}
value->SetString("app_launch_ordinal", app_launch_ordinal.ToInternalValue());
- // Run on OS Login can be changed only for locally installed web apps
+ // Only show the Run on OS Login menu item for locally installed web apps
value->SetBoolean(
- "mayChangeRunOnOsLoginMode",
+ "mayShowRunOnOsLoginMode",
base::FeatureList::IsEnabled(features::kDesktopPWAsRunOnOsLogin) &&
is_locally_installed);
+
+ value->SetBoolean(
+ "mayToggleRunOnOsLoginMode",
+ web_app_provider_->policy_manager().GetUrlRunOnOsLoginPolicy(
+ policy_installed_apps_[app_id]) ==
+ web_app::RunOnOsLoginPolicy::kAllowed);
+
std::string runOnOsLoginModeString =
(registrar.GetAppRunOnOsLoginMode(app_id) ==
- web_app::RunOnOsLoginMode::kUndefined)
- ? kRunOnOsLoginModeNone
+ web_app::RunOnOsLoginMode::kNotRun)
+ ? kRunOnOsLoginModeNotRun
: kRunOnOsLoginModeWindowed;
value->SetString("runOnOsLoginMode", runOnOsLoginModeString);
}
@@ -400,15 +406,17 @@ void AppLauncherHandler::CreateExtensionInfo(const Extension* extension,
value->SetString("app_launch_ordinal", app_launch_ordinal.ToInternalValue());
// Run on OS Login is not implemented for extension/bookmark apps.
- value->SetBoolean("mayChangeRunOnOsLoginMode", false);
+ value->SetBoolean("mayShowRunOnOsLoginMode", false);
+ value->SetBoolean("mayToggleRunOnOsLoginMode", false);
}
// static
-void AppLauncherHandler::GetLocalizedValues(Profile* profile,
- base::DictionaryValue* values) {
+void AppLauncherHandler::RegisterLoadTimeData(
+ Profile* profile,
+ content::WebUIDataSource* source) {
PrefService* prefs = profile->GetPrefs();
int shown_page = prefs->GetInteger(prefs::kNtpShownPage);
- values->SetInteger("shown_page_index", shown_page & INDEX_MASK);
+ source->AddInteger("shown_page_index", shown_page & INDEX_MASK);
}
// static
@@ -569,19 +577,41 @@ void AppLauncherHandler::OnWebAppInstalled(const web_app::AppId& app_id) {
web_ui()->CallJavascriptFunctionUnsafe("ntp.appAdded", *app_info, highlight);
}
-void AppLauncherHandler::OnWebAppUninstalled(const web_app::AppId& app_id) {
+void AppLauncherHandler::OnWebAppWillBeUninstalled(
+ const web_app::AppId& app_id) {
std::unique_ptr<base::DictionaryValue> app_info =
std::make_unique<base::DictionaryValue>();
+ // Since |isUninstall| is true below, the only item needed in the app_info
+ // dictionary is the id.
app_info->SetString(kInfoIdKey, app_id);
- // Since |isUninstaLL| is true below, the only item needed in the app_info
+ web_ui()->CallJavascriptFunctionUnsafe(
+ "ntp.appRemoved", *app_info, /*isUninstall=*/base::Value(true),
+ base::Value(!extension_id_prompting_.empty()));
+}
+
+void AppLauncherHandler::OnWebAppUninstalled(const web_app::AppId& app_id) {
+ // This can be redundant in most cases, however it is not uncommon for the
+ // chrome://apps page to be loaded, or reloaded, during the uninstallation of
+ // an app. In this state, the app is still in the registry, but the
+ // |OnWebAppWillBeUninstalled| event has already been sent. Thus we also
+ // listen to this event, to ensure that the app is removed.
+ std::unique_ptr<base::DictionaryValue> app_info =
+ std::make_unique<base::DictionaryValue>();
+ // Since |isUninstall| is true below, the only item needed in the app_info
// dictionary is the id.
+ app_info->SetString(kInfoIdKey, app_id);
web_ui()->CallJavascriptFunctionUnsafe(
"ntp.appRemoved", *app_info, /*isUninstall=*/base::Value(true),
base::Value(!extension_id_prompting_.empty()));
}
+void AppLauncherHandler::OnPolicyChanged() {
+ HandleGetApps(nullptr);
+}
+
void AppLauncherHandler::OnAppRegistrarDestroyed() {
- web_apps_observer_.RemoveAll();
+ web_apps_observation_.Reset();
+ web_apps_policy_manager_observation_.Reset();
}
void AppLauncherHandler::FillAppDictionary(base::DictionaryValue* dictionary) {
@@ -690,6 +720,10 @@ void AppLauncherHandler::HandleGetApps(const base::ListValue* args) {
}
}
+ policy_installed_apps_ =
+ web_app_provider_->registrar().GetExternallyInstalledApps(
+ web_app::ExternalInstallSource::kExternalPolicy);
+
SetAppToBeHighlighted();
FillAppDictionary(&dictionary);
web_ui()->CallJavascriptFunctionUnsafe("ntp.getAppsCallback", dictionary);
@@ -697,9 +731,9 @@ void AppLauncherHandler::HandleGetApps(const base::ListValue* args) {
// First time we get here we set up the observer so that we can tell update
// the apps as they change.
if (!has_loaded_apps_) {
- base::Closure callback = base::Bind(
- &AppLauncherHandler::OnExtensionPreferenceChanged,
- base::Unretained(this));
+ base::RepeatingClosure callback =
+ base::BindRepeating(&AppLauncherHandler::OnExtensionPreferenceChanged,
+ base::Unretained(this));
extension_pref_change_registrar_.Init(
ExtensionPrefs::Get(profile)->pref_service());
extension_pref_change_registrar_.Add(
@@ -710,7 +744,9 @@ void AppLauncherHandler::HandleGetApps(const base::ListValue* args) {
registrar_.Add(this, chrome::NOTIFICATION_APP_LAUNCHER_REORDERED,
content::Source<AppSorting>(
ExtensionSystem::Get(profile)->app_sorting()));
- web_apps_observer_.Add(&web_app_provider_->registrar());
+ web_apps_observation_.Observe(&web_app_provider_->registrar());
+ web_apps_policy_manager_observation_.Observe(
+ &web_app_provider_->policy_manager());
}
has_loaded_apps_ = true;
@@ -955,7 +991,7 @@ void AppLauncherHandler::HandleCreateAppShortcut(const base::ListValue* args) {
chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
chrome::ShowCreateChromeAppShortcutsDialog(
browser->window()->GetNativeWindow(), browser->profile(), app_id,
- base::BindRepeating([](bool success) {
+ base::BindOnce([](bool success) {
base::UmaHistogramBoolean(
"Apps.AppInfoDialog.CreateWebAppShortcutSuccess", success);
}));
@@ -976,7 +1012,7 @@ void AppLauncherHandler::HandleCreateAppShortcut(const base::ListValue* args) {
web_ui()->GetWebContents());
chrome::ShowCreateChromeAppShortcutsDialog(
browser->window()->GetNativeWindow(), browser->profile(), extension,
- base::BindRepeating([](bool success) {
+ base::BindOnce([](bool success) {
base::UmaHistogramBoolean(
"Apps.AppInfoDialog.CreateExtensionShortcutSuccess", success);
}));
@@ -1025,13 +1061,9 @@ void AppLauncherHandler::HandleShowAppInfo(const base::ListValue* args) {
return;
DCHECK(!FromBookmark(extension));
- UMA_HISTOGRAM_ENUMERATION("Apps.AppInfoDialog.Launches",
- AppInfoLaunchSource::FROM_APPS_PAGE,
- AppInfoLaunchSource::NUM_LAUNCH_SOURCES);
-
ShowAppInfoInNativeDialog(web_ui()->GetWebContents(),
Profile::FromWebUI(web_ui()), extension,
- base::Closure());
+ base::DoNothing());
}
void AppLauncherHandler::HandleReorderApps(const base::ListValue* args) {
@@ -1097,7 +1129,9 @@ void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) {
std::string url;
CHECK(args->GetString(0, &url));
GURL launch_url(url);
-
+ // Do not install app for invalid url.
+ if (!launch_url.SchemeIsHTTPOrHTTPS())
+ return;
// Can only install one app at a time.
if (attempting_web_app_install_page_ordinal_.has_value())
return;
@@ -1130,7 +1164,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) {
favicon_service->GetFaviconImageForPageURL(
launch_url,
base::BindOnce(&AppLauncherHandler::OnFaviconForAppInstallFromLink,
- base::Unretained(this), base::Passed(&install_info)),
+ base::Unretained(this), std::move(install_info)),
&cancelable_task_tracker_);
}
@@ -1154,8 +1188,8 @@ void AppLauncherHandler::HandleRunOnOsLogin(const base::ListValue* args) {
CHECK(args->GetString(0, &app_id));
CHECK(args->GetString(1, &mode_string));
- if (mode_string == kRunOnOsLoginModeNone) {
- mode = web_app::RunOnOsLoginMode::kUndefined;
+ if (mode_string == kRunOnOsLoginModeNotRun) {
+ mode = web_app::RunOnOsLoginMode::kNotRun;
} else if (mode_string == kRunOnOsLoginModeWindowed) {
mode = web_app::RunOnOsLoginMode::kWindowed;
} else {
@@ -1168,7 +1202,7 @@ void AppLauncherHandler::HandleRunOnOsLogin(const base::ListValue* args) {
web_app_provider_->registry_controller().SetAppRunOnOsLoginMode(app_id, mode);
- if (mode == web_app::RunOnOsLoginMode::kUndefined) {
+ if (mode == web_app::RunOnOsLoginMode::kNotRun) {
web_app::OsHooksResults os_hooks;
os_hooks[web_app::OsHookType::kRunOnOsLogin] = true;
web_app_provider_->os_integration_manager().UninstallOsHooks(
@@ -1221,7 +1255,7 @@ void AppLauncherHandler::OnFaviconForAppInstallFromLink(
web_app_provider_->install_manager().InstallWebAppFromInfo(
std::move(web_app), web_app::ForInstallableSite::kUnknown,
- WebappInstallSource::SYNC, std::move(install_complete_callback));
+ webapps::WebappInstallSource::SYNC, std::move(install_complete_callback));
}
void AppLauncherHandler::SetAppToBeHighlighted() {
@@ -1359,6 +1393,13 @@ void AppLauncherHandler::InstallOsHooks(const web_app::AppId& app_id) {
options.os_hooks[web_app::OsHookType::kShortcutsMenu] = true;
options.os_hooks[web_app::OsHookType::kFileHandlers] = true;
options.os_hooks[web_app::OsHookType::kRunOnOsLogin] = false;
+ options.os_hooks[web_app::OsHookType::kUninstallationViaOsSettings] = true;
+#if defined(OS_WIN) || defined(OS_MAC) || \
+ (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS))
+ options.os_hooks[web_app::OsHookType::kUrlHandlers] = true;
+#else
+ options.os_hooks[web_app::OsHookType::kUrlHandlers] = false;
+#endif
web_app_provider_->os_integration_manager().InstallOsHooks(
app_id,
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 81ab55db965..30aea059ff3 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/optional.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/extensions/extension_uninstall_dialog.h"
#include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
@@ -19,12 +19,15 @@
#include "chrome/browser/web_applications/components/app_registrar_observer.h"
#include "chrome/browser/web_applications/components/os_integration_manager.h"
#include "chrome/browser/web_applications/components/web_app_id.h"
+#include "chrome/browser/web_applications/policy/web_app_policy_manager.h"
+#include "chrome/browser/web_applications/policy/web_app_policy_manager_observer.h"
#include "chrome/common/extensions/extension_constants.h"
#include "components/favicon/core/favicon_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/sync/model/string_ordinal.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/common/extension.h"
@@ -56,6 +59,7 @@ class AppLauncherHandler
public ExtensionEnableFlowDelegate,
public content::NotificationObserver,
public web_app::AppRegistrarObserver,
+ public web_app::WebAppPolicyManagerObserver,
public extensions::ExtensionRegistryObserver {
public:
AppLauncherHandler(extensions::ExtensionService* extension_service,
@@ -69,8 +73,8 @@ class AppLauncherHandler
base::DictionaryValue* value);
// Registers values (strings etc.) for the page.
- static void GetLocalizedValues(Profile* profile,
- base::DictionaryValue* values);
+ static void RegisterLoadTimeData(Profile* profile,
+ content::WebUIDataSource* source);
// Register per-profile preferences.
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
@@ -95,9 +99,13 @@ class AppLauncherHandler
// web_app::AppRegistrarObserver:
void OnWebAppInstalled(const web_app::AppId& app_id) override;
+ void OnWebAppWillBeUninstalled(const web_app::AppId& app_id) override;
void OnWebAppUninstalled(const web_app::AppId& app_id) override;
void OnAppRegistrarDestroyed() override;
+ // web_app::WebAppPolicyManagerObserver
+ void OnPolicyChanged() override;
+
// Populate the given dictionary with all installed app info.
void FillAppDictionary(base::DictionaryValue* value);
@@ -224,8 +232,12 @@ class AppLauncherHandler
// features::kDesktopPWAsWithoutExtensions is enabled.
web_app::WebAppProvider* const web_app_provider_;
- ScopedObserver<web_app::AppRegistrar, web_app::AppRegistrarObserver>
- web_apps_observer_{this};
+ base::ScopedObservation<web_app::AppRegistrar, web_app::AppRegistrarObserver>
+ web_apps_observation_{this};
+
+ base::ScopedObservation<web_app::WebAppPolicyManager,
+ web_app::WebAppPolicyManagerObserver>
+ web_apps_policy_manager_observation_{this};
// We monitor changes to the extension system so that we can reload the apps
// when necessary.
@@ -247,6 +259,9 @@ class AppLauncherHandler
// The ids of apps to show on the NTP.
std::set<std::string> visible_apps_;
+ // The ids of apps installed externally.
+ std::map<web_app::AppId, GURL> policy_installed_apps_;
+
// The id of the extension we are prompting the user about (either enable or
// uninstall).
std::string extension_id_prompting_;
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 d072d8378c1..db824f873ff 100644
--- a/chromium/chrome/browser/ui/webui/ntp/cookie_controls_handler.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/cookie_controls_handler.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/cookie_controls/cookie_controls_service.h"
#include "chrome/browser/ui/cookie_controls/cookie_controls_service_factory.h"
#include "chrome/common/chrome_features.h"
+#include "chrome/common/webui_url_constants.h"
#include "components/content_settings/core/common/cookie_controls_enforcement.h"
namespace {
@@ -90,10 +91,6 @@ void CookieControlsHandler::SendCookieControlsUIChanges() {
dict.SetBoolKey("checked", service_->GetToggleCheckedValue());
dict.SetStringKey(
"icon", GetEnforcementIcon(service_->GetCookieControlsEnforcement()));
- bool use_new_cookie_page =
- base::FeatureList::IsEnabled(features::kPrivacySettingsRedesign);
- dict.SetString("cookieSettingsUrl",
- use_new_cookie_page ? "chrome://settings/cookies"
- : "chrome://settings/content/cookies");
+ dict.SetString("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 4d67fe36e43..814e0063791 100644
--- a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -74,9 +74,10 @@ NewTabUI::NewTabUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
profile->GetOriginalProfile()));
pref_change_registrar_.Init(profile->GetPrefs());
- pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar,
- base::Bind(&NewTabUI::OnShowBookmarkBarChanged,
- base::Unretained(this)));
+ pref_change_registrar_.Add(
+ bookmarks::prefs::kShowBookmarkBar,
+ base::BindRepeating(&NewTabUI::OnShowBookmarkBarChanged,
+ base::Unretained(this)));
}
NewTabUI::~NewTabUI() {}
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 95dd5f51c45..54a952c6e50 100644
--- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -15,17 +15,16 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_util.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/apps/app_info_dialog.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"
@@ -42,42 +41,36 @@
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/content_settings/core/common/cookie_controls_enforcement.h"
#include "components/content_settings/core/common/pref_names.h"
-#include "components/google/core/common/google_util.h"
#include "components/policy/core/common/policy_service.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
-#include "components/signin/public/identity_manager/identity_manager.h"
+#include "components/reading_list/features/reading_list_switches.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
-#include "extensions/common/extension_urls.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/template_expressions.h"
#include "ui/base/theme_provider.h"
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/base/webui/web_ui_util.h"
-#include "ui/gfx/animation/animation.h"
+#include "ui/chromeos/devicetype_utils.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#endif
-#if defined(OS_MAC)
-#include "chrome/browser/platform_util.h"
-#endif
-
using content::BrowserThread;
namespace {
// The URL for the the Learn More page shown on incognito new tab.
const char kLearnMoreIncognitoUrl[] =
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
"https://support.google.com/chromebook/?p=incognito";
#else
"https://support.google.com/chrome/?p=incognito";
@@ -85,7 +78,7 @@ const char kLearnMoreIncognitoUrl[] =
// The URL for the Learn More page shown on guest session new tab.
const char kLearnMoreGuestSessionUrl[] =
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
"https://support.google.com/chromebook/?p=chromebook_guest";
#else
"https://support.google.com/chrome/?p=ui_guest";
@@ -165,18 +158,17 @@ NTPResourceCache::NTPResourceCache(Profile* profile)
content::Source<ThemeService>(
ThemeServiceFactory::GetForProfile(profile)));
- base::Closure callback = base::Bind(&NTPResourceCache::OnPreferenceChanged,
- base::Unretained(this));
+ base::RepeatingClosure callback = base::BindRepeating(
+ &NTPResourceCache::OnPreferenceChanged, base::Unretained(this));
// Watch for pref changes that cause us to need to invalidate the HTML cache.
profile_pref_change_registrar_.Init(profile_->GetPrefs());
profile_pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar,
callback);
profile_pref_change_registrar_.Add(prefs::kNtpShownPage, callback);
- profile_pref_change_registrar_.Add(prefs::kHideWebStoreIcon, callback);
profile_pref_change_registrar_.Add(prefs::kCookieControlsMode, callback);
- theme_observer_.Add(ui::NativeTheme::GetInstanceForNativeUi());
+ theme_observation_.Observe(ui::NativeTheme::GetInstanceForNativeUi());
policy_change_registrar_ = std::make_unique<policy::PolicyChangeRegistrar>(
profile->GetProfilePolicyConnector()->policy_service(),
@@ -189,71 +181,63 @@ NTPResourceCache::NTPResourceCache(Profile* profile)
NTPResourceCache::~NTPResourceCache() = default;
-bool NTPResourceCache::NewTabHTMLNeedsRefresh() {
-#if defined(OS_MAC)
- // Invalidate if the current value is different from the cached value.
- bool is_enabled = platform_util::IsSwipeTrackingFromScrollEventsEnabled();
- if (is_enabled != is_swipe_tracking_from_scroll_events_enabled_) {
- is_swipe_tracking_from_scroll_events_enabled_ = is_enabled;
- return true;
- }
-#endif
- return false;
-}
-
NTPResourceCache::WindowType NTPResourceCache::GetWindowType(
Profile* profile, content::RenderProcessHost* render_host) {
- if (profile->IsGuestSession() || profile->IsEphemeralGuestProfile()) {
+ if (profile->IsGuestSession() || profile->IsEphemeralGuestProfile())
return GUEST;
- } else if (render_host) {
- // Sometimes the |profile| is the parent (non-incognito) version of the user
- // so we check the |render_host| if it is provided.
- if (render_host->GetBrowserContext()->IsOffTheRecord())
- return INCOGNITO;
- } else if (profile->IsOffTheRecord()) {
+
+ // Sometimes the |profile| is the parent (non-incognito) version of the user
+ // so we check the |render_host| if it is provided.
+ if (render_host && render_host->GetBrowserContext()->IsOffTheRecord())
+ profile = Profile::FromBrowserContext(render_host->GetBrowserContext());
+
+ if (profile->IsIncognitoProfile())
return INCOGNITO;
- }
+ if (profile->IsOffTheRecord())
+ return NON_PRIMARY_OTR;
+
return NORMAL;
}
base::RefCountedMemory* NTPResourceCache::GetNewTabGuestHTML() {
- if (!profile_->IsEphemeralGuestProfile()) {
- if (!new_tab_guest_html_) {
- GuestNTPInfo guest_ntp_info{kLearnMoreGuestSessionUrl, IDR_GUEST_TAB_HTML,
- IDS_NEW_TAB_GUEST_SESSION_HEADING,
- IDS_NEW_TAB_GUEST_SESSION_DESCRIPTION};
- new_tab_guest_html_ = CreateNewTabGuestHTML(guest_ntp_info);
- }
-
- return new_tab_guest_html_.get();
+ // TODO(crbug.com/1134111): For full launch of ephemeral Guest profiles,
+ // instead of the below code block, use IdentityManager for ephemeral Guest
+ // profiles to check sign in status and return either
+ // |CreateNewTabEphemeralGuestSignedInHTML()| or
+ // |CreateNewTabEphemeralGuestSignedOutHTML()|.
+ if (!new_tab_guest_html_) {
+ GuestNTPInfo guest_ntp_info{kLearnMoreGuestSessionUrl, IDR_GUEST_TAB_HTML,
+ IDS_NEW_TAB_GUEST_SESSION_HEADING,
+ IDS_NEW_TAB_GUEST_SESSION_DESCRIPTION};
+ new_tab_guest_html_ = CreateNewTabGuestHTML(guest_ntp_info);
}
- // TODO(crbug.com/1134111): Use IdentityManager to check sign in status when
- // Ephemeral Guest sign in functioncality is implemented.
- const bool is_signed_in =
- signin_util::GuestSignedInUserData::IsSignedIn(profile_);
- return is_signed_in ? CreateNewTabEphemeralGuestSignedInHTML()
- : CreateNewTabEphemeralGuestSignedOutHTML();
+ return new_tab_guest_html_.get();
}
base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(WindowType win_type) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (win_type == GUEST) {
- return GetNewTabGuestHTML();
+ switch (win_type) {
+ case GUEST:
+ return GetNewTabGuestHTML();
+
+ case INCOGNITO:
+ if (!new_tab_incognito_html_)
+ CreateNewTabIncognitoHTML();
+ return new_tab_incognito_html_.get();
+
+ case NON_PRIMARY_OTR:
+ if (!new_tab_non_primary_otr_html_) {
+ std::string empty_html;
+ new_tab_non_primary_otr_html_ =
+ base::RefCountedString::TakeString(&empty_html);
+ }
+ return new_tab_non_primary_otr_html_.get();
+
+ case NORMAL:
+ NOTREACHED();
+ return nullptr;
}
-
- if (win_type == INCOGNITO) {
- if (!new_tab_incognito_html_)
- CreateNewTabIncognitoHTML();
- return new_tab_incognito_html_.get();
- }
-
- // Refresh the cached HTML if necessary.
- // NOTE: NewTabHTMLNeedsRefresh() must be called every time the new tab
- // HTML is fetched, because it needs to initialize cached values.
- if (NewTabHTMLNeedsRefresh() || !new_tab_html_)
- CreateNewTabHTML();
- return new_tab_html_.get();
}
base::RefCountedMemory* NTPResourceCache::GetNewTabCSS(WindowType win_type) {
@@ -292,14 +276,12 @@ void NTPResourceCache::OnPreferenceChanged() {
// A change occurred to one of the preferences we care about, so flush the
// cache.
new_tab_incognito_html_ = nullptr;
- new_tab_html_ = nullptr;
new_tab_css_ = nullptr;
}
// TODO(dbeam): why must Invalidate() and OnPreferenceChanged() both exist?
void NTPResourceCache::Invalidate() {
new_tab_incognito_html_ = nullptr;
- new_tab_html_ = nullptr;
new_tab_incognito_css_ = nullptr;
new_tab_css_ = nullptr;
new_tab_guest_html_ = nullptr;
@@ -317,13 +299,17 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() {
// Ensure passing off-the-record profile; |profile_| is not an OTR profile.
DCHECK(!profile_->IsOffTheRecord());
- DCHECK(profile_->HasPrimaryOTRProfile());
+ DCHECK(profile_->HasAnyOffTheRecordProfile());
+ // Cookie controls service returns the same result for all off-the-record
+ // profiles, so it doesn't matter which of them we use.
CookieControlsService* cookie_controls_service =
CookieControlsServiceFactory::GetForProfile(
- profile_->GetPrimaryOTRProfile());
+ profile_->GetAllOffTheRecordProfiles()[0]);
replacements["incognitoTabDescription"] =
- l10n_util::GetStringUTF8(IDS_NEW_TAB_OTR_SUBTITLE);
+ l10n_util::GetStringUTF8(reading_list::switches::IsReadingListEnabled()
+ ? IDS_NEW_TAB_OTR_SUBTITLE_WITH_READING_LIST
+ : IDS_NEW_TAB_OTR_SUBTITLE);
replacements["incognitoTabHeading"] =
l10n_util::GetStringUTF8(IDS_NEW_TAB_OTR_TITLE);
replacements["incognitoTabWarning"] =
@@ -410,7 +396,7 @@ scoped_refptr<base::RefCountedString> NTPResourceCache::CreateNewTabGuestHTML(
l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
int guest_tab_idr = guest_ntp_info.html_idr;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
guest_tab_idr = IDR_GUEST_SESSION_TAB_HTML;
policy::BrowserPolicyConnectorChromeOS* connector =
@@ -427,11 +413,11 @@ scoped_refptr<base::RefCountedString> NTPResourceCache::CreateNewTabGuestHTML(
const std::string enterprise_domain_manager =
connector->GetEnterpriseDomainManager();
enterprise_info = l10n_util::GetStringFUTF16(
- IDS_ASH_ENTERPRISE_DEVICE_MANAGED_BY,
+ IDS_ASH_ENTERPRISE_DEVICE_MANAGED_BY, ui::GetChromeOSDeviceName(),
base::UTF8ToUTF16(enterprise_domain_manager));
} else if (connector->IsActiveDirectoryManaged()) {
- enterprise_info =
- l10n_util::GetStringUTF16(IDS_ASH_ENTERPRISE_DEVICE_MANAGED);
+ enterprise_info = l10n_util::GetStringFUTF16(
+ IDS_ASH_ENTERPRISE_DEVICE_MANAGED, ui::GetChromeOSDeviceName());
} else {
NOTREACHED() << "Unknown management type";
}
@@ -483,125 +469,6 @@ scoped_refptr<base::RefCountedString> NTPResourceCache::CreateNewTabGuestHTML(
return base::RefCountedString::TakeString(&full_html);
}
-// TODO(alancutter): Consider moving this utility function up somewhere where it
-// can be shared with bookmarks_ui.cc.
-// Ampersands are used by menus to determine which characters to use as shortcut
-// keys. This functionality is not implemented for NTP.
-static base::string16 GetLocalizedString(int message_id) {
- base::string16 result = l10n_util::GetStringUTF16(message_id);
- base::Erase(result, '&');
- return result;
-}
-
-void NTPResourceCache::CreateNewTabHTML() {
- // TODO(estade): these strings should be defined in their relevant handlers
- // (in GetLocalizedValues) and should have more legible names.
- // Show the profile name in the title and most visited labels if the current
- // profile is not the default.
- PrefService* prefs = profile_->GetPrefs();
- base::DictionaryValue load_time_data;
- load_time_data.SetString(
- "bookmarkbarattached",
- prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar) ? "true" : "false");
- load_time_data.SetString("title", GetLocalizedString(IDS_NEW_TAB_TITLE));
- load_time_data.SetString("webStoreTitle",
- GetLocalizedString(IDS_EXTENSION_WEB_STORE_TITLE));
- load_time_data.SetString(
- "webStoreTitleShort",
- GetLocalizedString(IDS_EXTENSION_WEB_STORE_TITLE_SHORT));
- load_time_data.SetString("attributionintro",
- GetLocalizedString(IDS_NEW_TAB_ATTRIBUTION_INTRO));
- load_time_data.SetString("appuninstall",
- GetLocalizedString(IDS_EXTENSIONS_UNINSTALL));
- load_time_data.SetString("appoptions",
- GetLocalizedString(IDS_NEW_TAB_APP_OPTIONS));
- load_time_data.SetString("appdetails",
- GetLocalizedString(IDS_NEW_TAB_APP_DETAILS));
- load_time_data.SetString("appinfodialog",
- GetLocalizedString(IDS_APP_CONTEXT_MENU_SHOW_INFO));
- load_time_data.SetString("appcreateshortcut",
- GetLocalizedString(IDS_NEW_TAB_APP_CREATE_SHORTCUT));
- load_time_data.SetString("appinstalllocally",
- GetLocalizedString(IDS_NEW_TAB_APP_INSTALL_LOCALLY));
- load_time_data.SetString("appDefaultPageName",
- GetLocalizedString(IDS_APP_DEFAULT_PAGE_NAME));
- load_time_data.SetString(
- "applaunchtypepinned",
- GetLocalizedString(IDS_APP_CONTEXT_MENU_OPEN_PINNED));
- load_time_data.SetString(
- "applaunchtyperegular",
- GetLocalizedString(IDS_APP_CONTEXT_MENU_OPEN_REGULAR));
- load_time_data.SetString(
- "applaunchtypewindow",
- GetLocalizedString(IDS_APP_CONTEXT_MENU_OPEN_WINDOW));
- load_time_data.SetString(
- "applaunchtypefullscreen",
- GetLocalizedString(IDS_APP_CONTEXT_MENU_OPEN_FULLSCREEN));
- load_time_data.SetString(
- "syncpromotext", GetLocalizedString(IDS_SYNC_START_SYNC_BUTTON_LABEL));
- load_time_data.SetString("syncLinkText",
- GetLocalizedString(IDS_SYNC_ADVANCED_OPTIONS));
- load_time_data.SetBoolean("shouldShowSyncLogin",
- AppLauncherLoginHandler::ShouldShow(profile_));
- load_time_data.SetString("learnMore", GetLocalizedString(IDS_LEARN_MORE));
- const std::string& app_locale = g_browser_process->GetApplicationLocale();
- load_time_data.SetString(
- "webStoreLink", google_util::AppendGoogleLocaleParam(
- extension_urls::GetWebstoreLaunchURL(), app_locale)
- .spec());
- load_time_data.SetString(
- "appInstallHintText",
- GetLocalizedString(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL));
- load_time_data.SetString("learn_more", GetLocalizedString(IDS_LEARN_MORE));
- load_time_data.SetString(
- "tile_grid_screenreader_accessible_description",
- GetLocalizedString(IDS_NEW_TAB_TILE_GRID_ACCESSIBLE_DESCRIPTION));
- load_time_data.SetString(
- "page_switcher_change_title",
- GetLocalizedString(IDS_NEW_TAB_PAGE_SWITCHER_CHANGE_TITLE));
- load_time_data.SetString(
- "page_switcher_same_title",
- GetLocalizedString(IDS_NEW_TAB_PAGE_SWITCHER_SAME_TITLE));
- load_time_data.SetString(
- "runonoslogin", GetLocalizedString(IDS_APP_CONTEXT_MENU_RUN_ON_OS_LOGIN));
-
- // 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.
- load_time_data.SetBoolean("isSwipeTrackingFromScrollEventsEnabled",
- is_swipe_tracking_from_scroll_events_enabled_);
-
- load_time_data.SetBoolean("showWebStoreIcon",
- !prefs->GetBoolean(prefs::kHideWebStoreIcon));
-
- load_time_data.SetBoolean("canShowAppInfoDialog",
- CanPlatformShowAppInfoDialog());
-
- AppLauncherHandler::GetLocalizedValues(profile_, &load_time_data);
-
- webui::SetLoadTimeDataDefaults(app_locale, &load_time_data);
-
- // Control fade and resize animations.
- load_time_data.SetBoolean("anim",
- gfx::Animation::ShouldRenderRichAnimation());
-
- load_time_data.SetBoolean(
- "isUserSignedIn",
- IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount());
-
- // Load the new tab page template and localize it.
- static const base::NoDestructor<scoped_refptr<base::RefCountedMemory>>
- new_tab_html(
- ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
- IDR_NEW_TAB_4_HTML));
- CHECK(*new_tab_html);
- std::string full_html = webui::GetI18nTemplateHtml(
- base::StringPiece(reinterpret_cast<const char*>((*new_tab_html)->front()),
- (*new_tab_html)->size()),
- &load_time_data);
- new_tab_html_ = base::RefCountedString::TakeString(&full_html);
-}
-
void NTPResourceCache::CreateNewTabIncognitoCSS() {
const ui::ThemeProvider& tp = ThemeService::GetThemeProviderForProfile(
profile_->GetPrimaryOTRProfile());
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 6e6fb438de3..6a520553958 100644
--- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
+++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/notification_observer.h"
@@ -46,6 +46,8 @@ class NTPResourceCache : public content::NotificationObserver,
NORMAL,
INCOGNITO,
GUEST,
+ // The OTR profile that is not used for Incognito or Guest windows.
+ NON_PRIMARY_OTR,
};
explicit NTPResourceCache(Profile* profile);
@@ -120,13 +122,13 @@ class NTPResourceCache : public content::NotificationObserver,
Profile* profile_;
- scoped_refptr<base::RefCountedMemory> new_tab_html_;
scoped_refptr<base::RefCountedMemory> new_tab_css_;
scoped_refptr<base::RefCountedMemory> new_tab_guest_html_;
scoped_refptr<base::RefCountedMemory> new_tab_guest_signed_in_html_;
scoped_refptr<base::RefCountedMemory> new_tab_guest_signed_out_html_;
scoped_refptr<base::RefCountedMemory> new_tab_incognito_html_;
scoped_refptr<base::RefCountedMemory> new_tab_incognito_css_;
+ scoped_refptr<base::RefCountedMemory> new_tab_non_primary_otr_html_;
content::NotificationRegistrar registrar_;
PrefChangeRegistrar profile_pref_change_registrar_;
PrefChangeRegistrar local_state_pref_change_registrar_;
@@ -134,8 +136,8 @@ class NTPResourceCache : public content::NotificationObserver,
// Set based on platform_util::IsSwipeTrackingFromScrollEventsEnabled.
bool is_swipe_tracking_from_scroll_events_enabled_;
- ScopedObserver<ui::NativeTheme, ui::NativeThemeObserver> theme_observer_{
- this};
+ base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
+ theme_observation_{this};
std::unique_ptr<policy::PolicyChangeRegistrar> policy_change_registrar_;
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 934444ff3e3..0df9dce9e78 100644
--- a/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc
@@ -80,7 +80,7 @@ bool ChromeNTPTilesInternalsMessageHandlerClient::DoesSourceExist(
switch (source) {
case ntp_tiles::TileSource::TOP_SITES:
case ntp_tiles::TileSource::SUGGESTIONS_SERVICE:
- case ntp_tiles::TileSource::WHITELIST:
+ case ntp_tiles::TileSource::ALLOWLIST:
case ntp_tiles::TileSource::HOMEPAGE:
return true;
case ntp_tiles::TileSource::POPULAR_BAKED_IN:
diff --git a/chromium/chrome/browser/ui/webui/offline/DIR_METADATA b/chromium/chrome/browser/ui/webui/offline/DIR_METADATA
new file mode 100644
index 00000000000..f9c15e508fc
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/offline/DIR_METADATA
@@ -0,0 +1,4 @@
+monorail {
+ component: "UI>Browser>Offline"
+}
+team_email: "offline-dev@chromium.org"
diff --git a/chromium/chrome/browser/ui/webui/offline/OWNERS b/chromium/chrome/browser/ui/webui/offline/OWNERS
index f5dcbccfbce..901ae80e90a 100644
--- a/chromium/chrome/browser/ui/webui/offline/OWNERS
+++ b/chromium/chrome/browser/ui/webui/offline/OWNERS
@@ -1,4 +1 @@
file://components/offline_pages/OWNERS
-
-# TEAM: offline-dev@chromium.org
-# COMPONENT: UI>Browser>Offline
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
index a226e412938..0b83168cf5f 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
@@ -200,10 +200,9 @@ struct TypeConverter<mojom::AutocompleteResultsForProviderPtr,
OmniboxPageHandler::OmniboxPageHandler(
Profile* profile,
mojo::PendingReceiver<mojom::OmniboxPageHandler> receiver)
- : profile_(profile),
- receiver_(this, std::move(receiver)),
- observer_(this) {
- observer_.Add(OmniboxControllerEmitter::GetForBrowserContext(profile_));
+ : profile_(profile), receiver_(this, std::move(receiver)) {
+ observation_.Observe(
+ OmniboxControllerEmitter::GetForBrowserContext(profile_));
ResetController();
}
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h
index eee3cc24def..3b529a26a0e 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.h
@@ -12,7 +12,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "chrome/browser/ui/webui/omnibox/omnibox.mojom.h"
#include "components/omnibox/browser/autocomplete_controller.h"
@@ -90,8 +90,9 @@ class OmniboxPageHandler : public AutocompleteController::Observer,
mojo::Receiver<mojom::OmniboxPageHandler> receiver_;
- ScopedObserver<OmniboxControllerEmitter, AutocompleteController::Observer>
- observer_;
+ base::ScopedObservation<OmniboxControllerEmitter,
+ AutocompleteController::Observer>
+ observation_{this};
base::WeakPtrFactory<OmniboxPageHandler> weak_factory_{this};
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc
index f15c23a5251..b6a23414547 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc
@@ -10,16 +10,18 @@
#include "base/feature_list.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/omnibox/omnibox_page_handler.h"
-#include "chrome/browser/ui/webui/version_handler.h"
-#include "chrome/browser/ui/webui/version_ui.h"
+#include "chrome/browser/ui/webui/version/version_handler.h"
+#include "chrome/browser/ui/webui/version/version_ui.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/omnibox_resources.h"
+#include "chrome/grit/omnibox_resources_map.h"
#include "components/omnibox/common/omnibox_features.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"
#include "services/network/public/mojom/content_security_policy.mojom.h"
+#include "ui/base/webui/web_ui_util.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/ui/webui/omnibox/omnibox_popup_handler.h"
@@ -33,34 +35,18 @@ OmniboxUI::OmniboxUI(content::WebUI* web_ui)
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::TrustedTypes,
- "trusted-types parse-html-subset;");
+ "trusted-types cr-autocomplete-match parse-html-subset;");
// Expose version information to client because it is useful in output.
VersionUI::AddVersionDetailStrings(source);
source->UseStringsJs();
- static constexpr webui::ResourcePath kResources[] = {
- {"omnibox.css", IDR_OMNIBOX_CSS},
- {"omnibox_input.css", IDR_OMNIBOX_INPUT_CSS},
- {"output_results_group.css", IDR_OUTPUT_RESULTS_GROUP_CSS},
- {"omnibox_output_column_widths.css",
- IDR_OMNIBOX_OUTPUT_COLUMN_WIDTHS_CSS},
- {"omnibox_element.js", IDR_OMNIBOX_ELEMENT_JS},
- {"omnibox_input.js", IDR_OMNIBOX_INPUT_JS},
- {"omnibox_output.js", IDR_OMNIBOX_OUTPUT_JS},
- {"omnibox.js", IDR_OMNIBOX_JS},
- {"chrome/browser/ui/webui/omnibox/omnibox.mojom-webui.js",
- IDR_OMNIBOX_MOJO_JS},
- };
- webui::AddResourcePathsBulk(source, kResources);
-
- source->SetDefaultResource(IDR_OMNIBOX_HTML);
+ source->AddResourcePaths(
+ base::make_span(kOmniboxResources, kOmniboxResourcesSize));
+ source->SetDefaultResource(IDR_OMNIBOX_OMNIBOX_HTML);
#if !defined(OS_ANDROID)
if (base::FeatureList::IsEnabled(omnibox::kWebUIOmniboxPopup)) {
- source->AddResourcePath("omnibox_popup.js", IDR_OMNIBOX_POPUP_JS);
- source->AddResourcePath("omnibox_popup.html", IDR_OMNIBOX_POPUP_HTML);
-
popup_handler_ = std::make_unique<OmniboxPopupHandler>();
}
#endif
diff --git a/chromium/chrome/browser/ui/webui/plural_string_handler.cc b/chromium/chrome/browser/ui/webui/plural_string_handler.cc
index d50043bdd88..3648fe02d9e 100644
--- a/chromium/chrome/browser/ui/webui/plural_string_handler.cc
+++ b/chromium/chrome/browser/ui/webui/plural_string_handler.cc
@@ -7,8 +7,10 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/values.h"
+#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/strings/grit/ui_strings.h"
PluralStringHandler::PluralStringHandler() {}
@@ -19,6 +21,18 @@ void PluralStringHandler::RegisterMessages() {
"getPluralString",
base::BindRepeating(&PluralStringHandler::HandleGetPluralString,
base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "getPluralStringTupleWithComma",
+ base::BindRepeating(
+ &PluralStringHandler::HandleGetPluralStringTupleWithComma,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "getPluralStringTupleWithPeriods",
+ base::BindRepeating(
+ &PluralStringHandler::HandleGetPluralStringTupleWithPeriods,
+ base::Unretained(this)));
}
void PluralStringHandler::AddLocalizedString(const std::string& name, int id) {
@@ -37,10 +51,52 @@ void PluralStringHandler::HandleGetPluralString(const base::ListValue* args) {
int count;
CHECK(args->GetInteger(2, &count));
+ auto string = GetPluralizedStringForMessageName(message_name, count);
+
+ ResolveJavascriptCallback(*callback_id, base::Value(string));
+}
+
+void PluralStringHandler::HandleGetPluralStringTupleWithComma(
+ const base::ListValue* args) {
+ GetPluralStringTuple(args, IDS_CONCAT_TWO_STRINGS_WITH_COMMA);
+}
+
+void PluralStringHandler::HandleGetPluralStringTupleWithPeriods(
+ const base::ListValue* args) {
+ GetPluralStringTuple(args, IDS_CONCAT_TWO_STRINGS_WITH_PERIODS);
+}
+
+void PluralStringHandler::GetPluralStringTuple(const base::ListValue* args,
+ int string_tuple_id) {
+ AllowJavascript();
+ CHECK_EQ(5U, args->GetSize());
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+
+ std::string message_name1;
+ CHECK(args->GetString(1, &message_name1));
+
+ int count1;
+ CHECK(args->GetInteger(2, &count1));
+
+ std::string message_name2;
+ CHECK(args->GetString(3, &message_name2));
+
+ int count2;
+ CHECK(args->GetInteger(4, &count2));
+
+ auto string1 = GetPluralizedStringForMessageName(message_name1, count1);
+ auto string2 = GetPluralizedStringForMessageName(message_name2, count2);
+
+ ResolveJavascriptCallback(
+ *callback_id, base::Value(l10n_util::GetStringFUTF8(string_tuple_id,
+ string1, string2)));
+}
+
+base::string16 PluralStringHandler::GetPluralizedStringForMessageName(
+ std::string message_name,
+ int count) {
auto message_id_it = name_to_id_.find(message_name);
CHECK(name_to_id_.end() != message_id_it);
-
- ResolveJavascriptCallback(*callback_id,
- base::Value(l10n_util::GetPluralStringFUTF8(
- message_id_it->second, count)));
+ return l10n_util::GetPluralStringFUTF16(message_id_it->second, count);
}
diff --git a/chromium/chrome/browser/ui/webui/plural_string_handler.h b/chromium/chrome/browser/ui/webui/plural_string_handler.h
index c9535247d0a..c123a51c377 100644
--- a/chromium/chrome/browser/ui/webui/plural_string_handler.h
+++ b/chromium/chrome/browser/ui/webui/plural_string_handler.h
@@ -22,6 +22,24 @@ class PluralStringHandler : public content::WebUIMessageHandler {
private:
void HandleGetPluralString(const base::ListValue* args);
+ // Constructs two pluralized strings from the received arguments for the two
+ // strings, and then concatenates those with comma and whitespace in between.
+ void HandleGetPluralStringTupleWithComma(const base::ListValue* args);
+
+ // Constructs two pluralized strings from the received arguments for the two
+ // strings, and then concatenates those with period and whitespace in between,
+ // and a period afterwards.
+ void HandleGetPluralStringTupleWithPeriods(const base::ListValue* args);
+
+ // Constructs two pluralized strings from the received arguments for the two
+ // strings, and then concatenates those using the concatenation template
+ // specified. This method should only be called from within the
+ // |HandleGetPluralStringTuple*| methods above.
+ void GetPluralStringTuple(const base::ListValue* args, int string_tuple_id);
+
+ base::string16 GetPluralizedStringForMessageName(std::string message_name,
+ int count);
+
std::map<std::string, int> name_to_id_;
DISALLOW_COPY_AND_ASSIGN(PluralStringHandler);
diff --git a/chromium/chrome/browser/ui/webui/policy_ui.cc b/chromium/chrome/browser/ui/webui/policy/policy_ui.cc
index 13d09970fe3..dc454eb542f 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui.cc
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui.cc
@@ -2,13 +2,13 @@
// 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_ui.h"
+#include "chrome/browser/ui/webui/policy/policy_ui.h"
#include <memory>
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/policy_ui_handler.h"
+#include "chrome/browser/ui/webui/policy/policy_ui_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "components/grit/dev_ui_components_resources.h"
@@ -34,8 +34,6 @@ content::WebUIDataSource* CreatePolicyUIHtmlSource() {
{"labelAssetId", IDS_POLICY_LABEL_ASSET_ID},
{"labelClientId", IDS_POLICY_LABEL_CLIENT_ID},
{"labelDirectoryApiId", IDS_POLICY_LABEL_DIRECTORY_API_ID},
- {"labelEnterpriseDisplayDomain",
- IDS_POLICY_LABEL_ENTERPRISE_DISPLAY_DOMAIN},
{"labelEnterpriseEnrollmentDomain",
IDS_POLICY_LABEL_ENTERPRISE_ENROLLMENT_DOMAIN},
{"labelGaiaId", IDS_POLICY_LABEL_GAIA_ID},
@@ -54,6 +52,7 @@ content::WebUIDataSource* CreatePolicyUIHtmlSource() {
{"labelStatus", IDS_POLICY_LABEL_STATUS},
{"labelTimeSinceLastRefresh", IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH},
{"labelUsername", IDS_POLICY_LABEL_USERNAME},
+ {"labelManagedBy", IDS_POLICY_LABEL_MANAGED_BY},
{"labelVersion", IDS_POLICY_LABEL_VERSION},
{"noPoliciesSet", IDS_POLICY_NO_POLICIES_SET},
{"offHoursActive", IDS_POLICY_OFFHOURS_ACTIVE},
@@ -76,7 +75,7 @@ content::WebUIDataSource* CreatePolicyUIHtmlSource() {
#endif
{"statusUser", IDS_POLICY_STATUS_USER},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->AddResourcePath("policy.css", IDR_POLICY_CSS);
source->AddResourcePath("policy_base.js", IDR_POLICY_BASE_JS);
diff --git a/chromium/chrome/browser/ui/webui/policy_ui.h b/chromium/chrome/browser/ui/webui/policy/policy_ui.h
index d8b58392fcd..a70da60869b 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui.h
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui.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_POLICY_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_POLICY_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_POLICY_POLICY_UI_H_
#include <string>
@@ -24,4 +24,4 @@ class PolicyUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(PolicyUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_POLICY_POLICY_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc
index 2cb49709e76..3355f373e28 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui_browsertest.cc
@@ -19,6 +19,7 @@
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/install_verifier.h"
#include "chrome/browser/extensions/test_extension_system.h"
@@ -52,9 +53,9 @@
#include "ui/shell_dialogs/select_file_policy.h"
#include "url/gurl.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#endif // defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/profiles/profile_helper.h"
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
using testing::_;
using testing::Return;
@@ -159,7 +160,7 @@ void SetChromeMetaData(base::DictionaryValue* expected) {
expected->SetPath({prefix, "application"}, base::Value(""));
expected->SetPath({prefix, "version"}, base::Value(""));
expected->SetPath({prefix, "revision"}, base::Value(""));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
expected->SetPath({prefix, "platform"}, base::Value(""));
#else
expected->SetPath({prefix, "OS"}, base::Value(""));
@@ -214,7 +215,7 @@ class PolicyUITest : public InProcessBrowserTest {
void VerifyExportingPolicies(const base::DictionaryValue& expected);
protected:
- policy::MockConfigurationPolicyProvider provider_;
+ testing::NiceMock<policy::MockConfigurationPolicyProvider> provider_;
private:
DISALLOW_COPY_AND_ASSIGN(PolicyUITest);
@@ -266,8 +267,8 @@ PolicyUITest::PolicyUITest() {}
PolicyUITest::~PolicyUITest() {}
void PolicyUITest::SetUpInProcessBrowserTestFixture() {
- EXPECT_CALL(provider_, IsInitializationComplete(_))
- .WillRepeatedly(Return(true));
+ ON_CALL(provider_, IsInitializationComplete(_)).WillByDefault(Return(true));
+ ON_CALL(provider_, IsFirstPolicyLoadComplete(_)).WillByDefault(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
policy::PushProfilePolicyConnectorProviderForTesting(&provider_);
@@ -432,12 +433,12 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, WritePoliciesToJSONFile) {
// such policies.
expected_values.SetDictionary("extensionPolicies",
std::make_unique<base::DictionaryValue>());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
expected_values.SetDictionary("loginScreenExtensionPolicies",
std::make_unique<base::DictionaryValue>());
expected_values.SetDictionary("deviceLocalAccountPolicies",
std::make_unique<base::DictionaryValue>());
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
provider_.UpdateChromePolicy(values);
@@ -465,7 +466,7 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, WritePoliciesToJSONFile) {
// contents).
VerifyExportingPolicies(expected_values);
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// 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,
@@ -596,11 +597,11 @@ class ExtensionPolicyUITest : public PolicyUITest,
bool UseSigninProfile() const { return GetParam(); }
Profile* extension_profile() const {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (UseSigninProfile()) {
return chromeos::ProfileHelper::GetSigninProfile();
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return browser()->profile();
}
};
@@ -796,10 +797,10 @@ IN_PROC_BROWSER_TEST_P(ExtensionPolicyUITest,
INSTANTIATE_TEST_SUITE_P(All,
ExtensionPolicyUITest,
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
::testing::Values(false, true)
-#else // defined(OS_CHROMEOS)
+#else // BUILDFLAG(IS_CHROMEOS_ASH)
::testing::Values(false)
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
);
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.cc
index fb3f4d9caaf..0c7732c6129 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.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/policy_ui_handler.h"
+#include "chrome/browser/ui/webui/policy/policy_ui_handler.h"
#include <stddef.h>
@@ -27,6 +27,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
@@ -35,7 +36,8 @@
#include "chrome/browser/policy/schema_registry_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
-#include "chrome/browser/ui/webui/version_ui.h"
+#include "chrome/browser/ui/webui/management/management_ui_handler.h"
+#include "chrome/browser/ui/webui/version/version_ui.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/channel_info.h"
#include "chrome/grit/chromium_strings.h"
@@ -79,7 +81,8 @@
#include "chrome/browser/ui/android/android_about_app_info.h"
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/policy/active_directory_policy_manager.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -87,7 +90,6 @@
#include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
#include "chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chromeos/dbus/util/version_loader.h"
#include "components/user_manager/user_manager.h"
#else
@@ -99,7 +101,7 @@
#endif
#if defined(OS_WIN)
-#include "chrome/browser/ui/webui/version_util_win.h"
+#include "chrome/browser/ui/webui/version/version_util_win.h"
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -217,14 +219,12 @@ void GetStatusFromCore(const policy::CloudPolicyCore* core,
GetTimeSinceLastRefreshString(last_refresh_time));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Adds a new entry to |dict| with the affiliation status of the user associated
-// with |profile|. Device scope policy status providers call this method with
-// nullptr |profile|. In this case no entry is added as affiliation status only
-// makes sense for user scope policy status providers.
+// with |profile|. This method shouldn't be called for device scope status.
void GetUserAffiliationStatus(base::DictionaryValue* dict, Profile* profile) {
- if (!profile)
- return;
+ CHECK(profile);
+
const user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
if (!user)
@@ -240,7 +240,19 @@ void GetOffHoursStatus(base::DictionaryValue* dict) {
off_hours_controller->is_off_hours_mode());
}
}
-#endif // defined(OS_CHROMEOS)
+
+// 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) {
+ CHECK(profile);
+
+ std::string account_manager = ManagementUIHandler::GetAccountManager(profile);
+ if (!account_manager.empty()) {
+ dict->SetString("enterpriseDomainManager", account_manager);
+ }
+}
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void ExtractDomainFromUsername(base::DictionaryValue* dict) {
std::string username;
@@ -260,7 +272,7 @@ class PolicyStatusProvider {
virtual ~PolicyStatusProvider();
// Sets a callback to invoke upon status changes.
- void SetStatusChangeCallback(const base::Closure& callback);
+ void SetStatusChangeCallback(const base::RepeatingClosure& callback);
virtual void GetStatus(base::DictionaryValue* dict);
@@ -268,7 +280,7 @@ class PolicyStatusProvider {
void NotifyStatusChange();
private:
- base::Closure callback_;
+ base::RepeatingClosure callback_;
DISALLOW_COPY_AND_ASSIGN(PolicyStatusProvider);
};
@@ -310,7 +322,7 @@ class UserCloudPolicyStatusProvider : public CloudPolicyCoreStatusProvider {
DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStatusProvider);
};
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// A cloud policy status provider for user policy on Chrome OS.
class UserCloudPolicyStatusProviderChromeOS
: public UserCloudPolicyStatusProvider {
@@ -326,9 +338,9 @@ class UserCloudPolicyStatusProviderChromeOS
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStatusProviderChromeOS);
};
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
class MachineLevelUserCloudPolicyStatusProvider
: public PolicyStatusProvider,
public policy::CloudPolicyStore::Observer {
@@ -348,9 +360,9 @@ class MachineLevelUserCloudPolicyStatusProvider
DISALLOW_COPY_AND_ASSIGN(MachineLevelUserCloudPolicyStatusProvider);
};
-#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// A cloud policy status provider for device policy.
class DeviceCloudPolicyStatusProviderChromeOS
: public CloudPolicyCoreStatusProvider {
@@ -364,7 +376,7 @@ class DeviceCloudPolicyStatusProviderChromeOS
private:
std::string enterprise_enrollment_domain_;
- std::string enterprise_display_domain_;
+ std::string enterprise_domain_manager_;
DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStatusProviderChromeOS);
};
@@ -429,7 +441,7 @@ class DeviceActiveDirectoryPolicyStatusProvider
DeviceActiveDirectoryPolicyStatusProvider(
policy::ActiveDirectoryPolicyManager* policy_manager,
const std::string& enterprise_realm,
- const std::string& enterprise_display_domain);
+ const std::string& enterprise_domain_manager);
~DeviceActiveDirectoryPolicyStatusProvider() override = default;
@@ -438,7 +450,7 @@ class DeviceActiveDirectoryPolicyStatusProvider
private:
std::string enterprise_realm_;
- std::string enterprise_display_domain_;
+ std::string enterprise_domain_manager_;
DISALLOW_COPY_AND_ASSIGN(DeviceActiveDirectoryPolicyStatusProvider);
};
@@ -467,7 +479,7 @@ PolicyStatusProvider::PolicyStatusProvider() {}
PolicyStatusProvider::~PolicyStatusProvider() {}
void PolicyStatusProvider::SetStatusChangeCallback(
- const base::Closure& callback) {
+ const base::RepeatingClosure& callback) {
callback_ = callback;
}
@@ -514,7 +526,7 @@ void UserCloudPolicyStatusProvider::GetStatus(base::DictionaryValue* dict) {
ExtractDomainFromUsername(dict);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
UserCloudPolicyStatusProviderChromeOS::UserCloudPolicyStatusProviderChromeOS(
policy::CloudPolicyCore* core,
Profile* profile)
@@ -531,10 +543,11 @@ void UserCloudPolicyStatusProviderChromeOS::GetStatus(
return;
UserCloudPolicyStatusProvider::GetStatus(dict);
GetUserAffiliationStatus(dict, profile_);
+ GetUserManager(dict, profile_);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
MachineLevelUserCloudPolicyStatusProvider::
MachineLevelUserCloudPolicyStatusProvider(policy::CloudPolicyCore* core)
@@ -604,16 +617,16 @@ void MachineLevelUserCloudPolicyStatusProvider::OnStoreError(
NotifyStatusChange();
}
-#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
DeviceCloudPolicyStatusProviderChromeOS::
DeviceCloudPolicyStatusProviderChromeOS(
policy::BrowserPolicyConnectorChromeOS* connector)
: CloudPolicyCoreStatusProvider(
connector->GetDeviceCloudPolicyManager()->core()) {
enterprise_enrollment_domain_ = connector->GetEnterpriseEnrollmentDomain();
- enterprise_display_domain_ = connector->GetEnterpriseDisplayDomain();
+ enterprise_domain_manager_ = connector->GetEnterpriseDomainManager();
}
DeviceCloudPolicyStatusProviderChromeOS::
@@ -623,7 +636,7 @@ void DeviceCloudPolicyStatusProviderChromeOS::GetStatus(
base::DictionaryValue* dict) {
GetStatusFromCore(core_, dict);
dict->SetString("enterpriseEnrollmentDomain", enterprise_enrollment_domain_);
- dict->SetString("enterpriseDisplayDomain", enterprise_display_domain_);
+ dict->SetString("enterpriseDomainManager", enterprise_domain_manager_);
GetOffHoursStatus(dict);
}
@@ -706,7 +719,15 @@ void UserActiveDirectoryPolicyStatusProvider::GetStatus(
dict->SetString("timeSinceLastRefresh",
GetTimeSinceLastRefreshString(last_refresh_time));
- GetUserAffiliationStatus(dict, profile_);
+
+ // 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(
@@ -723,19 +744,19 @@ DeviceActiveDirectoryPolicyStatusProvider::
DeviceActiveDirectoryPolicyStatusProvider(
policy::ActiveDirectoryPolicyManager* policy_manager,
const std::string& enterprise_realm,
- const std::string& enterprise_display_domain)
+ const std::string& enterprise_domain_manager)
: UserActiveDirectoryPolicyStatusProvider(policy_manager, nullptr),
enterprise_realm_(enterprise_realm),
- enterprise_display_domain_(enterprise_display_domain) {}
+ enterprise_domain_manager_(enterprise_domain_manager) {}
void DeviceActiveDirectoryPolicyStatusProvider::GetStatus(
base::DictionaryValue* dict) {
UserActiveDirectoryPolicyStatusProvider::GetStatus(dict);
dict->SetString("enterpriseEnrollmentDomain", enterprise_realm_);
- dict->SetString("enterpriseDisplayDomain", enterprise_display_domain_);
+ dict->SetString("enterpriseDomainManager", enterprise_domain_manager_);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
UpdaterStatusProvider::UpdaterStatusProvider() {
@@ -809,10 +830,13 @@ PolicyUIHandler::~PolicyUIHandler() {
void PolicyUIHandler::AddCommonLocalizedStringsToSource(
content::WebUIDataSource* source) {
- AddLocalizedStringsBulk(source, policy::kPolicySources);
+ source->AddLocalizedStrings(policy::kPolicySources);
static constexpr webui::LocalizedString kStrings[] = {
{"conflict", IDS_POLICY_LABEL_CONFLICT},
+ {"superseding", IDS_POLICY_LABEL_SUPERSEDING},
+ {"conflictValue", IDS_POLICY_LABEL_CONFLICT_VALUE},
+ {"supersededValue", IDS_POLICY_LABEL_SUPERSEDED_VALUE},
{"headerLevel", IDS_POLICY_HEADER_LEVEL},
{"headerName", IDS_POLICY_HEADER_NAME},
{"headerScope", IDS_POLICY_HEADER_SCOPE},
@@ -825,6 +849,7 @@ void PolicyUIHandler::AddCommonLocalizedStringsToSource(
{"error", IDS_POLICY_LABEL_ERROR},
{"deprecated", IDS_POLICY_LABEL_DEPRECATED},
{"future", IDS_POLICY_LABEL_FUTURE},
+ {"info", IDS_POLICY_LABEL_INFO},
{"ignored", IDS_POLICY_LABEL_IGNORED},
{"notSpecified", IDS_POLICY_NOT_SPECIFIED},
{"ok", IDS_POLICY_OK},
@@ -835,15 +860,17 @@ void PolicyUIHandler::AddCommonLocalizedStringsToSource(
{"unset", IDS_POLICY_UNSET},
{"value", IDS_POLICY_LABEL_VALUE},
{"sourceDefault", IDS_POLICY_SOURCE_DEFAULT},
+ {"loadPoliciesDone", IDS_POLICY_LOAD_POLICIES_DONE},
+ {"loadingPolicies", IDS_POLICY_LOADING_POLICIES},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->UseStringsJs();
}
void PolicyUIHandler::RegisterMessages() {
Profile* profile = Profile::FromWebUI(web_ui());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
if (connector->IsEnterpriseManaged()) {
@@ -851,7 +878,7 @@ void PolicyUIHandler::RegisterMessages() {
device_status_provider_ =
std::make_unique<DeviceActiveDirectoryPolicyStatusProvider>(
connector->GetDeviceActiveDirectoryPolicyManager(),
- connector->GetRealm(), connector->GetEnterpriseDisplayDomain());
+ connector->GetRealm(), connector->GetEnterpriseDomainManager());
} else {
device_status_provider_ =
std::make_unique<DeviceCloudPolicyStatusProviderChromeOS>(connector);
@@ -901,7 +928,7 @@ void PolicyUIHandler::RegisterMessages() {
manager->core());
}
#endif // !defined(OS_ANDROID)
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
ReloadUpdaterPoliciesAndState();
@@ -1015,9 +1042,9 @@ base::Value PolicyUIHandler::GetPolicyNames() const {
// Add extension policy names.
AddExtensionPolicyNames(&names, policy::POLICY_DOMAIN_EXTENSIONS);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
AddExtensionPolicyNames(&names, policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
@@ -1049,14 +1076,14 @@ void PolicyUIHandler::AddExtensionPolicyNames(
DCHECK(names->is_dict());
#if BUILDFLAG(ENABLE_EXTENSIONS)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
Profile* extension_profile =
policy_domain == policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS
? chromeos::ProfileHelper::GetSigninProfile()
: Profile::FromWebUI(web_ui());
-#else // defined(OS_CHROMEOS)
+#else // BUILDFLAG(IS_CHROMEOS_ASH)
Profile* extension_profile = Profile::FromWebUI(web_ui());
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
scoped_refptr<policy::SchemaMap> schema_map =
extension_profile->GetOriginalProfile()
@@ -1164,7 +1191,7 @@ void PolicyUIHandler::HandleListenPoliciesUpdates(const base::ListValue* args) {
}
void PolicyUIHandler::HandleReloadPolicies(const base::ListValue* args) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Allow user to manually fetch remote commands. Useful for testing or when
// the invalidation service is not working properly.
policy::CloudPolicyManager* const device_manager =
@@ -1232,7 +1259,7 @@ std::string PolicyUIHandler::GetPoliciesAsJson() const {
cohort_name.c_str());
chrome_metadata.SetKey("version", base::Value(version));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
chrome_metadata.SetKey("platform",
base::Value(chromeos::version_loader::GetVersion(
chromeos::version_loader::VERSION_FULL)));
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.h b/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.h
index 2b26a9a28f5..5091f7ece1e 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/policy/policy_ui_handler.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_POLICY_UI_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_POLICY_POLICY_UI_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_POLICY_POLICY_UI_HANDLER_H_
#include <stddef.h>
#include <string.h>
@@ -142,4 +142,4 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_POLICY_POLICY_UI_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc
index 1d3271b586f..794baf902be 100644
--- a/chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc
@@ -5,20 +5,21 @@
#include "chrome/browser/ui/webui/policy_indicator_localized_strings_provider.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/webui/web_ui_util.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/login/demo_mode/demo_session.h"
#endif
namespace policy_indicator {
void AddLocalizedStrings(content::WebUIDataSource* html_source) {
int controlled_setting_policy_id = IDS_CONTROLLED_SETTING_POLICY;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (chromeos::DemoSession::IsDeviceInDemoMode())
controlled_setting_policy_id = IDS_CONTROLLED_SETTING_DEMO_SESSION;
#endif
@@ -30,7 +31,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
{"controlledSettingExtension", IDS_CONTROLLED_SETTING_EXTENSION},
{"controlledSettingExtensionWithoutName",
IDS_CONTROLLED_SETTING_EXTENSION_WITHOUT_NAME},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"controlledSettingShared", IDS_CONTROLLED_SETTING_SHARED},
{"controlledSettingWithOwner", IDS_CONTROLLED_SETTING_WITH_OWNER},
{"controlledSettingNoOwner", IDS_CONTROLLED_SETTING_NO_OWNER},
@@ -39,7 +40,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
IDS_CONTROLLED_SETTING_CHILD_RESTRICTION},
#endif
};
- AddLocalizedStringsBulk(html_source, localized_strings);
+ html_source->AddLocalizedStrings(localized_strings);
}
} // namespace policy_indicator
diff --git a/chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc b/chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc
index dea6997da32..066a0eed1e9 100644
--- a/chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc
+++ b/chromium/chrome/browser/ui/webui/predictors/predictors_handler.cc
@@ -46,6 +46,7 @@ void PredictorsHandler::RegisterMessages() {
void PredictorsHandler::RequestAutocompleteActionPredictorDb(
const base::ListValue* args) {
+ AllowJavascript();
const bool enabled = !!autocomplete_action_predictor_;
base::DictionaryValue dict;
dict.SetBoolean("enabled", enabled);
@@ -67,12 +68,12 @@ void PredictorsHandler::RequestAutocompleteActionPredictorDb(
dict.Set("db", std::move(db));
}
- web_ui()->CallJavascriptFunctionUnsafe("updateAutocompleteActionPredictorDb",
- dict);
+ ResolveJavascriptCallback(args->GetList()[0] /* callback_id */, dict);
}
void PredictorsHandler::RequestResourcePrefetchPredictorDb(
const base::ListValue* args) {
+ AllowJavascript();
const bool enabled = (loading_predictor_ != nullptr);
base::DictionaryValue dict;
dict.SetBoolean("enabled", enabled);
@@ -95,8 +96,7 @@ void PredictorsHandler::RequestResourcePrefetchPredictorDb(
}
}
- web_ui()->CallJavascriptFunctionUnsafe("updateResourcePrefetchPredictorDb",
- dict);
+ ResolveJavascriptCallback(args->GetList()[0] /* callback_id */, dict);
}
void PredictorsHandler::AddOriginDataMapToListValue(
diff --git a/chromium/chrome/browser/ui/webui/predictors/predictors_ui.cc b/chromium/chrome/browser/ui/webui/predictors/predictors_ui.cc
index ba374623271..cfc822df921 100644
--- a/chromium/chrome/browser/ui/webui/predictors/predictors_ui.cc
+++ b/chromium/chrome/browser/ui/webui/predictors/predictors_ui.cc
@@ -19,7 +19,11 @@ namespace {
content::WebUIDataSource* CreatePredictorsUIHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIPredictorsHost);
+ source->AddResourcePath("autocomplete_action_predictor.js",
+ IDR_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_JS);
source->AddResourcePath("predictors.js", IDR_PREDICTORS_JS);
+ source->AddResourcePath("resource_prefetch_predictor.js",
+ IDR_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_JS);
source->SetDefaultResource(IDR_PREDICTORS_HTML);
return source;
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/DEPS b/chromium/chrome/browser/ui/webui/print_preview/DEPS
new file mode 100644
index 00000000000..89e0648e41a
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/print_preview/DEPS
@@ -0,0 +1,5 @@
+specific_include_rules = {
+ "local_printer_handler_.*_unittest.cc": [
+ "+chrome/services/printing/print_backend_service_test_impl.h",
+ ],
+}
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 26768770d2b..41845b698b3 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
@@ -15,6 +15,7 @@
#include "base/metrics/histogram_functions.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/printing/cups_print_job_manager.h"
#include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h"
@@ -22,20 +23,21 @@
#include "chrome/browser/chromeos/printing/cups_printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/ppd_provider_factory.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/printing/print_backend_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/printing/printer_capabilities.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
#include "chromeos/printing/printer_configuration.h"
#include "chromeos/printing/printer_translator.h"
#include "components/prefs/pref_service.h"
-#include "components/printing/browser/printer_capabilities.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "printing/backend/print_backend_consts.h"
#include "printing/backend/printing_restrictions.h"
+#include "printing/printing_features.h"
#include "url/gurl.h"
namespace printing {
@@ -63,10 +65,9 @@ PrinterBasicInfo ToBasicInfo(const chromeos::Printer& printer) {
}
void AddPrintersToList(const std::vector<chromeos::Printer>& printers,
- PrinterList* list) {
- for (const auto& printer : printers) {
- list->push_back(ToBasicInfo(printer));
- }
+ PrinterList& list) {
+ for (const auto& printer : printers)
+ list.push_back(ToBasicInfo(printer));
}
base::Value FetchCapabilitiesAsync(const std::string& device_name,
@@ -86,6 +87,30 @@ void CapabilitiesFetched(base::Value policies,
std::move(cb).Run(std::move(printer_info));
}
+void CapabilitiesFetchedFromService(
+ const std::string& device_name,
+ const PrinterBasicInfo& basic_info,
+ bool has_secure_protocol,
+ base::Value policies,
+ LocalPrinterHandlerChromeos::GetCapabilityCallback cb,
+ const base::Optional<PrinterSemanticCapsAndDefaults>& printer_caps) {
+ std::unique_ptr<PrinterSemanticCapsAndDefaults> caps;
+ if (printer_caps.has_value()) {
+ VLOG(1) << "Successfully received printer capabilities from service for "
+ << device_name;
+ caps =
+ std::make_unique<PrinterSemanticCapsAndDefaults>(printer_caps.value());
+ } else {
+ LOG(WARNING) << "Failure fetching printer capabilities from service for "
+ << device_name;
+ }
+ CapabilitiesFetched(
+ std::move(policies), std::move(cb),
+ AssemblePrinterSettings(device_name, basic_info,
+ PrinterSemanticCapsAndDefaults::Papers(),
+ has_secure_protocol, caps.get()));
+}
+
void FetchCapabilities(const chromeos::Printer& printer,
base::Value policies,
LocalPrinterHandlerChromeos::GetCapabilityCallback cb) {
@@ -93,13 +118,26 @@ void FetchCapabilities(const chromeos::Printer& printer,
PrinterBasicInfo basic_info = ToBasicInfo(printer);
- // USER_VISIBLE because the result is displayed in the print preview dialog.
- base::ThreadPool::PostTaskAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
- base::BindOnce(&FetchCapabilitiesAsync, printer.id(), basic_info,
- printer.HasSecureProtocol(),
- g_browser_process->GetApplicationLocale()),
- base::BindOnce(&CapabilitiesFetched, std::move(policies), std::move(cb)));
+ if (base::FeatureList::IsEnabled(features::kEnableOopPrintDrivers)) {
+ VLOG(1) << "Fetching printer capabilities via service";
+ GetPrintBackendService(g_browser_process->GetApplicationLocale(),
+ printer.id())
+ ->GetPrinterSemanticCapsAndDefaults(
+ printer.id(),
+ base::BindOnce(&CapabilitiesFetchedFromService, printer.id(),
+ std::move(basic_info), printer.HasSecureProtocol(),
+ std::move(policies), std::move(cb)));
+ } else {
+ VLOG(1) << "Fetching printer capabilities in-process";
+ // USER_VISIBLE because the result is displayed in the print preview dialog.
+ base::ThreadPool::PostTaskAndReplyWithResult(
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
+ base::BindOnce(&FetchCapabilitiesAsync, printer.id(), basic_info,
+ printer.HasSecureProtocol(),
+ g_browser_process->GetApplicationLocale()),
+ base::BindOnce(&CapabilitiesFetched, std::move(policies),
+ std::move(cb)));
+ }
}
} // namespace
@@ -115,7 +153,7 @@ LocalPrinterHandlerChromeos::LocalPrinterHandlerChromeos(
printers_manager_(printers_manager),
printer_configurer_(std::move(printer_configurer)),
ppd_provider_(std::move(ppd_provider)) {
- // Construct the CupsPrintJobManager to listen for printing events.
+ // Construct the `CupsPrintJobManager` to listen for printing events.
chromeos::CupsPrintJobManagerFactory::GetForBrowserContext(profile);
}
@@ -168,7 +206,7 @@ void LocalPrinterHandlerChromeos::GetDefaultPrinter(DefaultPrinterCallback cb) {
void LocalPrinterHandlerChromeos::StartGetPrinters(
AddedPrintersCallback added_printers_callback,
GetPrintersDoneCallback done_callback) {
- // SyncedPrintersManager is not thread safe and must be called from the UI
+ // `SyncedPrintersManager` is not thread safe and must be called from the UI
// thread.
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -177,11 +215,11 @@ void LocalPrinterHandlerChromeos::StartGetPrinters(
PrinterList printer_list;
AddPrintersToList(printers_manager_->GetPrinters(PrinterClass::kSaved),
- &printer_list);
+ printer_list);
AddPrintersToList(printers_manager_->GetPrinters(PrinterClass::kEnterprise),
- &printer_list);
+ printer_list);
AddPrintersToList(printers_manager_->GetPrinters(PrinterClass::kAutomatic),
- &printer_list);
+ printer_list);
ConvertPrinterListForCallback(std::move(added_printers_callback),
std::move(done_callback), printer_list);
@@ -298,7 +336,7 @@ void LocalPrinterHandlerChromeos::HandlePrinterSetup(
chromeos::PrinterConfigurer::RecordUsbPrinterSetupSource(
chromeos::UsbPrinterSetupSource::kPrintPreview);
}
- // fetch settings on the blocking pool and invoke callback.
+ // Fetch settings off of the UI thread and invoke callback.
FetchCapabilities(printer, GetNativePrinterPolicies(), std::move(cb));
return;
}
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 065fc3e4015..c5598f54172 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
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h"
#include <algorithm>
+#include <functional>
#include <memory>
#include <string>
#include <vector>
@@ -16,17 +17,20 @@
#include "base/values.h"
#include "chrome/browser/chromeos/printing/test_cups_printers_manager.h"
#include "chrome/browser/chromeos/printing/test_printer_configurer.h"
+#include "chrome/browser/printing/print_backend_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/printing/printer_capabilities.h"
+#include "chrome/services/printing/print_backend_service_test_impl.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/printing/ppd_provider.h"
-#include "components/printing/browser/printer_capabilities.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "printing/backend/print_backend.h"
#include "printing/backend/printing_restrictions.h"
#include "printing/backend/test_print_backend.h"
#include "printing/print_job_constants.h"
+#include "printing/printing_features.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace printing {
@@ -40,29 +44,31 @@ using chromeos::PrinterConfigurer;
using chromeos::PrinterSetupCallback;
using chromeos::PrinterSetupResult;
-// Used as a callback to StartGetPrinters in tests.
-// Increases |*call_count| and records values returned by StartGetPrinters.
-void RecordPrinterList(size_t* call_count,
- std::unique_ptr<base::ListValue>* printers_out,
+// Used as a callback to `StartGetPrinters` in tests.
+// Increases `call_count` and records values returned by `StartGetPrinters`.
+void RecordPrinterList(size_t& call_count,
+ std::unique_ptr<base::ListValue>& printers_out,
const base::ListValue& printers) {
- ++(*call_count);
- printers_out->reset(printers.DeepCopy());
+ ++call_count;
+ printers_out.reset(printers.DeepCopy());
}
// Used as a callback to StartGetPrinters in tests.
// Records that the test is done.
-void RecordPrintersDone(bool* is_done_out) {
- *is_done_out = true;
+void RecordPrintersDone(bool& is_done_out) {
+ is_done_out = true;
}
-void RecordGetCapability(std::unique_ptr<base::Value>* capabilities_out,
+void RecordGetCapability(bool& capabilities_set,
+ base::Value& capabilities_out,
base::Value capability) {
- capabilities_out->reset(capability.DeepCopy());
+ capabilities_out = capability.Clone();
+ capabilities_set = true;
}
-void RecordGetEulaUrl(std::string* fetched_eula_url,
+void RecordGetEulaUrl(std::string& fetched_eula_url,
const std::string& eula_url) {
- *fetched_eula_url = eula_url;
+ fetched_eula_url = eula_url;
}
Printer CreateTestPrinter(const std::string& id,
@@ -95,20 +101,20 @@ Printer CreateEnterprisePrinter(const std::string& id,
}
// Converts JSON string to base::ListValue object.
-// On failure, returns NULL and fills |*error| string.
+// On failure, returns NULL and fills `error` string.
std::unique_ptr<base::ListValue> GetJSONAsListValue(const std::string& json,
- std::string* error) {
+ std::string& error) {
auto ret = base::ListValue::From(
- JSONStringValueDeserializer(json).Deserialize(nullptr, error));
+ JSONStringValueDeserializer(json).Deserialize(nullptr, &error));
if (!ret)
- *error = "Value is not a list.";
+ error = "Value is not a list.";
return ret;
}
-// Fake PpdProvider backend. This fake PpdProvider is used to fake fetching the
-// PPD EULA license of a destination. If |effective_make_and_model| is empty, it
-// will return with NOT_FOUND and an empty string. Otherwise, it will return
-// SUCCESS with |effective_make_and_model| as the PPD license.
+// Fake `PpdProvider` backend. This fake `PpdProvider` is used to fake fetching
+// the PPD EULA license of a destination. If `effective_make_and_model` is
+// empty, it will return with NOT_FOUND and an empty string. Otherwise, it will
+// return SUCCESS with `effective_make_and_model` as the PPD license.
class FakePpdProvider : public chromeos::PpdProvider {
public:
FakePpdProvider() = default;
@@ -123,7 +129,7 @@ class FakePpdProvider : public chromeos::PpdProvider {
effective_make_and_model.as_string()));
}
- // These methods are not used by CupsPrintersManager.
+ // These methods are not used by `CupsPrintersManager`.
void ResolvePpd(const Printer::PpdReference& reference,
ResolvePpdCallback cb) override {}
void ResolvePpdReference(const chromeos::PrinterSearchData& search_data,
@@ -143,6 +149,10 @@ class FakePpdProvider : public chromeos::PpdProvider {
class LocalPrinterHandlerChromeosTest : public testing::Test {
public:
LocalPrinterHandlerChromeosTest() = default;
+ LocalPrinterHandlerChromeosTest(const LocalPrinterHandlerChromeosTest&) =
+ delete;
+ LocalPrinterHandlerChromeosTest& operator=(
+ const LocalPrinterHandlerChromeosTest&) = delete;
~LocalPrinterHandlerChromeosTest() override = default;
void SetUp() override {
@@ -155,19 +165,65 @@ class LocalPrinterHandlerChromeosTest : public testing::Test {
}
protected:
- // Must outlive |profile_|.
+ void AddPrinter(const std::string& id,
+ const std::string& display_name,
+ const std::string& description,
+ bool is_default) {
+ auto caps = std::make_unique<PrinterSemanticCapsAndDefaults>();
+ caps->papers.push_back({"bar", "vendor", {600, 600}});
+ auto basic_info = std::make_unique<PrinterBasicInfo>(
+ id, display_name, description, /*printer_status=*/0, is_default,
+ PrinterBasicInfoOptions{});
+ test_backend_->AddValidPrinter("printer1", std::move(caps),
+ std::move(basic_info));
+ }
+
+ // Must outlive `profile_`.
content::BrowserTaskEnvironment task_environment_;
- // Must outlive |printers_manager_|.
+ // Must outlive `printers_manager_`.
TestingProfile profile_;
scoped_refptr<TestPrintBackend> test_backend_;
chromeos::TestCupsPrintersManager printers_manager_;
scoped_refptr<FakePpdProvider> ppd_provider_;
std::unique_ptr<LocalPrinterHandlerChromeos> local_printer_handler_;
+};
- private:
- DISALLOW_COPY_AND_ASSIGN(LocalPrinterHandlerChromeosTest);
+// `LocalPrinterHandlerChromeosProcessScopeTest` performs test which make use
+// of the print backend and can utilize that in different process scopes, be
+// that in-process via a local task runner or out-of-process through a service.
+class LocalPrinterHandlerChromeosProcessScopeTest
+ : public LocalPrinterHandlerChromeosTest,
+ public testing::WithParamInterface<bool> {
+ public:
+ LocalPrinterHandlerChromeosProcessScopeTest() = default;
+ LocalPrinterHandlerChromeosProcessScopeTest(
+ const LocalPrinterHandlerChromeosProcessScopeTest&) = delete;
+ LocalPrinterHandlerChromeosProcessScopeTest& operator=(
+ const LocalPrinterHandlerChromeosProcessScopeTest&) = delete;
+ ~LocalPrinterHandlerChromeosProcessScopeTest() override = default;
+
+ void SetUp() override {
+ // Choose between running with local test runner or via a service.
+ LocalPrinterHandlerChromeosTest::SetUp();
+ const bool use_backend_service = GetParam();
+ if (use_backend_service) {
+ feature_list_.InitAndEnableFeature(features::kEnableOopPrintDrivers);
+ print_backend_service_ = PrintBackendServiceTestImpl::LaunchForTesting(
+ test_remote_, test_backend_);
+ }
+ }
+
+ protected:
+ // Support for testing via a service instead of with a local task runner.
+ base::test::ScopedFeatureList feature_list_;
+ mojo::Remote<mojom::PrintBackendService> test_remote_;
+ std::unique_ptr<PrintBackendServiceTestImpl> print_backend_service_;
};
+INSTANTIATE_TEST_SUITE_P(All,
+ LocalPrinterHandlerChromeosProcessScopeTest,
+ testing::Bool());
+
TEST_F(LocalPrinterHandlerChromeosTest, GetPrinters) {
size_t call_count = 0;
std::unique_ptr<base::ListValue> printers;
@@ -185,8 +241,9 @@ TEST_F(LocalPrinterHandlerChromeosTest, GetPrinters) {
printers_manager_.AddPrinter(automatic_printer, PrinterClass::kAutomatic);
local_printer_handler_->StartGetPrinters(
- base::BindRepeating(&RecordPrinterList, &call_count, &printers),
- base::BindOnce(&RecordPrintersDone, &is_done));
+ base::BindRepeating(&RecordPrinterList, std::ref(call_count),
+ std::ref(printers)),
+ base::BindOnce(&RecordPrintersDone, std::ref(is_done)));
EXPECT_EQ(call_count, 1u);
EXPECT_TRUE(is_done);
@@ -225,77 +282,78 @@ TEST_F(LocalPrinterHandlerChromeosTest, GetPrinters) {
)";
std::string error;
std::unique_ptr<base::ListValue> expected_printers(
- GetJSONAsListValue(expected_list, &error));
+ GetJSONAsListValue(expected_list, std::ref(error)));
ASSERT_TRUE(expected_printers) << "Error deserializing printers: " << error;
EXPECT_EQ(*printers, *expected_printers);
}
// Tests that fetching capabilities for an existing installed printer is
// successful.
-TEST_F(LocalPrinterHandlerChromeosTest, StartGetCapabilityValidPrinter) {
+TEST_P(LocalPrinterHandlerChromeosProcessScopeTest,
+ StartGetCapabilityValidPrinter) {
Printer saved_printer =
CreateTestPrinter("printer1", "saved", "description1");
printers_manager_.AddPrinter(saved_printer, PrinterClass::kSaved);
printers_manager_.InstallPrinter("printer1");
- // Add printer capabilities to |test_backend_|.
- PrinterSemanticCapsAndDefaults caps;
- test_backend_->AddValidPrinter(
- "printer1", std::make_unique<PrinterSemanticCapsAndDefaults>(caps),
- std::make_unique<printing::PrinterBasicInfo>());
+ // Add printer capabilities to `test_backend_`.
+ AddPrinter("printer1", "saved", "description1", true);
- std::unique_ptr<base::Value> fetched_caps;
+ bool did_fetch_caps = false;
+ base::Value fetched_caps;
local_printer_handler_->StartGetCapability(
- "printer1", base::BindOnce(&RecordGetCapability, &fetched_caps));
+ "printer1", base::BindOnce(&RecordGetCapability, std::ref(did_fetch_caps),
+ std::ref(fetched_caps)));
task_environment_.RunUntilIdle();
- ASSERT_TRUE(fetched_caps);
- base::DictionaryValue* dict;
- ASSERT_TRUE(fetched_caps->GetAsDictionary(&dict));
- ASSERT_TRUE(dict->HasKey(kSettingCapabilities));
- ASSERT_TRUE(dict->HasKey(kPrinter));
+ ASSERT_TRUE(did_fetch_caps);
+ ASSERT_TRUE(fetched_caps.is_dict());
+ EXPECT_TRUE(fetched_caps.FindKey(kSettingCapabilities));
+ EXPECT_TRUE(fetched_caps.FindKey(kPrinter));
}
// Test that printers which have not yet been installed are installed with
-// SetUpPrinter before their capabilities are fetched.
-TEST_F(LocalPrinterHandlerChromeosTest, StartGetCapabilityPrinterNotInstalled) {
+// `SetUpPrinter` before their capabilities are fetched.
+TEST_P(LocalPrinterHandlerChromeosProcessScopeTest,
+ StartGetCapabilityPrinterNotInstalled) {
Printer discovered_printer =
CreateTestPrinter("printer1", "discovered", "description1");
- // NOTE: The printer |discovered_printer| is not installed using
- // InstallPrinter.
+ // NOTE: The printer `discovered_printer` is not installed using
+ // `InstallPrinter`.
printers_manager_.AddPrinter(discovered_printer, PrinterClass::kDiscovered);
- // Add printer capabilities to |test_backend_|.
- PrinterSemanticCapsAndDefaults caps;
- test_backend_->AddValidPrinter(
- "printer1", std::make_unique<PrinterSemanticCapsAndDefaults>(caps),
- std::make_unique<printing::PrinterBasicInfo>());
+ // Add printer capabilities to `test_backend_`.
+ AddPrinter("printer1", "discovered", "description1", true);
- std::unique_ptr<base::Value> fetched_caps;
+ bool did_fetch_caps = false;
+ base::Value fetched_caps;
local_printer_handler_->StartGetCapability(
- "printer1", base::BindOnce(&RecordGetCapability, &fetched_caps));
+ "printer1", base::BindOnce(&RecordGetCapability, std::ref(did_fetch_caps),
+ std::ref(fetched_caps)));
task_environment_.RunUntilIdle();
- ASSERT_TRUE(fetched_caps);
- base::DictionaryValue* dict;
- ASSERT_TRUE(fetched_caps->GetAsDictionary(&dict));
- ASSERT_TRUE(dict->HasKey(kSettingCapabilities));
- ASSERT_TRUE(dict->HasKey(kPrinter));
+ ASSERT_TRUE(did_fetch_caps);
+ ASSERT_TRUE(fetched_caps.is_dict());
+ EXPECT_TRUE(fetched_caps.FindKey(kSettingCapabilities));
+ EXPECT_TRUE(fetched_caps.FindKey(kPrinter));
}
-// In this test we expect the StartGetCapability to bail early because the
-// provided printer can't be found in the CupsPrintersManager.
+// In this test we expect the `StartGetCapability` to bail early because the
+// provided printer can't be found in the `CupsPrintersManager`.
TEST_F(LocalPrinterHandlerChromeosTest, StartGetCapabilityInvalidPrinter) {
- std::unique_ptr<base::Value> fetched_caps;
+ bool did_fetch_caps = false;
+ base::Value fetched_caps;
local_printer_handler_->StartGetCapability(
- "invalid printer", base::BindOnce(&RecordGetCapability, &fetched_caps));
+ "invalid printer",
+ base::BindOnce(&RecordGetCapability, std::ref(did_fetch_caps),
+ std::ref(fetched_caps)));
task_environment_.RunUntilIdle();
- ASSERT_TRUE(fetched_caps);
- EXPECT_TRUE(fetched_caps->is_none());
+ ASSERT_TRUE(did_fetch_caps);
+ EXPECT_TRUE(fetched_caps.is_none());
}
TEST_F(LocalPrinterHandlerChromeosTest, GetNativePrinterPolicies) {
@@ -333,7 +391,7 @@ TEST_F(LocalPrinterHandlerChromeosTest, StartFetchValidEulaUrl) {
Printer::PpdReference ref;
ref.effective_make_and_model = "expected_make_model";
- // Printers with a PpdReference will return a license
+ // Printers with a `PpdReference` will return a license
Printer saved_printer = CreateTestPrinterWithPpdReference(
"printer1", "saved", "description1", ref);
printers_manager_.AddPrinter(saved_printer, PrinterClass::kSaved);
@@ -341,7 +399,8 @@ TEST_F(LocalPrinterHandlerChromeosTest, StartFetchValidEulaUrl) {
std::string fetched_eula_url;
local_printer_handler_->StartGetEulaUrl(
- "printer1", base::BindOnce(&RecordGetEulaUrl, &fetched_eula_url));
+ "printer1",
+ base::BindOnce(&RecordGetEulaUrl, std::ref(fetched_eula_url)));
task_environment_.RunUntilIdle();
@@ -350,7 +409,7 @@ TEST_F(LocalPrinterHandlerChromeosTest, StartFetchValidEulaUrl) {
// Test that a printer with no PPD license will return an empty string.
TEST_F(LocalPrinterHandlerChromeosTest, StartFetchNotFoundEulaUrl) {
- // A printer without a PpdReference will simulate an PPD without a license.
+ // A printer without a `PpdReference` will simulate an PPD without a license.
Printer saved_printer =
CreateTestPrinter("printer1", "saved", "description1");
printers_manager_.AddPrinter(saved_printer, PrinterClass::kSaved);
@@ -358,7 +417,8 @@ TEST_F(LocalPrinterHandlerChromeosTest, StartFetchNotFoundEulaUrl) {
std::string fetched_eula_url;
local_printer_handler_->StartGetEulaUrl(
- "printer1", base::BindOnce(&RecordGetEulaUrl, &fetched_eula_url));
+ "printer1",
+ base::BindOnce(&RecordGetEulaUrl, std::ref(fetched_eula_url)));
task_environment_.RunUntilIdle();
@@ -366,14 +426,15 @@ TEST_F(LocalPrinterHandlerChromeosTest, StartFetchNotFoundEulaUrl) {
}
// Test that fetching a PPD license will exit early if the printer is not found
-// in CupsPrintersManager.
+// in `CupsPrintersManager`.
TEST_F(LocalPrinterHandlerChromeosTest, StartFetchEulaUrlOnNonExistantPrinter) {
Printer saved_printer =
CreateTestPrinter("printer1", "saved", "description1");
std::string fetched_eula_url;
local_printer_handler_->StartGetEulaUrl(
- "printer1", base::BindOnce(&RecordGetEulaUrl, &fetched_eula_url));
+ "printer1",
+ base::BindOnce(&RecordGetEulaUrl, std::ref(fetched_eula_url)));
task_environment_.RunUntilIdle();
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 bf325ecd6bc..be75cd7188a 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
@@ -16,13 +16,15 @@
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/printing/print_backend_service.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
-#include "components/printing/browser/printer_capabilities.h"
+#include "chrome/common/printing/printer_capabilities.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
+#include "printing/printing_features.h"
#if defined(OS_MAC)
-#include "components/printing/browser/printer_capabilities_mac.h"
+#include "chrome/common/printing/printer_capabilities_mac.h"
#endif
#if defined(OS_WIN)
@@ -54,6 +56,45 @@ scoped_refptr<base::TaskRunner> CreatePrinterHandlerTaskRunner() {
#endif
}
+void OnDidEnumeratePrinters(
+ PrinterHandler::AddedPrintersCallback added_printers_callback,
+ PrinterHandler::GetPrintersDoneCallback done_callback,
+ const base::Optional<PrinterList>& printer_list) {
+ const bool have_printers = printer_list.has_value();
+ if (!have_printers)
+ LOG(WARNING) << "Failure enumerating local printers.";
+
+ ConvertPrinterListForCallback(
+ std::move(added_printers_callback), std::move(done_callback),
+ have_printers ? printer_list.value() : PrinterList());
+}
+
+void OnDidFetchCapabilities(
+ const std::string& device_name,
+ bool has_secure_protocol,
+ PrinterHandler::GetCapabilityCallback callback,
+ const base::Optional<PrinterBasicInfo>& printer_info,
+ const base::Optional<PrinterSemanticCapsAndDefaults::Papers>&
+ user_defined_papers,
+ const base::Optional<PrinterSemanticCapsAndDefaults>& caps_and_defaults) {
+ const bool has_values = printer_info.has_value() &&
+ user_defined_papers.has_value() &&
+ caps_and_defaults.has_value();
+ if (!has_values) {
+ LOG(WARNING) << "Failure fetching printer capabilities for "
+ << device_name;
+ std::move(callback).Run(base::Value());
+ return;
+ }
+
+ VLOG(1) << "Received printer info & capabilities for " << device_name;
+ PrinterSemanticCapsAndDefaults caps = caps_and_defaults.value();
+ base::Value settings = AssemblePrinterSettings(
+ device_name, std::move(printer_info.value()),
+ std::move(user_defined_papers.value()), has_secure_protocol, &caps);
+ std::move(callback).Run(std::move(settings));
+}
+
} // namespace
// static
@@ -143,15 +184,24 @@ void LocalPrinterHandlerDefault::GetDefaultPrinter(DefaultPrinterCallback cb) {
void LocalPrinterHandlerDefault::StartGetPrinters(
AddedPrintersCallback callback,
GetPrintersDoneCallback done_callback) {
- VLOG(1) << "Enumerate printers start";
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::PostTaskAndReplyWithResult(
- task_runner_.get(), FROM_HERE,
- base::BindOnce(&EnumeratePrintersAsync,
- g_browser_process->GetApplicationLocale()),
- base::BindOnce(&ConvertPrinterListForCallback, std::move(callback),
- std::move(done_callback)));
+ if (base::FeatureList::IsEnabled(features::kEnableOopPrintDrivers)) {
+ VLOG(1) << "Enumerate printers start via service";
+ GetPrintBackendService(g_browser_process->GetApplicationLocale(),
+ /*printer_name=*/std::string())
+ ->EnumeratePrinters(base::BindOnce(&OnDidEnumeratePrinters,
+ std::move(callback),
+ std::move(done_callback)));
+ } else {
+ VLOG(1) << "Enumerate printers start in-process";
+ base::PostTaskAndReplyWithResult(
+ task_runner_.get(), FROM_HERE,
+ base::BindOnce(&EnumeratePrintersAsync,
+ g_browser_process->GetApplicationLocale()),
+ base::BindOnce(&ConvertPrinterListForCallback, std::move(callback),
+ std::move(done_callback)));
+ }
}
void LocalPrinterHandlerDefault::StartGetCapability(
@@ -159,11 +209,22 @@ void LocalPrinterHandlerDefault::StartGetCapability(
GetCapabilityCallback cb) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- base::PostTaskAndReplyWithResult(
- task_runner_.get(), FROM_HERE,
- base::BindOnce(&FetchCapabilitiesAsync, device_name,
- g_browser_process->GetApplicationLocale()),
- std::move(cb));
+ if (base::FeatureList::IsEnabled(features::kEnableOopPrintDrivers)) {
+ VLOG(1) << "Getting printer capabilities via service for " << device_name;
+ GetPrintBackendService(g_browser_process->GetApplicationLocale(),
+ device_name)
+ ->FetchCapabilities(
+ device_name,
+ base::BindOnce(&OnDidFetchCapabilities, device_name,
+ /*has_secure_protocol=*/false, std::move(cb)));
+ } else {
+ VLOG(1) << "Getting printer capabilities in-process for " << device_name;
+ base::PostTaskAndReplyWithResult(
+ task_runner_.get(), FROM_HERE,
+ base::BindOnce(&FetchCapabilitiesAsync, device_name,
+ g_browser_process->GetApplicationLocale()),
+ std::move(cb));
+ }
}
void LocalPrinterHandlerDefault::StartPrint(
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default_unittest.cc
new file mode 100644
index 00000000000..25549620856
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default_unittest.cc
@@ -0,0 +1,232 @@
+// 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.
+
+#include "chrome/browser/ui/webui/print_preview/local_printer_handler_default.h"
+
+#include <functional>
+#include <memory>
+
+#include "base/json/json_string_value_serializer.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_refptr.h"
+#include "base/strings/string_piece.h"
+#include "base/values.h"
+#include "chrome/browser/printing/print_backend_service.h"
+#include "chrome/common/printing/printer_capabilities.h"
+#include "chrome/services/printing/print_backend_service_test_impl.h"
+#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_task_environment.h"
+#include "printing/backend/print_backend.h"
+#include "printing/backend/test_print_backend.h"
+#include "printing/printing_features.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace printing {
+
+namespace {
+
+// Used as a callback to `StartGetPrinters` in tests.
+// Increases `call_count` and records values returned by `StartGetPrinters`.
+// TODO(crbug.com/1171579) Get rid of use of base::ListValue.
+void RecordPrinterList(size_t& call_count,
+ std::unique_ptr<base::ListValue>& printers_out,
+ const base::ListValue& printers) {
+ ++call_count;
+ printers_out.reset(printers.DeepCopy());
+}
+
+// Used as a callback to StartGetPrinters in tests.
+// Records that the test is done.
+void RecordPrintersDone(bool& is_done_out) {
+ is_done_out = true;
+}
+
+void RecordGetCapability(bool& capabilities_set,
+ base::Value& capabilities_out,
+ base::Value capability) {
+ capabilities_out = capability.Clone();
+ capabilities_set = true;
+}
+
+// Converts JSON string to base::ListValue object.
+// On failure, returns NULL and fills `error` string.
+std::unique_ptr<base::ListValue> GetJSONAsListValue(
+ const base::StringPiece& json,
+ std::string& error) {
+ auto ret = base::ListValue::From(
+ JSONStringValueDeserializer(json).Deserialize(nullptr, &error));
+ if (!ret)
+ error = "Value is not a list.";
+ return ret;
+}
+
+} // namespace
+
+class LocalPrinterHandlerDefaultTest : public testing::TestWithParam<bool> {
+ public:
+ LocalPrinterHandlerDefaultTest() = default;
+ LocalPrinterHandlerDefaultTest(const LocalPrinterHandlerDefaultTest&) =
+ delete;
+ LocalPrinterHandlerDefaultTest& operator=(
+ const LocalPrinterHandlerDefaultTest&) = delete;
+ ~LocalPrinterHandlerDefaultTest() override = default;
+
+ TestPrintBackend* print_backend() { return test_backend_.get(); }
+
+ void SetUp() override {
+ // Choose between running with local test runner or via a service.
+ const bool use_backend_service = GetParam();
+ feature_list_.InitWithFeatureState(features::kEnableOopPrintDrivers,
+ use_backend_service);
+
+ TestingProfile::Builder builder;
+ profile_ = builder.Build();
+ initiator_web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(profile_.get()));
+ content::WebContents* initiator = initiator_web_contents_.get();
+ test_backend_ = base::MakeRefCounted<TestPrintBackend>();
+ PrintBackend::SetPrintBackendForTesting(test_backend_.get());
+ local_printer_handler_ =
+ std::make_unique<LocalPrinterHandlerDefault>(initiator);
+
+ if (use_backend_service) {
+ print_backend_service_ = PrintBackendServiceTestImpl::LaunchForTesting(
+ test_remote_, test_backend_);
+ }
+ }
+
+ void AddPrinter(const std::string& id,
+ const std::string& display_name,
+ const std::string& description,
+ bool is_default) {
+ auto caps = std::make_unique<PrinterSemanticCapsAndDefaults>();
+ caps->papers.emplace_back(
+ PrinterSemanticCapsAndDefaults::Paper{"bar", "vendor", {600, 600}});
+ auto basic_info = std::make_unique<PrinterBasicInfo>(
+ id, display_name, description,
+ /*printer_status=*/0, is_default, PrinterBasicInfoOptions{});
+
+ print_backend()->AddValidPrinter(id, std::move(caps),
+ std::move(basic_info));
+ }
+
+ protected:
+ content::BrowserTaskEnvironment task_environment_;
+ std::unique_ptr<TestingProfile> profile_;
+ std::unique_ptr<content::WebContents> initiator_web_contents_;
+ scoped_refptr<TestPrintBackend> test_backend_;
+ std::unique_ptr<LocalPrinterHandlerDefault> local_printer_handler_;
+
+ // Support for testing via a service instead of with a local task runner.
+ base::test::ScopedFeatureList feature_list_;
+ mojo::Remote<mojom::PrintBackendService> test_remote_;
+ std::unique_ptr<PrintBackendServiceTestImpl> print_backend_service_;
+};
+
+INSTANTIATE_TEST_SUITE_P(All, LocalPrinterHandlerDefaultTest, testing::Bool());
+
+TEST_P(LocalPrinterHandlerDefaultTest, GetPrinters) {
+ AddPrinter("printer1", "default1", "description1", true);
+ AddPrinter("printer2", "non-default2", "description2", false);
+ AddPrinter("printer3", "non-default3", "description3", false);
+
+ size_t call_count = 0;
+ std::unique_ptr<base::ListValue> printers;
+ bool is_done = false;
+
+ local_printer_handler_->StartGetPrinters(
+ base::BindRepeating(&RecordPrinterList, std::ref(call_count),
+ std::ref(printers)),
+ base::BindOnce(&RecordPrintersDone, std::ref(is_done)));
+
+ task_environment_.RunUntilIdle();
+
+ EXPECT_EQ(call_count, 1u);
+ EXPECT_TRUE(is_done);
+ ASSERT_TRUE(printers);
+
+ constexpr base::StringPiece expected_list = R"(
+ [
+ {
+ "deviceName": "printer1",
+ "printerDescription": "description1",
+ "printerName": "default1",
+ "printerOptions": {}
+ },
+ {
+ "deviceName": "printer2",
+ "printerDescription": "description2",
+ "printerName": "non-default2",
+ "printerOptions": {}
+ },
+ {
+ "deviceName": "printer3",
+ "printerDescription": "description3",
+ "printerName": "non-default3",
+ "printerOptions": {}
+ }
+ ]
+ )";
+ std::string error;
+ std::unique_ptr<base::ListValue> expected_printers(
+ GetJSONAsListValue(expected_list, error));
+ ASSERT_TRUE(expected_printers) << "Error deserializing printers: " << error;
+ EXPECT_EQ(*printers, *expected_printers);
+}
+
+TEST_P(LocalPrinterHandlerDefaultTest, GetPrintersNoneRegistered) {
+ size_t call_count = 0;
+ std::unique_ptr<base::ListValue> printers;
+ bool is_done = false;
+
+ // Do not add any printers before attempt to get printer list.
+ local_printer_handler_->StartGetPrinters(
+ base::BindRepeating(&RecordPrinterList, std::ref(call_count),
+ std::ref(printers)),
+ base::BindOnce(&RecordPrintersDone, std::ref(is_done)));
+
+ task_environment_.RunUntilIdle();
+
+ EXPECT_EQ(call_count, 0u);
+ EXPECT_TRUE(is_done);
+ EXPECT_FALSE(printers);
+}
+
+// Tests that fetching capabilities for an existing installed printer is
+// successful.
+TEST_P(LocalPrinterHandlerDefaultTest, StartGetCapabilityValidPrinter) {
+ AddPrinter("printer1", "default1", "description1", true);
+
+ bool did_fetch_caps = false;
+ base::Value fetched_caps;
+ local_printer_handler_->StartGetCapability(
+ "printer1", base::BindOnce(&RecordGetCapability, std::ref(did_fetch_caps),
+ std::ref(fetched_caps)));
+
+ task_environment_.RunUntilIdle();
+
+ ASSERT_TRUE(did_fetch_caps);
+ ASSERT_TRUE(fetched_caps.is_dict());
+ EXPECT_TRUE(fetched_caps.FindKey(kSettingCapabilities));
+ EXPECT_TRUE(fetched_caps.FindKey(kPrinter));
+}
+
+// Tests that fetching capabilities bails early when the provided printer
+// can't be found.
+TEST_P(LocalPrinterHandlerDefaultTest, StartGetCapabilityInvalidPrinter) {
+ bool did_fetch_caps = false;
+ base::Value fetched_caps;
+ local_printer_handler_->StartGetCapability(
+ /*destination_id=*/"invalid printer",
+ base::BindOnce(&RecordGetCapability, std::ref(did_fetch_caps),
+ std::ref(fetched_caps)));
+
+ task_environment_.RunUntilIdle();
+
+ ASSERT_TRUE(did_fetch_caps);
+ EXPECT_TRUE(fetched_caps.is_none());
+}
+
+} // namespace printing
diff --git a/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
index c48314e52e8..e64ac255c18 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
@@ -9,17 +9,19 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/command_line.h"
+#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/i18n/file_util_icu.h"
-#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_prefs.h"
@@ -46,10 +48,10 @@
#include "url/gurl.h"
#if defined(OS_MAC)
-#include "components/printing/browser/printer_capabilities_mac.h"
+#include "chrome/common/printing/printer_capabilities_mac.h"
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#endif
@@ -254,7 +256,7 @@ void PdfPrinterHandler::StartPrint(
base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
bool prompt_user = !cmdline->HasSwitch(switches::kKioskModePrinting);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
use_drive_mount_ =
settings.FindBoolKey(kSettingPrintToGoogleDrive).value_or(false);
#endif
@@ -287,7 +289,7 @@ base::FilePath PdfPrinterHandler::GetFileNameForPrintJobTitle(
const base::string16& job_title) {
DCHECK(!job_title.empty());
#if defined(OS_WIN)
- base::FilePath::StringType print_job_title(job_title);
+ base::FilePath::StringType print_job_title(base::AsWString(job_title));
#elif defined(OS_POSIX)
base::FilePath::StringType print_job_title = base::UTF16ToUTF8(job_title);
#endif
@@ -430,7 +432,7 @@ void PdfPrinterHandler::OnDirectorySelected(const base::FilePath& filename,
}
base::FilePath PdfPrinterHandler::GetSaveLocation() const {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
drive::DriveIntegrationService* drive_service =
drive::DriveIntegrationServiceFactory::GetForProfile(profile_);
if (use_drive_mount_ && drive_service && drive_service->IsMounted()) {
diff --git a/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.h b/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
index 26954aeae08..d796486f6b7 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
#include "ui/shell_dialogs/select_file_dialog.h"
@@ -108,7 +109,7 @@ class PdfPrinterHandler : public PrinterHandler,
// The callback to call when complete.
PrintCallback print_callback_;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Determines if the local Drive mount is sent to the file picker as the
// default save location. Set to true for Save to Drive print jobs.
bool use_drive_mount_ = false;
diff --git a/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_unittest.cc
index 23cc4711f79..c5b9d0242be 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_unittest.cc
@@ -17,7 +17,7 @@
#include "url/gurl.h"
#if defined(OS_MAC)
-#include "components/printing/browser/printer_capabilities_mac.h"
+#include "chrome/common/printing/printer_capabilities_mac.h"
#include "printing/backend/print_backend.h"
#include "ui/gfx/geometry/size.h"
#endif
diff --git a/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_win_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_win_unittest.cc
index 77de5f8fd34..1616bb22b6a 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_win_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_win_unittest.cc
@@ -32,7 +32,7 @@ void ExecuteCancelledSelectFileDialog(
const base::FilePath& default_path,
const std::vector<ui::FileFilterSpec>& filter,
int file_type_index,
- const base::string16& default_extension,
+ const std::wstring& default_extension,
HWND owner,
ui::OnSelectFileExecutedCallback on_select_file_executed_callback) {
// Send an empty result to simulate a cancelled dialog.
@@ -117,17 +117,17 @@ class PdfPrinterHandlerWinTest : public BrowserWithTestWindowTest {
};
TEST_F(PdfPrinterHandlerWinTest, TestSaveAsPdf) {
- pdf_printer_->StartPrintToPdf(L"111111111111111111111.html");
+ pdf_printer_->StartPrintToPdf(STRING16_LITERAL("111111111111111111111.html"));
EXPECT_TRUE(pdf_printer_->save_failed());
}
TEST_F(PdfPrinterHandlerWinTest, TestSaveAsPdfLongFileName) {
- pdf_printer_->StartPrintToPdf(
- L"11111111111111111111111111111111111111111111111111111111111111111111111"
- L"11111111111111111111111111111111111111111111111111111111111111111111111"
- L"11111111111111111111111111111111111111111111111111111111111111111111111"
- L"11111111111111111111111111111111111111111111111111111111111111111111111"
- L"1111111111111111111111111111111111111111111111111.html");
+ pdf_printer_->StartPrintToPdf(STRING16_LITERAL(
+ "111111111111111111111111111111111111111111111111111111111111111111111111"
+ "111111111111111111111111111111111111111111111111111111111111111111111111"
+ "111111111111111111111111111111111111111111111111111111111111111111111111"
+ "111111111111111111111111111111111111111111111111111111111111111111111111"
+ "111111111111111111111111111111111111111111111.html"));
EXPECT_TRUE(pdf_printer_->save_failed());
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc b/chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc
index 28088a6be76..ce617f0a28c 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/print_preview/policy_settings.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
@@ -12,13 +13,14 @@ namespace printing {
// static
void PolicySettings::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(prefs::kForceEnablePrivetPrinting, false);
registry->RegisterListPref(prefs::kPrinterTypeDenyList);
registry->RegisterBooleanPref(prefs::kPrintHeaderFooter, true);
registry->RegisterIntegerPref(prefs::kPrintingAllowedBackgroundGraphicsModes,
0);
registry->RegisterIntegerPref(prefs::kPrintingBackgroundGraphicsDefault, 0);
registry->RegisterDictionaryPref(prefs::kPrintingPaperSizeDefault);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
registry->RegisterIntegerPref(prefs::kPrintingAllowedColorModes, 0);
registry->RegisterIntegerPref(prefs::kPrintingAllowedDuplexModes, 0);
registry->RegisterIntegerPref(prefs::kPrintingAllowedPinModes, 0);
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 4064cb61edd..5beb6ac1f57 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
@@ -24,6 +24,8 @@
#include "base/memory/ref_counted_memory.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
+#include "chrome/browser/account_manager_facade_factory.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/bad_message.h"
#include "chrome/browser/browser_process.h"
@@ -53,12 +55,12 @@
#include "chrome/common/cloud_print/cloud_print_constants.h"
#include "chrome/common/crash_keys.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/printing/printer_capabilities.h"
#include "chrome/common/webui_url_constants.h"
#include "components/cloud_devices/common/cloud_device_description.h"
#include "components/cloud_devices/common/cloud_devices_urls.h"
#include "components/cloud_devices/common/printer_description.h"
#include "components/prefs/pref_service.h"
-#include "components/printing/browser/printer_capabilities.h"
#include "components/printing/common/cloud_print_cdd_conversion.h"
#include "components/signin/public/identity_manager/accounts_in_cookie_jar_info.h"
#include "components/signin/public/identity_manager/primary_account_access_token_fetcher.h"
@@ -78,17 +80,14 @@
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/icu/source/i18n/unicode/ulocdata.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/account_manager/account_manager_util.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/constants/ash_features.h"
+#include "chrome/browser/ash/account_manager/account_manager_util.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
-#include "chrome/browser/device_identity/device_oauth2_token_service.h"
-#include "chrome/browser/device_identity/device_oauth2_token_service_factory.h"
#include "chrome/browser/ui/settings_window_manager_chromeos.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h"
-#include "chromeos/constants/chromeos_features.h"
-#include "chromeos/printing/printer_configuration.h"
-#include "components/signin/public/identity_manager/scope_set.h"
+#include "components/account_manager_core/account_manager_facade.h"
#endif
using content::RenderFrameHost;
@@ -177,12 +176,12 @@ const char kCssBackground[] = "cssBackground";
// Name of a dictionary pref holding the policy value for the paper size
// setting.
const char kMediaSize[] = "mediaSize";
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Name of a dictionary field holding policy value for the setting.
const char kValue[] = "value";
// Name of a dictionary pref holding the policy value for the sheets number.
const char kSheets[] = "sheets";
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Name of a dictionary field indicating whether the 'Save to PDF' destination
// is disabled.
const char kPdfPrinterDisabled[] = "pdfPrinterDisabled";
@@ -197,11 +196,11 @@ const char kUserAccounts[] = "userAccounts";
// Print Preview will always send a request to the Google Cloud Print server on
// load, to check the user's sign in state.
const char kSyncAvailable[] = "syncAvailable";
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Name of a dictionary field indicating whether the user's Drive directory is
// mounted.
const char kIsDriveMounted[] = "isDriveMounted";
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Get the print job settings dictionary from |json_str|.
// Returns |base::Value()| on failure.
@@ -226,7 +225,7 @@ UserActionBuckets DetermineUserAction(const base::Value& settings) {
return UserActionBuckets::kOpenInMacPreview;
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (base::FeatureList::IsEnabled(chromeos::features::kPrintSaveToDrive) &&
settings.FindBoolKey(kSettingPrintToGoogleDrive).value_or(false)) {
return UserActionBuckets::kPrintToGoogleDriveCros;
@@ -324,64 +323,20 @@ base::Value GetPolicies(const PrefService& prefs) {
if (!paper_size_policy.DictEmpty())
policies.SetKey(kMediaSize, std::move(paper_size_policy));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (prefs.HasPrefPath(prefs::kPrintingMaxSheetsAllowed)) {
base::Value sheets_policy(base::Value::Type::DICTIONARY);
sheets_policy.SetIntKey(kValue,
prefs.GetInteger(prefs::kPrintingMaxSheetsAllowed));
policies.SetKey(kSheets, std::move(sheets_policy));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return policies;
}
} // namespace
-#if defined(OS_CHROMEOS)
-class PrintPreviewHandler::AccessTokenService
- : public OAuth2AccessTokenManager::Consumer {
- public:
- AccessTokenService() : OAuth2AccessTokenManager::Consumer("print_preview") {}
-
- void RequestToken(base::OnceCallback<void(const std::string&)> callback) {
- // There can only be one pending request at a time. See
- // cloud_print_interface_js.js.
- const signin::ScopeSet scopes{cloud_devices::kCloudPrintAuthScope};
- DCHECK(!device_request_callback_);
-
- DeviceOAuth2TokenService* token_service =
- DeviceOAuth2TokenServiceFactory::Get();
- device_request_ = token_service->StartAccessTokenRequest(scopes, this);
- device_request_callback_ = std::move(callback);
- }
-
- void OnGetTokenSuccess(
- const OAuth2AccessTokenManager::Request* request,
- const OAuth2AccessTokenConsumer::TokenResponse& token_response) override {
- OnServiceResponse(request, token_response.access_token);
- }
-
- void OnGetTokenFailure(const OAuth2AccessTokenManager::Request* request,
- const GoogleServiceAuthError& error) override {
- OnServiceResponse(request, std::string());
- }
-
- private:
- void OnServiceResponse(const OAuth2AccessTokenManager::Request* request,
- const std::string& access_token) {
- DCHECK_EQ(request, device_request_.get());
- std::move(device_request_callback_).Run(access_token);
- device_request_.reset();
- }
-
- std::unique_ptr<OAuth2AccessTokenManager::Request> device_request_;
- base::OnceCallback<void(const std::string&)> device_request_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(AccessTokenService);
-};
-#endif // defined(OS_CHROMEOS)
-
PrintPreviewHandler::PrintPreviewHandler() {
ReportUserActionHistogram(UserActionBuckets::kPreviewStarted);
}
@@ -405,10 +360,6 @@ void PrintPreviewHandler::RegisterMessages() {
"getPrinterCapabilities",
base::BindRepeating(&PrintPreviewHandler::HandleGetPrinterCapabilities,
base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "setupPrinter",
- base::BindRepeating(&PrintPreviewHandler::HandlePrinterSetup,
- base::Unretained(this)));
#if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG)
web_ui()->RegisterMessageCallback(
"showSystemDialog",
@@ -418,12 +369,6 @@ void PrintPreviewHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"signIn", base::BindRepeating(&PrintPreviewHandler::HandleSignin,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
- web_ui()->RegisterMessageCallback(
- "getAccessToken",
- base::BindRepeating(&PrintPreviewHandler::HandleGetAccessToken,
- base::Unretained(this)));
-#endif
web_ui()->RegisterMessageCallback(
"closePrintPreviewDialog",
base::BindRepeating(&PrintPreviewHandler::HandleClosePreviewDialog,
@@ -445,25 +390,9 @@ void PrintPreviewHandler::RegisterMessages() {
base::BindRepeating(&PrintPreviewHandler::HandleGetInitialSettings,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "grantExtensionPrinterAccess",
- base::BindRepeating(
- &PrintPreviewHandler::HandleGrantExtensionPrinterAccess,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
"managePrinters",
base::BindRepeating(&PrintPreviewHandler::HandleManagePrinters,
base::Unretained(this)));
-
-#if defined(OS_CHROMEOS)
- web_ui()->RegisterMessageCallback(
- "getEulaUrl", base::BindRepeating(&PrintPreviewHandler::HandleGetEulaUrl,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "requestPrinterStatus",
- base::BindRepeating(
- &PrintPreviewHandler::HandleRequestPrinterStatusUpdate,
- base::Unretained(this)));
-#endif
}
void PrintPreviewHandler::OnJavascriptAllowed() {
@@ -589,21 +518,6 @@ void PrintPreviewHandler::HandleGetPrinters(const base::ListValue* args) {
weak_factory_.GetWeakPtr(), callback_id));
}
-void PrintPreviewHandler::HandleGrantExtensionPrinterAccess(
- const base::ListValue* args) {
- std::string callback_id;
- std::string printer_id;
- bool ok = args->GetString(0, &callback_id) &&
- args->GetString(1, &printer_id) && !callback_id.empty();
- DCHECK(ok);
-
- PrinterHandler* handler = GetPrinterHandler(PrinterType::kExtension);
- handler->StartGrantPrinterAccess(
- printer_id,
- base::BindOnce(&PrintPreviewHandler::OnGotExtensionPrinterInfo,
- weak_factory_.GetWeakPtr(), callback_id));
-}
-
void PrintPreviewHandler::HandleGetPrinterCapabilities(
const base::ListValue* args) {
std::string callback_id;
@@ -794,36 +708,18 @@ void PrintPreviewHandler::HandleSaveAppState(const base::ListValue* args) {
sticky_settings->SaveInPrefs(GetPrefs());
}
-// |args| is expected to contain a string with representing the callback id
-// followed by a list of arguments the first of which should be the printer id.
-void PrintPreviewHandler::HandlePrinterSetup(const base::ListValue* args) {
- std::string callback_id;
- std::string printer_name;
- if (!args->GetString(0, &callback_id) || !args->GetString(1, &printer_name) ||
- callback_id.empty() || printer_name.empty()) {
- RejectJavascriptCallback(base::Value(callback_id),
- base::Value(printer_name));
- return;
- }
-
- PrinterHandler* handler = GetPrinterHandler(PrinterType::kLocal);
- handler->StartGetCapability(
- printer_name,
- base::BindOnce(&PrintPreviewHandler::SendPrinterSetup,
- weak_factory_.GetWeakPtr(), callback_id, printer_name));
-}
-
void PrintPreviewHandler::HandleSignin(const base::ListValue* /*args*/) {
Profile* profile = Profile::FromWebUI(web_ui());
DCHECK(profile);
-#if defined(OS_CHROMEOS)
- if (chromeos::IsAccountManagerAvailable(profile)) {
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ if (ash::IsAccountManagerAvailable(profile)) {
// Chrome OS Account Manager is enabled on this Profile and hence, all
// account management flows will go through native UIs and not through a
// tabbed browser window.
- chromeos::InlineLoginDialogChromeOS::Show(
- chromeos::InlineLoginDialogChromeOS::Source::kPrintPreviewDialog);
+ ::GetAccountManagerFacade(profile->GetPath().value())
+ ->ShowAddAccountDialog(account_manager::AccountManagerFacade::
+ AccountAdditionSource::kPrintPreviewDialog);
return;
}
#endif
@@ -844,21 +740,6 @@ void PrintPreviewHandler::OnSignInTabClosed() {
FireWebUIListener("check-for-account-update");
}
-#if defined(OS_CHROMEOS)
-void PrintPreviewHandler::HandleGetAccessToken(const base::ListValue* args) {
- std::string callback_id;
-
- bool ok = args->GetString(0, &callback_id) && !callback_id.empty();
- DCHECK(ok);
-
- if (!token_service_)
- token_service_ = std::make_unique<AccessTokenService>();
- token_service_->RequestToken(
- base::BindOnce(&PrintPreviewHandler::SendAccessToken,
- weak_factory_.GetWeakPtr(), callback_id));
-}
-#endif
-
#if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG)
void PrintPreviewHandler::HandleShowSystemDialog(
const base::ListValue* /*args*/) {
@@ -886,20 +767,6 @@ void PrintPreviewHandler::HandleClosePreviewDialog(
regenerate_preview_request_count_);
}
-#if defined(OS_CHROMEOS)
-void PrintPreviewHandler::HandleGetEulaUrl(const base::ListValue* args) {
- CHECK_EQ(2U, args->GetSize());
-
- const std::string& callback_id = args->GetList()[0].GetString();
- const std::string& destination_id = args->GetList()[1].GetString();
-
- PrinterHandler* handler = GetPrinterHandler(PrinterType::kLocal);
- handler->StartGetEulaUrl(
- destination_id, base::BindOnce(&PrintPreviewHandler::SendEulaUrl,
- weak_factory_.GetWeakPtr(), callback_id));
-}
-#endif
-
void PrintPreviewHandler::GetLocaleInformation(base::Value* settings) {
// Getting the measurement system based on the locale.
UErrorCode errorCode = U_ZERO_ERROR;
@@ -1020,7 +887,7 @@ void PrintPreviewHandler::SendInitialSettings(
GetUserAccountList(&initial_settings);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (base::FeatureList::IsEnabled(chromeos::features::kPrintSaveToDrive)) {
drive::DriveIntegrationService* drive_service =
drive::DriveIntegrationServiceFactory::GetForProfile(
@@ -1028,7 +895,7 @@ void PrintPreviewHandler::SendInitialSettings(
initial_settings.SetBoolKey(kIsDriveMounted,
drive_service && drive_service->IsMounted());
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
ResolveJavascriptCallback(base::Value(callback_id), initial_settings);
}
@@ -1037,21 +904,6 @@ void PrintPreviewHandler::ClosePreviewDialog() {
print_preview_ui()->OnClosePrintPreviewDialog();
}
-#if defined(OS_CHROMEOS)
-void PrintPreviewHandler::SendAccessToken(const std::string& callback_id,
- const std::string& access_token) {
- VLOG(1) << "Get getAccessToken finished";
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(access_token));
-}
-
-void PrintPreviewHandler::SendEulaUrl(const std::string& callback_id,
- const std::string& eula_url) {
- VLOG(1) << "Get PPD license finished";
- ResolveJavascriptCallback(base::Value(callback_id), base::Value(eula_url));
-}
-#endif
-
void PrintPreviewHandler::SendPrinterCapabilities(
const std::string& callback_id,
base::Value settings_info) {
@@ -1068,35 +920,6 @@ void PrintPreviewHandler::SendPrinterCapabilities(
RejectJavascriptCallback(base::Value(callback_id), base::Value());
}
-void PrintPreviewHandler::SendPrinterSetup(const std::string& callback_id,
- const std::string& printer_name,
- base::Value destination_info) {
- base::Value response(base::Value::Type::DICTIONARY);
- base::Value* caps_value =
- destination_info.is_dict()
- ? destination_info.FindKeyOfType(kSettingCapabilities,
- base::Value::Type::DICTIONARY)
- : nullptr;
- response.SetKey("printerId", base::Value(printer_name));
- response.SetKey("success", base::Value(!!caps_value));
- response.SetKey("capabilities",
- caps_value ? std::move(*caps_value)
- : base::Value(base::Value::Type::DICTIONARY));
- if (caps_value) {
- base::Value* printer =
- destination_info.FindKeyOfType(kPrinter, base::Value::Type::DICTIONARY);
- if (printer) {
- base::Value* policies_value = printer->FindKeyOfType(
- kSettingPolicies, base::Value::Type::DICTIONARY);
- if (policies_value)
- response.SetKey("policies", std::move(*policies_value));
- }
- } else {
- LOG(WARNING) << "Printer setup failed";
- }
- ResolveJavascriptCallback(base::Value(callback_id), response);
-}
-
void PrintPreviewHandler::SendCloudPrintJob(
const std::string& callback_id,
const base::RefCountedMemory* data) {
@@ -1259,7 +1082,8 @@ PrinterHandler* PrintPreviewHandler::GetPrinterHandler(
return extension_printer_handler_.get();
}
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
- if (printer_type == PrinterType::kPrivet) {
+ if (printer_type == PrinterType::kPrivet &&
+ GetPrefs()->GetBoolean(prefs::kForceEnablePrivetPrinting)) {
if (!privet_printer_handler_) {
privet_printer_handler_ =
PrinterHandler::CreateForPrivetPrinters(Profile::FromWebUI(web_ui()));
@@ -1309,16 +1133,6 @@ void PrintPreviewHandler::OnGetPrintersDone(const std::string& callback_id) {
ResolveJavascriptCallback(base::Value(callback_id), base::Value());
}
-void PrintPreviewHandler::OnGotExtensionPrinterInfo(
- const std::string& callback_id,
- const base::DictionaryValue& printer_info) {
- if (printer_info.empty()) {
- RejectJavascriptCallback(base::Value(callback_id), base::Value());
- return;
- }
- ResolveJavascriptCallback(base::Value(callback_id), printer_info);
-}
-
void PrintPreviewHandler::OnPrintResult(const std::string& callback_id,
const base::Value& error) {
if (error.is_none())
@@ -1395,29 +1209,8 @@ void PrintPreviewHandler::SendManipulateSettingsForTest(
FireWebUIListener("manipulate-settings-for-test", settings);
}
-#if defined(OS_CHROMEOS)
-void PrintPreviewHandler::HandleRequestPrinterStatusUpdate(
- const base::ListValue* args) {
- CHECK_EQ(2U, args->GetSize());
-
- const std::string& callback_id = args->GetList()[0].GetString();
- const std::string& printer_id = args->GetList()[1].GetString();
-
- PrinterHandler* handler = GetPrinterHandler(PrinterType::kLocal);
- handler->StartPrinterStatusRequest(
- printer_id, base::BindOnce(&PrintPreviewHandler::OnPrinterStatusUpdated,
- weak_factory_.GetWeakPtr(), callback_id));
-}
-
-void PrintPreviewHandler::OnPrinterStatusUpdated(
- const std::string& callback_id,
- const base::Value& cups_printer_status) {
- ResolveJavascriptCallback(base::Value(callback_id), cups_printer_status);
-}
-#endif
-
void PrintPreviewHandler::HandleManagePrinters(const base::ListValue* args) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
chrome::SettingsWindowManager::GetInstance()->ShowOSSettings(
Profile::FromWebUI(web_ui()),
chromeos::settings::mojom::kPrintingDetailsSubpagePath);
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 dd538d6c784..93d41f6e69b 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
@@ -16,6 +16,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/common/buildflags.h"
#include "components/prefs/pref_service.h"
#include "components/printing/common/print.mojom.h"
@@ -112,9 +113,10 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// Fires the 'manipulate-settings-for-test' WebUI event with |settings|.
void SendManipulateSettingsForTest(const base::DictionaryValue& settings);
+ virtual PrinterHandler* GetPrinterHandler(PrinterType printer_type);
+
protected:
// Protected so unit tests can override.
- virtual PrinterHandler* GetPrinterHandler(PrinterType printer_type);
virtual bool IsCloudPrintEnabled();
// Shuts down the initiator renderer. Called when a bad IPC message is
@@ -146,10 +148,6 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerFailingTest,
GetPrinterCapabilities);
-#if defined(OS_CHROMEOS)
- class AccessTokenService;
-#endif
-
content::WebContents* preview_web_contents() const;
PrintPreviewUI* print_preview_ui() const;
@@ -176,10 +174,6 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// callback, second element of |args| is the printer type to fetch.
void HandleGetPrinters(const base::ListValue* args);
- // Grants an extension access to a provisional printer. First element of
- // |args| is the provisional printer ID.
- void HandleGrantExtensionPrinterAccess(const base::ListValue* args);
-
// Asks the initiator renderer to generate a preview. First element of |args|
// is a job settings JSON string.
void HandleGetPreview(const base::ListValue* args);
@@ -205,9 +199,6 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// printer whose capabilities are requested.
void HandleGetPrinterCapabilities(const base::ListValue* args);
- // Performs printer setup. First element of |args| is the printer name.
- void HandlePrinterSetup(const base::ListValue* args);
-
#if BUILDFLAG(ENABLE_BASIC_PRINT_DIALOG)
// Asks the initiator renderer to show the native print system dialog. |args|
// is unused.
@@ -221,11 +212,6 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// Called when the tab opened by HandleSignIn() is closed.
void OnSignInTabClosed();
-#if defined(OS_CHROMEOS)
- // Generates new token and sends back to UI.
- void HandleGetAccessToken(const base::ListValue* args);
-#endif
-
// Gathers UMA stats when the print preview dialog is about to close.
// |args| is unused.
void HandleClosePreviewDialog(const base::ListValue* args);
@@ -238,35 +224,15 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// dialog. |args| is unused.
void HandleManagePrinters(const base::ListValue* args);
-#if defined(OS_CHROMEOS)
- // Gets the EULA URL.
- void HandleGetEulaUrl(const base::ListValue* args);
-#endif
-
void SendInitialSettings(const std::string& callback_id,
const std::string& default_printer);
-#if defined(OS_CHROMEOS)
- // Send OAuth2 access token.
- void SendAccessToken(const std::string& callback_id,
- const std::string& access_token);
-
- // Send the EULA URL;
- void SendEulaUrl(const std::string& callback_id, const std::string& eula_url);
-#endif
-
// Sends the printer capabilities to the Web UI. |settings_info| contains
// printer capabilities information. If |settings_info| is empty, sends
// error notification to the Web UI instead.
void SendPrinterCapabilities(const std::string& callback_id,
base::Value settings_info);
- // Send the result of performing printer setup. |settings_info| contains
- // printer capabilities.
- void SendPrinterSetup(const std::string& callback_id,
- const std::string& printer_name,
- base::Value settings_info);
-
// Send the PDF data to Print Preview so that it can be sent to the cloud
// print server to print.
void SendCloudPrintJob(const std::string& callback_id,
@@ -297,13 +263,6 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// |callback_id|: The javascript callback to call.
void OnGetPrintersDone(const std::string& callback_id);
- // Called when an extension reports information requested for a provisional
- // printer.
- // |callback_id|: The javascript callback to resolve or reject.
- // |printer_info|: The data reported by the extension.
- void OnGotExtensionPrinterInfo(const std::string& callback_id,
- const base::DictionaryValue& printer_info);
-
// Called when an extension or privet print job is completed.
// |callback_id|: The javascript callback to run.
// |error|: The returned print job error. Useful for reporting a specific
@@ -311,15 +270,6 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
void OnPrintResult(const std::string& callback_id,
const base::Value& error);
-#if defined(OS_CHROMEOS)
- // Called to initiate a status request for a printer.
- void HandleRequestPrinterStatusUpdate(const base::ListValue* args);
-
- // Resolves callback with printer status.
- void OnPrinterStatusUpdated(const std::string& callback_id,
- const base::Value& cups_printer_status);
-#endif
-
// A count of how many requests received to regenerate preview data.
// Initialized to 0 then incremented and emitted to a histogram.
int regenerate_preview_request_count_ = 0;
@@ -336,11 +286,6 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// The settings used for the most recent preview request.
base::Value last_preview_settings_;
-#if defined(OS_CHROMEOS)
- // Holds token service to get OAuth2 access tokens.
- std::unique_ptr<AccessTokenService> token_service_;
-#endif
-
// Pointer to the identity manager service so that print preview can listen
// for GAIA cookie changes.
signin::IdentityManager* identity_manager_ = nullptr;
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
new file mode 100644
index 00000000000..bdaa69da7be
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.cc
@@ -0,0 +1,379 @@
+// 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/print_preview/print_preview_handler_chromeos.h"
+
+#include <ctype.h>
+#include <stddef.h>
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "ash/constants/ash_features.h"
+#include "base/bind.h"
+#include "base/callback_helpers.h"
+#include "base/lazy_instance.h"
+#include "base/values.h"
+#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
+#include "chrome/browser/ash/account_manager/account_manager_util.h"
+#include "chrome/browser/chromeos/drive/drive_integration_service.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager_factory.h"
+#include "chrome/browser/device_identity/device_oauth2_token_service.h"
+#include "chrome/browser/device_identity/device_oauth2_token_service_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
+#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
+#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
+#include "chrome/common/printing/printer_capabilities.h"
+#include "chromeos/printing/printer_configuration.h"
+#include "components/cloud_devices/common/cloud_devices_urls.h"
+#include "components/signin/public/identity_manager/scope_set.h"
+#include "content/public/browser/web_ui.h"
+
+namespace printing {
+
+namespace {
+
+using chromeos::CupsPrintersManager;
+using chromeos::CupsPrintersManagerFactory;
+
+base::Value ConvertPrintServersConfig(
+ const chromeos::PrintServersConfig& config) {
+ base::Value ui_print_servers(base::Value::Type::LIST);
+ for (const auto& print_server : config.print_servers) {
+ base::Value ui_print_server(base::Value::Type::DICTIONARY);
+ ui_print_server.SetStringKey("id", print_server.GetId());
+ ui_print_server.SetStringKey("name", print_server.GetName());
+ 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(
+ "isSingleServerFetchingMode",
+ config.fetching_mode ==
+ chromeos::ServerPrintersFetchingMode::kSingleServerOnly);
+ return ui_print_servers_config;
+}
+
+} // namespace
+
+class PrintPreviewHandlerChromeOS::AccessTokenService
+ : public OAuth2AccessTokenManager::Consumer {
+ public:
+ AccessTokenService() : OAuth2AccessTokenManager::Consumer("print_preview") {}
+
+ void RequestToken(base::OnceCallback<void(const std::string&)> callback) {
+ // There can only be one pending request at a time. See
+ // cloud_print_interface_js.js.
+ const signin::ScopeSet scopes{cloud_devices::kCloudPrintAuthScope};
+ DCHECK(!device_request_callback_);
+
+ DeviceOAuth2TokenService* token_service =
+ DeviceOAuth2TokenServiceFactory::Get();
+ device_request_ = token_service->StartAccessTokenRequest(scopes, this);
+ device_request_callback_ = std::move(callback);
+ }
+
+ void OnGetTokenSuccess(
+ const OAuth2AccessTokenManager::Request* request,
+ const OAuth2AccessTokenConsumer::TokenResponse& token_response) override {
+ OnServiceResponse(request, token_response.access_token);
+ }
+
+ void OnGetTokenFailure(const OAuth2AccessTokenManager::Request* request,
+ const GoogleServiceAuthError& error) override {
+ OnServiceResponse(request, std::string());
+ }
+
+ private:
+ void OnServiceResponse(const OAuth2AccessTokenManager::Request* request,
+ const std::string& access_token) {
+ DCHECK_EQ(request, device_request_.get());
+ std::move(device_request_callback_).Run(access_token);
+ device_request_.reset();
+ }
+
+ std::unique_ptr<OAuth2AccessTokenManager::Request> device_request_;
+ base::OnceCallback<void(const std::string&)> device_request_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(AccessTokenService);
+};
+
+PrintPreviewHandlerChromeOS::PrintPreviewHandlerChromeOS() {}
+
+PrintPreviewHandlerChromeOS::~PrintPreviewHandlerChromeOS() {
+ if (!base::FeatureList::IsEnabled(chromeos::features::kPrintServerScaling)) {
+ return;
+ }
+ Profile* profile = Profile::FromWebUI(web_ui());
+ auto* cups_manager =
+ CupsPrintersManagerFactory::GetForBrowserContext(profile);
+ if (cups_manager) {
+ auto* print_servers_manager = cups_manager->GetPrintServersManager();
+ print_servers_manager->RemoveObserver(this);
+ }
+}
+
+void PrintPreviewHandlerChromeOS::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "setupPrinter",
+ base::BindRepeating(&PrintPreviewHandlerChromeOS::HandlePrinterSetup,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getAccessToken",
+ base::BindRepeating(&PrintPreviewHandlerChromeOS::HandleGetAccessToken,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "grantExtensionPrinterAccess",
+ base::BindRepeating(
+ &PrintPreviewHandlerChromeOS::HandleGrantExtensionPrinterAccess,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getEulaUrl",
+ base::BindRepeating(&PrintPreviewHandlerChromeOS::HandleGetEulaUrl,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "requestPrinterStatus",
+ base::BindRepeating(
+ &PrintPreviewHandlerChromeOS::HandleRequestPrinterStatusUpdate,
+ base::Unretained(this)));
+ if (base::FeatureList::IsEnabled(chromeos::features::kPrintServerScaling)) {
+ web_ui()->RegisterMessageCallback(
+ "choosePrintServers",
+ base::BindRepeating(
+ &PrintPreviewHandlerChromeOS::HandleChoosePrintServers,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getPrintServersConfig",
+ base::BindRepeating(
+ &PrintPreviewHandlerChromeOS::HandleGetPrintServersConfig,
+ base::Unretained(this)));
+ }
+}
+
+void PrintPreviewHandlerChromeOS::OnJavascriptAllowed() {
+ if (base::FeatureList::IsEnabled(chromeos::features::kPrintServerScaling)) {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ print_servers_manager_ =
+ CupsPrintersManagerFactory::GetForBrowserContext(profile)
+ ->GetPrintServersManager();
+ print_servers_manager_->AddObserver(this);
+ }
+}
+
+void PrintPreviewHandlerChromeOS::OnJavascriptDisallowed() {
+ // Normally the handler and print preview will be destroyed together, but
+ // this is necessary for refresh or navigation from the chrome://print page.
+ weak_factory_.InvalidateWeakPtrs();
+ if (base::FeatureList::IsEnabled(chromeos::features::kPrintServerScaling)) {
+ print_servers_manager_->RemoveObserver(this);
+ }
+}
+
+void PrintPreviewHandlerChromeOS::HandleGrantExtensionPrinterAccess(
+ const base::ListValue* args) {
+ std::string callback_id;
+ std::string printer_id;
+ bool ok = args->GetString(0, &callback_id) &&
+ args->GetString(1, &printer_id) && !callback_id.empty();
+ DCHECK(ok);
+ MaybeAllowJavascript();
+
+ PrinterHandler* handler = GetPrinterHandler(PrinterType::kExtension);
+ handler->StartGrantPrinterAccess(
+ printer_id,
+ base::BindOnce(&PrintPreviewHandlerChromeOS::OnGotExtensionPrinterInfo,
+ weak_factory_.GetWeakPtr(), callback_id));
+}
+
+// |args| is expected to contain a string with representing the callback id
+// followed by a list of arguments the first of which should be the printer id.
+void PrintPreviewHandlerChromeOS::HandlePrinterSetup(
+ const base::ListValue* args) {
+ std::string callback_id;
+ std::string printer_name;
+ MaybeAllowJavascript();
+ if (!args->GetString(0, &callback_id) || !args->GetString(1, &printer_name) ||
+ callback_id.empty() || printer_name.empty()) {
+ RejectJavascriptCallback(base::Value(callback_id),
+ base::Value(printer_name));
+ return;
+ }
+
+ PrinterHandler* handler = GetPrinterHandler(PrinterType::kLocal);
+ handler->StartGetCapability(
+ printer_name,
+ base::BindOnce(&PrintPreviewHandlerChromeOS::SendPrinterSetup,
+ weak_factory_.GetWeakPtr(), callback_id, printer_name));
+}
+
+void PrintPreviewHandlerChromeOS::HandleGetAccessToken(
+ const base::ListValue* args) {
+ std::string callback_id;
+
+ bool ok = args->GetString(0, &callback_id) && !callback_id.empty();
+ DCHECK(ok);
+ MaybeAllowJavascript();
+
+ if (!token_service_)
+ token_service_ = std::make_unique<AccessTokenService>();
+ token_service_->RequestToken(
+ base::BindOnce(&PrintPreviewHandlerChromeOS::SendAccessToken,
+ weak_factory_.GetWeakPtr(), callback_id));
+}
+
+void PrintPreviewHandlerChromeOS::HandleGetEulaUrl(
+ const base::ListValue* args) {
+ CHECK_EQ(2U, args->GetSize());
+ MaybeAllowJavascript();
+
+ const std::string& callback_id = args->GetList()[0].GetString();
+ const std::string& destination_id = args->GetList()[1].GetString();
+
+ PrinterHandler* handler = GetPrinterHandler(PrinterType::kLocal);
+ handler->StartGetEulaUrl(
+ destination_id, base::BindOnce(&PrintPreviewHandlerChromeOS::SendEulaUrl,
+ weak_factory_.GetWeakPtr(), callback_id));
+}
+
+void PrintPreviewHandlerChromeOS::SendAccessToken(
+ const std::string& callback_id,
+ const std::string& access_token) {
+ VLOG(1) << "Get getAccessToken finished";
+ ResolveJavascriptCallback(base::Value(callback_id),
+ base::Value(access_token));
+}
+
+void PrintPreviewHandlerChromeOS::SendEulaUrl(const std::string& callback_id,
+ const std::string& eula_url) {
+ VLOG(1) << "Get PPD license finished";
+ ResolveJavascriptCallback(base::Value(callback_id), base::Value(eula_url));
+}
+
+void PrintPreviewHandlerChromeOS::SendPrinterSetup(
+ const std::string& callback_id,
+ const std::string& printer_name,
+ base::Value destination_info) {
+ base::Value response(base::Value::Type::DICTIONARY);
+ base::Value* caps_value =
+ destination_info.is_dict()
+ ? destination_info.FindKeyOfType(kSettingCapabilities,
+ base::Value::Type::DICTIONARY)
+ : nullptr;
+ response.SetKey("printerId", base::Value(printer_name));
+ response.SetKey("success", base::Value(!!caps_value));
+ response.SetKey("capabilities",
+ caps_value ? std::move(*caps_value)
+ : base::Value(base::Value::Type::DICTIONARY));
+ if (caps_value) {
+ base::Value* printer =
+ destination_info.FindKeyOfType(kPrinter, base::Value::Type::DICTIONARY);
+ if (printer) {
+ base::Value* policies_value = printer->FindKeyOfType(
+ kSettingPolicies, base::Value::Type::DICTIONARY);
+ if (policies_value)
+ response.SetKey("policies", std::move(*policies_value));
+ }
+ } else {
+ LOG(WARNING) << "Printer setup failed";
+ }
+ ResolveJavascriptCallback(base::Value(callback_id), response);
+}
+
+PrintPreviewHandler* PrintPreviewHandlerChromeOS::GetPrintPreviewHandler() {
+ PrintPreviewUI* ui = static_cast<PrintPreviewUI*>(web_ui()->GetController());
+ return ui->handler();
+}
+
+PrinterHandler* PrintPreviewHandlerChromeOS::GetPrinterHandler(
+ PrinterType printer_type) {
+ return GetPrintPreviewHandler()->GetPrinterHandler(printer_type);
+}
+
+void PrintPreviewHandlerChromeOS::MaybeAllowJavascript() {
+ if (!IsJavascriptAllowed() &&
+ GetPrintPreviewHandler()->IsJavascriptAllowed()) {
+ AllowJavascript();
+ }
+}
+
+void PrintPreviewHandlerChromeOS::OnGotExtensionPrinterInfo(
+ const std::string& callback_id,
+ const base::DictionaryValue& printer_info) {
+ if (printer_info.empty()) {
+ RejectJavascriptCallback(base::Value(callback_id), base::Value());
+ return;
+ }
+ ResolveJavascriptCallback(base::Value(callback_id), printer_info);
+}
+
+void PrintPreviewHandlerChromeOS::HandleRequestPrinterStatusUpdate(
+ const base::ListValue* args) {
+ CHECK_EQ(2U, args->GetSize());
+
+ const std::string& callback_id = args->GetList()[0].GetString();
+ const std::string& printer_id = args->GetList()[1].GetString();
+
+ MaybeAllowJavascript();
+ PrinterHandler* handler = GetPrinterHandler(PrinterType::kLocal);
+ handler->StartPrinterStatusRequest(
+ printer_id,
+ base::BindOnce(&PrintPreviewHandlerChromeOS::OnPrinterStatusUpdated,
+ weak_factory_.GetWeakPtr(), callback_id));
+}
+
+void PrintPreviewHandlerChromeOS::OnPrinterStatusUpdated(
+ const std::string& callback_id,
+ const base::Value& cups_printer_status) {
+ ResolveJavascriptCallback(base::Value(callback_id), cups_printer_status);
+}
+
+void PrintPreviewHandlerChromeOS::HandleChoosePrintServers(
+ const base::ListValue* args) {
+ CHECK_EQ(1U, args->GetSize());
+
+ const base::Value& val = args->GetList()[0];
+ std::vector<std::string> print_server_ids;
+ for (const auto& id : val.GetList()) {
+ print_server_ids.push_back(id.GetString());
+ }
+ MaybeAllowJavascript();
+ FireWebUIListener("server-printers-loading", base::Value(true));
+ print_servers_manager_->ChoosePrintServer(print_server_ids);
+}
+
+void PrintPreviewHandlerChromeOS::HandleGetPrintServersConfig(
+ const base::ListValue* args) {
+ std::string callback_id;
+ CHECK(args->GetString(0, &callback_id));
+ CHECK(!callback_id.empty());
+
+ const chromeos::PrintServersConfig print_servers_config =
+ print_servers_manager_->GetPrintServersConfig();
+ base::Value ui_print_servers_config =
+ ConvertPrintServersConfig(print_servers_config);
+ ResolveJavascriptCallback(base::Value(callback_id), ui_print_servers_config);
+}
+
+void PrintPreviewHandlerChromeOS::OnPrintServersChanged(
+ const chromeos::PrintServersConfig& config) {
+ if (base::FeatureList::IsEnabled(chromeos::features::kPrintServerScaling)) {
+ base::Value ui_print_servers_config = ConvertPrintServersConfig(config);
+ MaybeAllowJavascript();
+ FireWebUIListener("print-servers-config-changed", ui_print_servers_config);
+ }
+}
+
+void PrintPreviewHandlerChromeOS::OnServerPrintersChanged(
+ const std::vector<chromeos::PrinterDetector::DetectedPrinter>& printers) {
+ if (base::FeatureList::IsEnabled(chromeos::features::kPrintServerScaling)) {
+ MaybeAllowJavascript();
+ FireWebUIListener("server-printers-loading", base::Value(false));
+ }
+}
+
+} // namespace printing
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
new file mode 100644
index 00000000000..1482994a0a5
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.h
@@ -0,0 +1,125 @@
+// 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_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_CHROMEOS_H_
+#define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_CHROMEOS_H_
+
+#include <memory>
+#include <string>
+
+#include "base/gtest_prod_util.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/timer/timer.h"
+#include "build/chromeos_buildflags.h"
+#include "chrome/browser/chromeos/printing/print_servers_manager.h"
+#include "chrome/common/buildflags.h"
+#include "components/prefs/pref_service.h"
+#include "components/signin/public/identity_manager/identity_manager.h"
+#include "content/public/browser/web_ui_message_handler.h"
+#include "printing/backend/print_backend.h"
+#include "printing/buildflags/buildflags.h"
+#include "printing/print_job_constants.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace printing {
+
+class PrinterHandler;
+class PrintPreviewHandler;
+
+// The handler for Javascript messages related to the print preview dialog.
+class PrintPreviewHandlerChromeOS
+ : public content::WebUIMessageHandler,
+ public chromeos::PrintServersManager::Observer {
+ public:
+ PrintPreviewHandlerChromeOS();
+ ~PrintPreviewHandlerChromeOS() override;
+
+ // WebUIMessageHandler implementation.
+ void RegisterMessages() override;
+ void OnJavascriptDisallowed() override;
+ void OnJavascriptAllowed() override;
+
+ protected:
+ // Protected so unit tests can override.
+ virtual PrinterHandler* GetPrinterHandler(PrinterType printer_type);
+
+ private:
+ class AccessTokenService;
+
+ PrintPreviewHandler* GetPrintPreviewHandler();
+
+ void MaybeAllowJavascript();
+
+ // Grants an extension access to a provisional printer. First element of
+ // |args| is the provisional printer ID.
+ void HandleGrantExtensionPrinterAccess(const base::ListValue* args);
+
+ // Performs printer setup. First element of |args| is the printer name.
+ void HandlePrinterSetup(const base::ListValue* args);
+
+ // Generates new token and sends back to UI.
+ void HandleGetAccessToken(const base::ListValue* args);
+
+ // Gets the EULA URL.
+ void HandleGetEulaUrl(const base::ListValue* args);
+
+ // Send OAuth2 access token.
+ void SendAccessToken(const std::string& callback_id,
+ const std::string& access_token);
+
+ // Send the EULA URL;
+ void SendEulaUrl(const std::string& callback_id, const std::string& eula_url);
+
+ // Send the result of performing printer setup. |settings_info| contains
+ // printer capabilities.
+ void SendPrinterSetup(const std::string& callback_id,
+ const std::string& printer_name,
+ base::Value settings_info);
+
+ // Called when an extension reports information requested for a provisional
+ // printer.
+ // |callback_id|: The javascript callback to resolve or reject.
+ // |printer_info|: The data reported by the extension.
+ void OnGotExtensionPrinterInfo(const std::string& callback_id,
+ const base::DictionaryValue& printer_info);
+
+ // Called to initiate a status request for a printer.
+ void HandleRequestPrinterStatusUpdate(const base::ListValue* args);
+
+ // Resolves callback with printer status.
+ void OnPrinterStatusUpdated(const std::string& callback_id,
+ const base::Value& cups_printer_status);
+
+ // PrintServersManager::Observer implementation
+ void OnPrintServersChanged(
+ const chromeos::PrintServersConfig& config) override;
+ void OnServerPrintersChanged(
+ const std::vector<chromeos::PrinterDetector::DetectedPrinter>& printers)
+ override;
+
+ // Loads printers corresponding to the print server(s). First element of
+ // |args| is the print server IDs.
+ void HandleChoosePrintServers(const base::ListValue* args);
+
+ // Gets the list of print servers and fetching mode.
+ void HandleGetPrintServersConfig(const base::ListValue* args);
+
+ // Holds token service to get OAuth2 access tokens.
+ std::unique_ptr<AccessTokenService> token_service_;
+
+ chromeos::PrintServersManager* print_servers_manager_;
+
+ base::WeakPtrFactory<PrintPreviewHandlerChromeOS> weak_factory_{this};
+
+ DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandlerChromeOS);
+};
+
+} // namespace printing
+
+#endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_CHROMEOS_H_
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
new file mode 100644
index 00000000000..a7769525583
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos_unittest.cc
@@ -0,0 +1,212 @@
+// 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/print_preview/print_preview_handler_chromeos.h"
+
+#include <vector>
+
+#include "ash/constants/ash_features.h"
+#include "base/run_loop.h"
+#include "base/test/bind.h"
+#include "base/test/scoped_feature_list.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager_factory.h"
+#include "chrome/browser/chromeos/printing/printing_stubs.h"
+#include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
+#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
+#include "chrome/test/base/testing_profile.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 "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace printing {
+
+const char kSelectedPrintServerId[] = "selected-print-server-id";
+const char kSelectedPrintServerName[] = "Print Server Name";
+
+class TestPrintServersManager : public chromeos::PrintServersManager {
+ public:
+ void AddObserver(Observer* observer) override { observer_ = observer; }
+
+ void RemoveObserver(Observer* observer) override { observer_ = nullptr; }
+
+ void ChoosePrintServer(
+ const std::vector<std::string>& selected_print_server_ids) override {
+ selected_print_server_ids_ = selected_print_server_ids;
+ }
+
+ chromeos::PrintServersConfig GetPrintServersConfig() const override {
+ return print_servers_config_;
+ }
+
+ void ChangePrintServersConfig(const chromeos::PrintServersConfig& config) {
+ print_servers_config_ = config;
+ observer_->OnPrintServersChanged(config);
+ }
+
+ virtual void ChangeServerPrinters(
+ const std::vector<chromeos::PrinterDetector::DetectedPrinter>& printers) {
+ observer_->OnServerPrintersChanged(printers);
+ }
+
+ std::vector<std::string> selected_print_server_ids() {
+ return selected_print_server_ids_;
+ }
+
+ Observer* observer_;
+ std::vector<std::string> selected_print_server_ids_;
+ chromeos::PrintServersConfig print_servers_config_;
+};
+
+class TestCupsPrintersManager : public chromeos::StubCupsPrintersManager {
+ public:
+ explicit TestCupsPrintersManager(
+ chromeos::PrintServersManager* print_servers_manager)
+ : print_servers_manager_(print_servers_manager) {}
+
+ chromeos::PrintServersManager* GetPrintServersManager() const override {
+ return print_servers_manager_;
+ }
+
+ private:
+ chromeos::PrintServersManager* print_servers_manager_;
+};
+
+class FakePrintPreviewUI : public PrintPreviewUI {
+ public:
+ FakePrintPreviewUI(content::WebUI* web_ui,
+ std::unique_ptr<PrintPreviewHandler> handler)
+ : PrintPreviewUI(web_ui, std::move(handler)) {}
+
+ ~FakePrintPreviewUI() override = default;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FakePrintPreviewUI);
+};
+
+class PrintPreviewHandlerChromeOSTest : public testing::Test {
+ public:
+ PrintPreviewHandlerChromeOSTest() = default;
+ ~PrintPreviewHandlerChromeOSTest() override = default;
+
+ void SetUp() override {
+ scoped_feature_list_.InitWithFeatures(
+ {chromeos::features::kPrintServerScaling}, {});
+ TestingProfile::Builder builder;
+ profile_ = builder.Build();
+
+ chromeos::CupsPrintersManagerFactory::GetInstance()
+ ->SetTestingFactoryAndUse(
+ profile_.get(),
+ base::BindLambdaForTesting([this](content::BrowserContext* context)
+ -> std::unique_ptr<KeyedService> {
+ print_servers_manager_ =
+ std::make_unique<TestPrintServersManager>();
+ return std::make_unique<TestCupsPrintersManager>(
+ print_servers_manager_.get());
+ }));
+
+ preview_web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(profile_.get()));
+ web_ui_ = std::make_unique<content::TestWebUI>();
+ web_ui_->set_web_contents(preview_web_contents_.get());
+
+ auto preview_handler = std::make_unique<PrintPreviewHandlerChromeOS>();
+ handler_ = preview_handler.get();
+ web_ui()->AddMessageHandler(std::move(preview_handler));
+ handler_->AllowJavascriptForTesting();
+
+ auto preview_ui = std::make_unique<FakePrintPreviewUI>(
+ web_ui(), std::make_unique<PrintPreviewHandler>());
+ web_ui()->SetController(std::move(preview_ui));
+ }
+
+ void AssertWebUIEventFired(const content::TestWebUI::CallData& data,
+ const std::string& event_id) {
+ EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
+ std::string event_fired;
+ ASSERT_TRUE(data.arg1()->GetAsString(&event_fired));
+ EXPECT_EQ(event_id, event_fired);
+ }
+
+ content::TestWebUI* web_ui() { return web_ui_.get(); }
+ TestPrintServersManager* print_servers_manager() {
+ return print_servers_manager_.get();
+ }
+
+ private:
+ content::BrowserTaskEnvironment task_environment_;
+ base::test::ScopedFeatureList scoped_feature_list_;
+ std::unique_ptr<TestingProfile> profile_;
+ std::unique_ptr<TestPrintServersManager> print_servers_manager_;
+ std::unique_ptr<content::WebContents> preview_web_contents_;
+ std::unique_ptr<content::TestWebUI> web_ui_;
+ PrintPreviewHandlerChromeOS* handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandlerChromeOSTest);
+};
+
+TEST_F(PrintPreviewHandlerChromeOSTest, ChoosePrintServers) {
+ base::Value selected_args(base::Value::Type::LIST);
+ base::Value selected_ids_js(base::Value::Type::LIST);
+ selected_ids_js.Append(kSelectedPrintServerId);
+ selected_args.Append(std::move(selected_ids_js));
+
+ base::Value none_selected_args(base::Value::Type::LIST);
+ base::Value none_selected_js(base::Value::Type::LIST);
+ none_selected_args.Append(std::move(none_selected_js));
+
+ web_ui()->HandleReceivedMessage("choosePrintServers",
+ &base::Value::AsListValue(selected_args));
+ EXPECT_THAT(print_servers_manager()->selected_print_server_ids(),
+ testing::ElementsAre(std::string(kSelectedPrintServerId)));
+
+ web_ui()->HandleReceivedMessage(
+ "choosePrintServers", &base::Value::AsListValue(none_selected_args));
+ EXPECT_THAT(print_servers_manager()->selected_print_server_ids(),
+ testing::IsEmpty());
+
+ AssertWebUIEventFired(*web_ui()->call_data().back(),
+ "server-printers-loading");
+ EXPECT_EQ(web_ui()->call_data().back()->arg2()->GetBool(), true);
+}
+
+TEST_F(PrintPreviewHandlerChromeOSTest, OnPrintServersChanged) {
+ std::vector<chromeos::PrintServer> servers;
+ servers.emplace_back(kSelectedPrintServerId, GURL("http://print-server.com"),
+ kSelectedPrintServerName);
+
+ chromeos::PrintServersConfig config;
+ config.print_servers = servers;
+ config.fetching_mode = chromeos::ServerPrintersFetchingMode::kStandard;
+ print_servers_manager()->ChangePrintServersConfig(config);
+
+ auto* call_data = web_ui()->call_data().back().get();
+ AssertWebUIEventFired(*call_data, "print-servers-config-changed");
+ base::Value::ConstListView printer_list =
+ call_data->arg2()->FindListKey("printServers")->GetList();
+ bool is_single_server_fetching_mode =
+ call_data->arg2()->FindBoolKey("isSingleServerFetchingMode").value();
+
+ ASSERT_EQ(printer_list.size(), 1u);
+ const base::Value& first_printer = printer_list.front();
+ EXPECT_EQ(*first_printer.FindStringKey("id"), kSelectedPrintServerId);
+ EXPECT_EQ(*first_printer.FindStringKey("name"), kSelectedPrintServerName);
+ EXPECT_EQ(is_single_server_fetching_mode, false);
+}
+
+TEST_F(PrintPreviewHandlerChromeOSTest, OnServerPrintersUpdated) {
+ std::vector<chromeos::PrinterDetector::DetectedPrinter> printers;
+
+ print_servers_manager()->ChangeServerPrinters(printers);
+
+ AssertWebUIEventFired(*web_ui()->call_data().back(),
+ "server-printers-loading");
+ EXPECT_EQ(web_ui()->call_data().back()->arg2()->GetBool(), false);
+}
+
+} // namespace printing
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 c38d276926e..0b94314edab 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
@@ -22,6 +22,7 @@
#include "base/test/icu_test_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/printing/print_test_utils.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/ui/webui/print_preview/fake_print_render_frame.h"
@@ -803,14 +804,14 @@ TEST_F(PrintPreviewHandlerTest, InitialSettingsDefaultPaperSizeCustomSize) {
std::move(expected_initial_settings_policy));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(PrintPreviewHandlerTest, InitialSettingsMaxSheetsAllowedPolicy) {
prefs()->SetInteger(prefs::kPrintingMaxSheetsAllowed, 2);
Initialize();
ValidateInitialSettingsValuePolicy(*web_ui()->call_data().back(), "sheets",
base::Value(2));
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(PrintPreviewHandlerTest, GetPrinters) {
Initialize();
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_metrics.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_metrics.cc
index d00cef7992d..303f21d35bf 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_metrics.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_metrics.cc
@@ -11,6 +11,7 @@
#include "base/optional.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "printing/mojom/print.mojom.h"
#include "printing/print_job_constants.h"
#include "printing/print_settings.h"
@@ -171,10 +172,10 @@ void ReportPrintSettingsStats(const base::Value& print_settings,
}
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (print_settings.FindStringKey(kSettingPinValue))
ReportPrintSettingHistogram(PrintSettingsBuckets::kPin);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void ReportRegeneratePreviewRequestCountBeforeCancel(size_t count) {
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
index 1e583ad19d2..0351787fc0e 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
+#include "ash/constants/ash_features.h"
#include "base/base_paths.h"
#include "base/bind.h"
#include "base/containers/flat_map.h"
@@ -28,11 +29,15 @@
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/pdf/pdf_extension_util.h"
#include "chrome/browser/printing/background_printing_manager.h"
+#include "chrome/browser/printing/pdf_nup_converter_client.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_preview_data_service.h"
+#include "chrome/browser/printing/print_preview_dialog_controller.h"
+#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_pages.h"
@@ -47,13 +52,12 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/chromium_strings.h"
-#include "chrome/grit/component_extension_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/print_preview_resources.h"
#include "chrome/grit/print_preview_resources_map.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/prefs/pref_service.h"
-#include "components/printing/common/print_messages.h"
+#include "components/printing/browser/print_composite_client.h"
+#include "components/printing/browser/print_manager_utils.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_task_traits.h"
@@ -62,7 +66,9 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
#include "extensions/common/constants.h"
+#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "printing/mojom/print.mojom.h"
+#include "printing/nup_parameters.h"
#include "printing/print_job_constants.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/l10n/l10n_util.h"
@@ -71,6 +77,10 @@
#include "ui/web_dialogs/web_dialog_delegate.h"
#include "ui/web_dialogs/web_dialog_ui.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ui/webui/print_preview/print_preview_handler_chromeos.h"
+#endif
+
#if !BUILDFLAG(OPTIMIZE_WEBUI)
#include "chrome/browser/ui/webui/managed_ui_handler.h"
#endif
@@ -84,10 +94,17 @@ namespace {
#if defined(OS_MAC)
// U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8
const char kBasicPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29";
-#elif !defined(OS_CHROMEOS)
+#elif !BUILDFLAG(IS_CHROMEOS_ASH)
const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)";
#endif
+constexpr char kInvalidArgsForDidStartPreview[] =
+ "Invalid arguments for DidStartPreview";
+constexpr char kInvalidPageNumberForDidPreviewPage[] =
+ "Invalid page number for DidPreviewPage";
+constexpr char kInvalidPageCountForMetafileReadyForPrinting[] =
+ "Invalid page count for MetafileReadyForPrinting";
+
PrintPreviewUI::TestDelegate* g_test_delegate = nullptr;
void StopWorker(int document_cookie) {
@@ -104,6 +121,22 @@ void StopWorker(int document_cookie) {
}
}
+bool IsValidPageNumber(uint32_t page_number, uint32_t page_count) {
+ return page_number < page_count;
+}
+
+bool ShouldUseCompositor(PrintPreviewUI* print_preview_ui) {
+ return IsOopifEnabled() && print_preview_ui->source_is_modifiable();
+}
+
+WebContents* GetInitiator(content::WebUI* web_ui) {
+ PrintPreviewDialogController* dialog_controller =
+ PrintPreviewDialogController::GetInstance();
+ if (!dialog_controller)
+ return nullptr;
+ return dialog_controller->GetInitiator(web_ui->GetWebContents());
+}
+
// Thread-safe wrapper around a base::flat_map to keep track of mappings from
// PrintPreviewUI IDs to most recent print preview request IDs.
class PrintPreviewRequestIdMapWithLock {
@@ -308,10 +341,14 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
{"selectButton", IDS_PRINT_PREVIEW_BUTTON_SELECT},
{"seeMore", IDS_PRINT_PREVIEW_SEE_MORE},
{"seeMoreDestinationsLabel", IDS_PRINT_PREVIEW_SEE_MORE_DESTINATIONS_LABEL},
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ {"serverSearchBoxPlaceholder",
+ IDS_PRINT_PREVIEW_SERVER_SEARCH_BOX_PLACEHOLDER},
+#endif
{"title", IDS_PRINT_PREVIEW_TITLE},
{"top", IDS_PRINT_PREVIEW_TOP_MARGIN_LABEL},
{"unsupportedCloudPrinter", IDS_PRINT_PREVIEW_UNSUPPORTED_CLOUD_PRINTER},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"configuringFailedText", IDS_PRINT_CONFIGURING_FAILED_TEXT},
{"configuringInProgressText", IDS_PRINT_CONFIGURING_IN_PROGRESS_TEXT},
{"optionPin", IDS_PRINT_PREVIEW_OPTION_PIN},
@@ -341,12 +378,12 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
{"openingPDFInPreview", IDS_PRINT_PREVIEW_OPENING_PDF_IN_PREVIEW_APP},
#endif
};
- AddLocalizedStringsBulk(source, kLocalizedStrings);
+ source->AddLocalizedStrings(kLocalizedStrings);
source->AddString("gcpCertificateErrorLearnMoreURL",
chrome::kCloudPrintCertificateErrorLearnMoreURL);
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
const base::string16 shortcut_text(base::UTF8ToUTF16(kBasicPrintShortcut));
source->AddString("systemDialogOption",
l10n_util::GetStringFUTF16(
@@ -362,7 +399,7 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
}
void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
source->AddBoolean("useSystemDefaultPrinter", false);
#else
bool system_default_printer = profile->GetPrefs()->GetBoolean(
@@ -372,18 +409,14 @@ void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) {
source->AddBoolean("isEnterpriseManaged", webui::IsEnterpriseManaged());
- bool cloud_print_deprecation_warnings_suppressed = true;
- source->AddBoolean("cloudPrintDeprecationWarningsSuppressed",
- cloud_print_deprecation_warnings_suppressed);
-
#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
source->AddBoolean(
"forceEnablePrivetPrinting",
- cloud_print_deprecation_warnings_suppressed ||
+ profile->GetPrefs()->GetBoolean(prefs::kForceEnablePrivetPrinting) ||
base::FeatureList::IsEnabled(features::kForceEnablePrivetPrinting));
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
source->AddBoolean(
"showPrinterStatus",
base::FeatureList::IsEnabled(chromeos::features::kPrinterStatus));
@@ -393,35 +426,13 @@ void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) {
source->AddBoolean(
"printSaveToDrive",
base::FeatureList::IsEnabled(chromeos::features::kPrintSaveToDrive));
+ source->AddBoolean(
+ "printServerScaling",
+ base::FeatureList::IsEnabled(chromeos::features::kPrintServerScaling));
#endif
}
void SetupPrintPreviewPlugin(content::WebUIDataSource* source) {
- static constexpr webui::ResourcePath kPdfResources[] = {
- {"pdf/browser_api.js", IDR_PDF_BROWSER_API_JS},
- {"pdf/constants.js", IDR_PDF_CONSTANTS_JS},
- {"pdf/controller.js", IDR_PDF_CONTROLLER_JS},
- {"pdf/elements/icons.js", IDR_PDF_ICONS_JS},
- {"pdf/elements/shared-vars.js", IDR_PDF_SHARED_VARS_JS},
- {"pdf/elements/viewer-error-screen.js", IDR_PDF_VIEWER_ERROR_SCREEN_JS},
- {"pdf/elements/viewer-zoom-button.js", IDR_PDF_VIEWER_ZOOM_BUTTON_JS},
- {"pdf/elements/viewer-zoom-toolbar.js", IDR_PDF_VIEWER_ZOOM_SELECTOR_JS},
- {"pdf/gesture_detector.js", IDR_PDF_GESTURE_DETECTOR_JS},
- {"pdf/index.css", IDR_PDF_INDEX_CSS},
- {"pdf/main.js", IDR_PDF_MAIN_JS},
- {"pdf/metrics.js", IDR_PDF_METRICS_JS},
- {"pdf/open_pdf_params_parser.js", IDR_PDF_OPEN_PDF_PARAMS_PARSER_JS},
- {"pdf/pdf_scripting_api.js", IDR_PDF_PDF_SCRIPTING_API_JS},
- {"pdf/pdf_viewer_base.js", IDR_PDF_PDF_VIEWER_BASE_JS},
- {"pdf/pdf_viewer_shared_style.js", IDR_PDF_PDF_VIEWER_SHARED_STYLE_JS},
- {"pdf/pdf_viewer_utils.js", IDR_PDF_PDF_VIEWER_UTILS_JS},
- {"pdf/toolbar_manager.js", IDR_PDF_TOOLBAR_MANAGER_JS},
- {"pdf/viewport.js", IDR_PDF_VIEWPORT_JS},
- {"pdf/viewport_scroller.js", IDR_PDF_VIEWPORT_SCROLLER_JS},
- {"pdf/zoom_manager.js", IDR_PDF_ZOOM_MANAGER_JS},
- };
- webui::AddResourcePathsBulk(source, kPdfResources);
-
source->SetRequestFilter(base::BindRepeating(&ShouldHandleRequestCallback),
base::BindRepeating(&HandleRequestCallback));
source->OverrideContentSecurityPolicy(
@@ -436,7 +447,7 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) {
content::WebUIDataSource::Create(chrome::kChromeUIPrintHost);
webui::SetupWebUIDataSource(
source,
- base::make_span(kPrintPreviewResources, kPrintPreviewResourcesSize), "",
+ base::make_span(kPrintPreviewResources, kPrintPreviewResourcesSize),
IDR_PRINT_PREVIEW_PRINT_PREVIEW_HTML);
AddPrintPreviewStrings(source);
SetupPrintPreviewPlugin(source);
@@ -447,6 +458,9 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) {
PrintPreviewHandler* CreatePrintPreviewHandlers(content::WebUI* web_ui) {
auto handler = std::make_unique<PrintPreviewHandler>();
PrintPreviewHandler* handler_ptr = handler.get();
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ web_ui->AddMessageHandler(std::make_unique<PrintPreviewHandlerChromeOS>());
+#endif
web_ui->AddMessageHandler(std::move(handler));
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
@@ -456,7 +470,7 @@ PrintPreviewHandler* CreatePrintPreviewHandlers(content::WebUI* web_ui) {
"printPreviewPageSummaryLabel", IDS_PRINT_PREVIEW_PAGE_SUMMARY_LABEL);
plural_string_handler->AddLocalizedString(
"printPreviewSheetSummaryLabel", IDS_PRINT_PREVIEW_SHEET_SUMMARY_LABEL);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
plural_string_handler->AddLocalizedString(
"sheetsLimitErrorMessage", IDS_PRINT_PREVIEW_SHEETS_LIMIT_ERROR_MESSAGE);
#endif
@@ -564,8 +578,197 @@ void PrintPreviewUI::ClearAllPreviewData() {
PrintPreviewDataService::GetInstance()->RemoveEntry(*id_);
}
-void PrintPreviewUI::SetInitiatorTitle(
- const base::string16& job_title) {
+void PrintPreviewUI::NotifyUIPreviewPageReady(
+ uint32_t page_number,
+ int request_id,
+ scoped_refptr<base::RefCountedMemory> data_bytes) {
+ if (!data_bytes || !data_bytes->size())
+ return;
+
+ // Don't bother notifying the UI if this request has been cancelled already.
+ if (ShouldCancelRequest(id_, request_id))
+ return;
+
+ DCHECK_NE(page_number, kInvalidPageIndex);
+ SetPrintPreviewDataForIndex(base::checked_cast<int>(page_number),
+ std::move(data_bytes));
+
+ if (g_test_delegate)
+ g_test_delegate->DidRenderPreviewPage(web_ui()->GetWebContents());
+ handler_->SendPagePreviewReady(base::checked_cast<int>(page_number), *id_,
+ request_id);
+}
+
+void PrintPreviewUI::NotifyUIPreviewDocumentReady(
+ int request_id,
+ scoped_refptr<base::RefCountedMemory> data_bytes) {
+ if (!data_bytes || !data_bytes->size())
+ return;
+
+ // Don't bother notifying the UI if this request has been cancelled already.
+ if (ShouldCancelRequest(id_, request_id))
+ return;
+
+ if (!initial_preview_start_time_.is_null()) {
+ base::UmaHistogramTimes(
+ "PrintPreview.InitialDisplayTime",
+ base::TimeTicks::Now() - initial_preview_start_time_);
+ initial_preview_start_time_ = base::TimeTicks();
+ }
+
+ SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX,
+ std::move(data_bytes));
+ handler_->OnPrintPreviewReady(*id_, request_id);
+}
+
+void PrintPreviewUI::OnCompositePdfPageDone(
+ uint32_t page_number,
+ int document_cookie,
+ int32_t request_id,
+ mojom::PrintCompositor::Status status,
+ base::ReadOnlySharedMemoryRegion region) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (ShouldCancelRequest(id_, request_id))
+ return;
+
+ if (status != mojom::PrintCompositor::Status::kSuccess) {
+ DLOG(ERROR) << "Compositing pdf failed with error " << status;
+ OnPrintPreviewFailed(request_id);
+ return;
+ }
+
+ if (pages_per_sheet_ == 1) {
+ NotifyUIPreviewPageReady(
+ page_number, request_id,
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(region));
+ } else {
+ AddPdfPageForNupConversion(std::move(region));
+ uint32_t current_page_index = GetPageToNupConvertIndex(page_number);
+ if (current_page_index == kInvalidPageIndex)
+ return;
+
+ if (((current_page_index + 1) % pages_per_sheet_) == 0 ||
+ LastPageComposited(page_number)) {
+ uint32_t new_page_number =
+ base::checked_cast<uint32_t>(current_page_index / pages_per_sheet_);
+ DCHECK_NE(new_page_number, kInvalidPageIndex);
+ std::vector<base::ReadOnlySharedMemoryRegion> pdf_page_regions =
+ TakePagesForNupConvert();
+
+ gfx::Rect printable_rect =
+ PageSetup::GetSymmetricalPrintableArea(page_size(), printable_area());
+ if (printable_rect.IsEmpty())
+ return;
+
+ WebContents* web_contents = GetInitiator(web_ui());
+ if (!web_contents)
+ return;
+
+ auto* client = PdfNupConverterClient::FromWebContents(web_contents);
+ DCHECK(client);
+ client->DoNupPdfConvert(
+ document_cookie, pages_per_sheet_, page_size(), printable_rect,
+ std::move(pdf_page_regions),
+ mojo::WrapCallbackWithDefaultInvokeIfNotRun(
+ base::BindOnce(&PrintPreviewUI::OnNupPdfConvertDone,
+ weak_ptr_factory_.GetWeakPtr(), new_page_number,
+ request_id),
+ mojom::PdfNupConverter::Status::CONVERSION_FAILURE,
+ base::ReadOnlySharedMemoryRegion()));
+ }
+ }
+}
+
+void PrintPreviewUI::OnNupPdfConvertDone(
+ uint32_t page_number,
+ int32_t request_id,
+ mojom::PdfNupConverter::Status status,
+ base::ReadOnlySharedMemoryRegion region) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (status != mojom::PdfNupConverter::Status::SUCCESS) {
+ DLOG(ERROR) << "Nup pdf page conversion failed with error " << status;
+ OnPrintPreviewFailed(request_id);
+ return;
+ }
+
+ NotifyUIPreviewPageReady(
+ page_number, request_id,
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(region));
+}
+
+void PrintPreviewUI::OnCompositeToPdfDone(
+ int document_cookie,
+ int32_t request_id,
+ mojom::PrintCompositor::Status status,
+ base::ReadOnlySharedMemoryRegion region) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (ShouldCancelRequest(id_, request_id))
+ return;
+
+ if (status != mojom::PrintCompositor::Status::kSuccess) {
+ DLOG(ERROR) << "Completion of document to pdf failed with error " << status;
+ OnPrintPreviewFailed(request_id);
+ return;
+ }
+
+ if (pages_per_sheet_ == 1) {
+ NotifyUIPreviewDocumentReady(
+ request_id,
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(region));
+ } else {
+ WebContents* web_contents = GetInitiator(web_ui());
+ if (!web_contents)
+ return;
+
+ auto* client = PdfNupConverterClient::FromWebContents(web_contents);
+ DCHECK(client);
+
+ gfx::Rect printable_rect =
+ PageSetup::GetSymmetricalPrintableArea(page_size_, printable_area_);
+ if (printable_rect.IsEmpty())
+ return;
+
+ client->DoNupPdfDocumentConvert(
+ document_cookie, pages_per_sheet_, page_size_, printable_rect,
+ std::move(region),
+ mojo::WrapCallbackWithDefaultInvokeIfNotRun(
+ base::BindOnce(&PrintPreviewUI::OnNupPdfDocumentConvertDone,
+ weak_ptr_factory_.GetWeakPtr(), request_id),
+ mojom::PdfNupConverter::Status::CONVERSION_FAILURE,
+ base::ReadOnlySharedMemoryRegion()));
+ }
+}
+
+void PrintPreviewUI::OnPrepareForDocumentToPdfDone(
+ int32_t request_id,
+ mojom::PrintCompositor::Status status) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (ShouldCancelRequest(id_, request_id))
+ return;
+
+ if (status != mojom::PrintCompositor::Status::kSuccess)
+ OnPrintPreviewFailed(request_id);
+}
+
+void PrintPreviewUI::OnNupPdfDocumentConvertDone(
+ int32_t request_id,
+ mojom::PdfNupConverter::Status status,
+ base::ReadOnlySharedMemoryRegion region) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (status != mojom::PdfNupConverter::Status::SUCCESS) {
+ DLOG(ERROR) << "Nup pdf document convert failed with error " << status;
+ OnPrintPreviewFailed(request_id);
+ return;
+ }
+ NotifyUIPreviewDocumentReady(
+ request_id,
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(region));
+}
+
+void PrintPreviewUI::SetInitiatorTitle(const base::string16& job_title) {
initiator_title_ = job_title;
}
@@ -597,7 +800,7 @@ void PrintPreviewUI::AddPdfPageForNupConversion(
// static
void PrintPreviewUI::SetInitialParams(
content::WebContents* print_preview_dialog,
- const PrintHostMsg_RequestPrintPreview_Params& params) {
+ const mojom::RequestPrintPreviewParams& params) {
if (!print_preview_dialog || !print_preview_dialog->GetWebUI())
return;
PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
@@ -610,11 +813,15 @@ void PrintPreviewUI::SetInitialParams(
}
// static
-bool PrintPreviewUI::ShouldCancelRequest(const mojom::PreviewIds& ids) {
+bool PrintPreviewUI::ShouldCancelRequest(
+ const base::Optional<int32_t>& preview_ui_id,
+ int request_id) {
+ if (!preview_ui_id)
+ return true;
int current_id = -1;
- if (!g_print_preview_request_id_map.Get().Get(ids.ui_id, &current_id))
+ if (!g_print_preview_request_id_map.Get().Get(*preview_ui_id, &current_id))
return true;
- return ids.request_id != current_id;
+ return request_id != current_id;
}
base::Optional<int32_t> PrintPreviewUI::GetIDForPrintPreviewUI() const {
@@ -656,51 +863,80 @@ void PrintPreviewUI::OnPrintPreviewRequest(int request_id) {
g_print_preview_request_id_map.Get().Set(*id_, request_id);
}
-void PrintPreviewUI::OnDidStartPreview(
- const mojom::DidStartPreviewParams& params,
- int request_id) {
- DCHECK_GT(params.page_count, 0u);
- DCHECK_LE(params.page_count, kMaxPageCount);
- DCHECK(!params.pages_to_render.empty());
+void PrintPreviewUI::DidStartPreview(mojom::DidStartPreviewParamsPtr params,
+ int32_t request_id) {
+ if (params->page_count == 0 || params->page_count > kMaxPageCount ||
+ params->pages_to_render.empty()) {
+ receiver_.ReportBadMessage(kInvalidArgsForDidStartPreview);
+ return;
+ }
- pages_to_render_ = params.pages_to_render;
+ for (uint32_t page_number : params->pages_to_render) {
+ if (!IsValidPageNumber(page_number, params->page_count)) {
+ receiver_.ReportBadMessage(kInvalidArgsForDidStartPreview);
+ return;
+ }
+ }
+
+ if (!printing::NupParameters::IsSupported(params->pages_per_sheet)) {
+ receiver_.ReportBadMessage(kInvalidArgsForDidStartPreview);
+ return;
+ }
+
+ if (params->page_size.IsEmpty()) {
+ receiver_.ReportBadMessage(kInvalidArgsForDidStartPreview);
+ return;
+ }
+
+ pages_to_render_ = params->pages_to_render;
pages_to_render_index_ = 0;
- pages_per_sheet_ = params.pages_per_sheet;
- page_size_ = params.page_size;
+ pages_per_sheet_ = params->pages_per_sheet;
+ page_size_ = params->page_size;
ClearAllPreviewData();
if (g_test_delegate)
- g_test_delegate->DidGetPreviewPageCount(params.page_count);
- handler_->SendPageCountReady(base::checked_cast<int>(params.page_count),
- params.fit_to_page_scaling, request_id);
+ g_test_delegate->DidGetPreviewPageCount(params->page_count);
+ handler_->SendPageCountReady(base::checked_cast<int>(params->page_count),
+ params->fit_to_page_scaling, request_id);
}
-void PrintPreviewUI::OnDidGetDefaultPageLayout(
- const mojom::PageSizeMargins& page_layout,
- const gfx::Rect& printable_area,
+void PrintPreviewUI::DidGetDefaultPageLayout(
+ mojom::PageSizeMarginsPtr page_layout_in_points,
+ const gfx::Rect& printable_area_in_points,
bool has_custom_page_size_style,
- int request_id) {
- if (page_layout.margin_top < 0 || page_layout.margin_left < 0 ||
- page_layout.margin_bottom < 0 || page_layout.margin_right < 0 ||
- page_layout.content_width < 0 || page_layout.content_height < 0 ||
- printable_area.width() <= 0 || printable_area.height() <= 0) {
+ int32_t request_id) {
+ if (printable_area_in_points.width() <= 0 ||
+ printable_area_in_points.height() <= 0) {
NOTREACHED();
return;
}
- // Save printable_area information for N-up conversion.
- printable_area_ = printable_area;
+ // Save printable_area_in_points information for N-up conversion.
+ printable_area_ = printable_area_in_points;
+
+ if (page_layout_in_points->margin_top < 0 ||
+ page_layout_in_points->margin_left < 0 ||
+ page_layout_in_points->margin_bottom < 0 ||
+ page_layout_in_points->margin_right < 0 ||
+ page_layout_in_points->content_width < 0 ||
+ page_layout_in_points->content_height < 0) {
+ // Even though it early returns here, it doesn't block printing the page.
+ return;
+ }
base::DictionaryValue layout;
- layout.SetDouble(kSettingMarginTop, page_layout.margin_top);
- layout.SetDouble(kSettingMarginLeft, page_layout.margin_left);
- layout.SetDouble(kSettingMarginBottom, page_layout.margin_bottom);
- layout.SetDouble(kSettingMarginRight, page_layout.margin_right);
- layout.SetDouble(kSettingContentWidth, page_layout.content_width);
- layout.SetDouble(kSettingContentHeight, page_layout.content_height);
- layout.SetInteger(kSettingPrintableAreaX, printable_area.x());
- layout.SetInteger(kSettingPrintableAreaY, printable_area.y());
- layout.SetInteger(kSettingPrintableAreaWidth, printable_area.width());
- layout.SetInteger(kSettingPrintableAreaHeight, printable_area.height());
+ layout.SetDouble(kSettingMarginTop, page_layout_in_points->margin_top);
+ layout.SetDouble(kSettingMarginLeft, page_layout_in_points->margin_left);
+ layout.SetDouble(kSettingMarginBottom, page_layout_in_points->margin_bottom);
+ layout.SetDouble(kSettingMarginRight, page_layout_in_points->margin_right);
+ layout.SetDouble(kSettingContentWidth, page_layout_in_points->content_width);
+ layout.SetDouble(kSettingContentHeight,
+ page_layout_in_points->content_height);
+ layout.SetInteger(kSettingPrintableAreaX, printable_area_in_points.x());
+ layout.SetInteger(kSettingPrintableAreaY, printable_area_in_points.y());
+ layout.SetInteger(kSettingPrintableAreaWidth,
+ printable_area_in_points.width());
+ layout.SetInteger(kSettingPrintableAreaHeight,
+ printable_area_in_points.height());
handler_->SendPageLayoutReady(layout, has_custom_page_size_style, request_id);
}
@@ -713,36 +949,6 @@ bool PrintPreviewUI::OnPendingPreviewPage(uint32_t page_number) {
return matched;
}
-void PrintPreviewUI::OnDidPreviewPage(
- uint32_t page_number,
- scoped_refptr<base::RefCountedMemory> data,
- int preview_request_id) {
- DCHECK_NE(page_number, kInvalidPageIndex);
-
- SetPrintPreviewDataForIndex(base::checked_cast<int>(page_number),
- std::move(data));
-
- if (g_test_delegate)
- g_test_delegate->DidRenderPreviewPage(web_ui()->GetWebContents());
- handler_->SendPagePreviewReady(base::checked_cast<int>(page_number), *id_,
- preview_request_id);
-}
-
-void PrintPreviewUI::OnPreviewDataIsAvailable(
- scoped_refptr<base::RefCountedMemory> data,
- int preview_request_id) {
- if (!initial_preview_start_time_.is_null()) {
- base::UmaHistogramTimes(
- "PrintPreview.InitialDisplayTime",
- base::TimeTicks::Now() - initial_preview_start_time_);
- initial_preview_start_time_ = base::TimeTicks();
- }
-
- SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX, std::move(data));
-
- handler_->OnPrintPreviewReady(*id_, preview_request_id);
-}
-
void PrintPreviewUI::OnCancelPendingPreviewRequest() {
g_print_preview_request_id_map.Get().Set(*id_, -1);
}
@@ -770,7 +976,6 @@ void PrintPreviewUI::OnHidePreviewDialog() {
}
void PrintPreviewUI::OnClosePrintPreviewDialog() {
- receiver_.reset();
if (dialog_closed_)
return;
dialog_closed_ = true;
@@ -790,6 +995,143 @@ void PrintPreviewUI::SetOptionsFromDocument(
params->duplex, request_id);
}
+void PrintPreviewUI::DidPrepareDocumentForPreview(int32_t document_cookie,
+ int32_t request_id) {
+ // Determine if document composition from individual pages with the print
+ // compositor is the desired configuration. Issue a preparation call to the
+ // PrintCompositeClient if that hasn't been done yet. Otherwise, return early.
+ if (!ShouldUseCompositor(this))
+ return;
+
+ WebContents* web_contents = GetInitiator(web_ui());
+ if (!web_contents)
+ return;
+
+ // For case of print preview, page metafile is used to composite into
+ // the document PDF at same time. Need to indicate that this scenario
+ // is at play for the compositor.
+ auto* client = PrintCompositeClient::FromWebContents(web_contents);
+ DCHECK(client);
+ if (client->GetIsDocumentConcurrentlyComposited(document_cookie))
+ return;
+
+ content::RenderFrameHost* render_frame_host =
+ PrintViewManager::FromWebContents(web_contents)->print_preview_rfh();
+ // |render_frame_host| could be null when the print preview dialog is closed.
+ if (!render_frame_host)
+ return;
+
+ client->DoPrepareForDocumentToPdf(
+ document_cookie, render_frame_host,
+ mojo::WrapCallbackWithDefaultInvokeIfNotRun(
+ base::BindOnce(&PrintPreviewUI::OnPrepareForDocumentToPdfDone,
+ weak_ptr_factory_.GetWeakPtr(), request_id),
+ mojom::PrintCompositor::Status::kCompositingFailure));
+}
+
+void PrintPreviewUI::DidPreviewPage(mojom::DidPreviewPageParamsPtr params,
+ int32_t request_id) {
+ uint32_t page_number = params->page_number;
+ const mojom::DidPrintContentParams& content = *params->content;
+ if (page_number == kInvalidPageIndex ||
+ !content.metafile_data_region.IsValid()) {
+ return;
+ }
+
+ if (!OnPendingPreviewPage(page_number)) {
+ receiver_.ReportBadMessage(kInvalidPageNumberForDidPreviewPage);
+ return;
+ }
+
+ if (ShouldUseCompositor(this)) {
+ // Don't bother compositing if this request has been cancelled already.
+ if (ShouldCancelRequest(id_, request_id))
+ return;
+
+ WebContents* web_contents = GetInitiator(web_ui());
+ if (!web_contents)
+ return;
+
+ auto* client = PrintCompositeClient::FromWebContents(web_contents);
+ DCHECK(client);
+
+ content::RenderFrameHost* render_frame_host =
+ PrintViewManager::FromWebContents(web_contents)->print_preview_rfh();
+ // |render_frame_host| could be null when the print preview dialog is
+ // closed.
+ if (!render_frame_host)
+ return;
+
+ // Use utility process to convert skia metafile to pdf.
+ client->DoCompositePageToPdf(
+ params->document_cookie, render_frame_host, content,
+ mojo::WrapCallbackWithDefaultInvokeIfNotRun(
+ base::BindOnce(&PrintPreviewUI::OnCompositePdfPageDone,
+ weak_ptr_factory_.GetWeakPtr(), page_number,
+ params->document_cookie, request_id),
+ mojom::PrintCompositor::Status::kCompositingFailure,
+ base::ReadOnlySharedMemoryRegion()));
+ } else {
+ NotifyUIPreviewPageReady(
+ page_number, request_id,
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(
+ content.metafile_data_region));
+ }
+}
+
+void PrintPreviewUI::MetafileReadyForPrinting(
+ mojom::DidPreviewDocumentParamsPtr params,
+ int32_t request_id) {
+ // Always try to stop the worker.
+ StopWorker(params->document_cookie);
+
+ const bool composite_document_using_individual_pages =
+ ShouldUseCompositor(this);
+ const base::ReadOnlySharedMemoryRegion& metafile =
+ params->content->metafile_data_region;
+
+ // When the Print Compositor is active, the print document is composed from
+ // the individual pages, so |metafile| should be invalid.
+ // When it is inactive, the print document is composed from |metafile|.
+ // So if this comparison succeeds, that means the renderer sent bad data.
+ if (composite_document_using_individual_pages == metafile.IsValid())
+ return;
+
+ if (params->expected_pages_count == 0) {
+ receiver_.ReportBadMessage(kInvalidPageCountForMetafileReadyForPrinting);
+ return;
+ }
+
+ if (composite_document_using_individual_pages) {
+ // Don't bother compositing if this request has been cancelled already.
+ if (ShouldCancelRequest(id_, request_id))
+ return;
+
+ auto callback = base::BindOnce(&PrintPreviewUI::OnCompositeToPdfDone,
+ weak_ptr_factory_.GetWeakPtr(),
+ params->document_cookie, request_id);
+
+ WebContents* web_contents = GetInitiator(web_ui());
+ if (!web_contents)
+ return;
+
+ // Page metafile is used to composite into the document at same time.
+ // Need to provide particulars of how many pages are required before
+ // document will be completed.
+ auto* client = PrintCompositeClient::FromWebContents(web_contents);
+ client->DoCompleteDocumentToPdf(
+ params->document_cookie, params->expected_pages_count,
+ mojo::WrapCallbackWithDefaultInvokeIfNotRun(
+ std::move(callback),
+ mojom::PrintCompositor::Status::kCompositingFailure,
+ base::ReadOnlySharedMemoryRegion()));
+ } else {
+ NotifyUIPreviewDocumentReady(
+ request_id,
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(metafile));
+ }
+}
+
void PrintPreviewUI::PrintPreviewFailed(int32_t document_cookie,
int32_t request_id) {
StopWorker(document_cookie);
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h
index d0e9b1fc8b1..a131d53bad6 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h
@@ -16,27 +16,24 @@
#include "base/macros.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
+#include "chrome/services/printing/public/mojom/pdf_nup_converter.mojom.h"
#include "components/printing/common/print.mojom.h"
+#include "components/services/print_compositor/public/mojom/print_compositor.mojom.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "printing/mojom/print.mojom-forward.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
-struct PrintHostMsg_RequestPrintPreview_Params;
-
namespace base {
class DictionaryValue;
class FilePath;
class RefCountedMemory;
}
-namespace gfx {
-class Rect;
-}
-
namespace printing {
class PrintPreviewHandler;
@@ -59,11 +56,23 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
// printing::mojo::PrintPreviewUI:
void SetOptionsFromDocument(const mojom::OptionsFromDocumentParamsPtr params,
int32_t request_id) override;
+ void DidPrepareDocumentForPreview(int32_t document_cookie,
+ int32_t request_id) override;
+ void DidPreviewPage(mojom::DidPreviewPageParamsPtr params,
+ int32_t request_id) override;
+ void MetafileReadyForPrinting(mojom::DidPreviewDocumentParamsPtr params,
+ int32_t request_id) override;
void PrintPreviewFailed(int32_t document_cookie, int32_t request_id) override;
void PrintPreviewCancelled(int32_t document_cookie,
int32_t request_id) override;
void PrinterSettingsInvalid(int32_t document_cookie,
int32_t request_id) override;
+ void DidGetDefaultPageLayout(mojom::PageSizeMarginsPtr page_layout_in_points,
+ const gfx::Rect& printable_area_in_points,
+ bool has_custom_page_size_style,
+ int32_t request_id) override;
+ void DidStartPreview(mojom::DidStartPreviewParamsPtr params,
+ int32_t request_id) override;
bool IsBound() const;
@@ -88,6 +97,8 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
const gfx::Size& page_size() const { return page_size_; }
+ PrintPreviewHandler* handler() const { return handler_; }
+
// Returns true if |page_number| is the last page in |pages_to_render_|.
// |page_number| is a 0-based number.
bool LastPageComposited(uint32_t page_number) const;
@@ -124,14 +135,14 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
int* page_index);
// Set initial settings for PrintPreviewUI.
- static void SetInitialParams(
- content::WebContents* print_preview_dialog,
- const PrintHostMsg_RequestPrintPreview_Params& params);
+ static void SetInitialParams(content::WebContents* print_preview_dialog,
+ const mojom::RequestPrintPreviewParams& params);
// Determines whether to cancel a print preview request based on the request
- // and UI ids in |ids|.
+ // id.
// Can be called from any thread.
- static bool ShouldCancelRequest(const mojom::PreviewIds& ids);
+ static bool ShouldCancelRequest(const base::Optional<int32_t>& preview_ui_id,
+ int request_id);
// Returns an id to uniquely identify this PrintPreviewUI.
base::Optional<int32_t> GetIDForPrintPreviewUI() const;
@@ -139,33 +150,11 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
// Notifies the Web UI of a print preview request with |request_id|.
virtual void OnPrintPreviewRequest(int request_id);
- // Notifies the Web UI about the properties of the request preview.
- void OnDidStartPreview(const mojom::DidStartPreviewParams& params,
- int request_id);
-
- // Notifies the Web UI of the default page layout according to the currently
- // selected printer and page size.
- void OnDidGetDefaultPageLayout(const mojom::PageSizeMargins& page_layout,
- const gfx::Rect& printable_area,
- bool has_custom_page_size_style,
- int request_id);
-
// Notifies the Web UI that the 0-based page |page_number| rendering is being
// processed and an OnPendingPreviewPage() call is imminent. Returns whether
// |page_number| is the expected page.
bool OnPendingPreviewPage(uint32_t page_number);
- // Notifies the Web UI that the 0-based page |page_number| has been rendered.
- // |preview_request_id| indicates which request resulted in this response.
- void OnDidPreviewPage(uint32_t page_number,
- scoped_refptr<base::RefCountedMemory> data,
- int preview_request_id);
-
- // Notifies the Web UI renderer that preview data is available.
- // |preview_request_id| indicates which request resulted in this response.
- void OnPreviewDataIsAvailable(scoped_refptr<base::RefCountedMemory> data,
- int preview_request_id);
-
// Notifies the Web UI that the print preview failed to render for the request
// with id = |request_id|.
void OnPrintPreviewFailed(int request_id);
@@ -247,6 +236,39 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
// Clear the existing print preview data.
void ClearAllPreviewData();
+ // Notifies the Web UI that the 0-based page |page_number| has been rendered.
+ // |request_id| indicates which request resulted in this response.
+ void NotifyUIPreviewPageReady(
+ uint32_t page_number,
+ int request_id,
+ scoped_refptr<base::RefCountedMemory> data_bytes);
+
+ // Notifies the Web UI renderer that preview data is available. |request_id|
+ // indicates which request resulted in this response.
+ void NotifyUIPreviewDocumentReady(
+ int request_id,
+ scoped_refptr<base::RefCountedMemory> data_bytes);
+
+ // Callbacks for print compositor client.
+ void OnPrepareForDocumentToPdfDone(int32_t request_id,
+ mojom::PrintCompositor::Status status);
+ void OnCompositePdfPageDone(uint32_t page_number,
+ int32_t document_cookie,
+ int32_t request_id,
+ mojom::PrintCompositor::Status status,
+ base::ReadOnlySharedMemoryRegion region);
+ void OnNupPdfConvertDone(uint32_t page_number,
+ int32_t request_id,
+ mojom::PdfNupConverter::Status status,
+ base::ReadOnlySharedMemoryRegion region);
+ void OnNupPdfDocumentConvertDone(int32_t request_id,
+ mojom::PdfNupConverter::Status status,
+ base::ReadOnlySharedMemoryRegion region);
+ void OnCompositeToPdfDone(int document_cookie,
+ int32_t request_id,
+ mojom::PrintCompositor::Status status,
+ base::ReadOnlySharedMemoryRegion region);
+
base::TimeTicks initial_preview_start_time_;
// The unique ID for this class instance. Stored here to avoid calling
@@ -298,6 +320,8 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
mojo::AssociatedReceiver<mojom::PrintPreviewUI> receiver_{this};
+ base::WeakPtrFactory<PrintPreviewUI> weak_ptr_factory_{this};
+
DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI);
};
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 78e8255f3e7..1052355c78e 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
@@ -4,6 +4,7 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/task_manager/task_manager_browsertest_util.h"
@@ -58,7 +59,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewBrowserTest, PrintCommands) {
ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT));
-#if BUILDFLAG(ENABLE_PRINTING) && !defined(OS_CHROMEOS)
+#if BUILDFLAG(ENABLE_PRINTING) && !BUILDFLAG(IS_CHROMEOS_ASH)
// This is analagous to ENABLE_BASIC_PRINT_DIALOG but helps to verify
// that it is defined as expected.
bool is_basic_print_expected = true;
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
index d09c6609e5c..48c70b6b802 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
@@ -17,7 +17,6 @@
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "components/prefs/pref_service.h"
-#include "components/printing/common/print_messages.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/site_instance.h"
@@ -190,23 +189,26 @@ TEST_F(PrintPreviewUIUnitTest, ShouldCancelRequest) {
ASSERT_TRUE(preview_ui);
preview_ui->SetPreviewUIId();
- // Test with invalid UI ID.
- const int32_t kInvalidId = -5;
- EXPECT_TRUE(preview_ui->ShouldCancelRequest({0, kInvalidId}));
+ // Test the initial state.
+ EXPECT_TRUE(PrintPreviewUI::ShouldCancelRequest(
+ *preview_ui->GetIDForPrintPreviewUI(), 0));
const int kFirstRequestId = 1000;
const int kSecondRequestId = 1001;
- const int32_t preview_id = preview_ui->GetIDForPrintPreviewUI().value();
// Test with kFirstRequestId.
preview_ui->OnPrintPreviewRequest(kFirstRequestId);
- EXPECT_FALSE(preview_ui->ShouldCancelRequest({kFirstRequestId, preview_id}));
- EXPECT_TRUE(preview_ui->ShouldCancelRequest({kSecondRequestId, preview_id}));
+ EXPECT_FALSE(PrintPreviewUI::ShouldCancelRequest(
+ *preview_ui->GetIDForPrintPreviewUI(), kFirstRequestId));
+ EXPECT_TRUE(PrintPreviewUI::ShouldCancelRequest(
+ *preview_ui->GetIDForPrintPreviewUI(), kSecondRequestId));
// Test with kSecondRequestId.
preview_ui->OnPrintPreviewRequest(kSecondRequestId);
- EXPECT_TRUE(preview_ui->ShouldCancelRequest({kFirstRequestId, preview_id}));
- EXPECT_FALSE(preview_ui->ShouldCancelRequest({kSecondRequestId, preview_id}));
+ EXPECT_TRUE(PrintPreviewUI::ShouldCancelRequest(
+ *preview_ui->GetIDForPrintPreviewUI(), kFirstRequestId));
+ EXPECT_FALSE(PrintPreviewUI::ShouldCancelRequest(
+ *preview_ui->GetIDForPrintPreviewUI(), kSecondRequestId));
}
TEST_F(PrintPreviewUIUnitTest, ParseDataPath) {
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 c0bed875af9..24485b73494 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
@@ -10,19 +10,20 @@
#include <vector>
#include "base/bind.h"
+#include "base/containers/contains.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/stl_util.h"
#include "base/strings/string_piece.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
+#include "chrome/common/printing/printer_capabilities.h"
#include "components/crash/core/common/crash_keys.h"
-#include "components/printing/browser/printer_capabilities.h"
#include "content/public/browser/render_frame_host.h"
#include "printing/backend/print_backend_consts.h"
#include "printing/page_range.h"
@@ -56,12 +57,12 @@ void PrintersToValues(const PrinterList& printer_list,
for (const auto& opt_it : printer.options)
options->SetString(opt_it.first, opt_it.second);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
printer_info->SetBoolean(
kCUPSEnterprisePrinter,
base::Contains(printer.options, kCUPSEnterprisePrinter) &&
printer.options.at(kCUPSEnterprisePrinter) == kValueTrue);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
printer_info->Set(kSettingPrinterOptions, std::move(options));
diff --git a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc
index 2b2a95282ee..e29f23e2e04 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
#include "build/buildflag.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/print_preview/extension_printer_handler.h"
#include "chrome/browser/ui/webui/print_preview/pdf_printer_handler.h"
#include "chrome/common/buildflags.h"
@@ -13,7 +14,7 @@
#include "chrome/browser/ui/webui/print_preview/privet_printer_handler.h"
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h"
#else
#include "chrome/browser/ui/webui/print_preview/local_printer_handler_default.h"
@@ -31,7 +32,7 @@ std::unique_ptr<PrinterHandler> PrinterHandler::CreateForExtensionPrinters(
std::unique_ptr<PrinterHandler> PrinterHandler::CreateForLocalPrinters(
content::WebContents* preview_web_contents,
Profile* profile) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
return LocalPrinterHandlerChromeos::CreateDefault(profile,
preview_web_contents);
#else
@@ -65,7 +66,7 @@ void PrinterHandler::StartGrantPrinterAccess(const std::string& printer_id,
NOTREACHED();
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void PrinterHandler::StartGetEulaUrl(const std::string& destination_id,
GetEulaUrlCallback callback) {
NOTREACHED();
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 6fa82c3a521..f9a02da5d0e 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h
@@ -13,6 +13,7 @@
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string16.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/common/buildflags.h"
namespace content {
@@ -49,7 +50,7 @@ class PrinterHandler {
using PrintCallback = base::OnceCallback<void(const base::Value& error)>;
using GetPrinterInfoCallback =
base::OnceCallback<void(const base::DictionaryValue& printer_info)>;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
using GetEulaUrlCallback =
base::OnceCallback<void(const std::string& license)>;
using PrinterStatusRequestCallback =
@@ -117,7 +118,7 @@ class PrinterHandler {
scoped_refptr<base::RefCountedMemory> print_data,
PrintCallback callback) = 0;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Starts getting the printer's PPD EULA URL with the provided destination ID.
// |destination_id|: The ID of the printer.
// |callback| should be called in response to the request.
diff --git a/chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc
index 88a2448b5b4..d9f2085e753 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc
@@ -253,7 +253,8 @@ void PrivetPrinterHandler::StartPrint(
IdentityManagerFactory::GetForProfileIfExists(profile_);
if (identity_manager) {
privet_local_print_operation_->SetUsername(
- identity_manager->GetPrimaryAccountInfo().email);
+ identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
+ .email);
}
privet_local_print_operation_->Start();
diff --git a/chromium/chrome/browser/ui/webui/profile_helper.cc b/chromium/chrome/browser/ui/webui/profile_helper.cc
index e54db3e4957..de437da559b 100644
--- a/chromium/chrome/browser/ui/webui/profile_helper.cc
+++ b/chromium/chrome/browser/ui/webui/profile_helper.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/profile_picker.h"
-#include "chrome/browser/ui/user_manager.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
@@ -26,32 +25,6 @@
namespace webui {
namespace {
-void ShowUserManager(const ProfileManager::CreateCallback& callback) {
- if (!UserManager::IsShowing()) {
- UserManager::Show(base::FilePath(),
- profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
- }
-
- g_browser_process->profile_manager()->CreateProfileAsync(
- ProfileManager::GetSystemProfilePath(), callback, base::string16(),
- std::string());
-}
-
-std::string GetProfileUserName(Profile* profile) {
- ProfileAttributesEntry* entry;
- if (!g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile->GetPath(), &entry))
- return std::string();
- return base::UTF16ToUTF8(entry->GetUserName());
-}
-
-void ShowUnlockDialog(const std::string& user_name,
- Profile* system_profile,
- Profile::CreateStatus status) {
- UserManagerProfileDialog::ShowUnlockDialog(system_profile, user_name);
-}
-
void DeleteProfileCallback(std::unique_ptr<ScopedKeepAlive> keep_alive,
Profile* profile) {
OpenNewWindowForProfile(profile);
@@ -61,17 +34,15 @@ void DeleteProfileCallback(std::unique_ptr<ScopedKeepAlive> keep_alive,
void OpenNewWindowForProfile(Profile* profile) {
if (profiles::IsProfileLocked(profile->GetPath())) {
- // The profile picker does not support locked profiles.
- DCHECK(!ProfilePicker::IsOpen());
-
- if (signin_util::IsForceSigninEnabled()) {
- // If force-sign-in policy is enabled, UserManager will be displayed
- // without any sign-in dialog opened.
- ShowUserManager(ProfileManager::CreateCallback());
- } else {
- ShowUserManager(
- base::BindRepeating(&ShowUnlockDialog, GetProfileUserName(profile)));
+ DCHECK(signin_util::IsForceSigninEnabled());
+ // Displays the ProfilePicker without any sign-in dialog opened.
+ if (!ProfilePicker::IsOpen()) {
+ ProfilePicker::Show(ProfilePicker::EntryPoint::kProfileLocked);
}
+
+ g_browser_process->profile_manager()->CreateProfileAsync(
+ ProfileManager::GetSystemProfilePath(),
+ ProfileManager::CreateCallback(), base::string16(), std::string());
return;
}
diff --git a/chromium/chrome/browser/ui/webui/profile_info_watcher.cc b/chromium/chrome/browser/ui/webui/profile_info_watcher.cc
index 722a7737638..1d661788758 100644
--- a/chromium/chrome/browser/ui/webui/profile_info_watcher.cc
+++ b/chromium/chrome/browser/ui/webui/profile_info_watcher.cc
@@ -15,9 +15,9 @@
#include "components/signin/public/base/signin_pref_names.h"
#include "components/signin/public/identity_manager/identity_manager.h"
-ProfileInfoWatcher::ProfileInfoWatcher(
- Profile* profile, const base::Closure& callback)
- : profile_(profile), callback_(callback) {
+ProfileInfoWatcher::ProfileInfoWatcher(Profile* profile,
+ base::RepeatingClosure callback)
+ : profile_(profile), callback_(std::move(callback)) {
DCHECK(profile_);
DCHECK(!callback_.is_null());
@@ -47,8 +47,11 @@ void ProfileInfoWatcher::OnProfileAuthInfoChanged(
std::string ProfileInfoWatcher::GetAuthenticatedUsername() const {
std::string username;
auto* identity_manager = GetIdentityManager();
- if (identity_manager)
- username = identity_manager->GetPrimaryAccountInfo().email;
+ if (identity_manager) {
+ username =
+ identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
+ .email;
+ }
return username;
}
diff --git a/chromium/chrome/browser/ui/webui/profile_info_watcher.h b/chromium/chrome/browser/ui/webui/profile_info_watcher.h
index 315c68281af..129ed867de6 100644
--- a/chromium/chrome/browser/ui/webui/profile_info_watcher.h
+++ b/chromium/chrome/browser/ui/webui/profile_info_watcher.h
@@ -22,7 +22,7 @@ class IdentityManager;
// username changes).
class ProfileInfoWatcher : public ProfileAttributesStorage::Observer {
public:
- ProfileInfoWatcher(Profile* profile, const base::Closure& callback);
+ ProfileInfoWatcher(Profile* profile, base::RepeatingClosure callback);
~ProfileInfoWatcher() override;
// Gets the authenticated username (e.g. username@gmail.com) for |profile_|.
@@ -43,7 +43,7 @@ class ProfileInfoWatcher : public ProfileAttributesStorage::Observer {
Profile* const profile_;
// Called when the authenticated username changes.
- base::Closure callback_;
+ base::RepeatingClosure callback_;
BooleanPrefMember signin_allowed_pref_;
diff --git a/chromium/chrome/browser/ui/webui/quota_internals/DIR_METADATA b/chromium/chrome/browser/ui/webui/quota_internals/DIR_METADATA
new file mode 100644
index 00000000000..4bba49e42e8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/quota_internals/DIR_METADATA
@@ -0,0 +1,4 @@
+monorail {
+ component: "Blink>Storage>Quota"
+}
+team_email: "storage-dev@chromium.org"
diff --git a/chromium/chrome/browser/ui/webui/quota_internals/OWNERS b/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
index 84d5cb66e1c..a61a7147e9a 100644
--- a/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
@@ -1,4 +1 @@
file://storage/browser/quota/OWNERS
-
-# TEAM: storage-dev@chromium.org
-# COMPONENT: Blink>Storage>Quota
diff --git a/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_ui.cc b/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_ui.cc
index cf90ad733e4..d636b3e5f1e 100644
--- a/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_ui.cc
@@ -26,8 +26,7 @@ content::WebUIDataSource* CreateQuotaInternalsHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIQuotaInternalsHost);
source->UseStringsJs();
- webui::AddResourcePathsBulk(
- source,
+ source->AddResourcePaths(
base::make_span(kQuotaInternalsResources, kQuotaInternalsResourcesSize));
source->AddResourcePath("", IDR_QUOTA_INTERNALS_MAIN_HTML);
source->OverrideContentSecurityPolicy(
diff --git a/chromium/chrome/browser/ui/webui/read_later/DIR_METADATA b/chromium/chrome/browser/ui/webui/read_later/DIR_METADATA
new file mode 100644
index 00000000000..08743222e65
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/read_later/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>ReadLater"
+}
diff --git a/chromium/chrome/browser/ui/webui/read_later/OWNERS b/chromium/chrome/browser/ui/webui/read_later/OWNERS
index b98ff8e9c76..845054fac28 100644
--- a/chromium/chrome/browser/ui/webui/read_later/OWNERS
+++ b/chromium/chrome/browser/ui/webui/read_later/OWNERS
@@ -4,5 +4,3 @@ pbos@chromium.org
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: UI>Browser>ReadLater
diff --git a/chromium/chrome/browser/ui/webui/read_later/read_later.mojom b/chromium/chrome/browser/ui/webui/read_later/read_later.mojom
index 34b514f7c46..9803a5ddc60 100644
--- a/chromium/chrome/browser/ui/webui/read_later/read_later.mojom
+++ b/chromium/chrome/browser/ui/webui/read_later/read_later.mojom
@@ -53,7 +53,8 @@ interface PageHandler {
// WebUI-side handler for requests from the browser.
interface Page {
- // Callback when any item in read later is
- // changed/removed.
- ItemsChanged();
+ // Callback when any item in read later is changed/removed. `entries` is a
+ // collection of all read later entries by read/unread status. This data
+ // structure is always present, even if the read/unread lists are empty.
+ ItemsChanged(ReadLaterEntriesByStatus entries);
};
diff --git a/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.cc b/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.cc
index 2133e643811..d082fa15b26 100644
--- a/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.cc
@@ -18,10 +18,14 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/read_later/reading_list_model_factory.h"
#include "chrome/browser/ui/webui/read_later/read_later_ui.h"
+#include "chrome/common/webui_url_constants.h"
#include "components/reading_list/core/reading_list_entry.h"
#include "components/reading_list/core/reading_list_model.h"
#include "components/url_formatter/url_formatter.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/time_format.h"
+#include "url/gurl.h"
namespace {
@@ -37,63 +41,69 @@ int64_t TimeToUS(const base::Time& time) {
return (time - base::Time::UnixEpoch()).InMicroseconds();
}
+bool IsActiveTabNTP(Browser* browser) {
+ content::WebContents* web_contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ if (web_contents) {
+ const GURL site_origin = web_contents->GetLastCommittedURL().GetOrigin();
+ // These are also the NTP urls checked for showing the bookmark bar on the
+ // NTP.
+ if (site_origin == GURL(chrome::kChromeUINewTabURL).GetOrigin() ||
+ site_origin == GURL(chrome::kChromeUINewTabPageURL).GetOrigin()) {
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace
ReadLaterPageHandler::ReadLaterPageHandler(
mojo::PendingReceiver<read_later::mojom::PageHandler> receiver,
mojo::PendingRemote<read_later::mojom::Page> page,
- ReadLaterUI* read_later_ui)
+ ReadLaterUI* read_later_ui,
+ content::WebUI* web_ui)
: receiver_(this, std::move(receiver)),
page_(std::move(page)),
- browser_(chrome::FindLastActive()),
read_later_ui_(read_later_ui),
clock_(base::DefaultClock::GetInstance()) {
- DCHECK(browser_);
+ Profile* profile = Profile::FromWebUI(web_ui);
+ DCHECK(profile);
- reading_list_model_ =
- ReadingListModelFactory::GetForBrowserContext(browser_->profile());
+ reading_list_model_ = ReadingListModelFactory::GetForBrowserContext(profile);
}
ReadLaterPageHandler::~ReadLaterPageHandler() = default;
void ReadLaterPageHandler::GetReadLaterEntries(
GetReadLaterEntriesCallback callback) {
- auto entries = read_later::mojom::ReadLaterEntriesByStatus::New();
-
- for (const auto& url : reading_list_model_->Keys()) {
- const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url);
- DCHECK(entry);
- if (entry->IsRead()) {
- entries->read_entries.push_back(GetEntryData(entry));
- } else {
- entries->unread_entries.push_back(GetEntryData(entry));
- }
- }
-
- std::sort(entries->read_entries.begin(), entries->read_entries.end(),
- EntrySorter);
- std::sort(entries->unread_entries.begin(), entries->unread_entries.end(),
- EntrySorter);
-
- std::move(callback).Run(std::move(entries));
+ std::move(callback).Run(CreateReadLaterEntriesByStatusData());
}
void ReadLaterPageHandler::OpenSavedEntry(const GURL& url) {
- content::OpenURLParams params(url, content::Referrer(),
- WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ Browser* browser = chrome::FindLastActive();
+ if (!browser)
+ return;
+
+ // Open in active tab if the user is on the NTP.
+ WindowOpenDisposition open_location =
+ IsActiveTabNTP(browser) ? WindowOpenDisposition::CURRENT_TAB
+ : WindowOpenDisposition::NEW_FOREGROUND_TAB;
+
+ content::OpenURLParams params(url, content::Referrer(), open_location,
ui::PAGE_TRANSITION_AUTO_BOOKMARK, false);
- browser_->OpenURL(params);
+ browser->OpenURL(params);
reading_list_model_->SetReadStatus(url, true);
}
void ReadLaterPageHandler::UpdateReadStatus(const GURL& url, bool read) {
reading_list_model_->SetReadStatus(url, read);
- page_->ItemsChanged();
+ page_->ItemsChanged(CreateReadLaterEntriesByStatusData());
}
void ReadLaterPageHandler::RemoveEntry(const GURL& url) {
reading_list_model_->RemoveEntryByURL(url);
- page_->ItemsChanged();
+ page_->ItemsChanged(CreateReadLaterEntriesByStatusData());
}
void ReadLaterPageHandler::ShowUI() {
@@ -129,6 +139,28 @@ read_later::mojom::ReadLaterEntryPtr ReadLaterPageHandler::GetEntryData(
return entry_data;
}
+read_later::mojom::ReadLaterEntriesByStatusPtr
+ReadLaterPageHandler::CreateReadLaterEntriesByStatusData() {
+ auto entries = read_later::mojom::ReadLaterEntriesByStatus::New();
+
+ for (const auto& url : reading_list_model_->Keys()) {
+ const ReadingListEntry* entry = reading_list_model_->GetEntryByURL(url);
+ DCHECK(entry);
+ if (entry->IsRead()) {
+ entries->read_entries.push_back(GetEntryData(entry));
+ } else {
+ entries->unread_entries.push_back(GetEntryData(entry));
+ }
+ }
+
+ std::sort(entries->read_entries.begin(), entries->read_entries.end(),
+ EntrySorter);
+ std::sort(entries->unread_entries.begin(), entries->unread_entries.end(),
+ EntrySorter);
+
+ return entries;
+}
+
std::string ReadLaterPageHandler::GetTimeSinceLastUpdate(
int64_t last_update_time) {
const int64_t now = TimeToUS(clock_->Now());
diff --git a/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.h b/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.h
index 727b4baa4d2..1b9e8b5f9ea 100644
--- a/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.h
@@ -17,7 +17,10 @@ namespace base {
class Clock;
}
-class Browser;
+namespace content {
+class WebUI;
+}
+
class GURL;
class ReadLaterUI;
class ReadingListEntry;
@@ -28,7 +31,8 @@ class ReadLaterPageHandler : public read_later::mojom::PageHandler {
ReadLaterPageHandler(
mojo::PendingReceiver<read_later::mojom::PageHandler> receiver,
mojo::PendingRemote<read_later::mojom::Page> page,
- ReadLaterUI* read_later_ui);
+ ReadLaterUI* read_later_ui,
+ content::WebUI* web_ui);
ReadLaterPageHandler(const ReadLaterPageHandler&) = delete;
ReadLaterPageHandler& operator=(const ReadLaterPageHandler&) = delete;
~ReadLaterPageHandler() override;
@@ -47,6 +51,10 @@ class ReadLaterPageHandler : public read_later::mojom::PageHandler {
read_later::mojom::ReadLaterEntryPtr GetEntryData(
const ReadingListEntry* entry);
+ // Returns the lists for the read/unread entries.
+ read_later::mojom::ReadLaterEntriesByStatusPtr
+ CreateReadLaterEntriesByStatusData();
+
// Converts |last_update_time| from microseconds since epoch in Unix-like
// system (Jan 1, 1970), since this is how ReadingListEntry's |update_time| is
// stored, to a localized representation as a delay (e.g. "5 minutes ago").
@@ -54,7 +62,6 @@ class ReadLaterPageHandler : public read_later::mojom::PageHandler {
mojo::Receiver<read_later::mojom::PageHandler> receiver_;
mojo::Remote<read_later::mojom::Page> page_;
- Browser* const browser_;
// ReadLaterPageHandler is owned by |read_later_ui_| and so we expect
// |read_later_ui_| to remain valid for the lifetime of |this|.
ReadLaterUI* const read_later_ui_;
diff --git a/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler_unittest.cc b/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler_unittest.cc
index 1f95047edd0..4a0bac57a13 100644
--- a/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/read_later/read_later_page_handler_unittest.cc
@@ -14,9 +14,11 @@
#include "chrome/browser/ui/read_later/read_later_test_utils.h"
#include "chrome/browser/ui/read_later/reading_list_model_factory.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/test_browser_window.h"
#include "components/reading_list/core/reading_list_model.h"
+#include "content/public/test/test_web_ui.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "url/gurl.h"
@@ -43,7 +45,8 @@ class MockPage : public read_later::mojom::Page {
}
mojo::Receiver<read_later::mojom::Page> receiver_{this};
- MOCK_METHOD0(ItemsChanged, void());
+ MOCK_METHOD1(ItemsChanged,
+ void(read_later::mojom::ReadLaterEntriesByStatusPtr));
};
void ExpectNewReadLaterEntry(const read_later::mojom::ReadLaterEntry* entry,
@@ -56,11 +59,13 @@ void ExpectNewReadLaterEntry(const read_later::mojom::ReadLaterEntry* entry,
class TestReadLaterPageHandler : public ReadLaterPageHandler {
public:
explicit TestReadLaterPageHandler(
- mojo::PendingRemote<read_later::mojom::Page> page)
+ mojo::PendingRemote<read_later::mojom::Page> page,
+ content::WebUI* test_web_ui)
: ReadLaterPageHandler(
mojo::PendingReceiver<read_later::mojom::PageHandler>(),
std::move(page),
- nullptr) {}
+ nullptr,
+ test_web_ui) {}
};
class TestReadLaterPageHandlerTest : public BrowserWithTestWindowTest {
@@ -68,8 +73,14 @@ class TestReadLaterPageHandlerTest : public BrowserWithTestWindowTest {
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
BrowserList::SetLastActive(browser());
- handler_ =
- std::make_unique<TestReadLaterPageHandler>(page_.BindAndGetRemote());
+
+ web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(profile()));
+ test_web_ui_ = std::make_unique<content::TestWebUI>();
+ test_web_ui_->set_web_contents(web_contents_.get());
+
+ handler_ = std::make_unique<TestReadLaterPageHandler>(
+ page_.BindAndGetRemote(), test_web_ui_.get());
model_ =
ReadingListModelFactory::GetForBrowserContext(browser()->profile());
test::ReadingListLoadObserver(model_).Wait();
@@ -86,6 +97,9 @@ class TestReadLaterPageHandlerTest : public BrowserWithTestWindowTest {
}
void TearDown() override {
+ handler_.reset();
+ test_web_ui_.reset();
+ web_contents_.reset();
browser()->tab_strip_model()->CloseAllTabs();
BrowserWithTestWindowTest::TearDown();
}
@@ -110,6 +124,8 @@ class TestReadLaterPageHandlerTest : public BrowserWithTestWindowTest {
testing::StrictMock<MockPage> page_;
private:
+ std::unique_ptr<content::WebContents> web_contents_;
+ std::unique_ptr<content::TestWebUI> test_web_ui_;
std::unique_ptr<TestReadLaterPageHandler> handler_;
ReadingListModel* model_;
};
@@ -134,8 +150,35 @@ TEST_F(TestReadLaterPageHandlerTest, GetReadLaterEntries) {
handler()->GetReadLaterEntries(std::move(callback1));
}
-TEST_F(TestReadLaterPageHandlerTest, OpenSavedEntry) {
- // Check that OpenSavedEntry opens a new tab.
+TEST_F(TestReadLaterPageHandlerTest, OpenSavedEntryOnNTP) {
+ // Open and navigate to NTP.
+ AddTabWithTitle(browser(), GURL(chrome::kChromeUINewTabURL), "NTP");
+
+ // Check that OpenSavedEntry from the NTP does not open a new tab.
+ EXPECT_EQ(browser()->tab_strip_model()->count(), 5);
+ handler()->OpenSavedEntry(GURL(kTabUrl3));
+ EXPECT_EQ(browser()->tab_strip_model()->count(), 5);
+
+ // Get Read later entries.
+ read_later::mojom::PageHandler::GetReadLaterEntriesCallback callback1 =
+ base::BindLambdaForTesting(
+ [&](read_later::mojom::ReadLaterEntriesByStatusPtr
+ entries_by_status) {
+ ASSERT_EQ(1u, entries_by_status->unread_entries.size());
+ ASSERT_EQ(1u, entries_by_status->read_entries.size());
+
+ auto* entry1 = entries_by_status->unread_entries[0].get();
+ ExpectNewReadLaterEntry(entry1, GURL(kTabUrl1), kTabName1);
+
+ auto* entry2 = entries_by_status->read_entries[0].get();
+ ExpectNewReadLaterEntry(entry2, GURL(kTabUrl3), kTabName3);
+ });
+
+ handler()->GetReadLaterEntries(std::move(callback1));
+}
+
+TEST_F(TestReadLaterPageHandlerTest, OpenSavedEntryNotOnNTP) {
+ // Check that OpenSavedEntry opens a new tab when not on the NTP.
EXPECT_EQ(browser()->tab_strip_model()->count(), 4);
handler()->OpenSavedEntry(GURL(kTabUrl3));
EXPECT_EQ(browser()->tab_strip_model()->count(), 5);
@@ -160,7 +203,7 @@ TEST_F(TestReadLaterPageHandlerTest, OpenSavedEntry) {
TEST_F(TestReadLaterPageHandlerTest, UpdateReadStatus) {
handler()->UpdateReadStatus(GURL(kTabUrl3), true);
- EXPECT_CALL(page_, ItemsChanged()).Times(1);
+ EXPECT_CALL(page_, ItemsChanged(testing::_)).Times(1);
// Get Read later entries.
read_later::mojom::PageHandler::GetReadLaterEntriesCallback callback1 =
@@ -182,7 +225,7 @@ TEST_F(TestReadLaterPageHandlerTest, UpdateReadStatus) {
TEST_F(TestReadLaterPageHandlerTest, RemoveEntry) {
handler()->RemoveEntry(GURL(kTabUrl3));
- EXPECT_CALL(page_, ItemsChanged()).Times(1);
+ EXPECT_CALL(page_, ItemsChanged(testing::_)).Times(1);
// Get Read later entries.
read_later::mojom::PageHandler::GetReadLaterEntriesCallback callback1 =
diff --git a/chromium/chrome/browser/ui/webui/read_later/read_later_ui.cc b/chromium/chrome/browser/ui/webui/read_later/read_later_ui.cc
index 46c23d2e3ca..50b0c2e7b42 100644
--- a/chromium/chrome/browser/ui/webui/read_later/read_later_ui.cc
+++ b/chromium/chrome/browser/ui/webui/read_later/read_later_ui.cc
@@ -7,18 +7,23 @@
#include <string>
#include <utility>
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/ui_features.h"
+#include "chrome/browser/ui/webui/favicon_source.h"
#include "chrome/browser/ui/webui/read_later/read_later_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/read_later_resources.h"
#include "chrome/grit/read_later_resources_map.h"
+#include "components/favicon_base/favicon_url_parser.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.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 "ui/views/style/platform_style.h"
namespace {
void AddLocalizedString(content::WebUIDataSource* source,
@@ -31,10 +36,15 @@ void AddLocalizedString(content::WebUIDataSource* source,
} // namespace
ReadLaterUI::ReadLaterUI(content::WebUI* web_ui)
- : ui::MojoBubbleWebUIController(web_ui) {
+ : ui::MojoBubbleWebUIController(web_ui),
+ webui_load_timer_(web_ui->GetWebContents(),
+ "ReadingList.WebUI.LoadDocumentTime",
+ "ReadingList.WebUI.LoadCompletedTime") {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIReadLaterHost);
static constexpr webui::LocalizedString kLocalizedStrings[] = {
+ {"emptyStateHeader", IDS_READ_LATER_MENU_EMPTY_STATE_HEADER},
+ {"emptyStateSubheader", IDS_READ_LATER_MENU_EMPTY_STATE_SUBHEADER},
{"readHeader", IDS_READ_LATER_MENU_READ_HEADER},
{"title", IDS_READ_LATER_TITLE},
{"tooltipClose", IDS_CLOSE},
@@ -46,9 +56,18 @@ ReadLaterUI::ReadLaterUI(content::WebUI* web_ui)
for (const auto& str : kLocalizedStrings)
AddLocalizedString(source, str.name, str.id);
+ source->AddBoolean("useRipples", views::PlatformStyle::kUseRipples);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::URLDataSource::Add(
+ profile, std::make_unique<FaviconSource>(
+ profile, chrome::FaviconUrlFormat::kFavicon2));
+
webui::SetupWebUIDataSource(
source, base::make_span(kReadLaterResources, kReadLaterResourcesSize),
- /*generated_path=*/std::string(), IDR_READ_LATER_READ_LATER_HTML);
+ base::FeatureList::IsEnabled(features::kSidePanel)
+ ? IDR_READ_LATER_SIDE_PANEL_SIDE_PANEL_HTML
+ : IDR_READ_LATER_READ_LATER_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
source);
}
@@ -67,6 +86,6 @@ void ReadLaterUI::CreatePageHandler(
mojo::PendingRemote<read_later::mojom::Page> page,
mojo::PendingReceiver<read_later::mojom::PageHandler> receiver) {
DCHECK(page);
- page_handler_ = std::make_unique<ReadLaterPageHandler>(std::move(receiver),
- std::move(page), this);
+ page_handler_ = std::make_unique<ReadLaterPageHandler>(
+ std::move(receiver), std::move(page), this, web_ui());
}
diff --git a/chromium/chrome/browser/ui/webui/read_later/read_later_ui.h b/chromium/chrome/browser/ui/webui/read_later/read_later_ui.h
index 5532f286b7a..86ddb501f8c 100644
--- a/chromium/chrome/browser/ui/webui/read_later/read_later_ui.h
+++ b/chromium/chrome/browser/ui/webui/read_later/read_later_ui.h
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "chrome/browser/ui/webui/read_later/read_later.mojom.h"
+#include "chrome/browser/ui/webui/webui_load_timer.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
@@ -40,6 +41,8 @@ class ReadLaterUI : public ui::MojoBubbleWebUIController,
mojo::Receiver<read_later::mojom::PageHandlerFactory> page_factory_receiver_{
this};
+ WebuiLoadTimer webui_load_timer_;
+
WEB_UI_CONTROLLER_TYPE_DECL();
};
diff --git a/chromium/chrome/browser/ui/webui/realbox/BUILD.gn b/chromium/chrome/browser/ui/webui/realbox/BUILD.gn
new file mode 100644
index 00000000000..35751430180
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/realbox/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+import("//mojo/public/tools/bindings/mojom.gni")
+
+mojom("mojo_bindings") {
+ sources = [ "realbox.mojom" ]
+
+ public_deps = [
+ "//chrome/common/search:mojo_bindings",
+ "//mojo/public/mojom/base",
+ "//skia/public/mojom",
+ "//url/mojom:url_mojom_gurl",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/webui/realbox/DIR_METADATA b/chromium/chrome/browser/ui/webui/realbox/DIR_METADATA
new file mode 100644
index 00000000000..07a46699669
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/realbox/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>Omnibox"
+}
diff --git a/chromium/chrome/browser/ui/webui/realbox/OWNERS b/chromium/chrome/browser/ui/webui/realbox/OWNERS
new file mode 100644
index 00000000000..725cafa5da8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/realbox/OWNERS
@@ -0,0 +1,6 @@
+mahmadi@chromium.org
+tommycli@chromium.org
+file://components/omnibox/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/realbox/realbox.mojom b/chromium/chrome/browser/ui/webui/realbox/realbox.mojom
new file mode 100644
index 00000000000..9d2774448c5
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/realbox/realbox.mojom
@@ -0,0 +1,79 @@
+// 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.
+
+module realbox.mojom;
+
+import "chrome/common/search/omnibox.mojom";
+import "mojo/public/mojom/base/string16.mojom";
+import "mojo/public/mojom/base/time.mojom";
+import "skia/public/mojom/skcolor.mojom";
+import "url/mojom/url.mojom";
+
+// Theme settings for the NTP realbox.
+struct SearchBoxTheme {
+ skia.mojom.SkColor bg;
+ skia.mojom.SkColor icon;
+ skia.mojom.SkColor icon_selected;
+ skia.mojom.SkColor placeholder;
+ skia.mojom.SkColor results_bg;
+ skia.mojom.SkColor results_bg_hovered;
+ skia.mojom.SkColor results_bg_selected;
+ skia.mojom.SkColor results_dim;
+ skia.mojom.SkColor results_dim_selected;
+ skia.mojom.SkColor results_text;
+ skia.mojom.SkColor results_text_selected;
+ skia.mojom.SkColor results_url;
+ skia.mojom.SkColor results_url_selected;
+ skia.mojom.SkColor text;
+};
+
+// Browser-side handler for requests from WebUI page.
+interface PageHandler {
+ // The RealboxBrowserProxy singleton calls this when it's first initialized.
+ SetPage(pending_remote<Page> page);
+ // Queries autocomplete matches from the browser.
+ QueryAutocomplete(mojo_base.mojom.String16 input,
+ bool prevent_inline_autocomplete);
+ // Cancels the current autocomplete query. Clears the result set if
+ // |clear_result| is true.
+ StopAutocomplete(bool clear_result);
+ // Handles navigation to an autocomplete match (i.e. an item in the realbox's
+ // list of matches). Note: |url| is passed solely to verify that the browser
+ // and renderer are in sync; don't trust this content or use it for anything
+ // other than verification purposes (i.e. is the URL still the same?).
+ // TODO(crbug.com/1076604): replace |url| with an unguessable token.
+ // |mouse_button| indicates which mouse button was pressed on the match. See
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
+ OpenAutocompleteMatch(uint8 line,
+ url.mojom.Url url,
+ bool are_matches_showing,
+ mojo_base.mojom.TimeDelta time_elapsed_since_last_focus,
+ uint8 mouse_button,
+ bool alt_key,
+ bool ctrl_key,
+ bool meta_key,
+ bool shift_key);
+ // Deletes the AutocompleteMatch in the current results by |line| number if
+ // it is deletable.
+ DeleteAutocompleteMatch(uint8 line);
+ // Tells the browser to allow suggestions with the given suggestion group ID
+ // to appear in the results if they currently are not allowed to or to prevent
+ // them from appearing in the results if they are currently permitted to.
+ ToggleSuggestionGroupIdVisibility(int32 suggestion_group_id);
+ // Logs the time it took in milliseconds since the first character (in a
+ // series of characters) was typed until Autocomplete results were painted.
+ LogCharTypedToRepaintLatency(mojo_base.mojom.TimeDelta latency);
+};
+
+// WebUI-side handler for requests from the browser.
+interface Page {
+ // Updates the NTP realbox with the autocomplete results.
+ AutocompleteResultChanged(search.mojom.AutocompleteResult result);
+ // Updates the NTP realbox popup with the image or favicon data URL for the
+ // given |match_index| and |url| where |url| is an AutocompleteMatch image_url
+ // or destination_url for an entity or a navigation suggestion respectively.
+ AutocompleteMatchImageAvailable(uint32 match_index,
+ url.mojom.Url url,
+ string data_url);
+};
diff --git a/chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc b/chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc
new file mode 100644
index 00000000000..b5039b26c31
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/realbox/realbox_handler.cc
@@ -0,0 +1,335 @@
+// 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.
+
+#include "chrome/browser/ui/webui/realbox/realbox_handler.h"
+
+#include "base/metrics/histogram_macros.h"
+#include "base/metrics/user_metrics.h"
+#include "base/metrics/user_metrics_action.h"
+#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
+#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
+#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/favicon/favicon_service_factory.h"
+#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/profiles/profile.h"
+#include "chrome/browser/profiles/profile_metrics.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
+#include "chrome/browser/ui/search/omnibox_mojo_utils.h"
+#include "chrome/browser/ui/search/omnibox_utils.h"
+#include "components/bookmarks/browser/bookmark_model.h"
+#include "components/navigation_metrics/navigation_metrics.h"
+#include "components/omnibox/browser/autocomplete_classifier.h"
+#include "components/omnibox/browser/autocomplete_input.h"
+#include "components/omnibox/browser/autocomplete_match.h"
+#include "components/omnibox/browser/autocomplete_match_type.h"
+#include "components/omnibox/browser/omnibox_controller_emitter.h"
+#include "components/omnibox/browser/omnibox_event_global_tracker.h"
+#include "components/omnibox/browser/omnibox_log.h"
+#include "components/omnibox/browser/omnibox_prefs.h"
+#include "components/search_engines/omnibox_focus_type.h"
+#include "components/search_engines/template_url_service.h"
+#include "components/sessions/content/session_tab_helper.h"
+#include "net/cookies/cookie_util.h"
+#include "ui/base/webui/web_ui_util.h"
+
+RealboxHandler::RealboxHandler(
+ mojo::PendingReceiver<realbox::mojom::PageHandler> pending_page_handler,
+ Profile* profile,
+ content::WebContents* web_contents)
+ : profile_(profile),
+ web_contents_(web_contents),
+ bitmap_fetcher_service_(
+ BitmapFetcherServiceFactory::GetForBrowserContext(profile)),
+ favicon_cache_(FaviconServiceFactory::GetForProfile(
+ profile,
+ ServiceAccessType::EXPLICIT_ACCESS),
+ HistoryServiceFactory::GetForProfile(
+ profile,
+ ServiceAccessType::EXPLICIT_ACCESS)),
+ page_handler_(this, std::move(pending_page_handler)) {}
+
+RealboxHandler::~RealboxHandler() {
+ // Clear pending bitmap requests.
+ for (auto bitmap_request_id : bitmap_request_ids_) {
+ bitmap_fetcher_service_->CancelRequest(bitmap_request_id);
+ }
+}
+
+void RealboxHandler::SetPage(
+ mojo::PendingRemote<realbox::mojom::Page> pending_page) {
+ page_.Bind(std::move(pending_page));
+}
+
+void RealboxHandler::QueryAutocomplete(const base::string16& input,
+ bool prevent_inline_autocomplete) {
+ if (!autocomplete_controller_) {
+ autocomplete_controller_ = std::make_unique<AutocompleteController>(
+ std::make_unique<ChromeAutocompleteProviderClient>(profile_),
+ AutocompleteClassifier::DefaultOmniboxProviders());
+ autocomplete_controller_->AddObserver(this);
+
+ OmniboxControllerEmitter* emitter =
+ OmniboxControllerEmitter::GetForBrowserContext(profile_);
+ if (emitter)
+ autocomplete_controller_->AddObserver(emitter);
+ }
+
+ // TODO(tommycli): We use the input being empty as a signal we are requesting
+ // on-focus suggestions. It would be nice if we had a more explicit signal.
+ bool is_on_focus = input.empty();
+
+ // Early exit if a query is already in progress for on focus inputs.
+ if (!autocomplete_controller_->done() && is_on_focus)
+ return;
+
+ if (time_user_first_modified_realbox_.is_null() && !is_on_focus)
+ time_user_first_modified_realbox_ = base::TimeTicks::Now();
+
+ AutocompleteInput autocomplete_input(
+ input, metrics::OmniboxEventProto::NTP_REALBOX,
+ ChromeAutocompleteSchemeClassifier(profile_));
+ autocomplete_input.set_focus_type(is_on_focus ? OmniboxFocusType::ON_FOCUS
+ : OmniboxFocusType::DEFAULT);
+ autocomplete_input.set_prevent_inline_autocomplete(
+ prevent_inline_autocomplete);
+
+ // We do not want keyword matches for the NTP realbox, which has no UI
+ // facilities to support them.
+ autocomplete_input.set_prefer_keyword(false);
+ autocomplete_input.set_allow_exact_keyword_match(false);
+
+ autocomplete_controller_->Start(autocomplete_input);
+}
+
+void RealboxHandler::StopAutocomplete(bool clear_result) {
+ if (!autocomplete_controller_)
+ return;
+
+ autocomplete_controller_->Stop(clear_result);
+
+ if (clear_result)
+ time_user_first_modified_realbox_ = base::TimeTicks();
+}
+
+void RealboxHandler::OpenAutocompleteMatch(
+ uint8_t line,
+ const GURL& url,
+ bool are_matches_showing,
+ base::TimeDelta time_elapsed_since_last_focus,
+ uint8_t mouse_button,
+ bool alt_key,
+ bool ctrl_key,
+ bool meta_key,
+ bool shift_key) {
+ if (autocomplete_controller_->result().size() <= line) {
+ return;
+ }
+
+ AutocompleteMatch match(autocomplete_controller_->result().match_at(line));
+ if (match.destination_url != url) {
+ // TODO(https://crbug.com/1020025): this could be malice or staleness.
+ // Either way: don't navigate.
+ return;
+ }
+
+ // TODO(crbug.com/1041129): The following logic for recording Omnibox metrics
+ // is largely copied from SearchTabHelper::OpenAutocompleteMatch(). Make sure
+ // any changes here is reflected there until one code path is obsolete.
+
+ const auto now = base::TimeTicks::Now();
+ base::TimeDelta elapsed_time_since_first_autocomplete_query =
+ now - time_user_first_modified_realbox_;
+ autocomplete_controller_->UpdateMatchDestinationURLWithQueryFormulationTime(
+ elapsed_time_since_first_autocomplete_query, &match);
+
+ LOCAL_HISTOGRAM_BOOLEAN("Omnibox.EventCount", true);
+
+ UMA_HISTOGRAM_MEDIUM_TIMES("Omnibox.FocusToOpenTimeAnyPopupState3",
+ time_elapsed_since_last_focus);
+
+ if (ui::PageTransitionTypeIncludingQualifiersIs(match.transition,
+ ui::PAGE_TRANSITION_TYPED)) {
+ navigation_metrics::RecordOmniboxURLNavigation(match.destination_url);
+ }
+ // The following histogram should be recorded for both TYPED and pasted
+ // URLs, but should still exclude reloads.
+ if (ui::PageTransitionTypeIncludingQualifiersIs(match.transition,
+ ui::PAGE_TRANSITION_TYPED) ||
+ ui::PageTransitionTypeIncludingQualifiersIs(match.transition,
+ ui::PAGE_TRANSITION_LINK)) {
+ net::cookie_util::RecordCookiePortOmniboxHistograms(match.destination_url);
+ }
+
+ SuggestionAnswer::LogAnswerUsed(match.answer);
+
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (template_url_service &&
+ template_url_service->IsSearchResultsPageFromDefaultSearchProvider(
+ match.destination_url)) {
+ // Note: will always be false for the realbox.
+ UMA_HISTOGRAM_BOOLEAN("Omnibox.Search.OffTheRecord",
+ profile_->IsOffTheRecord());
+ base::RecordAction(
+ base::UserMetricsAction("OmniboxDestinationURLIsSearchOnDSP"));
+ }
+
+ AutocompleteMatch::LogSearchEngineUsed(match, template_url_service);
+
+ auto* bookmark_model = BookmarkModelFactory::GetForBrowserContext(profile_);
+ if (bookmark_model->IsBookmarked(match.destination_url)) {
+ RecordBookmarkLaunch(BOOKMARK_LAUNCH_LOCATION_OMNIBOX,
+ ProfileMetrics::GetBrowserProfileType(profile_));
+ }
+
+ const AutocompleteInput& input = autocomplete_controller_->input();
+ WindowOpenDisposition disposition = ui::DispositionFromClick(
+ /*middle_button=*/mouse_button == 1, alt_key, ctrl_key, meta_key,
+ shift_key);
+
+ base::TimeDelta default_time_delta = base::TimeDelta::FromMilliseconds(-1);
+
+ if (time_user_first_modified_realbox_.is_null())
+ elapsed_time_since_first_autocomplete_query = default_time_delta;
+
+ base::TimeDelta elapsed_time_since_last_change_to_default_match =
+ !autocomplete_controller_->last_time_default_match_changed().is_null()
+ ? now - autocomplete_controller_->last_time_default_match_changed()
+ : default_time_delta;
+
+ OmniboxLog log(
+ /*text=*/input.focus_type() != OmniboxFocusType::DEFAULT
+ ? base::string16()
+ : input.text(),
+ /*just_deleted_text=*/input.prevent_inline_autocomplete(),
+ /*input_type=*/input.type(),
+ /*in_keyword_mode=*/false,
+ /*entry_method=*/metrics::OmniboxEventProto::INVALID,
+ /*is_popup_open=*/are_matches_showing,
+ /*selected_index=*/line,
+ /*disposition=*/disposition,
+ /*is_paste_and_go=*/false,
+ /*tab_id=*/sessions::SessionTabHelper::IdForTab(web_contents_),
+ /*current_page_classification=*/metrics::OmniboxEventProto::NTP_REALBOX,
+ /*elapsed_time_since_user_first_modified_omnibox=*/
+ elapsed_time_since_first_autocomplete_query,
+ /*completed_length=*/match.allowed_to_be_default_match
+ ? match.inline_autocompletion.length()
+ : base::string16::npos,
+ /*elapsed_time_since_last_change_to_default_match=*/
+ elapsed_time_since_last_change_to_default_match,
+ /*result=*/autocomplete_controller_->result());
+ autocomplete_controller_->AddProviderAndTriggeringLogs(&log);
+
+ OmniboxEventGlobalTracker::GetInstance()->OnURLOpened(&log);
+
+ predictors::AutocompleteActionPredictorFactory::GetForProfile(profile_)
+ ->OnOmniboxOpenedUrl(log);
+
+ web_contents_->OpenURL(
+ content::OpenURLParams(match.destination_url, content::Referrer(),
+ disposition, match.transition, false));
+}
+
+void RealboxHandler::DeleteAutocompleteMatch(uint8_t line) {
+ if (autocomplete_controller_->result().size() <= line ||
+ !autocomplete_controller_->result().match_at(line).SupportsDeletion()) {
+ return;
+ }
+
+ const auto& match = autocomplete_controller_->result().match_at(line);
+ if (match.SupportsDeletion()) {
+ autocomplete_controller_->Stop(false);
+ autocomplete_controller_->DeleteMatch(match);
+ }
+}
+
+void RealboxHandler::ToggleSuggestionGroupIdVisibility(
+ int32_t suggestion_group_id) {
+ 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);
+}
+
+void RealboxHandler::LogCharTypedToRepaintLatency(base::TimeDelta latency) {
+ UMA_HISTOGRAM_TIMES("NewTabPage.Realbox.CharTypedToRepaintLatency.ToPaint",
+ latency);
+}
+
+void RealboxHandler::OnResultChanged(AutocompleteController* controller,
+ bool default_match_changed) {
+ DCHECK(controller == autocomplete_controller_.get());
+
+ page_->AutocompleteResultChanged(omnibox::CreateAutocompleteResult(
+ autocomplete_controller_->input().text(),
+ autocomplete_controller_->result(),
+ BookmarkModelFactory::GetForBrowserContext(profile_),
+ profile_->GetPrefs()));
+
+ // Clear pending bitmap requests before requesting new ones.
+ for (auto bitmap_request_id : bitmap_request_ids_) {
+ bitmap_fetcher_service_->CancelRequest(bitmap_request_id);
+ }
+ bitmap_request_ids_.clear();
+
+ int match_index = -1;
+ for (const auto& match : autocomplete_controller_->result()) {
+ match_index++;
+
+ // Request bitmaps for matche images.
+ if (!match.image_url.is_empty()) {
+ bitmap_request_ids_.push_back(bitmap_fetcher_service_->RequestImage(
+ match.image_url,
+ base::BindOnce(&RealboxHandler::OnRealboxBitmapFetched,
+ weak_ptr_factory_.GetWeakPtr(), match_index,
+ match.image_url)));
+ }
+
+ // Request favicons for navigational matches.
+ // TODO(crbug.com/1075848): Investigate using chrome://favicon2.
+ if (!AutocompleteMatch::IsSearchType(match.type) &&
+ match.type != AutocompleteMatchType::DOCUMENT_SUGGESTION) {
+ gfx::Image favicon = favicon_cache_.GetLargestFaviconForPageUrl(
+ match.destination_url,
+ base::BindOnce(&RealboxHandler::OnRealboxFaviconFetched,
+ weak_ptr_factory_.GetWeakPtr(), match_index,
+ match.destination_url));
+ if (!favicon.IsEmpty()) {
+ OnRealboxFaviconFetched(match_index, match.destination_url, favicon);
+ }
+ }
+ }
+}
+
+void RealboxHandler::OnRealboxBitmapFetched(int match_index,
+ const GURL& image_url,
+ const SkBitmap& bitmap) {
+ auto data = gfx::Image::CreateFrom1xBitmap(bitmap).As1xPNGBytes();
+ std::string data_url =
+ webui::GetPngDataUrl(data->front_as<unsigned char>(), data->size());
+
+ page_->AutocompleteMatchImageAvailable(match_index, image_url, data_url);
+}
+
+void RealboxHandler::OnRealboxFaviconFetched(int match_index,
+ const GURL& page_url,
+ const gfx::Image& favicon) {
+ DCHECK(!favicon.IsEmpty());
+ auto data = favicon.As1xPNGBytes();
+ std::string data_url =
+ webui::GetPngDataUrl(data->front_as<unsigned char>(), data->size());
+
+ page_->AutocompleteMatchImageAvailable(match_index, page_url, data_url);
+}
diff --git a/chromium/chrome/browser/ui/webui/realbox/realbox_handler.h b/chromium/chrome/browser/ui/webui/realbox/realbox_handler.h
new file mode 100644
index 00000000000..79d32838c2c
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/realbox/realbox_handler.h
@@ -0,0 +1,88 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_REALBOX_REALBOX_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_REALBOX_REALBOX_HANDLER_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
+#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"
+#include "chrome/browser/ui/webui/realbox/realbox.mojom.h"
+#include "components/omnibox/browser/autocomplete_controller.h"
+#include "components/omnibox/browser/favicon_cache.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "mojo/public/cpp/bindings/remote.h"
+
+class GURL;
+class Profile;
+
+namespace content {
+class WebContents;
+} // namespace content
+
+namespace gfx {
+class Image;
+} // namespace gfx
+
+// Handles bidirectional communication between NTP realbox JS and the browser.
+class RealboxHandler : public realbox::mojom::PageHandler,
+ public AutocompleteController::Observer {
+ public:
+ RealboxHandler(
+ mojo::PendingReceiver<realbox::mojom::PageHandler> pending_page_handler,
+ Profile* profile,
+ content::WebContents* web_contents);
+ ~RealboxHandler() override;
+
+ // realbox::mojom::PageHandler:
+ void SetPage(mojo::PendingRemote<realbox::mojom::Page> pending_page) override;
+ void QueryAutocomplete(const base::string16& input,
+ bool prevent_inline_autocomplete) override;
+ void StopAutocomplete(bool clear_result) override;
+ void OpenAutocompleteMatch(uint8_t line,
+ const GURL& url,
+ bool are_matches_showing,
+ base::TimeDelta time_elapsed_since_last_focus,
+ uint8_t mouse_button,
+ bool alt_key,
+ bool ctrl_key,
+ bool meta_key,
+ bool shift_key) override;
+ void DeleteAutocompleteMatch(uint8_t line) override;
+ void ToggleSuggestionGroupIdVisibility(int32_t suggestion_group_id) override;
+ void LogCharTypedToRepaintLatency(base::TimeDelta latency) override;
+
+ // AutocompleteController::Observer:
+ void OnResultChanged(AutocompleteController* controller,
+ bool default_match_changed) override;
+
+ void OnRealboxBitmapFetched(int match_index,
+ const GURL& image_url,
+ const SkBitmap& bitmap);
+ void OnRealboxFaviconFetched(int match_index,
+ const GURL& page_url,
+ const gfx::Image& favicon);
+
+ private:
+ Profile* profile_;
+ content::WebContents* web_contents_;
+ std::unique_ptr<AutocompleteController> autocomplete_controller_;
+ BitmapFetcherService* bitmap_fetcher_service_;
+ std::vector<BitmapFetcherService::RequestId> bitmap_request_ids_;
+ FaviconCache favicon_cache_;
+ base::TimeTicks time_user_first_modified_realbox_;
+
+ mojo::Remote<realbox::mojom::Page> page_;
+ mojo::Receiver<realbox::mojom::PageHandler> page_handler_;
+
+ base::WeakPtrFactory<RealboxHandler> weak_ptr_factory_{this};
+
+ DISALLOW_COPY_AND_ASSIGN(RealboxHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_REALBOX_REALBOX_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/reset_password/BUILD.gn b/chromium/chrome/browser/ui/webui/reset_password/BUILD.gn
index bd425a30ea7..e10270e4772 100644
--- a/chromium/chrome/browser/ui/webui/reset_password/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/reset_password/BUILD.gn
@@ -6,4 +6,5 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojo_bindings") {
sources = [ "reset_password.mojom" ]
+ webui_module_path = "/"
}
diff --git a/chromium/chrome/browser/ui/webui/reset_password/DIR_METADATA b/chromium/chrome/browser/ui/webui/reset_password/DIR_METADATA
new file mode 100644
index 00000000000..e04bbe2ae27
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/reset_password/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>Safebrowsing"
+}
diff --git a/chromium/chrome/browser/ui/webui/reset_password/OWNERS b/chromium/chrome/browser/ui/webui/reset_password/OWNERS
index c30ee078ee0..6a739ea7892 100644
--- a/chromium/chrome/browser/ui/webui/reset_password/OWNERS
+++ b/chromium/chrome/browser/ui/webui/reset_password/OWNERS
@@ -4,5 +4,3 @@ per-file *.mojom=file://ipc/SECURITY_OWNERS
drubery@chromium.org
nparker@chromium.org
vakh@chromium.org
-
-# COMPONENT: UI>Browser>Safebrowsing
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 adfeeab4f21..1f98e4ab441 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
@@ -14,9 +14,9 @@
#include "chrome/browser/ui/webui/reset_password/reset_password.mojom.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
-#include "components/safe_browsing/content/password_protection/metrics_util.h"
#include "components/safe_browsing/content/password_protection/password_protection_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
+#include "components/safe_browsing/core/password_protection/metrics_util.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
#include "components/strings/grit/components_strings.h"
#include "components/url_formatter/url_formatter.h"
@@ -89,10 +89,13 @@ PasswordType GetPasswordType(content::WebContents* web_contents) {
if (!nav_entry || !nav_entry->GetHasPostData())
return PasswordType::PASSWORD_TYPE_UNKNOWN;
auto& post_data = nav_entry->GetPostData()->elements()->at(0);
- int post_data_int = -1;
- if (base::StringToInt(std::string(post_data.bytes(), post_data.length()),
- &post_data_int)) {
- return static_cast<PasswordType>(post_data_int);
+ if (post_data.type() == network::DataElement::Tag::kBytes) {
+ int post_data_int = -1;
+ if (base::StringToInt(
+ post_data.As<network::DataElementBytes>().AsStringPiece(),
+ &post_data_int)) {
+ return static_cast<PasswordType>(post_data_int);
+ }
}
return PasswordType::PASSWORD_TYPE_UNKNOWN;
@@ -115,8 +118,8 @@ ResetPasswordUI::ResetPasswordUI(content::WebUI* web_ui)
content::WebUIDataSource::Create(chrome::kChromeUIResetPasswordHost));
html_source->DisableTrustedTypesCSP();
html_source->AddResourcePath("reset_password.js", IDR_RESET_PASSWORD_JS);
- html_source->AddResourcePath("reset_password.mojom-lite.js",
- IDR_RESET_PASSWORD_MOJOM_LITE_JS);
+ html_source->AddResourcePath("reset_password.mojom-webui.js",
+ IDR_RESET_PASSWORD_MOJOM_WEBUI_JS);
html_source->SetDefaultResource(IDR_RESET_PASSWORD_HTML);
html_source->AddLocalizedStrings(PopulateStrings());
diff --git a/chromium/chrome/browser/ui/webui/sandbox/DIR_METADATA b/chromium/chrome/browser/ui/webui/sandbox/DIR_METADATA
new file mode 100644
index 00000000000..be222260074
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/sandbox/DIR_METADATA
@@ -0,0 +1,4 @@
+monorail {
+ component: "Internals>Sandbox"
+}
+team_email: "security-dev@chromium.org"
diff --git a/chromium/chrome/browser/ui/webui/sandbox/OWNERS b/chromium/chrome/browser/ui/webui/sandbox/OWNERS
index 058ee25caec..6c3369ae777 100644
--- a/chromium/chrome/browser/ui/webui/sandbox/OWNERS
+++ b/chromium/chrome/browser/ui/webui/sandbox/OWNERS
@@ -1,3 +1 @@
-file://sandbox/OWNERS
-# COMPONENT: Internals>Sandbox
-# TEAM: security-dev@chromium.org
+file://sandbox/OWNERS \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/sessions/OWNERS b/chromium/chrome/browser/ui/webui/sessions/OWNERS
new file mode 100644
index 00000000000..ca81d90ab06
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/sessions/OWNERS
@@ -0,0 +1,2 @@
+sky@chromium.org
+
diff --git a/chromium/chrome/browser/ui/webui/sessions/session_service_internals_ui.cc b/chromium/chrome/browser/ui/webui/sessions/session_service_internals_ui.cc
new file mode 100644
index 00000000000..6480da2e719
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/sessions/session_service_internals_ui.cc
@@ -0,0 +1,100 @@
+// 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.
+
+#include "chrome/browser/ui/webui/sessions/session_service_internals_ui.h"
+
+#include <string>
+
+#include "base/memory/ref_counted_memory.h"
+#include "base/strings/strcat.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/time/time.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/session_service_log.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+
+namespace {
+
+// This is for debugging, so it doesn't use local time conversions.
+std::string EventTimeToString(const SessionServiceEvent& event) {
+ base::Time::Exploded time_details;
+ event.time.LocalExplode(&time_details);
+ return base::StringPrintf("%d/%d/%d %d:%02d:%02d", time_details.month,
+ time_details.day_of_month, time_details.year,
+ time_details.hour, time_details.minute,
+ time_details.second);
+}
+
+std::string EventToString(const SessionServiceEvent& event) {
+ switch (event.type) {
+ case SessionServiceEventLogType::kStart:
+ return base::StrCat(
+ {EventTimeToString(event), " start",
+ (event.data.start.did_last_session_crash ? " (last session crashed)"
+ : std::string())});
+ case SessionServiceEventLogType::kRestore:
+ return base::StrCat(
+ {EventTimeToString(event), " restore windows=",
+ base::NumberToString(event.data.restore.window_count),
+ " tabs=", base::NumberToString(event.data.restore.tab_count),
+ (event.data.restore.encountered_error_reading ? " (error reading)"
+ : std::string())});
+ case SessionServiceEventLogType::kExit:
+ return base::StrCat(
+ {EventTimeToString(event), " exit (shutdown) windows=",
+ base::NumberToString(event.data.exit.window_count),
+ " tabs=", base::NumberToString(event.data.exit.tab_count)});
+ case SessionServiceEventLogType::kWriteError:
+ return base::StrCat(
+ {EventTimeToString(event), " write errors (",
+ base::NumberToString(event.data.write_error.error_count), ")"});
+ }
+}
+
+std::string GetEventLogAsString(Profile* profile) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ std::vector<std::string> results;
+ results.push_back("<pre>");
+ for (const auto& event : GetSessionServiceEvents(profile))
+ results.push_back(EventToString(event));
+ results.push_back("</pre>");
+ return base::JoinString(results, "\n");
+}
+
+bool ShouldHandleWebUIRequestCallback(const std::string& path) {
+ return true;
+}
+
+void HandleWebUIRequestCallback(
+ const std::string& result,
+ const std::string& path,
+ content::WebUIDataSource::GotDataCallback callback) {
+ DCHECK(ShouldHandleWebUIRequestCallback(path));
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ std::string result_copy = result;
+ std::move(callback).Run(base::RefCountedString::TakeString(&result_copy));
+}
+
+} // namespace
+
+SessionServiceInternalsUI::SessionServiceInternalsUI(content::WebUI* web_ui)
+ : WebUIController(web_ui) {
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource* source = content::WebUIDataSource::Create(
+ chrome::kChromeUISessionServiceInternalsHost);
+ // This page only needs raw text, and the string is on the small side.
+ source->SetRequestFilter(
+ base::BindRepeating(&ShouldHandleWebUIRequestCallback),
+ base::BindRepeating(&HandleWebUIRequestCallback,
+ GetEventLogAsString(profile)));
+ content::WebUIDataSource::Add(profile, source);
+}
+
+SessionServiceInternalsUI::~SessionServiceInternalsUI() = default;
diff --git a/chromium/chrome/browser/ui/webui/sessions/session_service_internals_ui.h b/chromium/chrome/browser/ui/webui/sessions/session_service_internals_ui.h
new file mode 100644
index 00000000000..fbf62745041
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/sessions/session_service_internals_ui.h
@@ -0,0 +1,21 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SESSIONS_SESSION_SERVICE_INTERNALS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_SESSIONS_SESSION_SERVICE_INTERNALS_UI_H_
+
+#include "content/public/browser/web_ui_controller.h"
+
+// WebUIController that is used to show a diagnostic page for the
+// SessionService.
+class SessionServiceInternalsUI : public content::WebUIController {
+ public:
+ explicit SessionServiceInternalsUI(content::WebUI* web_ui);
+ SessionServiceInternalsUI(const SessionServiceInternalsUI&) = delete;
+ SessionServiceInternalsUI& operator=(const SessionServiceInternalsUI&) =
+ delete;
+ ~SessionServiceInternalsUI() override;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SESSIONS_SESSION_SERVICE_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/DEPS b/chromium/chrome/browser/ui/webui/settings/DEPS
new file mode 100644
index 00000000000..33142b17512
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+content/public/browser/tts_controller.h",
+]
diff --git a/chromium/chrome/browser/ui/webui/settings/DIR_METADATA b/chromium/chrome/browser/ui/webui/settings/DIR_METADATA
new file mode 100644
index 00000000000..f4b2e0ae71c
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Settings"
+}
diff --git a/chromium/chrome/browser/ui/webui/settings/OWNERS b/chromium/chrome/browser/ui/webui/settings/OWNERS
index 5b2350082b3..cca8351c3d9 100644
--- a/chromium/chrome/browser/ui/webui/settings/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/OWNERS
@@ -8,5 +8,4 @@ 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
-
-# COMPONENT: UI>Settings
+per-file settings_security_key_handler*=file://device/fido/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
index bf04fc096a5..09b82022336 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
@@ -27,6 +27,7 @@
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/ui/browser.h"
@@ -49,13 +50,14 @@
#include "ui/base/l10n/l10n_util.h"
#include "v8/include/v8-version-string.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/constants/ash_switches.h"
#include "base/i18n/time_formatting.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/tpm_firmware_update.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -63,7 +65,6 @@
#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/constants/chromeos_switches.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/dbus/update_engine_client.h"
#include "chromeos/dbus/util/version_loader.h"
@@ -79,7 +80,7 @@ using content::BrowserThread;
namespace {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// The directory containing the regulatory labels for supported
// models/regions, relative to chromeos-assets directory
@@ -211,7 +212,7 @@ std::unique_ptr<base::DictionaryValue> GetVersionInfo() {
return version_info;
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
std::string UpdateStatusToString(VersionUpdater::Status status) {
std::string status_str;
@@ -277,7 +278,11 @@ void AboutHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"openHelpPage", base::BindRepeating(&AboutHandler::HandleOpenHelpPage,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ web_ui()->RegisterMessageCallback(
+ "openDiagnostics",
+ base::BindRepeating(&AboutHandler::HandleOpenDiagnostics,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"openOsHelpPage", base::BindRepeating(&AboutHandler::HandleOpenOsHelpPage,
base::Unretained(this)));
@@ -328,7 +333,7 @@ void AboutHandler::RegisterMessages() {
base::Unretained(this)));
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Handler for the product label image, which will be shown if available.
content::URLDataSource::Add(profile_,
std::make_unique<chromeos::ImageSource>());
@@ -343,8 +348,8 @@ void AboutHandler::OnJavascriptAllowed() {
policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
policy_registrar_->Observe(
policy::key::kDeviceAutoUpdateDisabled,
- base::Bind(&AboutHandler::OnDeviceAutoUpdatePolicyChanged,
- base::Unretained(this)));
+ base::BindRepeating(&AboutHandler::OnDeviceAutoUpdatePolicyChanged,
+ base::Unretained(this)));
}
void AboutHandler::OnJavascriptDisallowed() {
@@ -388,10 +393,10 @@ void AboutHandler::HandleRefreshUpdateStatus(const base::ListValue* args) {
void AboutHandler::RefreshUpdateStatus() {
// On Chrome OS, do not check for an update automatically.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
static_cast<VersionUpdaterCros*>(version_updater_.get())
- ->GetUpdateStatus(
- base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)));
+ ->GetUpdateStatus(base::BindRepeating(&AboutHandler::SetUpdateStatus,
+ base::Unretained(this)));
#else
RequestUpdate();
#endif
@@ -418,7 +423,12 @@ void AboutHandler::HandleOpenHelpPage(const base::ListValue* args) {
chrome::ShowHelp(browser, chrome::HELP_SOURCE_WEBUI);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+void AboutHandler::HandleOpenDiagnostics(const base::ListValue* args) {
+ DCHECK(args->empty());
+ chrome::ShowDiagnosticsApp(profile_);
+}
+
void AboutHandler::HandleCheckInternetConnection(const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
std::string callback_id;
@@ -469,7 +479,8 @@ void AboutHandler::HandleSetChannel(const base::ListValue* args) {
if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
// Check for update after switching release channel.
version_updater_->CheckForUpdate(
- base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)),
+ base::BindRepeating(&AboutHandler::SetUpdateStatus,
+ base::Unretained(this)),
VersionUpdater::PromoteCallback());
}
}
@@ -509,8 +520,8 @@ void AboutHandler::HandleGetChannelInfo(const base::ListValue* args) {
CHECK(args->GetString(0, &callback_id));
version_updater_->GetChannel(
true /* get current channel */,
- base::Bind(&AboutHandler::OnGetCurrentChannel, weak_factory_.GetWeakPtr(),
- callback_id));
+ base::BindOnce(&AboutHandler::OnGetCurrentChannel,
+ weak_factory_.GetWeakPtr(), callback_id));
}
void AboutHandler::HandleCanChangeChannel(const base::ListValue* args) {
@@ -525,8 +536,8 @@ void AboutHandler::OnGetCurrentChannel(std::string callback_id,
const std::string& current_channel) {
version_updater_->GetChannel(
false /* get target channel */,
- base::Bind(&AboutHandler::OnGetTargetChannel, weak_factory_.GetWeakPtr(),
- callback_id, current_channel));
+ base::BindOnce(&AboutHandler::OnGetTargetChannel,
+ weak_factory_.GetWeakPtr(), callback_id, current_channel));
}
void AboutHandler::OnGetTargetChannel(std::string callback_id,
@@ -569,7 +580,8 @@ void AboutHandler::HandleRequestUpdateOverCellular(
void AboutHandler::RequestUpdateOverCellular(const std::string& update_version,
int64_t update_size) {
version_updater_->SetUpdateOverCellularOneTimePermission(
- base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)),
+ base::BindRepeating(&AboutHandler::SetUpdateStatus,
+ base::Unretained(this)),
update_version, update_size);
}
@@ -610,7 +622,9 @@ void AboutHandler::OnGetEndOfLifeInfo(
response.SetStringKey(
"aboutPageEndOfLifeMessage",
l10n_util::GetStringFUTF16(
- eol_string_id, base::TimeFormatMonthAndYear(eol_info.eol_date),
+ eol_string_id,
+ base::TimeFormatMonthAndYear(eol_info.eol_date,
+ /*time_zone=*/icu::TimeZone::getGMT()),
base::ASCIIToUTF16(has_eol_passed ? chrome::kEolNotificationURL
: chrome::kAutoUpdatePolicyURL)));
} else {
@@ -620,13 +634,15 @@ void AboutHandler::OnGetEndOfLifeInfo(
ResolveJavascriptCallback(base::Value(callback_id), response);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
void AboutHandler::RequestUpdate() {
version_updater_->CheckForUpdate(
- base::Bind(&AboutHandler::SetUpdateStatus, base::Unretained(this)),
+ base::BindRepeating(&AboutHandler::SetUpdateStatus,
+ base::Unretained(this)),
#if defined(OS_MAC)
- base::Bind(&AboutHandler::SetPromotionState, base::Unretained(this)));
+ base::BindRepeating(&AboutHandler::SetPromotionState,
+ base::Unretained(this)));
#else
VersionUpdater::PromoteCallback());
#endif // OS_MAC
@@ -651,7 +667,7 @@ void AboutHandler::SetUpdateStatus(VersionUpdater::Status status,
event->SetString("version", version);
// DictionaryValue does not support int64_t, so convert to string.
event->SetString("size", base::NumberToString(size));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
if (status == VersionUpdater::FAILED_OFFLINE ||
status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) {
base::string16 types_msg = GetAllowedConnectionTypesMessage();
@@ -662,7 +678,7 @@ void AboutHandler::SetUpdateStatus(VersionUpdater::Status status,
} else {
event->Set("connectionTypes", std::make_unique<base::Value>());
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
FireWebUIListener("update-status-changed", *event);
}
@@ -695,7 +711,7 @@ void AboutHandler::SetPromotionState(VersionUpdater::PromotionState state) {
}
#endif // defined(OS_MAC)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void AboutHandler::OnRegulatoryLabelDirFound(
std::string callback_id,
const base::FilePath& label_dir_path) {
@@ -728,6 +744,6 @@ void AboutHandler::OnRegulatoryLabelTextRead(
ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.h b/chromium/chrome/browser/ui/webui/settings/about_handler.h
index bed6a0ecb10..4b5aafa848d 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.h
@@ -13,16 +13,17 @@
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/help/version_updater.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/browser/upgrade_detector/upgrade_observer.h"
#include "components/policy/core/common/policy_service.h"
#include "content/public/browser/web_ui_message_handler.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/chromeos/tpm_firmware_update.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace base {
class DictionaryValue;
@@ -82,7 +83,7 @@ class AboutHandler : public settings::SettingsPageUIHandler,
// Opens the help page. |args| must be empty.
void HandleOpenHelpPage(const base::ListValue* args);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Checks if ReleaseNotes is enabled.
void HandleGetEnabledReleaseNotes(const base::ListValue* args);
@@ -152,7 +153,9 @@ class AboutHandler : public settings::SettingsPageUIHandler,
void SetPromotionState(VersionUpdater::PromotionState state);
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ void HandleOpenDiagnostics(const base::ListValue* args);
+
void HandleGetRegulatoryInfo(const base::ListValue* args);
// Callback for when the directory with the regulatory label image and alt
diff --git a/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc b/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc
index 4a5a81f839e..194cb4aa277 100644
--- a/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/accessibility/accessibility_state_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_context_menu/accessibility_labels_bubble_model.h"
@@ -37,19 +38,18 @@ void AccessibilityMainHandler::RegisterMessages() {
}
void AccessibilityMainHandler::OnJavascriptAllowed() {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
accessibility_subscription_ =
- chromeos::AccessibilityManager::Get()->RegisterCallback(
- base::BindRepeating(
- &AccessibilityMainHandler::OnAccessibilityStatusChanged,
- base::Unretained(this)));
-#endif // defined(OS_CHROMEOS)
+ ash::AccessibilityManager::Get()->RegisterCallback(base::BindRepeating(
+ &AccessibilityMainHandler::OnAccessibilityStatusChanged,
+ base::Unretained(this)));
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void AccessibilityMainHandler::OnJavascriptDisallowed() {
-#if defined(OS_CHROMEOS)
- accessibility_subscription_.reset();
-#endif // defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ accessibility_subscription_ = {};
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void AccessibilityMainHandler::HandleA11yPageReady(
@@ -64,7 +64,7 @@ void AccessibilityMainHandler::HandleCheckAccessibilityImageLabels(
// dialog will disable the feature again if it is not accepted.
content::WebContents* web_contents = web_ui()->GetWebContents();
content::RenderWidgetHostView* view =
- web_contents->GetRenderViewHost()->GetWidget()->GetView();
+ web_contents->GetMainFrame()->GetRenderViewHost()->GetWidget()->GetView();
gfx::Rect rect = view->GetViewBounds();
auto model = std::make_unique<AccessibilityLabelsBubbleModel>(
Profile::FromWebUI(web_ui()), web_contents, true /* enable always */);
@@ -78,14 +78,14 @@ void AccessibilityMainHandler::SendScreenReaderStateChanged() {
FireWebUIListener("screen-reader-state-changed", result);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void AccessibilityMainHandler::OnAccessibilityStatusChanged(
- const chromeos::AccessibilityStatusEventDetails& details) {
+ const ash::AccessibilityStatusEventDetails& details) {
if (details.notification_type ==
- chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) {
+ ash::AccessibilityNotificationType::kToggleSpokenFeedback) {
SendScreenReaderStateChanged();
}
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.h b/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.h
index ebc1f51b392..19674cd58d4 100644
--- a/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/accessibility_main_handler.h
@@ -8,11 +8,12 @@
#include <memory>
#include "base/macros.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
-#endif // defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/accessibility/accessibility_manager.h"
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace base {
class ListValue;
@@ -40,13 +41,12 @@ class AccessibilityMainHandler : public ::settings::SettingsPageUIHandler {
private:
void SendScreenReaderStateChanged();
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void OnAccessibilityStatusChanged(
- const chromeos::AccessibilityStatusEventDetails& details);
+ const ash::AccessibilityStatusEventDetails& details);
- std::unique_ptr<chromeos::AccessibilityStatusSubscription>
- accessibility_subscription_;
-#endif // defined(OS_CHROMEOS)
+ base::CallbackListSubscription accessibility_subscription_;
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
};
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/appearance_handler.cc b/chromium/chrome/browser/ui/webui/settings/appearance_handler.cc
index c4f57a6ee98..b8fa3d7cc29 100644
--- a/chromium/chrome/browser/ui/webui/settings/appearance_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/appearance_handler.cc
@@ -7,6 +7,8 @@
#include "base/bind.h"
#include "base/notreached.h"
#include "base/values.h"
+#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
@@ -27,7 +29,9 @@ void AppearanceHandler::RegisterMessages() {
"useDefaultTheme",
base::BindRepeating(&AppearanceHandler::HandleUseDefaultTheme,
base::Unretained(this)));
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
+// of lacros-chrome is complete.
+#if defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
web_ui()->RegisterMessageCallback(
"useSystemTheme",
base::BindRepeating(&AppearanceHandler::HandleUseSystemTheme,
@@ -39,7 +43,9 @@ void AppearanceHandler::HandleUseDefaultTheme(const base::ListValue* args) {
ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme();
}
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
+// of lacros-chrome is complete.
+#if defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
void AppearanceHandler::HandleUseSystemTheme(const base::ListValue* args) {
if (profile_->IsSupervised())
NOTREACHED();
diff --git a/chromium/chrome/browser/ui/webui/settings/appearance_handler.h b/chromium/chrome/browser/ui/webui/settings/appearance_handler.h
index 961e16eec2d..60f42a62277 100644
--- a/chromium/chrome/browser/ui/webui/settings/appearance_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/appearance_handler.h
@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
namespace base {
@@ -36,7 +37,9 @@ class AppearanceHandler : public SettingsPageUIHandler {
// Changes the UI theme of the browser to the default theme.
void HandleUseDefaultTheme(const base::ListValue* args);
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
+// of lacros-chrome is complete.
+#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
// Changes the UI theme of the browser to the system (GTK+) theme.
void HandleUseSystemTheme(const base::ListValue* args);
#endif
diff --git a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
index 02e3ff59f12..8b03ae3281f 100644
--- a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
@@ -7,22 +7,23 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/lifetime/application_lifetime.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/tpm_firmware_update.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace settings {
namespace {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Triggers a TPM firmware update using the least destructive mode from
// |available_modes|.
void TriggerTPMFirmwareUpdate(
@@ -47,7 +48,7 @@ void TriggerTPMFirmwareUpdate(
return;
}
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace
@@ -62,7 +63,7 @@ void BrowserLifetimeHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"relaunch", base::BindRepeating(&BrowserLifetimeHandler::HandleRelaunch,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
"signOutAndRestart",
base::BindRepeating(&BrowserLifetimeHandler::HandleSignOutAndRestart,
@@ -71,7 +72,7 @@ void BrowserLifetimeHandler::RegisterMessages() {
"factoryReset",
base::BindRepeating(&BrowserLifetimeHandler::HandleFactoryReset,
base::Unretained(this)));
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void BrowserLifetimeHandler::HandleRestart(
@@ -84,7 +85,7 @@ void BrowserLifetimeHandler::HandleRelaunch(
chrome::AttemptRelaunch();
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void BrowserLifetimeHandler::HandleSignOutAndRestart(
const base::ListValue* args) {
chrome::AttemptUserExit();
@@ -119,6 +120,6 @@ void BrowserLifetimeHandler::HandleFactoryReset(
// be launched (as if it was a restart).
chrome::AttemptRelaunch();
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.h b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.h
index b5394d1673b..6ded5ac34ff 100644
--- a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_BROWSER_LIFETIME_HANDLER_H_
#include "base/macros.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
namespace base {
@@ -27,10 +28,10 @@ class BrowserLifetimeHandler : public SettingsPageUIHandler {
private:
void HandleRestart(const base::ListValue* /*args*/);
void HandleRelaunch(const base::ListValue* /*args*/);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void HandleSignOutAndRestart(const base::ListValue* /*args*/);
void HandleFactoryReset(const base::ListValue* /*args*/);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
DISALLOW_COPY_AND_ASSIGN(BrowserLifetimeHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/settings/captions_handler.cc b/chromium/chrome/browser/ui/webui/settings/captions_handler.cc
index f6a88382732..c67cf0a431f 100644
--- a/chromium/chrome/browser/ui/webui/settings/captions_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/captions_handler.cc
@@ -23,7 +23,9 @@ namespace settings {
CaptionsHandler::CaptionsHandler(PrefService* prefs) : prefs_(prefs) {}
-CaptionsHandler::~CaptionsHandler() = default;
+CaptionsHandler::~CaptionsHandler() {
+ speech::SodaInstaller::GetInstance()->RemoveObserver(this);
+}
void CaptionsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
@@ -37,11 +39,11 @@ void CaptionsHandler::RegisterMessages() {
}
void CaptionsHandler::OnJavascriptAllowed() {
- speech::SODAInstaller::GetInstance()->AddObserver(this);
+ speech::SodaInstaller::GetInstance()->AddObserver(this);
}
void CaptionsHandler::OnJavascriptDisallowed() {
- speech::SODAInstaller::GetInstance()->RemoveObserver(this);
+ speech::SodaInstaller::GetInstance()->RemoveObserver(this);
}
void CaptionsHandler::HandleCaptionsSubpageReady(const base::ListValue* args) {
@@ -55,20 +57,21 @@ void CaptionsHandler::HandleOpenSystemCaptionsDialog(
#endif
}
-void CaptionsHandler::OnSODAInstalled() {
+void CaptionsHandler::OnSodaInstalled() {
+ speech::SodaInstaller::GetInstance()->RemoveObserver(this);
FireWebUIListener("enable-live-caption-subtitle-changed",
base::Value(l10n_util::GetStringUTF16(
IDS_SETTINGS_CAPTIONS_LIVE_CAPTION_DOWNLOAD_COMPLETE)));
}
-void CaptionsHandler::OnSODAError() {
+void CaptionsHandler::OnSodaError() {
prefs_->SetBoolean(prefs::kLiveCaptionEnabled, false);
FireWebUIListener("enable-live-caption-subtitle-changed",
base::Value(l10n_util::GetStringUTF16(
IDS_SETTINGS_CAPTIONS_LIVE_CAPTION_DOWNLOAD_ERROR)));
}
-void CaptionsHandler::OnSODAProgress(int progress) {
+void CaptionsHandler::OnSodaProgress(int progress) {
FireWebUIListener(
"enable-live-caption-subtitle-changed",
base::Value(l10n_util::GetStringFUTF16Int(
diff --git a/chromium/chrome/browser/ui/webui/settings/captions_handler.h b/chromium/chrome/browser/ui/webui/settings/captions_handler.h
index c3029ef753d..9924dc6d2cb 100644
--- a/chromium/chrome/browser/ui/webui/settings/captions_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/captions_handler.h
@@ -14,7 +14,7 @@ namespace settings {
// Settings handler for the captions settings subpage.
class CaptionsHandler : public SettingsPageUIHandler,
- public speech::SODAInstaller::Observer {
+ public speech::SodaInstaller::Observer {
public:
explicit CaptionsHandler(PrefService* prefs);
~CaptionsHandler() override;
@@ -30,10 +30,10 @@ class CaptionsHandler : public SettingsPageUIHandler,
void HandleCaptionsSubpageReady(const base::ListValue* args);
void HandleOpenSystemCaptionsDialog(const base::ListValue* args);
- // SODAInstaller::Observer overrides:
- void OnSODAInstalled() override;
- void OnSODAError() override;
- void OnSODAProgress(int progress) override;
+ // SodaInstaller::Observer overrides:
+ void OnSodaInstalled() override;
+ void OnSodaError() override;
+ void OnSodaProgress(int progress) override;
PrefService* prefs_;
};
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 37f8b056c86..ca6c5e50300 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
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.h"
#include <memory>
+#include <set>
#include <string>
#include <utility>
@@ -15,13 +16,12 @@
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/string16.h"
-#include "base/strings/utf_string_conversions.h"
+#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_win.h"
#include "chrome/grit/generated_resources.h"
@@ -30,8 +30,6 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_message_handler.h"
-#include "extensions/browser/extension_registry.h"
-#include "extensions/browser/extension_system.h"
#include "ui/base/l10n/l10n_util.h"
using safe_browsing::ChromeCleanerController;
@@ -46,8 +44,9 @@ std::unique_ptr<base::ListValue> GetFilesAsListStorage(
auto value = std::make_unique<base::ListValue>();
for (const base::FilePath& path : files) {
auto item = std::make_unique<base::DictionaryValue>();
- item->SetString("dirname", path.DirName().AsEndingWithSeparator().value());
- item->SetString("basename", path.BaseName().value());
+ item->SetString("dirname",
+ path.DirName().AsEndingWithSeparator().AsUTF8Unsafe());
+ item->SetString("basename", path.BaseName().AsUTF8Unsafe());
value->Append(std::move(item));
}
return value;
@@ -55,10 +54,10 @@ std::unique_ptr<base::ListValue> GetFilesAsListStorage(
// Returns a ListValue containing a copy of the strings stored in |string_set|.
std::unique_ptr<base::ListValue> GetStringSetAsListStorage(
- const std::set<base::string16>& string_set) {
+ const std::set<std::wstring>& string_set) {
auto value = std::make_unique<base::ListValue>();
- for (const base::string16& string : string_set)
- value->AppendString(string);
+ for (const std::wstring& string : string_set)
+ value->AppendString(base::AsString16(string));
return value;
}
@@ -71,10 +70,6 @@ base::DictionaryValue GetScannerResultsAsDictionary(
GetFilesAsListStorage(scanner_results.files_to_delete()));
value.SetList("registryKeys",
GetStringSetAsListStorage(scanner_results.registry_keys()));
- std::set<base::string16> extensions;
- ChromeCleanupHandler::GetExtensionNamesFromIds(
- profile, scanner_results.extension_ids(), &extensions);
- value.SetList("extensions", GetStringSetAsListStorage(extensions));
return value;
}
@@ -115,28 +110,6 @@ ChromeCleanupHandler::~ChromeCleanupHandler() {
controller_->RemoveObserver(this);
}
-// static
-void ChromeCleanupHandler::GetExtensionNamesFromIds(
- Profile* profile,
- const std::set<base::string16>& extension_ids,
- std::set<base::string16>* extension_names) {
-#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- extensions::ExtensionRegistry* extension_registry =
- extensions::ExtensionRegistry::Get(profile);
- for (const base::string16& extension_id : extension_ids) {
- const extensions::Extension* extension =
- extension_registry->GetInstalledExtension(
- base::UTF16ToUTF8(extension_id));
- if (extension) {
- extension_names->insert(base::UTF8ToUTF16(extension->name()));
- } else {
- extension_names->insert(l10n_util::GetStringFUTF16(
- IDS_SETTINGS_RESET_CLEANUP_DETAILS_EXTENSION_UNKNOWN, extension_id));
- }
- }
-#endif
-}
-
void ChromeCleanupHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"registerChromeCleanerObserver",
@@ -269,11 +242,8 @@ void ChromeCleanupHandler::HandleStartCleanup(const base::ListValue* args) {
base::RecordAction(
base::UserMetricsAction("SoftwareReporter.CleanupWebui_StartCleanup"));
- extensions::ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
-
controller_->ReplyWithUserResponse(
- profile_, extension_service,
+ profile_,
allow_logs_upload
? ChromeCleanerController::UserResponse::kAcceptedWithLogs
: ChromeCleanerController::UserResponse::kAcceptedWithoutLogs);
diff --git a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.h b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.h
index 5f966e8fa7b..c942bc27268 100644
--- a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.h
+++ b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.h
@@ -5,11 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROME_CLEANUP_HANDLER_WIN_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROME_CLEANUP_HANDLER_WIN_H_
-#include <set>
-
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/strings/string16.h"
#include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_win.h"
#include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_scanner_results_win.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -31,15 +28,6 @@ class ChromeCleanupHandler
explicit ChromeCleanupHandler(Profile* profile);
~ChromeCleanupHandler() override;
- // Retrieves extension names for |extension_ids| from |profile|'s extension
- // registry and adds them to |extension_names|. If a name cannot be found for
- // an extension ID, instead adds a translated string stating the item is an
- // unknown extension ID.
- static void GetExtensionNamesFromIds(
- Profile* profile,
- const std::set<base::string16>& extension_ids,
- std::set<base::string16>* extension_names);
-
// SettingsPageUIHandler implementation.
void RegisterMessages() override;
void OnJavascriptAllowed() override;
diff --git a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win_unittest.cc
deleted file mode 100644
index cff17fb6870..00000000000
--- a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler_win_unittest.cc
+++ /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.
-
-#include "chrome/browser/ui/webui/settings/chrome_cleanup_handler_win.h"
-
-#include "build/branding_buildflags.h"
-#include "chrome/browser/safe_browsing/chrome_cleaner/mock_chrome_cleaner_process_win.h"
-#include "chrome/grit/generated_resources.h"
-#include "chrome/test/base/testing_browser_process.h"
-#include "chrome/test/base/testing_profile.h"
-#include "chrome/test/base/testing_profile_manager.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/l10n/l10n_util.h"
-
-namespace settings {
-
-using safe_browsing::MockChromeCleanerProcess;
-
-TEST(ChromeCleanupHandlerTest, GetExtensionsNamesFromIds) {
- content::BrowserTaskEnvironment task_environment_;
- TestingProfileManager profile_manager_(TestingBrowserProcess::GetGlobal());
-
- // Set up the testing profile to get the extensions registry from it.
- ASSERT_TRUE(profile_manager_.SetUp());
- TestingProfile* testing_profile_ =
- profile_manager_.CreateTestingProfile("DummyProfile");
- MockChromeCleanerProcess::AddMockExtensionsToProfile(testing_profile_);
-
- std::set<base::string16> test_ids = {
- MockChromeCleanerProcess::kInstalledExtensionId1,
- MockChromeCleanerProcess::kInstalledExtensionId2,
- MockChromeCleanerProcess::kUnknownExtensionId,
- };
-
- std::set<base::string16> expected_names = {
-#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- // Extension names are only available in Google-branded builds.
- MockChromeCleanerProcess::kInstalledExtensionName1,
- MockChromeCleanerProcess::kInstalledExtensionName2,
- l10n_util::GetStringFUTF16(
- IDS_SETTINGS_RESET_CLEANUP_DETAILS_EXTENSION_UNKNOWN,
- MockChromeCleanerProcess::kUnknownExtensionId),
-#endif
- };
-
- std::set<base::string16> actual_names;
- ChromeCleanupHandler::GetExtensionNamesFromIds(testing_profile_, test_ids,
- &actual_names);
-
- EXPECT_THAT(actual_names, testing::ContainerEq(expected_names));
-}
-
-} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS b/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS
index 1a526ea8d7e..1c079659d26 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+ash/components/pcie_peripheral",
"+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/DIR_METADATA b/chromium/chrome/browser/ui/webui/settings/chromeos/DIR_METADATA
new file mode 100644
index 00000000000..2d34b2f4c92
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "OS>Systems>Settings"
+}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS b/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
index b89ca31bbd5..e26540b4619 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
@@ -2,6 +2,4 @@ file://chrome/browser/resources/settings/chromeos/OWNERS
per-file languages_section*=myy@chromium.org
per-file multidevice_handler*=file://chromeos/components/multidevice/OWNERS
-per-file account_manager_*=file://chromeos/components/account_manager/OWNERS
-
-# COMPONENT: OS>Systems>Settings
+per-file account_manager_*=file://ash/components/account_manager/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 bb9eb38876b..8a8384d6426 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/about_section.h"
+#include "ash/constants/ash_features.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/i18n/message_formatter.h"
@@ -13,17 +14,17 @@
#include "base/system/sys_info.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/obsolete_system/obsolete_system.h"
-#include "chrome/browser/ui/webui/management_ui.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/chromeos/device_name_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
-#include "chrome/browser/ui/webui/version_ui.h"
+#include "chrome/browser/ui/webui/version/version_ui.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/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/dbus/constants/dbus_switches.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_chromium_strings.h"
@@ -96,6 +97,22 @@ const std::vector<SearchConcept>& GetAboutSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetDiagnosticsAppSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_ABOUT_DIAGNOSTICS,
+ mojom::kAboutChromeOsDetailsSubpagePath,
+ mojom::SearchResultIcon::kChrome,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kDiagnostics},
+ {IDS_OS_SETTINGS_TAG_ABOUT_DIAGNOSTICS_ALT1,
+ IDS_OS_SETTINGS_TAG_ABOUT_DIAGNOSTICS_ALT2,
+ IDS_OS_SETTINGS_TAG_ABOUT_DIAGNOSTICS_ALT3,
+ IDS_OS_SETTINGS_TAG_ABOUT_DIAGNOSTICS_ALT4, SearchConcept::kAltTagEnd}},
+ });
+ return *tags;
+}
+
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
const std::vector<SearchConcept>& GetAboutTermsOfServiceSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
@@ -165,6 +182,10 @@ AboutSection::AboutSection(Profile* profile,
: OsSettingsSection(profile, search_tag_registry) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.AddSearchTags(GetAboutSearchConcepts());
+
+ if (base::FeatureList::IsEnabled(chromeos::features::kDiagnosticsApp)) {
+ updater.AddSearchTags(GetDiagnosticsAppSearchConcepts());
+ }
}
AboutSection::~AboutSection() = default;
@@ -176,6 +197,7 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
{"aboutReportAnIssue", IDS_SETTINGS_ABOUT_PAGE_REPORT_AN_ISSUE},
#endif
+ {"aboutDiagnostics", IDS_SETTINGS_ABOUT_PAGE_DIAGNOSTICS},
{"aboutRelaunch", IDS_SETTINGS_ABOUT_PAGE_RELAUNCH},
{"aboutUpgradeCheckStarted", IDS_SETTINGS_ABOUT_UPGRADE_CHECK_STARTED},
{"aboutUpgradeRelaunch", IDS_SETTINGS_UPGRADE_SUCCESSFUL_RELAUNCH},
@@ -258,7 +280,7 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"aboutReleaseNotesOffline", IDS_SETTINGS_ABOUT_PAGE_RELEASE_NOTES},
{"aboutShowReleaseNotes", IDS_SETTINGS_ABOUT_PAGE_SHOW_RELEASE_NOTES},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString("aboutTPMFirmwareUpdateLearnMoreURL",
chrome::kTPMFirmwareUpdateLearnMoreURL);
@@ -326,6 +348,10 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
std::string safetyInfoLink = GetSafetyInfoLink();
html_source->AddBoolean("shouldShowSafetyInfo", !safetyInfoLink.empty());
+ html_source->AddBoolean(
+ "diagnosticsAppEnabled",
+ base::FeatureList::IsEnabled(chromeos::features::kDiagnosticsApp));
+
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
html_source->AddString("aboutTermsURL", chrome::kChromeUITermsURL);
html_source->AddLocalizedString("aboutProductTos",
@@ -341,6 +367,7 @@ void AboutSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
void AboutSection::AddHandlers(content::WebUI* web_ui) {
web_ui->AddMessageHandler(
std::make_unique<::settings::AboutHandler>(profile()));
+ web_ui->AddMessageHandler(std::make_unique<DeviceNameHandler>());
}
int AboutSection::GetSectionNameMessageId() const {
@@ -371,9 +398,9 @@ void AboutSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::SearchResultIcon::kChrome, mojom::SearchResultDefaultRank::kMedium,
mojom::kAboutChromeOsDetailsSubpagePath);
static constexpr mojom::Setting kAboutChromeOsDetailsSettings[] = {
- mojom::Setting::kCheckForOsUpdate, mojom::Setting::kSeeWhatsNew,
+ mojom::Setting::kCheckForOsUpdate, mojom::Setting::kSeeWhatsNew,
mojom::Setting::kGetHelpWithChromeOs, mojom::Setting::kReportAnIssue,
- mojom::Setting::kTermsOfService};
+ mojom::Setting::kTermsOfService, mojom::Setting::kDiagnostics};
RegisterNestedSettingBulk(mojom::Subpage::kAboutChromeOsDetails,
kAboutChromeOsDetailsSettings, generator);
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 ca9fab13381..6dd9a95f43b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
+#include "chrome/browser/ash/accessibility/accessibility_manager.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -18,9 +18,10 @@
namespace chromeos {
namespace settings {
-
namespace {
+using ::ash::AccessibilityManager;
+
void RecordShowShelfNavigationButtonsValueChange(bool enabled) {
base::UmaHistogramBoolean(
"Accessibility.CrosShelfNavigationButtonsInTabletModeChanged."
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 f8df807a57e..b35cc7976ac 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include "ash/public/cpp/accessibility_controller_enums.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/tablet_mode.h"
@@ -23,6 +24,7 @@
#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"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
@@ -30,6 +32,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
+#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_features.h"
#include "extensions/browser/extension_system.h"
@@ -200,6 +203,12 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kEnableSwitchAccess}},
+ {IDS_OS_SETTINGS_TAG_A11Y_CURSOR_COLOR,
+ mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kEnableCursorColor}},
});
return *tags;
}
@@ -292,23 +301,24 @@ const std::vector<SearchConcept>& GetA11yLabelsSearchConcepts() {
const std::vector<SearchConcept>& GetA11yLiveCaptionSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_A11Y_LIVE_CAPTION,
- mojom::kManageAccessibilitySubpagePath,
+ mojom::kCaptionsSubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kLiveCaptions}},
+ {.setting = mojom::Setting::kLiveCaption}},
});
return *tags;
}
-const std::vector<SearchConcept>& GetA11yCursorColorSearchConcepts() {
+const std::vector<SearchConcept>&
+GetA11yFullscreenMagnifierFocusFollowingSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_A11Y_CURSOR_COLOR,
+ {IDS_OS_SETTINGS_TAG_A11Y_FULLSCREEN_MAGNIFIER_FOCUS_FOLLOWING,
mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kEnableCursorColor}},
+ {.setting = mojom::Setting::kFullscreenMagnifierFocusFollowing}},
});
return *tags;
}
@@ -318,12 +328,16 @@ bool AreExperimentalA11yLabelsAllowed() {
::features::kExperimentalAccessibilityLabels);
}
-bool AreLiveCaptionsAllowed() {
+bool IsLiveCaptionEnabled() {
return base::FeatureList::IsEnabled(media::kLiveCaption);
}
-bool IsCursorColorAllowed() {
- return features::IsAccessibilityCursorColorEnabled();
+bool IsMagnifierPanningImprovementsEnabled() {
+ return features::IsMagnifierPanningImprovementsEnabled();
+}
+
+bool IsMagnifierContinuousMouseFollowingModeSettingEnabled() {
+ return features::IsMagnifierContinuousMouseFollowingModeSettingEnabled();
}
bool IsSwitchAccessTextAllowed() {
@@ -331,6 +345,11 @@ bool IsSwitchAccessTextAllowed() {
::switches::kEnableExperimentalAccessibilitySwitchAccessText);
}
+bool IsSwitchAccessSetupGuideAllowed() {
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kEnableExperimentalAccessibilitySwitchAccessSetupGuide);
+}
+
bool AreTabletNavigationButtonsAllowed() {
return ash::features::IsHideShelfControlsInTabletModeEnabled() &&
ash::TabletMode::IsBoardTypeMarkedAsTabletCapable();
@@ -359,6 +378,10 @@ AccessibilitySection::AccessibilitySection(
ash::prefs::kAccessibilitySwitchAccessAutoScanEnabled,
base::BindRepeating(&AccessibilitySection::UpdateSearchTags,
base::Unretained(this)));
+ pref_change_registrar_.Add(
+ ash::prefs::kAccessibilityScreenMagnifierEnabled,
+ base::BindRepeating(&AccessibilitySection::UpdateSearchTags,
+ base::Unretained(this)));
UpdateSearchTags();
@@ -417,6 +440,12 @@ void AccessibilitySection::AddLoadTimeData(
{"chromeVoxLabel", IDS_SETTINGS_CHROMEVOX_LABEL},
{"chromeVoxOptionsLabel", IDS_SETTINGS_CHROMEVOX_OPTIONS_LABEL},
{"screenMagnifierLabel", IDS_SETTINGS_SCREEN_MAGNIFIER_LABEL},
+ {"screenMagnifierMouseFollowingModeContinuous",
+ IDS_SETTINGS_SCREEN_MANIFIER_MOUSE_FOLLOWING_MODE_CONTINUOUS},
+ {"screenMagnifierMouseFollowingModeCentered",
+ IDS_SETTINGS_SCREEN_MANIFIER_MOUSE_FOLLOWING_MODE_CENTERED},
+ {"screenMagnifierMouseFollowingModeEdge",
+ IDS_SETTINGS_SCREEN_MANIFIER_MOUSE_FOLLOWING_MODE_EDGE},
{"screenMagnifierFocusFollowingLabel",
IDS_SETTINGS_SCREEN_MAGNIFIER_FOCUS_FOLLOWING_LABEL},
{"screenMagnifierZoomLabel", IDS_SETTINGS_SCREEN_MAGNIFIER_ZOOM_LABEL},
@@ -486,14 +515,68 @@ void AccessibilitySection::AddLoadTimeData(
{"manageSwitchAccessSettings",
IDS_SETTINGS_MANAGE_SWITCH_ACCESS_SETTINGS},
{"switchAssignmentHeading", IDS_SETTINGS_SWITCH_ASSIGNMENT_HEADING},
- {"switchAssignOptionPlaceholder",
- IDS_SETTINGS_SWITCH_ASSIGN_OPTION_PLACEHOLDER},
- {"switchAssignOptionNone", IDS_SETTINGS_SWITCH_ASSIGN_OPTION_NONE},
- {"switchAssignOptionSpace", IDS_SETTINGS_SWITCH_ASSIGN_OPTION_SPACE},
- {"switchAssignOptionEnter", IDS_SETTINGS_SWITCH_ASSIGN_OPTION_ENTER},
+ {"switchAccessSetupGuideLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_SETUP_GUIDE_LABEL},
+ {"assignSwitchSubLabel0Switches",
+ IDS_SETTINGS_ASSIGN_SWITCH_SUB_LABEL_0_SWITCHES},
+ {"assignSwitchSubLabel1Switch",
+ IDS_SETTINGS_ASSIGN_SWITCH_SUB_LABEL_1_SWITCH},
+ {"assignSwitchSubLabel2Switches",
+ IDS_SETTINGS_ASSIGN_SWITCH_SUB_LABEL_2_SWITCHES},
+ {"assignSwitchSubLabel3Switches",
+ IDS_SETTINGS_ASSIGN_SWITCH_SUB_LABEL_3_SWITCHES},
+ {"assignSwitchSubLabel4Switches",
+ IDS_SETTINGS_ASSIGN_SWITCH_SUB_LABEL_4_SWITCHES},
+ {"assignSwitchSubLabel5OrMoreSwitches",
+ IDS_SETTINGS_ASSIGN_SWITCH_SUB_LABEL_5_OR_MORE_SWITCHES},
{"assignSelectSwitchLabel", IDS_SETTINGS_ASSIGN_SELECT_SWITCH_LABEL},
{"assignNextSwitchLabel", IDS_SETTINGS_ASSIGN_NEXT_SWITCH_LABEL},
{"assignPreviousSwitchLabel", IDS_SETTINGS_ASSIGN_PREVIOUS_SWITCH_LABEL},
+ {"switchAccessInternalDeviceTypeLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_INTERNAL_DEVICE_TYPE_LABEL},
+ {"switchAccessUsbDeviceTypeLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_USB_DEVICE_TYPE_LABEL},
+ {"switchAccessBluetoothDeviceTypeLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_BLUETOOTH_DEVICE_TYPE_LABEL},
+ {"switchAccessUnknownDeviceTypeLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_UNKNOWN_DEVICE_TYPE_LABEL},
+ {"switchAccessActionAssignmentDialogAssignedIconLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_ASSIGNED_ICON_LABEL},
+ {"switchAccessActionAssignmentDialogAddAssignmentIconLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_ADD_ASSIGNMENT_ICON_LABEL},
+ {"switchAccessActionAssignmentDialogRemoveAssignmentIconLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_REMOVE_ASSIGNMENT_ICON_LABEL},
+ {"switchAccessActionAssignmentDialogErrorIconLabel",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_ERROR_ICON_LABEL},
+ {"switchAccessActionAssignmentDialogTitle",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_TITLE},
+ {"switchAccessActionAssignmentDialogWarnNotConfirmedPrompt",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WARN_NOT_CONFIRMED_PROMPT},
+ {"switchAccessActionAssignmentDialogWarnAlreadyAssignedActionPrompt",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WARN_ALREADY_ASSIGNED_ACTION_PROMPT},
+ {"switchAccessActionAssignmentDialogWarnUnrecognizedKeyPrompt",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WARN_UNRECOGNIZED_KEY_PROMPT},
+ {"switchAccessActionAssignmentDialogWaitForKeyPromptNoSwitches",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WAIT_FOR_KEY_PROMPT_NO_SWITCHES},
+ {"switchAccessActionAssignmentDialogWaitForKeyPromptAtLeastOneSwitch",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WAIT_FOR_KEY_PROMPT_AT_LEAST_ONE_SWITCH},
+ {"switchAccessActionAssignmentDialogWaitForConfirmationPrompt",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WAIT_FOR_CONFIRMATION_PROMPT},
+ {"switchAccessActionAssignmentDialogWaitForConfirmationRemovalPrompt",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WAIT_FOR_CONFIRMATION_REMOVAL_PROMPT},
+ {"switchAccessActionAssignmentDialogWarnCannotRemoveLastSelectSwitch",
+ IDS_SETTINGS_SWITCH_ACCESS_ACTION_ASSIGNMENT_DIALOG_WARN_CANNOT_REMOVE_LAST_SELECT_SWITCH},
+ {"switchAndDeviceType", IDS_SETTINGS_SWITCH_AND_DEVICE_TYPE},
+ {"noSwitchesAssigned", IDS_SETTINGS_NO_SWITCHES_ASSIGNED},
+ {"switchAccessDialogExit", IDS_SETTINGS_SWITCH_ACCESS_DIALOG_EXIT},
+ {"switchAccessSetupIntroTitle",
+ IDS_SETTINGS_SWITCH_ACCESS_SETUP_INTRO_TITLE},
+ {"switchAccessSetupIntroBody",
+ IDS_SETTINGS_SWITCH_ACCESS_SETUP_INTRO_BODY},
+ {"switchAccessSetupPairBluetooth",
+ IDS_SETTINGS_SWITCH_ACCESS_SETUP_PAIR_BLUETOOTH},
+ {"switchAccessSetupNext", IDS_SETTINGS_SWITCH_ACCESS_SETUP_NEXT},
+ {"switchAccessSetupPrevious", IDS_SETTINGS_SWITCH_ACCESS_SETUP_PREVIOUS},
{"switchAccessAutoScanHeading",
IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_HEADING},
{"switchAccessAutoScanLabel", IDS_SETTINGS_SWITCH_ACCESS_AUTO_SCAN_LABEL},
@@ -568,8 +651,9 @@ void AccessibilitySection::AddLoadTimeData(
IDS_SETTINGS_A11Y_TABLET_MODE_SHELF_BUTTONS_DESCRIPTION},
{"caretBrowsingTitle", IDS_SETTINGS_ENABLE_CARET_BROWSING_TITLE},
{"caretBrowsingSubtitle", IDS_SETTINGS_ENABLE_CARET_BROWSING_SUBTITLE},
+ {"cancel", IDS_CANCEL},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString("a11yLearnMoreUrl",
chrome::kChromeAccessibilityHelpURL);
@@ -578,6 +662,9 @@ void AccessibilitySection::AddLoadTimeData(
"showExperimentalAccessibilitySwitchAccessImprovedTextInput",
IsSwitchAccessTextAllowed());
+ html_source->AddBoolean("showSwitchAccessSetupGuide",
+ IsSwitchAccessSetupGuideAllowed());
+
html_source->AddBoolean("showExperimentalA11yLabels",
AreExperimentalA11yLabelsAllowed());
@@ -587,8 +674,12 @@ void AccessibilitySection::AddLoadTimeData(
html_source->AddString("tabletModeShelfNavigationButtonsLearnMoreUrl",
chrome::kTabletModeGesturesLearnMoreURL);
- html_source->AddBoolean("showExperimentalAccessibilityCursorColor",
- IsCursorColorAllowed());
+ html_source->AddBoolean("isMagnifierPanningImprovementsEnabled",
+ IsMagnifierPanningImprovementsEnabled());
+
+ html_source->AddBoolean(
+ "isMagnifierContinuousMouseFollowingModeSettingEnabled",
+ IsMagnifierContinuousMouseFollowingModeSettingEnabled());
::settings::AddCaptionSubpageStrings(html_source);
}
@@ -597,6 +688,8 @@ void AccessibilitySection::AddHandlers(content::WebUI* web_ui) {
web_ui->AddMessageHandler(
std::make_unique<::settings::AccessibilityMainHandler>());
web_ui->AddMessageHandler(std::make_unique<AccessibilityHandler>(profile()));
+ web_ui->AddMessageHandler(
+ std::make_unique<SwitchAccessHandler>(profile()->GetPrefs()));
web_ui->AddMessageHandler(std::make_unique<::settings::TtsHandler>());
web_ui->AddMessageHandler(
std::make_unique<::settings::FontHandler>(profile()));
@@ -621,12 +714,20 @@ std::string AccessibilitySection::GetSectionPath() const {
}
bool AccessibilitySection::LogMetric(mojom::Setting setting,
base::Value& value) const {
+ // TODO(accessibility): Ensure to capture metrics for Switch Access's action
+ // dialog on detach.
switch (setting) {
case mojom::Setting::kFullscreenMagnifierFocusFollowing:
base::UmaHistogramBoolean(
"ChromeOS.Settings.Accessibility.FullscreenMagnifierFocusFollowing",
value.GetBool());
return true;
+ case mojom::Setting::kFullscreenMagnifierMouseFollowingMode:
+ base::UmaHistogramEnumeration(
+ "ChromeOS.Settings.Accessibility."
+ "FullscreenMagnifierMouseFollowingMode",
+ static_cast<ash::MagnifierMouseFollowingMode>(value.GetInt()));
+ return true;
default:
return false;
@@ -651,6 +752,7 @@ void AccessibilitySection::RegisterHierarchy(
mojom::Setting::kHighContrastMode,
mojom::Setting::kFullscreenMagnifier,
mojom::Setting::kFullscreenMagnifierFocusFollowing,
+ mojom::Setting::kFullscreenMagnifierMouseFollowingMode,
mojom::Setting::kDockedMagnifier,
mojom::Setting::kStickyKeys,
mojom::Setting::kOnScreenKeyboard,
@@ -664,7 +766,6 @@ void AccessibilitySection::RegisterHierarchy(
mojom::Setting::kTabletNavigationButtons,
mojom::Setting::kMonoAudio,
mojom::Setting::kStartupSound,
- mojom::Setting::kLiveCaptions,
mojom::Setting::kEnableCursorColor,
};
RegisterNestedSettingBulk(mojom::Subpage::kManageAccessibility,
@@ -702,6 +803,11 @@ void AccessibilitySection::RegisterHierarchy(
IDS_SETTINGS_CAPTIONS, mojom::Subpage::kCaptions,
mojom::SearchResultIcon::kA11y, mojom::SearchResultDefaultRank::kMedium,
mojom::kCaptionsSubpagePath);
+ static constexpr mojom::Setting kCaptionsSettings[] = {
+ mojom::Setting::kLiveCaption,
+ };
+ RegisterNestedSettingBulk(mojom::Subpage::kCaptions, kCaptionsSettings,
+ generator);
}
void AccessibilitySection::OnVoicesChanged() {
@@ -761,16 +867,20 @@ void AccessibilitySection::UpdateSearchTags() {
updater.RemoveSearchTags(GetA11ySwitchAccessOnSearchConcepts());
updater.RemoveSearchTags(GetA11ySwitchAccessKeyboardSearchConcepts());
- if (AreLiveCaptionsAllowed()) {
+ if (IsLiveCaptionEnabled()) {
updater.AddSearchTags(GetA11yLiveCaptionSearchConcepts());
} else {
updater.RemoveSearchTags(GetA11yLiveCaptionSearchConcepts());
}
- if (IsCursorColorAllowed()) {
- updater.AddSearchTags(GetA11yCursorColorSearchConcepts());
+ if (IsMagnifierPanningImprovementsEnabled() &&
+ pref_service_->GetBoolean(
+ ash::prefs::kAccessibilityScreenMagnifierEnabled)) {
+ updater.AddSearchTags(
+ GetA11yFullscreenMagnifierFocusFollowingSearchConcepts());
} else {
- updater.RemoveSearchTags(GetA11yCursorColorSearchConcepts());
+ updater.RemoveSearchTags(
+ GetA11yFullscreenMagnifierFocusFollowingSearchConcepts());
}
if (!pref_service_->GetBoolean(
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h
index e87764dda08..fab878386a7 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h
@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCESSIBILITY_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCESSIBILITY_SECTION_H_
-#include "base/scoped_observer.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "components/prefs/pref_change_registrar.h"
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 18e0dfc7203..3d591a99b11 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,6 +6,7 @@
#include <utility>
+#include "ash/components/account_manager/account_manager_factory.h"
#include "ash/public/cpp/toast_data.h"
#include "ash/public/cpp/toast_manager.h"
#include "base/bind.h"
@@ -14,7 +15,8 @@
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/account_manager_facade_factory.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/chromeos/account_manager/account_manager_welcome_dialog.h"
@@ -22,7 +24,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/components/account_manager/account_manager_factory.h"
+#include "components/account_manager_core/account_manager_facade.h"
#include "components/signin/public/identity_manager/consent_level.h"
#include "components/user_manager/user.h"
#include "google_apis/gaia/gaia_auth_util.h"
@@ -174,10 +176,7 @@ class AccountBuilder {
AccountManagerUIHandler::AccountManagerUIHandler(
AccountManager* account_manager,
signin::IdentityManager* identity_manager)
- : account_manager_(account_manager),
- identity_manager_(identity_manager),
- account_manager_observer_(this),
- identity_manager_observer_(this) {
+ : account_manager_(account_manager), identity_manager_(identity_manager) {
DCHECK(account_manager_);
DCHECK(identity_manager_);
}
@@ -343,8 +342,10 @@ base::ListValue AccountManagerUIHandler::GetSecondaryGaiaAccounts(
void AccountManagerUIHandler::HandleAddAccount(const base::ListValue* args) {
AllowJavascript();
- InlineLoginDialogChromeOS::Show(
- InlineLoginDialogChromeOS::Source::kSettingsAddAccountButton);
+ ::GetAccountManagerFacade(profile_->GetPath().value())
+ ->ShowAddAccountDialog(
+ account_manager::AccountManagerFacade::AccountAdditionSource::
+ kSettingsAddAccountButton);
}
void AccountManagerUIHandler::HandleReauthenticateAccount(
@@ -354,9 +355,11 @@ void AccountManagerUIHandler::HandleReauthenticateAccount(
CHECK(!args->GetList().empty());
const std::string& account_email = args->GetList()[0].GetString();
- InlineLoginDialogChromeOS::Show(
- account_email,
- InlineLoginDialogChromeOS::Source::kSettingsReauthAccountButton);
+ ::GetAccountManagerFacade(profile_->GetPath().value())
+ ->ShowReauthAccountDialog(
+ account_manager::AccountManagerFacade::AccountAdditionSource::
+ kSettingsReauthAccountButton,
+ account_email);
}
void AccountManagerUIHandler::HandleMigrateAccount(
@@ -405,13 +408,13 @@ void AccountManagerUIHandler::HandleShowWelcomeDialogIfRequired(
}
void AccountManagerUIHandler::OnJavascriptAllowed() {
- account_manager_observer_.Add(account_manager_);
- identity_manager_observer_.Add(identity_manager_);
+ account_manager_observation_.Observe(account_manager_);
+ identity_manager_observation_.Observe(identity_manager_);
}
void AccountManagerUIHandler::OnJavascriptDisallowed() {
- account_manager_observer_.RemoveAll();
- identity_manager_observer_.RemoveAll();
+ account_manager_observation_.Reset();
+ identity_manager_observation_.Reset();
}
// |AccountManager::Observer| overrides. Note: We need to listen on
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 f3d2bfcf9f0..90b45c38d5b 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
@@ -8,11 +8,11 @@
#include <string>
#include <vector>
+#include "ash/components/account_manager/account_manager.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "chromeos/components/account_manager/account_manager.h"
#include "components/account_id/account_id.h"
#include "components/account_manager_core/account.h"
#include "components/signin/public/identity_manager/identity_manager.h"
@@ -104,13 +104,14 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler,
// An observer for |AccountManager|. Automatically deregisters when |this| is
// destructed.
- ScopedObserver<AccountManager, AccountManager::Observer>
- account_manager_observer_;
+ base::ScopedObservation<AccountManager, AccountManager::Observer>
+ account_manager_observation_{this};
// An observer for |signin::IdentityManager|. Automatically deregisters when
// |this| is destructed.
- ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
- identity_manager_observer_;
+ base::ScopedObservation<signin::IdentityManager,
+ signin::IdentityManager::Observer>
+ identity_manager_observation_{this};
base::WeakPtrFactory<AccountManagerUIHandler> weak_factory_{this};
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 9e135808282..37bf9bbfb66 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,17 +7,17 @@
#include <memory>
#include <ostream>
+#include "ash/components/account_manager/account_manager.h"
+#include "ash/components/account_manager/account_manager_factory.h"
#include "base/test/bind.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/supervised_user/supervised_user_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
-#include "chromeos/components/account_manager/account_manager.h"
-#include "chromeos/components/account_manager/account_manager_factory.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_utils.h"
#include "components/user_manager/scoped_user_manager.h"
@@ -27,6 +27,9 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace {
+
+using ::ash::AccountManager;
+
constexpr char kGetAccountsMessage[] = "getAccounts";
constexpr char kHandleFunctionName[] = "handleFunctionName";
@@ -57,7 +60,7 @@ DeviceAccountInfo GetActiveDirectoryDeviceAccountInfo() {
"example.com" /*organization*/,
user_manager::USER_TYPE_ACTIVE_DIRECTORY /*user_type*/,
account_manager::AccountType::kActiveDirectory /*account_type*/,
- chromeos::AccountManager::kActiveDirectoryDummyToken /*token*/};
+ AccountManager::kActiveDirectoryDummyToken /*token*/};
}
DeviceAccountInfo GetGaiaDeviceAccountInfo() {
@@ -161,7 +164,7 @@ class AccountManagerUIHandlerTest
identity_manager_ = IdentityManagerFactory::GetForProfile(profile_.get());
- chromeos::AccountManagerFactory* factory =
+ auto* factory =
g_browser_process->platform_part()->GetAccountManagerFactory();
account_manager_ = factory->GetAccountManager(profile_->GetPath().value());
@@ -229,7 +232,7 @@ class AccountManagerUIHandlerTest
content::TestWebUI* web_ui() { return &web_ui_; }
signin::IdentityManager* identity_manager() { return identity_manager_; }
- chromeos::AccountManager* account_manager() { return account_manager_; }
+ AccountManager* account_manager() { return account_manager_; }
private:
chromeos::FakeChromeUserManager* GetFakeUserManager() const {
@@ -240,7 +243,7 @@ class AccountManagerUIHandlerTest
std::unique_ptr<user_manager::ScopedUserManager> user_manager_enabler_;
base::ScopedTempDir temp_dir_;
std::unique_ptr<TestingProfile> profile_;
- chromeos::AccountManager* account_manager_ = nullptr;
+ AccountManager* account_manager_ = nullptr;
signin::IdentityManager* identity_manager_ = nullptr;
content::TestWebUI web_ui_;
AccountId primary_account_id_;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc
index 277bf50c80f..f4e541f277e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc
@@ -8,8 +8,10 @@
#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_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"
@@ -24,7 +26,7 @@
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
+#include "components/prefs/pref_service.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/l10n/l10n_util.h"
@@ -124,9 +126,10 @@ base::string16 GetAlbumDescription(const ash::PersonalAlbum& album) {
} // namespace
-AmbientModeHandler::AmbientModeHandler()
+AmbientModeHandler::AmbientModeHandler(PrefService* pref_service)
: fetch_settings_retry_backoff_(&kRetryBackoffPolicy),
- update_settings_retry_backoff_(&kRetryBackoffPolicy) {}
+ update_settings_retry_backoff_(&kRetryBackoffPolicy),
+ pref_service_(pref_service) {}
AmbientModeHandler::~AmbientModeHandler() = default;
@@ -152,9 +155,30 @@ void AmbientModeHandler::RegisterMessages() {
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::ListValue* args) {
@@ -188,8 +212,11 @@ void AmbientModeHandler::HandleSetSelectedTemperatureUnit(
DCHECK(settings_);
CHECK_EQ(1U, args->GetSize());
- settings_->temperature_unit = ExtractTemperatureUnit(args);
- UpdateSettings();
+ auto temperature_unit = ExtractTemperatureUnit(args);
+ if (settings_->temperature_unit != temperature_unit) {
+ settings_->temperature_unit = temperature_unit;
+ UpdateSettings();
+ }
}
void AmbientModeHandler::HandleSetSelectedAlbums(const base::ListValue* args) {
@@ -344,6 +371,10 @@ void AmbientModeHandler::SendRecentHighlightsPreviews() {
}
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();
@@ -356,7 +387,10 @@ void AmbientModeHandler::UpdateSettings() {
has_pending_updates_for_backend_ = false;
is_updating_backend_ = true;
- DCHECK(settings_);
+ // 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,
@@ -472,14 +506,9 @@ void AmbientModeHandler::OnSettingsAndAlbumsFetched(
SendTopicSource();
SendTemperatureUnit();
- // Explicitly enable the weather settings if necessary to make sure we
- // can always get weather info in the response. Leaving this settings as
- // default could result in unpredictable behavior (b/158630188). Note that
- // right now the weather info is designed to be always shown on ambient
- // screen, so we don't expose an option in ambient Settings for users to
- // switch it off.
- if (!settings_->show_weather) {
- settings_->show_weather = true;
+ // If weather info is disabled, call |UpdateSettings| immediately to force
+ // it to true.
+ if (!settings_->show_weather && IsAmbientModeEnabled()) {
UpdateSettings();
}
return;
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
index 13d8f5d269f..02bf9b79e4b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h
@@ -12,6 +12,7 @@
#include "base/memory/weak_ptr.h"
#include "base/optional.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"
namespace ash {
@@ -26,6 +27,8 @@ namespace gfx {
class ImageSkia;
} // namespace gfx
+class PrefService;
+
namespace chromeos {
namespace settings {
@@ -33,19 +36,23 @@ namespace settings {
// photo frame and other related functionalities.
class AmbientModeHandler : public ::settings::SettingsPageUIHandler {
public:
- AmbientModeHandler();
+ 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 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::ListValue* args);
@@ -162,6 +169,10 @@ class AmbientModeHandler : public ::settings::SettingsPageUIHandler {
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>
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
index d84e435ea89..8cce4c904f5 100644
--- 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
@@ -6,11 +6,14 @@
#include <memory>
+#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 "ash/public/cpp/test/test_image_downloader.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"
@@ -24,7 +27,8 @@ const char kWebCallbackFunctionName[] = "cr.webUIListenerCallback";
class TestAmbientModeHandler : public AmbientModeHandler {
public:
- TestAmbientModeHandler() = default;
+ explicit TestAmbientModeHandler(PrefService* pref_service)
+ : AmbientModeHandler(pref_service) {}
~TestAmbientModeHandler() override = default;
// Make public for testing.
@@ -42,7 +46,13 @@ class AmbientModeHandlerTest : public testing::Test {
void SetUp() override {
web_ui_ = std::make_unique<content::TestWebUI>();
- handler_ = std::make_unique<TestAmbientModeHandler>();
+ 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();
@@ -51,12 +61,23 @@ class AmbientModeHandlerTest : public testing::Test {
image_downloader_ = std::make_unique<ash::TestImageDownloader>();
}
+ void TearDown() override { handler_->DisallowJavascript(); }
+
content::TestWebUI* web_ui() { return web_ui_.get(); }
const base::HistogramTester& histogram_tester() const {
return histogram_tester_;
}
+ base::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();
@@ -64,6 +85,13 @@ class AmbientModeHandlerTest : public testing::Test {
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() {
base::ListValue args;
handler_->HandleRequestSettings(&args);
@@ -75,6 +103,10 @@ class AmbientModeHandlerTest : public testing::Test {
handler_->HandleRequestAlbums(&args);
}
+ void HandleSetSelectedTemperatureUnit(const base::ListValue* args) {
+ handler_->HandleSetSelectedTemperatureUnit(args);
+ }
+
void HandleSetSelectedAlbums(const base::ListValue* args) {
handler_->HandleSetSelectedAlbums(args);
}
@@ -118,8 +150,11 @@ class AmbientModeHandlerTest : public testing::Test {
return fake_backend_controller_->IsFetchSettingsAndAlbumsPending();
}
- void ReplyFetchSettingsAndAlbums(bool success) {
- fake_backend_controller_->ReplyFetchSettingsAndAlbums(success);
+ void ReplyFetchSettingsAndAlbums(
+ bool success,
+ base::Optional<ash::AmbientSettings> settings = base::nullopt) {
+ fake_backend_controller_->ReplyFetchSettingsAndAlbums(success,
+ std::move(settings));
}
bool IsUpdateSettingsPendingAtBackend() const {
@@ -223,6 +258,7 @@ class AmbientModeHandlerTest : public testing::Test {
std::unique_ptr<ash::TestImageDownloader> image_downloader_;
std::unique_ptr<TestAmbientModeHandler> handler_;
base::HistogramTester histogram_tester_;
+ std::unique_ptr<TestingPrefServiceSimple> test_pref_service_;
};
TEST_F(AmbientModeHandlerTest, TestSendTemperatureUnitAndTopicSource) {
@@ -735,5 +771,84 @@ TEST_F(AmbientModeHandlerTest, TestAlbumNumbersAreRecorded) {
/*count=*/1);
}
+TEST_F(AmbientModeHandlerTest, TestTemperatureUnitChangeUpdatesSettings) {
+ SetTemperatureUnit(ash::AmbientModeTemperatureUnit::kCelsius);
+
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+
+ base::ListValue args;
+ args.Append("fahrenheit");
+
+ HandleSetSelectedTemperatureUnit(&args);
+
+ 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::ListValue args;
+ args.Append("celsius");
+
+ HandleSetSelectedTemperatureUnit(&args);
+
+ 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 df482d3555e..9ddec3c9294 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
@@ -6,9 +6,13 @@
#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/chromeos/arc/arc_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" // kSettingsAppId
+#include "components/services/app_service/public/cpp/intent_util.h"
#include "content/public/browser/web_contents.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
@@ -17,10 +21,9 @@
namespace chromeos {
namespace settings {
-AndroidAppsHandler::AndroidAppsHandler(Profile* profile)
- : arc_prefs_observer_(this),
- arc_session_manager_observer_(this),
- profile_(profile) {}
+AndroidAppsHandler::AndroidAppsHandler(Profile* profile,
+ apps::AppServiceProxy* app_service_proxy)
+ : profile_(profile), app_service_proxy_(app_service_proxy) {}
AndroidAppsHandler::~AndroidAppsHandler() {}
@@ -34,24 +37,20 @@ void AndroidAppsHandler::RegisterMessages() {
"showAndroidAppsSettings",
base::BindRepeating(&AndroidAppsHandler::ShowAndroidAppsSettings,
weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
- "showAndroidManageAppLinks",
- base::BindRepeating(&AndroidAppsHandler::ShowAndroidManageAppLinks,
- weak_ptr_factory_.GetWeakPtr()));
}
void AndroidAppsHandler::OnJavascriptAllowed() {
ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_);
if (arc_prefs) {
- arc_prefs_observer_.Add(arc_prefs);
+ arc_prefs_observation_.Observe(arc_prefs);
// arc::ArcSessionManager is associated with primary profile.
- arc_session_manager_observer_.Add(arc::ArcSessionManager::Get());
+ arc_session_manager_observation_.Observe(arc::ArcSessionManager::Get());
}
}
void AndroidAppsHandler::OnJavascriptDisallowed() {
- arc_prefs_observer_.RemoveAll();
- arc_session_manager_observer_.RemoveAll();
+ arc_prefs_observation_.Reset();
+ arc_session_manager_observation_.Reset();
}
void AndroidAppsHandler::OnAppRegistered(
@@ -111,17 +110,10 @@ void AndroidAppsHandler::ShowAndroidAppsSettings(const base::ListValue* args) {
args->GetBoolean(0, &activated_from_keyboard);
int flags = activated_from_keyboard ? ui::EF_NONE : ui::EF_LEFT_MOUSE_BUTTON;
- arc::LaunchAndroidSettingsApp(profile_, flags,
- GetDisplayIdForCurrentProfile());
-}
-
-void AndroidAppsHandler::ShowAndroidManageAppLinks(
- const base::ListValue* args) {
- DCHECK_EQ(0U, args->GetSize());
-
- arc::LaunchSettingsAppActivity(profile_, arc::kSettingsAppDomainUrlActivity,
- ui::EF_NONE /* flags */,
- GetDisplayIdForCurrentProfile());
+ 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 f6b0242c4a2..c1811b1d019 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,7 +10,8 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
+#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager_observer.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
@@ -29,7 +30,8 @@ class AndroidAppsHandler : public ::settings::SettingsPageUIHandler,
public ArcAppListPrefs::Observer,
public arc::ArcSessionManagerObserver {
public:
- explicit AndroidAppsHandler(Profile* profile);
+ explicit AndroidAppsHandler(Profile* profile,
+ apps::AppServiceProxy* app_service_proxy);
~AndroidAppsHandler() override;
// SettingsPageUIHandler
@@ -53,14 +55,15 @@ class AndroidAppsHandler : public ::settings::SettingsPageUIHandler,
void HandleAppChanged(const std::string& app_id);
void SendAndroidAppsInfo();
void ShowAndroidAppsSettings(const base::ListValue* args);
- void ShowAndroidManageAppLinks(const base::ListValue* args);
int64_t GetDisplayIdForCurrentProfile();
- ScopedObserver<ArcAppListPrefs, ArcAppListPrefs::Observer>
- arc_prefs_observer_;
- ScopedObserver<arc::ArcSessionManager, arc::ArcSessionManagerObserver>
- arc_session_manager_observer_;
+ base::ScopedObservation<ArcAppListPrefs, ArcAppListPrefs::Observer>
+ arc_prefs_observation_{this};
+ base::ScopedObservation<arc::ArcSessionManager,
+ arc::ArcSessionManagerObserver>
+ arc_session_manager_observation_{this};
Profile* profile_; // unowned
+ apps::AppServiceProxy* app_service_proxy_;
base::WeakPtrFactory<AndroidAppsHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(AndroidAppsHandler);
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/app_management/DIR_METADATA b/chromium/chrome/browser/ui/webui/settings/chromeos/app_management/DIR_METADATA
new file mode 100644
index 00000000000..cf53beece28
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/app_management/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "Platform>Apps>Foundation"
+}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/app_management/OWNERS b/chromium/chrome/browser/ui/webui/settings/chromeos/app_management/OWNERS
index 94b2e07d850..b784206d95d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/app_management/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/app_management/OWNERS
@@ -1,4 +1,2 @@
dominickn@chromium.org
jshikaram@chromium.org
-
-# COMPONENT: Platform>Apps>Foundation
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 bde3ac471f3..13a569f6124 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/apps_section.h"
+#include "ash/constants/ash_features.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
@@ -14,13 +15,13 @@
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/webui/app_management/app_management_page_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h"
+#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/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/os_settings_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/arc/arc_prefs.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -131,7 +132,37 @@ void AddAppManagementStrings(content::WebUIDataSource* html_source) {
{"appManagementStoragePermissionLabel", IDS_APP_MANAGEMENT_STORAGE},
{"appManagementUninstallLabel", IDS_APP_MANAGEMENT_UNINSTALL_APP},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
+}
+
+void AddGuestOsStrings(content::WebUIDataSource* html_source) {
+ // These strings are used for both Crostini and Plugin VM.
+ static constexpr webui::LocalizedString kLocalizedStrings[] = {
+ {"guestOsSharedPaths", IDS_SETTINGS_GUEST_OS_SHARED_PATHS},
+ {"guestOsSharedPathsListHeading",
+ IDS_SETTINGS_GUEST_OS_SHARED_PATHS_LIST_HEADING},
+ {"guestOsSharedPathsInstructionsRemove",
+ IDS_SETTINGS_GUEST_OS_SHARED_PATHS_INSTRUCTIONS_REMOVE},
+ {"guestOsSharedPathsStopSharing",
+ IDS_SETTINGS_GUEST_OS_SHARED_PATHS_STOP_SHARING},
+ {"guestOsSharedPathsRemoveFailureDialogTitle",
+ IDS_SETTINGS_GUEST_OS_SHARED_PATHS_REMOVE_FAILURE_DIALOG_TITLE},
+ {"guestOsSharedPathsRemoveFailureTryAgain",
+ IDS_SETTINGS_GUEST_OS_SHARED_PATHS_REMOVE_FAILURE_TRY_AGAIN},
+ {"guestOsSharedPathsListEmptyMessage",
+ IDS_SETTINGS_GUEST_OS_SHARED_PATHS_LIST_EMPTY_MESSAGE},
+ {"guestOsSharedUsbDevicesLabel",
+ IDS_SETTINGS_GUEST_OS_SHARED_USB_DEVICES_LABEL},
+ {"guestOsSharedUsbDevicesExtraDescription",
+ IDS_SETTINGS_GUEST_OS_SHARED_USB_DEVICES_EXTRA_DESCRIPTION},
+ {"guestOsSharedUsbDevicesListEmptyMessage",
+ IDS_SETTINGS_GUEST_OS_SHARED_USB_DEVICES_LIST_EMPTY_MESSAGE},
+ {"guestOsSharedUsbDevicesInUse",
+ IDS_SETTINGS_GUEST_OS_SHARED_USB_DEVICES_IN_USE},
+ {"guestOsSharedUsbDevicesReassign",
+ IDS_SETTINGS_GUEST_OS_SHARED_USB_DEVICES_REASSIGN},
+ };
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
bool ShowPluginVm(const Profile* profile, const PrefService& pref_service) {
@@ -146,10 +177,12 @@ bool ShowPluginVm(const Profile* profile, const PrefService& pref_service) {
AppsSection::AppsSection(Profile* profile,
SearchTagRegistry* search_tag_registry,
PrefService* pref_service,
- ArcAppListPrefs* arc_app_list_prefs)
+ ArcAppListPrefs* arc_app_list_prefs,
+ apps::AppServiceProxy* app_service_proxy)
: OsSettingsSection(profile, search_tag_registry),
pref_service_(pref_service),
- arc_app_list_prefs_(arc_app_list_prefs) {
+ arc_app_list_prefs_(arc_app_list_prefs),
+ app_service_proxy_(app_service_proxy) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.AddSearchTags(GetAppsSearchConcepts());
@@ -179,7 +212,7 @@ void AppsSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"appsPageTitle", IDS_SETTINGS_APPS_TITLE},
{"appManagementTitle", IDS_SETTINGS_APPS_LINK_TEXT},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
// We have 2 variants of Android apps settings. Default case, when the Play
// Store app exists we show expandable section that allows as to
@@ -196,17 +229,19 @@ void AppsSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
AppManagementPageHandler::IsCurrentArcVersionSupported(profile()));
AddAppManagementStrings(html_source);
+ AddGuestOsStrings(html_source);
AddAndroidAppStrings(html_source);
AddPluginVmLoadTimeData(html_source);
}
void AppsSection::AddHandlers(content::WebUI* web_ui) {
web_ui->AddMessageHandler(
- std::make_unique<chromeos::settings::AndroidAppsHandler>(profile()));
+ std::make_unique<chromeos::settings::AndroidAppsHandler>(
+ profile(), app_service_proxy_));
if (ShowPluginVm(profile(), *pref_service_)) {
- web_ui->AddMessageHandler(
- std::make_unique<chromeos::settings::PluginVmHandler>(profile()));
+ web_ui->AddMessageHandler(std::make_unique<GuestOsHandler>(profile()));
+ web_ui->AddMessageHandler(std::make_unique<PluginVmHandler>(profile()));
}
}
@@ -246,14 +281,13 @@ void AppsSection::RegisterHierarchy(HierarchyGenerator* generator) const {
IDS_SETTINGS_APP_DETAILS_TITLE, mojom::Subpage::kAppDetails,
mojom::Subpage::kAppManagement, mojom::SearchResultIcon::kAppsGrid,
mojom::SearchResultDefaultRank::kMedium, mojom::kAppDetailsSubpagePath);
- generator->RegisterNestedSubpage(IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS,
- mojom::Subpage::kPluginVmSharedPaths,
- mojom::Subpage::kAppManagement,
- mojom::SearchResultIcon::kAppsGrid,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::kPluginVmSharedPathsSubpagePath);
generator->RegisterNestedSubpage(
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_USB_DEVICES_LABEL,
+ IDS_SETTINGS_GUEST_OS_SHARED_PATHS, mojom::Subpage::kPluginVmSharedPaths,
+ mojom::Subpage::kAppManagement, mojom::SearchResultIcon::kAppsGrid,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kPluginVmSharedPathsSubpagePath);
+ generator->RegisterNestedSubpage(
+ IDS_SETTINGS_GUEST_OS_SHARED_USB_DEVICES_LABEL,
mojom::Subpage::kPluginVmUsbPreferences, mojom::Subpage::kAppManagement,
mojom::SearchResultIcon::kAppsGrid,
mojom::SearchResultDefaultRank::kMedium,
@@ -293,9 +327,8 @@ void AppsSection::AddAndroidAppStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_ANDROID_APPS_DISABLE_DIALOG_MESSAGE},
{"androidAppsDisableDialogRemove",
IDS_SETTINGS_ANDROID_APPS_DISABLE_DIALOG_REMOVE},
- {"androidAppsManageAppLinks", IDS_SETTINGS_ANDROID_APPS_MANAGE_APP_LINKS},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddLocalizedString("androidAppsPageTitle",
arc::IsPlayStoreAvailable()
? IDS_SETTINGS_ANDROID_APPS_TITLE
@@ -310,35 +343,12 @@ void AppsSection::AddAndroidAppStrings(content::WebUIDataSource* html_source) {
void AppsSection::AddPluginVmLoadTimeData(
content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"pluginVmSharedPaths", IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS},
- {"pluginVmSharedPathsListHeading",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS_LIST_HEADING},
{"pluginVmSharedPathsInstructionsAdd",
IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS_INSTRUCTIONS_ADD},
- {"pluginVmSharedPathsInstructionsRemove",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS_INSTRUCTIONS_REMOVE},
- {"pluginVmSharedPathsRemoveSharing",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS_REMOVE_SHARING},
{"pluginVmSharedPathsRemoveFailureDialogMessage",
IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS_REMOVE_FAILURE_DIALOG_MESSAGE},
- {"pluginVmSharedPathsRemoveFailureDialogTitle",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS_REMOVE_FAILURE_DIALOG_TITLE},
- {"pluginVmSharedPathsRemoveFailureTryAgain",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS_REMOVE_FAILURE_TRY_AGAIN},
- {"pluginVmSharedPathsListEmptyMessage",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_PATHS_LIST_EMPTY_MESSAGE},
- {"pluginVmSharedUsbDevicesLabel",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_USB_DEVICES_LABEL},
{"pluginVmSharedUsbDevicesDescription",
IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_USB_DEVICES_DESCRIPTION},
- {"pluginVmSharedUsbDevicesExtraDescription",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_USB_DEVICES_EXTRA_DESCRIPTION},
- {"pluginVmSharedUsbDevicesListEmptyMessage",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_USB_DEVICES_LIST_EMPTY_MESSAGE},
- {"pluginVmSharedUsbDevicesInUse",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_USB_DEVICES_IN_USE},
- {"pluginVmSharedUsbDevicesReassign",
- IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_USB_DEVICES_REASSIGN},
{"pluginVmPermissionDialogCameraLabel",
IDS_SETTINGS_APPS_PLUGIN_VM_PERMISSION_DIALOG_CAMERA_LABEL},
{"pluginVmPermissionDialogMicrophoneLabel",
@@ -346,7 +356,7 @@ void AppsSection::AddPluginVmLoadTimeData(
{"pluginVmPermissionDialogRelaunchButton",
IDS_SETTINGS_APPS_PLUGIN_VM_PERMISSION_DIALOG_RELAUNCH_BUTTON},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("showPluginVm",
ShowPluginVm(profile(), *pref_service_));
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h
index 4b36372c1b9..042ac25ac87 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_APPS_SECTION_H_
#include "base/values.h"
+#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "components/prefs/pref_change_registrar.h"
@@ -27,7 +28,8 @@ class AppsSection : public OsSettingsSection, public ArcAppListPrefs::Observer {
AppsSection(Profile* profile,
SearchTagRegistry* search_tag_registry,
PrefService* pref_service,
- ArcAppListPrefs* arc_app_list_prefs);
+ ArcAppListPrefs* arc_app_list_prefs,
+ apps::AppServiceProxy* app_service_proxy);
~AppsSection() override;
private:
@@ -52,6 +54,7 @@ class AppsSection : public OsSettingsSection, public ArcAppListPrefs::Observer {
PrefService* pref_service_;
ArcAppListPrefs* arc_app_list_prefs_;
+ apps::AppServiceProxy* app_service_proxy_;
PrefChangeRegistrar pref_change_registrar_;
};
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 24211deabe9..5cb7ace2c8f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc
@@ -125,8 +125,8 @@ BluetoothSection::BluetoothSection(Profile* profile,
// Note: May be uninitialized in tests.
if (bluez::BluezDBusManager::IsInitialized()) {
device::BluetoothAdapterFactory::Get()->GetAdapter(
- base::Bind(&BluetoothSection::OnFetchBluetoothAdapter,
- weak_ptr_factory_.GetWeakPtr()));
+ base::BindOnce(&BluetoothSection::OnFetchBluetoothAdapter,
+ weak_ptr_factory_.GetWeakPtr()));
}
}
@@ -190,7 +190,7 @@ void BluetoothSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"bluetoothDeviceType_unknown",
IDS_BLUETOOTH_ACCESSIBILITY_DEVICE_TYPE_UNKNOWN},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
chromeos::bluetooth_dialog::AddLocalizedStrings(html_source);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc
index 21bdb9b8d10..eef4fac6f63 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.cc
@@ -179,11 +179,11 @@ void BrowsingDataSizeCalculator::PerformCalculation() {
new browsing_data::IndexedDBHelper(storage_partition),
browsing_data::FileSystemHelper::Create(
storage_partition->GetFileSystemContext(),
- browsing_data_file_system_util::GetAdditionalFileSystemTypes()),
+ browsing_data_file_system_util::GetAdditionalFileSystemTypes(),
+ storage_partition->GetNativeIOContext()),
new browsing_data::ServiceWorkerHelper(
storage_partition->GetServiceWorkerContext()),
- new browsing_data::CacheStorageHelper(
- storage_partition->GetCacheStorageContext()));
+ new browsing_data::CacheStorageHelper(storage_partition));
}
site_data_size_collector_->Fetch(
base::BindOnce(&BrowsingDataSizeCalculator::OnGetBrowsingDataSize,
@@ -239,7 +239,7 @@ void AppsSizeCalculator::OnConnectionClosed() {
void AppsSizeCalculator::AddObserver(SizeCalculator::Observer* observer) {
// Start observing arc mojo connection when the first observer is added, to
// allow the calculation of android apps.
- if (!observers_.might_have_observers()) {
+ if (observers_.empty()) {
arc::ArcServiceManager::Get()
->arc_bridge_service()
->storage_manager()
@@ -251,7 +251,7 @@ void AppsSizeCalculator::AddObserver(SizeCalculator::Observer* observer) {
void AppsSizeCalculator::RemoveObserver(SizeCalculator::Observer* observer) {
observers_.RemoveObserver(observer);
// Stop observing arc connection if all observers have been removed.
- if (!observers_.might_have_observers()) {
+ if (observers_.empty()) {
arc::ArcServiceManager::Get()
->arc_bridge_service()
->storage_manager()
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 643158423b7..8f203997c01 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,6 +7,7 @@
#include <memory>
#include <utility>
+#include "ash/components/audio/sounds.h"
#include "base/base64.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
@@ -20,12 +21,12 @@
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
+#include "chrome/browser/ash/accessibility/accessibility_manager.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/camera_presence_notifier.h"
#include "chrome/browser/chromeos/login/users/avatar/user_image_manager.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/default_user_image/default_user_images.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
@@ -34,7 +35,6 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/audio/chromeos_sounds.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_image/user_image.h"
#include "components/user_manager/user_manager.h"
@@ -49,13 +49,14 @@
#include "ui/views/widget/widget.h"
#include "url/gurl.h"
-using content::BrowserThread;
-
namespace chromeos {
namespace settings {
-
namespace {
+using ::ash::AccessibilityManager;
+using ::ash::PlaySoundOption;
+using ::content::BrowserThread;
+
// Returns info about extensions for files we support as user images.
ui::SelectFileDialog::FileTypeInfo GetUserImageFileTypeInfo() {
ui::SelectFileDialog::FileTypeInfo file_type_info;
@@ -84,9 +85,9 @@ ChangePictureHandler::ChangePictureHandler()
: previous_image_index_(user_manager::User::USER_IMAGE_INVALID) {
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
audio::SoundsManager* manager = audio::SoundsManager::Get();
- manager->Initialize(SOUND_OBJECT_DELETE,
+ manager->Initialize(static_cast<int>(Sound::kObjectDelete),
bundle.GetRawDataResource(IDR_SOUND_OBJECT_DELETE_WAV));
- manager->Initialize(SOUND_CAMERA_SNAP,
+ manager->Initialize(static_cast<int>(Sound::kCameraSnap),
bundle.GetRawDataResource(IDR_SOUND_CAMERA_SNAP_WAV));
}
@@ -121,13 +122,18 @@ void ChangePictureHandler::RegisterMessages() {
}
void ChangePictureHandler::OnJavascriptAllowed() {
- user_manager_observer_.Add(user_manager::UserManager::Get());
- camera_observer_.Add(CameraPresenceNotifier::GetInstance());
+ user_manager_observation_.Observe(user_manager::UserManager::Get());
+ camera_observation_.Observe(CameraPresenceNotifier::GetInstance());
}
void ChangePictureHandler::OnJavascriptDisallowed() {
- user_manager_observer_.Remove(user_manager::UserManager::Get());
- camera_observer_.Remove(CameraPresenceNotifier::GetInstance());
+ DCHECK(user_manager_observation_.IsObservingSource(
+ user_manager::UserManager::Get()));
+ user_manager_observation_.Reset();
+
+ DCHECK(camera_observation_.IsObservingSource(
+ CameraPresenceNotifier::GetInstance()));
+ camera_observation_.Reset();
}
void ChangePictureHandler::SendDefaultImages() {
@@ -164,13 +170,13 @@ void ChangePictureHandler::HandleChooseFile(const base::ListValue* args) {
void ChangePictureHandler::HandleDiscardPhoto(const base::ListValue* args) {
DCHECK(args->empty());
AccessibilityManager::Get()->PlayEarcon(
- SOUND_OBJECT_DELETE, PlaySoundOption::ONLY_IF_SPOKEN_FEEDBACK_ENABLED);
+ Sound::kObjectDelete, PlaySoundOption::kOnlyIfSpokenFeedbackEnabled);
}
void ChangePictureHandler::HandlePhotoTaken(const base::ListValue* args) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
AccessibilityManager::Get()->PlayEarcon(
- SOUND_CAMERA_SNAP, PlaySoundOption::ONLY_IF_SPOKEN_FEEDBACK_ENABLED);
+ Sound::kCameraSnap, PlaySoundOption::kOnlyIfSpokenFeedbackEnabled);
std::string image_url;
if (!args || args->GetSize() != 1 || !args->GetString(0, &image_url))
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 1be240f6115..e18ab47d0a1 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
@@ -7,7 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/camera_presence_notifier.h"
#include "chrome/browser/image_decoder/image_decoder.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -139,10 +139,12 @@ class ChangePictureHandler : public ::settings::SettingsPageUIHandler,
// Data for |user_photo_|.
scoped_refptr<base::RefCountedBytes> user_photo_data_;
- ScopedObserver<user_manager::UserManager, user_manager::UserManager::Observer>
- user_manager_observer_{this};
- ScopedObserver<CameraPresenceNotifier, CameraPresenceNotifier::Observer>
- camera_observer_{this};
+ base::ScopedObservation<user_manager::UserManager,
+ user_manager::UserManager::Observer>
+ user_manager_observation_{this};
+ base::ScopedObservation<CameraPresenceNotifier,
+ CameraPresenceNotifier::Observer>
+ camera_observation_{this};
base::WeakPtrFactory<ChangePictureHandler> weak_ptr_factory_{this};
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 a2ed7dabcb8..af9c1c98b41 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/BUILD.gn
@@ -2,9 +2,10 @@
# 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)
+assert(is_chromeos_ash)
mojom("mojom") {
sources = [
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 af0e17ae34b..94db45d7cc1 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom
@@ -28,6 +28,7 @@ enum Section {
kReset = 16,
kAboutChromeOs = 17,
kKerberos = 18,
+ kOnStartup = 19,
};
// Chrome OS Settings subpages (i.e., nested pages within a section). Each
@@ -79,6 +80,7 @@ enum Subpage {
// Note: Value 502 was for deprecated kAmbientModePhotos. Do not reuse.
kAmbientModeGooglePhotosAlbum = 503,
kAmbientModeArtGalleryAlbum = 504,
+ kWallpaper = 505,
// Search and Assistant section.
kAssistant = 600,
@@ -103,7 +105,10 @@ enum Subpage {
// Date and Time section.
kTimeZone = 1000,
- // Note: Privacy section has no subpages.
+ // Privacy section.
+ kManageOtherPeopleV2 = 1100,
+ kSecurityAndSignInV2 = 1101,
+ kFingerprintV2 = 1102,
// Languages and Input section.
kLanguagesAndInputDetails = 1200,
@@ -142,6 +147,7 @@ const string kEthernetDetailsSubpagePath = "networkDetail";
const string kWifiNetworksSubpagePath = "networks?type=WiFi";
const string kWifiDetailsSubpagePath = "networkDetail";
const string kKnownNetworksSubpagePath = "knownNetworks";
+const string kCellularNetworksSubpagePath = "networks?type=Cellular";
const string kMobileDataNetworksSubpagePath = "networks?type=Tether";
const string kCellularDetailsSubpagePath = "networkDetail";
const string kTetherDetailsSubpagePath = "networkDetail";
@@ -181,6 +187,7 @@ const string kPowerSubpagePath = "power";
// Personalization section.
const string kPersonalizationSectionPath = "personalization";
const string kChangePictureSubpagePath = "changePicture";
+const string kWallpaperSubpagePath = "wallpaper";
const string kAmbientModeSubpagePath = "ambientMode";
const string kAmbientModeGooglePhotosAlbumSubpagePath =
"ambientMode/photos?topicSource=0";
@@ -210,12 +217,18 @@ const string kCrostiniBackupAndRestoreSubpagePath = "crostini/exportImport";
const string kCrostiniDevelopAndroidAppsSubpagePath = "crostini/androidAdb";
const string kCrostiniPortForwardingSubpagePath = "crostini/portForwarding";
+// On Startup section.
+const string kOnStartupSectionPath = "onstartup";
+
// Date and Time section.
const string kDateAndTimeSectionPath = "dateTime";
const string kTimeZoneSubpagePath = "dateTime/timeZone";
// Privacy and Security section.
const string kPrivacyAndSecuritySectionPath = "osPrivacy";
+const string kManageOtherPeopleSubpagePathV2 = "osPrivacy/accounts";
+const string kSecurityAndSignInSubpagePathV2 = "osPrivacy/lockScreen";
+const string kFingerprintSubpagePathV2 = "osPrivacy/lockScreen/fingerprint";
// Languages and Input section.
const string kLanguagesAndInputSectionPath = "osLanguages";
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 9bd8c2c611a..ee8497629a5 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc
@@ -61,6 +61,7 @@ bool IsOSSettingsSubPage(const std::string& sub_page) {
// Personalization section.
chromeos::settings::mojom::kPersonalizationSectionPath,
chromeos::settings::mojom::kChangePictureSubpagePath,
+ chromeos::settings::mojom::kWallpaperSubpagePath,
chromeos::settings::mojom::kAmbientModeSubpagePath,
// Search and Assistant section.
@@ -83,6 +84,9 @@ bool IsOSSettingsSubPage(const std::string& sub_page) {
chromeos::settings::mojom::kCrostiniDevelopAndroidAppsSubpagePath,
chromeos::settings::mojom::kCrostiniPortForwardingSubpagePath,
+ // On Startup section.
+ chromeos::settings::mojom::kOnStartupSectionPath,
+
// Date and Time section.
chromeos::settings::mojom::kDateAndTimeSectionPath,
chromeos::settings::mojom::kTimeZoneSubpagePath,
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 f2a4881ed69..e975fd423ec 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom
@@ -5,7 +5,8 @@
module chromeos.settings.mojom;
// Enumeration of each setting in the Chrome OS Settings app. Numerical values
-// are used for metrics; do not change or reuse values.
+// are used for metrics; do not change or reuse values. Add new values to the
+// OsSetting enum in tools/metrics/histograms/enums.xml.
enum Setting {
// Network section.
kConfigureEthernet = 0,
@@ -61,6 +62,10 @@ enum Setting {
// Do not reuse.
kPhoneHubTaskContinuationOnOff = 212,
kWifiSyncOnOff = 213,
+ kNearbyShareDeviceName = 214,
+ kNearbyShareDeviceVisibility = 215,
+ kNearbyShareContacts = 216,
+ kNearbyShareDataUsage = 217,
// People section.
kAddAccount = 300,
@@ -121,6 +126,9 @@ enum Setting {
kNightLightColorTemperature = 432,
kPowerIdleBehaviorWhileOnBattery = 433,
kDisplayOverscan = 434,
+ kPointingStickSpeed = 435,
+ kPointingStickAcceleration = 436,
+ kPointingStickSwapPrimaryButtons = 437,
// Personalization section.
kOpenWallpaper = 500,
@@ -134,7 +142,8 @@ enum Setting {
kPreferredSearchEngine = 600,
kAssistantOnOff = 601,
kAssistantRelatedInfo = 602,
- kAssistantQuickAnswers = 603,
+ // Note: Value 603 was for deprecated kAssistantQuickAnswers.
+ // Do not reuse.
kAssistantOkGoogle = 604,
kAssistantNotifications = 605,
kAssistantVoiceInput = 606,
@@ -167,6 +176,16 @@ enum Setting {
// see https://bugs.chromium.org/p/chromium/issues/detail?id=1077126.
// Do not reuse.
kUsageStatsAndCrashReports = 1103,
+ kGuestBrowsingV2 = 1104,
+ kShowUsernamesAndPhotosAtSignInV2 = 1105,
+ kRestrictSignInV2 = 1106,
+ kAddToUserAllowlistV2 = 1107,
+ kRemoveFromUserAllowlistV2 = 1108,
+ kLockScreenV2 = 1109,
+ kChangeAuthPinV2 = 1110,
+ kAddFingerprintV2 = 1111,
+ kRemoveFingerprintV2 = 1112,
+ kPeripheralDataAccessProtection = 1113,
// Languages and Input section.
kAddLanguage = 1200,
@@ -185,6 +204,7 @@ enum Setting {
kAddPrinter = 1400,
kSavedPrinters = 1401,
kPrintJobs = 1402,
+ kScanningApp = 1403,
// Accessibility section.
kA11yQuickSettings = 1500,
@@ -214,9 +234,10 @@ enum Setting {
kSwitchActionAutoScan = 1524,
kSwitchActionAutoScanKeyboard = 1525,
kGetImageDescriptionsFromGoogle = 1526,
- kLiveCaptions = 1527,
+ kLiveCaption = 1527,
kEnableCursorColor = 1528,
kFullscreenMagnifierFocusFollowing = 1529,
+ kFullscreenMagnifierMouseFollowingMode = 1530,
// Reset section.
kPowerwash = 1600,
@@ -229,9 +250,13 @@ enum Setting {
kGetHelpWithChromeOs = 1704,
kReportAnIssue = 1705,
kTermsOfService = 1706,
+ kDiagnostics = 1707,
// Kerberos section.
kAddKerberosTicketV2 = 1800,
kRemoveKerberosTicketV2 = 1801,
kSetActiveKerberosTicketV2 = 1802,
+
+ // On Startup section.
+ kRestoreAppsAndPages = 1900,
};
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 8dc3fcd3cd7..21eb8bd3b89 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
@@ -20,8 +20,6 @@
#include "chrome/browser/chromeos/crostini/crostini_types.mojom.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
-#include "chrome/browser/chromeos/guest_os/guest_os_share_path.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.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"
@@ -65,24 +63,6 @@ void CrostiniHandler::RegisterMessages() {
base::BindRepeating(&CrostiniHandler::HandleRequestRemoveCrostini,
weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
- "getCrostiniSharedPathsDisplayText",
- base::BindRepeating(
- &CrostiniHandler::HandleGetCrostiniSharedPathsDisplayText,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
- "removeCrostiniSharedPath",
- base::BindRepeating(&CrostiniHandler::HandleRemoveCrostiniSharedPath,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
- "notifyCrostiniSharedUsbDevicesPageReady",
- base::BindRepeating(
- &CrostiniHandler::HandleNotifyCrostiniSharedUsbDevicesPageReady,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
- "setCrostiniUsbDeviceShared",
- base::BindRepeating(&CrostiniHandler::HandleSetCrostiniUsbDeviceShared,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
"exportCrostiniContainer",
base::BindRepeating(&CrostiniHandler::HandleExportCrostiniContainer,
weak_ptr_factory_.GetWeakPtr()));
@@ -192,9 +172,6 @@ void CrostiniHandler::OnJavascriptAllowed() {
crostini_manager->AddContainerStartedObserver(this);
crostini_manager->AddContainerShutdownObserver(this);
crostini_manager->AddCrostiniMicSharingEnabledObserver(this);
- if (chromeos::CrosUsbDetector::Get()) {
- chromeos::CrosUsbDetector::Get()->AddUsbDeviceObserver(this);
- }
crostini::CrostiniExportImport::GetForProfile(profile_)->AddObserver(this);
crostini::CrostiniPortForwarder::GetForProfile(profile_)->AddObserver(this);
@@ -220,14 +197,11 @@ void CrostiniHandler::OnJavascriptDisallowed() {
crostini_manager->RemoveContainerStartedObserver(this);
crostini_manager->RemoveContainerShutdownObserver(this);
crostini_manager->RemoveCrostiniMicSharingEnabledObserver(this);
- if (chromeos::CrosUsbDetector::Get()) {
- chromeos::CrosUsbDetector::Get()->RemoveUsbDeviceObserver(this);
- }
crostini::CrostiniExportImport::GetForProfile(profile_)->RemoveObserver(this);
crostini::CrostiniPortForwarder::GetForProfile(profile_)->RemoveObserver(
this);
- adb_sideloading_device_policy_subscription_.reset();
+ adb_sideloading_device_policy_subscription_ = {};
pref_change_registrar_.RemoveAll();
}
@@ -244,63 +218,7 @@ void CrostiniHandler::HandleRequestRemoveCrostini(const base::ListValue* args) {
crostini::CrostiniUISurface::kSettings);
}
-void CrostiniHandler::HandleGetCrostiniSharedPathsDisplayText(
- const base::ListValue* args) {
- AllowJavascript();
- CHECK_EQ(2U, args->GetList().size());
- std::string callback_id = args->GetList()[0].GetString();
- base::Value::ConstListView paths = args->GetList()[1].GetList();
-
- base::ListValue texts;
- for (size_t i = 0; i < paths.size(); ++i) {
- texts.AppendString(file_manager::util::GetPathDisplayTextForSettings(
- profile_, paths[i].GetString()));
- }
- ResolveJavascriptCallback(base::Value(callback_id), texts);
-}
-
-void CrostiniHandler::HandleRemoveCrostiniSharedPath(
- const base::ListValue* args) {
- AllowJavascript();
- CHECK_EQ(3U, args->GetList().size());
- std::string callback_id = args->GetList()[0].GetString();
- std::string vm_name = args->GetList()[1].GetString();
- std::string path = args->GetList()[2].GetString();
-
- guest_os::GuestOsSharePath::GetForProfile(profile_)->UnsharePath(
- vm_name, base::FilePath(path),
- /*unpersist=*/true,
- base::BindOnce(&CrostiniHandler::OnCrostiniSharedPathRemoved,
- weak_ptr_factory_.GetWeakPtr(), callback_id, path));
-}
-
-void CrostiniHandler::OnCrostiniSharedPathRemoved(
- const std::string& callback_id,
- const std::string& path,
- bool result,
- const std::string& failure_reason) {
- if (!result) {
- LOG(ERROR) << "Error unsharing " << path << ": " << failure_reason;
- }
- ResolveJavascriptCallback(base::Value(callback_id), base::Value(result));
-}
-
namespace {
-base::ListValue UsbDevicesToListValue(
- const std::vector<CrosUsbDeviceInfo> shared_usbs) {
- base::ListValue usb_devices_list;
- for (auto& device : shared_usbs) {
- base::Value device_info(base::Value::Type::DICTIONARY);
- device_info.SetStringKey("guid", device.guid);
- device_info.SetStringKey("label", device.label);
- bool shared = device.shared_vm_name == crostini::kCrostiniDefaultVmName;
- device_info.SetBoolKey("shared", shared);
- device_info.SetBoolKey("shareWillReassign",
- device.shared_vm_name && !shared);
- usb_devices_list.Append(std::move(device_info));
- }
- return usb_devices_list;
-}
base::Value CrostiniDiskInfoToValue(
std::unique_ptr<crostini::CrostiniDiskInfo> disk_info) {
@@ -328,40 +246,6 @@ base::Value CrostiniDiskInfoToValue(
}
} // namespace
-void CrostiniHandler::HandleNotifyCrostiniSharedUsbDevicesPageReady(
- const base::ListValue* args) {
- AllowJavascript();
- OnUsbDevicesChanged();
-}
-
-void CrostiniHandler::HandleSetCrostiniUsbDeviceShared(
- const base::ListValue* args) {
- CHECK_EQ(2U, args->GetList().size());
- const auto& args_list = args->GetList();
- std::string guid = args_list[0].GetString();
- bool shared = args_list[1].GetBool();
-
- chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
- if (!detector)
- return;
-
- if (shared) {
- detector->AttachUsbDeviceToVm(crostini::kCrostiniDefaultVmName, guid,
- base::DoNothing());
- return;
- }
- detector->DetachUsbDeviceFromVm(crostini::kCrostiniDefaultVmName, guid,
- base::DoNothing());
-}
-
-void CrostiniHandler::OnUsbDevicesChanged() {
- chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
- DCHECK(detector); // This callback is called by the detector.
- FireWebUIListener(
- "crostini-shared-usb-devices-changed",
- UsbDevicesToListValue(detector->GetDevicesSharableWithCrostini()));
-}
-
void CrostiniHandler::HandleExportCrostiniContainer(
const base::ListValue* args) {
CHECK_EQ(0U, args->GetList().size());
@@ -618,8 +502,8 @@ void CrostiniHandler::HandleRemoveCrostiniPortForward(
crostini::ContainerId(std::move(vm_name), std::move(container_name)),
port_number,
static_cast<crostini::CrostiniPortForwarder::Protocol>(protocol_type),
- base::Bind(&CrostiniHandler::OnPortForwardComplete,
- weak_ptr_factory_.GetWeakPtr(), std::move(callback_id)));
+ base::BindOnce(&CrostiniHandler::OnPortForwardComplete,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback_id)));
}
void CrostiniHandler::HandleRemoveAllCrostiniPortForwards(
@@ -661,8 +545,8 @@ void CrostiniHandler::HandleActivateCrostiniPortForward(
crostini::ContainerId(std::move(vm_name), std::move(container_name)),
port_number,
static_cast<crostini::CrostiniPortForwarder::Protocol>(protocol_type),
- base::Bind(&CrostiniHandler::OnPortForwardComplete,
- weak_ptr_factory_.GetWeakPtr(), std::move(callback_id)));
+ base::BindOnce(&CrostiniHandler::OnPortForwardComplete,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback_id)));
}
void CrostiniHandler::HandleDeactivateCrostiniPortForward(
@@ -689,8 +573,8 @@ void CrostiniHandler::HandleDeactivateCrostiniPortForward(
crostini::ContainerId(std::move(vm_name), std::move(container_name)),
port_number,
static_cast<crostini::CrostiniPortForwarder::Protocol>(protocol_type),
- base::Bind(&CrostiniHandler::OnPortForwardComplete,
- weak_ptr_factory_.GetWeakPtr(), std::move(callback_id)));
+ base::BindOnce(&CrostiniHandler::OnPortForwardComplete,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback_id)));
}
void CrostiniHandler::OnPortForwardComplete(std::string callback_id,
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 3839b2fe3f8..2b59cce1bf3 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
@@ -8,11 +8,10 @@
#include <vector>
#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/chromeos/crostini/crostini_export_import.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_port_forwarder.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/chromeos/usb/cros_usb_detector.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/dbus/session_manager/session_manager_client.h"
#include "components/prefs/pref_change_registrar.h"
@@ -34,8 +33,7 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
public crostini::CrostiniMicSharingEnabledObserver,
public crostini::CrostiniPortForwarder::Observer,
public crostini::ContainerStartedObserver,
- public crostini::ContainerShutdownObserver,
- public chromeos::CrosUsbDeviceObserver {
+ public crostini::ContainerShutdownObserver {
public:
explicit CrostiniHandler(Profile* profile);
~CrostiniHandler() override;
@@ -48,23 +46,6 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
private:
void HandleRequestCrostiniInstallerView(const base::ListValue* args);
void HandleRequestRemoveCrostini(const base::ListValue* args);
- // Callback for the "getSharedPathsDisplayText" message. Converts actual
- // paths in chromeos to values suitable to display to users.
- // E.g. /home/chronos/u-<hash>/Downloads/foo => "Downloads > foo".
- void HandleGetCrostiniSharedPathsDisplayText(const base::ListValue* args);
- // Remove a specified path from being shared.
- void HandleRemoveCrostiniSharedPath(const base::ListValue* args);
- void OnCrostiniSharedPathRemoved(const std::string& callback_id,
- const std::string& path,
- bool result,
- const std::string& failure_reason);
- // Called when the shared USB devices page is ready.
- void HandleNotifyCrostiniSharedUsbDevicesPageReady(
- const base::ListValue* args);
- // Set the share state of a USB device.
- void HandleSetCrostiniUsbDeviceShared(const base::ListValue* args);
- // chromeos::SharedUsbDeviceObserver.
- void OnUsbDevicesChanged() override;
// Export the crostini container.
void HandleExportCrostiniContainer(const base::ListValue* args);
// Import the crostini container.
@@ -156,8 +137,7 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
void OnCanChangeArcAdbSideloading(bool can_change_arc_adb_sideloading);
Profile* profile_;
- std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
- adb_sideloading_device_policy_subscription_;
+ base::CallbackListSubscription adb_sideloading_device_policy_subscription_;
PrefChangeRegistrar pref_change_registrar_;
// weak_ptr_factory_ should always be last member.
base::WeakPtrFactory<CrostiniHandler> weak_ptr_factory_{this};
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 4e05e15ec74..def33547d14 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc
@@ -4,22 +4,23 @@
#include "chrome/browser/ui/webui/settings/chromeos/crostini_section.h"
+#include "ash/constants/ash_features.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/crostini/crostini_disk.h"
#include "chrome/browser/chromeos/crostini/crostini_features.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.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"
-#include "chromeos/constants/chromeos_features.h"
#include "components/arc/arc_prefs.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
@@ -37,11 +38,12 @@ const std::vector<SearchConcept>& GetCrostiniOptedInSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_CROSTINI,
mojom::kCrostiniDetailsSubpagePath,
- mojom::SearchResultIcon::kPenguin,
+ mojom::SearchResultIcon::kDeveloperTags,
mojom::SearchResultDefaultRank::kHigh,
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kCrostiniDetails},
- {IDS_OS_SETTINGS_TAG_CROSTINI_ALT1, SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_CROSTINI_ALT1, IDS_OS_SETTINGS_TAG_CROSTINI_ALT2,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_CROSTINI_USB_PREFERENCES,
mojom::kCrostiniUsbPreferencesSubpagePath,
mojom::SearchResultIcon::kPenguin,
@@ -52,7 +54,7 @@ const std::vector<SearchConcept>& GetCrostiniOptedInSearchConcepts() {
SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_CROSTINI_REMOVE,
mojom::kCrostiniDetailsSubpagePath,
- mojom::SearchResultIcon::kPenguin,
+ mojom::SearchResultIcon::kDeveloperTags,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kUninstallCrostini},
@@ -89,14 +91,15 @@ const std::vector<SearchConcept>& GetCrostiniOptedOutSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_CROSTINI,
mojom::kCrostiniSectionPath,
- mojom::SearchResultIcon::kPenguin,
+ mojom::SearchResultIcon::kDeveloperTags,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSection,
{.section = mojom::Section::kCrostini},
- {IDS_OS_SETTINGS_TAG_CROSTINI_ALT1, SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_CROSTINI_ALT1, IDS_OS_SETTINGS_TAG_CROSTINI_ALT2,
+ SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_CROSTINI_SETUP,
mojom::kCrostiniSectionPath,
- mojom::SearchResultIcon::kPenguin,
+ mojom::SearchResultIcon::kDeveloperTags,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kSetUpCrostini},
@@ -123,7 +126,7 @@ const std::vector<SearchConcept>& GetCrostiniAdbSideloadingSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_CROSTINI_ANDROID_APPS_ADB,
mojom::kCrostiniDevelopAndroidAppsSubpagePath,
- mojom::SearchResultIcon::kPenguin,
+ mojom::SearchResultIcon::kDeveloperTags,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kCrostiniAdbDebugging},
@@ -131,7 +134,7 @@ const std::vector<SearchConcept>& GetCrostiniAdbSideloadingSearchConcepts() {
SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_CROSTINI_ANDROID_APPS,
mojom::kCrostiniDevelopAndroidAppsSubpagePath,
- mojom::SearchResultIcon::kPenguin,
+ mojom::SearchResultIcon::kDeveloperTags,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kCrostiniDevelopAndroidApps},
@@ -233,23 +236,10 @@ void CrostiniSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"crostiniPageTitle", IDS_SETTINGS_CROSTINI_TITLE},
{"crostiniPageLabel", IDS_SETTINGS_CROSTINI_LABEL},
{"crostiniEnable", IDS_SETTINGS_TURN_ON},
- {"crostiniSharedPaths", IDS_SETTINGS_CROSTINI_SHARED_PATHS},
- {"crostiniSharedPathsListHeading",
- IDS_SETTINGS_CROSTINI_SHARED_PATHS_LIST_HEADING},
{"crostiniSharedPathsInstructionsAdd",
IDS_SETTINGS_CROSTINI_SHARED_PATHS_INSTRUCTIONS_ADD},
- {"crostiniSharedPathsInstructionsRemove",
- IDS_SETTINGS_CROSTINI_SHARED_PATHS_INSTRUCTIONS_REMOVE},
- {"crostiniSharedPathsRemoveSharing",
- IDS_SETTINGS_CROSTINI_SHARED_PATHS_REMOVE_SHARING},
{"crostiniSharedPathsRemoveFailureDialogMessage",
IDS_SETTINGS_CROSTINI_SHARED_PATHS_REMOVE_FAILURE_DIALOG_MESSAGE},
- {"crostiniSharedPathsRemoveFailureDialogTitle",
- IDS_SETTINGS_CROSTINI_SHARED_PATHS_REMOVE_FAILURE_DIALOG_TITLE},
- {"crostiniSharedPathsRemoveFailureTryAgain",
- IDS_SETTINGS_CROSTINI_SHARED_PATHS_REMOVE_FAILURE_TRY_AGAIN},
- {"crostiniSharedPathsListEmptyMessage",
- IDS_SETTINGS_CROSTINI_SHARED_PATHS_LIST_EMPTY_MESSAGE},
{"crostiniExportImportTitle", IDS_SETTINGS_CROSTINI_EXPORT_IMPORT_TITLE},
{"crostiniExport", IDS_SETTINGS_CROSTINI_EXPORT},
{"crostiniExportLabel", IDS_SETTINGS_CROSTINI_EXPORT_LABEL},
@@ -262,18 +252,8 @@ void CrostiniSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"crostiniImportConfirmationDialogConfirmationButton",
IDS_SETTINGS_CROSTINI_IMPORT},
{"crostiniRemoveButton", IDS_SETTINGS_CROSTINI_REMOVE_BUTTON},
- {"crostiniSharedUsbDevicesLabel",
- IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LABEL},
{"crostiniSharedUsbDevicesDescription",
IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_DESCRIPTION},
- {"crostiniSharedUsbDevicesExtraDescription",
- IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_EXTRA_DESCRIPTION},
- {"crostiniSharedUsbDevicesListEmptyMessage",
- IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LIST_EMPTY_MESSAGE},
- {"crostiniSharedUsbDevicesInUse",
- IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_IN_USE},
- {"crostiniSharedUsbDevicesReassign",
- IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_REASSIGN},
{"crostiniArcAdbTitle", IDS_SETTINGS_CROSTINI_ARC_ADB_TITLE},
{"crostiniArcAdbDescription", IDS_SETTINGS_CROSTINI_ARC_ADB_DESCRIPTION},
{"crostiniArcAdbLabel", IDS_SETTINGS_CROSTINI_ARC_ADB_LABEL},
@@ -367,13 +347,18 @@ void CrostiniSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"crostiniMicDialogLabel", IDS_SETTINGS_CROSTINI_MIC_DIALOG_LABEL},
{"crostiniMicDialogShutdownButton",
IDS_SETTINGS_CROSTINI_MIC_DIALOG_SHUTDOWN_BUTTON},
+ {"crostiniRemove", IDS_SETTINGS_CROSTINI_REMOVE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
- html_source->AddBoolean("showCrostini", IsCrostiniAllowed());
+ // Should the crostini section in settings be displayed?
+ html_source->AddBoolean(
+ "showCrostini",
+ crostini::CrostiniFeatures::Get()->CouldBeAllowed(profile()));
+ // Should we actually enable the button to install it?
html_source->AddBoolean(
"allowCrostini",
- crostini::CrostiniFeatures::Get()->IsUIAllowed(profile()));
+ crostini::CrostiniFeatures::Get()->IsAllowedNow(profile()));
html_source->AddString(
"crostiniSubtext",
@@ -385,9 +370,6 @@ void CrostiniSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
l10n_util::GetStringFUTF16(
IDS_SETTINGS_CROSTINI_ARC_ADB_POWERWASH_REQUIRED_SUBLABEL,
base::ASCIIToUTF16(chrome::kArcAdbSideloadingLearnMoreURL)));
- html_source->AddString("crostiniRemove", l10n_util::GetStringFUTF16(
- IDS_SETTINGS_CROSTINI_REMOVE,
- ui::GetChromeOSDeviceName()));
html_source->AddString(
"crostiniArcAdbConfirmationMessageEnable",
l10n_util::GetStringFUTF16(
@@ -430,8 +412,8 @@ void CrostiniSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
}
void CrostiniSection::AddHandlers(content::WebUI* web_ui) {
- if (crostini::CrostiniFeatures::Get()->IsUIAllowed(profile(),
- /*check_policy=*/false)) {
+ if (crostini::CrostiniFeatures::Get()->CouldBeAllowed(profile())) {
+ web_ui->AddMessageHandler(std::make_unique<GuestOsHandler>(profile()));
web_ui->AddMessageHandler(std::make_unique<CrostiniHandler>(profile()));
}
}
@@ -445,7 +427,7 @@ mojom::Section CrostiniSection::GetSection() const {
}
mojom::SearchResultIcon CrostiniSection::GetSectionIcon() const {
- return mojom::SearchResultIcon::kPenguin;
+ return mojom::SearchResultIcon::kDeveloperTags;
}
std::string CrostiniSection::GetSectionPath() const {
@@ -464,7 +446,7 @@ void CrostiniSection::RegisterHierarchy(HierarchyGenerator* generator) const {
// Crostini details.
generator->RegisterTopLevelSubpage(IDS_SETTINGS_CROSTINI_LABEL,
mojom::Subpage::kCrostiniDetails,
- mojom::SearchResultIcon::kPenguin,
+ mojom::SearchResultIcon::kDeveloperTags,
mojom::SearchResultDefaultRank::kMedium,
mojom::kCrostiniDetailsSubpagePath);
static constexpr mojom::Setting kCrostiniDetailsSettings[] = {
@@ -478,7 +460,7 @@ void CrostiniSection::RegisterHierarchy(HierarchyGenerator* generator) const {
// Manage shared folders.
generator->RegisterNestedSubpage(
- IDS_SETTINGS_CROSTINI_SHARED_PATHS,
+ IDS_SETTINGS_GUEST_OS_SHARED_PATHS,
mojom::Subpage::kCrostiniManageSharedFolders,
mojom::Subpage::kCrostiniDetails, mojom::SearchResultIcon::kPenguin,
mojom::SearchResultDefaultRank::kMedium,
@@ -486,7 +468,7 @@ void CrostiniSection::RegisterHierarchy(HierarchyGenerator* generator) const {
// USB preferences.
generator->RegisterNestedSubpage(
- IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LABEL,
+ IDS_SETTINGS_GUEST_OS_SHARED_USB_DEVICES_LABEL,
mojom::Subpage::kCrostiniUsbPreferences, mojom::Subpage::kCrostiniDetails,
mojom::SearchResultIcon::kPenguin,
mojom::SearchResultDefaultRank::kMedium,
@@ -510,7 +492,7 @@ void CrostiniSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterNestedSubpage(
IDS_SETTINGS_CROSTINI_ARC_ADB_TITLE,
mojom::Subpage::kCrostiniDevelopAndroidApps,
- mojom::Subpage::kCrostiniDetails, mojom::SearchResultIcon::kPenguin,
+ mojom::Subpage::kCrostiniDetails, mojom::SearchResultIcon::kDeveloperTags,
mojom::SearchResultDefaultRank::kMedium,
mojom::kCrostiniDevelopAndroidAppsSubpagePath);
generator->RegisterNestedSetting(mojom::Setting::kCrostiniAdbDebugging,
@@ -525,11 +507,6 @@ void CrostiniSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::kCrostiniPortForwardingSubpagePath);
}
-bool CrostiniSection::IsCrostiniAllowed() {
- return crostini::CrostiniFeatures::Get()->IsUIAllowed(profile(),
- /*check_policy=*/false);
-}
-
bool CrostiniSection::IsExportImportAllowed() {
return crostini::CrostiniFeatures::Get()->IsExportImportUIAllowed(profile());
}
@@ -553,7 +530,7 @@ void CrostiniSection::UpdateSearchTags() {
updater.RemoveSearchTags(GetCrostiniContainerUpgradeSearchConcepts());
updater.RemoveSearchTags(GetCrostiniDiskResizingSearchConcepts());
- if (!IsCrostiniAllowed())
+ if (!crostini::CrostiniFeatures::Get()->IsAllowedNow(profile()))
return;
if (!pref_service_->GetBoolean(crostini::prefs::kCrostiniEnabled)) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.h
index 98d353d0d27..ac0f74a9d7f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.h
@@ -39,7 +39,6 @@ class CrostiniSection : public OsSettingsSection {
bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
- bool IsCrostiniAllowed();
bool IsExportImportAllowed();
bool IsContainerUpgradeAllowed();
bool IsPortForwardingAllowed();
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 8c50f004d6b..9e831c79f9e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
@@ -7,6 +7,7 @@
#include <set>
#include <utility>
+#include "ash/constants/ash_features.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/containers/flat_map.h"
@@ -43,7 +44,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/constants/chromeos_features.h"
+#include "chromeos/components/scanning/scanning_uma.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
#include "chromeos/printing/ppd_line_reader.h"
@@ -268,8 +269,8 @@ CupsPrintersHandler::CupsPrintersHandler(
ppd_provider_(ppd_provider),
printer_configurer_(std::move(printer_configurer)),
printers_manager_(printers_manager),
- endpoint_resolver_(std::make_unique<local_discovery::EndpointResolver>()),
- printers_manager_observer_(this) {}
+ endpoint_resolver_(
+ std::make_unique<local_discovery::EndpointResolver>()) {}
// static
std::unique_ptr<CupsPrintersHandler> CupsPrintersHandler::CreateForTesting(
@@ -350,23 +351,25 @@ void CupsPrintersHandler::RegisterMessages() {
"queryPrintServer",
base::BindRepeating(&CupsPrintersHandler::HandleQueryPrintServer,
base::Unretained(this)));
- if (base::FeatureList::IsEnabled(
- chromeos::features::kPrintJobManagementApp)) {
+ web_ui()->RegisterMessageCallback(
+ "openPrintManagementApp",
+ base::BindRepeating(&CupsPrintersHandler::HandleOpenPrintManagementApp,
+ base::Unretained(this)));
+ if (base::FeatureList::IsEnabled(chromeos::features::kScanningUI)) {
web_ui()->RegisterMessageCallback(
- "openPrintManagementApp",
- base::BindRepeating(&CupsPrintersHandler::HandleOpenPrintManagementApp,
+ "openScanningApp",
+ base::BindRepeating(&CupsPrintersHandler::HandleOpenScanningApp,
base::Unretained(this)));
}
}
void CupsPrintersHandler::OnJavascriptAllowed() {
- if (!printers_manager_observer_.IsObservingSources()) {
- printers_manager_observer_.Add(printers_manager_);
- }
+ DCHECK(!printers_manager_observation_.IsObserving());
+ printers_manager_observation_.Observe(printers_manager_);
}
void CupsPrintersHandler::OnJavascriptDisallowed() {
- printers_manager_observer_.RemoveAll();
+ printers_manager_observation_.Reset();
}
void CupsPrintersHandler::SetWebUIForTest(content::WebUI* web_ui) {
@@ -1088,6 +1091,14 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter(
return;
}
+ // We need a special case for USB printers here. We cannot query them
+ // directly, so we have to fall back to manual configuration here.
+ if (printer->IsUsbProtocol()) {
+ RejectJavascriptCallback(base::Value(callback_id),
+ *GetCupsPrinterInfo(*printer));
+ return;
+ }
+
// The mDNS record doesn't guarantee we can setup the printer. Query it to
// see if we want to try IPP.
auto address = printer->GetHostAndPort();
@@ -1242,7 +1253,7 @@ void CupsPrintersHandler::QueryPrintServer(const std::string& callback_id,
const GURL& server_url,
bool should_fallback) {
server_printers_fetcher_ = std::make_unique<ServerPrintersFetcher>(
- server_url, "(from user)",
+ profile_, server_url, "(from user)",
base::BindRepeating(&CupsPrintersHandler::OnQueryPrintServerCompleted,
weak_factory_.GetWeakPtr(), callback_id,
should_fallback));
@@ -1302,11 +1313,16 @@ void CupsPrintersHandler::OnQueryPrintServerCompleted(
void CupsPrintersHandler::HandleOpenPrintManagementApp(
const base::ListValue* args) {
DCHECK(args->empty());
- DCHECK(
- base::FeatureList::IsEnabled(chromeos::features::kPrintJobManagementApp));
chrome::ShowPrintManagementApp(profile_,
PrintManagementAppEntryPoint::kSettings);
}
+void CupsPrintersHandler::HandleOpenScanningApp(const base::ListValue* args) {
+ DCHECK(args->empty());
+ DCHECK(base::FeatureList::IsEnabled(chromeos::features::kScanningUI));
+ chrome::ShowScanningApp(profile_,
+ chromeos::scanning::ScanAppEntryPoint::kSettings);
+}
+
} // namespace settings
} // namespace chromeos
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 e899d67a19b..1cc8e7fc66c 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
@@ -11,7 +11,7 @@
#include <vector>
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printer_event_tracker.h"
@@ -235,6 +235,8 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
void HandleOpenPrintManagementApp(const base::ListValue* args);
+ void HandleOpenScanningApp(const base::ListValue* args);
+
Profile* profile_;
// Discovery support. discovery_active_ tracks whether or not the UI
@@ -262,8 +264,8 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
std::unique_ptr<ServerPrintersFetcher> server_printers_fetcher_;
- ScopedObserver<CupsPrintersManager, CupsPrintersManager::Observer>
- printers_manager_observer_;
+ base::ScopedObservation<CupsPrintersManager, CupsPrintersManager::Observer>
+ printers_manager_observation_{this};
base::WeakPtrFactory<CupsPrintersHandler> weak_factory_{this};
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 e156cef3e43..3cbc84137cd 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
@@ -11,7 +11,6 @@
#include "base/files/file_path.h"
#include "base/json/json_string_value_serializer.h"
#include "base/test/metrics/histogram_tester.h"
-#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "chrome/browser/chromeos/printing/print_management/print_management_uma.h"
#include "chrome/browser/chromeos/printing/printing_stubs.h"
@@ -20,7 +19,7 @@
#include "chrome/browser/download/download_core_service_impl.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/test/base/testing_profile.h"
-#include "chromeos/constants/chromeos_features.h"
+#include "chromeos/components/scanning/scanning_uma.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
#include "content/public/test/browser_task_environment.h"
@@ -196,8 +195,6 @@ class CupsPrintersHandlerTest : public testing::Test {
~CupsPrintersHandlerTest() override = default;
void SetUp() override {
- scoped_feature_list_.InitWithFeatures(
- {chromeos::features::kPrintJobManagementApp}, {});
printers_handler_ = CupsPrintersHandler::CreateForTesting(
&profile_, base::MakeRefCounted<FakePpdProvider>(),
std::make_unique<StubPrinterConfigurer>(), &printers_manager_);
@@ -213,7 +210,6 @@ class CupsPrintersHandlerTest : public testing::Test {
content::TestWebUI web_ui_;
std::unique_ptr<CupsPrintersHandler> printers_handler_;
TestCupsPrintersManager printers_manager_;
- base::test::ScopedFeatureList scoped_feature_list_;
};
TEST_F(CupsPrintersHandlerTest, RemoveCorrectPrinter) {
@@ -280,5 +276,17 @@ TEST_F(CupsPrintersHandlerTest, VerifyPrintManagementAppEntryPointHistogram) {
PrintManagementAppEntryPoint::kBrowser, 0);
}
+TEST_F(CupsPrintersHandlerTest, VerifyScanAppEntryPointHistogram) {
+ base::Value args(base::Value::Type::LIST);
+ web_ui_.HandleReceivedMessage("openScanningApp",
+ &base::Value::AsListValue(args));
+ histogram_tester_.ExpectBucketCount(
+ "Scanning.ScanAppEntryPoint",
+ chromeos::scanning::ScanAppEntryPoint::kSettings, 1);
+ histogram_tester_.ExpectBucketCount(
+ "Scanning.ScanAppEntryPoint",
+ chromeos::scanning::ScanAppEntryPoint::kLauncher, 0);
+}
+
} // namespace settings.
} // namespace chromeos.
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
index 203ea6a2a07..1c5867a610e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
@@ -11,14 +11,13 @@
#include "base/command_line.h"
#include "base/time/time.h"
#include "base/values.h"
+#include "chrome/browser/ash/system/timezone_resolver_manager.h"
+#include "chrome/browser/ash/system/timezone_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/child_accounts/parent_access_code/parent_access_service.h"
#include "chrome/browser/chromeos/set_time_dialog.h"
-#include "chrome/browser/chromeos/system/timezone_resolver_manager.h"
-#include "chrome/browser/chromeos/system/timezone_util.h"
#include "chrome/common/pref_names.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/system_clock/system_clock_client.h"
#include "chromeos/settings/timezone_settings.h"
#include "components/policy/proto/chrome_device_policy.pb.h"
@@ -65,7 +64,7 @@ bool IsTimezoneAutomaticDetectionUserEditable() {
} // namespace
-DateTimeHandler::DateTimeHandler() : scoped_observer_(this) {}
+DateTimeHandler::DateTimeHandler() {}
DateTimeHandler::~DateTimeHandler() = default;
@@ -89,7 +88,7 @@ void DateTimeHandler::RegisterMessages() {
void DateTimeHandler::OnJavascriptAllowed() {
SystemClockClient* system_clock_client = SystemClockClient::Get();
- scoped_observer_.Add(system_clock_client);
+ scoped_observation_.Observe(system_clock_client);
SystemClockCanSetTimeChanged(system_clock_client->CanSetTime());
// The system time zone policy disables auto-detection entirely. (However,
@@ -97,20 +96,22 @@ void DateTimeHandler::OnJavascriptAllowed() {
system_timezone_policy_subscription_ =
CrosSettings::Get()->AddSettingsObserver(
kSystemTimezonePolicy,
- base::Bind(&DateTimeHandler::NotifyTimezoneAutomaticDetectionPolicy,
- weak_ptr_factory_.GetWeakPtr()));
+ base::BindRepeating(
+ &DateTimeHandler::NotifyTimezoneAutomaticDetectionPolicy,
+ weak_ptr_factory_.GetWeakPtr()));
// The auto-detection policy can force auto-detection on or off.
local_state_pref_change_registrar_.Init(g_browser_process->local_state());
local_state_pref_change_registrar_.Add(
prefs::kSystemTimezoneAutomaticDetectionPolicy,
- base::Bind(&DateTimeHandler::NotifyTimezoneAutomaticDetectionPolicy,
- base::Unretained(this)));
+ base::BindRepeating(
+ &DateTimeHandler::NotifyTimezoneAutomaticDetectionPolicy,
+ base::Unretained(this)));
}
void DateTimeHandler::OnJavascriptDisallowed() {
- scoped_observer_.RemoveAll();
- system_timezone_policy_subscription_.reset();
+ scoped_observation_.Reset();
+ system_timezone_policy_subscription_ = {};
local_state_pref_change_registrar_.RemoveAll();
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
index 102fb30eed6..9e73864dd4b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.h
@@ -9,8 +9,8 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
+#include "base/scoped_observation.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/dbus/system_clock/system_clock_client.h"
#include "components/prefs/pref_change_registrar.h"
@@ -59,14 +59,13 @@ class DateTimeHandler : public ::settings::SettingsPageUIHandler,
// setting according to policy.
void NotifyTimezoneAutomaticDetectionPolicy();
- std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
- system_timezone_policy_subscription_;
+ base::CallbackListSubscription system_timezone_policy_subscription_;
// Used to listen to changes to the system time zone detection policy.
PrefChangeRegistrar local_state_pref_change_registrar_;
- ScopedObserver<SystemClockClient, SystemClockClient::Observer>
- scoped_observer_;
+ base::ScopedObservation<SystemClockClient, SystemClockClient::Observer>
+ scoped_observation_{this};
base::WeakPtrFactory<DateTimeHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DateTimeHandler);
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 e42ba85d228..37af30c4031 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
@@ -7,8 +7,8 @@
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ash/system/timezone_util.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/system/timezone_util.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"
@@ -115,7 +115,7 @@ void DateTimeSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"use24HourClock", IDS_SETTINGS_USE_24_HOUR_CLOCK},
{"setDateTime", IDS_SETTINGS_SET_DATE_TIME},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString(
"timeZoneSettingsLearnMoreURL",
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 21f56f98ea7..080e26d7718 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
@@ -4,12 +4,12 @@
#include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h"
+#include "ash/constants/ash_switches.h"
#include "ash/public/cpp/keyboard_shortcut_viewer.h"
#include "ash/public/cpp/tablet_mode.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/values.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "content/public/browser/web_ui.h"
#include "ui/chromeos/events/event_rewriter_chromeos.h"
#include "ui/chromeos/events/keyboard_layout_util.h"
@@ -82,11 +82,11 @@ void KeyboardHandler::RegisterMessages() {
}
void KeyboardHandler::OnJavascriptAllowed() {
- observer_.Add(ui::DeviceDataManager::GetInstance());
+ observation_.Observe(ui::DeviceDataManager::GetInstance());
}
void KeyboardHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void KeyboardHandler::OnInputDeviceConfigurationChanged(
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
index ee6c480adc5..403303c8b75 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_KEYBOARD_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "ui/events/devices/device_data_manager.h"
#include "ui/events/devices/input_device_event_observer.h"
@@ -68,8 +68,8 @@ class KeyboardHandler
// Sends the UI a message about whether hardware keyboard are attached.
void UpdateKeyboards();
- ScopedObserver<ui::DeviceDataManager, ui::InputDeviceEventObserver> observer_{
- this};
+ base::ScopedObservation<ui::DeviceDataManager, ui::InputDeviceEventObserver>
+ observation_{this};
DISALLOW_COPY_AND_ASSIGN(KeyboardHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc
index efa5d926d6a..31fe09897d5 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc
@@ -9,10 +9,10 @@
#include <utility>
#include <vector>
+#include "ash/constants/ash_switches.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/observer_list.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "content/public/test/test_web_ui.h"
#include "device/udev_linux/fake_udev_loader.h"
#include "testing/gtest/include/gtest/gtest.h"
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
new file mode 100644
index 00000000000..d65abda5480
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.cc
@@ -0,0 +1,40 @@
+// 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/device_name_handler.h"
+
+#include <string>
+
+#include "base/check.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/device_name_store.h"
+#include "content/public/browser/web_ui.h"
+
+namespace chromeos {
+namespace settings {
+
+void DeviceNameHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "getDeviceNameMetadata",
+ base::BindRepeating(&DeviceNameHandler::HandleGetDeviceNameMetadata,
+ base::Unretained(this)));
+}
+
+void DeviceNameHandler::HandleGetDeviceNameMetadata(
+ const base::ListValue* args) {
+ AllowJavascript();
+
+ CHECK_EQ(1U, args->GetSize());
+ std::string callback_id;
+ CHECK(args->GetString(0, &callback_id));
+
+ base::DictionaryValue metadata;
+ metadata.SetString("deviceName",
+ DeviceNameStore::GetInstance()->GetDeviceName());
+
+ ResolveJavascriptCallback(base::Value(callback_id), metadata);
+}
+
+} // namespace settings
+} // namespace chromeos
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
new file mode 100644
index 00000000000..79b4f672e53
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler.h
@@ -0,0 +1,40 @@
+// 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_DEVICE_NAME_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_NAME_HANDLER_H_
+
+#include "base/macros.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+
+namespace base {
+class ListValue;
+}
+
+namespace chromeos {
+namespace settings {
+
+// DeviceNameHandler handles calls from WebUI JS related to getting and setting
+// the device name.
+class DeviceNameHandler : public ::settings::SettingsPageUIHandler {
+ public:
+ DeviceNameHandler() = default;
+ ~DeviceNameHandler() override = default;
+
+ // SettingsPageUIHandler implementation.
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override {}
+ void OnJavascriptDisallowed() override {}
+
+ protected:
+ void HandleGetDeviceNameMetadata(const base::ListValue* args);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DeviceNameHandler);
+};
+
+} // namespace settings
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DEVICE_NAME_HANDLER_H_
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
new file mode 100644
index 00000000000..5a9d3b13bbe
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_name_handler_unittest.cc
@@ -0,0 +1,83 @@
+// 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/device_name_handler.h"
+
+#include <memory>
+#include <string>
+
+#include "chrome/browser/chromeos/device_name_store.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/testing_pref_service.h"
+#include "content/public/test/browser_task_environment.h"
+#include "content/public/test/test_web_ui.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+namespace settings {
+
+class TestDeviceNameHandler : public DeviceNameHandler {
+ public:
+ explicit TestDeviceNameHandler(content::WebUI* web_ui) : DeviceNameHandler() {
+ set_web_ui(web_ui);
+ }
+
+ // Raise visibility to public.
+ void HandleGetDeviceNameMetadata(const base::ListValue* args) {
+ DeviceNameHandler::HandleGetDeviceNameMetadata(args);
+ }
+};
+
+class DeviceNameHandlerTest : public testing::Test {
+ public:
+ DeviceNameHandlerTest() = default;
+
+ void SetUp() override {
+ testing::Test::SetUp();
+
+ handler_ = std::make_unique<TestDeviceNameHandler>(web_ui());
+ handler()->AllowJavascriptForTesting();
+ web_ui()->ClearTrackedCalls();
+
+ DeviceNameStore::RegisterLocalStatePrefs(local_state_.registry());
+
+ local_state()->SetString(prefs::kDeviceName, "TestDeviceName");
+ DeviceNameStore::GetInstance()->Initialize(&local_state_);
+ }
+
+ TestDeviceNameHandler* handler() { return handler_.get(); }
+ content::TestWebUI* web_ui() { return &web_ui_; }
+ TestingPrefServiceSimple* local_state() { return &local_state_; }
+
+ private:
+ // Run on the UI thread.
+ content::BrowserTaskEnvironment task_environment_;
+
+ // Test backing store for prefs.
+ TestingPrefServiceSimple local_state_;
+
+ content::TestWebUI web_ui_;
+ std::unique_ptr<TestDeviceNameHandler> handler_;
+};
+
+TEST_F(DeviceNameHandlerTest, DeviceNameMetadata_DeviceName) {
+ base::ListValue args;
+ args.AppendString("callback-id");
+ handler()->HandleGetDeviceNameMetadata(&args);
+
+ const content::TestWebUI::CallData& call_data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIResponse", call_data.function_name());
+ EXPECT_EQ("callback-id", call_data.arg1()->GetString());
+ EXPECT_TRUE(call_data.arg2()->GetBool());
+
+ const base::DictionaryValue* returned_data;
+ ASSERT_TRUE(call_data.arg3()->GetAsDictionary(&returned_data));
+
+ std::string device_name;
+ ASSERT_TRUE(returned_data->GetString("deviceName", &device_name));
+ EXPECT_EQ("TestDeviceName", device_name);
+}
+
+} // namespace settings
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h
index adc1b28c301..676b25c0075 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h
@@ -8,7 +8,7 @@
#include <memory>
#include "base/macros.h"
-#include "chrome/browser/chromeos/system/pointer_device_observer.h"
+#include "chrome/browser/ash/system/pointer_device_observer.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
namespace base {
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 15ffd9709a1..6bf1eca2d85 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
@@ -162,13 +162,14 @@ void PowerHandler::RegisterMessages() {
void PowerHandler::OnJavascriptAllowed() {
PowerManagerClient* power_manager_client = PowerManagerClient::Get();
- power_manager_client_observer_.Add(power_manager_client);
+ power_manager_client_observation_.Observe(power_manager_client);
power_manager_client->GetSwitchStates(base::BindOnce(
&PowerHandler::OnGotSwitchStates, weak_ptr_factory_.GetWeakPtr()));
// Observe power management prefs used in the UI.
- base::Closure callback(base::Bind(&PowerHandler::SendPowerManagementSettings,
- base::Unretained(this), false /* force */));
+ base::RepeatingClosure callback(
+ base::BindRepeating(&PowerHandler::SendPowerManagementSettings,
+ base::Unretained(this), false /* force */));
pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>();
pref_change_registrar_->Init(prefs_);
pref_change_registrar_->Add(ash::prefs::kPowerAcIdleAction, callback);
@@ -186,7 +187,7 @@ void PowerHandler::OnJavascriptAllowed() {
}
void PowerHandler::OnJavascriptDisallowed() {
- power_manager_client_observer_.RemoveAll();
+ power_manager_client_observation_.Reset();
pref_change_registrar_.reset();
}
@@ -202,7 +203,7 @@ void PowerHandler::PowerManagerRestarted() {
}
void PowerHandler::LidEventReceived(PowerManagerClient::LidState state,
- const base::TimeTicks& timestamp) {
+ base::TimeTicks timestamp) {
lid_state_ = state;
SendPowerManagementSettings(false /* force */);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
index 71db52e8680..699802af8ae 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/dbus/power/power_manager_client.h"
@@ -85,7 +85,7 @@ class PowerHandler : public ::settings::SettingsPageUIHandler,
void PowerChanged(const power_manager::PowerSupplyProperties& proto) override;
void PowerManagerRestarted() override;
void LidEventReceived(PowerManagerClient::LidState state,
- const base::TimeTicks& timestamp) override;
+ base::TimeTicks timestamp) override;
private:
enum class PowerSource { kAc, kBattery };
@@ -158,8 +158,8 @@ class PowerHandler : public ::settings::SettingsPageUIHandler,
// Used to watch power management prefs for changes so the UI can be notified.
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
- ScopedObserver<PowerManagerClient, PowerManagerClient::Observer>
- power_manager_client_observer_{this};
+ base::ScopedObservation<PowerManagerClient, PowerManagerClient::Observer>
+ power_manager_client_observation_{this};
// Last lid state received from powerd.
PowerManagerClient::LidState lid_state_ = PowerManagerClient::LidState::OPEN;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
index 0b21a59f441..4d54e411208 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
@@ -84,6 +84,8 @@ class PowerHandlerTest : public InProcessBrowserTest {
void SetUpInProcessBrowserTestFixture() override {
// Initialize user policy.
ON_CALL(provider_, IsInitializationComplete(_)).WillByDefault(Return(true));
+ ON_CALL(provider_, IsFirstPolicyLoadComplete(_))
+ .WillByDefault(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
}
@@ -188,7 +190,7 @@ class PowerHandlerTest : public InProcessBrowserTest {
content::TestWebUI web_ui_;
- policy::MockConfigurationPolicyProvider provider_;
+ testing::NiceMock<policy::MockConfigurationPolicyProvider> provider_;
private:
DISALLOW_COPY_AND_ASSIGN(PowerHandlerTest);
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 506de1ff43e..519773e5bda 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/settings/chromeos/device_section.h"
+#include "ash/constants/ash_features.h"
+#include "ash/constants/ash_switches.h"
#include "ash/public/ash_interfaces.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/night_light_controller.h"
@@ -14,7 +16,7 @@
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
+#include "chrome/browser/ash/login/demo_mode/demo_session.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_display_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h"
@@ -28,8 +30,6 @@
#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
-#include "chromeos/constants/chromeos_switches.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
@@ -198,6 +198,18 @@ GetTouchpadScrollAccelerationSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetMouseScrollAccelerationSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_MOUSE_SCROLL_ACCELERATION,
+ mojom::kPointersSubpagePath,
+ mojom::SearchResultIcon::kMouse,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kMouseScrollAcceleration}},
+ });
+ return *tags;
+}
+
const std::vector<SearchConcept>& GetMouseSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_MOUSE_ACCELERATION,
@@ -230,12 +242,30 @@ const std::vector<SearchConcept>& GetMouseSearchConcepts() {
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kPointers}},
- {IDS_OS_SETTINGS_TAG_MOUSE_SCROLL_ACCELERATION,
+ });
+ return *tags;
+}
+
+const std::vector<SearchConcept>& GetPointingStickSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_POINTING_STICK_PRIMARY_BUTTON,
mojom::kPointersSubpagePath,
- mojom::SearchResultIcon::kMouse,
+ mojom::SearchResultIcon::kLaptop,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kMouseScrollAcceleration}},
+ {.setting = mojom::Setting::kPointingStickSwapPrimaryButtons}},
+ {IDS_OS_SETTINGS_TAG_POINTING_STICK_ACCELERATION,
+ mojom::kPointersSubpagePath,
+ mojom::SearchResultIcon::kLaptop,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kPointingStickAcceleration}},
+ {IDS_OS_SETTINGS_TAG_POINTING_STICK_SPEED,
+ mojom::kPointersSubpagePath,
+ mojom::SearchResultIcon::kLaptop,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kPointingStickSpeed}},
});
return *tags;
}
@@ -448,6 +478,11 @@ const std::vector<SearchConcept>& GetPowerWithLaptopLidSearchConcepts() {
return *tags;
}
+bool AreScrollSettingsAllowed() {
+ return base::FeatureList::IsEnabled(
+ ::chromeos::features::kAllowScrollSettings);
+}
+
bool IsUnifiedDesktopAvailable() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kEnableUnifiedDesktop);
@@ -497,7 +532,7 @@ void AddDeviceKeyboardStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_KEYBOARD_SHOW_LANGUAGE_AND_INPUT},
{"keyboardShowInputSettings", IDS_SETTINGS_KEYBOARD_SHOW_INPUT_SETTINGS},
};
- AddLocalizedStringsBulk(html_source, keyboard_strings);
+ html_source->AddLocalizedStrings(keyboard_strings);
html_source->AddLocalizedString("keyboardKeySearch",
ui::DeviceUsesKeyboardLayout2()
@@ -529,7 +564,7 @@ void AddDeviceStylusStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_STYLUS_NOTE_TAKING_APP_NONE_AVAILABLE},
{"stylusNoteTakingAppWaitingForAndroid",
IDS_SETTINGS_STYLUS_NOTE_TAKING_APP_WAITING_FOR_ANDROID}};
- AddLocalizedStringsBulk(html_source, kStylusStrings);
+ html_source->AddLocalizedStrings(kStylusStrings);
html_source->AddBoolean("hasInternalStylus",
ash::stylus_utils::HasInternalStylus());
@@ -538,7 +573,6 @@ void AddDeviceStylusStrings(content::WebUIDataSource* html_source) {
void AddDeviceDisplayStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kDisplayStrings[] = {
{"displayTitle", IDS_SETTINGS_DISPLAY_TITLE},
- {"displayArrangementText", IDS_SETTINGS_DISPLAY_ARRANGEMENT_TEXT},
{"displayArrangementTitle", IDS_SETTINGS_DISPLAY_ARRANGEMENT_TITLE},
{"displayMirror", IDS_SETTINGS_DISPLAY_MIRROR},
{"displayMirrorDisplayName", IDS_SETTINGS_DISPLAY_MIRROR_DISPLAY_NAME},
@@ -619,7 +653,14 @@ void AddDeviceDisplayStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_DISPLAY_TOUCH_CALIBRATION_TITLE},
{"displayTouchCalibrationText",
IDS_SETTINGS_DISPLAY_TOUCH_CALIBRATION_TEXT}};
- AddLocalizedStringsBulk(html_source, kDisplayStrings);
+ html_source->AddLocalizedStrings(kDisplayStrings);
+
+ html_source->AddLocalizedString(
+ "displayArrangementText",
+ base::FeatureList::IsEnabled(
+ ash::features::kKeyboardBasedDisplayArrangementInSettings)
+ ? IDS_SETTINGS_DISPLAY_ARRANGEMENT_WITH_KEYBOARD_TEXT
+ : IDS_SETTINGS_DISPLAY_ARRANGEMENT_TEXT);
html_source->AddBoolean("unifiedDesktopAvailable",
IsUnifiedDesktopAvailable());
@@ -643,6 +684,11 @@ void AddDeviceDisplayStrings(content::WebUIDataSource* html_source) {
html_source->AddBoolean(
"allowDisplayAlignmentApi",
base::FeatureList::IsEnabled(ash::features::kDisplayAlignAssist));
+
+ html_source->AddBoolean(
+ "allowKeyboardBasedDisplayArrangementInSettings",
+ base::FeatureList::IsEnabled(
+ ash::features::kKeyboardBasedDisplayArrangementInSettings));
}
void AddDeviceStorageStrings(content::WebUIDataSource* html_source,
@@ -677,7 +723,7 @@ void AddDeviceStorageStrings(content::WebUIDataSource* html_source,
{"storageExternalStorageListHeader",
IDS_SETTINGS_STORAGE_EXTERNAL_STORAGE_LIST_HEADER},
{"storageOverviewAriaLabel", IDS_SETTINGS_STORAGE_OVERVIEW_ARIA_LABEL}};
- AddLocalizedStringsBulk(html_source, kStorageStrings);
+ html_source->AddLocalizedStrings(kStorageStrings);
html_source->AddBoolean("androidEnabled", is_external_storage_page_available);
@@ -715,7 +761,7 @@ void AddDevicePowerStrings(content::WebUIDataSource* html_source) {
{"powerLidSignOutLabel", IDS_SETTINGS_POWER_LID_CLOSED_SIGN_OUT_LABEL},
{"powerLidShutDownLabel", IDS_SETTINGS_POWER_LID_CLOSED_SHUT_DOWN_LABEL},
};
- AddLocalizedStringsBulk(html_source, kPowerStrings);
+ html_source->AddLocalizedStrings(kPowerStrings);
}
// Mirrors enum of the same name in enums.xml.
@@ -803,7 +849,7 @@ void DeviceSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"devicePageTitle", IDS_SETTINGS_DEVICE_TITLE},
{"touchPadScrollLabel", IDS_OS_SETTINGS_TOUCHPAD_REVERSE_SCROLL_LABEL},
};
- AddLocalizedStringsBulk(html_source, kDeviceStrings);
+ html_source->AddLocalizedStrings(kDeviceStrings);
html_source->AddBoolean("isDemoSession",
chromeos::DemoSession::IsDeviceInDemoMode());
@@ -885,6 +931,9 @@ void DeviceSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::Setting::kTouchpadAcceleration,
mojom::Setting::kTouchpadScrollAcceleration,
mojom::Setting::kTouchpadSpeed,
+ mojom::Setting::kPointingStickSwapPrimaryButtons,
+ mojom::Setting::kPointingStickSpeed,
+ mojom::Setting::kPointingStickAcceleration,
mojom::Setting::kMouseSwapPrimaryButtons,
mojom::Setting::kMouseReverseScrolling,
mojom::Setting::kMouseAcceleration,
@@ -982,15 +1031,23 @@ void DeviceSection::TouchpadExists(bool exists) {
void DeviceSection::MouseExists(bool exists) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetMouseSearchConcepts());
+ updater.RemoveSearchTags(GetMouseScrollAccelerationSearchConcepts());
- if (exists)
+ if (exists) {
updater.AddSearchTags(GetMouseSearchConcepts());
- else
- updater.RemoveSearchTags(GetMouseSearchConcepts());
+ if (AreScrollSettingsAllowed())
+ updater.AddSearchTags(GetMouseScrollAccelerationSearchConcepts());
+ }
}
void DeviceSection::PointingStickExists(bool exists) {
- // TODO(crbug.com/1114828): manage search tags when the UI is implemented.
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+
+ if (exists)
+ updater.AddSearchTags(GetPointingStickSearchConcepts());
+ else
+ updater.RemoveSearchTags(GetPointingStickSearchConcepts());
}
void DeviceSection::OnDeviceListsComplete() {
@@ -1144,7 +1201,10 @@ void DeviceSection::AddDevicePointersStrings(
{"pointerFast", IDS_SETTINGS_POINTER_SPEED_FAST_LABEL},
{"mouseScrollSpeed", IDS_SETTINGS_MOUSE_SCROLL_SPEED_LABEL},
{"mouseSpeed", IDS_SETTINGS_MOUSE_SPEED_LABEL},
+ {"pointingStickSpeed", IDS_SETTINGS_POINTING_STICK_SPEED_LABEL},
{"mouseSwapButtons", IDS_SETTINGS_MOUSE_SWAP_BUTTONS_LABEL},
+ {"pointingStickPrimaryButton",
+ IDS_SETTINGS_POINTING_STICK_PRIMARY_BUTTON_LABEL},
{"primaryMouseButtonLeft", IDS_SETTINGS_PRIMARY_MOUSE_BUTTON_LEFT_LABEL},
{"primaryMouseButtonRight",
IDS_SETTINGS_PRIMARY_MOUSE_BUTTON_RIGHT_LABEL},
@@ -1152,12 +1212,14 @@ void DeviceSection::AddDevicePointersStrings(
{"mouseAccelerationLabel", IDS_SETTINGS_MOUSE_ACCELERATION_LABEL},
{"mouseScrollAccelerationLabel",
IDS_SETTINGS_MOUSE_SCROLL_ACCELERATION_LABEL},
+ {"pointingStickAccelerationLabel",
+ IDS_SETTINGS_POINTING_STICK_ACCELERATION_LABEL},
{"touchpadAccelerationLabel", IDS_SETTINGS_TOUCHPAD_ACCELERATION_LABEL},
{"touchpadScrollAccelerationLabel",
IDS_SETTINGS_TOUCHPAD_SCROLL_ACCELERATION_LABEL},
{"touchpadScrollSpeed", IDS_SETTINGS_TOUCHPAD_SCROLL_SPEED_LABEL},
};
- AddLocalizedStringsBulk(html_source, kPointersStrings);
+ html_source->AddLocalizedStrings(kPointersStrings);
html_source->AddString("naturalScrollLearnMoreLink",
GetHelpUrlWithBoard(chrome::kNaturalScrollHelpURL));
@@ -1165,9 +1227,7 @@ void DeviceSection::AddDevicePointersStrings(
html_source->AddBoolean(
"allowDisableMouseAcceleration",
base::FeatureList::IsEnabled(::features::kAllowDisableMouseAcceleration));
- html_source->AddBoolean(
- "allowScrollSettings",
- base::FeatureList::IsEnabled(::chromeos::features::kAllowScrollSettings));
+ html_source->AddBoolean("allowScrollSettings", AreScrollSettingsAllowed());
html_source->AddBoolean(
"separatePointingStickSettings",
base::FeatureList::IsEnabled(::features::kSeparatePointingStickSettings));
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 47bae70bb51..7f056792aa1 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h
@@ -12,7 +12,7 @@
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/system/pointer_device_observer.h"
+#include "chrome/browser/ash/system/pointer_device_observer.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
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 c299a2bdea4..ad8de481a8d 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
@@ -65,7 +65,6 @@ StorageHandler::StorageHandler(Profile* profile,
other_users_size_calculator_(),
profile_(profile),
source_name_(html_source->GetSource()),
- arc_observer_(this),
special_volume_path_pattern_("[a-z]+://.*") {
// TODO(khorimoto): Set kAndroidEnabled within DeviceSection, and
// updates this value accordingly (see OnArcPlayStoreEnabledChanged()).
@@ -103,7 +102,7 @@ void StorageHandler::RegisterMessages() {
void StorageHandler::OnJavascriptAllowed() {
if (base::FeatureList::IsEnabled(arc::kUsbStorageUIFeature))
- arc_observer_.Add(arc::ArcSessionManager::Get());
+ arc_observation_.Observe(arc::ArcSessionManager::Get());
// Start observing mount/unmount events to update the connected device list.
DiskMountManager::GetInstance()->AddObserver(this);
@@ -121,8 +120,10 @@ void StorageHandler::OnJavascriptDisallowed() {
// Ensure that pending callbacks do not complete and cause JS to be evaluated.
weak_ptr_factory_.InvalidateWeakPtrs();
- if (base::FeatureList::IsEnabled(arc::kUsbStorageUIFeature))
- arc_observer_.Remove(arc::ArcSessionManager::Get());
+ if (base::FeatureList::IsEnabled(arc::kUsbStorageUIFeature)) {
+ DCHECK(arc_observation_.IsObservingSource(arc::ArcSessionManager::Get()));
+ arc_observation_.Reset();
+ }
StopObservingEvents();
}
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 78e3db03d97..0819ea175cb 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
@@ -7,6 +7,7 @@
#include <string>
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager_observer.h"
#include "chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator.h"
@@ -125,8 +126,9 @@ class StorageHandler : public ::settings::SettingsPageUIHandler,
Profile* const profile_;
const std::string source_name_;
- ScopedObserver<arc::ArcSessionManager, arc::ArcSessionManagerObserver>
- arc_observer_;
+ base::ScopedObservation<arc::ArcSessionManager,
+ arc::ArcSessionManagerObserver>
+ arc_observation_{this};
const re2::RE2 special_volume_path_pattern_;
base::WeakPtrFactory<StorageHandler> weak_ptr_factory_{this};
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 b05bf1bd730..e82018ceead 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
@@ -12,11 +12,11 @@
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
+#include "base/test/scoped_running_on_chromeos.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/chromeos/arc/test/test_arc_session_manager.h"
#include "chrome/browser/chromeos/file_manager/fake_disk_mount_manager.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
-#include "chrome/browser/chromeos/scoped_set_running_on_chromeos_for_testing.h"
#include "chrome/browser/ui/webui/settings/chromeos/calculator/size_calculator_test_api.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_storage_handler.h"
#include "chrome/common/chrome_paths.h"
@@ -38,10 +38,6 @@ namespace settings {
namespace {
-const char kLsbRelease[] =
- "CHROMEOS_RELEASE_NAME=Chrome OS\n"
- "CHROMEOS_RELEASE_VERSION=1.2.3.4\n";
-
class TestStorageHandler : public StorageHandler {
public:
explicit TestStorageHandler(Profile* profile,
@@ -104,14 +100,13 @@ class StorageHandlerTest : public testing::Test {
// Create and register My files directory.
// By emulating chromeos running, GetMyFilesFolderForProfile will return the
// profile's temporary location instead of $HOME/Downloads.
- chromeos::ScopedSetRunningOnChromeOSForTesting fake_release(kLsbRelease,
- base::Time());
+ base::test::ScopedRunningOnChromeOS running_on_chromeos;
const base::FilePath my_files_path =
file_manager::util::GetMyFilesFolderForProfile(profile_);
CHECK(base::CreateDirectory(my_files_path));
CHECK(storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
file_manager::util::GetDownloadsMountPointName(profile_),
- storage::kFileSystemTypeNativeLocal, storage::FileSystemMountOption(),
+ storage::kFileSystemTypeLocal, storage::FileSystemMountOption(),
my_files_path));
}
@@ -325,7 +320,7 @@ TEST_F(StorageHandlerTest, MyFilesSize) {
// Register android files mount point.
CHECK(storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
file_manager::util::GetAndroidFilesMountPointName(),
- storage::kFileSystemTypeNativeLocal, storage::FileSystemMountOption(),
+ storage::kFileSystemTypeLocal, storage::FileSystemMountOption(),
android_files_path));
// Add files in My files and android files.
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 ad7f2ee26ba..c9be5570431 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
@@ -11,6 +11,8 @@
#include "ash/public/cpp/stylus_utils.h"
#include "base/bind.h"
+#include "chrome/browser/apps/app_service/app_service_proxy.h"
+#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
@@ -60,13 +62,13 @@ void StylusHandler::RegisterMessages() {
}
void StylusHandler::OnJavascriptAllowed() {
- note_observer_.Add(NoteTakingHelper::Get());
- input_observer_.Add(ui::DeviceDataManager::GetInstance());
+ note_observation_.Observe(NoteTakingHelper::Get());
+ input_observation_.Observe(ui::DeviceDataManager::GetInstance());
}
void StylusHandler::OnJavascriptDisallowed() {
- note_observer_.RemoveAll();
- input_observer_.RemoveAll();
+ note_observation_.Reset();
+ input_observation_.Reset();
}
void StylusHandler::OnAvailableNoteTakingAppsUpdated() {
@@ -163,7 +165,11 @@ void StylusHandler::HandleShowPlayStoreApps(const base::ListValue* args) {
return;
}
- arc::LaunchPlayStoreWithUrl(apps_url);
+ DCHECK(
+ apps::AppServiceProxyFactory::IsAppServiceAvailableForProfile(profile));
+ 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/device_stylus_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h
index c0e2429de10..8e1ca21a1ac 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_stylus_handler.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/note_taking_helper.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "ui/events/devices/device_data_manager.h"
@@ -60,10 +60,10 @@ class StylusHandler : public ::settings::SettingsPageUIHandler,
std::set<std::string> note_taking_app_ids_;
// Observer registration.
- ScopedObserver<NoteTakingHelper, NoteTakingHelper::Observer> note_observer_{
- this};
- ScopedObserver<ui::DeviceDataManager, ui::InputDeviceEventObserver>
- input_observer_{this};
+ base::ScopedObservation<NoteTakingHelper, NoteTakingHelper::Observer>
+ note_observation_{this};
+ base::ScopedObservation<ui::DeviceDataManager, ui::InputDeviceEventObserver>
+ input_observation_{this};
DISALLOW_COPY_AND_ASSIGN(StylusHandler);
};
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 f9d8293005f..75f9d4652ec 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/files_section.h"
#include "base/no_destructor.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#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"
@@ -85,7 +85,7 @@ void FilesSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"smbShareAddedInvalidSSOURLMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_INVALID_SSO_URL_MESSAGE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
chromeos::smb_dialog::AddLocalizedStrings(html_source);
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 7a93a5a8268..48cac0a8934 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
@@ -8,14 +8,14 @@
#include <memory>
#include "base/bind.h"
-#include "base/stl_util.h"
+#include "base/containers/contains.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/login/quick_unlock/auth_token.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/ash/login/quick_unlock/auth_token.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_factory.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_storage.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
@@ -105,13 +105,13 @@ void FingerprintHandler::RegisterMessages() {
void FingerprintHandler::OnJavascriptAllowed() {
// SessionManager may not exist in some tests.
if (SessionManager::Get())
- session_observer_.Add(SessionManager::Get());
+ session_observation_.Observe(SessionManager::Get());
fp_service_->AddFingerprintObserver(receiver_.BindNewPipeAndPassRemote());
}
void FingerprintHandler::OnJavascriptDisallowed() {
- session_observer_.RemoveAll();
+ session_observation_.Reset();
receiver_.reset();
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
index 97c85fd65d9..b18be765335 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FINGERPRINT_HANDLER_H_
#include "base/containers/flat_map.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/session_manager/core/session_manager.h"
#include "components/session_manager/core/session_manager_observer.h"
@@ -79,9 +79,9 @@ class FingerprintHandler : public ::settings::SettingsPageUIHandler,
mojo::Remote<device::mojom::Fingerprint> fp_service_;
mojo::Receiver<device::mojom::FingerprintObserver> receiver_{this};
- ScopedObserver<session_manager::SessionManager,
- session_manager::SessionManagerObserver>
- session_observer_{this};
+ base::ScopedObservation<session_manager::SessionManager,
+ session_manager::SessionManagerObserver>
+ session_observation_{this};
base::WeakPtrFactory<FingerprintHandler> weak_ptr_factory_{this};
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 4bb35364615..b8202d9cbf4 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
@@ -6,14 +6,13 @@
#include <utility>
+#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/audio/cras_audio_handler.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/services/assistant/public/cpp/assistant_service.h"
#include "components/arc/arc_prefs.h"
#include "components/arc/arc_service_manager.h"
@@ -88,7 +87,9 @@ void GoogleAssistantHandler::HandleSyncVoiceModelStatus(
const base::ListValue* args) {
CHECK_EQ(0U, args->GetSize());
- assistant::AssistantSettings::Get()->SyncSpeakerIdEnrollmentStatus();
+ auto* settings = assistant::AssistantSettings::Get();
+ if (settings)
+ settings->SyncSpeakerIdEnrollmentStatus();
}
void GoogleAssistantHandler::HandleInitialized(const base::ListValue* args) {
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 5b96d4abf13..7e81a6d003c 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,10 +5,10 @@
#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 "base/macros.h"
#include "base/optional.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "chromeos/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
new file mode 100644
index 00000000000..b92e54c9b8b
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.cc
@@ -0,0 +1,147 @@
+// 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.
+
+#include "chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h"
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/bind.h"
+#include "base/callback_helpers.h"
+#include "chrome/browser/chromeos/file_manager/path_util.h"
+#include "chrome/browser/chromeos/guest_os/guest_os_share_path.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace chromeos {
+
+namespace {
+
+base::ListValue GetSharableUsbDevices(CrosUsbDetector* detector) {
+ base::ListValue 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);
+ usb_devices_list.Append(std::move(device_info));
+ }
+ return usb_devices_list;
+}
+
+} // namespace
+
+namespace settings {
+
+GuestOsHandler::GuestOsHandler(Profile* profile) : profile_(profile) {}
+
+GuestOsHandler::~GuestOsHandler() = default;
+
+void GuestOsHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "getGuestOsSharedPathsDisplayText",
+ base::BindRepeating(
+ &GuestOsHandler::HandleGetGuestOsSharedPathsDisplayText,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "removeGuestOsSharedPath",
+ base::BindRepeating(&GuestOsHandler::HandleRemoveGuestOsSharedPath,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "notifyGuestOsSharedUsbDevicesPageReady",
+ base::BindRepeating(
+ &GuestOsHandler::HandleNotifyGuestOsSharedUsbDevicesPageReady,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "setGuestOsUsbDeviceShared",
+ base::BindRepeating(&GuestOsHandler::HandleSetGuestOsUsbDeviceShared,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void GuestOsHandler::OnJavascriptAllowed() {
+ if (auto* detector = chromeos::CrosUsbDetector::Get()) {
+ cros_usb_device_observation_.Observe(detector);
+ }
+}
+
+void GuestOsHandler::OnJavascriptDisallowed() {
+ cros_usb_device_observation_.Reset();
+}
+
+void GuestOsHandler::HandleGetGuestOsSharedPathsDisplayText(
+ const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(2U, args->GetSize());
+ std::string callback_id = args->GetList()[0].GetString();
+
+ base::ListValue texts;
+ for (const auto& path : args->GetList()[1].GetList()) {
+ texts.AppendString(file_manager::util::GetPathDisplayTextForSettings(
+ profile_, path.GetString()));
+ }
+ ResolveJavascriptCallback(base::Value(callback_id), texts);
+}
+
+void GuestOsHandler::HandleRemoveGuestOsSharedPath(
+ const base::ListValue* args) {
+ CHECK_EQ(3U, args->GetList().size());
+ std::string callback_id = args->GetList()[0].GetString();
+ std::string vm_name = args->GetList()[1].GetString();
+ std::string path = args->GetList()[2].GetString();
+
+ guest_os::GuestOsSharePath::GetForProfile(profile_)->UnsharePath(
+ vm_name, base::FilePath(path),
+ /*unpersist=*/true,
+ base::BindOnce(&GuestOsHandler::OnGuestOsSharedPathRemoved,
+ weak_ptr_factory_.GetWeakPtr(), callback_id, path));
+}
+
+void GuestOsHandler::OnGuestOsSharedPathRemoved(
+ const std::string& callback_id,
+ const std::string& path,
+ bool success,
+ const std::string& failure_reason) {
+ if (!success) {
+ LOG(ERROR) << "Error unsharing " << path << ": " << failure_reason;
+ }
+ ResolveJavascriptCallback(base::Value(callback_id), base::Value(success));
+}
+
+void GuestOsHandler::HandleNotifyGuestOsSharedUsbDevicesPageReady(
+ const base::ListValue* args) {
+ AllowJavascript();
+ OnUsbDevicesChanged();
+}
+
+void GuestOsHandler::HandleSetGuestOsUsbDeviceShared(
+ const base::ListValue* args) {
+ CHECK_EQ(3U, args->GetList().size());
+ const auto& args_list = args->GetList();
+ const std::string& vm_name = args_list[0].GetString();
+ const std::string& guid = args_list[1].GetString();
+ bool shared = args_list[2].GetBool();
+
+ chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
+ if (!detector)
+ return;
+
+ if (shared) {
+ detector->AttachUsbDeviceToVm(vm_name, guid, base::DoNothing());
+ return;
+ }
+ detector->DetachUsbDeviceFromVm(vm_name, guid, base::DoNothing());
+}
+
+void GuestOsHandler::OnUsbDevicesChanged() {
+ chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
+ DCHECK(detector); // This callback is called by the detector.
+ FireWebUIListener("guest-os-shared-usb-devices-changed",
+ GetSharableUsbDevices(detector));
+}
+
+} // namespace settings
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h
new file mode 100644
index 00000000000..41c4888116e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/guest_os_handler.h
@@ -0,0 +1,67 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_GUEST_OS_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_GUEST_OS_HANDLER_H_
+
+#include "base/memory/weak_ptr.h"
+#include "base/scoped_observation.h"
+#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h"
+#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager_factory.h"
+#include "chrome/browser/chromeos/usb/cros_usb_detector.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+
+class Profile;
+
+namespace chromeos {
+namespace settings {
+
+class GuestOsHandler : public ::settings::SettingsPageUIHandler,
+ public chromeos::CrosUsbDeviceObserver {
+ public:
+ explicit GuestOsHandler(Profile* profile);
+ GuestOsHandler(const GuestOsHandler&) = delete;
+ GuestOsHandler& operator=(const GuestOsHandler&) = delete;
+ ~GuestOsHandler() override;
+
+ // SettingsPageUIHandler
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ private:
+ // chromeos::SharedUsbDeviceObserver.
+ void OnUsbDevicesChanged() override;
+
+ // Callback for the "getSharedPathsDisplayText" message. Converts actual
+ // paths in chromeos to values suitable to display to users.
+ // E.g. /home/chronos/u-<hash>/Downloads/foo => "Downloads > foo".
+ void HandleGetGuestOsSharedPathsDisplayText(const base::ListValue* args);
+ // Remove a specified path from being shared.
+ void HandleRemoveGuestOsSharedPath(const base::ListValue* args);
+ // Called when the shared USB devices page is ready.
+ void HandleNotifyGuestOsSharedUsbDevicesPageReady(
+ const base::ListValue* args);
+ // Set the share state of a USB device.
+ void HandleSetGuestOsUsbDeviceShared(const base::ListValue* args);
+
+ void OnGuestOsSharedPathRemoved(const std::string& callback_id,
+ const std::string& path,
+ bool success,
+ const std::string& failure_reason);
+
+ Profile* profile_;
+ base::ScopedObservation<CrosUsbDetector,
+ CrosUsbDeviceObserver,
+ &CrosUsbDetector::AddUsbDeviceObserver,
+ &CrosUsbDetector::RemoveUsbDeviceObserver>
+ cros_usb_device_observation_{this};
+ // weak_ptr_factory_ should always be last member.
+ base::WeakPtrFactory<GuestOsHandler> weak_ptr_factory_{this};
+};
+
+} // namespace settings
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_GUEST_OS_HANDLER_H_
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 bd301cfcb91..b89421bc94d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
@@ -9,7 +9,9 @@
#include "base/bind.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.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/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/tether/tether_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
@@ -113,8 +115,10 @@ void InternetHandler::AddThirdPartyVpn(const base::ListValue* args) {
// Request to launch Arc VPN provider.
const auto* arc_app_list_prefs = ArcAppListPrefs::Get(profile_);
if (arc_app_list_prefs && arc_app_list_prefs->GetApp(app_id)) {
- arc::LaunchApp(profile_, app_id, ui::EF_NONE,
- arc::UserInteractionType::APP_STARTED_FROM_SETTINGS);
+ DCHECK(apps::AppServiceProxyFactory::IsAppServiceAvailableForProfile(
+ profile_));
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->Launch(
+ app_id, ui::EF_NONE, apps::mojom::LaunchSource::kFromParentalControls);
return;
}
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 20329939ac2..aaab88f1523 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/internet_section.h"
+#include "ash/constants/ash_features.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/network_config_service.h"
#include "base/bind.h"
@@ -20,7 +21,6 @@
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/strings/grit/chromeos_strings.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -575,6 +575,7 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"internetDeviceEnabling", IDS_SETTINGS_INTERNET_DEVICE_ENABLING},
{"internetDeviceDisabling", IDS_SETTINGS_INTERNET_DEVICE_DISABLING},
{"internetDeviceInitializing", IDS_SETTINGS_INTERNET_DEVICE_INITIALIZING},
+ {"internetDeviceBusy", IDS_SETTINGS_INTERNET_DEVICE_BUSY},
{"internetJoinType", IDS_SETTINGS_INTERNET_JOIN_TYPE},
{"internetKnownNetworksPageTitle", IDS_SETTINGS_INTERNET_KNOWN_NETWORKS},
{"internetMobileSearching", IDS_SETTINGS_INTERNET_MOBILE_SEARCH},
@@ -701,16 +702,44 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"eSimNetworkNotSetup",
IDS_SETTINGS_INTERNET_ESIM_NOT_SETUP_WITH_SETUP_LINK},
{"cellularNetworkTetherLabel", IDS_SETTINGS_INTERNET_TETHER_LABEL},
+ {"showEidPopupButtonLabel",
+ IDS_SETTINGS_INTERNET_SHOW_EID_POPUP_BUTTON_LABEL},
+ {"eSimInstallErrorDialogTitle",
+ IDS_SETTINGS_INTERNET_NETWORK_INSTALL_ERROR_DIALOG_TITLE},
+ {"eSimInstallErrorDialogConfirmationCodeMessage",
+ IDS_SETTINGS_INTERNET_NETWORK_INSTALL_ERROR_DIALOG_CONFIRMATION_CODE_MESSAGE},
+ {"eSimInstallErrorDialogConfirmationCodeError",
+ IDS_CELLULAR_SETUP_ESIM_PAGE_INSTALL_ERROR_DIALOG_CONFIRMATION_CODE_ERROR},
+ {"eSimRenameProfileDialogLabel",
+ IDS_SETTINGS_INTERNET_NETWORK_RENAME_DIALOG_RENAME_PROFILE},
+ {"eSimRenameProfileDialogDone",
+ IDS_SETTINGS_INTERNET_NETWORK_RENAME_DIALOG_DONE},
+ {"eSimRenameProfileDialogCancel",
+ IDS_SETTINGS_INTERNET_NETWORK_RENAME_DIALOG_CANCEL},
+ {"eSimRenameProfileDialogError",
+ IDS_SETTINGS_INTERNET_NETWORK_RENAME_DIALOG_ERROR_MESSAGE},
+ {"eSimRemoveProfileDialogCancel",
+ IDS_SETTINGS_INTERNET_NETWORK_REMOVE_PROFILE_DIALOG_CANCEL},
+ {"esimRemoveProfileDialogTitle",
+ IDS_SETTINGS_INTERNET_NETWORK_REMOVE_PROFILE_DIALOG_TITLE},
+ {"eSimRemoveProfileDialogRemove",
+ IDS_SETTINGS_INTERNET_NETWORK_REMOVE_PROFILE_DIALOG_REMOVE},
+ {"eSimRemoveProfileDialogError",
+ IDS_SETTINGS_INTERNET_NETWORK_REMOVE_PROFILE_DIALOG_ERROR_MESSAGE},
+ {"eSimRemoveProfileDialogOkay",
+ IDS_SETTINGS_INTERNET_NETWORK_REMOVE_PROFILE_DIALOG_OKAY},
+ {"eSimDialogConnectionWarning",
+ IDS_SETTINGS_INTERNET_ESIM_DIALOG_CONNECTION_WARNING},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
network_element::AddLocalizedStrings(html_source);
network_element::AddOncLocalizedStrings(html_source);
network_element::AddDetailsLocalizedStrings(html_source);
network_element::AddConfigLocalizedStrings(html_source);
network_element::AddErrorLocalizedStrings(html_source);
- if (base::FeatureList::IsEnabled(
- chromeos::features::kUpdatedCellularActivationUi)) {
+ cellular_setup::AddNonStringLoadTimeData(html_source);
+ if (features::IsCellularActivationUiEnabled()) {
cellular_setup::AddLocalizedStrings(html_source);
}
@@ -722,10 +751,6 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
html_source->AddString("networkGoogleNameserversLearnMoreUrl",
chrome::kGoogleNameserversLearnMoreURL);
- html_source->AddBoolean(
- "updatedCellularActivationUi",
- base::FeatureList::IsEnabled(
- chromeos::features::kUpdatedCellularActivationUi));
html_source->AddString(
"networkNotSynced",
@@ -974,7 +999,7 @@ void InternetSection::FetchNetworkList() {
network_config::mojom::FilterType::kVisible,
network_config::mojom::NetworkType::kAll,
network_config::mojom::kNoLimit),
- base::Bind(&InternetSection::OnNetworkList, base::Unretained(this)));
+ base::BindOnce(&InternetSection::OnNetworkList, base::Unretained(this)));
}
void InternetSection::OnNetworkList(
@@ -1031,10 +1056,8 @@ void InternetSection::OnNetworkList(
if (base::FeatureList::IsEnabled(::features::kMeteredShowToggle))
updater.AddSearchTags(GetCellularMeteredSearchConcepts());
- if (base::FeatureList::IsEnabled(
- chromeos::features::kUpdatedCellularActivationUi)) {
+ if (features::IsCellularActivationUiEnabled())
updater.AddSearchTags(GetCellularSetupAndDetailMenuSearchConcepts());
- }
break;
case NetworkType::kTether:
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 b271e0e8e75..06f1ec6d9ef 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
@@ -6,6 +6,7 @@
#include <utility>
+#include "ash/constants/ash_features.h"
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string16.h"
@@ -47,7 +48,19 @@ void AddKerberosTitleStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_KERBEROS_ACCOUNTS_SUBMENU_LABEL},
{"kerberosAccountsPageTitle", IDS_SETTINGS_KERBEROS_ACCOUNTS_PAGE_TITLE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
+}
+
+// Adds flags related to Kerberos settings visibility and its corresponding
+// settings section.
+void AddKerberosSettingsVisibilityFlags(
+ content::WebUIDataSource* html_source,
+ KerberosCredentialsManager* kerberos_credentials_manager) {
+ html_source->AddBoolean("isKerberosEnabled",
+ IsKerberosEnabled(kerberos_credentials_manager));
+ html_source->AddBoolean(
+ "isKerberosSettingsSectionEnabled",
+ chromeos::features::IsKerberosSettingsSectionEnabled());
}
// Adds load time strings to Kerberos Add Accounts dialog.
@@ -102,7 +115,7 @@ void AddKerberosAddAccountDialogStrings(content::WebUIDataSource* html_source) {
{"addKerberosAccount", IDS_SETTINGS_ADD_KERBEROS_ACCOUNT},
{"refreshKerberosAccount", IDS_SETTINGS_REFRESH_KERBEROS_ACCOUNT},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
PrefService* local_state = g_browser_process->local_state();
@@ -118,9 +131,7 @@ void AddKerberosAddAccountDialogStrings(content::WebUIDataSource* html_source) {
}
// Adds load time strings to Kerberos Accounts page.
-void AddKerberosAccountsPageStrings(
- content::WebUIDataSource* html_source,
- KerberosCredentialsManager* kerberos_credentials_manager) {
+void AddKerberosAccountsPageStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"kerberosAccountsAddAccountLabel",
IDS_SETTINGS_KERBEROS_ACCOUNTS_ADD_ACCOUNT_LABEL},
@@ -143,12 +154,7 @@ void AddKerberosAccountsPageStrings(
IDS_SETTINGS_KERBEROS_ACCOUNTS_ACCOUNT_REFRESHED_TIP},
{"kerberosAccountsSignedIn", IDS_SETTINGS_KERBEROS_ACCOUNTS_SIGNED_IN},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
-
- // Toggles the Chrome OS Kerberos Accounts submenu in the People section.
- // Note that the handler is also dependent on this pref.
- html_source->AddBoolean("isKerberosEnabled",
- IsKerberosEnabled(kerberos_credentials_manager));
+ html_source->AddLocalizedStrings(kLocalizedStrings);
PrefService* local_state = g_browser_process->local_state();
@@ -182,8 +188,9 @@ KerberosAccountsHandler::CreateIfKerberosEnabled(Profile* profile) {
void KerberosAccountsHandler::AddLoadTimeKerberosStrings(
content::WebUIDataSource* html_source,
KerberosCredentialsManager* kerberos_credentials_manager) {
+ AddKerberosSettingsVisibilityFlags(html_source, kerberos_credentials_manager);
AddKerberosTitleStrings(html_source);
- AddKerberosAccountsPageStrings(html_source, kerberos_credentials_manager);
+ AddKerberosAccountsPageStrings(html_source);
AddKerberosAddAccountDialogStrings(html_source);
}
@@ -387,11 +394,11 @@ void KerberosAccountsHandler::HandleSetAsActiveKerberosAccount(
}
void KerberosAccountsHandler::OnJavascriptAllowed() {
- credentials_manager_observer_.Add(kerberos_credentials_manager_);
+ credentials_manager_observation_.Observe(kerberos_credentials_manager_);
}
void KerberosAccountsHandler::OnJavascriptDisallowed() {
- credentials_manager_observer_.RemoveAll();
+ credentials_manager_observation_.Reset();
}
void KerberosAccountsHandler::OnAccountsChanged() {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h
index 622f2a70896..9c2d1e3a9d3 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_accounts_handler.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/dbus/kerberos/kerberos_service.pb.h"
@@ -92,9 +92,9 @@ class KerberosAccountsHandler : public ::settings::SettingsPageUIHandler,
// This instance can be added as observer to KerberosCredentialsManager.
// This class keeps track of that and removes this instance on destruction.
- ScopedObserver<KerberosCredentialsManager,
- KerberosCredentialsManager::Observer>
- credentials_manager_observer_{this};
+ base::ScopedObservation<KerberosCredentialsManager,
+ KerberosCredentialsManager::Observer>
+ credentials_manager_observation_{this};
// Not owned.
KerberosCredentialsManager* kerberos_credentials_manager_;
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 1b1a043b592..ea6d1082978 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/kerberos_section.cc
@@ -4,12 +4,12 @@
#include "chrome/browser/ui/webui/settings/chromeos/kerberos_section.h"
+#include "ash/constants/ash_features.h"
#include "base/no_destructor.h"
#include "chrome/browser/profiles/profile.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 "chromeos/constants/chromeos_features.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -19,7 +19,36 @@ namespace {
const std::vector<SearchConcept>& GetKerberosSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
- // TODO(fsandrade): add Kerberos search tags here.
+ {IDS_OS_SETTINGS_TAG_KERBEROS_SECTION,
+ mojom::kKerberosSectionPath,
+ mojom::SearchResultIcon::kAuthKey,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSection,
+ {.section = mojom::Section::kKerberos}},
+ {IDS_OS_SETTINGS_TAG_KERBEROS,
+ mojom::kKerberosAccountsV2SubpagePath,
+ mojom::SearchResultIcon::kAuthKey,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kKerberosAccountsV2}},
+ {IDS_OS_SETTINGS_TAG_KERBEROS_ADD,
+ mojom::kKerberosAccountsV2SubpagePath,
+ mojom::SearchResultIcon::kAuthKey,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kAddKerberosTicketV2}},
+ {IDS_OS_SETTINGS_TAG_KERBEROS_REMOVE,
+ mojom::kKerberosAccountsV2SubpagePath,
+ mojom::SearchResultIcon::kAuthKey,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kRemoveKerberosTicketV2}},
+ {IDS_OS_SETTINGS_TAG_KERBEROS_ACTIVE,
+ mojom::kKerberosAccountsV2SubpagePath,
+ mojom::SearchResultIcon::kAuthKey,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kSetActiveKerberosTicketV2}},
});
return *tags;
}
@@ -53,8 +82,8 @@ KerberosSection::~KerberosSection() {
}
void KerberosSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
- // TODO(fsandrade): add Kerberos section title to corresponding UI element,
- // when it's created.
+ html_source->AddLocalizedString("kerberosPageTitle",
+ IDS_OS_SETTINGS_KERBEROS);
KerberosAccountsHandler::AddLoadTimeKerberosStrings(
html_source, kerberos_credentials_manager_);
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc
index 162e26a16e9..b28881b432c 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/settings/chromeos/languages_section.h"
+#include "ash/constants/ash_features.h"
+#include "ash/constants/ash_pref_names.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
@@ -14,8 +16,6 @@
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
-#include "chromeos/constants/chromeos_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/spellcheck/browser/pref_names.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -196,7 +196,7 @@ void AddSmartInputsStrings(content::WebUIDataSource* html_source,
{"emojiSuggestionDescription",
IDS_SETTINGS_SUGGESTIONS_EMOJI_SUGGESTION_DESCRIPTION},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("allowAssistivePersonalInfo",
IsAssistivePersonalInfoAllowed());
@@ -254,7 +254,7 @@ void AddInputMethodOptionsStrings(content::WebUIDataSource* html_source) {
{"inputMethodOptionsColemakKeyboard",
IDS_SETTINGS_INPUT_METHOD_OPTIONS_KEYBOARD_COLEMAK},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddLanguagesPageStringsV2(content::WebUIDataSource* html_source) {
@@ -285,7 +285,7 @@ void AddLanguagesPageStringsV2(content::WebUIDataSource* html_source) {
{"changeDeviceLanguageConfirmButtonLabel",
IDS_OS_SETTINGS_LANGUAGES_CHANGE_DEVICE_LANGUAGE_CONFIRM_BUTTON_LABEL},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString(
"languagesPreferenceDescription",
@@ -342,7 +342,7 @@ void AddInputPageStringsV2(content::WebUIDataSource* html_source) {
{"noDictionaryWordsLabel",
IDS_OS_SETTINGS_LANGUAGES_NO_DICTIONARY_WORDS_LABEL},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
} // namespace
@@ -412,8 +412,9 @@ void LanguagesSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"removeLanguage", IDS_SETTINGS_LANGUAGES_LANGUAGES_LIST_REMOVE},
{"addLanguages", IDS_SETTINGS_LANGUAGES_LANGUAGES_ADD},
{"moveUp", IDS_SETTINGS_LANGUAGES_LANGUAGES_LIST_MOVE_UP},
+ {"noSearchResults", IDS_SEARCH_NO_RESULTS},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
AddSmartInputsStrings(html_source, IsEmojiSuggestionAllowed());
AddInputMethodOptionsStrings(html_source);
AddLanguagesPageStringsV2(html_source);
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 cd5997ecb7b..023895cfeb0 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc
@@ -4,19 +4,21 @@
#include "chrome/browser/ui/webui/settings/chromeos/main_section.h"
+#include "ash/constants/ash_features.h"
#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
#include "base/feature_list.h"
#include "base/i18n/message_formatter.h"
#include "base/i18n/number_formatting.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/minimum_version_policy_handler.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
+#include "chrome/browser/ui/webui/plural_string_handler.h"
#include "chrome/browser/ui/webui/policy_indicator_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/browser_lifetime_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h"
@@ -27,7 +29,6 @@
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/os_settings_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -47,7 +48,7 @@ void AddSearchInSettingsStrings(content::WebUIDataSource* html_source) {
{"searchResultSelected", IDS_OS_SEARCH_RESULT_ROW_A11Y_RESULT_SELECTED},
{"clearSearch", IDS_CLEAR_SEARCH},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString(
"searchNoOsResultsHelp",
@@ -78,7 +79,7 @@ void AddUpdateRequiredEolStrings(content::WebUIDataSource* html_source) {
// deadline.
int days_remaining = days.value() ? days.value() : 1;
base::string16 domain_name =
- base::UTF8ToUTF16(connector->GetEnterpriseDisplayDomain());
+ base::UTF8ToUTF16(connector->GetEnterpriseDomainManager());
base::string16 link_url =
base::UTF8ToUTF16(chrome::kChromeUIManagementURL);
if (days_remaining == 7) {
@@ -91,7 +92,7 @@ void AddUpdateRequiredEolStrings(content::WebUIDataSource* html_source) {
l10n_util::GetStringUTF16(
IDS_SETTINGS_UPDATE_REQUIRED_EOL_BANNER_DAYS),
days_remaining,
- base::UTF8ToUTF16(connector->GetEnterpriseDisplayDomain()),
+ base::UTF8ToUTF16(connector->GetEnterpriseDomainManager()),
ui::GetChromeOSDeviceName(),
base::UTF8ToUTF16(chrome::kChromeUIManagementURL));
}
@@ -156,7 +157,7 @@ void MainSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"large", IDS_SETTINGS_LARGE_FONT},
{"veryLarge", IDS_SETTINGS_VERY_LARGE_FONT},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
// This handler is for chrome://os-settings.
html_source->AddBoolean("isOSSettings", true);
@@ -186,6 +187,8 @@ void MainSection::AddHandlers(content::WebUI* web_ui) {
web_ui->AddMessageHandler(
std::make_unique<::settings::BrowserLifetimeHandler>());
+
+ web_ui->AddMessageHandler(CreatePluralStringHandler());
}
int MainSection::GetSectionNameMessageId() const {
@@ -239,5 +242,20 @@ void MainSection::AddChromeOSUserStrings(
base::ASCIIToUTF16(primary_user_email)));
}
+std::unique_ptr<PluralStringHandler> MainSection::CreatePluralStringHandler() {
+ auto plural_string_handler = std::make_unique<PluralStringHandler>();
+ if (chromeos::features::IsAccountManagementFlowsV2Enabled()) {
+ plural_string_handler->AddLocalizedString("profileLabel",
+ IDS_OS_SETTINGS_PROFILE_LABEL_V2);
+ } else {
+ plural_string_handler->AddLocalizedString("profileLabel",
+ IDS_OS_SETTINGS_PROFILE_LABEL);
+ }
+ plural_string_handler->AddLocalizedString(
+ "nearbyShareContactVisibilityNumUnreachable",
+ IDS_NEARBY_CONTACT_VISIBILITY_NUM_UNREACHABLE);
+ return plural_string_handler;
+}
+
} // namespace settings
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.h
index 569b4827d51..3260534dd67 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.h
@@ -8,6 +8,8 @@
#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
+class PluralStringHandler;
+
namespace content {
class WebUIDataSource;
} // namespace content
@@ -35,6 +37,7 @@ class MainSection : public OsSettingsSection {
void RegisterHierarchy(HierarchyGenerator* generator) const override;
void AddChromeOSUserStrings(content::WebUIDataSource* html_source);
+ std::unique_ptr<PluralStringHandler> CreatePluralStringHandler();
};
} // namespace settings
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 158e13f7d39..e6f7a19e4a2 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
@@ -4,21 +4,21 @@
#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h"
+#include "ash/constants/ash_features.h"
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/values.h"
+#include "chrome/browser/ash/login/quick_unlock/auth_token.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_factory.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_storage.h"
#include "chrome/browser/chromeos/android_sms/android_sms_pairing_state_tracker_impl.h"
#include "chrome/browser/chromeos/android_sms/android_sms_urls.h"
-#include "chrome/browser/chromeos/login/quick_unlock/auth_token.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h"
#include "chromeos/components/multidevice/logging/logging.h"
#include "chromeos/components/phonehub/util/histogram_util.h"
#include "chromeos/components/proximity_auth/proximity_auth_pref_names.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/services/multidevice_setup/public/cpp/prefs.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/prefs/pref_service.h"
@@ -70,11 +70,7 @@ MultideviceHandler::MultideviceHandler(
multidevice_setup_client_(multidevice_setup_client),
notification_access_manager_(notification_access_manager),
android_sms_pairing_state_tracker_(android_sms_pairing_state_tracker),
- android_sms_app_manager_(android_sms_app_manager),
- multidevice_setup_observer_(this),
- android_sms_pairing_state_tracker_observer_(this),
- android_sms_app_manager_observer_(this),
- notification_access_manager_observer_(this) {
+ android_sms_app_manager_(android_sms_app_manager) {
pref_change_registrar_.Init(prefs_);
}
@@ -133,18 +129,19 @@ void MultideviceHandler::RegisterMessages() {
void MultideviceHandler::OnJavascriptAllowed() {
if (multidevice_setup_client_)
- multidevice_setup_observer_.Add(multidevice_setup_client_);
+ multidevice_setup_observation_.Observe(multidevice_setup_client_);
if (notification_access_manager_)
- notification_access_manager_observer_.Add(notification_access_manager_);
+ notification_access_manager_observation_.Observe(
+ notification_access_manager_);
if (android_sms_pairing_state_tracker_) {
- android_sms_pairing_state_tracker_observer_.Add(
+ android_sms_pairing_state_tracker_observation_.Observe(
android_sms_pairing_state_tracker_);
}
if (android_sms_app_manager_)
- android_sms_app_manager_observer_.Add(android_sms_app_manager_);
+ android_sms_app_manager_observation_.Observe(android_sms_app_manager_);
pref_change_registrar_.Add(
proximity_auth::prefs::kProximityAuthIsChromeOSLoginEnabled,
@@ -161,21 +158,30 @@ void MultideviceHandler::OnJavascriptAllowed() {
void MultideviceHandler::OnJavascriptDisallowed() {
pref_change_registrar_.RemoveAll();
- if (multidevice_setup_client_)
- multidevice_setup_observer_.Remove(multidevice_setup_client_);
+ if (multidevice_setup_client_) {
+ DCHECK(multidevice_setup_observation_.IsObservingSource(
+ multidevice_setup_client_));
+ multidevice_setup_observation_.Reset();
+ }
if (notification_access_manager_) {
- notification_access_manager_observer_.Remove(notification_access_manager_);
+ DCHECK(notification_access_manager_observation_.IsObservingSource(
+ notification_access_manager_));
+ notification_access_manager_observation_.Reset();
notification_access_operation_.reset();
}
if (android_sms_pairing_state_tracker_) {
- android_sms_pairing_state_tracker_observer_.Remove(
- android_sms_pairing_state_tracker_);
+ DCHECK(android_sms_pairing_state_tracker_observation_.IsObservingSource(
+ android_sms_pairing_state_tracker_));
+ android_sms_pairing_state_tracker_observation_.Reset();
}
- if (android_sms_app_manager_)
- android_sms_app_manager_observer_.Remove(android_sms_app_manager_);
+ if (android_sms_app_manager_) {
+ DCHECK(android_sms_app_manager_observation_.IsObservingSource(
+ android_sms_app_manager_));
+ android_sms_app_manager_observation_.Reset();
+ }
// Ensure that pending callbacks do not complete and cause JS to be evaluated.
callback_weak_ptr_factory_.InvalidateWeakPtrs();
@@ -275,7 +281,7 @@ void MultideviceHandler::HandleSetFeatureEnabledState(
base::BindOnce(&MultideviceHandler::OnSetFeatureStateEnabledResult,
callback_weak_ptr_factory_.GetWeakPtr(), callback_id));
- if (feature == multidevice_setup::mojom::Feature::kPhoneHub) {
+ if (enabled && feature == multidevice_setup::mojom::Feature::kPhoneHub) {
phonehub::util::LogFeatureOptInEntryPoint(
phonehub::util::OptInEntryPoint::kSettings);
}
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 e4217ae422f..58e557548b2 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
@@ -7,7 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/chromeos/android_sms/android_sms_app_manager.h"
#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -137,18 +137,19 @@ class MultideviceHandler
android_sms_pairing_state_tracker_;
android_sms::AndroidSmsAppManager* android_sms_app_manager_;
- ScopedObserver<multidevice_setup::MultiDeviceSetupClient,
- multidevice_setup::MultiDeviceSetupClient::Observer>
- multidevice_setup_observer_;
- ScopedObserver<multidevice_setup::AndroidSmsPairingStateTracker,
- multidevice_setup::AndroidSmsPairingStateTracker::Observer>
- android_sms_pairing_state_tracker_observer_;
- ScopedObserver<android_sms::AndroidSmsAppManager,
- android_sms::AndroidSmsAppManager::Observer>
- android_sms_app_manager_observer_;
- ScopedObserver<phonehub::NotificationAccessManager,
- phonehub::NotificationAccessManager::Observer>
- notification_access_manager_observer_;
+ base::ScopedObservation<multidevice_setup::MultiDeviceSetupClient,
+ multidevice_setup::MultiDeviceSetupClient::Observer>
+ multidevice_setup_observation_{this};
+ base::ScopedObservation<
+ multidevice_setup::AndroidSmsPairingStateTracker,
+ multidevice_setup::AndroidSmsPairingStateTracker::Observer>
+ android_sms_pairing_state_tracker_observation_{this};
+ base::ScopedObservation<android_sms::AndroidSmsAppManager,
+ android_sms::AndroidSmsAppManager::Observer>
+ android_sms_app_manager_observation_{this};
+ base::ScopedObservation<phonehub::NotificationAccessManager,
+ phonehub::NotificationAccessManager::Observer>
+ notification_access_manager_observation_{this};
// Used to cancel callbacks when JavaScript becomes disallowed.
base::WeakPtrFactory<MultideviceHandler> callback_weak_ptr_factory_{this};
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 fa14f1a7a6d..2ead0548f4d 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
@@ -6,13 +6,13 @@
#include <memory>
+#include "ash/constants/ash_features.h"
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/chromeos/android_sms/android_sms_urls.h"
#include "chrome/browser/chromeos/android_sms/fake_android_sms_app_manager.h"
#include "chromeos/components/multidevice/remote_device_test_util.h"
#include "chromeos/components/phonehub/fake_notification_access_manager.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/services/multidevice_setup/public/cpp/fake_android_sms_pairing_state_tracker.h"
#include "chromeos/services/multidevice_setup/public/cpp/fake_multidevice_setup_client.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
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 ee9b3817242..a7c74bc84be 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc
@@ -4,12 +4,13 @@
#include "chrome/browser/ui/webui/settings/chromeos/multidevice_section.h"
+#include "ash/constants/ash_features.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/android_sms/android_sms_service.h"
-#include "chrome/browser/nearby_sharing/common/nearby_share_features.h"
#include "chrome/browser/nearby_sharing/common/nearby_share_prefs.h"
+#include "chrome/browser/nearby_sharing/nearby_sharing_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/nearby_share/shared_resources.h"
#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h"
@@ -20,7 +21,7 @@
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/components/phonehub/phone_hub_manager.h"
-#include "chromeos/constants/chromeos_features.h"
+#include "chromeos/components/phonehub/url_constants.h"
#include "chromeos/services/multidevice_setup/public/cpp/prefs.h"
#include "chromeos/services/multidevice_setup/public/cpp/url_provider.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
@@ -35,6 +36,8 @@ namespace chromeos {
namespace settings {
namespace {
+using FeatureState = multidevice_setup::mojom::FeatureState;
+
const std::vector<SearchConcept>& GetMultiDeviceOptedInSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags(
{{IDS_OS_SETTINGS_TAG_MULTIDEVICE_FORGET,
@@ -181,6 +184,32 @@ const std::vector<SearchConcept>& GetNearbyShareOnSearchConcepts() {
{.setting = mojom::Setting::kNearbyShareOnOff},
{IDS_OS_SETTINGS_TAG_NEARBY_SHARE_TURN_OFF_ALT1,
SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_NEARBY_SHARE_DEVICE_NAME,
+ mojom::kNearbyShareSubpagePath,
+ mojom::SearchResultIcon::kNearbyShare,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kNearbyShareDeviceName}},
+ {IDS_OS_SETTINGS_TAG_NEARBY_SHARE_DEVICE_VISIBILITY,
+ mojom::kNearbyShareSubpagePath,
+ mojom::SearchResultIcon::kNearbyShare,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kNearbyShareDeviceVisibility},
+ {IDS_OS_SETTINGS_TAG_NEARBY_SHARE_DEVICE_VISIBILITY_ALT1,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_NEARBY_SHARE_CONTACTS,
+ mojom::kNearbyShareSubpagePath,
+ mojom::SearchResultIcon::kNearbyShare,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kNearbyShareContacts}},
+ {IDS_OS_SETTINGS_TAG_NEARBY_SHARE_DATA_USAGE,
+ mojom::kNearbyShareSubpagePath,
+ mojom::SearchResultIcon::kNearbyShare,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kNearbyShareDataUsage}},
});
return *tags;
}
@@ -207,7 +236,7 @@ void AddEasyUnlockStrings(content::WebUIDataSource* html_source) {
{"easyUnlockUnlockDeviceAndAllowSignin",
IDS_SETTINGS_EASY_UNLOCK_UNLOCK_DEVICE_AND_ALLOW_SIGNIN},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
bool IsOptedIn(multidevice_setup::mojom::HostStatus host_status) {
@@ -230,7 +259,8 @@ MultiDeviceSection::MultiDeviceSection(
phone_hub_manager_(phone_hub_manager),
android_sms_service_(android_sms_service),
pref_service_(pref_service) {
- if (base::FeatureList::IsEnabled(::features::kNearbySharing)) {
+ if (NearbySharingServiceFactory::IsNearbyShareSupportedForBrowserContext(
+ profile)) {
pref_change_registrar_.Init(pref_service_);
pref_change_registrar_.Add(
::prefs::kNearbySharingEnabledPrefName,
@@ -269,26 +299,26 @@ void MultiDeviceSection::AddLoadTimeData(
{"multideviceSmartLockItemTitle", IDS_SETTINGS_EASY_UNLOCK_SECTION_TITLE},
{"multidevicePhoneHubItemTitle",
IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_SECTION_TITLE},
+ {"multidevicePhoneHubLearnMoreLabel",
+ IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_LEARN_MORE_LABEL},
{"multidevicePhoneHubNotificationsItemTitle",
IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_NOTIFICATIONS_SECTION_TITLE},
{"multidevicePhoneHubTaskContinuationItemTitle",
IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_TASK_CONTINUATION_SECTION_TITLE},
{"multidevicePhoneHubTaskContinuationItemSummary",
IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_TASK_CONTINUATION_SUMMARY},
+ {"multidevicePhoneHubTaskContinuationSyncLabel",
+ IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_TASK_CONTINUATION_SYNC_LABEL},
{"multideviceWifiSyncItemTitle",
IDS_SETTINGS_MULTIDEVICE_WIFI_SYNC_SECTION_TITLE},
{"multideviceWifiSyncChromeSyncLabel",
IDS_SETTINGS_MULTIDEVICE_WIFI_SYNC_CHROME_SYNC_LABEL},
{"multideviceWifiSyncLearnMoreLabel",
IDS_SETTINGS_MULTIDEVICE_WIFI_SYNC_LEARN_MORE_LABEL},
- {"multideviceNotificationAccessSetupAckTitle",
- IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_ACK_TITLE},
{"multideviceNotificationAccessSetupConnectingTitle",
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_CONNECTING_TITLE},
{"multideviceNotificationAccessSetupAwaitingResponseTitle",
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_AWAITING_RESPONSE_TITLE},
- {"multideviceNotificationAccessSetupAwaitingResponseSummary",
- IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_AWAITING_RESPONSE_SUMMARY},
{"multideviceNotificationAccessSetupInstructions",
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_INSTRUCTIONS},
{"multideviceNotificationAccessSetupCompletedTitle",
@@ -321,7 +351,7 @@ void MultiDeviceSection::AddLoadTimeData(
{"multideviceForgetDeviceDisconnect",
IDS_SETTINGS_MULTIDEVICE_FORGET_THIS_DEVICE_DISCONNECT},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean(
"multideviceAllowedByPolicy",
@@ -387,18 +417,21 @@ void MultiDeviceSection::AddLoadTimeData(
ui::GetChromeOSDeviceName()));
html_source->AddString(
"multidevicePhoneHubNotificationsItemSummary",
- l10n_util::GetStringFUTF16(
- IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_NOTIFICATIONS_SUMMARY,
- ui::GetChromeOSDeviceName()));
- // TODO(https://crbug.com/1144053): Replace with updated URL.
+ ui::SubstituteChromeOSDeviceType(
+ IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_NOTIFICATIONS_SUMMARY));
+ html_source->AddString(
+ "multideviceNotificationAccessSetupAckTitle",
+ ui::SubstituteChromeOSDeviceType(
+ IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_ACK_TITLE));
+ html_source->AddString(
+ "multideviceNotificationAccessSetupAwaitingResponseSummary",
+ ui::SubstituteChromeOSDeviceType(
+ IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_AWAITING_RESPONSE_SUMMARY));
html_source->AddString(
"multideviceNotificationAccessSetupAccessProhibitedSummary",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_ACCESS_PROHIBITED_SUMMARY,
- base::UTF8ToUTF16(
- multidevice_setup::
- GetBoardSpecificBetterTogetherSuiteLearnMoreUrl()
- .spec())));
+ GetHelpUrlWithBoard(phonehub::kPhoneHubLearnMoreLink)));
html_source->AddString(
"multideviceWifiSyncItemSummary",
l10n_util::GetStringFUTF16(
@@ -409,10 +442,23 @@ void MultiDeviceSection::AddLoadTimeData(
l10n_util::GetStringFUTF16(
IDS_SETTINGS_MULTIDEVICE_ENABLE_WIFI_SYNC_V1_SUMMARY,
GetHelpUrlWithBoard(chrome::kWifiSyncLearnMoreURL)));
+ html_source->AddString(
+ "multidevicePhoneHubTaskContinuationDisabledSummary",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_TASK_CONTINUATION_DISABLED_SUMMARY,
+ GetHelpUrlWithBoard(phonehub::kPhoneHubLearnMoreLink)));
AddEasyUnlockStrings(html_source);
+
+ // We still need to register strings even if Nearby Share is not supported.
+ // For example, the HTML is always built but only displayed if Nearby Share is
+ // supported.
::settings::AddNearbyShareData(html_source);
RegisterNearbySharedStrings(html_source);
+ html_source->AddBoolean(
+ "isNearbyShareSupported",
+ NearbySharingServiceFactory::IsNearbyShareSupportedForBrowserContext(
+ profile()));
}
void MultiDeviceSection::AddHandlers(content::WebUI* web_ui) {
@@ -504,6 +550,10 @@ void MultiDeviceSection::RegisterHierarchy(
mojom::SearchResultDefaultRank::kMedium, mojom::kNearbyShareSubpagePath);
static constexpr mojom::Setting kNearbyShareSettings[] = {
mojom::Setting::kNearbyShareOnOff,
+ mojom::Setting::kNearbyShareDeviceName,
+ mojom::Setting::kNearbyShareDeviceVisibility,
+ mojom::Setting::kNearbyShareContacts,
+ mojom::Setting::kNearbyShareDataUsage,
};
RegisterNestedSettingBulk(mojom::Subpage::kNearbyShare, kNearbyShareSettings,
generator);
@@ -515,16 +565,10 @@ void MultiDeviceSection::OnHostStatusChanged(
host_status_with_device) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetMultiDeviceOptedOutSearchConcepts());
- updater.RemoveSearchTags(GetMultiDeviceOptedInPhoneHubSearchConcepts());
- updater.RemoveSearchTags(GetMultiDeviceOptedInWifiSyncSearchConcepts());
updater.RemoveSearchTags(GetMultiDeviceOptedInSearchConcepts());
if (IsOptedIn(host_status_with_device.first)) {
updater.AddSearchTags(GetMultiDeviceOptedInSearchConcepts());
- if (features::IsPhoneHubEnabled())
- updater.AddSearchTags(GetMultiDeviceOptedInPhoneHubSearchConcepts());
- if (features::IsWifiSyncAndroidEnabled())
- updater.AddSearchTags(GetMultiDeviceOptedInWifiSyncSearchConcepts());
} else {
updater.AddSearchTags(GetMultiDeviceOptedOutSearchConcepts());
}
@@ -535,11 +579,17 @@ void MultiDeviceSection::OnFeatureStatesChanged(
feature_states_map) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetSmartLockOptionsSearchConcepts());
+ updater.RemoveSearchTags(GetMultiDeviceOptedInPhoneHubSearchConcepts());
+ updater.RemoveSearchTags(GetMultiDeviceOptedInWifiSyncSearchConcepts());
if (feature_states_map.at(multidevice_setup::mojom::Feature::kSmartLock) ==
multidevice_setup::mojom::FeatureState::kEnabledByUser) {
updater.AddSearchTags(GetSmartLockOptionsSearchConcepts());
}
+ if (IsFeatureSupported(multidevice_setup::mojom::Feature::kPhoneHub))
+ updater.AddSearchTags(GetMultiDeviceOptedInPhoneHubSearchConcepts());
+ if (IsFeatureSupported(multidevice_setup::mojom::Feature::kWifiSync))
+ updater.AddSearchTags(GetMultiDeviceOptedInWifiSyncSearchConcepts());
}
void MultiDeviceSection::OnNearbySharingEnabledChanged() {
@@ -554,5 +604,13 @@ void MultiDeviceSection::OnNearbySharingEnabledChanged() {
}
}
+bool MultiDeviceSection::IsFeatureSupported(
+ multidevice_setup::mojom::Feature feature) {
+ const FeatureState feature_state =
+ multidevice_setup_client_->GetFeatureState(feature);
+ return feature_state != FeatureState::kNotSupportedByPhone &&
+ feature_state != FeatureState::kNotSupportedByChromebook;
+}
+
} // namespace settings
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.h
index f420b8a9c22..4cf23cbfd3f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.h
@@ -68,6 +68,8 @@ class MultiDeviceSection
// Nearby Share enabled pref change observer.
void OnNearbySharingEnabledChanged();
+ bool IsFeatureSupported(multidevice_setup::mojom::Feature feature);
+
multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client_;
phonehub::PhoneHubManager* phone_hub_manager_;
android_sms::AndroidSmsService* android_sms_service_;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/on_startup_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/on_startup_section.cc
new file mode 100644
index 00000000000..21700554c8d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/on_startup_section.cc
@@ -0,0 +1,98 @@
+// 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/on_startup_section.h"
+
+#include "ash/public/cpp/ash_features.h"
+#include "base/no_destructor.h"
+#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/webui_util.h"
+#include "chrome/grit/generated_resources.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/base/webui/web_ui_util.h"
+
+namespace chromeos {
+namespace settings {
+namespace {
+
+const std::vector<SearchConcept>& GetOnStartupSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_ON_STARTUP,
+ mojom::kOnStartupSectionPath,
+ mojom::SearchResultIcon::kStartup,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSection,
+ {.section = mojom::Section::kOnStartup}},
+ {IDS_OS_SETTINGS_TAG_RESTORE_APPS_AND_PAGES,
+ mojom::kOnStartupSectionPath,
+ mojom::SearchResultIcon::kStartup,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kRestoreAppsAndPages}},
+ });
+ return *tags;
+}
+
+bool ShouldShowStartup() {
+ return ash::features::IsFullRestoreEnabled();
+}
+
+} // namespace
+
+OnStartupSection::OnStartupSection(Profile* profile,
+ SearchTagRegistry* search_tag_registry,
+ PrefService* pref_service)
+ : OsSettingsSection(profile, search_tag_registry) {
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+
+ if (ShouldShowStartup()) {
+ updater.AddSearchTags(GetOnStartupSearchConcepts());
+ }
+}
+
+OnStartupSection::~OnStartupSection() = default;
+
+void OnStartupSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
+ static constexpr webui::LocalizedString kLocalizedStrings[] = {
+ {"onStartupPageTitle", IDS_OS_SETTINGS_ON_STARTUP},
+ {"onStartupRadioGroundTitle",
+ IDS_OS_SETTINGS_ON_STARTUP_RADIO_GROUP_TITLE},
+ {"onStartupAlways", IDS_OS_SETTINGS_ON_STARTUP_ALWAYS},
+ {"onStartupAskEveryTime", IDS_OS_SETTINGS_ON_STARTUP_ASK_EVERY_TIME},
+ {"onStartupDoNotRestore", IDS_OS_SETTINGS_ON_STARTUP_DO_NOT_RESTORE},
+ };
+
+ html_source->AddLocalizedStrings(kLocalizedStrings);
+
+ html_source->AddBoolean("showStartup", ShouldShowStartup());
+}
+
+int OnStartupSection::GetSectionNameMessageId() const {
+ return IDS_OS_SETTINGS_ON_STARTUP;
+}
+
+mojom::Section OnStartupSection::GetSection() const {
+ return mojom::Section::kOnStartup;
+}
+
+mojom::SearchResultIcon OnStartupSection::GetSectionIcon() const {
+ return mojom::SearchResultIcon::kStartup;
+}
+
+std::string OnStartupSection::GetSectionPath() const {
+ return mojom::kOnStartupSectionPath;
+}
+
+bool OnStartupSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
+void OnStartupSection::RegisterHierarchy(HierarchyGenerator* generator) const {
+ generator->RegisterTopLevelSetting(mojom::Setting::kRestoreAppsAndPages);
+}
+
+} // namespace settings
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/on_startup_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/on_startup_section.h
new file mode 100644
index 00000000000..141f5a18d01
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/on_startup_section.h
@@ -0,0 +1,38 @@
+// 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_ON_STARTUP_SECTION_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ON_STARTUP_SECTION_H_
+
+#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
+#include "components/prefs/pref_change_registrar.h"
+
+namespace chromeos {
+namespace settings {
+
+class SearchTagRegistry;
+
+// Provides UI strings and search tags for On Startup settings.
+class OnStartupSection : public OsSettingsSection {
+ public:
+ OnStartupSection(Profile* profile,
+ SearchTagRegistry* search_tag_registry,
+ PrefService* pref_service);
+ ~OnStartupSection() override;
+
+ private:
+ // OsSettingsSection:
+ void AddLoadTimeData(content::WebUIDataSource* html_source) override;
+ int GetSectionNameMessageId() const override;
+ mojom::Section GetSection() const override;
+ mojom::SearchResultIcon GetSectionIcon() const override;
+ std::string GetSectionPath() const override;
+ void RegisterHierarchy(HierarchyGenerator* generator) const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
+};
+
+} // namespace settings
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ON_STARTUP_SECTION_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc
index 19fa718b1b5..9190e6f6ba9 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.cc
@@ -30,10 +30,6 @@ bool ShouldShowParentalControlSettings(const Profile* profile) {
if (profile->IsGuestSession())
return false;
- // Settings are for Family Link, not legacy parental controls
- if (profile->IsLegacySupervised())
- return false;
-
return profile->IsChild() ||
!profile->GetProfilePolicyConnector()->IsManaged();
}
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 8ab9ea90fc1..552e7c79439 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
@@ -11,8 +11,6 @@
#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 "chromeos/components/local_search_service/local_search_service_sync.h"
-#include "chromeos/constants/chromeos_features.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
@@ -21,7 +19,7 @@ namespace settings {
OsSettingsManager::OsSettingsManager(
Profile* profile,
- local_search_service::LocalSearchServiceSync* local_search_service,
+ local_search_service::LocalSearchServiceProxy* local_search_service_proxy,
multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client,
phonehub::PhoneHubManager* phone_hub_manager,
syncer::SyncService* sync_service,
@@ -30,9 +28,10 @@ OsSettingsManager::OsSettingsManager(
ArcAppListPrefs* arc_app_list_prefs,
signin::IdentityManager* identity_manager,
android_sms::AndroidSmsService* android_sms_service,
- CupsPrintersManager* printers_manager)
+ CupsPrintersManager* printers_manager,
+ apps::AppServiceProxy* app_service_proxy)
: search_tag_registry_(
- std::make_unique<SearchTagRegistry>(local_search_service)),
+ std::make_unique<SearchTagRegistry>(local_search_service_proxy)),
sections_(
std::make_unique<OsSettingsSections>(profile,
search_tag_registry_.get(),
@@ -44,7 +43,8 @@ OsSettingsManager::OsSettingsManager(
arc_app_list_prefs,
identity_manager,
android_sms_service,
- printers_manager)),
+ printers_manager,
+ app_service_proxy)),
hierarchy_(std::make_unique<Hierarchy>(sections_.get())),
settings_user_action_tracker_(
std::make_unique<SettingsUserActionTracker>(hierarchy_.get(),
@@ -53,7 +53,7 @@ OsSettingsManager::OsSettingsManager(
std::make_unique<SearchHandler>(search_tag_registry_.get(),
sections_.get(),
hierarchy_.get(),
- local_search_service)) {}
+ local_search_service_proxy)) {}
OsSettingsManager::~OsSettingsManager() = default;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h
index 531ac379e4b..5377a69d657 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h
@@ -14,6 +14,10 @@ class ArcAppListPrefs;
class Profile;
class SupervisedUserService;
+namespace apps {
+class AppServiceProxy;
+} // namespace apps
+
namespace content {
class WebUI;
class WebUIDataSource;
@@ -37,7 +41,7 @@ class AndroidSmsService;
} // namespace android_sms
namespace local_search_service {
-class LocalSearchServiceSync;
+class LocalSearchServiceProxy;
} // namespace local_search_service
namespace multidevice_setup {
@@ -64,7 +68,7 @@ class SettingsUserActionTracker;
//
// (1) Support search queries for settings content. OsSettingsManager is
// responsible for updating the kCroSettings index of the
-// LocalSearchServiceSync
+// LocalSearchService
// with search tags corresponding to all settings which are available.
//
// The availability of settings depends on the user's account (e.g.,
@@ -86,7 +90,7 @@ class OsSettingsManager : public KeyedService {
public:
OsSettingsManager(
Profile* profile,
- local_search_service::LocalSearchServiceSync* local_search_service,
+ local_search_service::LocalSearchServiceProxy* local_search_service_proxy,
multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client,
phonehub::PhoneHubManager* phone_hub_manager,
syncer::SyncService* sync_service,
@@ -95,7 +99,8 @@ class OsSettingsManager : public KeyedService {
ArcAppListPrefs* arc_app_list_prefs,
signin::IdentityManager* identity_manager,
android_sms::AndroidSmsService* android_sms_service,
- CupsPrintersManager* printers_manager);
+ CupsPrintersManager* printers_manager,
+ apps::AppServiceProxy* app_service_proxy);
OsSettingsManager(const OsSettingsManager& other) = delete;
OsSettingsManager& operator=(const OsSettingsManager& other) = delete;
~OsSettingsManager() override;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.cc
index 3c390d1a166..cd270e55fbd 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
@@ -4,12 +4,13 @@
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.h"
+#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h"
#include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager_factory.h"
#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h"
#include "chrome/browser/chromeos/phonehub/phone_hub_manager_factory.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager_factory.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
@@ -17,7 +18,7 @@
#include "chrome/browser/sync/profile_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/local_search_service_sync_factory.h"
+#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
namespace chromeos {
@@ -39,7 +40,8 @@ OsSettingsManagerFactory::OsSettingsManagerFactory()
: BrowserContextKeyedServiceFactory(
"OsSettingsManager",
BrowserContextDependencyManager::GetInstance()) {
- DependsOn(local_search_service::LocalSearchServiceSyncFactory::GetInstance());
+ DependsOn(
+ local_search_service::LocalSearchServiceProxyFactory::GetInstance());
DependsOn(multidevice_setup::MultiDeviceSetupClientFactory::GetInstance());
DependsOn(phonehub::PhoneHubManagerFactory::GetInstance());
DependsOn(ProfileSyncServiceFactory::GetInstance());
@@ -49,6 +51,7 @@ OsSettingsManagerFactory::OsSettingsManagerFactory()
DependsOn(IdentityManagerFactory::GetInstance());
DependsOn(android_sms::AndroidSmsServiceFactory::GetInstance());
DependsOn(CupsPrintersManagerFactory::GetInstance());
+ DependsOn(apps::AppServiceProxyFactory::GetInstance());
}
OsSettingsManagerFactory::~OsSettingsManagerFactory() = default;
@@ -68,8 +71,8 @@ KeyedService* OsSettingsManagerFactory::BuildServiceInstanceFor(
return new OsSettingsManager(
profile,
- local_search_service::LocalSearchServiceSyncFactory::GetForBrowserContext(
- context),
+ local_search_service::LocalSearchServiceProxyFactory::
+ GetForBrowserContext(context),
multidevice_setup::MultiDeviceSetupClientFactory::GetForProfile(profile),
phonehub::PhoneHubManagerFactory::GetForProfile(profile),
ProfileSyncServiceFactory::GetForProfile(profile),
@@ -78,7 +81,8 @@ KeyedService* OsSettingsManagerFactory::BuildServiceInstanceFor(
ArcAppListPrefsFactory::GetForBrowserContext(profile),
IdentityManagerFactory::GetForProfile(profile),
android_sms::AndroidSmsServiceFactory::GetForBrowserContext(profile),
- CupsPrintersManagerFactory::GetForBrowserContext(profile));
+ CupsPrintersManagerFactory::GetForBrowserContext(profile),
+ apps::AppServiceProxyFactory::GetForProfile(profile));
}
bool OsSettingsManagerFactory::ServiceIsNULLWhileTesting() const {
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 2984d9c6ae4..ac6c5a9ccdf 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
@@ -7,6 +7,17 @@
#include "base/metrics/histogram_base.h"
#include "base/no_destructor.h"
#include "base/test/metrics/histogram_enum_reader.h"
+#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
+#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h"
+#include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager_factory.h"
+#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h"
+#include "chrome/browser/chromeos/phonehub/phone_hub_manager_factory.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager_factory.h"
+#include "chrome/browser/signin/identity_manager_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/constants_util.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/hierarchy.h"
@@ -15,6 +26,9 @@
#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 "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -35,12 +49,37 @@ class OsSettingsManagerTest : public testing::Test {
TestingProfile* profile =
profile_manager_.CreateTestingProfile("TestingProfile");
- manager_ = OsSettingsManagerFactory::GetForProfile(profile);
+ local_search_service::SearchMetricsReporter::RegisterLocalStatePrefs(
+ pref_service_.registry());
+ local_search_service::LocalSearchServiceProxyFactory::GetInstance()
+ ->SetLocalState(&pref_service_);
+ KerberosCredentialsManager* kerberos_credentials_manager =
+ ProfileHelper::IsPrimaryProfile(profile)
+ ? KerberosCredentialsManagerFactory::Get(profile)
+ : nullptr;
+ manager_ = std::make_unique<OsSettingsManager>(
+ profile, local_search_service_proxy_.get(),
+ multidevice_setup::MultiDeviceSetupClientFactory::GetForProfile(
+ profile),
+ phonehub::PhoneHubManagerFactory::GetForProfile(profile),
+ ProfileSyncServiceFactory::GetForProfile(profile),
+ SupervisedUserServiceFactory::GetForProfile(profile),
+ kerberos_credentials_manager,
+ ArcAppListPrefsFactory::GetForBrowserContext(profile),
+ IdentityManagerFactory::GetForProfile(profile),
+ android_sms::AndroidSmsServiceFactory::GetForBrowserContext(profile),
+ CupsPrintersManagerFactory::GetForBrowserContext(profile),
+ apps::AppServiceProxyFactory::GetForProfile(profile));
}
content::BrowserTaskEnvironment task_environment_;
+ TestingPrefServiceSimple pref_service_;
TestingProfileManager profile_manager_;
- OsSettingsManager* manager_;
+ std::unique_ptr<local_search_service::LocalSearchServiceProxy>
+ local_search_service_proxy_ =
+ std::make_unique<local_search_service::LocalSearchServiceProxy>(
+ /*for_testing=*/true);
+ std::unique_ptr<OsSettingsManager> manager_;
};
TEST_F(OsSettingsManagerTest, Initialization) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc
index 6ae3dd1cc8e..a600d86be7c 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.cc
@@ -4,11 +4,11 @@
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
+#include "ash/constants/ash_features.h"
#include "base/check.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section_unittest.cc
index 7408442bf73..747c7c3277b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section_unittest.cc
@@ -4,9 +4,9 @@
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
+#include "ash/constants/ash_features.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom.h"
-#include "chromeos/constants/chromeos_features.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc
index 1f5d6c10758..57434b8dc17 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/languages_section.h"
#include "chrome/browser/ui/webui/settings/chromeos/main_section.h"
#include "chrome/browser/ui/webui/settings/chromeos/multidevice_section.h"
+#include "chrome/browser/ui/webui/settings/chromeos/on_startup_section.h"
#include "chrome/browser/ui/webui/settings/chromeos/people_section.h"
#include "chrome/browser/ui/webui/settings/chromeos/personalization_section.h"
#include "chrome/browser/ui/webui/settings/chromeos/printing_section.h"
@@ -41,7 +42,8 @@ OsSettingsSections::OsSettingsSections(
ArcAppListPrefs* arc_app_list_prefs,
signin::IdentityManager* identity_manager,
android_sms::AndroidSmsService* android_sms_service,
- CupsPrintersManager* printers_manager) {
+ CupsPrintersManager* printers_manager,
+ apps::AppServiceProxy* app_service_proxy) {
// Special case: Main section does not have an associated enum value.
sections_.push_back(
std::make_unique<MainSection>(profile, search_tag_registry));
@@ -85,7 +87,8 @@ OsSettingsSections::OsSettingsSections(
sections_.push_back(std::move(search_section));
auto apps_section = std::make_unique<AppsSection>(
- profile, search_tag_registry, profile->GetPrefs(), arc_app_list_prefs);
+ profile, search_tag_registry, profile->GetPrefs(), arc_app_list_prefs,
+ app_service_proxy);
sections_map_[mojom::Section::kApps] = apps_section.get();
sections_.push_back(std::move(apps_section));
@@ -94,13 +97,18 @@ OsSettingsSections::OsSettingsSections(
sections_map_[mojom::Section::kCrostini] = crostini_section.get();
sections_.push_back(std::move(crostini_section));
+ auto on_startup_section = std::make_unique<OnStartupSection>(
+ profile, search_tag_registry, profile->GetPrefs());
+ sections_map_[mojom::Section::kOnStartup] = on_startup_section.get();
+ sections_.push_back(std::move(on_startup_section));
+
auto date_time_section =
std::make_unique<DateTimeSection>(profile, search_tag_registry);
sections_map_[mojom::Section::kDateAndTime] = date_time_section.get();
sections_.push_back(std::move(date_time_section));
- auto privacy_section =
- std::make_unique<PrivacySection>(profile, search_tag_registry);
+ auto privacy_section = std::make_unique<PrivacySection>(
+ profile, search_tag_registry, profile->GetPrefs());
sections_map_[mojom::Section::kPrivacyAndSecurity] = privacy_section.get();
sections_.push_back(std::move(privacy_section));
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h
index 0f294235d21..2cef92ca7d6 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h
@@ -15,6 +15,10 @@ class ArcAppListPrefs;
class Profile;
class SupervisedUserService;
+namespace apps {
+class AppServiceProxy;
+} // namespace apps
+
namespace signin {
class IdentityManager;
} // namespace signin
@@ -56,7 +60,8 @@ class OsSettingsSections {
ArcAppListPrefs* arc_app_list_prefs,
signin::IdentityManager* identity_manager,
android_sms::AndroidSmsService* android_sms_service,
- CupsPrintersManager* printers_manager);
+ CupsPrintersManager* printers_manager,
+ apps::AppServiceProxy* app_service_proxy);
OsSettingsSections(const OsSettingsSections& other) = delete;
OsSettingsSections& operator=(const OsSettingsSections& other) = delete;
virtual ~OsSettingsSections();
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc
index fe0ef6ee393..273c191c8a8 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
@@ -6,6 +6,8 @@
#include <utility>
+#include "ash/constants/ash_features.h"
+#include "ash/public/cpp/esim_manager.h"
#include "ash/public/cpp/network_config_service.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/nearby_sharing/contacts/nearby_share_contact_manager.h"
@@ -24,8 +26,8 @@
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/os_settings_resources.h"
#include "chrome/grit/os_settings_resources_map.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/services/cellular_setup/cellular_setup_impl.h"
+#include "chromeos/services/cellular_setup/public/mojom/esim_manager.mojom.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -74,7 +76,7 @@ OSSettingsUI::OSSettingsUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource(
html_source,
base::make_span(kOsSettingsResources, kOsSettingsResourcesSize),
- /*generated_path=*/std::string(), default_resource);
+ default_resource);
// For Polymer 2 optimized builds that rely on loading individual subpages,
// set the default resource for tests.
@@ -106,6 +108,11 @@ void OSSettingsUI::BindInterface(
}
void OSSettingsUI::BindInterface(
+ mojo::PendingReceiver<cellular_setup::mojom::ESimManager> receiver) {
+ ash::GetESimManager(std::move(receiver));
+}
+
+void OSSettingsUI::BindInterface(
mojo::PendingReceiver<network_config::mojom::CrosNetworkConfig> receiver) {
ash::GetNetworkConfigService(std::move(receiver));
}
@@ -136,6 +143,11 @@ void OSSettingsUI::BindInterface(
void OSSettingsUI::BindInterface(
mojo::PendingReceiver<nearby_share::mojom::NearbyShareSettings> receiver) {
+ if (!NearbySharingServiceFactory::IsNearbyShareSupportedForBrowserContext(
+ Profile::FromWebUI(web_ui()))) {
+ return;
+ }
+
NearbySharingService* service =
NearbySharingServiceFactory::GetForBrowserContext(
Profile::FromWebUI(web_ui()));
@@ -144,6 +156,11 @@ void OSSettingsUI::BindInterface(
void OSSettingsUI::BindInterface(
mojo::PendingReceiver<nearby_share::mojom::ReceiveManager> receiver) {
+ if (!NearbySharingServiceFactory::IsNearbyShareSupportedForBrowserContext(
+ Profile::FromWebUI(web_ui()))) {
+ return;
+ }
+
NearbySharingService* service =
NearbySharingServiceFactory::GetForBrowserContext(
Profile::FromWebUI(web_ui()));
@@ -153,6 +170,11 @@ void OSSettingsUI::BindInterface(
void OSSettingsUI::BindInterface(
mojo::PendingReceiver<nearby_share::mojom::ContactManager> receiver) {
+ if (!NearbySharingServiceFactory::IsNearbyShareSupportedForBrowserContext(
+ Profile::FromWebUI(web_ui()))) {
+ return;
+ }
+
NearbySharingService* service =
NearbySharingServiceFactory::GetForBrowserContext(
Profile::FromWebUI(web_ui()));
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 fe123adb567..e06579b1244 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,6 +16,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom-forward.h"
#include "chrome/browser/ui/webui/webui_load_timer.h"
#include "chromeos/services/cellular_setup/public/mojom/cellular_setup.mojom-forward.h"
+#include "chromeos/services/cellular_setup/public/mojom/esim_manager.mojom-forward.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
@@ -45,6 +46,11 @@ class OSSettingsUI : public ui::MojoWebUIController {
void BindInterface(
mojo::PendingReceiver<cellular_setup::mojom::CellularSetup> receiver);
+ // Instantiates implementor of the mojom::ESimManager mojo interface
+ // passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<cellular_setup::mojom::ESimManager> receiver);
+
// Instantiates implementor of the mojom::CrosNetworkConfig mojo interface
// passing the pending receiver that will be internally bound.
void BindInterface(
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 ca7377452d9..364bfc38d0f 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
@@ -9,12 +9,12 @@
#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/chromeos/child_accounts/child_user_service.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#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 "chromeos/constants/chromeos_features.h"
#include "components/services/app_service/public/cpp/app_registry_cache.h"
#include "components/services/app_service/public/cpp/app_update.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
@@ -72,16 +72,20 @@ void ParentalControlsHandler::HandleLaunchFamilyLinkSettings(
// Launch FLH app since it is available.
proxy->Launch(app_id, ui::EventFlags::EF_NONE,
apps::mojom::LaunchSource::kFromParentalControls,
- display::kDefaultDisplayId);
+ apps::MakeWindowInfo(display::kDefaultDisplayId));
return;
}
+
// No FLH app installed, so try to launch Play Store to FLH app install page.
- // If there is no Play Store available LaunchPlayStoreWithUrl() will return
- // false.
- if (arc::LaunchPlayStoreWithUrl(
- chromeos::ChildUserService::kFamilyLinkHelperAppPlayStoreURL)) {
+ if (registry.GetAppType(arc::kPlayStoreAppId) !=
+ apps::mojom::AppType::kUnknown) {
+ apps::AppServiceProxyFactory::GetForProfile(profile_)->LaunchAppWithUrl(
+ arc::kPlayStoreAppId, ui::EF_NONE,
+ GURL(chromeos::ChildUserService::kFamilyLinkHelperAppPlayStoreURL),
+ apps::mojom::LaunchSource::kFromChromeInternal);
return;
}
+
// As a last resort, launch browser to the family link site.
NavigateParams params(profile_, GURL(kFamilyLinkSiteURL),
ui::PAGE_TRANSITION_FROM_API);
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 b1cab733a1d..a955e25b506 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc
@@ -4,6 +4,9 @@
#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 "ash/public/cpp/ash_features.h"
#include "base/bind.h"
#include "base/i18n/number_formatting.h"
@@ -12,16 +15,16 @@
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ash/account_manager/account_manager_util.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
-#include "chrome/browser/chromeos/account_manager/account_manager_util.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#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/plural_string_handler.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/kerberos_accounts_handler.h"
@@ -38,9 +41,6 @@
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/components/account_manager/account_manager_factory.h"
-#include "chromeos/constants/chromeos_features.h"
-#include "chromeos/constants/chromeos_pref_names.h"
#include "components/google/core/common/google_util.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/prefs/pref_service.h"
@@ -53,89 +53,118 @@
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
+#include "ui/chromeos/devicetype_utils.h"
#include "ui/chromeos/resources/grit/ui_chromeos_resources.h"
namespace chromeos {
namespace settings {
namespace {
+using ::ash::IsAccountManagerAvailable;
+
const std::vector<SearchConcept>& GetPeopleSearchConcepts() {
- static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_PEOPLE,
- mojom::kPeopleSectionPath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSection,
- {.section = mojom::Section::kPeople}},
- {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_PIN_OR_PASSWORD,
- mojom::kSecurityAndSignInSubpagePath,
- mojom::SearchResultIcon::kLock,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kChangeAuthPin},
- {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_PIN_OR_PASSWORD_ALT1,
- SearchConcept::kAltTagEnd}},
- {IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS,
- mojom::kManageOtherPeopleSubpagePath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kShowUsernamesAndPhotosAtSignIn},
- {IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS_ALT1,
- IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS_ALT2,
- SearchConcept::kAltTagEnd}},
- {IDS_OS_SETTINGS_TAG_PEOPLE_ACCOUNTS,
- mojom::kMyAccountsSubpagePath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kMyAccounts}},
- {IDS_OS_SETTINGS_TAG_PEOPLE_ACCOUNTS_ADD,
- mojom::kMyAccountsSubpagePath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kAddAccount}},
- {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_REMOVE,
- mojom::kManageOtherPeopleSubpagePath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kRemoveFromUserAllowlist}},
- {IDS_OS_SETTINGS_TAG_GUEST_BROWSING,
- mojom::kManageOtherPeopleSubpagePath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kGuestBrowsing}},
- {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_WHEN_WAKING,
- mojom::kSecurityAndSignInSubpagePath,
- mojom::SearchResultIcon::kLock,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kLockScreen},
- {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_WHEN_WAKING_ALT1,
- SearchConcept::kAltTagEnd}},
- {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN,
- mojom::kManageOtherPeopleSubpagePath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kRestrictSignIn},
- {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_ALT1, SearchConcept::kAltTagEnd}},
- {IDS_OS_SETTINGS_TAG_LOCK_SCREEN,
- mojom::kSecurityAndSignInSubpagePath,
- mojom::SearchResultIcon::kLock,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kSecurityAndSignIn}},
- {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_ADD,
- mojom::kManageOtherPeopleSubpagePath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kAddToUserAllowlist}},
- });
+ static const base::NoDestructor<std::vector<SearchConcept>> tags([] {
+ std::vector<SearchConcept> all_tags({
+ {IDS_OS_SETTINGS_TAG_PEOPLE_ACCOUNTS,
+ mojom::kMyAccountsSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kMyAccounts}},
+ });
+
+ if (chromeos::features::IsAccountManagementFlowsV2Enabled()) {
+ all_tags.insert(all_tags.end(),
+ {{IDS_OS_SETTINGS_TAG_PEOPLE_V2,
+ mojom::kPeopleSectionPath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSection,
+ {.section = mojom::Section::kPeople}},
+ {IDS_OS_SETTINGS_TAG_PEOPLE_ACCOUNTS_ADD_V2,
+ mojom::kMyAccountsSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kAddAccount}}});
+ } else {
+ all_tags.insert(
+ all_tags.end(),
+ {
+ {IDS_OS_SETTINGS_TAG_PEOPLE,
+ mojom::kPeopleSectionPath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSection,
+ {.section = mojom::Section::kPeople}},
+ {IDS_OS_SETTINGS_TAG_PEOPLE_ACCOUNTS_ADD,
+ mojom::kMyAccountsSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kAddAccount}},
+ {IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS,
+ mojom::kManageOtherPeopleSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kShowUsernamesAndPhotosAtSignIn},
+ {IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS_ALT1,
+ IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS_ALT2,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_REMOVE,
+ mojom::kManageOtherPeopleSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kRemoveFromUserAllowlist}},
+ {IDS_OS_SETTINGS_TAG_GUEST_BROWSING,
+ mojom::kManageOtherPeopleSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kGuestBrowsing}},
+ {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN,
+ mojom::kManageOtherPeopleSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kRestrictSignIn},
+ {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_ALT1,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_ADD,
+ mojom::kManageOtherPeopleSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kAddToUserAllowlist}},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_PIN_OR_PASSWORD,
+ mojom::kSecurityAndSignInSubpagePath,
+ mojom::SearchResultIcon::kLock,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kChangeAuthPin},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_PIN_OR_PASSWORD_ALT1,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_WHEN_WAKING,
+ mojom::kSecurityAndSignInSubpagePath,
+ mojom::SearchResultIcon::kLock,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kLockScreen},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_WHEN_WAKING_ALT1,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN,
+ mojom::kSecurityAndSignInSubpagePath,
+ mojom::SearchResultIcon::kLock,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kSecurityAndSignIn}},
+ });
+ }
+ return all_tags;
+ }());
+
return *tags;
}
@@ -307,26 +336,20 @@ const std::vector<SearchConcept>& GetParentalSearchConcepts() {
return *tags;
}
-void AddAccountManagerPageStrings(content::WebUIDataSource* html_source) {
+void AddAccountManagerPageStrings(content::WebUIDataSource* html_source,
+ Profile* profile) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"accountManagerDescription", IDS_SETTINGS_ACCOUNT_MANAGER_DESCRIPTION},
- {"accountManagerChildDescription",
- IDS_SETTINGS_ACCOUNT_MANAGER_CHILD_DESCRIPTION},
{"accountManagerChildFirstMessage",
IDS_SETTINGS_ACCOUNT_MANAGER_CHILD_FIRST_MESSAGE},
{"accountManagerChildSecondMessage",
IDS_SETTINGS_ACCOUNT_MANAGER_CHILD_SECOND_MESSAGE},
- {"accountListHeader", IDS_SETTINGS_ACCOUNT_MANAGER_LIST_HEADER},
{"accountManagerPrimaryAccountTooltip",
IDS_SETTINGS_ACCOUNT_MANAGER_PRIMARY_ACCOUNT_TOOLTIP},
{"accountManagerEducationAccountLabel",
IDS_SETTINGS_ACCOUNT_MANAGER_EDUCATION_ACCOUNT},
{"removeAccountLabel", IDS_SETTINGS_ACCOUNT_MANAGER_REMOVE_ACCOUNT_LABEL},
- {"addAccountLabel", IDS_SETTINGS_ACCOUNT_MANAGER_ADD_ACCOUNT_LABEL},
{"addSchoolAccountLabel",
IDS_SETTINGS_ACCOUNT_MANAGER_ADD_SCHOOL_ACCOUNT_LABEL},
- {"accountManagerSecondaryAccountsDisabledText",
- IDS_SETTINGS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_TEXT},
{"accountManagerSecondaryAccountsDisabledChildText",
IDS_SETTINGS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_CHILD_TEXT},
{"accountManagerSignedOutAccountName",
@@ -347,11 +370,53 @@ void AddAccountManagerPageStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_ACCOUNT_MANAGER_MANAGEMENT_STATUS_MANAGED_ACCOUNT},
{"accountManagerUnmanagedLabel",
IDS_SETTINGS_ACCOUNT_MANAGER_MANAGEMENT_STATUS_UNMANAGED_ACCOUNT},
+ {"accountListDescription", IDS_SETTINGS_ACCOUNT_MANAGER_LIST_DESCRIPTION},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
+
+ user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile);
+ DCHECK(user);
+ html_source->AddString(
+ "accountListChildDescription",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_ACCOUNT_MANAGER_LIST_CHILD_DESCRIPTION,
+ base::UTF8ToUTF16(user->GetDisplayEmail())));
html_source->AddString("accountManagerLearnMoreUrl",
chrome::kAccountManagerLearnMoreURL);
+ html_source->AddLocalizedString(
+ "accountManagerManagementDescription",
+ profile->IsChild() ? IDS_SETTINGS_ACCOUNT_MANAGER_MANAGEMENT_STATUS_CHILD
+ : IDS_SETTINGS_ACCOUNT_MANAGER_MANAGEMENT_STATUS);
+ html_source->AddString("accountManagerChromeUIManagementURL",
+ base::UTF8ToUTF16(chrome::kChromeUIManagementURL));
+
+ if (chromeos::features::IsAccountManagementFlowsV2Enabled()) {
+ static constexpr webui::LocalizedString kLocalizedStringsV2[] = {
+ {"addAccountLabel", IDS_SETTINGS_ACCOUNT_MANAGER_ADD_ACCOUNT_LABEL_V2},
+ {"accountListHeader", IDS_SETTINGS_ACCOUNT_MANAGER_LIST_HEADER_V2},
+ {"accountListHeaderChild",
+ IDS_SETTINGS_ACCOUNT_MANAGER_LIST_HEADER_CHILD},
+ {"accountManagerDescription",
+ IDS_SETTINGS_ACCOUNT_MANAGER_DESCRIPTION_V2},
+ {"accountManagerChildDescription",
+ IDS_SETTINGS_ACCOUNT_MANAGER_CHILD_DESCRIPTION_V2},
+ {"accountManagerSecondaryAccountsDisabledText",
+ IDS_SETTINGS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_TEXT_V2},
+ };
+ html_source->AddLocalizedStrings(kLocalizedStringsV2);
+ } else {
+ static constexpr webui::LocalizedString kLocalizedStringsV1[] = {
+ {"accountManagerDescription", IDS_SETTINGS_ACCOUNT_MANAGER_DESCRIPTION},
+ {"accountManagerChildDescription",
+ IDS_SETTINGS_ACCOUNT_MANAGER_CHILD_DESCRIPTION},
+ {"addAccountLabel", IDS_SETTINGS_ACCOUNT_MANAGER_ADD_ACCOUNT_LABEL},
+ {"accountListHeader", IDS_SETTINGS_ACCOUNT_MANAGER_LIST_HEADER},
+ {"accountManagerSecondaryAccountsDisabledText",
+ IDS_SETTINGS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_TEXT},
+ };
+ html_source->AddLocalizedStrings(kLocalizedStringsV1);
+ }
}
void AddLockScreenPageStrings(content::WebUIDataSource* html_source,
@@ -392,8 +457,6 @@ void AddLockScreenPageStrings(content::WebUIDataSource* html_source,
{"lockScreenSetupPinButton",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_SETUP_PIN_BUTTON},
{"lockScreenTitleLock", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_TITLE_LOCK},
- {"lockScreenTitleLoginLock",
- IDS_SETTINGS_PEOPLE_LOCK_SCREEN_TITLE_LOGIN_LOCK},
{"passwordPromptEnterPasswordLock",
IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_ENTER_PASSWORD_LOCK},
{"pinAutoSubmitPrompt",
@@ -405,7 +468,7 @@ void AddLockScreenPageStrings(content::WebUIDataSource* html_source,
{"passwordPromptEnterPasswordLoginLock",
IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_ENTER_PASSWORD_LOGIN_LOCK},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("quickUnlockEnabled",
chromeos::quick_unlock::IsPinEnabled(pref_service));
@@ -419,6 +482,16 @@ void AddLockScreenPageStrings(content::WebUIDataSource* html_source,
html_source->AddBoolean(
"lockScreenHideSensitiveNotificationsSupported",
ash::features::IsLockScreenHideSensitiveNotificationsSupported());
+
+ if (chromeos::features::IsAccountManagementFlowsV2Enabled()) {
+ html_source->AddLocalizedString(
+ "lockScreenTitleLoginLock",
+ IDS_SETTINGS_PEOPLE_LOCK_SCREEN_TITLE_LOGIN_LOCK_V2);
+ } else {
+ html_source->AddLocalizedString(
+ "lockScreenTitleLoginLock",
+ IDS_SETTINGS_PEOPLE_LOCK_SCREEN_TITLE_LOGIN_LOCK);
+ }
}
void AddFingerprintListStrings(content::WebUIDataSource* html_source) {
@@ -430,7 +503,7 @@ void AddFingerprintListStrings(content::WebUIDataSource* html_source) {
{"lockScreenFingerprintWarning",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_FINGERPRINT_LESS_SECURE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddFingerprintStrings(content::WebUIDataSource* html_source,
@@ -502,7 +575,7 @@ void AddSetupFingerprintDialogStrings(content::WebUIDataSource* html_source) {
{"configureFingerprintImmobile",
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_FINGER_IMMOBILE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddSetupPinDialogStrings(content::WebUIDataSource* html_source) {
@@ -522,7 +595,7 @@ void AddSetupPinDialogStrings(content::WebUIDataSource* html_source) {
{"pinKeyboardDeleteAccessibleName",
IDS_PIN_KEYBOARD_DELETE_ACCESSIBLE_NAME},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
// Format numbers to be used on the pin keyboard.
for (int j = 0; j <= 9; j++) {
@@ -545,7 +618,7 @@ void AddSyncControlsStrings(content::WebUIDataSource* html_source) {
{"osSyncTurnOn", IDS_OS_SETTINGS_SYNC_TURN_ON},
{"osSyncFeatureLabel", IDS_OS_SETTINGS_SYNC_FEATURE_LABEL},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("splitSettingsSyncEnabled",
chromeos::features::IsSplitSettingsSyncEnabled());
@@ -569,7 +642,7 @@ void AddUsersStrings(content::WebUIDataSource* html_source) {
{"addUsersEmail", IDS_SETTINGS_USERS_ADD_USERS_EMAIL},
{"userExistsError", IDS_SETTINGS_USER_EXISTS_ERROR},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddParentalControlStrings(content::WebUIDataSource* html_source,
@@ -588,7 +661,7 @@ void AddParentalControlStrings(content::WebUIDataSource* html_source,
{"parentalControlsSetUpButtonRole",
IDS_SETTINGS_PARENTAL_CONTROLS_SET_UP_BUTTON_ROLE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("showParentalControls",
are_parental_control_settings_allowed);
@@ -657,7 +730,7 @@ PeopleSection::PeopleSection(
// OS and browser settings.
if (IsAccountManagerAvailable(profile)) {
// Some Account Manager search tags are added/removed dynamically.
- AccountManagerFactory* factory =
+ auto* factory =
g_browser_process->platform_part()->GetAccountManagerFactory();
account_manager_ = factory->GetAccountManager(profile->GetPath().value());
DCHECK(account_manager_);
@@ -666,7 +739,10 @@ PeopleSection::PeopleSection(
FetchAccounts();
}
- if (kerberos_credentials_manager_) {
+ // No Kerberos search tags are registered here if Kerberos settings are in a
+ // separate section.
+ if (kerberos_credentials_manager_ &&
+ !chromeos::features::IsKerberosSettingsSectionEnabled()) {
// Kerberos search tags are added/removed dynamically.
kerberos_credentials_manager_->AddObserver(this);
OnKerberosEnabledStateChanged();
@@ -691,7 +767,8 @@ PeopleSection::PeopleSection(
// Fingerprint search tags are added if necessary. Remove fingerprint search
// tags update dynamically during a user session.
- if (AreFingerprintSettingsAllowed()) {
+ if (AreFingerprintSettingsAllowed() &&
+ !chromeos::features::IsAccountManagementFlowsV2Enabled()) {
updater.AddSearchTags(GetFingerprintSearchConcepts());
fingerprint_pref_change_registrar_.Init(pref_service_);
@@ -704,8 +781,10 @@ PeopleSection::PeopleSection(
}
PeopleSection::~PeopleSection() {
- if (kerberos_credentials_manager_)
+ if (kerberos_credentials_manager_ &&
+ !chromeos::features::IsKerberosSettingsSectionEnabled()) {
kerberos_credentials_manager_->RemoveObserver(this);
+ }
if (chromeos::features::IsSplitSettingsSyncEnabled() && sync_service_)
sync_service_->RemoveObserver(this);
@@ -729,11 +808,41 @@ void PeopleSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
IDS_SETTINGS_SYNC_SYNC_AND_NON_PERSONALIZED_SERVICES},
{"syncDisconnectConfirm", IDS_SETTINGS_SYNC_DISCONNECT_CONFIRM},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
+
+ user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile());
+ DCHECK(user);
+
+ if (chromeos::features::IsAccountManagementFlowsV2Enabled()) {
+ html_source->AddLocalizedString("osPeoplePageTitle",
+ IDS_OS_SETTINGS_PEOPLE_V2);
+
+ // This string is not used if the flag is disabled.
+ html_source->AddString("osProfileName", l10n_util::GetStringFUTF16(
+ IDS_OS_SETTINGS_PROFILE_NAME,
+ user->GetGivenName()));
+ html_source->AddString(
+ "accountManagerPageTitle",
+ l10n_util::GetStringFUTF16(IDS_SETTINGS_ACCOUNT_MANAGER_PAGE_TITLE_V2,
+ user->GetGivenName()));
+ } else {
+ static constexpr webui::LocalizedString kAccountManagerStrings[] = {
+ {"osPeoplePageTitle", IDS_OS_SETTINGS_PEOPLE},
+ {"accountManagerPageTitle", IDS_SETTINGS_ACCOUNT_MANAGER_PAGE_TITLE},
+ };
+ html_source->AddLocalizedStrings(kAccountManagerStrings);
+ }
// Toggles the Chrome OS Account Manager submenu in the People section.
html_source->AddBoolean("isAccountManagerEnabled",
account_manager_ != nullptr);
+ html_source->AddBoolean(
+ "isAccountManagementFlowsV2Enabled",
+ chromeos::features::IsAccountManagementFlowsV2Enabled());
+ html_source->AddBoolean(
+ "isDeviceAccountManaged",
+ user->IsActiveDirectoryUser() ||
+ profile()->GetProfilePolicyConnector()->IsManaged());
if (chromeos::features::ShouldUseBrowserSyncConsent()) {
static constexpr webui::LocalizedString kTurnOffStrings[] = {
@@ -741,13 +850,13 @@ void PeopleSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"syncDisconnectTitle",
IDS_SETTINGS_TURN_OFF_SYNC_AND_SIGN_OUT_DIALOG_TITLE},
};
- AddLocalizedStringsBulk(html_source, kTurnOffStrings);
+ html_source->AddLocalizedStrings(kTurnOffStrings);
} else {
static constexpr webui::LocalizedString kSignOutStrings[] = {
{"syncDisconnect", IDS_SETTINGS_PEOPLE_SIGN_OUT},
{"syncDisconnectTitle", IDS_SETTINGS_SYNC_DISCONNECT_TITLE},
};
- AddLocalizedStringsBulk(html_source, kSignOutStrings);
+ html_source->AddLocalizedStrings(kSignOutStrings);
}
std::string sync_dashboard_url =
@@ -770,7 +879,7 @@ void PeopleSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
"driveSuggestAvailable",
base::FeatureList::IsEnabled(omnibox::kDocumentProvider));
- AddAccountManagerPageStrings(html_source);
+ AddAccountManagerPageStrings(html_source, profile());
KerberosAccountsHandler::AddLoadTimeKerberosStrings(
html_source, kerberos_credentials_manager_);
AddLockScreenPageStrings(html_source, profile()->GetPrefs());
@@ -796,11 +905,6 @@ void PeopleSection::AddHandlers(content::WebUI* web_ui) {
web_ui->AddMessageHandler(
std::make_unique<::settings::ProfileInfoHandler>(profile()));
- auto plural_string_handler = std::make_unique<PluralStringHandler>();
- plural_string_handler->AddLocalizedString("profileLabel",
- IDS_OS_SETTINGS_PROFILE_LABEL);
- web_ui->AddMessageHandler(std::move(plural_string_handler));
-
if (account_manager_) {
web_ui->AddMessageHandler(
std::make_unique<chromeos::settings::AccountManagerUIHandler>(
@@ -823,12 +927,16 @@ void PeopleSection::AddHandlers(content::WebUI* web_ui) {
profile()));
}
- std::unique_ptr<chromeos::settings::KerberosAccountsHandler>
- kerberos_accounts_handler =
- KerberosAccountsHandler::CreateIfKerberosEnabled(profile());
- if (kerberos_accounts_handler) {
- // Note that the UI is enabled only if Kerberos is enabled.
- web_ui->AddMessageHandler(std::move(kerberos_accounts_handler));
+ // No Kerberos handler is created/added here if Kerberos settings are in a
+ // separate section.
+ if (!chromeos::features::IsKerberosSettingsSectionEnabled()) {
+ std::unique_ptr<chromeos::settings::KerberosAccountsHandler>
+ kerberos_accounts_handler =
+ KerberosAccountsHandler::CreateIfKerberosEnabled(profile());
+ if (kerberos_accounts_handler) {
+ // Note that the UI is enabled only if Kerberos is enabled.
+ web_ui->AddMessageHandler(std::move(kerberos_accounts_handler));
+ }
}
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h
index a5d731a75ff..43fee276baa 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h
@@ -5,11 +5,11 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PEOPLE_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PEOPLE_SECTION_H_
+#include "ash/components/account_manager/account_manager.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
-#include "chromeos/components/account_manager/account_manager.h"
#include "components/account_manager_core/account.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/sync/driver/sync_service_observer.h"
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
new file mode 100644
index 00000000000..bd4fa75288d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.cc
@@ -0,0 +1,90 @@
+// 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.
+
+#include "chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.h"
+
+#include <string>
+#include <utility>
+
+#include "ash/components/pcie_peripheral/pcie_peripheral_manager.h"
+#include "base/bind.h"
+#include "base/callback_helpers.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/task/task_traits.h"
+#include "base/task/thread_pool.h"
+#include "chrome/browser/ash/settings/cros_settings.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chromeos/dbus/pciguard/pciguard_client.h"
+#include "chromeos/settings/cros_settings_names.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace chromeos {
+namespace settings {
+
+namespace {
+constexpr char thunderbolt_file_path[] = "/sys/bus/thunderbolt/devices/0-0";
+} // namespace
+
+bool CheckIfThunderboltFilepathExists() {
+ return base::PathExists(base::FilePath(thunderbolt_file_path));
+}
+
+PeripheralDataAccessHandler::PeripheralDataAccessHandler() {
+ peripheral_data_access_subscription_ =
+ CrosSettings::Get()->AddSettingsObserver(
+ kDevicePeripheralDataAccessEnabled,
+ base::BindRepeating(&PeripheralDataAccessHandler::
+ OnPeripheralDataAccessProtectionChanged,
+ base::Unretained(this)));
+}
+
+PeripheralDataAccessHandler::~PeripheralDataAccessHandler() = default;
+
+void PeripheralDataAccessHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "isThunderboltSupported",
+ base::BindRepeating(
+ &PeripheralDataAccessHandler::HandleThunderboltSupported,
+ base::Unretained(this)));
+}
+
+void PeripheralDataAccessHandler::OnJavascriptAllowed() {}
+
+void PeripheralDataAccessHandler::OnJavascriptDisallowed() {}
+
+void PeripheralDataAccessHandler::HandleThunderboltSupported(
+ const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(1u, args->GetSize());
+ const std::string& callback_id = args->GetList()[0].GetString();
+
+ // PathExist is a blocking call. PostTask it and wait on the result.
+ base::ThreadPool::PostTaskAndReplyWithResult(
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
+ base::BindOnce(&CheckIfThunderboltFilepathExists),
+ base::BindOnce(&PeripheralDataAccessHandler::OnFilePathChecked,
+ weak_ptr_factory_.GetWeakPtr(), callback_id));
+}
+
+void PeripheralDataAccessHandler::OnFilePathChecked(
+ const std::string& callback_id, bool is_thunderbolt_supported) {
+ ResolveJavascriptCallback(base::Value(callback_id),
+ base::Value(is_thunderbolt_supported));
+}
+
+void PeripheralDataAccessHandler::OnPeripheralDataAccessProtectionChanged() {
+ DCHECK(PciguardClient::Get());
+
+ bool new_state = false;
+ CrosSettings::Get()->GetBoolean(chromeos::kDevicePeripheralDataAccessEnabled,
+ &new_state);
+
+ ash::PciePeripheralManager::Get()->SetPcieTunnelingAllowedState(new_state);
+ PciguardClient::Get()->SendExternalPciDevicesPermissionState(new_state);
+}
+
+} // namespace settings
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.h
new file mode 100644
index 00000000000..422c0b1eab3
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/peripheral_data_access_handler.h
@@ -0,0 +1,48 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PERIPHERAL_DATA_ACCESS_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PERIPHERAL_DATA_ACCESS_HANDLER_H_
+
+#include "base/callback_list.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+
+namespace chromeos {
+namespace settings {
+
+class PeripheralDataAccessHandler : public ::settings::SettingsPageUIHandler {
+ public:
+ PeripheralDataAccessHandler();
+ ~PeripheralDataAccessHandler() override;
+
+ PeripheralDataAccessHandler(const PeripheralDataAccessHandler&) = delete;
+ PeripheralDataAccessHandler& operator=(const PeripheralDataAccessHandler&) =
+ delete;
+
+ // SettingsPageUIHandler:
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ private:
+ // Handles checking if thunderbolt is supported in this device.
+ void HandleThunderboltSupported(const base::ListValue* args);
+
+ // Observer for the CrosSetting.
+ void OnPeripheralDataAccessProtectionChanged();
+
+ void OnFilePathChecked(const std::string& callback_id,
+ bool is_thunderbolt_supported);
+
+ base::CallbackListSubscription peripheral_data_access_subscription_;
+
+ // Used for callbacks.
+ base::WeakPtrFactory<PeripheralDataAccessHandler> weak_ptr_factory_{this};
+};
+
+} // namespace settings
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PERIPHERAL_DATA_ACCESS_HANDLER_H_
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 0b292d43ddc..94f0e039785 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/personalization_section.h"
+#include "ash/constants/ash_features.h"
#include "ash/public/cpp/ambient/ambient_client.h"
#include "ash/public/cpp/ambient/ambient_prefs.h"
#include "base/bind.h"
@@ -12,6 +13,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h"
+#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom-forward.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h"
@@ -19,7 +21,6 @@
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -41,14 +42,6 @@ const std::vector<SearchConcept>& GetPersonalizationSearchConcepts() {
{.section = mojom::Section::kPersonalization},
{IDS_OS_SETTINGS_TAG_PERSONALIZATION_ALT1,
IDS_OS_SETTINGS_TAG_PERSONALIZATION_ALT2, SearchConcept::kAltTagEnd}},
- {IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER,
- mojom::kPersonalizationSectionPath,
- mojom::SearchResultIcon::kWallpaper,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kOpenWallpaper},
- {IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT1,
- IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT2, SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_CHANGE_DEVICE_ACCOUNT_IMAGE,
mojom::kChangePictureSubpagePath,
mojom::SearchResultIcon::kAvatar,
@@ -64,6 +57,34 @@ const std::vector<SearchConcept>& GetPersonalizationSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetWallpaperChromeAppSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags(
+ {{IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER,
+ mojom::kPersonalizationSectionPath,
+ mojom::SearchResultIcon::kWallpaper,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kOpenWallpaper},
+ {IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT1,
+ IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT2,
+ SearchConcept::kAltTagEnd}}});
+ return *tags;
+}
+
+const std::vector<SearchConcept>& GetWallpaperWebUISearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags(
+ {{IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER,
+ mojom::kWallpaperSubpagePath,
+ mojom::SearchResultIcon::kWallpaper,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kWallpaper},
+ {IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT1,
+ IDS_OS_SETTINGS_TAG_CHANGE_WALLPAPER_ALT2,
+ SearchConcept::kAltTagEnd}}});
+ return *tags;
+}
+
const std::vector<SearchConcept>& GetAmbientModeSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_AMBIENT_MODE,
@@ -152,6 +173,11 @@ PersonalizationSection::PersonalizationSection(
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.AddSearchTags(GetPersonalizationSearchConcepts());
+ if (chromeos::features::IsWallpaperWebUIEnabled())
+ updater.AddSearchTags(GetWallpaperWebUISearchConcepts());
+ else
+ updater.AddSearchTags(GetWallpaperChromeAppSearchConcepts());
+
if (IsAmbientModeAllowed()) {
updater.AddSearchTags(GetAmbientModeSearchConcepts());
@@ -204,6 +230,10 @@ void PersonalizationSection::AddLoadTimeData(
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},
@@ -226,8 +256,10 @@ void PersonalizationSection::AddLoadTimeData(
IDS_SETTINGS_PHOTO_DISCARD_ACCESSIBLE_TEXT},
{"photoModeAccessibleText", IDS_SETTINGS_PHOTO_MODE_ACCESSIBLE_TEXT},
{"videoModeAccessibleText", IDS_SETTINGS_VIDEO_MODE_ACCESSIBLE_TEXT},
+ // TODO(b/178399962) finalize error string for WallpaperWebUI.
+ {"wallpaperCollectionsError", IDS_WALLPAPER_MANAGER_NETWORK_ERROR},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean(
"changePictureVideoModeEnabled",
@@ -245,6 +277,9 @@ void PersonalizationSection::AddLoadTimeData(
l10n_util::GetStringFUTF16(
IDS_OS_SETTINGS_AMBIENT_MODE_ALBUMS_SUBPAGE_GOOGLE_PHOTOS_NO_ALBUM,
base::UTF8ToUTF16(GetGooglePhotosURL().spec())));
+
+ html_source->AddBoolean("isWallpaperWebUIEnabled",
+ chromeos::features::IsWallpaperWebUIEnabled());
}
void PersonalizationSection::AddHandlers(content::WebUI* web_ui) {
@@ -256,7 +291,8 @@ void PersonalizationSection::AddHandlers(content::WebUI* web_ui) {
if (!profile()->IsGuestSession() &&
chromeos::features::IsAmbientModeEnabled()) {
web_ui->AddMessageHandler(
- std::make_unique<chromeos::settings::AmbientModeHandler>());
+ std::make_unique<chromeos::settings::AmbientModeHandler>(
+ pref_service_));
}
}
@@ -294,6 +330,12 @@ void PersonalizationSection::RegisterHierarchy(
generator->RegisterNestedSetting(mojom::Setting::kChangeDeviceAccountImage,
mojom::Subpage::kChangePicture);
+ // Wallpaper.
+ generator->RegisterTopLevelSubpage(
+ IDS_OS_SETTINGS_SET_WALLPAPER, mojom::Subpage::kWallpaper,
+ mojom::SearchResultIcon::kWallpaper,
+ mojom::SearchResultDefaultRank::kMedium, mojom::kWallpaperSubpagePath);
+
// Ambient mode.
generator->RegisterTopLevelSubpage(
IDS_OS_SETTINGS_AMBIENT_MODE_TITLE, mojom::Subpage::kAmbientMode,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc
index c0517aab3c4..f6ae5f23922 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc
@@ -10,34 +10,13 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
-#include "chrome/browser/chromeos/file_manager/path_util.h"
-#include "chrome/browser/chromeos/guest_os/guest_os_share_path.h"
-#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
+#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h"
+#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h"
namespace chromeos {
-namespace {
-
-base::ListValue UsbDevicesToListValue(
- const std::vector<CrosUsbDeviceInfo>& shared_usbs) {
- base::ListValue usb_devices_list;
- for (const auto& device : shared_usbs) {
- base::Value device_info(base::Value::Type::DICTIONARY);
- device_info.SetStringKey("guid", device.guid);
- device_info.SetStringKey("label", device.label);
- bool shared = device.shared_vm_name == plugin_vm::kPluginVmName;
- device_info.SetBoolKey("shared", shared);
- device_info.SetBoolKey("shareWillReassign",
- device.shared_vm_name && !shared);
- usb_devices_list.Append(std::move(device_info));
- }
- return usb_devices_list;
-}
-
-} // namespace
-
namespace settings {
PluginVmHandler::PluginVmHandler(Profile* profile) : profile_(profile) {}
@@ -46,24 +25,6 @@ PluginVmHandler::~PluginVmHandler() = default;
void PluginVmHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "getPluginVmSharedPathsDisplayText",
- base::BindRepeating(
- &PluginVmHandler::HandleGetPluginVmSharedPathsDisplayText,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "removePluginVmSharedPath",
- base::BindRepeating(&PluginVmHandler::HandleRemovePluginVmSharedPath,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "notifyPluginVmSharedUsbDevicesPageReady",
- base::BindRepeating(
- &PluginVmHandler::HandleNotifyPluginVmSharedUsbDevicesPageReady,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
- "setPluginVmUsbDeviceShared",
- base::BindRepeating(&PluginVmHandler::HandleSetPluginVmUsbDeviceShared,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
"isRelaunchNeededForNewPermissions",
base::BindRepeating(
&PluginVmHandler::HandleIsRelaunchNeededForNewPermissions,
@@ -74,90 +35,9 @@ void PluginVmHandler::RegisterMessages() {
base::Unretained(this)));
}
-void PluginVmHandler::OnJavascriptAllowed() {
- if (auto* detector = chromeos::CrosUsbDetector::Get()) {
- cros_usb_device_observer_.Add(detector);
- }
-}
-
-void PluginVmHandler::OnJavascriptDisallowed() {
- cros_usb_device_observer_.RemoveAll();
-}
+void PluginVmHandler::OnJavascriptAllowed() {}
-void PluginVmHandler::HandleGetPluginVmSharedPathsDisplayText(
- const base::ListValue* args) {
- AllowJavascript();
- CHECK_EQ(2U, args->GetSize());
- std::string callback_id = args->GetList()[0].GetString();
-
- base::ListValue texts;
- for (const auto& path : args->GetList()[1].GetList()) {
- texts.AppendString(file_manager::util::GetPathDisplayTextForSettings(
- profile_, path.GetString()));
- }
- ResolveJavascriptCallback(base::Value(callback_id), texts);
-}
-
-void PluginVmHandler::HandleRemovePluginVmSharedPath(
- const base::ListValue* args) {
- CHECK_EQ(3U, args->GetList().size());
- std::string callback_id = args->GetList()[0].GetString();
- std::string vm_name = args->GetList()[1].GetString();
- std::string path = args->GetList()[2].GetString();
-
- guest_os::GuestOsSharePath::GetForProfile(profile_)->UnsharePath(
- vm_name, base::FilePath(path),
- /*unpersist=*/true,
- base::BindOnce(&PluginVmHandler::OnPluginVmSharedPathRemoved,
- weak_ptr_factory_.GetWeakPtr(), callback_id, path));
-}
-
-void PluginVmHandler::OnPluginVmSharedPathRemoved(
- const std::string& callback_id,
- const std::string& path,
- bool success,
- const std::string& failure_reason) {
- if (!success) {
- LOG(ERROR) << "Error unsharing " << path << ": " << failure_reason;
- }
- ResolveJavascriptCallback(base::Value(callback_id), base::Value(success));
-}
-
-void PluginVmHandler::HandleNotifyPluginVmSharedUsbDevicesPageReady(
- const base::ListValue* args) {
- AllowJavascript();
- OnUsbDevicesChanged();
-}
-
-void PluginVmHandler::HandleSetPluginVmUsbDeviceShared(
- const base::ListValue* args) {
- CHECK_EQ(2U, args->GetList().size());
- const auto& args_list = args->GetList();
- const std::string& guid = args_list[0].GetString();
- bool shared = args_list[1].GetBool();
-
- chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
- if (!detector)
- return;
-
- if (shared) {
- detector->AttachUsbDeviceToVm(plugin_vm::kPluginVmName, guid,
- base::DoNothing());
- return;
- }
- detector->DetachUsbDeviceFromVm(plugin_vm::kPluginVmName, guid,
- base::DoNothing());
-}
-
-void PluginVmHandler::OnUsbDevicesChanged() {
- chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
- if (!detector)
- return;
-
- FireWebUIListener(
- "plugin-vm-shared-usb-devices-changed",
- UsbDevicesToListValue(detector->GetDevicesSharableWithCrostini()));
-}
+void PluginVmHandler::OnJavascriptDisallowed() {}
void PluginVmHandler::HandleIsRelaunchNeededForNewPermissions(
const base::ListValue* args) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h
index a9f3f7b878b..86d24e73a44 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h
@@ -8,10 +8,6 @@
#include <vector>
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
-#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager.h"
-#include "chrome/browser/chromeos/plugin_vm/plugin_vm_manager_factory.h"
-#include "chrome/browser/chromeos/usb/cros_usb_detector.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile;
@@ -19,8 +15,7 @@ class Profile;
namespace chromeos {
namespace settings {
-class PluginVmHandler : public ::settings::SettingsPageUIHandler,
- public chromeos::CrosUsbDeviceObserver {
+class PluginVmHandler : public ::settings::SettingsPageUIHandler {
public:
explicit PluginVmHandler(Profile* profile);
~PluginVmHandler() override;
@@ -31,37 +26,13 @@ class PluginVmHandler : public ::settings::SettingsPageUIHandler,
void OnJavascriptDisallowed() override;
private:
- // chromeos::SharedUsbDeviceObserver.
- void OnUsbDevicesChanged() override;
-
- // Callback for the "getSharedPathsDisplayText" message. Converts actual
- // paths in chromeos to values suitable to display to users.
- // E.g. /home/chronos/u-<hash>/Downloads/foo => "Downloads > foo".
- void HandleGetPluginVmSharedPathsDisplayText(const base::ListValue* args);
- // Remove a specified path from being shared.
- void HandleRemovePluginVmSharedPath(const base::ListValue* args);
- // Called when the shared USB devices page is ready.
- void HandleNotifyPluginVmSharedUsbDevicesPageReady(
- const base::ListValue* args);
- // Set the share state of a USB device.
- void HandleSetPluginVmUsbDeviceShared(const base::ListValue* args);
// Checks if Plugin VM would need to be relaunched if the proposed changes are
// made.
void HandleIsRelaunchNeededForNewPermissions(const base::ListValue* args);
// Relaunches Plugin VM.
void HandleRelaunchPluginVm(const base::ListValue* args);
- void OnPluginVmSharedPathRemoved(const std::string& callback_id,
- const std::string& path,
- bool success,
- const std::string& failure_reason);
-
Profile* profile_;
- ScopedObserver<CrosUsbDetector,
- CrosUsbDeviceObserver,
- &CrosUsbDetector::AddUsbDeviceObserver,
- &CrosUsbDetector::RemoveUsbDeviceObserver>
- cros_usb_device_observer_{this};
// weak_ptr_factory_ should always be last member.
base::WeakPtrFactory<PluginVmHandler> weak_ptr_factory_{this};
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 864d73ad923..6e42c805de8 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/printing_section.h"
+#include "ash/constants/ash_features.h"
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h"
@@ -12,7 +13,6 @@
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/printing/printer_configuration.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
@@ -68,9 +68,20 @@ const std::vector<SearchConcept>& GetPrintingManagementSearchConcepts() {
return *tags;
}
-bool IsPrintManagementEnabled() {
- return base::FeatureList::IsEnabled(
- chromeos::features::kPrintJobManagementApp);
+const std::vector<SearchConcept>& GetScanningAppSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_SCANNING_APP,
+ mojom::kPrintingSectionPath,
+ mojom::SearchResultIcon::kPrinter,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kScanningApp}},
+ });
+ return *tags;
+}
+
+bool IsScanningAppEnabled() {
+ return base::FeatureList::IsEnabled(chromeos::features::kScanningUI);
}
} // namespace
@@ -82,8 +93,10 @@ PrintingSection::PrintingSection(Profile* profile,
printers_manager_(printers_manager) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.AddSearchTags(GetPrintingSearchConcepts());
- if (IsPrintManagementEnabled())
- updater.AddSearchTags(GetPrintingManagementSearchConcepts());
+ updater.AddSearchTags(GetPrintingManagementSearchConcepts());
+
+ if (IsScanningAppEnabled())
+ updater.AddSearchTags(GetScanningAppSearchConcepts());
// Saved Printers search tags are added/removed dynamically.
if (printers_manager_) {
@@ -100,7 +113,7 @@ PrintingSection::~PrintingSection() {
void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"printingPageTitle", IDS_SETTINGS_PRINTING},
+ {"printingPageTitle", IDS_SETTINGS_PRINT_AND_SCAN},
{"cupsPrintersTitle", IDS_SETTINGS_PRINTING_CUPS_PRINTERS},
{"cupsPrintersLearnMoreLabel",
IDS_SETTINGS_PRINTING_CUPS_PRINTERS_LEARN_MORE_LABEL},
@@ -118,6 +131,8 @@ void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
IDS_SETTINGS_PRINTING_PRINT_JOBS_LAUNCH_APP_TITLE_LABEL},
{"printJobsSublabel",
IDS_SETTINGS_PRINTING_PRINT_JOBS_LAUNCH_APP_SUBLABEL},
+ {"scanAppTitle", IDS_SETTINGS_PRINTING_SCANNING_LAUNCH_APP_TITLE_LABEL},
+ {"scanAppSublabel", IDS_SETTINGS_PRINTING_SCANNING_LAUNCH_APP_SUBLABEL},
{"printerDetailsTitle", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_TITLE},
{"printerName", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_NAME},
{"printerModel", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_MODEL},
@@ -243,14 +258,14 @@ void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"printServerConfigurationErrorMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_REACHABLE_BUT_CANNOT_ADD},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString("printingCUPSPrintLearnMoreUrl",
GetHelpUrlWithBoard(chrome::kCupsPrintLearnMoreURL));
html_source->AddString(
"printingCUPSPrintPpdLearnMoreUrl",
GetHelpUrlWithBoard(chrome::kCupsPrintPPDLearnMoreURL));
- html_source->AddBoolean("printManagementEnabled", IsPrintManagementEnabled());
+ html_source->AddBoolean("scanningAppEnabled", IsScanningAppEnabled());
}
void PrintingSection::AddHandlers(content::WebUI* web_ui) {
@@ -259,7 +274,7 @@ void PrintingSection::AddHandlers(content::WebUI* web_ui) {
}
int PrintingSection::GetSectionNameMessageId() const {
- return IDS_SETTINGS_PRINTING;
+ return IDS_SETTINGS_PRINT_AND_SCAN;
}
mojom::Section PrintingSection::GetSection() const {
@@ -282,6 +297,7 @@ bool PrintingSection::LogMetric(mojom::Setting setting,
void PrintingSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kPrintJobs);
+ generator->RegisterTopLevelSetting(mojom::Setting::kScanningApp);
// Printing details.
generator->RegisterTopLevelSubpage(IDS_SETTINGS_PRINTING_CUPS_PRINTERS,
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 7a740f11a57..33cccfd1349 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc
@@ -4,16 +4,22 @@
#include "chrome/browser/ui/webui/settings/chromeos/privacy_section.h"
+#include "ash/constants/ash_features.h"
#include "base/feature_list.h"
+#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "build/branding_buildflags.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.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/shared_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
+#include "components/prefs/pref_service.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"
@@ -23,19 +29,134 @@ namespace settings {
namespace {
const std::vector<SearchConcept>& GetPrivacySearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags([] {
+ std::vector<SearchConcept> all_tags({
+ {IDS_OS_SETTINGS_TAG_PRIVACY_VERIFIED_ACCESS,
+ mojom::kPrivacyAndSecuritySectionPath,
+ mojom::SearchResultIcon::kShield,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kVerifiedAccess}},
+ {IDS_OS_SETTINGS_TAG_PRIVACY,
+ mojom::kPrivacyAndSecuritySectionPath,
+ mojom::SearchResultIcon::kShield,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSection,
+ {.section = mojom::Section::kPrivacyAndSecurity}},
+ });
+
+ if (chromeos::features::IsAccountManagementFlowsV2Enabled() &&
+ !features::IsGuestModeActive()) {
+ all_tags.insert(
+ all_tags.end(),
+ {{IDS_OS_SETTINGS_TAG_GUEST_BROWSING,
+ mojom::kManageOtherPeopleSubpagePathV2,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kGuestBrowsingV2}},
+ {IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS,
+ mojom::kManageOtherPeopleSubpagePathV2,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kShowUsernamesAndPhotosAtSignInV2},
+ {IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS_ALT1,
+ IDS_OS_SETTINGS_TAG_USERNAMES_AND_PHOTOS_ALT2,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN,
+ mojom::kManageOtherPeopleSubpagePathV2,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kRestrictSignInV2},
+ {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_ALT1,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_ADD,
+ mojom::kManageOtherPeopleSubpagePathV2,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kAddToUserAllowlistV2}},
+ {IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN_REMOVE,
+ mojom::kManageOtherPeopleSubpagePathV2,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kRemoveFromUserAllowlistV2}},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_PIN_OR_PASSWORD,
+ mojom::kSecurityAndSignInSubpagePathV2,
+ mojom::SearchResultIcon::kLock,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kChangeAuthPin},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_PIN_OR_PASSWORD_ALT1,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_WHEN_WAKING,
+ mojom::kSecurityAndSignInSubpagePathV2,
+ mojom::SearchResultIcon::kLock,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kLockScreen},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_WHEN_WAKING_ALT1,
+ SearchConcept::kAltTagEnd}},
+ {IDS_OS_SETTINGS_TAG_LOCK_SCREEN_V2,
+ mojom::kSecurityAndSignInSubpagePathV2,
+ mojom::SearchResultIcon::kLock,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kSecurityAndSignIn}}});
+ }
+
+ return all_tags;
+ }());
+
+ return *tags;
+}
+
+const std::vector<SearchConcept>& GetFingerprintSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_PRIVACY_VERIFIED_ACCESS,
- mojom::kPrivacyAndSecuritySectionPath,
- mojom::SearchResultIcon::kShield,
+ {IDS_OS_SETTINGS_TAG_FINGERPRINT_ADD,
+ mojom::kFingerprintSubpagePathV2,
+ mojom::SearchResultIcon::kFingerprint,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kAddFingerprintV2}},
+ {IDS_OS_SETTINGS_TAG_FINGERPRINT,
+ mojom::kFingerprintSubpagePathV2,
+ mojom::SearchResultIcon::kFingerprint,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kFingerprintV2}},
+ });
+ return *tags;
+}
+
+const std::vector<SearchConcept>& GetRemoveFingerprintSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_FINGERPRINT_REMOVE,
+ mojom::kFingerprintSubpagePathV2,
+ mojom::SearchResultIcon::kFingerprint,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kVerifiedAccess}},
- {IDS_OS_SETTINGS_TAG_PRIVACY,
+ {.setting = mojom::Setting::kRemoveFingerprintV2}},
+ });
+ return *tags;
+}
+
+const std::vector<SearchConcept>& GetPciguardSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_PRIVACY_PERIPHERAL_DATA_ACCESS_PROTECTION,
mojom::kPrivacyAndSecuritySectionPath,
mojom::SearchResultIcon::kShield,
mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSection,
- {.section = mojom::Section::kPrivacyAndSecurity}},
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kPeripheralDataAccessProtection},
+ {IDS_OS_SETTINGS_TAG_PRIVACY_PERIPHERAL_DATA_ACCESS_PROTECTION_ALT1,
+ IDS_OS_SETTINGS_TAG_PRIVACY_PERIPHERAL_DATA_ACCESS_PROTECTION_ALT2,
+ IDS_OS_SETTINGS_TAG_PRIVACY_PERIPHERAL_DATA_ACCESS_PROTECTION_ALT3,
+ IDS_OS_SETTINGS_TAG_PRIVACY_PERIPHERAL_DATA_ACCESS_PROTECTION_ALT4,
+ IDS_OS_SETTINGS_TAG_PRIVACY_PERIPHERAL_DATA_ACCESS_PROTECTION_ALT5}},
});
return *tags;
}
@@ -59,20 +180,44 @@ const std::vector<SearchConcept>& GetPrivacyGoogleChromeSearchConcepts() {
} // namespace
PrivacySection::PrivacySection(Profile* profile,
- SearchTagRegistry* search_tag_registry)
- : OsSettingsSection(profile, search_tag_registry) {
+ SearchTagRegistry* search_tag_registry,
+ PrefService* pref_service)
+ : OsSettingsSection(profile, search_tag_registry),
+ pref_service_(pref_service) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.AddSearchTags(GetPrivacySearchConcepts());
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
updater.AddSearchTags(GetPrivacyGoogleChromeSearchConcepts());
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
+
+ // Fingerprint search tags are added if necessary. Remove fingerprint search
+ // tags update dynamically during a user session.
+ if (!features::IsGuestModeActive() && AreFingerprintSettingsAllowed() &&
+ chromeos::features::IsAccountManagementFlowsV2Enabled()) {
+ updater.AddSearchTags(GetFingerprintSearchConcepts());
+
+ fingerprint_pref_change_registrar_.Init(pref_service_);
+ fingerprint_pref_change_registrar_.Add(
+ ::prefs::kQuickUnlockFingerprintRecord,
+ base::BindRepeating(&PrivacySection::UpdateRemoveFingerprintSearchTags,
+ base::Unretained(this)));
+ UpdateRemoveFingerprintSearchTags();
+ }
+
+ if (chromeos::features::IsPciguardUiEnabled()) {
+ updater.AddSearchTags(GetPciguardSearchConcepts());
+ }
}
PrivacySection::~PrivacySection() = default;
+void PrivacySection::AddHandlers(content::WebUI* web_ui) {
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::PeripheralDataAccessHandler>());
+}
+
void PrivacySection::AddLoadTimeData(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"privacyPageTitle", IDS_SETTINGS_PRIVACY},
{"enableLogging", IDS_SETTINGS_ENABLE_LOGGING_TOGGLE_TITLE},
{"enableLoggingDesc", IDS_SETTINGS_ENABLE_LOGGING_TOGGLE_DESC},
{"enableContentProtectionAttestation",
@@ -80,22 +225,42 @@ void PrivacySection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"enableSuggestedContent", IDS_SETTINGS_ENABLE_SUGGESTED_CONTENT_TITLE},
{"enableSuggestedContentDesc",
IDS_SETTINGS_ENABLE_SUGGESTED_CONTENT_DESC},
+ {"peripheralDataAccessProtectionToggleTitle",
+ IDS_OS_SETTINGS_DATA_ACCESS_PROTECTION_TOGGLE_TITLE},
+ {"peripheralDataAccessProtectionToggleDescription",
+ IDS_OS_SETTINGS_DATA_ACCESS_PROTECTION_TOGGLE_DESCRIPTION},
+ {"peripheralDataAccessProtectionWarningTitle",
+ IDS_OS_SETTINGS_DISABLE_DATA_ACCESS_PROTECTION_CONFIRM_DIALOG_TITLE},
+ {"peripheralDataAccessProtectionWarningDescription",
+ IDS_OS_SETTINGS_DISABLE_DATA_ACCESS_PROTECTION_CONFIRM_DIALOG_DESCRIPTION},
+ {"peripheralDataAccessProtectionWarningSubDescription",
+ IDS_OS_SETTINGS_DISABLE_DATA_ACCESS_PROTECTION_CONFIRM_DIALOG_SUB_DESCRIPTION},
+ {"peripheralDataAccessProtectionCancelButton",
+ IDS_OS_SETTINGS_DATA_ACCESS_PROTECTION_CONFIRM_DIALOG_CANCEL_BUTTON_LABEL},
+ {"peripheralDataAccessProtectionDisableButton",
+ IDS_OS_SETTINGS_DATA_ACCESS_PROTECTION_CONFIRM_DIALOG_DISABLE_BUTTON_LABEL},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
-
- html_source->AddBoolean(
- "privacySettingsRedesignEnabled",
- base::FeatureList::IsEnabled(::features::kPrivacySettingsRedesign));
+ html_source->AddLocalizedStrings(kLocalizedStrings);
- html_source->AddBoolean("suggestedContentToggleEnabled",
- base::FeatureList::IsEnabled(
- ::chromeos::features::kSuggestedContentToggle));
+ if (chromeos::features::IsAccountManagementFlowsV2Enabled()) {
+ html_source->AddLocalizedString("privacyPageTitle",
+ IDS_SETTINGS_PRIVACY_V2);
+ } else {
+ html_source->AddLocalizedString("privacyPageTitle", IDS_SETTINGS_PRIVACY);
+ }
html_source->AddString("suggestedContentLearnMoreURL",
chrome::kSuggestedContentLearnMoreURL);
html_source->AddString("syncAndGoogleServicesLearnMoreURL",
chrome::kSyncAndGoogleServicesLearnMoreURL);
+
+ html_source->AddString("peripheralDataAccessLearnMoreURL",
+ chrome::kPeripheralDataAccessHelpURL);
+
+ html_source->AddBoolean("pciguardUiEnabled",
+ chromeos::features::IsPciguardUiEnabled());
+
::settings::AddPersonalizationOptionsStrings(html_source);
}
@@ -117,14 +282,82 @@ std::string PrivacySection::GetSectionPath() const {
bool PrivacySection::LogMetric(mojom::Setting setting,
base::Value& value) const {
- // Unimplemented.
- return false;
+ switch (setting) {
+ case mojom::Setting::kPeripheralDataAccessProtection:
+ base::UmaHistogramBoolean(
+ "ChromeOS.Settings.Privacy.PeripheralDataAccessProtection",
+ value.GetBool());
+ return true;
+ default:
+ return false;
+ }
}
void PrivacySection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kVerifiedAccess);
generator->RegisterTopLevelSetting(
mojom::Setting::kUsageStatsAndCrashReports);
+
+ // Security and sign-in.
+ generator->RegisterTopLevelSubpage(
+ IDS_SETTINGS_PEOPLE_LOCK_SCREEN_TITLE_LOGIN_LOCK_V2,
+ mojom::Subpage::kSecurityAndSignInV2, mojom::SearchResultIcon::kLock,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kSecurityAndSignInSubpagePathV2);
+ static constexpr mojom::Setting kSecurityAndSignInSettings[] = {
+ mojom::Setting::kLockScreenV2,
+ mojom::Setting::kChangeAuthPinV2,
+ mojom::Setting::kPeripheralDataAccessProtection,
+ };
+ RegisterNestedSettingBulk(mojom::Subpage::kSecurityAndSignInV2,
+ kSecurityAndSignInSettings, generator);
+
+ // Fingerprint.
+ generator->RegisterNestedSubpage(
+ IDS_SETTINGS_PEOPLE_LOCK_SCREEN_FINGERPRINT_SUBPAGE_TITLE,
+ mojom::Subpage::kFingerprintV2, mojom::Subpage::kSecurityAndSignIn,
+ mojom::SearchResultIcon::kFingerprint,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kFingerprintSubpagePathV2);
+ static constexpr mojom::Setting kFingerprintSettings[] = {
+ mojom::Setting::kAddFingerprintV2,
+ mojom::Setting::kRemoveFingerprintV2,
+ };
+ RegisterNestedSettingBulk(mojom::Subpage::kFingerprintV2,
+ kFingerprintSettings, generator);
+
+ // Manage other people.
+ generator->RegisterTopLevelSubpage(IDS_SETTINGS_PEOPLE_MANAGE_OTHER_PEOPLE,
+ mojom::Subpage::kManageOtherPeopleV2,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kManageOtherPeopleSubpagePathV2);
+ static constexpr mojom::Setting kManageOtherPeopleSettings[] = {
+ mojom::Setting::kGuestBrowsingV2,
+ mojom::Setting::kShowUsernamesAndPhotosAtSignInV2,
+ mojom::Setting::kRestrictSignInV2,
+ mojom::Setting::kAddToUserAllowlistV2,
+ mojom::Setting::kRemoveFromUserAllowlistV2,
+ };
+ RegisterNestedSettingBulk(mojom::Subpage::kManageOtherPeopleV2,
+ kManageOtherPeopleSettings, generator);
+}
+
+bool PrivacySection::AreFingerprintSettingsAllowed() {
+ return chromeos::quick_unlock::IsFingerprintEnabled(profile());
+}
+
+void PrivacySection::UpdateRemoveFingerprintSearchTags() {
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetRemoveFingerprintSearchConcepts());
+
+ // "Remove fingerprint" search tag should exist only when 1 or more
+ // fingerprints are registered.
+ int registered_fingerprint_count =
+ pref_service_->GetInteger(::prefs::kQuickUnlockFingerprintRecord);
+ if (registered_fingerprint_count > 0) {
+ updater.AddSearchTags(GetRemoveFingerprintSearchConcepts());
+ }
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.h
index 30478612203..0f8f7da511f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.h
@@ -7,6 +7,9 @@
#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
+#include "components/prefs/pref_change_registrar.h"
+
+class PrefService;
namespace content {
class WebUIDataSource;
@@ -21,11 +24,14 @@ class SearchTagRegistry;
// search tags are added only for official Google Chrome OS builds.
class PrivacySection : public OsSettingsSection {
public:
- PrivacySection(Profile* profile, SearchTagRegistry* search_tag_registry);
+ PrivacySection(Profile* profile,
+ SearchTagRegistry* search_tag_registry,
+ PrefService* pref_service);
~PrivacySection() override;
private:
// OsSettingsSection:
+ void AddHandlers(content::WebUI* web_ui) override;
void AddLoadTimeData(content::WebUIDataSource* html_source) override;
int GetSectionNameMessageId() const override;
mojom::Section GetSection() const override;
@@ -33,6 +39,12 @@ class PrivacySection : public OsSettingsSection {
std::string GetSectionPath() const override;
bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
+
+ bool AreFingerprintSettingsAllowed();
+ void UpdateRemoveFingerprintSearchTags();
+
+ PrefService* pref_service_;
+ PrefChangeRegistrar fingerprint_pref_change_registrar_;
};
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/quick_unlock_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/quick_unlock_handler.cc
index f74ec2b9c89..2bc0b860087 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/quick_unlock_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/quick_unlock_handler.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/quick_unlock_handler.h"
#include "base/bind.h"
-#include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h"
+#include "chrome/browser/ash/login/quick_unlock/pin_backend.h"
#include "content/public/browser/web_ui.h"
namespace chromeos {
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 c840a790de4..6800b720eaf 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc
@@ -70,7 +70,7 @@ void ResetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"powerwashButtonRoleDescription",
IDS_SETTINGS_FACTORY_RESET_BUTTON_ROLE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("allowPowerwash", IsPowerwashAllowed());
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/BUILD.gn b/chromium/chrome/browser/ui/webui/settings/chromeos/search/BUILD.gn
index abbe2fc2715..00650950dfd 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/BUILD.gn
@@ -2,9 +2,10 @@
# 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)
+assert(is_chromeos_ash)
mojom("mojo_bindings") {
sources = [
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/DIR_METADATA b/chromium/chrome/browser/ui/webui/settings/chromeos/search/DIR_METADATA
new file mode 100644
index 00000000000..2d34b2f4c92
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "OS>Systems>Settings"
+}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/OWNERS b/chromium/chrome/browser/ui/webui/settings/chromeos/search/OWNERS
index 2d3d2668edc..2acde077ff6 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/OWNERS
@@ -3,5 +3,3 @@ zentaro@chromium.org
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: OS>Systems>Settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc
index efb3695cc8e..671c8b66a3b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc
@@ -13,7 +13,7 @@
#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/local_search_service_sync.h"
+#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
@@ -44,14 +44,16 @@ SearchHandler::SearchHandler(
SearchTagRegistry* search_tag_registry,
OsSettingsSections* sections,
Hierarchy* hierarchy,
- local_search_service::LocalSearchServiceSync* local_search_service)
+ local_search_service::LocalSearchServiceProxy* local_search_service_proxy)
: search_tag_registry_(search_tag_registry),
sections_(sections),
- hierarchy_(hierarchy),
- index_(local_search_service->GetIndexSync(
- local_search_service::IndexId::kCrosSettings,
- local_search_service::Backend::kLinearMap,
- g_browser_process ? g_browser_process->local_state() : nullptr)) {
+ hierarchy_(hierarchy) {
+ local_search_service_proxy->GetIndex(
+ local_search_service::IndexId::kCrosSettings,
+ local_search_service::Backend::kLinearMap,
+ index_remote_.BindNewPipeAndPassReceiver());
+ DCHECK(index_remote_.is_bound());
+
search_tag_registry_->AddObserver(this);
}
@@ -64,10 +66,10 @@ void SearchHandler::BindInterface(
receivers_.Add(this, std::move(pending_receiver));
}
-std::vector<mojom::SearchResultPtr> SearchHandler::Search(
- const base::string16& query,
- uint32_t max_num_results,
- mojom::ParentResultBehavior parent_result_behavior) {
+void SearchHandler::Search(const base::string16& query,
+ uint32_t max_num_results,
+ mojom::ParentResultBehavior parent_result_behavior,
+ SearchCallback callback) {
// Search for 5x the maximum set of results. If there are many matches for
// a query, it may be the case that |index_| returns some matches with higher
// SearchResultDefaultRank values later in the list. Requesting up to 5x the
@@ -75,27 +77,11 @@ std::vector<mojom::SearchResultPtr> SearchHandler::Search(
// accordingly when sorted.
uint32_t max_local_search_service_results = 5 * max_num_results;
- std::vector<local_search_service::Result> local_search_service_results;
- local_search_service::ResponseStatus response_status = index_->FindSync(
- query, max_local_search_service_results, &local_search_service_results);
-
- if (response_status != local_search_service::ResponseStatus::kSuccess) {
- LOG(ERROR) << "Cannot search; LocalSearchServiceSync returned "
- << static_cast<int>(response_status)
- << ". Returning empty results array.";
- return {};
- }
-
- return GenerateSearchResultsArray(local_search_service_results,
- max_num_results, parent_result_behavior);
-}
-
-void SearchHandler::Search(const base::string16& query,
- uint32_t max_num_results,
- mojom::ParentResultBehavior parent_result_behavior,
- SearchCallback callback) {
- std::move(callback).Run(
- Search(query, max_num_results, parent_result_behavior));
+ index_remote_->Find(
+ query, max_local_search_service_results,
+ base::BindOnce(&SearchHandler::OnFindComplete,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback),
+ max_num_results, parent_result_behavior));
}
void SearchHandler::Observe(
@@ -135,6 +121,26 @@ std::vector<mojom::SearchResultPtr> SearchHandler::GenerateSearchResultsArray(
return search_results;
}
+void SearchHandler::OnFindComplete(
+ SearchCallback callback,
+ uint32_t max_num_results,
+ mojom::ParentResultBehavior parent_result_behavior,
+ local_search_service::ResponseStatus response_status,
+ const base::Optional<std::vector<local_search_service::Result>>&
+ local_search_service_results) {
+ if (response_status != local_search_service::ResponseStatus::kSuccess) {
+ LOG(ERROR) << "Cannot search; LocalSearchService returned "
+ << static_cast<int>(response_status)
+ << ". Returning empty results array.";
+ std::move(callback).Run({});
+ return;
+ }
+
+ std::move(callback).Run(
+ GenerateSearchResultsArray(local_search_service_results.value(),
+ max_num_results, parent_result_behavior));
+}
+
void SearchHandler::AddParentResults(
uint32_t max_num_results,
std::vector<mojom::SearchResultPtr>* search_results) const {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h
index 95a50eae282..592fc768909 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h
@@ -11,7 +11,8 @@
#include "base/optional.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/index_sync.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 "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
@@ -20,10 +21,6 @@
namespace chromeos {
-namespace local_search_service {
-class LocalSearchServiceSync;
-} // namespace local_search_service
-
namespace settings {
class Hierarchy;
@@ -33,18 +30,18 @@ struct SearchConcept;
// Handles search queries for Chrome OS settings. Search() is expected to be
// invoked by the settings UI as well as the the Launcher search UI. Search
// results are obtained by matching the provided query against search tags
-// indexed in the LocalSearchServiceSync and cross-referencing results with
+// indexed in the LocalSearchService and cross-referencing results with
// SearchTagRegistry.
//
// Searches which do not provide any matches result in an empty results array.
class SearchHandler : public mojom::SearchHandler,
public SearchTagRegistry::Observer {
public:
- SearchHandler(
- SearchTagRegistry* search_tag_registry,
- OsSettingsSections* sections,
- Hierarchy* hierarchy,
- local_search_service::LocalSearchServiceSync* local_search_service);
+ SearchHandler(SearchTagRegistry* search_tag_registry,
+ OsSettingsSections* sections,
+ Hierarchy* hierarchy,
+ local_search_service::LocalSearchServiceProxy*
+ local_search_service_proxy);
~SearchHandler() override;
SearchHandler(const SearchHandler& other) = delete;
@@ -53,12 +50,6 @@ class SearchHandler : public mojom::SearchHandler,
void BindInterface(
mojo::PendingReceiver<mojom::SearchHandler> pending_receiver);
- // Synchronous search implementation (for in-process clients).
- std::vector<mojom::SearchResultPtr> Search(
- const base::string16& query,
- uint32_t max_num_results,
- mojom::ParentResultBehavior parent_result_behavior);
-
// mojom::SearchHandler:
void Search(const base::string16& query,
uint32_t max_num_results,
@@ -79,6 +70,14 @@ class SearchHandler : public mojom::SearchHandler,
uint32_t max_num_results,
mojom::ParentResultBehavior parent_result_behavior) const;
+ void OnFindComplete(
+ SearchCallback callback,
+ uint32_t max_num_results,
+ mojom::ParentResultBehavior parent_result_behavior,
+ local_search_service::ResponseStatus response_status,
+ const base::Optional<std::vector<local_search_service::Result>>&
+ local_search_service_results);
+
void AddParentResults(
uint32_t max_num_results,
std::vector<mojom::SearchResultPtr>* search_results) const;
@@ -108,11 +107,13 @@ class SearchHandler : public mojom::SearchHandler,
SearchTagRegistry* search_tag_registry_;
OsSettingsSections* sections_;
Hierarchy* hierarchy_;
- local_search_service::IndexSync* index_;
+ mojo::Remote<local_search_service::mojom::Index> index_remote_;
// Note: Expected to have multiple clients, so ReceiverSet/RemoteSet are used.
mojo::ReceiverSet<mojom::SearchHandler> receivers_;
mojo::RemoteSet<mojom::SearchResultsObserver> observers_;
+
+ base::WeakPtrFactory<SearchHandler> weak_ptr_factory_{this};
};
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc
index d1bf9da8c45..5d2bb644d0e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc
@@ -13,8 +13,7 @@
#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/local_search_service_sync.h"
-#include "chromeos/constants/chromeos_features.h"
+#include "chromeos/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"
@@ -90,12 +89,12 @@ mojom::SearchResultPtr CreateDummyResult() {
class SearchHandlerTest : public testing::Test {
protected:
SearchHandlerTest()
- : search_tag_registry_(&local_search_service_),
+ : search_tag_registry_(local_search_service_proxy_.get()),
fake_hierarchy_(&fake_sections_),
handler_(&search_tag_registry_,
&fake_sections_,
&fake_hierarchy_,
- &local_search_service_) {}
+ local_search_service_proxy_.get()) {}
~SearchHandlerTest() override = default;
// testing::Test:
@@ -129,7 +128,10 @@ class SearchHandlerTest : public testing::Test {
}
base::test::TaskEnvironment task_environment_;
- local_search_service::LocalSearchServiceSync local_search_service_;
+ std::unique_ptr<local_search_service::LocalSearchServiceProxy>
+ local_search_service_proxy_ =
+ std::make_unique<local_search_service::LocalSearchServiceProxy>(
+ /*for_testing=*/true);
SearchTagRegistry search_tag_registry_;
FakeOsSettingsSections fake_sections_;
FakeHierarchy fake_hierarchy_;
@@ -142,6 +144,7 @@ TEST_F(SearchHandlerTest, AddAndRemove) {
// Add printing search tags to registry and search for "Print".
AddSearchTags(GetPrintingSearchConcepts());
handler_remote_.FlushForTesting();
+ task_environment_.RunUntilIdle();
EXPECT_EQ(1u, observer_.num_calls());
std::vector<mojom::SearchResultPtr> search_results;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom
index 9fa8477dac6..0afbaeb6305 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_result_icon.mojom
@@ -16,6 +16,7 @@ enum SearchResultIcon {
kCellular,
kChrome,
kClock,
+ kDeveloperTags,
kDisplay,
kDrive,
kEthernet,
@@ -40,6 +41,7 @@ enum SearchResultIcon {
kPrinter,
kReset,
kShield,
+ kStartup,
kStylus,
kSync,
kWallpaper,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc
index 5f9e94c2a90..1772dcb0a6d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc
@@ -11,8 +11,7 @@
#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/local_search_service_sync.h"
-#include "chromeos/constants/chromeos_features.h"
+#include "chromeos/components/local_search_service/public/cpp/local_search_service_proxy.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
@@ -53,7 +52,7 @@ SearchTagRegistry::ScopedTagUpdater::~ScopedTagUpdater() {
bool is_pending_add = map_entry.second.second;
// If tag metadata is present for this tag, it has already been added and is
- // present in LocalSearchServiceSync.
+ // present in LocalSearchService.
bool is_concept_already_added =
registry_->GetTagMetadata(result_id) != nullptr;
@@ -99,11 +98,13 @@ void SearchTagRegistry::ScopedTagUpdater::ProcessPendingSearchTags(
}
SearchTagRegistry::SearchTagRegistry(
- local_search_service::LocalSearchServiceSync* local_search_service)
- : index_(local_search_service->GetIndexSync(
- local_search_service::IndexId::kCrosSettings,
- local_search_service::Backend::kLinearMap,
- g_browser_process ? g_browser_process->local_state() : nullptr)) {}
+ local_search_service::LocalSearchServiceProxy* local_search_service_proxy) {
+ local_search_service_proxy->GetIndex(
+ local_search_service::IndexId::kCrosSettings,
+ local_search_service::Backend::kLinearMap,
+ index_remote_.BindNewPipeAndPassReceiver());
+ DCHECK(index_remote_.is_bound());
+}
SearchTagRegistry::~SearchTagRegistry() = default;
@@ -121,15 +122,16 @@ SearchTagRegistry::ScopedTagUpdater SearchTagRegistry::StartUpdate() {
void SearchTagRegistry::AddSearchTags(
const std::vector<const SearchConcept*>& search_tags) {
- index_->AddOrUpdateSync(ConceptVectorToDataVector(search_tags));
-
// Add each concept to the map. Note that it is safe to take the address of
// each concept because all concepts are allocated via static
// base::NoDestructor objects in the Get*SearchConcepts() helper functions.
for (const auto* concept : search_tags)
result_id_to_metadata_list_map_[ToResultId(*concept)] = concept;
- NotifyRegistryUpdated();
+ index_remote_->AddOrUpdate(
+ ConceptVectorToDataVector(search_tags),
+ base::BindOnce(&SearchTagRegistry::NotifyRegistryAdded,
+ weak_ptr_factory_.GetWeakPtr()));
}
void SearchTagRegistry::RemoveSearchTags(
@@ -141,9 +143,9 @@ void SearchTagRegistry::RemoveSearchTags(
data_ids.push_back(std::move(result_id));
}
- index_->DeleteSync(data_ids);
-
- NotifyRegistryUpdated();
+ index_remote_->Delete(
+ data_ids, base::BindOnce(&SearchTagRegistry::NotifyRegistryDeleted,
+ weak_ptr_factory_.GetWeakPtr()));
}
const SearchConcept* SearchTagRegistry::GetTagMetadata(
@@ -200,5 +202,13 @@ void SearchTagRegistry::NotifyRegistryUpdated() {
observer.OnRegistryUpdated();
}
+void SearchTagRegistry::NotifyRegistryAdded() {
+ NotifyRegistryUpdated();
+}
+
+void SearchTagRegistry::NotifyRegistryDeleted(uint32_t num_deleted) {
+ NotifyRegistryUpdated();
+}
+
} // namespace settings
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h
index 645575e8a8d..46e9e2b7d7a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h
@@ -13,21 +13,18 @@
#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/index_sync.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 "mojo/public/cpp/bindings/remote.h"
namespace chromeos {
-namespace local_search_service {
-class IndexSync;
-class LocalSearchServiceSync;
-} // namespace local_search_service
-
namespace settings {
struct SearchConcept;
// Processes all registered search tags by adding/removing them from
-// LocalSearchServiceSync and providing metadata via GetTagMetadata().
+// LocalSearchService and providing metadata via GetTagMetadata().
class SearchTagRegistry {
public:
class Observer : public base::CheckedObserver {
@@ -63,8 +60,8 @@ class SearchTagRegistry {
std::unordered_map<std::string, ConceptWithShouldAddBool> pending_updates_;
};
- SearchTagRegistry(
- local_search_service::LocalSearchServiceSync* local_search_service);
+ SearchTagRegistry(local_search_service::LocalSearchServiceProxy*
+ local_search_service_proxy);
SearchTagRegistry(const SearchTagRegistry& other) = delete;
SearchTagRegistry& operator=(const SearchTagRegistry& other) = delete;
virtual ~SearchTagRegistry();
@@ -79,7 +76,7 @@ class SearchTagRegistry {
ScopedTagUpdater StartUpdate();
// Returns the tag metadata associated with |result_id|, which is the ID
- // returned by the LocalSearchServiceSync. If no metadata is available, null
+ // returned by the LocalSearchService. If no metadata is available, null
// is returned.
const SearchConcept* GetTagMetadata(const std::string& result_id) const;
private:
@@ -93,16 +90,19 @@ class SearchTagRegistry {
std::vector<local_search_service::Data> ConceptVectorToDataVector(
const std::vector<const SearchConcept*>& search_tags);
void NotifyRegistryUpdated();
+ void NotifyRegistryAdded();
+ void NotifyRegistryDeleted(uint32_t /*num_deleted*/);
- // Index used by the LocalSearchServiceSync for string matching.
- local_search_service::IndexSync* index_;
+ // Index used by the LocalSearchService for string matching.
+ mojo::Remote<local_search_service::mojom::Index> index_remote_;
// In-memory cache of all results which have been added to the
- // LocalSearchServiceSync. Contents are kept in sync with |index_|.
+ // LocalSearchService. Contents are kept in sync with |index_remote_|.
std::unordered_map<std::string, const SearchConcept*>
result_id_to_metadata_list_map_;
base::ObserverList<Observer> observer_list_;
+ base::WeakPtrFactory<SearchTagRegistry> weak_ptr_factory_{this};
};
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry_unittest.cc
index 7b683863f45..5611dab7336 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry_unittest.cc
@@ -5,12 +5,12 @@
#include "chrome/browser/ui/webui/settings/chromeos/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/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/index_sync.h"
-#include "chromeos/components/local_search_service/local_search_service_sync.h"
+#include "chromeos/components/local_search_service/public/mojom/index.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
@@ -63,23 +63,46 @@ const std::vector<SearchConcept>& GetPrintingSearchConcepts() {
class SearchTagRegistryTest : public testing::Test {
protected:
- SearchTagRegistryTest() : search_tag_registry_(&local_search_service_) {}
+ SearchTagRegistryTest()
+ : search_tag_registry_(local_search_service_proxy_.get()) {}
+
~SearchTagRegistryTest() override = default;
// testing::Test:
void SetUp() override {
search_tag_registry_.AddObserver(&observer_);
- index_ = local_search_service_.GetIndexSync(
+
+ local_search_service_proxy_->GetIndex(
local_search_service::IndexId::kCrosSettings,
- local_search_service::Backend::kLinearMap, nullptr /* local_state */);
+ local_search_service::Backend::kLinearMap,
+ index_remote_.BindNewPipeAndPassReceiver());
}
void TearDown() override { search_tag_registry_.RemoveObserver(&observer_); }
- local_search_service::LocalSearchServiceSync local_search_service_;
+ void IndexGetSizeAndCheckResults(uint32_t expected_num_items) {
+ bool callback_done = false;
+ uint32_t num_items = 0;
+ index_remote_->GetSize(base::BindOnce(
+ [](bool* callback_done, uint32_t* num_items, uint64_t size) {
+ *callback_done = true;
+ *num_items = size;
+ },
+ &callback_done, &num_items));
+ task_environment_.RunUntilIdle();
+ ASSERT_TRUE(callback_done);
+ EXPECT_EQ(num_items, expected_num_items);
+ }
+
+ // This line should be before search_tag_registry_ is declared.
+ base::test::SingleThreadTaskEnvironment task_environment_;
+ std::unique_ptr<local_search_service::LocalSearchServiceProxy>
+ local_search_service_proxy_ =
+ std::make_unique<local_search_service::LocalSearchServiceProxy>(
+ /*for_testing=*/true);
SearchTagRegistry search_tag_registry_;
FakeObserver observer_;
- local_search_service::IndexSync* index_;
+ mojo::Remote<local_search_service::mojom::Index> index_remote_;
};
TEST_F(SearchTagRegistryTest, AddAndRemove) {
@@ -91,11 +114,11 @@ TEST_F(SearchTagRegistryTest, AddAndRemove) {
// Nothing should have happened yet, since |updater| has not gone out of
// scope.
- EXPECT_EQ(0u, index_->GetSizeSync());
+ IndexGetSizeAndCheckResults(0u);
EXPECT_EQ(0u, observer_.num_calls());
}
// Now that it went out of scope, the update should have occurred.
- EXPECT_EQ(3u, index_->GetSizeSync());
+ IndexGetSizeAndCheckResults(3u);
EXPECT_EQ(1u, observer_.num_calls());
std::string first_tag_id =
@@ -115,11 +138,11 @@ TEST_F(SearchTagRegistryTest, AddAndRemove) {
// Tags should not have been removed yet, since |updater| has not gone out
// of scope.
- EXPECT_EQ(3u, index_->GetSizeSync());
+ IndexGetSizeAndCheckResults(3u);
EXPECT_EQ(1u, observer_.num_calls());
}
// Now that it went out of scope, the update should have occurred.
- EXPECT_EQ(0u, index_->GetSizeSync());
+ IndexGetSizeAndCheckResults(0u);
EXPECT_EQ(2u, observer_.num_calls());
// The tag should no longer be accessible via GetTagMetadata().
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 f27580fa333..f591a288ca3 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc
@@ -11,7 +11,7 @@
#include "base/no_destructor.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/assistant/assistant_util.h"
+#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/chromeos/google_assistant_handler.h"
@@ -20,8 +20,6 @@
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/components/quick_answers/quick_answers_client.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"
@@ -114,18 +112,6 @@ const std::vector<SearchConcept>& GetAssistantOffSearchConcepts() {
return *tags;
}
-const std::vector<SearchConcept>& GetAssistantQuickAnswersSearchConcepts() {
- static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_ASSISTANT_QUICK_ANSWERS,
- mojom::kAssistantSubpagePath,
- mojom::SearchResultIcon::kAssistant,
- mojom::SearchResultDefaultRank::kLow,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kAssistantQuickAnswers}},
- });
- return *tags;
-}
-
const std::vector<SearchConcept>& GetAssistantVoiceMatchSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_ASSISTANT_TRAIN_VOICE_MODEL,
@@ -148,10 +134,6 @@ void AddGoogleAssistantStrings(content::WebUIDataSource* html_source) {
{"googleAssistantEnableContext", IDS_ASSISTANT_SCREEN_CONTEXT_TITLE},
{"googleAssistantEnableContextDescription",
IDS_ASSISTANT_SCREEN_CONTEXT_DESC},
- {"googleAssistantEnableQuickAnswers",
- IDS_ASSISTANT_QUICK_ANSWERS_SETTING_TITLE},
- {"googleAssistantEnableQuickAnswersDescription",
- IDS_ASSISTANT_QUICK_ANSWERS_SETTING_DESC},
{"googleAssistantEnableHotword",
IDS_SETTINGS_GOOGLE_ASSISTANT_ENABLE_HOTWORD},
{"googleAssistantEnableHotwordDescription",
@@ -180,7 +162,7 @@ void AddGoogleAssistantStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_GOOGLE_ASSISTANT_LAUNCH_WITH_MIC_OPEN_DESCRIPTION},
{"googleAssistantSettings", IDS_SETTINGS_GOOGLE_ASSISTANT_SETTINGS},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("hotwordDspAvailable", IsHotwordDspAvailable());
html_source->AddBoolean("voiceMatchDisabled", !IsVoiceMatchAllowed());
@@ -221,11 +203,10 @@ void SearchSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"searchGoogleAssistantOn", IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_ON},
{"searchGoogleAssistantOff", IDS_SETTINGS_SEARCH_GOOGLE_ASSISTANT_OFF},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
const bool is_assistant_allowed = IsAssistantAllowed();
html_source->AddBoolean("isAssistantAllowed", is_assistant_allowed);
- html_source->AddBoolean("quickAnswersAvailable", IsQuickAnswersAllowed());
html_source->AddLocalizedString("osSearchPageTitle",
is_assistant_allowed
? IDS_SETTINGS_SEARCH_AND_ASSISTANT
@@ -278,7 +259,6 @@ void SearchSection::RegisterHierarchy(HierarchyGenerator* generator) const {
static constexpr mojom::Setting kAssistantSettings[] = {
mojom::Setting::kAssistantOnOff,
mojom::Setting::kAssistantRelatedInfo,
- mojom::Setting::kAssistantQuickAnswers,
mojom::Setting::kAssistantOkGoogle,
mojom::Setting::kAssistantNotifications,
mojom::Setting::kAssistantVoiceInput,
@@ -310,18 +290,12 @@ bool SearchSection::IsAssistantAllowed() const {
chromeos::assistant::AssistantAllowedState::ALLOWED;
}
-bool SearchSection::IsQuickAnswersAllowed() const {
- // TODO(b/159670857): Clean up Quick Answer settings toggle.
- return false;
-}
-
void SearchSection::UpdateAssistantSearchTags() {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
// Start without any Assistant search concepts, then add if needed below.
updater.RemoveSearchTags(GetAssistantOnSearchConcepts());
updater.RemoveSearchTags(GetAssistantOffSearchConcepts());
- updater.RemoveSearchTags(GetAssistantQuickAnswersSearchConcepts());
updater.RemoveSearchTags(GetAssistantVoiceMatchSearchConcepts());
ash::AssistantState* assistant_state = ash::AssistantState::Get();
@@ -336,11 +310,6 @@ void SearchSection::UpdateAssistantSearchTags() {
updater.AddSearchTags(GetAssistantOnSearchConcepts());
- if (IsQuickAnswersAllowed() && assistant_state->context_enabled() &&
- assistant_state->context_enabled().value()) {
- updater.AddSearchTags(GetAssistantQuickAnswersSearchConcepts());
- }
-
if (IsVoiceMatchAllowed() && assistant_state->hotword_enabled() &&
assistant_state->hotword_enabled().value() &&
assistant_state->consent_status() &&
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.h
index e493422f84c..6ab696b1749 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.h
@@ -45,7 +45,6 @@ class SearchSection : public OsSettingsSection,
void OnAssistantHotwordEnabled(bool enabled) override;
bool IsAssistantAllowed() const;
- bool IsQuickAnswersAllowed() const;
void UpdateAssistantSearchTags();
};
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.cc
index 3e3f93eea9c..0ccc78d91ff 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.cc
@@ -83,12 +83,14 @@ void SettingsUserActionTracker::RecordSettingChangeWithDetails(
// new_value is initialized as null. Null value is used in cases that don't
// require extra metadata.
base::Value new_value;
- if (value->is_bool_value()) {
- new_value = base::Value(value->get_bool_value());
- } else if (value->is_int_value()) {
- new_value = base::Value(value->get_int_value());
- } else if (value->is_string_value()) {
- new_value = base::Value(value->get_string_value());
+ if (value) {
+ if (value->is_bool_value()) {
+ new_value = base::Value(value->get_bool_value());
+ } else if (value->is_int_value()) {
+ new_value = base::Value(value->get_int_value());
+ } else if (value->is_string_value()) {
+ new_value = base::Value(value->get_string_value());
+ }
}
section->LogMetric(setting, new_value);
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 d557e9c81d3..b29c7f252c5 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
@@ -46,6 +46,8 @@ class SettingsUserActionTracker : public mojom::UserActionRecorder {
TestRecordSettingChangedBoolPref);
FRIEND_TEST_ALL_PREFIXES(SettingsUserActionTrackerTest,
TestRecordSettingChangedIntPref);
+ FRIEND_TEST_ALL_PREFIXES(SettingsUserActionTrackerTest,
+ TestRecordSettingChangedNullValue);
// mojom::UserActionRecorder:
void RecordPageFocus() override;
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 fd1856badc3..8493d1e6c3c 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
@@ -39,6 +39,8 @@ class SettingsUserActionTrackerTest : public testing::Test {
mojom::Setting::kTouchpadSpeed);
fake_hierarchy_.AddSettingMetadata(mojom::Section::kPeople,
mojom::Setting::kAddAccount);
+ fake_hierarchy_.AddSettingMetadata(mojom::Section::kPrinting,
+ mojom::Setting::kScanningApp);
}
base::HistogramTester histogram_tester_;
@@ -138,5 +140,26 @@ TEST_F(SettingsUserActionTrackerTest, TestRecordSettingChangedIntPref) {
mojom::Setting::kTouchpadSpeed);
}
+TEST_F(SettingsUserActionTrackerTest, TestRecordSettingChangedNullValue) {
+ // Record that the Scan app is opened.
+ tracker_.RecordSettingChangeWithDetails(mojom::Setting::kScanningApp,
+ nullptr);
+
+ // The umbrella metric for which setting was changed should be updated. Note
+ // that kScanningApp has enum value of 1403.
+ histogram_tester_.ExpectTotalCount("ChromeOS.Settings.SettingChanged",
+ /*count=*/1);
+ histogram_tester_.ExpectBucketCount("ChromeOS.Settings.SettingChanged",
+ /*sample=*/1403,
+ /*count=*/1);
+
+ // The LogMetric fn in the Printing section should have been called.
+ const FakeOsSettingsSection* printing_section =
+ static_cast<const FakeOsSettingsSection*>(
+ fake_sections_.GetSection(mojom::Section::kPrinting));
+ EXPECT_TRUE(printing_section->logged_metrics().back() ==
+ mojom::Setting::kScanningApp);
+}
+
} // namespace settings.
} // 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
new file mode 100644
index 00000000000..b6c8ffe9327
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.cc
@@ -0,0 +1,211 @@
+// 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/switch_access_handler.h"
+
+#include "ash/public/cpp/accessibility_controller.h"
+#include "ash/public/cpp/ash_constants.h"
+#include "ash/public/cpp/ash_pref_names.h"
+#include "base/bind.h"
+#include "base/no_destructor.h"
+#include "base/values.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/aura/window.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/events/devices/device_data_manager.h"
+#include "ui/events/devices/input_device.h"
+#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/keycode_converter.h"
+#include "ui/events/ozone/layout/keyboard_layout_engine.h"
+#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
+
+namespace chromeos {
+namespace settings {
+namespace {
+
+struct AssignmentInfo {
+ std::string action_name_for_js;
+ std::string pref_name;
+};
+
+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) {
+ if (!ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()->Lookup(
+ dom_code, /*flags=*/ui::EF_NONE, &dom_key, &key_code_to_compare)) {
+ continue;
+ }
+ if (key_code_to_compare != key_code || !dom_key.IsValid() ||
+ dom_key.IsDeadKey()) {
+ continue;
+ }
+ // Make sure the space key is rendered as "Space" instead of " ".
+ if (key_code == ui::VKEY_SPACE) {
+ return l10n_util::GetStringUTF8(IDS_SETTINGS_SWITCH_ASSIGN_OPTION_SPACE);
+ }
+ return ui::KeycodeConverter::DomKeyToKeyString(dom_key);
+ }
+ return std::string();
+}
+
+std::string GetSwitchAccessDevice(ui::InputDeviceType source_device_type) {
+ switch (source_device_type) {
+ case ui::INPUT_DEVICE_INTERNAL:
+ return ash::kSwitchAccessInternalDevice;
+ case ui::INPUT_DEVICE_USB:
+ return ash::kSwitchAccessUsbDevice;
+ case ui::INPUT_DEVICE_BLUETOOTH:
+ return ash::kSwitchAccessBluetoothDevice;
+ case ui::INPUT_DEVICE_UNKNOWN:
+ return ash::kSwitchAccessUnknownDevice;
+ }
+}
+
+} // namespace
+
+SwitchAccessHandler::SwitchAccessHandler(PrefService* prefs) : prefs_(prefs) {}
+
+SwitchAccessHandler::~SwitchAccessHandler() {
+ // Ensure we always leave Switch Access in a good state no matter what.
+ if (web_ui() && web_ui()->GetWebContents() &&
+ web_ui()->GetWebContents()->GetNativeView()) {
+ web_ui()->GetWebContents()->GetNativeView()->RemovePreTargetHandler(this);
+ }
+
+ if (ash::AccessibilityController::Get())
+ ash::AccessibilityController::Get()->SuspendSwitchAccessKeyHandling(false);
+}
+
+void SwitchAccessHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "refreshAssignmentsFromPrefs",
+ base::BindRepeating(
+ &SwitchAccessHandler::HandleRefreshAssignmentsFromPrefs,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "notifySwitchAccessActionAssignmentDialogAttached",
+ base::BindRepeating(
+ &SwitchAccessHandler::
+ HandleNotifySwitchAccessActionAssignmentDialogAttached,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "notifySwitchAccessActionAssignmentDialogDetached",
+ base::BindRepeating(
+ &SwitchAccessHandler::
+ HandleNotifySwitchAccessActionAssignmentDialogDetached,
+ base::Unretained(this)));
+}
+
+void SwitchAccessHandler::OnJavascriptAllowed() {
+ pref_change_registrar_.reset(new PrefChangeRegistrar);
+ pref_change_registrar_->Init(prefs_);
+ pref_change_registrar_->Add(
+ ash::prefs::kAccessibilitySwitchAccessSelectDeviceKeyCodes,
+ base::BindRepeating(
+ &SwitchAccessHandler::OnSwitchAccessAssignmentsUpdated,
+ base::Unretained(this)));
+ pref_change_registrar_->Add(
+ ash::prefs::kAccessibilitySwitchAccessNextDeviceKeyCodes,
+ base::BindRepeating(
+ &SwitchAccessHandler::OnSwitchAccessAssignmentsUpdated,
+ base::Unretained(this)));
+ pref_change_registrar_->Add(
+ ash::prefs::kAccessibilitySwitchAccessPreviousDeviceKeyCodes,
+ base::BindRepeating(
+ &SwitchAccessHandler::OnSwitchAccessAssignmentsUpdated,
+ base::Unretained(this)));
+}
+
+void SwitchAccessHandler::OnJavascriptDisallowed() {
+ pref_change_registrar_.reset();
+}
+
+void SwitchAccessHandler::OnKeyEvent(ui::KeyEvent* event) {
+ event->StopPropagation();
+ event->SetHandled();
+
+ 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()));
+ ui::InputDeviceType deviceType = ui::INPUT_DEVICE_UNKNOWN;
+
+ int source_device_id = event->source_device_id();
+ for (const auto& keyboard :
+ ui::DeviceDataManager::GetInstance()->GetKeyboardDevices()) {
+ if (source_device_id == keyboard.id) {
+ deviceType = keyboard.type;
+ break;
+ }
+ }
+ response.SetStringPath("device", GetSwitchAccessDevice(deviceType));
+
+ FireWebUIListener("switch-access-got-key-press-for-assignment", response);
+}
+
+void SwitchAccessHandler::HandleRefreshAssignmentsFromPrefs(
+ const base::ListValue* args) {
+ AllowJavascript();
+ OnSwitchAccessAssignmentsUpdated();
+}
+
+void SwitchAccessHandler::
+ HandleNotifySwitchAccessActionAssignmentDialogAttached(
+ const base::ListValue* args) {
+ AllowJavascript();
+ OnSwitchAccessAssignmentsUpdated();
+ web_ui()->GetWebContents()->GetNativeView()->AddPreTargetHandler(this);
+ ash::AccessibilityController::Get()->SuspendSwitchAccessKeyHandling(true);
+}
+
+void SwitchAccessHandler::
+ HandleNotifySwitchAccessActionAssignmentDialogDetached(
+ const base::ListValue* args) {
+ web_ui()->GetWebContents()->GetNativeView()->RemovePreTargetHandler(this);
+ ash::AccessibilityController::Get()->SuspendSwitchAccessKeyHandling(false);
+}
+
+void SwitchAccessHandler::OnSwitchAccessAssignmentsUpdated() {
+ base::DictionaryValue response;
+
+ static base::NoDestructor<std::vector<AssignmentInfo>> kAssignmentInfo({
+ {"select", ash::prefs::kAccessibilitySwitchAccessSelectDeviceKeyCodes},
+ {"next", ash::prefs::kAccessibilitySwitchAccessNextDeviceKeyCodes},
+ {"previous",
+ ash::prefs::kAccessibilitySwitchAccessPreviousDeviceKeyCodes},
+ });
+
+ for (const AssignmentInfo& info : *kAssignmentInfo) {
+ auto* keycodes = prefs_->GetDictionary(info.pref_name);
+ base::ListValue keys;
+ for (const auto& item : keycodes->DictItems()) {
+ int key_code;
+ if (!base::StringToInt(item.first, &key_code)) {
+ NOTREACHED();
+ return;
+ }
+ for (const base::Value& device_type : item.second.GetList()) {
+ base::DictionaryValue key;
+ key.SetStringPath("key", GetStringForKeyboardCode(
+ static_cast<ui::KeyboardCode>(key_code)));
+ key.SetStringPath("device", device_type.GetString());
+ keys.Append(std::move(key));
+ }
+ }
+ response.SetPath(info.action_name_for_js, std::move(keys));
+ }
+
+ FireWebUIListener("switch-access-assignments-changed", response);
+}
+
+} // namespace settings
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.h
new file mode 100644
index 00000000000..4132356c352
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/switch_access_handler.h
@@ -0,0 +1,53 @@
+// 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_SWITCH_ACCESS_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SWITCH_ACCESS_HANDLER_H_
+
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "components/prefs/pref_change_registrar.h"
+#include "ui/events/event_handler.h"
+
+namespace base {
+class ListValue;
+}
+
+class PrefService;
+
+namespace chromeos {
+namespace settings {
+
+// Settings handler for the switch access subpage.
+class SwitchAccessHandler : public ::settings::SettingsPageUIHandler,
+ public ui::EventHandler {
+ public:
+ explicit SwitchAccessHandler(PrefService* prefs);
+
+ ~SwitchAccessHandler() override;
+
+ // SettingsPageUIHandler implementation.
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ // ui::EventHandler overrides.
+ void OnKeyEvent(ui::KeyEvent* event) override;
+
+ private:
+ void HandleRefreshAssignmentsFromPrefs(const base::ListValue* args);
+ void HandleNotifySwitchAccessActionAssignmentDialogAttached(
+ const base::ListValue* args);
+ void HandleNotifySwitchAccessActionAssignmentDialogDetached(
+ const base::ListValue* args);
+ void OnSwitchAccessAssignmentsUpdated();
+
+ std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
+
+ PrefService* prefs_;
+};
+
+} // namespace settings
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SWITCH_ACCESS_HANDLER_H_
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 97d24e4a3c0..705545443dd 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/tts_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/tts_handler.cc
@@ -141,7 +141,7 @@ void TtsHandler::HandlePreviewTtsVoice(const base::ListValue* args) {
json->GetString("extension", &extension_id);
std::unique_ptr<content::TtsUtterance> utterance =
- content::TtsUtterance::Create((Profile::FromWebUI(web_ui())));
+ content::TtsUtterance::Create(web_ui()->GetWebContents());
utterance->SetText(text);
utterance->SetVoiceName(name);
utterance->SetEngineId(extension_id);
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc
index 60153b07908..a1f17aafc7c 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h"
#include "base/bind.h"
+#include "chrome/browser/chromeos/backdrop_wallpaper_handlers/backdrop_wallpaper.pb.h"
+#include "chrome/browser/chromeos/backdrop_wallpaper_handlers/backdrop_wallpaper_handlers.h"
#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "content/public/browser/web_ui.h"
@@ -33,6 +35,11 @@ void WallpaperHandler::RegisterMessages() {
"isWallpaperPolicyControlled",
base::BindRepeating(&WallpaperHandler::HandleIsWallpaperPolicyControlled,
base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "fetchWallpaperCollections",
+ base::BindRepeating(&WallpaperHandler::HandleFetchWallpaperCollections,
+ base::Unretained(this)));
}
void WallpaperHandler::HandleIsWallpaperSettingVisible(
@@ -55,6 +62,36 @@ void WallpaperHandler::HandleOpenWallpaperManager(const base::ListValue* args) {
WallpaperControllerClient::Get()->OpenWallpaperPickerIfAllowed();
}
+void WallpaperHandler::HandleFetchWallpaperCollections(
+ const base::ListValue* args) {
+ CHECK_EQ(args->GetSize(), 1U);
+ DCHECK(IsJavascriptAllowed()) << "Page should already be initialized";
+ backdrop_api_weak_factory_.InvalidateWeakPtrs();
+ collection_info_fetcher_.Start(
+ base::BindOnce(&WallpaperHandler::OnFetchWallpaperCollections,
+ backdrop_api_weak_factory_.GetWeakPtr(),
+ args->GetList().front().Clone()));
+}
+
+void WallpaperHandler::OnFetchWallpaperCollections(
+ const base::Value& callback_id,
+ bool success,
+ const std::vector<backdrop::Collection>& collections) {
+ if (!success || collections.empty()) {
+ RejectJavascriptCallback(callback_id, base::Value(base::Value::Type::NONE));
+ return;
+ }
+
+ base::Value result(base::Value::Type::LIST);
+ for (const auto& collection : collections) {
+ base::Value item(base::Value::Type::DICTIONARY);
+ item.SetKey("id", base::Value(collection.collection_id()));
+ item.SetKey("name", base::Value(collection.collection_name()));
+ result.Append(std::move(item));
+ }
+ ResolveJavascriptCallback(callback_id, result);
+}
+
void WallpaperHandler::ResolveCallback(const base::Value& callback_id,
bool result) {
AllowJavascript();
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h
index 90fa8c6c218..645671d06a1 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/wallpaper_handler.h
@@ -6,11 +6,17 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_WALLPAPER_HANDLER_H_
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/backdrop_wallpaper_handlers/backdrop_wallpaper_handlers.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+namespace backdrop {
+class Collection;
+} // namespace backdrop
+
namespace base {
class ListValue;
-}
+} // namespace base
namespace chromeos {
namespace settings {
@@ -36,9 +42,21 @@ class WallpaperHandler : public ::settings::SettingsPageUIHandler {
// Open the wallpaper manager app.
void HandleOpenWallpaperManager(const base::ListValue* args);
+ // Begin to fetch wallpaper collection info.
+ void HandleFetchWallpaperCollections(const base::ListValue* args);
+
+ void OnFetchWallpaperCollections(
+ const base::Value& callback_id,
+ bool success,
+ const std::vector<backdrop::Collection>& collections);
+
// Helper function to resolve the Javascript callback.
void ResolveCallback(const base::Value& callback_id, bool result);
+ backdrop_wallpaper_handlers::CollectionInfoFetcher collection_info_fetcher_;
+
+ base::WeakPtrFactory<WallpaperHandler> backdrop_api_weak_factory_{this};
+
DISALLOW_COPY_AND_ASSIGN(WallpaperHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc b/chromium/chrome/browser/ui/webui/settings/custom_home_pages_table_model.cc
index 63dc7c8b187..b4b0df20082 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
@@ -10,6 +10,7 @@
#include "base/callback_helpers.h"
#include "base/i18n/rtl.h"
#include "base/strings/utf_string_conversions.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@@ -25,7 +26,7 @@
#include "ui/gfx/codec/png_codec.h"
#include "url/gurl.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/settings_window_manager_chromeos.h"
#endif
@@ -210,7 +211,7 @@ bool CustomHomePagesTableModel::ShouldIncludeBrowser(Browser* browser) {
// Do not include incognito browsers.
if (browser->profile() != profile_)
return false;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Do not include the Settings window.
if (chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser(
browser)) {
diff --git a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
index 782935e766d..1354f21e3d7 100644
--- a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/metrics/user_metrics.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
@@ -19,7 +20,7 @@
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/file_manager/path_util.h"
#endif
@@ -49,7 +50,7 @@ void DownloadsHandler::RegisterMessages() {
"selectDownloadLocation",
base::BindRepeating(&DownloadsHandler::HandleSelectDownloadLocation,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
"getDownloadLocationText",
base::BindRepeating(&DownloadsHandler::HandleGetDownloadLocationText,
@@ -61,8 +62,8 @@ void DownloadsHandler::OnJavascriptAllowed() {
pref_registrar_.Init(profile_->GetPrefs());
pref_registrar_.Add(
prefs::kDownloadExtensionsToOpen,
- base::Bind(&DownloadsHandler::SendAutoOpenDownloadsToJavascript,
- base::Unretained(this)));
+ base::BindRepeating(&DownloadsHandler::SendAutoOpenDownloadsToJavascript,
+ base::Unretained(this)));
}
void DownloadsHandler::OnJavascriptDisallowed() {
@@ -116,7 +117,7 @@ void DownloadsHandler::FileSelected(const base::FilePath& path,
pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void DownloadsHandler::HandleGetDownloadLocationText(
const base::ListValue* args) {
AllowJavascript();
diff --git a/chromium/chrome/browser/ui/webui/settings/downloads_handler.h b/chromium/chrome/browser/ui/webui/settings/downloads_handler.h
index 503455691e0..fe06fab17be 100644
--- a/chromium/chrome/browser/ui/webui/settings/downloads_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/downloads_handler.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/macros.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/prefs/pref_change_registrar.h"
#include "ui/shell_dialogs/select_file_dialog.h"
@@ -51,7 +52,7 @@ class DownloadsHandler : public SettingsPageUIHandler,
int index,
void* params) override;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Callback for the "getDownloadLocationText" message. Converts actual
// paths in chromeos to values suitable to display to users.
// E.g. /home/chronos/u-<hash>/Downloads => "Downloads".
diff --git a/chromium/chrome/browser/ui/webui/settings/font_handler.cc b/chromium/chrome/browser/ui/webui/settings/font_handler.cc
index 22ff301808f..26ae033e95f 100644
--- a/chromium/chrome/browser/ui/webui/settings/font_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/font_handler.cc
@@ -21,7 +21,7 @@
#include "content/public/browser/web_ui.h"
#if defined(OS_MAC)
-#include "chrome/browser/ui/webui/settings_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.h"
#endif
namespace settings {
diff --git a/chromium/chrome/browser/ui/webui/settings/font_handler.h b/chromium/chrome/browser/ui/webui/settings/font_handler.h
index 18892313860..96669a5ce95 100644
--- a/chromium/chrome/browser/ui/webui/settings/font_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/font_handler.h
@@ -10,7 +10,6 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile;
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 aa57ad77c53..5eca85a0c62 100644
--- a/chromium/chrome/browser/ui/webui/settings/import_data_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/import_data_handler.cc
@@ -40,8 +40,7 @@ const char kImportStatusSucceeded[] = "succeeded";
const char kImportStatusFailed[] = "failed";
} // namespace
-ImportDataHandler::ImportDataHandler()
- : importer_host_(nullptr), import_did_succeed_(false) {
+ImportDataHandler::ImportDataHandler() : importer_host_(nullptr) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
@@ -115,6 +114,12 @@ void ImportDataHandler::HandleImportData(const base::ListValue* args) {
const base::DictionaryValue* types = nullptr;
CHECK(args->GetDictionary(1, &types));
+ if (!importer_list_loaded_ || browser_index < 0 ||
+ browser_index >= static_cast<int>(importer_list_->count())) {
+ // Prevent out-of-bounds access.
+ return;
+ }
+
uint16_t selected_items = importer::NONE;
if (*types->FindBoolKey(prefs::kImportDialogAutofillFormData))
selected_items |= importer::AUTOFILL_FORM_DATA;
@@ -152,8 +157,8 @@ void ImportDataHandler::HandleInitializeImportDialog(
importer_list_->DetectSourceProfiles(
g_browser_process->GetApplicationLocale(),
true, // include_interactive_profiles
- base::Bind(&ImportDataHandler::SendBrowserProfileData,
- base::Unretained(this), callback_id));
+ base::BindOnce(&ImportDataHandler::SendBrowserProfileData,
+ base::Unretained(this), callback_id));
}
void ImportDataHandler::HandleImportFromBookmarksFile(
@@ -180,6 +185,7 @@ void ImportDataHandler::HandleImportFromBookmarksFile(
void ImportDataHandler::SendBrowserProfileData(const std::string& callback_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ importer_list_loaded_ = true;
base::ListValue browser_profiles;
for (size_t i = 0; i < importer_list_->count(); ++i) {
diff --git a/chromium/chrome/browser/ui/webui/settings/import_data_handler.h b/chromium/chrome/browser/ui/webui/settings/import_data_handler.h
index 6ee9d1a99a8..173e710d6e8 100644
--- a/chromium/chrome/browser/ui/webui/settings/import_data_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/import_data_handler.h
@@ -69,7 +69,8 @@ class ImportDataHandler : public SettingsPageUIHandler,
// of deleting itself when import is complete.
ExternalProcessImporterHost* importer_host_; // weak
- bool import_did_succeed_;
+ bool import_did_succeed_{false};
+ bool importer_list_loaded_{false};
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
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 402e761e565..46b3d283ad4 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
@@ -102,9 +102,9 @@ void IncompatibleApplicationsHandler::HandleRequestIncompatibleApplicationsList(
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("name", base::Value(application.info.name));
dict.SetKey("type",
- base::Value(application.blacklist_action->message_type()));
+ base::Value(application.blocklist_action->message_type()));
dict.SetKey("url",
- base::Value(application.blacklist_action->message_url()));
+ base::Value(application.blocklist_action->message_url()));
application_list.Append(std::move(dict));
}
diff --git a/chromium/chrome/browser/ui/webui/settings/languages_handler.cc b/chromium/chrome/browser/ui/webui/settings/languages_handler.cc
index aeb49ddd718..f28bfd2e3b4 100644
--- a/chromium/chrome/browser/ui/webui/settings/languages_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/languages_handler.cc
@@ -7,15 +7,16 @@
#include "base/bind.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/pref_names.h"
#include "components/language/core/browser/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/chromeos/base/locale_util.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
@@ -23,7 +24,7 @@
namespace settings {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
LanguagesHandler::LanguagesHandler(Profile* profile) : profile_(profile) {}
#else
LanguagesHandler::LanguagesHandler() = default;
@@ -50,10 +51,10 @@ void LanguagesHandler::HandleGetProspectiveUILanguage(
AllowJavascript();
std::string locale;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// On Chrome OS, an individual profile may have a preferred locale.
locale = profile_->GetPrefs()->GetString(language::prefs::kApplicationLocale);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
if (locale.empty()) {
locale = g_browser_process->local_state()->GetString(
@@ -74,7 +75,7 @@ void LanguagesHandler::HandleSetProspectiveUILanguage(
#if defined(OS_WIN)
PrefService* prefs = g_browser_process->local_state();
prefs->SetString(language::prefs::kApplicationLocale, language_code);
-#elif defined(OS_CHROMEOS)
+#elif BUILDFLAG(IS_CHROMEOS_ASH)
// Secondary users and public session users cannot change the locale.
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
const user_manager::User* user =
diff --git a/chromium/chrome/browser/ui/webui/settings/languages_handler.h b/chromium/chrome/browser/ui/webui/settings/languages_handler.h
index b150e0e58ba..0e17ea9219d 100644
--- a/chromium/chrome/browser/ui/webui/settings/languages_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/languages_handler.h
@@ -6,9 +6,10 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_LANGUAGES_HANDLER_H_
#include "base/macros.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
class Profile;
#endif
@@ -21,7 +22,7 @@ namespace settings {
// Chrome "Languages" settings page UI handler.
class LanguagesHandler : public SettingsPageUIHandler {
public:
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
explicit LanguagesHandler(Profile* profile);
#else
LanguagesHandler();
@@ -43,7 +44,7 @@ class LanguagesHandler : public SettingsPageUIHandler {
// The actual UI language will not change until the next restart.
void HandleSetProspectiveUILanguage(const base::ListValue* args);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
Profile* profile_; // Weak pointer.
#endif
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 c84c5786111..6aebbaeefd4 100644
--- a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.cc
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
+#include "build/chromeos_buildflags.h"
+
+#if defined(GOOGLE_CHROME_BUILD) && !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/webui/settings/metrics_reporting_handler.h"
@@ -17,6 +19,11 @@
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+#include "chromeos/crosapi/mojom/metrics_reporting.mojom.h" // nogncheck
+#include "chromeos/lacros/lacros_chrome_service_impl.h"
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
+
namespace settings {
MetricsReportingHandler::MetricsReportingHandler() {}
@@ -36,17 +43,19 @@ void MetricsReportingHandler::RegisterMessages() {
void MetricsReportingHandler::OnJavascriptAllowed() {
pref_member_ = std::make_unique<BooleanPrefMember>();
- pref_member_->Init(metrics::prefs::kMetricsReportingEnabled,
- g_browser_process->local_state(),
- base::Bind(&MetricsReportingHandler::OnPrefChanged,
- base::Unretained(this)));
+ pref_member_->Init(
+ metrics::prefs::kMetricsReportingEnabled,
+ g_browser_process->local_state(),
+ base::BindRepeating(&MetricsReportingHandler::OnPrefChanged,
+ base::Unretained(this)));
policy_registrar_ = std::make_unique<policy::PolicyChangeRegistrar>(
g_browser_process->policy_service(),
policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
- policy_registrar_->Observe(policy::key::kMetricsReportingEnabled,
- base::Bind(&MetricsReportingHandler::OnPolicyChanged,
- base::Unretained(this)));
+ policy_registrar_->Observe(
+ policy::key::kMetricsReportingEnabled,
+ base::BindRepeating(&MetricsReportingHandler::OnPolicyChanged,
+ base::Unretained(this)));
}
void MetricsReportingHandler::OnJavascriptDisallowed() {
@@ -69,7 +78,18 @@ std::unique_ptr<base::DictionaryValue>
dict->SetBoolean(
"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
+ auto* lacros_chrome_service = chromeos::LacrosChromeServiceImpl::Get();
+ // Service may be null in tests.
+ bool managed = lacros_chrome_service &&
+ lacros_chrome_service->init_params()->ash_metrics_managed ==
+ crosapi::mojom::MetricsReportingManaged::kManaged;
+ dict->SetBoolean("managed", managed);
+#else
dict->SetBoolean("managed", IsMetricsReportingPolicyManaged());
+#endif
return dict;
}
@@ -88,6 +108,30 @@ void MetricsReportingHandler::HandleSetMetricsReportingEnabled(
bool enabled;
CHECK(args->GetBoolean(0, &enabled));
ChangeMetricsReportingState(enabled);
+
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ // To match the pre-Lacros settings UX, the metrics reporting toggle in Lacros
+ // browser settings controls both browser metrics reporting and OS metrics
+ // reporting. See https://crbug.com/1148604.
+ auto* lacros_chrome_service = chromeos::LacrosChromeServiceImpl::Get();
+ // Service may be null in tests.
+ if (!lacros_chrome_service)
+ return;
+ // The metrics reporting API was added in Chrome OS 89.
+ if (!lacros_chrome_service->IsMetricsReportingAvailable()) {
+ LOG(WARNING) << "MetricsReporting API not available";
+ return;
+ }
+ // Bind the remote here instead of the constructor because this function
+ // is rarely called, so we usually don't need the remote.
+ if (!metrics_reporting_remote_.is_bound()) {
+ lacros_chrome_service->BindMetricsReporting(
+ metrics_reporting_remote_.BindNewPipeAndPassReceiver());
+ }
+ // Set metrics reporting state in ash-chrome.
+ metrics_reporting_remote_->SetMetricsReportingEnabled(enabled,
+ base::DoNothing());
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
}
void MetricsReportingHandler::OnPolicyChanged(const base::Value* previous,
@@ -106,4 +150,4 @@ void MetricsReportingHandler::SendMetricsReportingChange() {
} // namespace settings
-#endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
+#endif // defined(GOOGLE_CHROME_BUILD) && !BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h
index 73cc5bd9572..420eac58251 100644
--- a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler.h
@@ -5,7 +5,9 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_
-#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
+#include "build/chromeos_buildflags.h"
+
+#if defined(GOOGLE_CHROME_BUILD) && !BUILDFLAG(IS_CHROMEOS_ASH)
#include <memory>
@@ -14,6 +16,11 @@
#include "components/policy/core/common/policy_service.h"
#include "components/prefs/pref_member.h"
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+#include "chromeos/crosapi/mojom/metrics_reporting.mojom.h" // nogncheck
+#include "mojo/public/cpp/bindings/remote.h"
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
+
namespace base {
class DictionaryValue;
}
@@ -63,11 +70,16 @@ class MetricsReportingHandler : public SettingsPageUIHandler {
// enabled or managed.
std::unique_ptr<policy::PolicyChangeRegistrar> policy_registrar_;
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
+ // The metrics reporting interface in ash-chrome.
+ mojo::Remote<crosapi::mojom::MetricsReporting> metrics_reporting_remote_;
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
+
DISALLOW_COPY_AND_ASSIGN(MetricsReportingHandler);
};
} // namespace settings
-#endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
+#endif // defined(GOOGLE_CHROME_BUILD) && !BUILDFLAG(IS_CHROMEOS_ASH)
#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_METRICS_REPORTING_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler_unittest.cc
index 189c2a837cd..c587ad61a1a 100644
--- a/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/metrics_reporting_handler_unittest.cc
@@ -3,8 +3,9 @@
// found in the LICENSE file.
#include "build/branding_buildflags.h"
+#include "build/chromeos_buildflags.h"
-#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !defined(OS_CHROMEOS)
+#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/webui/settings/metrics_reporting_handler.h"
@@ -124,4 +125,4 @@ TEST_F(MetricsReportingHandlerTest, PolicyChangesNotifyPage) {
} // namespace settings
-#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) && !defined(OS_CHROMEOS)
+#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/ui/webui/settings/native_certificates_handler.cc b/chromium/chrome/browser/ui/webui/settings/native_certificates_handler.cc
index 9da3cdf2eb7..e377bd96912 100644
--- a/chromium/chrome/browser/ui/webui/settings/native_certificates_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/native_certificates_handler.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/metrics/user_metrics.h"
-#include "chrome/browser/ui/webui/settings_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.h"
#include "content/public/browser/web_ui.h"
namespace settings {
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 b00c3dbb9a5..5756ab2c6ff 100644
--- a/chromium/chrome/browser/ui/webui/settings/on_startup_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/on_startup_handler.cc
@@ -11,7 +11,7 @@
#include "base/check_op.h"
#include "chrome/browser/extensions/settings_api_helpers.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/settings_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
#include "extensions/browser/extension_system.h"
@@ -24,19 +24,18 @@ namespace settings {
const char OnStartupHandler::kOnStartupNtpExtensionEventName[] =
"update-ntp-extension";
-OnStartupHandler::OnStartupHandler(Profile* profile)
- : extension_registry_observer_(this), profile_(profile) {
+OnStartupHandler::OnStartupHandler(Profile* profile) : profile_(profile) {
DCHECK(profile);
}
OnStartupHandler::~OnStartupHandler() {}
void OnStartupHandler::OnJavascriptAllowed() {
- extension_registry_observer_.Add(
+ extension_registry_observation_.Observe(
extensions::ExtensionRegistry::Get(profile_));
}
void OnStartupHandler::OnJavascriptDisallowed() {
- extension_registry_observer_.RemoveAll();
+ extension_registry_observation_.Reset();
}
void OnStartupHandler::RegisterMessages() {
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 e5438a3a851..56edf61f9d3 100644
--- a/chromium/chrome/browser/ui/webui/settings/on_startup_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/on_startup_handler.h
@@ -8,7 +8,7 @@
#include <memory>
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.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"
@@ -59,9 +59,9 @@ class OnStartupHandler : public SettingsPageUIHandler,
const extensions::Extension* extension) override;
// Listen to extension unloaded notifications.
- ScopedObserver<extensions::ExtensionRegistry,
- extensions::ExtensionRegistryObserver>
- extension_registry_observer_;
+ base::ScopedObservation<extensions::ExtensionRegistry,
+ extensions::ExtensionRegistryObserver>
+ extension_registry_observation_{this};
Profile* profile_;
diff --git a/chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc
index 2b60755b794..d8346169635 100644
--- a/chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/on_startup_handler_unittest.cc
@@ -10,10 +10,11 @@
#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "build/build_config.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#endif
+#include "build/chromeos_buildflags.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -46,7 +47,7 @@ class OnStartupHandlerTest : public testing::Test {
void SetUp() override {
ASSERT_TRUE(profile_manager_.SetUp());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::FakeChromeUserManager* fake_user_manager =
new chromeos::FakeChromeUserManager;
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
@@ -71,7 +72,7 @@ class OnStartupHandlerTest : public testing::Test {
TestingProfileManager profile_manager_;
std::unique_ptr<TestOnStartupHandler> handler_;
Profile* profile_;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<user_manager::ScopedUserManager> user_manager_enabler_;
#endif
content::TestWebUI web_ui_;
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
index e326ae815ea..eb6cf74a3c1 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
@@ -16,6 +16,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
@@ -60,7 +61,7 @@
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/image/image.h"
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/webui/profile_helper.h"
#endif
@@ -83,8 +84,6 @@ struct SyncConfigInfo {
bool sync_everything;
syncer::UserSelectableTypeSet selected_types;
bool payments_integration_enabled;
- std::string passphrase;
- bool set_new_passphrase;
};
bool IsSyncSubpage(const GURL& current_url) {
@@ -92,9 +91,7 @@ bool IsSyncSubpage(const GURL& current_url) {
}
SyncConfigInfo::SyncConfigInfo()
- : sync_everything(false),
- payments_integration_enabled(false),
- set_new_passphrase(false) {}
+ : sync_everything(false), payments_integration_enabled(false) {}
SyncConfigInfo::~SyncConfigInfo() {}
@@ -131,13 +128,6 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
config->selected_types.Put(type);
}
- // Passphrase settings.
- if (result->GetString("passphrase", &config->passphrase) &&
- !config->passphrase.empty() &&
- !result->GetBoolean("setNewPassphrase", &config->set_new_passphrase)) {
- DLOG(ERROR) << "GetConfiguration() not passed a set_new_passphrase value";
- return false;
- }
return true;
}
@@ -256,6 +246,10 @@ PeopleHandler::~PeopleHandler() {
if (!web_ui())
return;
+ // Remove this class as an observer to prevent calls back into this class
+ // while destroying.
+ OnJavascriptDisallowed();
+
// If unified consent is enabled and the user left the sync page by closing
// the tab, refresh, or via the back navigation, the sync setup needs to be
// closed. If this was the first time setup, sync will be cancelled.
@@ -275,8 +269,12 @@ void PeopleHandler::RegisterMessages() {
base::BindRepeating(&PeopleHandler::HandleSetDatatypes,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "SyncSetupSetEncryption",
- base::BindRepeating(&PeopleHandler::HandleSetEncryption,
+ "SyncSetupSetEncryptionPassphrase",
+ base::BindRepeating(&PeopleHandler::HandleSetEncryptionPassphrase,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "SyncSetupSetDecryptionPassphrase",
+ base::BindRepeating(&PeopleHandler::HandleSetDecryptionPassphrase,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"SyncSetupShowSetupUI",
@@ -290,7 +288,7 @@ void PeopleHandler::RegisterMessages() {
"SyncPrefsDispatch",
base::BindRepeating(&PeopleHandler::HandleSyncPrefsDispatch,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
"AttemptUserExit",
base::BindRepeating(&PeopleHandler::HandleAttemptUserExit,
@@ -332,28 +330,29 @@ void PeopleHandler::OnJavascriptAllowed() {
profile_pref_registrar_.Init(prefs);
profile_pref_registrar_.Add(
prefs::kSigninAllowed,
- base::Bind(&PeopleHandler::UpdateSyncStatus, base::Unretained(this)));
+ base::BindRepeating(&PeopleHandler::UpdateSyncStatus,
+ base::Unretained(this)));
signin::IdentityManager* identity_manager(
IdentityManagerFactory::GetInstance()->GetForProfile(profile_));
if (identity_manager)
- identity_manager_observer_.Add(identity_manager);
+ identity_manager_observation_.Observe(identity_manager);
// This is intentionally not using GetSyncService(), to go around the
// Profile::IsSyncAllowed() check.
syncer::SyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile_);
if (sync_service)
- sync_service_observer_.Add(sync_service);
+ sync_service_observation_.Observe(sync_service);
}
void PeopleHandler::OnJavascriptDisallowed() {
profile_pref_registrar_.RemoveAll();
- identity_manager_observer_.RemoveAll();
- sync_service_observer_.RemoveAll();
+ identity_manager_observation_.Reset();
+ sync_service_observation_.Reset();
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void PeopleHandler::DisplayGaiaLogin(signin_metrics::AccessPoint access_point) {
// Advanced options are no longer being configured if the login screen is
// visible. If the user exits the signin wizard after this without
@@ -373,12 +372,11 @@ void PeopleHandler::DisplayGaiaLoginInNewTabOrWindow(
IdentityManagerFactory::GetForProfile(browser->profile());
syncer::SyncService* service = GetSyncService();
- if (service && service->HasUnrecoverableError()) {
+ if (service && service->HasUnrecoverableError() &&
+ identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync)) {
// When the user has an unrecoverable error, they first have to sign out and
// then sign in again.
-
- identity_manager->GetPrimaryAccountMutator()->ClearPrimaryAccount(
- signin::PrimaryAccountMutator::ClearAccountsAction::kDefault,
+ identity_manager->GetPrimaryAccountMutator()->RevokeSyncConsent(
signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS,
signin_metrics::SignoutDelete::IGNORE_METRIC);
}
@@ -386,7 +384,7 @@ void PeopleHandler::DisplayGaiaLoginInNewTabOrWindow(
// If the identity manager already has a primary account, this is a
// re-auth scenario, and we need to ensure that the user signs in with the
// same email address.
- if (identity_manager->HasPrimaryAccount()) {
+ if (identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync)) {
UMA_HISTOGRAM_ENUMERATION("Signin.Reauth",
signin_metrics::HISTOGRAM_REAUTH_SHOWN,
signin_metrics::HISTOGRAM_REAUTH_MAX);
@@ -526,79 +524,72 @@ void PeopleHandler::HandleStartSyncingWithEmail(const base::ListValue* args) {
#endif
}
-void PeopleHandler::HandleSetEncryption(const base::ListValue* args) {
- SyncConfigInfo configuration;
- const base::Value* callback_id = nullptr;
- ParseConfigurationArguments(args, &configuration, &callback_id);
-
- // Start configuring the SyncService using the configuration passed to us from
- // the JS layer.
- syncer::SyncService* service = GetSyncService();
+void PeopleHandler::HandleSetEncryptionPassphrase(const base::ListValue* args) {
+ const base::Value& callback_id = args->GetList()[0];
- // If the sync engine has shutdown for some reason, just close the sync
- // dialog.
- if (!service || !service->IsEngineInitialized()) {
+ // Check the SyncService is up and running before retrieving SyncUserSettings,
+ // which contains the encryption-related APIs.
+ if (!GetSyncService() || !GetSyncService()->IsEngineInitialized()) {
+ // TODO(crbug.com/1139060): HandleSetDatatypes() also returns a success
+ // status in this case. Consider returning a failure in both methods. Maybe
+ // the CloseSyncSetup() call can also be removed.
CloseSyncSetup();
- ResolveJavascriptCallback(*callback_id, base::Value(kDonePageStatus));
+ ResolveJavascriptCallback(callback_id, base::Value(true));
return;
}
-
- if (service->GetUserSettings()->IsEncryptEverythingAllowed()) {
- ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_ENCRYPT);
+ syncer::SyncUserSettings* sync_user_settings =
+ GetSyncService()->GetUserSettings();
+
+ const std::string& passphrase = args->GetList()[1].GetString();
+ bool successfully_set = false;
+ if (passphrase.empty()) {
+ successfully_set = false;
+ } else if (!sync_user_settings->IsEncryptEverythingAllowed()) {
+ successfully_set = false;
+ } else if (sync_user_settings->IsUsingSecondaryPassphrase()) {
+ // In case a passphrase is already being used, changing to a new one isn't
+ // currently supported (one must reset all the Sync data).
+ successfully_set = false;
+ } else if (sync_user_settings->IsPassphraseRequired() ||
+ sync_user_settings->IsTrustedVaultKeyRequired()) {
+ // Can't re-encrypt the data with |passphrase| if some of it hasn't even
+ // been decrypted yet due to a pending passphrase / trusted vault key.
+ successfully_set = false;
} else {
- // Don't allow "encrypt all" if the SyncService doesn't allow it.
- // The UI is hidden, but the user may have enabled it e.g. by fiddling with
- // the web inspector.
- configuration.set_new_passphrase = false;
+ sync_user_settings->SetEncryptionPassphrase(passphrase);
+ successfully_set = true;
+ ProfileMetrics::LogProfileSyncInfo(
+ ProfileMetrics::SYNC_CREATED_NEW_PASSPHRASE);
}
+ ResolveJavascriptCallback(callback_id, base::Value(successfully_set));
+}
- bool passphrase_failed = false;
- if (!configuration.passphrase.empty()) {
- // We call IsPassphraseRequired() here (instead of
- // IsPassphraseRequiredForPreferredDataTypes()) because the user may try to
- // enter a passphrase even though no encrypted data types are enabled.
- if (service->GetUserSettings()->IsPassphraseRequired()) {
- // If we have pending keys, try to decrypt them with the provided
- // passphrase. We track if this succeeds or fails because a failed
- // decryption should result in an error even if there aren't any encrypted
- // data types.
- passphrase_failed = !service->GetUserSettings()->SetDecryptionPassphrase(
- configuration.passphrase);
- } else if (service->GetUserSettings()->IsTrustedVaultKeyRequired()) {
- // There are pending keys due to trusted vault keys being required, likely
- // because something changed since the UI was displayed. A passphrase
- // cannot be set in such circumstances.
- passphrase_failed = true;
- } else {
- // OK, the user sent us a passphrase, but we don't have pending keys. So
- // it either means that the pending keys were resolved somehow since the
- // time the UI was displayed (re-encryption, pending passphrase change,
- // etc) or the user wants to re-encrypt.
- if (configuration.set_new_passphrase &&
- !service->GetUserSettings()->IsUsingSecondaryPassphrase()) {
- service->GetUserSettings()->SetEncryptionPassphrase(
- configuration.passphrase);
- }
- }
- }
+void PeopleHandler::HandleSetDecryptionPassphrase(const base::ListValue* args) {
+ const base::Value& callback_id = args->GetList()[0];
- if (passphrase_failed ||
- service->GetUserSettings()->IsPassphraseRequiredForPreferredDataTypes()) {
- // If the user doesn't enter any passphrase, we won't call
- // SetDecryptionPassphrase() (passphrase_failed == false), but we still
- // want to display an error message to let the user know that their blank
- // passphrase entry is not acceptable.
-
- // TODO(tommycli): Switch this to RejectJavascriptCallback once the
- // Sync page JavaScript has been further refactored.
- ResolveJavascriptCallback(*callback_id,
- base::Value(kPassphraseFailedPageStatus));
- } else {
- ResolveJavascriptCallback(*callback_id, base::Value(kConfigurePageStatus));
+ // Check the SyncService is up and running before retrieving SyncUserSettings,
+ // which contains the encryption-related APIs.
+ if (!GetSyncService() || !GetSyncService()->IsEngineInitialized()) {
+ // TODO(crbug.com/1139060): HandleSetDatatypes() also returns a success
+ // status in this case. Consider returning a failure in both methods. Maybe
+ // the CloseSyncSetup() call can also be removed.
+ CloseSyncSetup();
+ ResolveJavascriptCallback(callback_id, base::Value(true));
+ return;
}
-
- if (!configuration.set_new_passphrase && !configuration.passphrase.empty())
- ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_PASSPHRASE);
+ syncer::SyncUserSettings* sync_user_settings =
+ GetSyncService()->GetUserSettings();
+
+ const std::string& passphrase = args->GetList()[1].GetString();
+ bool successfully_set = false;
+ if (!passphrase.empty() && sync_user_settings->IsPassphraseRequired()) {
+ successfully_set = sync_user_settings->SetDecryptionPassphrase(passphrase);
+ if (successfully_set) {
+ ProfileMetrics::LogProfileSyncInfo(
+ ProfileMetrics::SYNC_ENTERED_EXISTING_PASSPHRASE);
+ }
+ }
+ ResolveJavascriptCallback(callback_id, base::Value(successfully_set));
}
void PeopleHandler::HandleShowSyncSetupUI(const base::ListValue* args) {
@@ -630,7 +621,7 @@ void PeopleHandler::HandleShowSyncSetupUI(const base::ListValue* args) {
web_ui()->GetWebContents()->Focus();
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// On ChromeOS, we need to sign out the user session to fix an auth error, so
// the user goes through the real signin flow to generate a new auth token.
void PeopleHandler::HandleAttemptUserExit(const base::ListValue* args) {
@@ -648,11 +639,13 @@ void PeopleHandler::HandleTurnOffSync(const base::ListValue* args) {
DCHECK(identity_manager->HasPrimaryAccount(ConsentLevel::kSync));
DCHECK(signin_util::IsUserSignoutAllowedForProfile(profile_));
- identity_manager->GetPrimaryAccountMutator()->RevokeSyncConsent();
+ identity_manager->GetPrimaryAccountMutator()->RevokeSyncConsent(
+ signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS,
+ signin_metrics::SignoutDelete::IGNORE_METRIC);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void PeopleHandler::HandleStartSignin(const base::ListValue* args) {
AllowJavascript();
@@ -668,42 +661,46 @@ void PeopleHandler::HandleStartSignin(const base::ListValue* args) {
void PeopleHandler::HandleSignout(const base::ListValue* args) {
bool delete_profile = false;
args->GetBoolean(0, &delete_profile);
+ base::FilePath profile_path = profile_->GetPath();
if (!signin_util::IsUserSignoutAllowedForProfile(profile_)) {
// If the user cannot signout, the profile must be destroyed.
DCHECK(delete_profile);
} else {
- auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_);
- if (identity_manager->HasPrimaryAccount()) {
+ Browser* browser =
+ chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
+ if (browser) {
+ browser->signin_view_controller()->ShowGaiaLogoutTab(
+ signin_metrics::SourceForRefreshTokenOperation::kSettings_Signout);
+ }
+ auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_);
+ if (identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync)) {
signin_metrics::SignoutDelete delete_metric =
delete_profile ? signin_metrics::SignoutDelete::DELETED
: signin_metrics::SignoutDelete::KEEPING;
- // Use ClearAccountsAction::kDefault: if the primary account is still
- // valid, it will be removed by the Gaia logout tab
- // (see http://crbug.com/1068978). If the account is already invalid, drop
- // the token now (because it's already invalid on the web, so the Gaia
- // logout tab won't affect it, see http://crbug.com/1114646).
- identity_manager->GetPrimaryAccountMutator()->ClearPrimaryAccount(
- signin::PrimaryAccountMutator::ClearAccountsAction::kDefault,
+ // Only revoke the sync consent.
+ // * If the primary account is still valid, then it will be removed by
+ // the Gaia logout tab (see http://crbug.com/1068978).
+ // * If the account is already invalid, drop the token now because it's
+ // already invalid on the web, so the Gaia logout tab won't affect it
+ // (see http://crbug.com/1114646).
+ //
+ // This operation may delete the current browser that owns |this| if force
+ // signin is enabled (see https://crbug.com/1153120).
+ identity_manager->GetPrimaryAccountMutator()->RevokeSyncConsent(
signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS, delete_metric);
} else {
DCHECK(!delete_profile)
<< "Deleting the profile should only be offered the user is syncing.";
}
-
- Browser* browser =
- chrome::FindBrowserWithWebContents(web_ui()->GetWebContents());
- if (!browser)
- return;
-
- browser->signin_view_controller()->ShowGaiaLogoutTab(
- signin_metrics::SourceForRefreshTokenOperation::kSettings_Signout);
}
+ // CAUTION: |this| may be deleted at this point.
+
if (delete_profile) {
- webui::DeleteProfileAtPath(profile_->GetPath(),
+ webui::DeleteProfileAtPath(profile_path,
ProfileMetrics::DELETE_PROFILE_SETTINGS);
}
}
@@ -711,7 +708,7 @@ void PeopleHandler::HandleSignout(const base::ListValue* args) {
void PeopleHandler::HandlePauseSync(const base::ListValue* args) {
DCHECK(AccountConsistencyModeManager::IsDiceEnabledForProfile(profile_));
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_);
- DCHECK(identity_manager->HasPrimaryAccount());
+ DCHECK(identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync));
identity_manager->GetAccountsMutator()
->InvalidateRefreshTokenForPrimaryAccount(
@@ -771,15 +768,13 @@ void PeopleHandler::CloseSyncSetup() {
if (sync_service) {
DVLOG(1) << "Sync setup aborted by user action";
sync_service->StopAndClear();
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// Sign out the user on desktop Chrome if they click cancel during
// initial setup.
if (!sync_service->GetUserSettings()->IsFirstSetupComplete()) {
IdentityManagerFactory::GetForProfile(profile_)
->GetPrimaryAccountMutator()
- ->ClearPrimaryAccount(
- signin::PrimaryAccountMutator::ClearAccountsAction::
- kDefault,
+ ->RevokeSyncConsent(
signin_metrics::ABORT_SIGNIN,
signin_metrics::SignoutDelete::IGNORE_METRIC);
}
@@ -826,22 +821,26 @@ void PeopleHandler::FocusUI() {
web_contents->GetDelegate()->ActivateContents(web_contents);
}
-void PeopleHandler::OnPrimaryAccountSet(
- const CoreAccountInfo& primary_account_info) {
- // After a primary account was set, the Sync setup will start soon. Grab a
- // SetupInProgressHandle right now to avoid a temporary "missing Sync
- // confirmation" error in the avatar menu. See crbug.com/928696.
- syncer::SyncService* service = GetSyncService();
- if (service && !sync_blocker_)
- sync_blocker_ = service->GetSetupInProgressHandle();
-
- UpdateSyncStatus();
-}
-
-void PeopleHandler::OnPrimaryAccountCleared(
- const CoreAccountInfo& previous_primary_account_info) {
- sync_blocker_.reset();
- UpdateSyncStatus();
+void PeopleHandler::OnPrimaryAccountChanged(
+ const signin::PrimaryAccountChangeEvent& event) {
+ switch (event.GetEventTypeFor(signin::ConsentLevel::kSync)) {
+ case signin::PrimaryAccountChangeEvent::Type::kSet: {
+ // After a primary account was set, the Sync setup will start soon. Grab a
+ // SetupInProgressHandle right now to avoid a temporary "missing Sync
+ // confirmation" error in the avatar menu. See crbug.com/928696.
+ syncer::SyncService* service = GetSyncService();
+ if (service && !sync_blocker_)
+ sync_blocker_ = service->GetSetupInProgressHandle();
+ UpdateSyncStatus();
+ return;
+ }
+ case signin::PrimaryAccountChangeEvent::Type::kCleared:
+ sync_blocker_.reset();
+ UpdateSyncStatus();
+ return;
+ case signin::PrimaryAccountChangeEvent::Type::kNone:
+ return;
+ }
}
void PeopleHandler::OnStateChanged(syncer::SyncService* sync) {
@@ -855,7 +854,8 @@ void PeopleHandler::OnStateChanged(syncer::SyncService* sync) {
void PeopleHandler::BeforeUnloadDialogCancelled() {
// The before unload dialog is only shown during the first sync setup.
- DCHECK(IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount());
+ DCHECK(IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount(
+ signin::ConsentLevel::kSync));
syncer::SyncService* service = GetSyncService();
DCHECK(service && service->IsSetupInProgress() &&
!service->GetUserSettings()->IsFirstSetupComplete());
@@ -881,7 +881,9 @@ std::unique_ptr<base::DictionaryValue> PeopleHandler::GetSyncStatusDictionary()
// Signout is not allowed if the user has policy (crbug.com/172204).
if (!signin_util::IsUserSignoutAllowedForProfile(profile_)) {
- std::string username = identity_manager->GetPrimaryAccountInfo().email;
+ std::string username =
+ identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
+ .email;
// 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.
@@ -902,7 +904,7 @@ std::unique_ptr<base::DictionaryValue> PeopleHandler::GetSyncStatusDictionary()
"firstSetupInProgress",
service && !disallowed_by_policy && service->IsSetupInProgress() &&
!service->GetUserSettings()->IsFirstSetupComplete() &&
- identity_manager->HasPrimaryAccount());
+ identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync));
const sync_ui_util::StatusLabels status_labels =
sync_ui_util::GetStatusLabels(profile_);
@@ -923,12 +925,14 @@ std::unique_ptr<base::DictionaryValue> PeopleHandler::GetSyncStatusDictionary()
GetSyncErrorAction(status_labels.action_type));
sync_status->SetBoolean("managed", disallowed_by_policy);
- sync_status->SetBoolean(
- "disabled", !service || disallowed_by_policy ||
- !service->GetUserSettings()->IsSyncAllowedByPlatform());
+ // 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->SetBoolean("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->SetBoolean("signedIn", identity_manager->HasPrimaryAccount());
+ sync_status->SetBoolean("signedIn", identity_manager->HasPrimaryAccount(
+ signin::ConsentLevel::kSync));
sync_status->SetString("signedInUsername",
signin_ui_util::GetAuthenticatedUsername(profile_));
sync_status->SetBoolean("hasUnrecoverableError",
@@ -1042,7 +1046,7 @@ void PeopleHandler::MarkFirstSetupComplete() {
}
void PeopleHandler::MaybeMarkSyncConfiguring() {
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
if (IsProfileAuthNeededOrHasErrors())
return;
#endif
@@ -1053,8 +1057,8 @@ void PeopleHandler::MaybeMarkSyncConfiguring() {
}
bool PeopleHandler::IsProfileAuthNeededOrHasErrors() {
- return !IdentityManagerFactory::GetForProfile(profile_)
- ->HasPrimaryAccount() ||
+ return !IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount(
+ signin::ConsentLevel::kSync) ||
SigninErrorControllerFactory::GetForProfile(profile_)->HasError();
}
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.h b/chromium/chrome/browser/ui/webui/settings/people_handler.h
index a27f0a153ec..e189aec81d0 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.h
@@ -10,10 +10,11 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "build/buildflag.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "components/prefs/pref_change_registrar.h"
@@ -86,14 +87,16 @@ class PeopleHandler : public SettingsPageUIHandler,
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncEverything);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncAllManually);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, NonRegisteredType);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestPassphraseStillRequired);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, EnterCorrectExistingPassphrase);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncIndividualTypes);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
- EnterExistingFrozenImplicitPassword);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, SetNewCustomPassphrase);
+ SuccessfullyCreateCustomPassphrase);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, EnterWrongExistingPassphrase);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, EnterBlankExistingPassphrase);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TurnOnEncryptAllDisallowed);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, CannotCreateBlankPassphrase);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
+ CannotCreatePassphraseIfEncryptEverythingDisallowed);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
+ CannotOverwritePassphraseWithNewOne);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
UnrecoverableErrorInitializingSync);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, GaiaErrorInitializingSync);
@@ -123,10 +126,8 @@ class PeopleHandler : public SettingsPageUIHandler,
void FocusUI() override;
// IdentityManager::Observer implementation.
- void OnPrimaryAccountSet(
- const CoreAccountInfo& primary_account_info) override;
- void OnPrimaryAccountCleared(
- const CoreAccountInfo& previous_primary_account_info) override;
+ void OnPrimaryAccountChanged(
+ const signin::PrimaryAccountChangeEvent& event) override;
void OnExtendedAccountInfoUpdated(const AccountInfo& info) override;
void OnExtendedAccountInfoRemoved(const AccountInfo& info) override;
@@ -151,15 +152,16 @@ class PeopleHandler : public SettingsPageUIHandler,
void HandleGetProfileInfo(const base::ListValue* args);
void OnDidClosePage(const base::ListValue* args);
void HandleSetDatatypes(const base::ListValue* args);
- void HandleSetEncryption(const base::ListValue* args);
+ void HandleSetEncryptionPassphrase(const base::ListValue* args);
+ void HandleSetDecryptionPassphrase(const base::ListValue* args);
void HandleShowSyncSetupUI(const base::ListValue* args);
void HandleSyncPrefsDispatch(const base::ListValue* args);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void HandleAttemptUserExit(const base::ListValue* args);
void HandleTurnOnSync(const base::ListValue* args);
void HandleTurnOffSync(const base::ListValue* args);
#endif
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void HandleStartSignin(const base::ListValue* args);
void HandleSignout(const base::ListValue* args);
void HandlePauseSync(const base::ListValue* args);
@@ -167,7 +169,7 @@ class PeopleHandler : public SettingsPageUIHandler,
void HandleStartKeyRetrieval(const base::ListValue* args);
void HandleGetSyncStatus(const base::ListValue* args);
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// Displays the GAIA login form.
void DisplayGaiaLogin(signin_metrics::AccessPoint access_point);
@@ -224,10 +226,11 @@ class PeopleHandler : public SettingsPageUIHandler,
PrefChangeRegistrar profile_pref_registrar_;
// Manages observer lifetimes.
- ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
- identity_manager_observer_{this};
- ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
- sync_service_observer_{this};
+ base::ScopedObservation<signin::IdentityManager,
+ signin::IdentityManager::Observer>
+ identity_manager_observation_{this};
+ base::ScopedObservation<syncer::SyncService, syncer::SyncServiceObserver>
+ sync_service_observation_{this};
base::WeakPtrFactory<PeopleHandler> weak_factory_{this};
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 81d64caa1b9..10dcebabbce 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
@@ -17,6 +17,7 @@
#include "base/test/mock_callback.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
@@ -77,26 +78,12 @@ enum SyncAllDataConfig {
CHOOSE_WHAT_TO_SYNC
};
-enum EncryptAllConfig {
- ENCRYPT_ALL_DATA,
- ENCRYPT_PASSWORDS
-};
-
// Create a json-format string with the key/value pairs appropriate for a call
-// to HandleSetEncryption(). If |extra_values| is non-null, then the values from
-// the passed dictionary are added to the json.
-std::string GetConfiguration(const base::DictionaryValue* extra_values,
- SyncAllDataConfig sync_all,
- syncer::UserSelectableTypeSet types,
- const std::string& passphrase,
- EncryptAllConfig encrypt_all) {
+// to HandleSetDatatypes().
+std::string GetConfiguration(SyncAllDataConfig sync_all,
+ syncer::UserSelectableTypeSet types) {
base::DictionaryValue result;
- if (extra_values)
- result.MergeDictionary(extra_values);
result.SetBoolean("syncAllDataTypes", sync_all == SYNC_ALL_DATA);
- result.SetBoolean("encryptAllData", encrypt_all == ENCRYPT_ALL_DATA);
- if (!passphrase.empty())
- result.SetString("passphrase", passphrase);
// Add all of our data types.
result.SetBoolean("appsSynced", types.Has(syncer::UserSelectableType::kApps));
result.SetBoolean("autofillSynced",
@@ -204,7 +191,7 @@ class TestingPeopleHandler : public PeopleHandler {
using PeopleHandler::is_configuring_sync;
private:
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void DisplayGaiaLoginInNewTabOrWindow(
signin_metrics::AccessPoint access_point) override {}
#endif
@@ -313,6 +300,21 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
EXPECT_EQ(expected_status, status);
}
+ // Expects a call to ResolveJavascriptCallback() with |should_succeed| as its
+ // argument.
+ void ExpectSetPassphraseSuccess(bool should_succeed) {
+ EXPECT_EQ(1u, web_ui_.call_data().size());
+ const auto& data = *web_ui_.call_data()[0];
+ EXPECT_EQ("cr.webUIResponse", data.function_name());
+ EXPECT_TRUE(data.arg2()->is_bool());
+ EXPECT_TRUE(data.arg2()->GetBool())
+ << "Callback should be resolved with a boolean indicating the success, "
+ "never rejected.";
+
+ EXPECT_TRUE(data.arg3()->is_bool());
+ EXPECT_EQ(should_succeed, data.arg3()->GetBool());
+ }
+
const base::DictionaryValue* ExpectSyncPrefsChanged() {
const content::TestWebUI::CallData& data1 = *web_ui_.call_data().back();
EXPECT_EQ("cr.webUIListenerCallback", data1.function_name());
@@ -364,7 +366,7 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
DISALLOW_COPY_AND_ASSIGN(PeopleHandlerTest);
};
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(PeopleHandlerTest, DisplayBasicLogin) {
ASSERT_FALSE(identity_test_env()->identity_manager()->HasPrimaryAccount(
ConsentLevel::kSync));
@@ -394,7 +396,7 @@ TEST_F(PeopleHandlerTest, DisplayBasicLogin) {
LoginUIServiceFactory::GetForProfile(profile())->current_login_ui());
}
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndCancel) {
SigninUser();
@@ -605,6 +607,10 @@ TEST_F(PeopleHandlerTest, AcquireSyncBlockerWhenLoadingSyncSettingsSubpage) {
handler_->InitializeSyncBlocker();
EXPECT_TRUE(handler_->sync_blocker_);
+ content::WebUIControllerFactory::UnregisterFactoryForTesting(
+ test_factory_.get());
+ content::WebUIControllerFactory::RegisterFactory(
+ ChromeWebUIControllerFactory::GetInstance());
}
TEST_F(PeopleHandlerTest, UnrecoverableErrorInitializingSync) {
@@ -637,8 +643,7 @@ TEST_F(PeopleHandlerTest, GaiaErrorInitializingSync) {
TEST_F(PeopleHandlerTest, TestSyncEverything) {
SigninUser();
CreatePeopleHandler();
- std::string args = GetConfiguration(nullptr, SYNC_ALL_DATA, GetAllTypes(),
- std::string(), ENCRYPT_PASSWORDS);
+ std::string args = GetConfiguration(SYNC_ALL_DATA, GetAllTypes());
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
@@ -655,147 +660,119 @@ TEST_F(PeopleHandlerTest, TestSyncEverything) {
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
}
-TEST_F(PeopleHandlerTest, TestPassphraseStillRequired) {
+TEST_F(PeopleHandlerTest, EnterCorrectExistingPassphrase) {
SigninUser();
CreatePeopleHandler();
- std::string args = GetConfiguration(nullptr, SYNC_ALL_DATA, GetAllTypes(),
- std::string(), ENCRYPT_PASSWORDS);
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(args);
- ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsPassphraseRequiredForPreferredDataTypes())
- .WillByDefault(Return(true));
- ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
- .WillByDefault(Return(true));
- ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsUsingSecondaryPassphrase())
- .WillByDefault(Return(false));
SetupInitializedSyncService();
- SetDefaultExpectationsForConfigPage();
-
- handler_->HandleSetEncryption(&list_args);
- // We should navigate back to the configure page since we need a passphrase.
- ExpectPageStatusResponse(PeopleHandler::kPassphraseFailedPageStatus);
-}
-TEST_F(PeopleHandlerTest, EnterExistingFrozenImplicitPassword) {
- SigninUser();
- CreatePeopleHandler();
- base::DictionaryValue dict;
- dict.SetBoolean("setNewPassphrase", false);
- std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(),
- "oldGaiaPassphrase", ENCRYPT_PASSWORDS);
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(args);
- // Act as if an encryption passphrase is required the first time, then never
- // again after that.
- EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsPassphraseRequired())
- .WillOnce(Return(true));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
+ .WillByDefault(Return(true));
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsPassphraseRequiredForPreferredDataTypes())
+ IsTrustedVaultKeyRequired())
.WillByDefault(Return(false));
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsUsingSecondaryPassphrase())
- .WillByDefault(Return(false));
- SetupInitializedSyncService();
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
+ .WillByDefault(Return(true));
+
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
- SetDecryptionPassphrase("oldGaiaPassphrase"))
+ SetDecryptionPassphrase("correct_passphrase"))
.WillOnce(Return(true));
- handler_->HandleSetEncryption(&list_args);
- ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
+ base::ListValue list_args;
+ list_args.AppendString(kTestCallbackId);
+ list_args.AppendString("correct_passphrase");
+ handler_->HandleSetDecryptionPassphrase(&list_args);
+
+ ExpectSetPassphraseSuccess(true);
}
-TEST_F(PeopleHandlerTest, SetNewCustomPassphrase) {
+TEST_F(PeopleHandlerTest, SuccessfullyCreateCustomPassphrase) {
SigninUser();
CreatePeopleHandler();
- base::DictionaryValue dict;
- dict.SetBoolean("setNewPassphrase", true);
- std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(),
- "custom_passphrase", ENCRYPT_ALL_DATA);
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(args);
- ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsEncryptEverythingAllowed())
- .WillByDefault(Return(true));
- ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsPassphraseRequiredForPreferredDataTypes())
- .WillByDefault(Return(false));
+ SetupInitializedSyncService();
+
ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsTrustedVaultKeyRequired())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedSyncService();
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
+ .WillByDefault(Return(true));
+
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetEncryptionPassphrase("custom_passphrase"));
- handler_->HandleSetEncryption(&list_args);
- ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
+ base::ListValue list_args;
+ list_args.AppendString(kTestCallbackId);
+ list_args.AppendString("custom_passphrase");
+ handler_->HandleSetEncryptionPassphrase(&list_args);
+
+ ExpectSetPassphraseSuccess(true);
}
TEST_F(PeopleHandlerTest, EnterWrongExistingPassphrase) {
SigninUser();
CreatePeopleHandler();
- base::DictionaryValue dict;
- dict.SetBoolean("setNewPassphrase", false);
- std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(),
- "invalid_passphrase", ENCRYPT_ALL_DATA);
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(args);
- ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsPassphraseRequiredForPreferredDataTypes())
- .WillByDefault(Return(true));
+ SetupInitializedSyncService();
+
ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(true));
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsUsingSecondaryPassphrase())
+ IsTrustedVaultKeyRequired())
.WillByDefault(Return(false));
- SetupInitializedSyncService();
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
+ .WillByDefault(Return(true));
+
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetDecryptionPassphrase("invalid_passphrase"))
.WillOnce(Return(false));
- SetDefaultExpectationsForConfigPage();
+ base::ListValue list_args;
+ list_args.AppendString(kTestCallbackId);
+ list_args.AppendString("invalid_passphrase");
+ handler_->HandleSetDecryptionPassphrase(&list_args);
- handler_->HandleSetEncryption(&list_args);
- // We should navigate back to the configure page since we need a passphrase.
- ExpectPageStatusResponse(PeopleHandler::kPassphraseFailedPageStatus);
+ ExpectSetPassphraseSuccess(false);
}
-TEST_F(PeopleHandlerTest, EnterBlankExistingPassphrase) {
+TEST_F(PeopleHandlerTest, CannotCreateBlankPassphrase) {
SigninUser();
CreatePeopleHandler();
- base::DictionaryValue dict;
- dict.SetBoolean("setNewPassphrase", false);
- std::string args = GetConfiguration(&dict,
- SYNC_ALL_DATA,
- GetAllTypes(),
- "",
- ENCRYPT_PASSWORDS);
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(args);
- ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsPassphraseRequiredForPreferredDataTypes())
- .WillByDefault(Return(true));
+ SetupInitializedSyncService();
+
ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
- .WillByDefault(Return(true));
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsTrustedVaultKeyRequired())
+ .WillByDefault(Return(false));
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedSyncService();
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
+ .WillByDefault(Return(true));
- SetDefaultExpectationsForConfigPage();
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetEncryptionPassphrase)
+ .Times(0);
- handler_->HandleSetEncryption(&list_args);
- // We should navigate back to the configure page since we need a passphrase.
- ExpectPageStatusResponse(PeopleHandler::kPassphraseFailedPageStatus);
+ base::ListValue list_args;
+ list_args.AppendString(kTestCallbackId);
+ list_args.AppendString("");
+ handler_->HandleSetEncryptionPassphrase(&list_args);
+
+ ExpectSetPassphraseSuccess(false);
}
// Walks through each user selectable type, and tries to sync just that single
@@ -807,9 +784,7 @@ TEST_F(PeopleHandlerTest, TestSyncIndividualTypes) {
for (syncer::UserSelectableType type : GetAllTypes()) {
syncer::UserSelectableTypeSet type_to_set;
type_to_set.Put(type);
- std::string args =
- GetConfiguration(nullptr, CHOOSE_WHAT_TO_SYNC, type_to_set,
- std::string(), ENCRYPT_PASSWORDS);
+ std::string args = GetConfiguration(CHOOSE_WHAT_TO_SYNC, type_to_set);
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
@@ -832,9 +807,7 @@ TEST_F(PeopleHandlerTest, TestSyncAllManually) {
SigninUser();
CreatePeopleHandler();
SetDefaultExpectationsForConfigPage();
- std::string args =
- GetConfiguration(nullptr, CHOOSE_WHAT_TO_SYNC, GetAllTypes(),
- std::string(), ENCRYPT_PASSWORDS);
+ std::string args = GetConfiguration(CHOOSE_WHAT_TO_SYNC, GetAllTypes());
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
@@ -866,9 +839,7 @@ TEST_F(PeopleHandlerTest, NonRegisteredType) {
// Simulate "Sync everything" being turned off, but all individual
// toggles left on.
- std::string config =
- GetConfiguration(/*extra_values=*/nullptr, CHOOSE_WHAT_TO_SYNC,
- GetAllTypes(), std::string(), ENCRYPT_PASSWORDS);
+ std::string config = GetConfiguration(CHOOSE_WHAT_TO_SYNC, GetAllTypes());
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(config);
@@ -1077,34 +1048,62 @@ TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) {
CheckBool(dictionary, "encryptAllDataAllowed", false);
}
-TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) {
+TEST_F(PeopleHandlerTest, CannotCreatePassphraseIfEncryptEverythingDisallowed) {
SigninUser();
CreatePeopleHandler();
+ SetupInitializedSyncService();
+
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
+ .WillByDefault(Return(false));
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
- IsPassphraseRequiredForPreferredDataTypes())
+ IsTrustedVaultKeyRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedSyncService();
ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsEncryptEverythingAllowed())
.WillByDefault(Return(false));
- base::DictionaryValue dict;
- dict.SetBoolean("setNewPassphrase", true);
- std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(),
- "password", ENCRYPT_ALL_DATA);
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetEncryptionPassphrase)
+ .Times(0);
+
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
- list_args.AppendString(args);
+ list_args.AppendString("passphrase123");
+ handler_->HandleSetEncryptionPassphrase(&list_args);
+
+ ExpectSetPassphraseSuccess(false);
+}
+
+TEST_F(PeopleHandlerTest, CannotOverwritePassphraseWithNewOne) {
+ SigninUser();
+ CreatePeopleHandler();
+ SetupInitializedSyncService();
+
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsTrustedVaultKeyRequired())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
+ .WillByDefault(Return(true));
EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
- SetEncryptionPassphrase(_))
+ SetEncryptionPassphrase)
.Times(0);
- handler_->HandleSetEncryption(&list_args);
+ base::ListValue list_args;
+ list_args.AppendString(kTestCallbackId);
+ list_args.AppendString("passphrase123");
+ handler_->HandleSetEncryptionPassphrase(&list_args);
- ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
+ ExpectSetPassphraseSuccess(false);
}
TEST_F(PeopleHandlerTest, DashboardClearWhileSettingsOpen_ConfirmSoon) {
@@ -1276,7 +1275,7 @@ TEST(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) {
}
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Regression test for crash in guest mode. https://crbug.com/1040476
TEST(PeopleHandlerGuestModeTest, GetStoredAccountsList) {
content::BrowserTaskEnvironment task_environment;
@@ -1312,6 +1311,6 @@ TEST_F(PeopleHandlerTest, GetStoredAccountsList) {
ASSERT_EQ(1u, accounts_list.size());
EXPECT_EQ("user@gmail.com", accounts_list[0].FindKey("email")->GetString());
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace settings
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 922bfc02a41..8a695265d04 100644
--- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
@@ -13,8 +14,8 @@
#include "chrome/common/pref_names.h"
#include "ui/base/webui/web_ui_util.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/user_manager.h"
@@ -34,7 +35,7 @@ const char ProfileInfoHandler::kProfileStatsCountReadyEventName[] =
"profile-stats-count-ready";
ProfileInfoHandler::ProfileInfoHandler(Profile* profile) : profile_(profile) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Set up the chrome://userimage/ source.
content::URLDataSource::Add(profile,
std::make_unique<chromeos::UserImageSource>());
@@ -48,7 +49,7 @@ void ProfileInfoHandler::RegisterMessages() {
"getProfileInfo",
base::BindRepeating(&ProfileInfoHandler::HandleGetProfileInfo,
base::Unretained(this)));
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
"getProfileStatsCount",
base::BindRepeating(&ProfileInfoHandler::HandleGetProfileStats,
@@ -57,26 +58,29 @@ void ProfileInfoHandler::RegisterMessages() {
}
void ProfileInfoHandler::OnJavascriptAllowed() {
- profile_observer_.Add(
+ profile_observation_.Observe(
&g_browser_process->profile_manager()->GetProfileAttributesStorage());
-#if defined(OS_CHROMEOS)
- user_manager_observer_.Add(user_manager::UserManager::Get());
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ user_manager_observation_.Observe(user_manager::UserManager::Get());
#endif
}
void ProfileInfoHandler::OnJavascriptDisallowed() {
callback_weak_ptr_factory_.InvalidateWeakPtrs();
- profile_observer_.Remove(
- &g_browser_process->profile_manager()->GetProfileAttributesStorage());
+ DCHECK(profile_observation_.IsObservingSource(
+ &g_browser_process->profile_manager()->GetProfileAttributesStorage()));
+ profile_observation_.Reset();
-#if defined(OS_CHROMEOS)
- user_manager_observer_.Remove(user_manager::UserManager::Get());
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ DCHECK(user_manager_observation_.IsObservingSource(
+ user_manager::UserManager::Get()));
+ user_manager_observation_.Reset();
#endif
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void ProfileInfoHandler::OnUserImageChanged(const user_manager::User& user) {
PushProfileInfo();
}
@@ -103,13 +107,13 @@ void ProfileInfoHandler::HandleGetProfileInfo(const base::ListValue* args) {
ResolveJavascriptCallback(*callback_id, *GetAccountNameAndIcon());
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void ProfileInfoHandler::HandleGetProfileStats(const base::ListValue* args) {
AllowJavascript();
ProfileStatisticsFactory::GetForProfile(profile_)->GatherStatistics(
- base::Bind(&ProfileInfoHandler::PushProfileStatsCount,
- callback_weak_ptr_factory_.GetWeakPtr()));
+ base::BindRepeating(&ProfileInfoHandler::PushProfileStatsCount,
+ callback_weak_ptr_factory_.GetWeakPtr()));
}
void ProfileInfoHandler::PushProfileStatsCount(
@@ -134,7 +138,7 @@ ProfileInfoHandler::GetAccountNameAndIcon() const {
std::string name;
std::string icon_url;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
const user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile_);
DCHECK(user);
@@ -145,11 +149,12 @@ ProfileInfoHandler::GetAccountNameAndIcon() const {
scoped_refptr<base::RefCountedMemory> image =
chromeos::UserImageSource::GetUserImage(user->GetAccountId());
icon_url = webui::GetPngDataUrl(image->front(), image->size());
-#else // !defined(OS_CHROMEOS)
- ProfileAttributesEntry* entry;
- if (g_browser_process->profile_manager()
+#else // !BUILDFLAG(IS_CHROMEOS_ASH)
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) {
+ .GetProfileAttributesWithPath(profile_->GetPath());
+ if (entry) {
name = base::UTF16ToUTF8(entry->GetLocalProfileName());
// TODO(crbug.com/710660): return chrome://theme/IDR_PROFILE_AVATAR_*
// and update theme_source.cc to get high res avatar icons. This does less
@@ -159,7 +164,7 @@ ProfileInfoHandler::GetAccountNameAndIcon() const {
entry->GetAvatarIcon(), true, kAvatarIconSize, kAvatarIconSize);
icon_url = webui::GetBitmapDataUrl(icon.AsBitmap());
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
auto response = std::make_unique<base::DictionaryValue>();
response->SetString("name", name);
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 354c27d54eb..cd5be0f13e1 100644
--- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.h
@@ -9,13 +9,14 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/prefs/pref_change_registrar.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/user_manager/user_manager.h"
#else
#include "chrome/browser/profiles/profile_statistics_common.h"
@@ -26,7 +27,7 @@ class Profile;
namespace settings {
class ProfileInfoHandler : public SettingsPageUIHandler,
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
public user_manager::UserManager::Observer,
#endif
public ProfileAttributesStorage::Observer {
@@ -42,7 +43,7 @@ class ProfileInfoHandler : public SettingsPageUIHandler,
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// user_manager::UserManager::Observer implementation.
void OnUserImageChanged(const user_manager::User& user) override;
#endif
@@ -60,7 +61,7 @@ class ProfileInfoHandler : public SettingsPageUIHandler,
void HandleGetProfileInfo(const base::ListValue* args);
void PushProfileInfo();
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void HandleGetProfileStats(const base::ListValue* args);
// Returns the sum of the counts of individual profile states. Returns 0 if
@@ -73,13 +74,15 @@ class ProfileInfoHandler : public SettingsPageUIHandler,
// Weak pointer.
Profile* profile_;
-#if defined(OS_CHROMEOS)
- ScopedObserver<user_manager::UserManager, user_manager::UserManager::Observer>
- user_manager_observer_{this};
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ base::ScopedObservation<user_manager::UserManager,
+ user_manager::UserManager::Observer>
+ user_manager_observation_{this};
#endif
- ScopedObserver<ProfileAttributesStorage, ProfileAttributesStorage::Observer>
- profile_observer_{this};
+ base::ScopedObservation<ProfileAttributesStorage,
+ ProfileAttributesStorage::Observer>
+ profile_observation_{this};
// Used to cancel callbacks when JavaScript becomes disallowed.
base::WeakPtrFactory<ProfileInfoHandler> callback_weak_ptr_factory_{this};
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 8bccab5cf80..76feb8d9130 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
@@ -8,6 +8,7 @@
#include "base/memory/ptr_util.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
@@ -22,7 +23,7 @@
#include "ui/gfx/codec/png_codec.h"
#include "url/gurl.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#endif
@@ -31,7 +32,7 @@ namespace settings {
namespace {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char fake_id[] = "fake_id";
constexpr char fake_email[] = "fake_id@gmail.com";
#endif
@@ -55,7 +56,7 @@ class ProfileInfoHandlerTest : public testing::Test {
void SetUp() override {
ASSERT_TRUE(profile_manager_.SetUp());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::FakeChromeUserManager* fake_user_manager =
new chromeos::FakeChromeUserManager;
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
@@ -79,7 +80,7 @@ class ProfileInfoHandlerTest : public testing::Test {
ASSERT_TRUE(response->GetString("name", &name));
ASSERT_TRUE(response->GetString("iconUrl", &icon_url));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
EXPECT_EQ(fake_id, name);
EXPECT_FALSE(icon_url.empty());
#else
@@ -105,7 +106,7 @@ class ProfileInfoHandlerTest : public testing::Test {
TestingProfileManager profile_manager_;
content::TestWebUI web_ui_;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<user_manager::ScopedUserManager> user_manager_enabler_;
#endif
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 5b183c710d2..b453a5ebf1f 100644
--- a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
@@ -48,11 +48,11 @@ ProtocolHandlersHandler::ProtocolHandlersHandler() = default;
ProtocolHandlersHandler::~ProtocolHandlersHandler() = default;
void ProtocolHandlersHandler::OnJavascriptAllowed() {
- registry_observer_.Add(GetProtocolHandlerRegistry());
+ registry_observation_.Observe(GetProtocolHandlerRegistry());
}
void ProtocolHandlersHandler::OnJavascriptDisallowed() {
- registry_observer_.RemoveAll();
+ registry_observation_.Reset();
}
void ProtocolHandlersHandler::RegisterMessages() {
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 0b5b5767e7c..4ab0c6d0954 100644
--- a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.h
@@ -8,7 +8,7 @@
#include <string>
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/common/custom_handlers/protocol_handler.h"
@@ -81,8 +81,9 @@ class ProtocolHandlersHandler : public SettingsPageUIHandler,
ProtocolHandlerRegistry* GetProtocolHandlerRegistry();
- ScopedObserver<ProtocolHandlerRegistry, ProtocolHandlerRegistry::Observer>
- registry_observer_{this};
+ base::ScopedObservation<ProtocolHandlerRegistry,
+ ProtocolHandlerRegistry::Observer>
+ registry_observation_{this};
DISALLOW_COPY_AND_ASSIGN(ProtocolHandlersHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/settings/recent_site_settings_helper_unittest.cc b/chromium/chrome/browser/ui/webui/settings/recent_site_settings_helper_unittest.cc
index 5819cfbfd27..c7bcb9d2147 100644
--- a/chromium/chrome/browser/ui/webui/settings/recent_site_settings_helper_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/recent_site_settings_helper_unittest.cc
@@ -23,7 +23,7 @@ ContentSetting kDefault = ContentSetting::CONTENT_SETTING_DEFAULT;
SiteSettingSource kEmbargo = site_settings::SiteSettingSource::kEmbargo;
SiteSettingSource kPreference = site_settings::SiteSettingSource::kPreference;
ContentSettingsType kNotifications = ContentSettingsType::NOTIFICATIONS;
-ContentSettingsType kPlugins = ContentSettingsType::PLUGINS;
+ContentSettingsType kImages = ContentSettingsType::IMAGES;
ContentSettingsType kPopups = ContentSettingsType::POPUPS;
ContentSettingsType kLocation = ContentSettingsType::GEOLOCATION;
@@ -73,7 +73,7 @@ TEST_F(RecentSiteSettingsHelperTest, IncognitoPermissionTimestamps) {
TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
const GURL url1("https://example.com");
const GURL url2("http://example.com");
- std::vector<ContentSettingsType> content_types = {kNotifications, kPlugins,
+ std::vector<ContentSettingsType> content_types = {kNotifications, kImages,
kPopups, kLocation};
clock()->SetNow(base::Time::Now());
@@ -98,7 +98,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
}
clock()->Advance(base::TimeDelta::FromHours(2));
- map->SetContentSettingDefaultScope(url2, url2, kPlugins, kAllowed);
+ map->SetContentSettingDefaultScope(url2, url2, kImages, kAllowed);
CreateIncognitoProfile();
recent_permissions = GetRecentSitePermissions(profile(), content_types, 10);
@@ -117,7 +117,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
EXPECT_EQ(kBlocked, url1_permissions[0].content_setting);
EXPECT_EQ(kEmbargo, url1_permissions[0].setting_source);
- EXPECT_EQ(kPlugins, url2_permissions[0].content_type);
+ EXPECT_EQ(kImages, url2_permissions[0].content_type);
EXPECT_EQ(kAllowed, url2_permissions[0].content_setting);
EXPECT_EQ(kPreference, url2_permissions[0].setting_source);
}
@@ -127,7 +127,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
HostContentSettingsMap* incognito_map =
HostContentSettingsMapFactory::GetForProfile(incognito_profile());
incognito_map->SetClockForTesting(clock());
- incognito_map->SetContentSettingDefaultScope(url1, url1, kPlugins, kAllowed);
+ incognito_map->SetContentSettingDefaultScope(url1, url1, kImages, kAllowed);
clock()->Advance(base::TimeDelta::FromHours(1));
permissions::PermissionDecisionAutoBlocker* incognito_auto_blocker =
@@ -159,7 +159,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
EXPECT_EQ(kBlocked, incognito_url1_permissions[0].content_setting);
EXPECT_EQ(kEmbargo, incognito_url1_permissions[0].setting_source);
- EXPECT_EQ(kPlugins, incognito_url1_permissions[1].content_type);
+ EXPECT_EQ(kImages, incognito_url1_permissions[1].content_type);
EXPECT_EQ(kAllowed, incognito_url1_permissions[1].content_setting);
EXPECT_EQ(kPreference, incognito_url1_permissions[1].setting_source);
}
@@ -169,7 +169,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
// most recent permission for that source.
const GURL url3("https://example.com:8443");
clock()->Advance(base::TimeDelta::FromHours(1));
- map->SetContentSettingDefaultScope(url1, url1, kPlugins, kBlocked);
+ map->SetContentSettingDefaultScope(url1, url1, kImages, kBlocked);
clock()->Advance(base::TimeDelta::FromHours(1));
for (int i = 0; i < 4; ++i) {
auto_blocker->RecordIgnoreAndEmbargo(url3, kNotifications, false);
@@ -197,7 +197,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
auto url2_permissions = recent_permissions[1].settings;
auto url3_permissions = recent_permissions[0].settings;
- EXPECT_EQ(kPlugins, url1_permissions[0].content_type);
+ EXPECT_EQ(kImages, url1_permissions[0].content_type);
EXPECT_EQ(kBlocked, url1_permissions[0].content_setting);
EXPECT_EQ(kPreference, url1_permissions[0].setting_source);
@@ -245,7 +245,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
// dismissal and confirm this is recorded as a new permission change. Also
// confirm that sources with no permission changes associated are not
// considered. I.e. url3 now has an expired embargo and a default setting. It
- // should not be considered and should allow the plugins setting for url1 to
+ // should not be considered and should allow the images setting for url1 to
// be included as a recent change.
clock()->Advance(base::TimeDelta::FromDays(7));
auto_blocker->RecordDismissAndEmbargo(url1, kNotifications, false);
@@ -264,7 +264,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
EXPECT_EQ(kBlocked, url1_permissions[0].content_setting);
EXPECT_EQ(kEmbargo, url1_permissions[0].setting_source);
- EXPECT_EQ(kPlugins, url1_permissions[1].content_type);
+ EXPECT_EQ(kImages, url1_permissions[1].content_type);
EXPECT_EQ(kBlocked, url1_permissions[1].content_setting);
EXPECT_EQ(kPreference, url1_permissions[1].setting_source);
}
@@ -276,7 +276,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
clock()->Advance(base::TimeDelta::FromHours(1));
map->SetContentSettingDefaultScope(url1, url1, kLocation, kAllowed);
clock()->Advance(base::TimeDelta::FromHours(1));
- map->SetContentSettingDefaultScope(url1, url1, kPlugins, kAllowed);
+ map->SetContentSettingDefaultScope(url1, url1, kImages, kAllowed);
recent_permissions = GetRecentSitePermissions(profile(), content_types, 3);
{
@@ -287,7 +287,7 @@ TEST_F(RecentSiteSettingsHelperTest, CheckRecentSitePermissions) {
EXPECT_EQ(kLocation, url1_permissions[0].content_type);
EXPECT_EQ(kNotifications, url1_permissions[1].content_type);
- EXPECT_EQ(kPlugins, url1_permissions[2].content_type);
+ EXPECT_EQ(kImages, url1_permissions[2].content_type);
EXPECT_EQ(kPopups, url1_permissions[3].content_type);
}
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 78a086d9e61..7f63fe98b0e 100644
--- a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc
@@ -14,6 +14,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/browser/net/system_network_context_manager.h"
@@ -31,10 +32,10 @@
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "ui/base/l10n/l10n_util.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/reset/metrics.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ash/reset/metrics.h"
#include "chrome/common/pref_names.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if defined(OS_WIN)
#include "chrome/browser/profile_resetter/triggered_profile_resetter.h"
@@ -122,12 +123,12 @@ void ResetSettingsHandler::RegisterMessages() {
base::BindRepeating(
&ResetSettingsHandler::HandleGetTriggeredResetToolName,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
web_ui()->RegisterMessageCallback(
"onPowerwashDialogShow",
base::BindRepeating(&ResetSettingsHandler::OnShowPowerwashDialog,
base::Unretained(this)));
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
void ResetSettingsHandler::HandleResetProfileSettings(
@@ -147,9 +148,9 @@ void ResetSettingsHandler::HandleResetProfileSettings(
DCHECK(brandcode_.empty() || config_fetcher_);
if (config_fetcher_ && config_fetcher_->IsActive()) {
// Reset once the prefs are fetched.
- config_fetcher_->SetCallback(base::Bind(&ResetSettingsHandler::ResetProfile,
- base::Unretained(this), callback_id,
- send_settings, request_origin));
+ config_fetcher_->SetCallback(base::BindOnce(
+ &ResetSettingsHandler::ResetProfile, base::Unretained(this),
+ callback_id, send_settings, request_origin));
} else {
ResetProfile(callback_id, send_settings, request_origin);
}
@@ -185,8 +186,8 @@ void ResetSettingsHandler::HandleGetReportedSettings(
CHECK(args->GetString(0, &callback_id));
setting_snapshot_->RequestShortcuts(
- base::Bind(&ResetSettingsHandler::OnGetReportedSettingsDone,
- callback_weak_ptr_factory_.GetWeakPtr(), callback_id));
+ base::BindOnce(&ResetSettingsHandler::OnGetReportedSettingsDone,
+ callback_weak_ptr_factory_.GetWeakPtr(), callback_id));
}
void ResetSettingsHandler::OnGetReportedSettingsDone(std::string callback_id) {
@@ -206,8 +207,8 @@ void ResetSettingsHandler::OnShowResetProfileDialog(
config_fetcher_ = std::make_unique<BrandcodeConfigFetcher>(
g_browser_process->system_network_context_manager()
->GetURLLoaderFactory(),
- base::Bind(&ResetSettingsHandler::OnSettingsFetched,
- base::Unretained(this)),
+ base::BindOnce(&ResetSettingsHandler::OnSettingsFetched,
+ base::Unretained(this)),
GURL("https://tools.google.com/service/update2"), brandcode_);
}
@@ -250,9 +251,9 @@ void ResetSettingsHandler::ResetProfile(
GetResetter()->Reset(
ProfileResetter::ALL, std::move(default_settings),
- base::Bind(&ResetSettingsHandler::OnResetProfileSettingsDone,
- callback_weak_ptr_factory_.GetWeakPtr(), callback_id,
- send_settings, request_origin));
+ base::BindOnce(&ResetSettingsHandler::OnResetProfileSettingsDone,
+ callback_weak_ptr_factory_.GetWeakPtr(), callback_id,
+ send_settings, request_origin));
base::RecordAction(base::UserMetricsAction("ResetProfile"));
UMA_HISTOGRAM_ENUMERATION(
"ProfileReset.ResetRequestOrigin", request_origin,
@@ -298,14 +299,14 @@ void ResetSettingsHandler::HandleGetTriggeredResetToolName(
ResolveJavascriptCallback(*callback_id, string_value);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void ResetSettingsHandler::OnShowPowerwashDialog(
const base::ListValue* args) {
UMA_HISTOGRAM_ENUMERATION(
"Reset.ChromeOS.PowerwashDialogShown",
- chromeos::reset::DIALOG_FROM_OPTIONS,
- chromeos::reset::DIALOG_VIEW_TYPE_SIZE);
+ ash::reset::DialogViewType::kFromOptions,
+ ash::reset::DialogViewType::kCount);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.h b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.h
index c3b0ef8a100..2c08f8cb95b 100644
--- a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.h
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profile_resetter/profile_reset_report.pb.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -87,10 +88,10 @@ class ResetSettingsHandler : public SettingsPageUIHandler {
bool send_feedback,
reset_report::ChromeResetReport::ResetRequestOrigin request_origin);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Will be called when powerwash dialog is shown.
void OnShowPowerwashDialog(const base::ListValue* args);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
Profile* const profile_;
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 ac1b919577f..3c08e46999f 100644
--- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/settings/safety_check_handler.h"
#include "base/bind.h"
+#include "base/feature_list.h"
#include "base/i18n/number_formatting.h"
#include "base/macros.h"
#include "base/metrics/histogram_functions.h"
@@ -12,12 +13,14 @@
#include "base/metrics/user_metrics_action.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.h"
#include "chrome/browser/password_manager/bulk_leak_check_service_factory.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/version_ui.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/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
@@ -32,6 +35,7 @@
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension_id.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/strings/grit/ui_strings.h"
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
#include "base/win/registry.h"
@@ -39,7 +43,7 @@
#include "components/chrome_cleaner/public/constants/constants.h"
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ui/chromeos/devicetype_utils.h"
#endif
@@ -60,9 +64,6 @@ constexpr char kPerformSafetyCheck[] = "performSafetyCheck";
constexpr char kGetParentRanDisplayString[] = "getSafetyCheckRanDisplayString";
constexpr char kNewState[] = "newState";
constexpr char kDisplayString[] = "displayString";
-constexpr char kPasswordsCompromised[] = "passwordsCompromised";
-constexpr char kExtensionsReenabledByUser[] = "extensionsReenabledByUser";
-constexpr char kExtensionsReenabledByAdmin[] = "extensionsReenabledByAdmin";
// Converts the VersionUpdater::Status to the UpdateStatus enum to be passed
// to the safety check frontend. Note: if the VersionUpdater::Status gets
@@ -252,7 +253,7 @@ void SafetyCheckHandler::SendSafetyCheckStartedWebUiUpdates() {
GetStringForUpdates(update_status_));
FireBasicSafetyCheckWebUiListener(
kPasswordsEvent, static_cast<int>(passwords_status_),
- GetStringForPasswords(passwords_status_, Compromised(0), Done(0),
+ GetStringForPasswords(passwords_status_, Compromised(0), Weak(0), Done(0),
Total(0)));
FireBasicSafetyCheckWebUiListener(
kSafeBrowsingEvent, static_cast<int>(safe_browsing_status_),
@@ -387,8 +388,8 @@ void SafetyCheckHandler::HandleGetParentRanDisplayString(
void SafetyCheckHandler::CheckUpdates() {
// Usage of base::Unretained(this) is safe, because we own `version_updater_`.
version_updater_->CheckForUpdate(
- base::Bind(&SafetyCheckHandler::OnVersionUpdaterResult,
- base::Unretained(this)),
+ base::BindRepeating(&SafetyCheckHandler::OnVersionUpdaterResult,
+ base::Unretained(this)),
VersionUpdater::PromoteCallback());
}
@@ -399,11 +400,11 @@ void SafetyCheckHandler::CheckPasswords() {
// registered. This takes care of an edge case when safety check starts twice
// on the same page. Normally this should not happen, but if it does, the
// browser should not crash.
- observed_leak_check_.RemoveAll();
- observed_leak_check_.Add(leak_service_);
+ observed_leak_check_.Reset();
+ observed_leak_check_.Observe(leak_service_);
// Start observing the InsecureCredentialsManager.
- observed_insecure_credentials_manager_.RemoveAll();
- observed_insecure_credentials_manager_.Add(insecure_credentials_manager_);
+ observed_insecure_credentials_manager_.Reset();
+ observed_insecure_credentials_manager_.Observe(insecure_credentials_manager_);
passwords_delegate_->StartPasswordCheck(base::BindOnce(
&SafetyCheckHandler::OnStateChanged, weak_ptr_factory_.GetWeakPtr()));
}
@@ -502,15 +503,13 @@ void SafetyCheckHandler::OnUpdateCheckResult(UpdateStatus status) {
void SafetyCheckHandler::OnPasswordsCheckResult(PasswordsStatus status,
Compromised compromised,
+ Weak weak,
Done done,
Total total) {
base::DictionaryValue event;
event.SetIntKey(kNewState, static_cast<int>(status));
- if (status == PasswordsStatus::kCompromisedExist) {
- event.SetIntKey(kPasswordsCompromised, compromised.value());
- }
- event.SetStringKey(kDisplayString,
- GetStringForPasswords(status, compromised, done, total));
+ event.SetStringKey(kDisplayString, GetStringForPasswords(status, compromised,
+ weak, done, total));
FireWebUIListener(kPasswordsEvent, event);
if (status != PasswordsStatus::kChecking) {
base::UmaHistogramEnumeration("Settings.SafetyCheck.PasswordsResult",
@@ -527,14 +526,6 @@ void SafetyCheckHandler::OnExtensionsCheckResult(
ReenabledAdmin reenabled_admin) {
base::DictionaryValue event;
event.SetIntKey(kNewState, static_cast<int>(status));
- if (status == ExtensionsStatus::kBlocklistedReenabledAllByUser ||
- status == ExtensionsStatus::kBlocklistedReenabledSomeByUser) {
- event.SetIntKey(kExtensionsReenabledByUser, reenabled_user.value());
- }
- if (status == ExtensionsStatus::kBlocklistedReenabledAllByAdmin ||
- status == ExtensionsStatus::kBlocklistedReenabledSomeByUser) {
- event.SetIntKey(kExtensionsReenabledByAdmin, reenabled_admin.value());
- }
event.SetStringKey(kDisplayString,
GetStringForExtensions(status, Blocklisted(blocklisted),
reenabled_user, reenabled_admin));
@@ -579,7 +570,7 @@ base::string16 SafetyCheckHandler::GetStringForUpdates(UpdateStatus status) {
case UpdateStatus::kChecking:
return base::UTF8ToUTF16("");
case UpdateStatus::kUpdated:
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
return ui::SubstituteChromeOSDeviceType(IDS_SETTINGS_UPGRADE_UP_TO_DATE);
#else
return l10n_util::GetStringUTF16(IDS_SETTINGS_UPGRADE_UP_TO_DATE);
@@ -647,6 +638,7 @@ base::string16 SafetyCheckHandler::GetStringForSafeBrowsing(
base::string16 SafetyCheckHandler::GetStringForPasswords(
PasswordsStatus status,
Compromised compromised,
+ Weak weak,
Done done,
Total total) {
switch (status) {
@@ -663,8 +655,30 @@ base::string16 SafetyCheckHandler::GetStringForPasswords(
return l10n_util::GetPluralStringFUTF16(
IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT, 0);
case PasswordsStatus::kCompromisedExist:
+ // TODO(crbug.com/1128904): Clean up the old code path.
+ if (!base::FeatureList::IsEnabled(features::kSafetyCheckWeakPasswords)) {
+ return l10n_util::GetPluralStringFUTF16(
+ IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT, compromised.value());
+ }
+ if (weak.value() == 0) {
+ // Only compromised passwords, no weak passwords.
+ return l10n_util::GetPluralStringFUTF16(
+ IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT_SHORT,
+ compromised.value());
+ } else {
+ // Both compromised and weak passwords.
+ return l10n_util::GetStringFUTF16(
+ IDS_CONCAT_TWO_STRINGS_WITH_COMMA,
+ l10n_util::GetPluralStringFUTF16(
+ IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT_SHORT,
+ compromised.value()),
+ l10n_util::GetPluralStringFUTF16(
+ IDS_SETTINGS_WEAK_PASSWORDS_COUNT_SHORT, weak.value()));
+ }
+ case PasswordsStatus::kWeakPasswordsExist:
+ // Only weak passwords.
return l10n_util::GetPluralStringFUTF16(
- IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT, compromised.value());
+ IDS_SETTINGS_WEAK_PASSWORDS_COUNT_SHORT, weak.value());
case PasswordsStatus::kOffline:
return l10n_util::GetStringUTF16(
IDS_SETTINGS_CHECK_PASSWORDS_ERROR_OFFLINE);
@@ -709,16 +723,14 @@ base::string16 SafetyCheckHandler::GetStringForExtensions(
IDS_SETTINGS_SAFETY_CHECK_EXTENSIONS_BLOCKLISTED_ON_USER,
reenabled_user.value());
case ExtensionsStatus::kBlocklistedReenabledSomeByUser:
- // TODO(crbug/1060625): Make string concatenation with a period
- // internationalized (see go/i18n-concatenation).
- return l10n_util::GetPluralStringFUTF16(
- IDS_SETTINGS_SAFETY_CHECK_EXTENSIONS_BLOCKLISTED_ON_USER,
- reenabled_user.value()) +
- base::ASCIIToUTF16(". ") +
- l10n_util::GetPluralStringFUTF16(
- IDS_SETTINGS_SAFETY_CHECK_EXTENSIONS_BLOCKLISTED_ON_ADMIN,
- reenabled_admin.value()) +
- base::ASCIIToUTF16(".");
+ return l10n_util::GetStringFUTF16(
+ IDS_CONCAT_TWO_STRINGS_WITH_PERIODS,
+ l10n_util::GetPluralStringFUTF16(
+ IDS_SETTINGS_SAFETY_CHECK_EXTENSIONS_BLOCKLISTED_ON_USER,
+ reenabled_user.value()),
+ l10n_util::GetPluralStringFUTF16(
+ IDS_SETTINGS_SAFETY_CHECK_EXTENSIONS_BLOCKLISTED_ON_ADMIN,
+ reenabled_admin.value()));
case ExtensionsStatus::kBlocklistedReenabledAllByAdmin:
return l10n_util::GetPluralStringFUTF16(
IDS_SETTINGS_SAFETY_CHECK_EXTENSIONS_BLOCKLISTED_ON_ADMIN,
@@ -861,25 +873,36 @@ void SafetyCheckHandler::DetermineIfNoPasswordsOrSafe(
passwords) {
OnPasswordsCheckResult(passwords.empty() ? PasswordsStatus::kNoPasswords
: PasswordsStatus::kSafe,
- Compromised(0), Done(0), Total(0));
+ Compromised(0), Weak(0), Done(0), Total(0));
}
void SafetyCheckHandler::UpdatePasswordsResultOnCheckIdle() {
size_t num_compromised =
passwords_delegate_->GetCompromisedCredentials().size();
- if (num_compromised == 0) {
+ size_t num_weak = passwords_delegate_->GetWeakCredentials().size();
+ // TODO(crbug.com/1128904): Clean up the old code path.
+ if (num_compromised == 0 &&
+ (num_weak == 0 ||
+ !base::FeatureList::IsEnabled(features::kSafetyCheckWeakPasswords))) {
// If there are no |OnCredentialDone| callbacks with is_leaked = true, no
// need to wait for InsecureCredentialsManager callbacks any longer, since
// there should be none for the current password check.
if (!compromised_passwords_exist_) {
- observed_insecure_credentials_manager_.RemoveAll();
+ observed_insecure_credentials_manager_.Reset();
}
passwords_delegate_->GetSavedPasswordsList(
base::BindOnce(&SafetyCheckHandler::DetermineIfNoPasswordsOrSafe,
base::Unretained(this)));
- } else {
+ } else if (num_compromised > 0) {
+ // At least one compromised password. Treat as compromises.
OnPasswordsCheckResult(PasswordsStatus::kCompromisedExist,
- Compromised(num_compromised), Done(0), Total(0));
+ Compromised(num_compromised), Weak(num_weak),
+ Done(0), Total(0));
+ } else {
+ // No compromised but weak passwords. Treat as weak passwords only.
+ OnPasswordsCheckResult(PasswordsStatus::kWeakPasswordsExist,
+ Compromised(num_compromised), Weak(num_weak),
+ Done(0), Total(0));
}
}
@@ -919,41 +942,41 @@ void SafetyCheckHandler::OnStateChanged(
case BulkLeakCheckService::State::kIdle:
case BulkLeakCheckService::State::kCanceled: {
UpdatePasswordsResultOnCheckIdle();
- observed_leak_check_.RemoveAll();
+ observed_leak_check_.Reset();
return;
}
case BulkLeakCheckService::State::kRunning:
OnPasswordsCheckResult(PasswordsStatus::kChecking, Compromised(0),
- Done(0), Total(0));
+ Weak(0), Done(0), Total(0));
// Non-terminal state, so nothing else needs to be done.
return;
case BulkLeakCheckService::State::kSignedOut:
OnPasswordsCheckResult(PasswordsStatus::kSignedOut, Compromised(0),
- Done(0), Total(0));
+ Weak(0), Done(0), Total(0));
break;
case BulkLeakCheckService::State::kNetworkError:
- OnPasswordsCheckResult(PasswordsStatus::kOffline, Compromised(0), Done(0),
- Total(0));
+ OnPasswordsCheckResult(PasswordsStatus::kOffline, Compromised(0), Weak(0),
+ Done(0), Total(0));
break;
case BulkLeakCheckService::State::kQuotaLimit:
OnPasswordsCheckResult(PasswordsStatus::kQuotaLimit, Compromised(0),
- Done(0), Total(0));
+ Weak(0), Done(0), Total(0));
break;
case BulkLeakCheckService::State::kTokenRequestFailure:
OnPasswordsCheckResult(PasswordsStatus::kFeatureUnavailable,
- Compromised(0), Done(0), Total(0));
+ Compromised(0), Weak(0), Done(0), Total(0));
break;
case BulkLeakCheckService::State::kHashingFailure:
case BulkLeakCheckService::State::kServiceError:
- OnPasswordsCheckResult(PasswordsStatus::kError, Compromised(0), Done(0),
- Total(0));
+ OnPasswordsCheckResult(PasswordsStatus::kError, Compromised(0), Weak(0),
+ Done(0), Total(0));
break;
}
// Stop observing the leak service and credentials manager in all non-idle
// states.
- observed_leak_check_.RemoveAll();
- observed_insecure_credentials_manager_.RemoveAll();
+ observed_leak_check_.Reset();
+ observed_insecure_credentials_manager_.Reset();
}
void SafetyCheckHandler::OnCredentialDone(
@@ -972,12 +995,12 @@ void SafetyCheckHandler::OnCredentialDone(
status.already_processed && status.remaining_in_queue) {
Done done = Done(*(status.already_processed));
Total total = Total(*(status.remaining_in_queue) + done.value());
- OnPasswordsCheckResult(PasswordsStatus::kChecking, Compromised(0), done,
- total);
+ OnPasswordsCheckResult(PasswordsStatus::kChecking, Compromised(0), Weak(0),
+ done, total);
}
}
-void SafetyCheckHandler::OnCompromisedCredentialsChanged(
+void SafetyCheckHandler::OnInsecureCredentialsChanged(
password_manager::InsecureCredentialsManager::CredentialsView credentials) {
extensions::api::passwords_private::PasswordCheckStatus status =
passwords_delegate_->GetPasswordCheckStatus();
@@ -988,7 +1011,7 @@ void SafetyCheckHandler::OnCompromisedCredentialsChanged(
}
UpdatePasswordsResultOnCheckIdle();
// Stop observing the manager to avoid dynamically updating the result.
- observed_insecure_credentials_manager_.RemoveAll();
+ observed_insecure_credentials_manager_.Reset();
}
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
@@ -1037,7 +1060,7 @@ void SafetyCheckHandler::OnJavascriptDisallowed() {
// case when the page is reloaded while the password check is in progress and
// another safety check is started. Otherwise |observed_leak_check_|
// automatically calls RemoveAll() on destruction.
- observed_leak_check_.RemoveAll();
+ observed_leak_check_.Reset();
// Destroy the version updater to prevent getting a callback and firing a
// WebUI event, which would cause a crash.
version_updater_.reset();
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 bc6a4685a2c..774f6eb199c 100644
--- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h
@@ -13,9 +13,9 @@
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/time/time.h"
-#include "base/util/type_safety/strong_alias.h"
+#include "base/types/strong_alias.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h"
@@ -178,12 +178,13 @@ class SafetyCheckHandler
private:
// These ensure integers are passed in the correct possitions in the extension
// check methods.
- using Compromised = util::StrongAlias<class CompromisedTag, int>;
- using Done = util::StrongAlias<class DoneTag, int>;
- using Total = util::StrongAlias<class TotalTag, int>;
- using Blocklisted = util::StrongAlias<class BlocklistedTag, int>;
- using ReenabledUser = util::StrongAlias<class ReenabledUserTag, int>;
- using ReenabledAdmin = util::StrongAlias<class ReenabledAdminTag, int>;
+ using Compromised = base::StrongAlias<class CompromisedTag, int>;
+ using Weak = base::StrongAlias<class WeakTag, int>;
+ using Done = base::StrongAlias<class DoneTag, int>;
+ using Total = base::StrongAlias<class TotalTag, int>;
+ using Blocklisted = base::StrongAlias<class BlocklistedTag, int>;
+ using ReenabledUser = base::StrongAlias<class ReenabledUserTag, int>;
+ using ReenabledAdmin = base::StrongAlias<class ReenabledAdminTag, int>;
// Handles triggering the safety check from the frontend (by user pressing a
// button).
@@ -214,6 +215,7 @@ class SafetyCheckHandler
void OnUpdateCheckResult(UpdateStatus status);
void OnPasswordsCheckResult(PasswordsStatus status,
Compromised compromised,
+ Weak weak,
Done done,
Total total);
void OnExtensionsCheckResult(ExtensionsStatus status,
@@ -231,6 +233,7 @@ class SafetyCheckHandler
base::string16 GetStringForSafeBrowsing(SafeBrowsingStatus status);
base::string16 GetStringForPasswords(PasswordsStatus status,
Compromised compromised,
+ Weak weak,
Done done,
Total total);
base::string16 GetStringForExtensions(ExtensionsStatus status,
@@ -280,7 +283,7 @@ class SafetyCheckHandler
password_manager::IsLeaked is_leaked) override;
// InsecureCredentialsManager::Observer implementation.
- void OnCompromisedCredentialsChanged(
+ void OnInsecureCredentialsChanged(
password_manager::InsecureCredentialsManager::CredentialsView credentials)
override;
@@ -323,11 +326,13 @@ class SafetyCheckHandler
extensions::PasswordsPrivateDelegate* passwords_delegate_ = nullptr;
extensions::ExtensionPrefs* extension_prefs_ = nullptr;
extensions::ExtensionServiceInterface* extension_service_ = nullptr;
- ScopedObserver<password_manager::BulkLeakCheckServiceInterface,
- password_manager::BulkLeakCheckServiceInterface::Observer>
+ base::ScopedObservation<
+ password_manager::BulkLeakCheckServiceInterface,
+ password_manager::BulkLeakCheckServiceInterface::Observer>
observed_leak_check_{this};
- ScopedObserver<password_manager::InsecureCredentialsManager,
- password_manager::InsecureCredentialsManager::Observer>
+ base::ScopedObservation<
+ password_manager::InsecureCredentialsManager,
+ password_manager::InsecureCredentialsManager::Observer>
observed_insecure_credentials_manager_{this};
std::unique_ptr<TimestampDelegate> timestamp_delegate_;
base::WeakPtrFactory<SafetyCheckHandler> weak_ptr_factory_{this};
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 edfe365d49a..34991ccfa08 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
@@ -16,15 +16,18 @@
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h"
-#include "base/util/type_safety/strong_alias.h"
+#include "base/test/scoped_feature_list.h"
+#include "base/types/strong_alias.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/api/passwords_private/passwords_private_delegate.h"
#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/common/channel_info.h"
+#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/api/passwords_private.h"
-#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "chrome/test/base/testing_profile.h"
#include "components/crx_file/id_util.h"
#include "components/password_manager/core/browser/bulk_leak_check_service.h"
#include "components/password_manager/core/browser/leak_detection/bulk_leak_check.h"
@@ -34,6 +37,8 @@
#include "components/safety_check/test_update_check_helper.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/version_info/version_info.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 "extensions/browser/extension_prefs.h"
#include "extensions/common/extension.h"
@@ -45,7 +50,7 @@
#include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_impl_win.h"
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ui/chromeos/devicetype_utils.h"
#endif
@@ -64,8 +69,8 @@ constexpr char kChromeCleaner[] = "chrome-cleaner";
#endif
namespace {
-using Enabled = util::StrongAlias<class EnabledTag, bool>;
-using UserCanDisable = util::StrongAlias<class UserCanDisableTag, bool>;
+using Enabled = base::StrongAlias<class EnabledTag, bool>;
+using UserCanDisable = base::StrongAlias<class UserCanDisableTag, bool>;
class TestingSafetyCheckHandler : public SafetyCheckHandler {
public:
@@ -96,8 +101,7 @@ class TestDestructionVersionUpdater : public TestVersionUpdater {
public:
~TestDestructionVersionUpdater() override { destructor_invoked_ = true; }
- void CheckForUpdate(const StatusCallback& callback,
- const PromoteCallback&) override {}
+ void CheckForUpdate(StatusCallback callback, PromoteCallback) override {}
static bool GetDestructorInvoked() { return destructor_invoked_; }
@@ -144,6 +148,10 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
compromised_password_count_ = compromised_password_count;
}
+ void SetNumWeakCredentials(int weak_password_count) {
+ weak_password_count_ = weak_password_count;
+ }
+
void SetPasswordCheckState(
extensions::api::passwords_private::PasswordCheckState state) {
state_ = state;
@@ -155,11 +163,23 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
}
void InvokeOnCompromisedCredentialsChanged() {
+ // Compromised credentials can be added only after password form to which
+ // they corresponds exists.
+ password_manager::PasswordForm form;
+ form.signon_realm = std::string("test.com");
+ form.url = GURL("test.com");
// Credentials have to be unique, so the callback is always invoked.
- store_->AddCompromisedCredentials(
- {"test.com",
- base::ASCIIToUTF16("test" +
- base::NumberToString(test_credential_counter_++))});
+ form.username_value = base::ASCIIToUTF16(
+ "test" + base::NumberToString(test_credential_counter_++));
+ form.password_value = base::ASCIIToUTF16("password");
+ form.username_element = base::ASCIIToUTF16("username_element");
+ store_->AddLogin(form);
+ base::RunLoop().RunUntilIdle();
+
+ store_->AddInsecureCredential(password_manager::CompromisedCredentials(
+ form.signon_realm, form.username_value, base::Time(),
+ password_manager::InsecureType::kLeaked,
+ password_manager::IsMuted(false)));
base::RunLoop().RunUntilIdle();
}
@@ -173,6 +193,16 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
return compromised;
}
+ std::vector<extensions::api::passwords_private::InsecureCredential>
+ GetWeakCredentials() override {
+ std::vector<extensions::api::passwords_private::InsecureCredential> weak(
+ weak_password_count_);
+ for (int i = 0; i < weak_password_count_; ++i) {
+ weak[i].username = "test" + base::NumberToString(i);
+ }
+ return weak;
+ }
+
extensions::api::passwords_private::PasswordCheckStatus
GetPasswordCheckStatus() override {
extensions::api::passwords_private::PasswordCheckStatus status;
@@ -192,6 +222,7 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
private:
password_manager::BulkLeakCheckService* leak_service_ = nullptr;
int compromised_password_count_ = 0;
+ int weak_password_count_ = 0;
int done_ = 0;
int total_ = 0;
int test_credential_counter_ = 0;
@@ -249,7 +280,7 @@ class TestChromeCleanerControllerDelegate
} // namespace
-class SafetyCheckHandlerTest : public ChromeRenderViewHostTestHarness {
+class SafetyCheckHandlerTest : public testing::Test {
public:
void SetUp() override;
void TearDown() override;
@@ -274,6 +305,9 @@ class SafetyCheckHandlerTest : public ChromeRenderViewHostTestHarness {
void ReplaceBrowserName(base::string16* s);
protected:
+ content::BrowserTaskEnvironment browser_task_environment_;
+ std::unique_ptr<TestingProfile> profile_;
+ std::unique_ptr<content::WebContents> web_contents_;
safety_check::TestUpdateCheckHelper* update_helper_ = nullptr;
TestVersionUpdater* version_updater_ = nullptr;
std::unique_ptr<password_manager::BulkLeakCheckService> test_leak_service_;
@@ -283,13 +317,20 @@ class SafetyCheckHandlerTest : public ChromeRenderViewHostTestHarness {
content::TestWebUI test_web_ui_;
std::unique_ptr<TestingSafetyCheckHandler> safety_check_;
base::HistogramTester histogram_tester_;
+ base::test::ScopedFeatureList feature_list_;
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
TestChromeCleanerControllerDelegate test_chrome_cleaner_controller_delegate_;
#endif
};
void SafetyCheckHandlerTest::SetUp() {
- ChromeRenderViewHostTestHarness::SetUp();
+ feature_list_.InitWithFeatures({features::kSafetyCheckWeakPasswords}, {});
+
+ TestingProfile::Builder builder;
+ profile_ = builder.Build();
+
+ web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(profile_.get()));
// The unique pointer to a TestVersionUpdater gets moved to
// SafetyCheckHandler, but a raw pointer is retained here to change its
@@ -301,8 +342,8 @@ void SafetyCheckHandlerTest::SetUp() {
test_leak_service_ = std::make_unique<password_manager::BulkLeakCheckService>(
nullptr, nullptr);
test_passwords_delegate_.SetBulkLeakCheckService(test_leak_service_.get());
- test_web_ui_.set_web_contents(web_contents());
- test_extension_prefs_ = extensions::ExtensionPrefs::Get(profile());
+ test_web_ui_.set_web_contents(web_contents_.get());
+ test_extension_prefs_ = extensions::ExtensionPrefs::Get(profile_.get());
auto timestamp_delegate = std::make_unique<TestTimestampDelegate>();
safety_check_ = std::make_unique<TestingSafetyCheckHandler>(
std::move(update_helper), std::move(version_updater),
@@ -312,11 +353,12 @@ void SafetyCheckHandlerTest::SetUp() {
test_web_ui_.ClearTrackedCalls();
safety_check_->set_web_ui(&test_web_ui_);
safety_check_->AllowJavascript();
+
+ browser_task_environment_.RunUntilIdle();
}
void SafetyCheckHandlerTest::TearDown() {
test_passwords_delegate_.TearDown();
- ChromeRenderViewHostTestHarness::TearDown();
}
const base::DictionaryValue*
@@ -403,7 +445,7 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Updated) {
kUpdates,
static_cast<int>(SafetyCheckHandler::UpdateStatus::kUpdated));
ASSERT_TRUE(event);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
base::string16 expected = base::ASCIIToUTF16("Your ") +
ui::GetChromeOSDeviceName() +
base::ASCIIToUTF16(" is up to date");
@@ -424,7 +466,7 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Updating) {
kUpdates,
static_cast<int>(SafetyCheckHandler::UpdateStatus::kUpdating));
ASSERT_TRUE(event);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
VerifyDisplayString(event, "Updating your device");
#else
VerifyDisplayString(event, "Updating Browser");
@@ -442,7 +484,7 @@ TEST_F(SafetyCheckHandlerTest, CheckUpdates_Relaunch) {
kUpdates,
static_cast<int>(SafetyCheckHandler::UpdateStatus::kRelaunch));
ASSERT_TRUE(event);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
VerifyDisplayString(
event, "Nearly up to date! Restart your device to finish updating.");
#else
@@ -955,7 +997,7 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_SafeStateThenMoreEvents) {
EXPECT_FALSE(event2);
}
-TEST_F(SafetyCheckHandlerTest, CheckPasswords_CompromisedExist) {
+TEST_F(SafetyCheckHandlerTest, CheckPasswords_OnlyCompromisedExist) {
constexpr int kCompromised = 7;
test_passwords_delegate_.SetNumCompromisedCredentials(kCompromised);
safety_check_->PerformSafetyCheck();
@@ -981,6 +1023,60 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_CompromisedExist) {
SafetyCheckHandler::PasswordsStatus::kCompromisedExist, 1);
}
+TEST_F(SafetyCheckHandlerTest, CheckPasswords_CompromisedAndWeakExist) {
+ constexpr int kCompromised = 7;
+ constexpr int kWeak = 13;
+ test_passwords_delegate_.SetNumCompromisedCredentials(kCompromised);
+ test_passwords_delegate_.SetNumWeakCredentials(kWeak);
+ safety_check_->PerformSafetyCheck();
+ // First, a "running" change of state.
+ test_leak_service_->set_state_and_notify(
+ password_manager::BulkLeakCheckService::State::kRunning);
+ EXPECT_TRUE(GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)));
+ // Compromised passwords found state.
+ test_leak_service_->set_state_and_notify(
+ password_manager::BulkLeakCheckService::State::kIdle);
+ const base::DictionaryValue* event2 =
+ GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(
+ SafetyCheckHandler::PasswordsStatus::kCompromisedExist));
+ ASSERT_TRUE(event2);
+ VerifyDisplayString(
+ event2, base::NumberToString(kCompromised) + " compromised passwords, " +
+ base::NumberToString(kWeak) + " weak passwords");
+ histogram_tester_.ExpectBucketCount(
+ "Settings.SafetyCheck.PasswordsResult",
+ SafetyCheckHandler::PasswordsStatus::kCompromisedExist, 1);
+}
+
+TEST_F(SafetyCheckHandlerTest, CheckPasswords_OnlyWeakExist) {
+ constexpr int kWeak = 13;
+ test_passwords_delegate_.SetNumWeakCredentials(kWeak);
+ safety_check_->PerformSafetyCheck();
+ // First, a "running" change of state.
+ test_leak_service_->set_state_and_notify(
+ password_manager::BulkLeakCheckService::State::kRunning);
+ EXPECT_TRUE(GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)));
+ // Compromised passwords found state.
+ test_leak_service_->set_state_and_notify(
+ password_manager::BulkLeakCheckService::State::kIdle);
+ const base::DictionaryValue* event2 =
+ GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(
+ SafetyCheckHandler::PasswordsStatus::kWeakPasswordsExist));
+ ASSERT_TRUE(event2);
+ VerifyDisplayString(event2, base::NumberToString(kWeak) + " weak passwords");
+ histogram_tester_.ExpectBucketCount(
+ "Settings.SafetyCheck.PasswordsResult",
+ SafetyCheckHandler::PasswordsStatus::kWeakPasswordsExist, 1);
+}
+
TEST_F(SafetyCheckHandlerTest, CheckPasswords_Error) {
safety_check_->PerformSafetyCheck();
EXPECT_TRUE(test_passwords_delegate_.StartPasswordCheckTriggered());
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 0330c7dc49c..01b57879204 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
@@ -14,7 +14,7 @@
#include "base/stl_util.h"
#include "base/values.h"
#include "chrome/browser/browsing_data/browsing_data_important_sites_util.h"
-#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
+#include "chrome/browser/browsing_data/chrome_browsing_data_remover_constants.h"
#include "chrome/browser/browsing_data/counters/browsing_data_counter_factory.h"
#include "chrome/browser/browsing_data/counters/browsing_data_counter_utils.h"
#include "chrome/browser/engagement/important_sites_util.h"
@@ -77,7 +77,6 @@ ClearBrowsingDataHandler::ClearBrowsingDataHandler(content::WebUI* webui,
Profile* profile)
: profile_(profile),
sync_service_(ProfileSyncServiceFactory::GetForProfile(profile_)),
- sync_service_observer_(this),
show_history_deletion_dialog_(false) {}
ClearBrowsingDataHandler::~ClearBrowsingDataHandler() {
@@ -102,7 +101,7 @@ void ClearBrowsingDataHandler::RegisterMessages() {
void ClearBrowsingDataHandler::OnJavascriptAllowed() {
if (sync_service_)
- sync_service_observer_.Add(sync_service_);
+ sync_service_observation_.Observe(sync_service_);
DCHECK(counters_.empty());
for (const std::string& pref : kCounterPrefsBasic) {
@@ -127,7 +126,7 @@ void ClearBrowsingDataHandler::OnJavascriptAllowed() {
}
void ClearBrowsingDataHandler::OnJavascriptDisallowed() {
- sync_service_observer_.RemoveAll();
+ sync_service_observation_.Reset();
weak_ptr_factory_.InvalidateWeakPtrs();
counters_.clear();
period_.reset();
@@ -166,15 +165,16 @@ void ClearBrowsingDataHandler::GetRecentlyLaunchedInstalledApps(
browsing_data::TimePeriod time_period =
static_cast<browsing_data::TimePeriod>(period_selected);
- auto installed_apps = ImportantSitesUtil::GetInstalledRegisterableDomains(
- time_period, profile_, kMaxInstalledAppsToWarnOf);
+ auto installed_apps =
+ site_engagement::ImportantSitesUtil::GetInstalledRegisterableDomains(
+ time_period, profile_, kMaxInstalledAppsToWarnOf);
OnGotInstalledApps(webui_callback_id, installed_apps);
}
void ClearBrowsingDataHandler::OnGotInstalledApps(
const std::string& webui_callback_id,
- const std::vector<ImportantSitesUtil::ImportantDomainInfo>&
+ const std::vector<site_engagement::ImportantSitesUtil::ImportantDomainInfo>&
installed_apps) {
base::ListValue installed_apps_list;
for (const auto& info : installed_apps) {
@@ -221,7 +221,7 @@ ClearBrowsingDataHandler::ProcessInstalledApps(
}
}
if (!excluded_domains.empty() || !ignored_domains.empty()) {
- ImportantSitesUtil::RecordBlacklistedAndIgnoredImportantSites(
+ site_engagement::ImportantSitesUtil::RecordExcludedAndIgnoredImportantSites(
profile_->GetOriginalProfile(), excluded_domains,
excluded_domain_reasons, ignored_domains, ignored_domain_reasons);
}
@@ -242,10 +242,10 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
PrefService* prefs = profile_->GetPrefs();
- int site_data_mask = ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA;
+ int site_data_mask = chrome_browsing_data_remover::DATA_TYPE_SITE_DATA;
// Don't try to clear LSO data if it's not supported.
if (!prefs->GetBoolean(prefs::kClearPluginLSODataEnabled))
- site_data_mask &= ~ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA;
+ site_data_mask &= ~chrome_browsing_data_remover::DATA_TYPE_PLUGIN_DATA;
uint64_t remove_mask = 0;
uint64_t origin_mask = 0;
@@ -262,7 +262,7 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
switch (data_type) {
case BrowsingDataType::HISTORY:
if (prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory))
- remove_mask |= ChromeBrowsingDataRemoverDelegate::DATA_TYPE_HISTORY;
+ remove_mask |= chrome_browsing_data_remover::DATA_TYPE_HISTORY;
break;
case BrowsingDataType::DOWNLOADS:
if (prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory))
@@ -277,16 +277,15 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB;
break;
case BrowsingDataType::PASSWORDS:
- remove_mask |= ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PASSWORDS;
+ remove_mask |= chrome_browsing_data_remover::DATA_TYPE_PASSWORDS;
remove_mask |=
- ChromeBrowsingDataRemoverDelegate::DATA_TYPE_ACCOUNT_PASSWORDS;
+ chrome_browsing_data_remover::DATA_TYPE_ACCOUNT_PASSWORDS;
break;
case BrowsingDataType::FORM_DATA:
- remove_mask |= ChromeBrowsingDataRemoverDelegate::DATA_TYPE_FORM_DATA;
+ remove_mask |= chrome_browsing_data_remover::DATA_TYPE_FORM_DATA;
break;
case BrowsingDataType::SITE_SETTINGS:
- remove_mask |=
- ChromeBrowsingDataRemoverDelegate::DATA_TYPE_CONTENT_SETTINGS;
+ remove_mask |= chrome_browsing_data_remover::DATA_TYPE_CONTENT_SETTINGS;
break;
case BrowsingDataType::HOSTED_APPS_DATA:
remove_mask |= site_data_mask;
@@ -404,8 +403,7 @@ void ClearBrowsingDataHandler::OnClearingTaskFinished(
show_history_notice);
bool show_passwords_notice =
- (failed_data_types &
- ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PASSWORDS);
+ (failed_data_types & chrome_browsing_data_remover::DATA_TYPE_PASSWORDS);
base::Value result(base::Value::Type::DICTIONARY);
result.SetBoolKey("showHistoryNotice", show_history_notice);
@@ -441,7 +439,8 @@ void ClearBrowsingDataHandler::UpdateSyncState() {
IdentityManagerFactory::GetForProfile(profile_);
FireWebUIListener(
"update-sync-state",
- base::Value(identity_manager && identity_manager->HasPrimaryAccount()),
+ base::Value(identity_manager && identity_manager->HasPrimaryAccount(
+ signin::ConsentLevel::kSync)),
base::Value(sync_service_ && sync_service_->IsSyncFeatureActive() &&
sync_service_->GetActiveDataTypes().Has(
syncer::HISTORY_DELETE_DIRECTIVES)),
@@ -474,9 +473,10 @@ void ClearBrowsingDataHandler::AddCounter(
std::unique_ptr<browsing_data::BrowsingDataCounter> counter,
browsing_data::ClearBrowsingDataTab tab) {
DCHECK(counter);
- counter->Init(profile_->GetPrefs(), tab,
- base::Bind(&ClearBrowsingDataHandler::UpdateCounterText,
- base::Unretained(this)));
+ counter->Init(
+ profile_->GetPrefs(), tab,
+ base::BindRepeating(&ClearBrowsingDataHandler::UpdateCounterText,
+ base::Unretained(this)));
counters_.push_back(std::move(counter));
}
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 dcfc7343654..d0afce69538 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
@@ -11,7 +11,7 @@
#include "base/containers/flat_set.h"
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/engagement/important_sites_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -55,7 +55,8 @@ class ClearBrowsingDataHandler : public SettingsPageUIHandler,
// Respond to the WebUI callback with the list of installed apps.
void OnGotInstalledApps(
const std::string& webui_callback_id,
- const std::vector<ImportantSitesUtil::ImportantDomainInfo>&
+ const std::vector<
+ site_engagement::ImportantSitesUtil::ImportantDomainInfo>&
installed_apps);
// Build a filter of sites to include and exclude from site data removal
@@ -114,8 +115,8 @@ class ClearBrowsingDataHandler : public SettingsPageUIHandler,
// SyncService to observe sync state changes.
syncer::SyncService* sync_service_;
- ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
- sync_service_observer_;
+ base::ScopedObservation<syncer::SyncService, syncer::SyncServiceObserver>
+ sync_service_observation_{this};
// Whether we should show a dialog informing the user about other forms of
// history stored in their account after the history deletion is finished.
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 9e58e687ba5..6a8860ce957 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
@@ -100,22 +100,27 @@ int GetCategoryLabelID(CookieTreeNode::DetailedInfo::NodeType node_type) {
namespace settings {
-constexpr char kChildren[] = "children";
-constexpr char kCount[] = "count";
-constexpr char kId[] = "id";
-constexpr char kItems[] = "items";
-constexpr char kStart[] = "start";
constexpr char kLocalData[] = "localData";
constexpr char kSite[] = "site";
-constexpr char kTotal[] = "total";
-CookiesViewHandler::Request::Request() {
- Clear();
+CookiesViewHandler::Request::Request(TreeModelBatchBehavior batch_behavior,
+ base::OnceClosure initial_task)
+ : batch_behavior(batch_behavior), initial_task(std::move(initial_task)) {
+ if (batch_behavior == Request::ASYNC_BATCH)
+ batch_end_task = base::DoNothing::Once();
}
-void CookiesViewHandler::Request::Clear() {
- should_send_list = false;
- callback_id_.clear();
+CookiesViewHandler::Request::Request(base::OnceClosure initial_task,
+ base::OnceClosure batch_end_task)
+ : batch_behavior(Request::TreeModelBatchBehavior::ASYNC_BATCH),
+ initial_task(std::move(initial_task)),
+ batch_end_task(std::move(batch_end_task)) {}
+
+CookiesViewHandler::Request::~Request() = default;
+
+CookiesViewHandler::Request::Request(Request&& other) {
+ initial_task = std::move(other.initial_task);
+ batch_end_task = std::move(other.batch_end_task);
}
CookiesViewHandler::CookiesViewHandler()
@@ -125,16 +130,21 @@ CookiesViewHandler::~CookiesViewHandler() {
}
void CookiesViewHandler::OnJavascriptAllowed() {
+ // Some requests assume that a tree model has already been created, creating
+ // here ensures this is true.
+ pending_requests_.emplace(
+ Request::ASYNC_BATCH,
+ base::BindOnce(&CookiesViewHandler::RecreateCookiesTreeModel,
+ callback_weak_ptr_factory_.GetWeakPtr()));
+ ProcessPendingRequests();
}
void CookiesViewHandler::OnJavascriptDisallowed() {
callback_weak_ptr_factory_.InvalidateWeakPtrs();
- request_.Clear();
+ pending_requests_ = std::queue<Request>();
}
void CookiesViewHandler::RegisterMessages() {
- EnsureCookiesTreeModelCreated();
-
web_ui()->RegisterMessageCallback(
"localData.getDisplayList",
base::BindRepeating(&CookiesViewHandler::HandleGetDisplayList,
@@ -160,8 +170,8 @@ void CookiesViewHandler::RegisterMessages() {
base::BindRepeating(&CookiesViewHandler::HandleGetNumCookiesString,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "localData.removeCookie",
- base::BindRepeating(&CookiesViewHandler::HandleRemove,
+ "localData.removeSite",
+ base::BindRepeating(&CookiesViewHandler::HandleRemoveSite,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"localData.removeThirdPartyCookies",
@@ -176,30 +186,7 @@ void CookiesViewHandler::RegisterMessages() {
void CookiesViewHandler::TreeNodesAdded(ui::TreeModel* model,
ui::TreeModelNode* parent,
size_t start,
- size_t count) {
- // Skip if there is a batch update in progress.
- if (batch_update_)
- return;
-
- CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model);
- CookieTreeNode* parent_node = tree_model->AsNode(parent);
-
- std::unique_ptr<base::ListValue> children(new base::ListValue);
- // Passing false for |include_quota_nodes| since they don't reflect reality
- // until bug http://crbug.com/642955 is fixed and local/session storage is
- // counted against the total.
- model_util_->GetChildNodeList(
- parent_node, start, count, /*include_quota_nodes=*/false, children.get());
-
- base::DictionaryValue args;
- if (parent == tree_model->GetRoot())
- args.Set(kId, std::make_unique<base::Value>());
- else
- args.SetString(kId, model_util_->GetTreeNodeId(parent_node));
- args.SetInteger(kStart, int{start});
- args.Set(kChildren, std::move(children));
- FireWebUIListener("on-tree-item-added", args);
-}
+ size_t count) {}
void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model,
ui::TreeModelNode* parent,
@@ -208,74 +195,79 @@ void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model,
// Skip if there is a batch update in progress.
if (batch_update_)
return;
-
- CookiesTreeModel* tree_model = static_cast<CookiesTreeModel*>(model);
-
- base::DictionaryValue args;
- if (parent == tree_model->GetRoot())
- args.Set(kId, std::make_unique<base::Value>());
- else
- args.SetString(kId, model_util_->GetTreeNodeId(tree_model->AsNode(parent)));
- args.SetInteger(kStart, int{start});
- args.SetInteger(kCount, int{count});
- FireWebUIListener("on-tree-item-removed", args);
+ FireWebUIListener("on-tree-item-removed");
}
void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) {
DCHECK(!batch_update_); // There should be no nested batch begin.
+ DCHECK(!pending_requests_.empty());
batch_update_ = true;
+
+ DCHECK_NE(Request::NO_BATCH, pending_requests_.front().batch_behavior);
}
void CookiesViewHandler::TreeModelEndBatch(CookiesTreeModel* model) {
DCHECK(batch_update_);
+ DCHECK(!pending_requests_.empty());
batch_update_ = false;
- if (request_.should_send_list) {
- SendLocalDataList(model->GetRoot());
- } else if (!request_.callback_id_.empty()) {
- ResolveJavascriptCallback(base::Value(request_.callback_id_),
- (base::Value()));
- request_.Clear();
+ DCHECK_NE(Request::NO_BATCH, pending_requests_.front().batch_behavior);
+
+ if (pending_requests_.front().batch_behavior == Request::ASYNC_BATCH) {
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, std::move(pending_requests_.front().batch_end_task));
+
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(&CookiesViewHandler::RequestComplete,
+ callback_weak_ptr_factory_.GetWeakPtr()));
}
}
-void CookiesViewHandler::EnsureCookiesTreeModelCreated() {
- if (!cookies_tree_model_.get()) {
- Profile* profile = Profile::FromWebUI(web_ui());
- cookies_tree_model_ = CookiesTreeModel::CreateForProfile(profile);
- cookies_tree_model_->AddCookiesTreeObserver(this);
- }
+void CookiesViewHandler::SetCookiesTreeModelForTesting(
+ std::unique_ptr<CookiesTreeModel> cookies_tree_model) {
+ cookies_tree_model_for_testing_ = std::move(cookies_tree_model);
}
void CookiesViewHandler::RecreateCookiesTreeModel() {
cookies_tree_model_.reset();
filter_.clear();
- sorted_sites_.clear();
- EnsureCookiesTreeModelCreated();
-
- CHECK(!request_.callback_id_.empty());
- ResolveJavascriptCallback(base::Value(request_.callback_id_),
- (base::Value()));
- request_.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_->AddCookiesTreeObserver(this);
}
void CookiesViewHandler::HandleGetCookieDetails(const base::ListValue* args) {
- CHECK(request_.callback_id_.empty());
CHECK_EQ(2U, args->GetList().size());
- request_.callback_id_ = args->GetList()[0].GetString();
+ std::string callback_id = args->GetList()[0].GetString();
std::string site = args->GetList()[1].GetString();
AllowJavascript();
+ pending_requests_.emplace(
+ Request::NO_BATCH, base::BindOnce(&CookiesViewHandler::GetCookieDetails,
+ callback_weak_ptr_factory_.GetWeakPtr(),
+ callback_id, site));
+ ProcessPendingRequests();
+}
+
+void CookiesViewHandler::GetCookieDetails(const std::string& callback_id,
+ const std::string& site) {
const CookieTreeNode* node = model_util_->GetTreeNodeFromTitle(
cookies_tree_model_->GetRoot(), base::UTF8ToUTF16(site));
if (!node) {
- RejectJavascriptCallback(base::Value(request_.callback_id_), base::Value());
- request_.Clear();
+ RejectJavascriptCallback(base::Value(callback_id), base::Value());
return;
}
- SendCookieDetails(node);
+ base::ListValue children;
+ // TODO (crbug.com/642955): Pass true for |include_quota_nodes| parameter
+ // when quota nodes include local/session storage in the total.
+ model_util_->GetChildNodeDetails(node, /* include_quota_nodes */ false,
+ &children);
+
+ ResolveJavascriptCallback(base::Value(callback_id), std::move(children));
}
void CookiesViewHandler::HandleGetNumCookiesString(
@@ -295,106 +287,155 @@ void CookiesViewHandler::HandleGetNumCookiesString(
}
void CookiesViewHandler::HandleGetDisplayList(const base::ListValue* args) {
- CHECK(request_.callback_id_.empty());
CHECK_EQ(2U, args->GetList().size());
- request_.callback_id_ = args->GetList()[0].GetString();
+ std::string callback_id = args->GetList()[0].GetString();
base::string16 filter = base::UTF8ToUTF16(args->GetList()[1].GetString());
AllowJavascript();
- request_.should_send_list = true;
- // Resetting the filter is a heavy operation, avoid unnecessary filtering.
+ pending_requests_.emplace(
+ Request::SYNC_BATCH,
+ base::BindOnce(&CookiesViewHandler::GetDisplayList,
+ callback_weak_ptr_factory_.GetWeakPtr(), callback_id,
+ filter));
+
+ ProcessPendingRequests();
+}
+
+void CookiesViewHandler::GetDisplayList(std::string callback_id,
+ const base::string16& filter) {
if (filter != filter_) {
filter_ = filter;
- sorted_sites_.clear();
cookies_tree_model_->UpdateSearchResults(filter_);
- return;
+ DCHECK(!batch_update_) << "Expected CookiesTreeModel::UpdateSearchResults "
+ << "to execute synchronously.";
}
- SendLocalDataList(cookies_tree_model_->GetRoot());
+ ReturnLocalDataList(callback_id);
}
void CookiesViewHandler::HandleReloadCookies(const base::ListValue* args) {
- CHECK(request_.callback_id_.empty());
CHECK_EQ(1U, args->GetList().size());
- request_.callback_id_ = args->GetList()[0].GetString();
-
- AllowJavascript();
- RecreateCookiesTreeModel();
+ std::string callback_id = args->GetList()[0].GetString();
+
+ // Allowing Javascript for the first time will queue a task to create a new
+ // tree model. Thus the tree model only needs to be recreated if Javascript
+ // has already been allowed. Reload cookies is often the first call made by
+ // pages using this handler, so this avoids unnecessary work.
+ if (IsJavascriptAllowed()) {
+ pending_requests_.emplace(
+ base::BindOnce(&CookiesViewHandler::RecreateCookiesTreeModel,
+ callback_weak_ptr_factory_.GetWeakPtr()),
+ base::BindOnce(&CookiesViewHandler::ResolveJavascriptCallback,
+ callback_weak_ptr_factory_.GetWeakPtr(),
+ base::Value(callback_id), base::Value()));
+ } else {
+ AllowJavascript();
+ pending_requests_.emplace(
+ Request::NO_BATCH,
+ base::BindOnce(&CookiesViewHandler::ResolveJavascriptCallback,
+ callback_weak_ptr_factory_.GetWeakPtr(),
+ base::Value(callback_id), base::Value()));
+ }
+ ProcessPendingRequests();
}
void CookiesViewHandler::HandleRemoveAll(const base::ListValue* args) {
- CHECK(request_.callback_id_.empty());
CHECK_EQ(1U, args->GetList().size());
- request_.callback_id_ = args->GetList()[0].GetString();
-
AllowJavascript();
+
+ std::string callback_id = args->GetList()[0].GetString();
+
+ pending_requests_.emplace(
+ Request::SYNC_BATCH,
+ base::BindOnce(&CookiesViewHandler::RemoveAll,
+ callback_weak_ptr_factory_.GetWeakPtr(), callback_id));
+ ProcessPendingRequests();
+}
+
+void CookiesViewHandler::RemoveAll(const std::string& callback_id) {
cookies_tree_model_->DeleteAllStoredObjects();
- sorted_sites_.clear();
+ ResolveJavascriptCallback(base::Value(callback_id), base::Value());
}
-void CookiesViewHandler::HandleRemove(const base::ListValue* args) {
+void CookiesViewHandler::HandleRemoveItem(const base::ListValue* args) {
std::string node_path = args->GetList()[0].GetString();
AllowJavascript();
- const CookieTreeNode* node = model_util_->GetTreeNodeFromPath(
- cookies_tree_model_->GetRoot(), node_path);
+ pending_requests_.emplace(
+ Request::NO_BATCH,
+ base::BindOnce(&CookiesViewHandler::RemoveItem,
+ callback_weak_ptr_factory_.GetWeakPtr(), node_path));
+ ProcessPendingRequests();
+}
+
+void CookiesViewHandler::RemoveItem(const std::string& path) {
+ const CookieTreeNode* node =
+ model_util_->GetTreeNodeFromPath(cookies_tree_model_->GetRoot(), path);
if (node) {
cookies_tree_model_->DeleteCookieNode(const_cast<CookieTreeNode*>(node));
- sorted_sites_.clear();
}
}
void CookiesViewHandler::HandleRemoveThirdParty(const base::ListValue* args) {
- CHECK(request_.callback_id_.empty());
CHECK_EQ(1U, args->GetList().size());
- request_.callback_id_ = args->GetList()[0].GetString();
+ std::string callback_id = args->GetList()[0].GetString();
AllowJavascript();
Profile* profile = Profile::FromWebUI(web_ui());
- ClearSameSiteNoneData(
- base::BindOnce(&CookiesViewHandler::RecreateCookiesTreeModel,
- callback_weak_ptr_factory_.GetWeakPtr()),
- profile,
- /* clear_storage */ true);
+
+ pending_requests_.emplace(
+ base::BindOnce(
+ content::ClearSameSiteNoneData,
+ base::BindOnce(&CookiesViewHandler::RecreateCookiesTreeModel,
+ callback_weak_ptr_factory_.GetWeakPtr()),
+ profile,
+ /* clear_storage */ true),
+ base::BindOnce(&CookiesViewHandler::ResolveJavascriptCallback,
+ callback_weak_ptr_factory_.GetWeakPtr(),
+ base::Value(callback_id), base::Value()));
+ ProcessPendingRequests();
}
void CookiesViewHandler::HandleRemoveShownItems(const base::ListValue* args) {
CHECK_EQ(0U, args->GetList().size());
AllowJavascript();
+ pending_requests_.emplace(
+ Request::NO_BATCH,
+ base::BindOnce(&CookiesViewHandler::RemoveShownItems,
+ callback_weak_ptr_factory_.GetWeakPtr()));
+ ProcessPendingRequests();
+}
+
+void CookiesViewHandler::RemoveShownItems() {
CookieTreeNode* parent = cookies_tree_model_->GetRoot();
while (!parent->children().empty())
cookies_tree_model_->DeleteCookieNode(parent->children().front().get());
}
-void CookiesViewHandler::HandleRemoveItem(const base::ListValue* args) {
+void CookiesViewHandler::HandleRemoveSite(const base::ListValue* args) {
CHECK_EQ(1U, args->GetList().size());
- CHECK(request_.callback_id_.empty());
base::string16 site = base::UTF8ToUTF16(args->GetList()[0].GetString());
-
AllowJavascript();
+ pending_requests_.emplace(
+ Request::NO_BATCH,
+ base::BindOnce(&CookiesViewHandler::RemoveSite,
+ callback_weak_ptr_factory_.GetWeakPtr(), site));
+ ProcessPendingRequests();
+}
+
+void CookiesViewHandler::RemoveSite(const base::string16& site) {
CookieTreeNode* parent = cookies_tree_model_->GetRoot();
const auto i = std::find_if(
parent->children().cbegin(), parent->children().cend(),
[&site](const auto& node) { return node->GetTitle() == site; });
if (i != parent->children().cend()) {
cookies_tree_model_->DeleteCookieNode(i->get());
- sorted_sites_.clear();
}
}
-void CookiesViewHandler::SendLocalDataList(const CookieTreeNode* parent) {
+void CookiesViewHandler::ReturnLocalDataList(const std::string& callback_id) {
CHECK(cookies_tree_model_.get());
- CHECK(request_.should_send_list);
- const size_t parent_child_count = parent->children().size();
- if (sorted_sites_.empty()) {
- // Sort the list by site.
- sorted_sites_.reserve(parent_child_count); // Optimization, hint size.
- for (size_t i = 0; i < parent_child_count; ++i) {
- const base::string16& title = parent->children()[i]->GetTitle();
- sorted_sites_.push_back(LabelAndIndex(title, i));
- }
- std::sort(sorted_sites_.begin(), sorted_sites_.end());
- }
+ auto* parent = cookies_tree_model_->GetRoot();
// The layers in the CookieTree are:
// root - Top level.
@@ -402,9 +443,8 @@ void CookiesViewHandler::SendLocalDataList(const CookieTreeNode* parent) {
// category - Cookies, Local Storage, etc.
// item - Info on the actual thing.
// Gather list of sites with some highlights of the categories and items.
- std::unique_ptr<base::ListValue> site_list(new base::ListValue);
- for (const auto& sorted_site : sorted_sites_) {
- const CookieTreeNode* site = parent->children()[sorted_site.second].get();
+ base::ListValue site_list;
+ for (const auto& site : parent->children()) {
base::string16 description;
for (const auto& category : site->children()) {
if (!description.empty())
@@ -438,53 +478,44 @@ void CookiesViewHandler::SendLocalDataList(const CookieTreeNode* parent) {
list_info->Set(kLocalData, std::make_unique<base::Value>(description));
std::string title = base::UTF16ToUTF8(site->GetTitle());
list_info->Set(kSite, std::make_unique<base::Value>(title));
- site_list->Append(std::move(list_info));
+ site_list.Append(std::move(list_info));
}
- base::DictionaryValue response;
- response.Set(kItems, std::move(site_list));
- response.Set(kTotal,
- std::make_unique<base::Value>(int{sorted_sites_.size()}));
+ // Sort the list into alphabetical order based on site name.
+ std::sort(site_list.begin(), site_list.end(),
+ [=](const base::Value& a, const base::Value& b) {
+ return *a.FindStringKey(kSite) < *b.FindStringKey(kSite);
+ });
- ResolveJavascriptCallback(base::Value(request_.callback_id_), response);
- request_.Clear();
+ ResolveJavascriptCallback(base::Value(callback_id), std::move(site_list));
}
-void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) {
- std::unique_ptr<base::ListValue> children(new base::ListValue);
- // Passing false for |include_quota_nodes| since they don't reflect reality
- // until bug http://crbug.com/642955 is fixed and local/session storage is
- // counted against the total.
- model_util_->GetChildNodeList(parent, /*start=*/0, parent->children().size(),
- /*include_quota_nodes=*/false, children.get());
-
- base::DictionaryValue args;
- if (parent == cookies_tree_model_->GetRoot())
- args.Set(kId, std::make_unique<base::Value>());
- else
- args.SetString(kId, model_util_->GetTreeNodeId(parent));
- args.Set(kChildren, std::move(children));
-
- ResolveJavascriptCallback(base::Value(request_.callback_id_), args);
- request_.Clear();
+void CookiesViewHandler::ProcessPendingRequests() {
+ if (pending_requests_.empty())
+ return;
+
+ // To ensure that multiple requests do not run during a tree model batch
+ // update, only tasks for a single request are queued at any one time.
+ if (request_in_progress_)
+ return;
+
+ request_in_progress_ = true;
+
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, std::move(pending_requests_.front().initial_task));
+ if (pending_requests_.front().batch_behavior != Request::ASYNC_BATCH) {
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(&CookiesViewHandler::RequestComplete,
+ callback_weak_ptr_factory_.GetWeakPtr()));
+ }
}
-void CookiesViewHandler::SendCookieDetails(const CookieTreeNode* parent) {
- std::unique_ptr<base::ListValue> children(new base::ListValue);
- // Passing false for |include_quota_nodes| since they don't reflect reality
- // until bug http://crbug.com/642955 is fixed and local/session storage is
- // counted against the total.
- model_util_->GetChildNodeDetails(parent, false, children.get());
-
- base::DictionaryValue args;
- if (parent == cookies_tree_model_->GetRoot())
- args.Set(kId, std::make_unique<base::Value>());
- else
- args.SetString(kId, model_util_->GetTreeNodeId(parent));
- args.Set(kChildren, std::move(children));
-
- ResolveJavascriptCallback(base::Value(request_.callback_id_), args);
- request_.Clear();
+void CookiesViewHandler::RequestComplete() {
+ DCHECK(!pending_requests_.empty());
+ DCHECK(!batch_update_);
+ request_in_progress_ = false;
+ pending_requests_.pop();
+ ProcessPendingRequests();
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h
index 27b91d2d6c9..c98b2c9708b 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h
@@ -45,49 +45,60 @@ class CookiesViewHandler : public SettingsPageUIHandler,
void TreeModelBeginBatch(CookiesTreeModel* model) override;
void TreeModelEndBatch(CookiesTreeModel* model) override;
+ // Sets the tree model that will be used when the handler creates a tree
+ // model, instead of building from from the profile.
+ void SetCookiesTreeModelForTesting(
+ std::unique_ptr<CookiesTreeModel> cookies_tree_model);
+
private:
friend class CookiesViewHandlerTest;
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, HandleGetDisplayList);
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, HandleRemoveShownItems);
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, SingleRequestDuringBatch);
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, NoStarvation);
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, ImmediateTreeOperation);
FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest,
HandleReloadCookiesAndGetDisplayList);
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, HandleGetCookieDetails);
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, HandleRemoveAll);
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, HandleRemoveItem);
+ FRIEND_TEST_ALL_PREFIXES(CookiesViewHandlerTest, HandleRemoveSite);
- // Creates the CookiesTreeModel if necessary.
- void EnsureCookiesTreeModelCreated();
-
- // Resets the CookiesTreeModel, the current |filter_|, and the site list.
+ // Recreates the CookiesTreeModel and resets the current |filter_|.
void RecreateCookiesTreeModel();
// Set |filter_| and get a portion (or all) of the list items.
void HandleGetDisplayList(const base::ListValue* args);
+ void GetDisplayList(std::string callback_id, const base::string16& filter);
// Remove all items matching the current |filter_|.
void HandleRemoveShownItems(const base::ListValue* args);
+ void RemoveShownItems();
- // Remove a single item.
- void HandleRemoveItem(const base::ListValue* args);
+ // Remove selected sites data.
+ void HandleRemoveSite(const base::ListValue* args);
+ void RemoveSite(const base::string16& site);
// Retrieve cookie details for a specific site.
void HandleGetCookieDetails(const base::ListValue* args);
+ void GetCookieDetails(const std::string& callback_id,
+ const std::string& site);
// Gets a plural string for the given number of cookies.
void HandleGetNumCookiesString(const base::ListValue* args);
// Remove all sites data.
void HandleRemoveAll(const base::ListValue* args);
+ void RemoveAll(const std::string& callback_id);
- // Remove selected sites data.
- void HandleRemove(const base::ListValue* args);
+ // Remove a single item.
+ void HandleRemoveItem(const base::ListValue* args);
+ void RemoveItem(const std::string& path);
// Removes cookies and site data available in third-party contexts.
void HandleRemoveThirdParty(const base::ListValue* args);
- // Get children nodes data and pass it to 'CookiesView.loadChildren' to
- // update the WebUI.
- void SendChildren(const CookieTreeNode* parent);
-
- void SendLocalDataList(const CookieTreeNode* parent);
-
- // Package and send cookie details for a site.
- void SendCookieDetails(const CookieTreeNode* parent);
+ void ReturnLocalDataList(const std::string& callback_id);
// Reloads the CookiesTreeModel and passes the nodes to
// 'CookiesView.loadChildren' to update the WebUI.
@@ -99,21 +110,68 @@ class CookiesViewHandler : public SettingsPageUIHandler,
// The Cookies Tree model
std::unique_ptr<CookiesTreeModel> cookies_tree_model_;
+ // Cookies tree model which can be set for testing and will be used instead
+ // of creating one directly from the profile.
+ std::unique_ptr<CookiesTreeModel> cookies_tree_model_for_testing_;
+
// Only show items that contain |filter|.
base::string16 filter_;
struct Request {
- Request();
- void Clear();
-
- // Whether the request expects a list response.
- bool should_send_list;
- // The callback ID for the current outstanding request.
- std::string callback_id_;
+ // Specifies the batch behavior of the tree model when this request is run
+ // against it. Batch behavior must be constant across invocations, and
+ // defines when tasks can be queued.
+ enum TreeModelBatchBehavior {
+ // The request will not cause a batch operation to be started. Tasks may
+ // only be queued when the request is first processed.
+ NO_BATCH,
+
+ // The request will cause a batch to start and finish syncronously. Tasks
+ // may only be queued when the request is first processed.
+ SYNC_BATCH,
+
+ // The request will cause an asynchronous batch update to be run. Both
+ // batch end and begin may occur asynchronously. Tasks may be queued when
+ // the request is first processed, and when the batch is finished.
+ ASYNC_BATCH
+ };
+
+ // Creates a request with a task to be queued when the request is first
+ // processed.
+ Request(TreeModelBatchBehavior batch_behavior,
+ base::OnceClosure initial_task);
+
+ // Creates a request with both a task to be queued when processed, and a
+ // task to be queued when the tree model batch finishes. This constructor
+ // implies |batch_behavior| == ASYNC_BATCH.
+ Request(base::OnceClosure initial_task, base::OnceClosure batch_end_task);
+
+ ~Request();
+ Request(const Request&) = delete;
+ Request(Request&& other);
+ Request& operator=(const Request&&) = delete;
+
+ TreeModelBatchBehavior batch_behavior;
+
+ // Task which is run when the request reaches the front of the queue.
+ // Task must only interact with the tree model in a synchronous manner.
+ base::OnceClosure initial_task;
+
+ // Optional task which is queued to run when the tree model batch ends.
+ // Only valid when |batch_behavior| == ASYNC_BATCH. Must only interact with
+ // the tree model in a synchronous manner.
+ base::OnceClosure batch_end_task;
};
- // The current client request.
- Request request_;
+ // The current client requests.
+ std::queue<Request> pending_requests_;
+ bool request_in_progress_ = false;
+
+ // Check the request queue and process the first request if approproiate.
+ void ProcessPendingRequests();
+
+ // Signal that the request at the head of the request queue is complete.
+ void RequestComplete();
// Sorted index list, by site. Indexes refer to |model->GetRoot()| children.
typedef std::pair<base::string16, size_t> LabelAndIndex;
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 05d9e3dfcfa..2e2e56d4a66 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
@@ -7,10 +7,25 @@
#include <memory>
#include <string>
+#include "base/test/bind.h"
#include "base/values.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "components/browsing_data/content/mock_cookie_helper.h"
+#include "components/browsing_data/content/mock_local_storage_helper.h"
#include "content/public/test/test_web_ui.h"
+namespace {
+
+constexpr char kCallbackId[] = "test-callback-id";
+constexpr char kTestOrigin1[] = "https://a-example.com";
+constexpr char kTestOrigin2[] = "https://b-example.com";
+constexpr char kTestHost1[] = "a-example.com";
+constexpr char kTestHost2[] = "b-example.com";
+constexpr char kTestCookie1[] = "A=1";
+constexpr char kTestCookie2[] = "B=1";
+
+} // namespace
+
namespace settings {
class CookiesViewHandlerTest : public ChromeRenderViewHostTestHarness {
@@ -22,7 +37,6 @@ class CookiesViewHandlerTest : public ChromeRenderViewHostTestHarness {
web_ui_->set_web_contents(web_contents());
handler_ = std::make_unique<CookiesViewHandler>();
handler_->set_web_ui(web_ui());
- handler_->AllowJavascript();
web_ui_->ClearTrackedCalls();
}
@@ -34,32 +48,475 @@ class CookiesViewHandlerTest : public ChromeRenderViewHostTestHarness {
ChromeRenderViewHostTestHarness::TearDown();
}
+ void SetupTreeModelForTesting() {
+ mock_browsing_data_cookie_helper =
+ base::MakeRefCounted<browsing_data::MockCookieHelper>(profile());
+ mock_browsing_data_local_storage_helper =
+ base::MakeRefCounted<browsing_data::MockLocalStorageHelper>(profile());
+
+ auto container = std::make_unique<LocalDataContainer>(
+ mock_browsing_data_cookie_helper,
+ /*database_helper=*/nullptr, mock_browsing_data_local_storage_helper,
+ /*session_storage_helper=*/nullptr,
+ /*appcache_helper=*/nullptr,
+ /*indexed_db_helper=*/nullptr,
+ /*file_system_helper=*/nullptr,
+ /*quota_helper=*/nullptr,
+ /*service_worker_helper=*/nullptr,
+ /*data_shared_worker_helper=*/nullptr,
+ /*cache_storage_helper=*/nullptr,
+ /*media_license_helper=*/nullptr);
+ auto mock_cookies_tree_model = std::make_unique<CookiesTreeModel>(
+ std::move(container), profile()->GetExtensionSpecialStoragePolicy());
+
+ mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin(
+ url::Origin::Create(GURL(kTestOrigin1)), 2);
+ mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin(
+ url::Origin::Create(GURL(kTestOrigin2)), 3);
+
+ mock_browsing_data_cookie_helper->AddCookieSamples(GURL(kTestOrigin1),
+ kTestCookie1);
+ mock_browsing_data_cookie_helper->AddCookieSamples(GURL(kTestOrigin2),
+ kTestCookie2);
+
+ handler()->SetCookiesTreeModelForTesting(
+ std::move(mock_cookies_tree_model));
+ }
+
+ void NotifyTreeModel() {
+ mock_browsing_data_local_storage_helper->Notify();
+ mock_browsing_data_cookie_helper->Notify();
+ }
+
+ void SetupHandlerWithTreeModel() {
+ SetupTreeModelForTesting();
+ base::ListValue reload_args;
+ reload_args.AppendString(kCallbackId);
+ handler()->HandleReloadCookies(&reload_args);
+
+ // The handler will post a task to recreate the tree model.
+ task_environment()->RunUntilIdle();
+ NotifyTreeModel();
+
+ // After batch end, the handler will have posted a task to complete
+ // the callback.
+ task_environment()->RunUntilIdle();
+ 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());
+
+ web_ui_->ClearTrackedCalls();
+ }
+
content::TestWebUI* web_ui() { return web_ui_.get(); }
CookiesViewHandler* handler() { return handler_.get(); }
private:
std::unique_ptr<content::TestWebUI> web_ui_;
std::unique_ptr<CookiesViewHandler> handler_;
+
+ // Ref pointers to storage helpers used in the tree model used for testing.
+ // Retained to allow control over batch update completion.
+ scoped_refptr<browsing_data::MockLocalStorageHelper>
+ mock_browsing_data_local_storage_helper;
+ scoped_refptr<browsing_data::MockCookieHelper>
+ mock_browsing_data_cookie_helper;
};
-// This unit test checks that the javascript callbacks are called correctly for
-// the reloadCookies and the getDisplayList handler cases. It also makes sure
-// that CHECKs for request_.callback_id_.empty() do not fire when multiple
-// handlers are called in sequence.
-TEST_F(CookiesViewHandlerTest, HandleReloadCookiesAndGetDisplayList) {
- const std::string reload_callback_id("localData.reload_0");
- const std::string get_display_list_callback_id("localData.getDisplayList_1");
+TEST_F(CookiesViewHandlerTest, SingleRequestDuringBatch) {
+ // Ensure that multiple requests do not run while a tree model batch process
+ // is running.
+ SetupTreeModelForTesting();
+
+ constexpr char kReloadCallbackID[] = "reload-cookies-callback";
+ constexpr char kGetDisplaylistCallbackID[] = "get-display-list-callback";
base::ListValue reload_args;
- reload_args.AppendString(reload_callback_id);
+ reload_args.AppendString(kReloadCallbackID);
handler()->HandleReloadCookies(&reload_args);
- EXPECT_EQ(1U, web_ui()->call_data().size());
+ task_environment()->RunUntilIdle();
+ // At the point the handler will have recreated the model (using the provided
+ // test model) and will be awaiting batch end. Performing another request
+ // should result in it not being satisfied, and instead being queued.
base::ListValue get_display_list_args;
- get_display_list_args.AppendString(reload_callback_id);
- get_display_list_args.AppendString(std::string());
+ get_display_list_args.AppendString(kGetDisplaylistCallbackID);
+ get_display_list_args.AppendString("");
handler()->HandleGetDisplayList(&get_display_list_args);
+ task_environment()->RunUntilIdle();
+
+ // Because the tree model hasn't completed the batch, no callback should
+ // have been completed.
+ EXPECT_EQ(0U, web_ui()->call_data().size());
+
+ // Completing the tree model batch should result in both callbacks being
+ // completed in the correct order.
+ NotifyTreeModel();
+ task_environment()->RunUntilIdle();
EXPECT_EQ(2U, web_ui()->call_data().size());
+
+ const content::TestWebUI::CallData& reload_response =
+ *web_ui()->call_data().front();
+ EXPECT_EQ("cr.webUIResponse", reload_response.function_name());
+ EXPECT_EQ(kReloadCallbackID, reload_response.arg1()->GetString());
+ ASSERT_TRUE(reload_response.arg2()->GetBool());
+
+ const content::TestWebUI::CallData& get_display_list_response =
+ *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIResponse", get_display_list_response.function_name());
+ EXPECT_EQ(kGetDisplaylistCallbackID,
+ get_display_list_response.arg1()->GetString());
+ ASSERT_TRUE(get_display_list_response.arg2()->GetBool());
+ base::Value::ConstListView local_data_list =
+ get_display_list_response.arg3()->GetList();
+ ASSERT_EQ(2U, local_data_list.size());
+ EXPECT_EQ(kTestHost1, local_data_list[0].FindKey("site")->GetString());
+ EXPECT_EQ(kTestHost2, local_data_list[1].FindKey("site")->GetString());
+}
+
+TEST_F(CookiesViewHandlerTest, NoStarvation) {
+ SetupHandlerWithTreeModel();
+
+ // Confirm that the request queue does not starve during various combinations
+ // of requests. This is achieved by queueing numerous permutations of requests
+ // which have different interaction properties with the tree model.
+ std::string current_filter = kTestHost1;
+ auto get_display_list_new_filter =
+ base::BindLambdaForTesting([&](std::string callback_id) {
+ base::ListValue args;
+ args.AppendString(callback_id);
+ current_filter = current_filter == kTestHost1 ? "" : kTestHost1;
+ args.AppendString(kTestHost1);
+ handler()->HandleGetDisplayList(&args);
+ });
+ auto get_display_list_same_filter =
+ base::BindLambdaForTesting([&](std::string callback_id) {
+ base::ListValue args;
+ args.AppendString(callback_id);
+ args.AppendString(current_filter);
+ handler()->HandleGetDisplayList(&args);
+ });
+ auto get_cookie_details =
+ base::BindLambdaForTesting([&](std::string callback_id) {
+ base::ListValue args;
+ args.AppendString(callback_id);
+ args.AppendString(kTestHost1);
+ handler()->HandleGetCookieDetails(&args);
+ });
+ auto reload_cookies =
+ base::BindLambdaForTesting([&](std::string callback_id) {
+ base::ListValue args;
+ args.AppendString(callback_id);
+ handler()->HandleReloadCookies(&args);
+ });
+ auto remove_third_party =
+ base::BindLambdaForTesting([&](std::string callback_id) {
+ base::ListValue args;
+ args.AppendString(callback_id);
+ handler()->HandleRemoveThirdParty(&args);
+ });
+ // Include a dummy request which allows the request queue to be cleared. This
+ // ensures that requests may be queued up both during, and outside of, batch
+ // updates.
+ auto process_pending_requests = base::BindLambdaForTesting(
+ [&](std::string callback_id) { task_environment()->RunUntilIdle(); });
+
+ // For completeness, test every permutation of these calls.
+ std::vector<std::pair<int, base::RepeatingCallback<void(std::string)>>>
+ request_functions = {
+ {1, get_display_list_new_filter}, {2, get_display_list_same_filter},
+ {3, get_cookie_details}, {4, reload_cookies},
+ {5, remove_third_party}, {6, process_pending_requests},
+ };
+ auto request_function_ordering =
+ [](const std::pair<int, base::RepeatingCallback<void(std::string)>>& left,
+ std::pair<int, base::RepeatingCallback<void(std::string)>>& right) {
+ return left.first < right.first;
+ };
+ std::sort(request_functions.begin(), request_functions.end(),
+ request_function_ordering);
+
+ size_t expected_response_count = 0;
+ do {
+ for (const auto& function : request_functions) {
+ // Provide a unique callback ID for each request.
+ function.second.Run(
+ std::string(kCallbackId)
+ .append(base::NumberToString(expected_response_count)));
+
+ if (function.second != process_pending_requests)
+ expected_response_count++;
+ }
+ } while (std::next_permutation(request_functions.begin(),
+ request_functions.end(),
+ request_function_ordering));
+
+ task_environment()->RunUntilIdle();
+
+ // Ensure that callbacks have been fulfilled in the order they were queued.
+ ASSERT_EQ(expected_response_count, web_ui()->call_data().size());
+ for (size_t i = 0; i < expected_response_count; i++) {
+ EXPECT_EQ(std::string(kCallbackId).append(base::NumberToString(i)),
+ web_ui()->call_data()[i]->arg1()->GetString());
+ }
+}
+
+TEST_F(CookiesViewHandlerTest, ImmediateTreeOperation) {
+ // Check that a query which assumes a tree model to have been created
+ // previously results in a tree being created before the request is handled.
+ SetupTreeModelForTesting();
+
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString(kTestHost1);
+ handler()->HandleGetCookieDetails(&args);
+ task_environment()->RunUntilIdle();
+
+ // At this point the handler should have queued the creation of a tree and
+ // be awaiting batch completion.
+ NotifyTreeModel();
+ task_environment()->RunUntilIdle();
+
+ // Check that the returned information is accurate, despite not having
+ // previously loaded the tree.
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ(kCallbackId, data.arg1()->GetString());
+ EXPECT_EQ("cr.webUIResponse", data.function_name());
+ ASSERT_TRUE(data.arg2()->GetBool());
+
+ base::Value::ConstListView cookies_list = data.arg3()->GetList();
+ ASSERT_EQ(2UL, cookies_list.size());
+ EXPECT_EQ("cookie", cookies_list[0].FindKey("type")->GetString());
+ EXPECT_EQ("local_storage", cookies_list[1].FindKey("type")->GetString());
+}
+
+TEST_F(CookiesViewHandlerTest, HandleGetDisplayList) {
+ // Ensure that getting the display list works appropriately.
+ SetupHandlerWithTreeModel();
+
+ // Retrieve a filtered list.
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString(kTestHost1);
+
+ handler()->HandleGetDisplayList(&args);
+ task_environment()->RunUntilIdle();
+
+ 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 local_data_list = data.arg3()->GetList();
+ ASSERT_EQ(1U, local_data_list.size());
+ EXPECT_EQ(kTestHost1, local_data_list[0].FindKey("site")->GetString());
+ }
+
+ // Remove the filter and confirm the full list is returned.
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString("");
+
+ handler()->HandleGetDisplayList(&args);
+ task_environment()->RunUntilIdle();
+
+ 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 local_data_list = data.arg3()->GetList();
+ ASSERT_EQ(2U, local_data_list.size());
+ EXPECT_EQ(kTestHost1, local_data_list[0].FindKey("site")->GetString());
+ EXPECT_EQ(kTestHost2, local_data_list[1].FindKey("site")->GetString());
+ }
+}
+
+TEST_F(CookiesViewHandlerTest, HandleRemoveShownItems) {
+ // Ensure that removing shown items only removes items appropriate for the
+ // current filter.
+ SetupHandlerWithTreeModel();
+
+ // Apply a filter to the list and confirm it is returned.
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString(kTestHost2);
+ handler()->HandleGetDisplayList(&args);
+ task_environment()->RunUntilIdle();
+
+ 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 local_data_list = data.arg3()->GetList();
+ ASSERT_EQ(1U, local_data_list.size());
+ EXPECT_EQ(kTestHost2, local_data_list[0].FindKey("site")->GetString());
+ }
+
+ // Remove displayed items.
+ {
+ base::ListValue args;
+ handler()->HandleRemoveShownItems(&args);
+ task_environment()->RunUntilIdle();
+ }
+
+ // Remove the filter and confirm unremoved items are returned.
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString("");
+ handler()->HandleGetDisplayList(&args);
+ task_environment()->RunUntilIdle();
+
+ 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 local_data_list = data.arg3()->GetList();
+ ASSERT_EQ(1U, local_data_list.size());
+ EXPECT_EQ(kTestHost1, local_data_list[0].FindKey("site")->GetString());
+ }
+}
+
+TEST_F(CookiesViewHandlerTest, HandleGetCookieDetails) {
+ // Ensure that the cookie details are correctly returned for a site.
+ SetupHandlerWithTreeModel();
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString(kTestHost1);
+ handler()->HandleGetCookieDetails(&args);
+ task_environment()->RunUntilIdle();
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ(kCallbackId, data.arg1()->GetString());
+ EXPECT_EQ("cr.webUIResponse", data.function_name());
+ ASSERT_TRUE(data.arg2()->GetBool());
+
+ base::Value::ConstListView cookies_list = data.arg3()->GetList();
+ ASSERT_EQ(2UL, cookies_list.size());
+ EXPECT_EQ("cookie", cookies_list[0].FindKey("type")->GetString());
+ EXPECT_EQ("local_storage", cookies_list[1].FindKey("type")->GetString());
+}
+
+TEST_F(CookiesViewHandlerTest, HandleRemoveAll) {
+ // Ensure that RemoveAll removes all cookies & storage.
+ SetupHandlerWithTreeModel();
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ handler()->HandleRemoveAll(&args);
+ task_environment()->RunUntilIdle();
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ(kCallbackId, data.arg1()->GetString());
+ EXPECT_EQ("cr.webUIResponse", data.function_name());
+ ASSERT_TRUE(data.arg2()->GetBool());
+ }
+
+ // Ensure returned display list is empty.
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString("");
+ handler()->HandleGetDisplayList(&args);
+ task_environment()->RunUntilIdle();
+
+ 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 local_data_list = data.arg3()->GetList();
+ ASSERT_EQ(0U, local_data_list.size());
+ }
+}
+
+TEST_F(CookiesViewHandlerTest, HandleRemoveItem) {
+ // Delete an individual piece of site data. This requires first getting the
+ // node path ID via the HandleGetCookieDetails function.
+ SetupHandlerWithTreeModel();
+
+ // Get the appropriate path for removal.
+ std::string node_path_id;
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString(kTestHost1);
+ handler()->HandleGetCookieDetails(&args);
+ task_environment()->RunUntilIdle();
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ base::Value::ConstListView cookies_list = data.arg3()->GetList();
+ ASSERT_EQ(2UL, cookies_list.size());
+ // Find the entry item associated with the kTestCookie1 cookie.
+ for (const auto& cookie : cookies_list) {
+ if (cookie.FindKey("type")->GetString() == "cookie")
+ node_path_id = cookie.FindKey("idPath")->GetString();
+ }
+ }
+
+ // Remove path and ensure that the removed item listener fires.
+ {
+ base::ListValue args;
+ args.AppendString(node_path_id);
+ handler()->HandleRemoveItem(&args);
+ task_environment()->RunUntilIdle();
+
+ // Removal should fire an update event.
+ const content::TestWebUI::CallData& all_data =
+ *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIListenerCallback", all_data.function_name());
+ EXPECT_EQ("on-tree-item-removed", all_data.arg1()->GetString());
+ }
+
+ // Ensure that the removed item is no longer present in cookie details.
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString(kTestHost1);
+ handler()->HandleGetCookieDetails(&args);
+ task_environment()->RunUntilIdle();
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ base::Value::ConstListView cookies_list = data.arg3()->GetList();
+ ASSERT_EQ(1UL, cookies_list.size());
+ EXPECT_EQ("local_storage", cookies_list[0].FindKey("type")->GetString());
+ }
+}
+
+TEST_F(CookiesViewHandlerTest, HandleRemoveSite) {
+ SetupHandlerWithTreeModel();
+
+ // Check that removing a single site works.
+ {
+ base::ListValue args;
+ args.AppendString(kTestHost1);
+ handler()->HandleRemoveSite(&args);
+ task_environment()->RunUntilIdle();
+
+ // Removal should fire an update event.
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
+ EXPECT_EQ("on-tree-item-removed", data.arg1()->GetString());
+ }
+
+ // Check that the removed site is no longer present in the display list.
+ {
+ base::ListValue args;
+ args.AppendString(kCallbackId);
+ args.AppendString("");
+ handler()->HandleGetDisplayList(&args);
+ task_environment()->RunUntilIdle();
+
+ 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 local_data_list = data.arg3()->GetList();
+ ASSERT_EQ(1U, local_data_list.size());
+ EXPECT_EQ(kTestHost2, local_data_list[0].FindKey("site")->GetString());
+ }
}
} // namespace settings
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 2e81b4eb893..3cbe948cb6d 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
@@ -50,8 +50,8 @@ void DefaultBrowserHandler::OnJavascriptAllowed() {
local_state_pref_registrar_.Init(prefs);
local_state_pref_registrar_.Add(
prefs::kDefaultBrowserSettingEnabled,
- base::Bind(&DefaultBrowserHandler::RequestDefaultBrowserState,
- base::Unretained(this), nullptr));
+ base::BindRepeating(&DefaultBrowserHandler::RequestDefaultBrowserState,
+ base::Unretained(this), nullptr));
default_browser_worker_ = new shell_integration::DefaultBrowserWorker();
}
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 75a0d71b25f..f384bc355db 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
@@ -17,23 +17,25 @@
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/obsolete_system/obsolete_system.h"
+#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings.h"
+#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/browser/ui/ui_features.h"
-#include "chrome/browser/ui/webui/management_ui.h"
+#include "chrome/browser/ui/webui/management/management_ui.h"
#include "chrome/browser/ui/webui/policy_indicator_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/reset_settings_handler.h"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
-#include "chrome/browser/ui/webui/version_ui.h"
+#include "chrome/browser/ui/webui/version/version_ui.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
@@ -90,25 +92,25 @@
#include "ui/base/webui/web_ui_util.h"
#include "ui/strings/grit/ui_strings.h"
-#if BUILDFLAG(IS_LACROS)
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/lacros/account_manager_util.h"
-#endif // BUILDFLAG(IS_LACROS)
+#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/constants/ash_features.h"
#include "ash/public/cpp/ash_switches.h"
-#include "chrome/browser/chromeos/account_manager/account_manager_util.h"
-#include "chrome/browser/chromeos/assistant/assistant_util.h"
+#include "chrome/browser/ash/account_manager/account_manager_util.h"
+#include "chrome/browser/ash/assistant/assistant_util.h"
+#include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.h"
#include "chrome/browser/chromeos/kerberos/kerberos_credentials_manager.h"
-#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/common/webui_url_constants.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/user_manager/user_manager.h"
#include "ui/chromeos/devicetype_utils.h"
-#else // !defined(OS_CHROMEOS)
+#else // !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/webui/settings/system_handler.h"
#include "ui/accessibility/accessibility_features.h"
#endif
@@ -156,7 +158,7 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"moreActions", IDS_SETTINGS_MORE_ACTIONS},
{"ok", IDS_OK},
{"restart", IDS_SETTINGS_RESTART},
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
{"restartToApplyChanges", IDS_SETTINGS_RESTART_TO_APPLY_CHANGES},
#endif
{"retry", IDS_SETTINGS_RETRY},
@@ -183,11 +185,11 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"large", IDS_SETTINGS_LARGE_FONT},
{"veryLarge", IDS_SETTINGS_VERY_LARGE_FONT},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean(
"isGuest",
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
user_manager::UserManager::Get()->IsLoggedInAsPublicAccount());
#else
@@ -215,16 +217,15 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_SUBTITLE},
{"caretBrowsingTitle", IDS_SETTINGS_ENABLE_CARET_BROWSING_TITLE},
{"caretBrowsingSubtitle", IDS_SETTINGS_ENABLE_CARET_BROWSING_SUBTITLE},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"manageAccessibilityFeatures",
IDS_SETTINGS_ACCESSIBILITY_MANAGE_ACCESSIBILITY_FEATURES},
- {"androidAppsManageAppLinks", IDS_SETTINGS_ANDROID_APPS_MANAGE_APP_LINKS},
-#else // !defined(OS_CHROMEOS)
+#else // !BUILDFLAG(IS_CHROMEOS_ASH)
{"focusHighlightLabel",
IDS_SETTINGS_ACCESSIBILITY_FOCUS_HIGHLIGHT_DESCRIPTION},
#endif
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
#if defined(OS_WIN)
html_source->AddBoolean("isWindows10OrNewer",
@@ -234,7 +235,7 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
"showExperimentalA11yLabels",
base::FeatureList::IsEnabled(features::kExperimentalAccessibilityLabels));
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
html_source->AddBoolean(
"showFocusHighlightOption",
base::FeatureList::IsEnabled(features::kAccessibilityFocusHighlight));
@@ -261,18 +262,18 @@ 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 defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"aboutUpdateOsSettingsLink",
IDS_SETTINGS_ABOUT_SEE_OS_SETTINGS_FOR_UPDATE_MESSAGE},
#endif
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString("managementPage",
ManagementUI::GetManagementPageSubtitle(profile));
html_source->AddString(
"aboutUpgradeUpToDate",
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
ui::SubstituteChromeOSDeviceType(IDS_SETTINGS_UPGRADE_UP_TO_DATE));
#else
l10n_util::GetStringUTF16(IDS_SETTINGS_UPGRADE_UP_TO_DATE));
@@ -341,15 +342,19 @@ 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},
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
+// of lacros-chrome is complete.
+#if defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
{"systemTheme", IDS_SETTINGS_SYSTEM_THEME},
{"useSystemTheme", IDS_SETTINGS_USE_SYSTEM_THEME},
{"classicTheme", IDS_SETTINGS_CLASSIC_THEME},
{"useClassicTheme", IDS_SETTINGS_USE_CLASSIC_THEME},
- {"showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS},
#else
{"resetToDefaultTheme", IDS_SETTINGS_RESET_TO_DEFAULT_THEME},
#endif
+#if defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)
+ {"showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS},
+#endif
#if defined(OS_MAC)
{"tabsToLinks", IDS_SETTINGS_TABS_TO_LINKS_PREF},
{"warnBeforeQuitting", IDS_SETTINGS_WARN_BEFORE_QUITTING_PREF},
@@ -357,7 +362,7 @@ void AddAppearanceStrings(content::WebUIDataSource* html_source,
{"readerMode", IDS_SETTINGS_READER_MODE},
{"readerModeDescription", IDS_SETTINGS_READER_MODE_DESCRIPTION},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString("presetZoomFactors",
zoom::GetPresetZoomFactorsAsJSON());
@@ -429,10 +434,10 @@ void AddClearBrowsingDataStrings(content::WebUIDataSource* html_source,
IDS_CLEAR_BROWSING_DATA_PASSWORDS_NOTICE,
l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK)));
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_CHROMEOS_LACROS)
void AddDefaultBrowserStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"defaultBrowser", IDS_SETTINGS_DEFAULT_BROWSER},
@@ -443,7 +448,7 @@ void AddDefaultBrowserStrings(content::WebUIDataSource* html_source) {
{"defaultBrowserError", IDS_SETTINGS_DEFAULT_BROWSER_ERROR},
{"defaultBrowserSecondary", IDS_SETTINGS_DEFAULT_BROWSER_SECONDARY},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
#endif
@@ -456,7 +461,7 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) {
{"openFileTypesAutomatically",
IDS_SETTINGS_OPEN_FILE_TYPES_AUTOMATICALLY},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
@@ -468,8 +473,6 @@ void AddChromeCleanupStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"chromeCleanupPageTitle",
IDS_SETTINGS_RESET_CLEAN_UP_COMPUTER_PAGE_TITLE},
- {"chromeCleanupDetailsExtensions",
- IDS_SETTINGS_RESET_CLEANUP_DETAILS_EXTENSIONS},
{"chromeCleanupDetailsFilesAndPrograms",
IDS_SETTINGS_RESET_CLEANUP_DETAILS_FILES_AND_PROGRAMS},
{"chromeCleanupDetailsRegistryEntries",
@@ -527,7 +530,7 @@ void AddChromeCleanupStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_RESET_CLEANUP_EXPLANATION_CLEANUP_UNAVAILABLE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
const std::string cleanup_learn_more_url =
google_util::AppendGoogleLocaleParam(
GURL(chrome::kChromeCleanerLearnMoreURL),
@@ -573,7 +576,7 @@ void AddIncompatibleApplicationsStrings(content::WebUIDataSource* html_source) {
{"incompatibleApplicationsDone",
IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_DONE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
// The help URL is provided via Field Trial param. If none is provided, the
// "Learn How" text is left empty so that no link is displayed.
@@ -617,7 +620,7 @@ void AddResetStrings(content::WebUIDataSource* html_source, Profile* profile) {
IDS_SETTINGS_RESET_CLEAN_UP_COMPUTER_TRIGGER},
#endif
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean(
"showResetProfileBanner",
@@ -636,7 +639,7 @@ void AddResetStrings(content::WebUIDataSource* html_source, Profile* profile) {
chrome::kAutomaticSettingsResetLearnMoreURL);
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void AddImportDataStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"importTitle", IDS_SETTINGS_IMPORT_SETTINGS_TITLE},
@@ -654,7 +657,7 @@ void AddImportDataStrings(content::WebUIDataSource* html_source) {
{"noProfileFound", IDS_SETTINGS_IMPORT_NO_PROFILE_FOUND},
{"importSuccess", IDS_SETTINGS_IMPORT_SUCCESS},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
#endif
@@ -714,9 +717,9 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_LANGUAGES_DICTIONARY_DOWNLOAD_FAILED_HELP},
#endif
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Only the Chrome OS help article explains how language order affects website
// language.
html_source->AddString(
@@ -730,7 +733,7 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source,
"languagesPageTitle",
l10n_util::GetStringUTF16(IDS_SETTINGS_LANGUAGES_PAGE_TITLE));
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
user_manager::UserManager* user_manager = user_manager::UserManager::Get();
const user_manager::User* user =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
@@ -750,16 +753,11 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source,
base::FeatureList::IsEnabled(
chromeos::features::kLanguageSettingsUpdate));
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
-#if defined(OS_CHROMEOS)
-void AddChromeOSUserStrings(content::WebUIDataSource* html_source,
- Profile* profile) {
- user_manager::UserManager* user_manager = user_manager::UserManager::Get();
-
- const user_manager::User* primary_user = user_manager->GetPrimaryUser();
- std::string primary_user_email = primary_user->GetAccountId().GetUserEmail();
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+void AddChromeOSSettingsStrings(content::WebUIDataSource* html_source) {
html_source->AddString(
"osSettingsBannerText",
l10n_util::GetStringFUTF16(
@@ -782,7 +780,7 @@ void AddOnStartupStrings(content::WebUIDataSource* html_source) {
{"onStartupInvalidUrl", IDS_SETTINGS_INVALID_URL},
{"onStartupUrlTooLong", IDS_SETTINGS_URL_TOOL_LONG},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
bool IsFidoAuthenticationAvailable(autofill::PersonalDataManager* personal_data,
@@ -890,6 +888,7 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
{"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},
{"removeAddress", IDS_SETTINGS_ADDRESS_REMOVE},
{"removeAddressConfirmationTitle",
IDS_SETTINGS_ADDRESS_REMOVE_CONFIRMATION_TITLE},
@@ -972,6 +971,12 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_ACCOUNT},
{"passwordDeletedFromAccountAndDevice",
IDS_SETTINGS_PASSWORD_DELETED_PASSWORD_FROM_ACCOUNT_AND_DEVICE},
+ {"passwordMovePasswordsToAccount",
+ IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT},
+ {"passwordMovePasswordsToAccountDialogFooter",
+ IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT_DIALOG_FOOTER},
+ {"passwordMovePasswordsToAccountDialogTitle",
+ IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT_DIALOG_TITLE},
{"passwordMoveToAccountDialogTitle",
IDS_SETTINGS_PASSWORD_MOVE_TO_ACCOUNT_DIALOG_TITLE},
{"passwordMoveToAccountDialogBody",
@@ -980,6 +985,8 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
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",
@@ -990,12 +997,9 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_FROM_ACCOUNT_CHECKBOX_LABEL},
{"passwordRemoveDialogFromDeviceCheckboxLabel",
IDS_SETTINGS_PASSWORD_REMOVE_DIALOG_FROM_DEVICE_CHECKBOX_LABEL},
- {"devicePasswordsLinkLabelSingular",
- IDS_SETTINGS_DEVICE_PASSWORDS_LINK_LABEL_SINGULAR},
- {"devicePasswordsLinkLabelPlural",
- IDS_SETTINGS_DEVICE_PASSWORDS_LINK_LABEL_PLURAL},
- {"devicePasswordsLinkSubLabel",
- IDS_SETTINGS_DEVICE_PASSWORDS_LINK_SUB_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},
@@ -1080,12 +1084,12 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
base::ASCIIToUTF16(chrome::kSyncLearnMoreURL)));
bool is_guest_mode = false;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
is_guest_mode = user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
user_manager::UserManager::Get()->IsLoggedInAsPublicAccount();
-#else // !defined(OS_CHROMEOS)
+#else // !BUILDFLAG(IS_CHROMEOS_ASH)
is_guest_mode = profile->IsOffTheRecord();
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
autofill::PersonalDataManager* personal_data =
autofill::PersonalDataManagerFactory::GetForProfile(profile);
html_source->AddBoolean(
@@ -1110,15 +1114,16 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
autofill::features::kAutofillSaveAndFillVPA));
html_source->AddBoolean(
- "nicknameManagementEnabled",
+ "showHonorific",
base::FeatureList::IsEnabled(
- autofill::features::kAutofillEnableCardNicknameManagement));
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ autofill::features::kAutofillEnableSupportForHonorificPrefixes));
+
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddSignOutDialogStrings(content::WebUIDataSource* html_source,
Profile* profile) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
bool is_dice_enabled = false;
bool use_browser_sync_consent =
chromeos::features::ShouldUseBrowserSyncConsent();
@@ -1134,13 +1139,13 @@ void AddSignOutDialogStrings(content::WebUIDataSource* html_source,
{"syncDisconnectTitle",
IDS_SETTINGS_TURN_OFF_SYNC_AND_SIGN_OUT_DIALOG_TITLE},
};
- AddLocalizedStringsBulk(html_source, kTurnOffStrings);
+ html_source->AddLocalizedStrings(kTurnOffStrings);
} else {
static constexpr webui::LocalizedString kSignOutStrings[] = {
{"syncDisconnect", IDS_SETTINGS_PEOPLE_SIGN_OUT},
{"syncDisconnectTitle", IDS_SETTINGS_SYNC_DISCONNECT_TITLE},
};
- AddLocalizedStringsBulk(html_source, kSignOutStrings);
+ html_source->AddLocalizedStrings(kSignOutStrings);
}
std::string sync_dashboard_url =
@@ -1158,14 +1163,14 @@ void AddSignOutDialogStrings(content::WebUIDataSource* html_source,
{"syncDisconnectExplanation",
IDS_SETTINGS_SYNC_DISCONNECT_AND_SIGN_OUT_EXPLANATION},
};
- AddLocalizedStringsBulk(html_source, kSyncDisconnectStrings);
+ html_source->AddLocalizedStrings(kSyncDisconnectStrings);
} else {
static constexpr webui::LocalizedString kSyncDisconnectStrings[] = {
{"syncDisconnectDeleteProfile",
IDS_SETTINGS_SYNC_DISCONNECT_DELETE_PROFILE},
{"syncDisconnectConfirm", IDS_SETTINGS_SYNC_DISCONNECT_CONFIRM},
};
- AddLocalizedStringsBulk(html_source, kSyncDisconnectStrings);
+ html_source->AddLocalizedStrings(kSyncDisconnectStrings);
html_source->AddString(
"syncDisconnectExplanation",
@@ -1173,7 +1178,7 @@ void AddSignOutDialogStrings(content::WebUIDataSource* html_source,
base::ASCIIToUTF16(sync_dashboard_url)));
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
html_source->AddString(
"syncDisconnectManagedProfileExplanation",
l10n_util::GetStringFUTF8(
@@ -1195,14 +1200,15 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"manageGoogleAccount", IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT},
{"syncAndNonPersonalizedServices",
IDS_SETTINGS_SYNC_SYNC_AND_NON_PERSONALIZED_SERVICES},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"accountManagerSubMenuLabel", IDS_SETTINGS_ACCOUNT_MANAGER_SUBMENU_LABEL},
#else
- {"profileNameAndPicture", IDS_SETTINGS_PROFILE_NAME_AND_PICTURE},
+ {"editPerson", IDS_SETTINGS_CUSTOMIZE_PROFILE},
+ {"profileNameAndPicture", IDS_SETTINGS_CUSTOMIZE_YOUR_CHROME_PROFILE},
#endif
// Manage profile strings:
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
{"showShortcutLabel", IDS_SETTINGS_PROFILE_SHORTCUT_TOGGLE_LABEL},
{"nameInputLabel", IDS_SETTINGS_PROFILE_NAME_INPUT_LABEL},
{"nameYourProfile", IDS_SETTING_NAME_YOUR_PROFILE},
@@ -1226,7 +1232,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"deleteProfileWarningWithoutCounts",
IDS_SETTINGS_SYNC_DISCONNECT_DELETE_PROFILE_WARNING_WITHOUT_COUNTS},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
// Add Google Account URL and include UTM parameter to signal the source of
// the navigation.
@@ -1237,18 +1243,12 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
.spec());
html_source->AddBoolean("profileShortcutsEnabled",
ProfileShortcutManager::IsFeatureEnabled());
-#if !defined(OS_CHROMEOS)
- html_source->AddLocalizedString(
- "editPerson", base::FeatureList::IsEnabled(features::kNewProfilePicker)
- ? IDS_SETTINGS_CUSTOMIZE_PROFILE
- : IDS_SETTINGS_EDIT_PERSON);
-#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Toggles the Chrome OS Account Manager submenu in the People section.
html_source->AddBoolean("isAccountManagerEnabled",
- chromeos::IsAccountManagerAvailable(profile));
-#elif BUILDFLAG(IS_LACROS)
+ ash::IsAccountManagerAvailable(profile));
+#elif BUILDFLAG(IS_CHROMEOS_LACROS)
html_source->AddBoolean("isAccountManagerEnabled",
IsAccountManagerAvailable(profile));
#endif
@@ -1256,7 +1256,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
AddSignOutDialogStrings(html_source, profile);
AddSyncControlsStrings(html_source);
AddSyncAccountControlStrings(html_source);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
AddPasswordPromptDialogStrings(html_source);
#endif
AddSyncPageStrings(html_source);
@@ -1267,10 +1267,6 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"privacyPageTitle", IDS_SETTINGS_PRIVACY},
{"privacyPageMore", IDS_SETTINGS_PRIVACY_MORE},
- // TODO(crbug.com/1116608): This seemingly unrelated string resource is
- // used because it already has a localized version available in M85, so
- // we can ship this label in M85 on short notice.
- {"discardedPerSiteSetting", IDS_POLICY_LABEL_IGNORED},
{"doNotTrack", IDS_SETTINGS_ENABLE_DO_NOT_TRACK},
{"doNotTrackDialogTitle", IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TITLE},
// TODO(crbug.com/1062607): This string is no longer used. Remove.
@@ -1313,6 +1309,8 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
{"siteSettings", IDS_SETTINGS_SITE_SETTINGS},
{"siteSettingsDescription", IDS_SETTINGS_SITE_SETTINGS_DESCRIPTION},
{"clearData", IDS_SETTINGS_CLEAR_DATA},
+ {"clearingData", IDS_SETTINGS_CLEARING_DATA},
+ {"clearedData", IDS_SETTINGS_CLEARED_DATA},
{"clearBrowsingData", IDS_SETTINGS_CLEAR_BROWSING_DATA},
{"clearBrowsingDataDescription", IDS_SETTINGS_CLEAR_DATA_DESCRIPTION},
{"titleAndCount", IDS_SETTINGS_TITLE_AND_COUNT},
@@ -1322,6 +1320,8 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SAFEBROWSING_ENABLE_REPORTING_DESC},
{"safeBrowsingEnhanced", IDS_SETTINGS_SAFEBROWSING_ENHANCED},
{"safeBrowsingEnhancedDesc", IDS_SETTINGS_SAFEBROWSING_ENHANCED_DESC},
+ {"safeBrowsingEnhancedExpandA11yLabel",
+ IDS_SETTINGS_SAFEBROWSING_ENHANCED_EXPAND_ACCESSIBILITY_LABEL},
{"safeBrowsingEnhancedBulOne",
IDS_SETTINGS_SAFEBROWSING_ENHANCED_BULLET_ONE},
{"safeBrowsingEnhancedBulTwo",
@@ -1334,6 +1334,8 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SAFEBROWSING_ENHANCED_BULLET_FIVE},
{"safeBrowsingStandard", IDS_SETTINGS_SAFEBROWSING_STANDARD},
{"safeBrowsingStandardDesc", IDS_SETTINGS_SAFEBROWSING_STANDARD_DESC},
+ {"safeBrowsingStandardExpandA11yLabel",
+ IDS_SETTINGS_SAFEBROWSING_STANDARD_EXPAND_ACCESSIBILITY_LABEL},
{"safeBrowsingStandardBulOne",
IDS_SETTINGS_SAFEBROWSING_STANDARD_BULLET_ONE},
{"safeBrowsingStandardBulTwo",
@@ -1360,31 +1362,24 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
{"urlKeyedAnonymizedDataCollectionDesc",
IDS_SETTINGS_ENABLE_URL_KEYED_ANONYMIZED_DATA_COLLECTION_DESC},
{"noRecentPermissions", IDS_SETTINGS_RECENT_PERMISSIONS_NO_CHANGES},
- {"recentPermissionChangeAutoblockedSentenceStart",
- IDS_SETTINGS_RECENT_PERMISSIONS_CHANGE_AUTOBLOCKED_SENTENCE_START},
- {"recentPermissionChangeBlockedSentenceStart",
- IDS_SETTINGS_RECENT_PERMISSIONS_CHANGE_BLOCKED_SENTENCE_START},
- {"recentPermissionChangeAllowedSentenceStart",
- IDS_SETTINGS_RECENT_PERMISSIONS_CHANGE_ALLOWED_SENTENCE_START},
- {"recentPermissionChangeAutoblocked",
- IDS_SETTINGS_RECENT_PERMISSIONS_CHANGE_AUTOBLOCKED},
- {"recentPermissionChangeBlocked",
- IDS_SETTINGS_RECENT_PERMISSIONS_CHANGE_BLOCKED},
- {"recentPermissionChangeAllowed",
- IDS_SETTINGS_RECENT_PERMISSIONS_CHANGE_ALLOWED},
- {"recentPermissionsTwoItems", IDS_SETTINGS_RECENT_PERMISSIONS_TWO_ITEMS},
- {"recentPermissionsThreeItems",
- IDS_SETTINGS_RECENT_PERMISSIONS_THREE_ITEMS},
- {"recentPermissionsOverThreeItems",
- IDS_SETTINGS_RECENT_PERMISSIONS_OVER_THREE_ITEMS},
- {"recentPermissionsOneItemIncognito",
- IDS_SETTINGS_RECENT_PERMISSIONS_ONE_ITEM_INCOGNITO},
- {"recentPermissionsTwoItemsIncognito",
- IDS_SETTINGS_RECENT_PERMISSIONS_TWO_ITEMS_INCOGNITO},
- {"recentPermissionsThreeItemsIncognito",
- IDS_SETTINGS_RECENT_PERMISSIONS_THREE_ITEMS_INCOGNITO},
- {"recentPermissionsOverThreeItemsIncognito",
- IDS_SETTINGS_RECENT_PERMISSIONS_OVER_THREE_ITEMS_INCOGNITO},
+ {"recentPermissionAllowedOneItem",
+ IDS_SETTINGS_RECENT_PERMISSIONS_ALLOWED_ONE_ITEM},
+ {"recentPermissionAllowedTwoItems",
+ IDS_SETTINGS_RECENT_PERMISSIONS_ALLOWED_TWO_ITEMS},
+ {"recentPermissionAllowedMoreThanTwoItems",
+ IDS_SETTINGS_RECENT_PERMISSIONS_ALLOWED_MORE_THAN_TWO_ITEMS},
+ {"recentPermissionAutoBlockedOneItem",
+ IDS_SETTINGS_RECENT_PERMISSIONS_AUTOMATICALLY_BLOCKED_ONE_ITEM},
+ {"recentPermissionAutoBlockedTwoItems",
+ IDS_SETTINGS_RECENT_PERMISSIONS_AUTOMATICALLY_BLOCKED_TWO_ITEMS},
+ {"recentPermissionAutoBlockedMoreThanTwoItems",
+ IDS_SETTINGS_RECENT_PERMISSIONS_AUTOMATICALLY_BLOCKED_MORE_THAN_TWO_ITEMS},
+ {"recentPermissionBlockedOneItem",
+ IDS_SETTINGS_RECENT_PERMISSIONS_BLOCKED_ONE_ITEM},
+ {"recentPermissionBlockedTwoItems",
+ IDS_SETTINGS_RECENT_PERMISSIONS_BLOCKED_TWO_ITEMS},
+ {"recentPermissionBlockedMoreThanTwoItems",
+ IDS_SETTINGS_RECENT_PERMISSIONS_BLOCKED_MORE_THAN_TWO_ITEMS},
{"networkPredictionEnabled",
IDS_SETTINGS_NETWORK_PREDICTION_ENABLED_LABEL},
{"networkPredictionEnabledDesc",
@@ -1392,7 +1387,7 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
{"networkPredictionEnabledDescCookiesPage",
IDS_SETTINGS_NETWORK_PREDICTION_ENABLED_DESC_COOKIES_PAGE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString("cookiesSettingsHelpCenterURL",
chrome::kCookiesSettingsHelpCenterURL);
@@ -1436,6 +1431,61 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
AddPersonalizationOptionsStrings(html_source);
}
+void AddPrivacySandboxStrings(content::WebUIDataSource* html_source,
+ Profile* profile) {
+ // Strings used outside the privacy sandbox page. The i18n preprocessor might
+ // replace those before the corresponding flag value is checked, which is why
+ // they are included independently of the flag value.
+ static constexpr webui::LocalizedString kLocalizedStrings[] = {
+ {"privacySandboxTitle", IDS_SETTINGS_PRIVACY_SANDBOX_TITLE},
+ {"privacySandboxTrialsEnabled",
+ IDS_SETTINGS_PRIVACY_SANDBOX_TRIALS_ENABLED},
+ {"privacySandboxTrialsDisabled",
+ IDS_SETTINGS_PRIVACY_SANDBOX_TRIALS_DISABLED},
+ {"privacySandboxCookiesDialog",
+ IDS_SETTINGS_PRIVACY_SANDBOX_COOKIES_DIALOG},
+ {"privacySandboxCookiesDialogMore",
+ IDS_SETTINGS_PRIVACY_SANDBOX_COOKIES_DIALOG_MORE},
+ };
+ html_source->AddLocalizedStrings(kLocalizedStrings);
+
+ // Strings that only need to be available when the flag is enabled.
+ if (PrivacySandboxSettingsFactory::GetForProfile(profile)
+ ->PrivacySandboxSettingsFunctional()) {
+ static constexpr webui::LocalizedString kLocalizedStringsBehindFlag[] = {
+ {"privacySandboxPageHeading",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_HEADING},
+ {"privacySandboxPageExplanation1",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_EXPLANATION1},
+ {"privacySandboxPageExplanation2",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_EXPLANATION2},
+ {"privacySandboxPageExplanation3",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_EXPLANATION3},
+ {"privacySandboxPageSettingTitle",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_SETTING_TITLE},
+ {"privacySandboxPageSettingExplanation1",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_SETTING_EXPLANATION1},
+ {"privacySandboxPageSettingExplanation2",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_SETTING_EXPLANATION2},
+ {"privacySandboxPageSettingExplanation3",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_SETTING_EXPLANATION3},
+ {"privacySandboxPageDetails",
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_DETAILS},
+ };
+ html_source->AddLocalizedStrings(kLocalizedStringsBehindFlag);
+
+ // TODO(crbug/1152336): Solidify the final URL in code once the website is
+ // launched.
+ html_source->AddString("privacySandboxURL",
+ features::kPrivacySandboxSettingsURL.Get());
+ html_source->AddString(
+ "privacySandboxPageExplanation4",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_PRIVACY_SANDBOX_PAGE_EXPLANATION4,
+ base::ASCIIToUTF16(features::kPrivacySandboxSettingsURL.Get())));
+ }
+}
+
void AddSafetyCheckStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"safetyCheckSectionTitle", IDS_SETTINGS_SAFETY_CHECK_SECTION_TITLE},
@@ -1449,8 +1499,8 @@ void AddSafetyCheckStrings(content::WebUIDataSource* html_source) {
{"safetyCheckParentButton", IDS_SETTINGS_SAFETY_CHECK_PARENT_BUTTON},
{"safetyCheckParentButtonAriaLabel",
IDS_SETTINGS_SAFETY_CHECK_PARENT_BUTTON_ARIA_LABEL},
- {"safetyCheckParentButtonAriaLabelReload",
- IDS_SETTINGS_CHECK_PASSWORDS_AGAIN},
+ {"safetyCheckParentRunAgainButtonAriaLabel",
+ IDS_SETTINGS_SAFETY_CHECK_PARENT_RUN_AGAIN_BUTTON_ARIA_LABEL},
{"safetyCheckIconRunningAriaLabel",
IDS_SETTINGS_SAFETY_CHECK_ICON_RUNNING_ARIA_LABEL},
{"safetyCheckIconSafeAriaLabel",
@@ -1480,7 +1530,7 @@ void AddSafetyCheckStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_SAFETY_CHECK_CHROME_CLEANER_BUTTON_ARIA_LABEL},
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddSearchInSettingsStrings(content::WebUIDataSource* html_source) {
@@ -1490,7 +1540,7 @@ void AddSearchInSettingsStrings(content::WebUIDataSource* html_source) {
{"searchResults", IDS_SEARCH_RESULTS},
{"clearSearch", IDS_CLEAR_SEARCH},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
base::string16 help_text = l10n_util::GetStringFUTF16(
IDS_SETTINGS_SEARCH_NO_RESULTS_HELP,
@@ -1504,7 +1554,7 @@ void AddSearchStrings(content::WebUIDataSource* html_source) {
{"searchPageTitle", IDS_SETTINGS_SEARCH},
{"searchExplanation", IDS_SETTINGS_SEARCH_EXPLANATION},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString("searchExplanationLearnMoreURL",
base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL));
@@ -1535,7 +1585,7 @@ void AddSearchEnginesStrings(content::WebUIDataSource* html_source) {
{"searchEnginesManageExtension",
IDS_SETTINGS_SEARCH_ENGINES_MANAGE_EXTENSION},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
@@ -1543,7 +1593,7 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"addSite", IDS_SETTINGS_ADD_SITE},
{"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{"androidSmsNote", IDS_SETTINGS_ANDROID_SMS_NOTE},
#endif
{"appCacheOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL},
@@ -1666,25 +1716,50 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_SITE_REPRESENTATION_SEPARATOR},
{"siteSettingsAutomaticDownloads",
IDS_SETTINGS_SITE_SETTINGS_AUTOMATIC_DOWNLOADS},
+ {"siteSettingsAutomaticDownloadsMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_AUTOMATIC_DOWNLOADS_MID_SENTENCE},
{"siteSettingsBackgroundSync", IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC},
+ {"siteSettingsBackgroundSyncMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC_MID_SENTENCE},
{"siteSettingsCamera", IDS_SETTINGS_SITE_SETTINGS_CAMERA},
+ {"siteSettingsCameraMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_CAMERA_MID_SENTENCE},
{"siteSettingsClipboard", IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD},
+ {"siteSettingsClipboardMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_MID_SENTENCE},
{"siteSettingsClipboardAsk", IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_ASK},
{"siteSettingsClipboardAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_ASK_RECOMMENDED},
{"siteSettingsClipboardBlock", IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_BLOCK},
{"siteSettingsCookies", IDS_SETTINGS_SITE_SETTINGS_COOKIES},
+ {"siteSettingsCookiesMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_COOKIES_MID_SENTENCE},
{"siteSettingsHandlers", IDS_SETTINGS_SITE_SETTINGS_HANDLERS},
+ {"siteSettingsHandlersMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_HANDLERS_MID_SENTENCE},
{"siteSettingsLocation", IDS_SETTINGS_SITE_SETTINGS_LOCATION},
+ {"siteSettingsLocationMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_LOCATION_MID_SENTENCE},
{"siteSettingsMic", IDS_SETTINGS_SITE_SETTINGS_MIC},
+ {"siteSettingsMicMidSentence", IDS_SETTINGS_SITE_SETTINGS_MIC_MID_SENTENCE},
{"siteSettingsNotifications", IDS_SETTINGS_SITE_SETTINGS_NOTIFICATIONS},
+ {"siteSettingsNotificationsMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_NOTIFICATIONS_MID_SENTENCE},
{"siteSettingsImages", IDS_SETTINGS_SITE_SETTINGS_IMAGES},
+ {"siteSettingsImagesMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_IMAGES_MID_SENTENCE},
{"siteSettingsInsecureContent",
IDS_SETTINGS_SITE_SETTINGS_INSECURE_CONTENT},
+ {"siteSettingsInsecureContentMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_INSECURE_CONTENT_MID_SENTENCE},
{"siteSettingsInsecureContentBlock",
IDS_SETTINGS_SITE_SETTINGS_INSECURE_CONTENT_BLOCK},
{"siteSettingsJavascript", IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT},
+ {"siteSettingsJavascriptMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_MID_SENTENCE},
{"siteSettingsSound", IDS_SETTINGS_SITE_SETTINGS_SOUND},
+ {"siteSettingsSoundMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_SOUND_MID_SENTENCE},
{"siteSettingsSoundAllow", IDS_SETTINGS_SITE_SETTINGS_SOUND_ALLOW},
{"siteSettingsSoundAllowRecommended",
IDS_SETTINGS_SITE_SETTINGS_SOUND_ALLOW_RECOMMENDED},
@@ -1698,32 +1773,42 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_IDENTIFIERS},
{"siteSettingsProtectedContentEnable",
IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_ENABLE},
-#if defined(OS_CHROMEOS) || defined(OS_WIN)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN)
{"siteSettingsProtectedContentIdentifiersExplanation",
IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_IDENTIFIERS_EXPLANATION},
{"siteSettingsProtectedContentEnableIdentifiers",
IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_ENABLE_IDENTIFIERS},
#endif
{"siteSettingsPopups", IDS_SETTINGS_SITE_SETTINGS_POPUPS},
+ {"siteSettingsPopupsMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_POPUPS_MID_SENTENCE},
{"siteSettingsHidDevices", IDS_SETTINGS_SITE_SETTINGS_HID_DEVICES},
+ {"siteSettingsHidDevicesMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_HID_DEVICES_MID_SENTENCE},
{"siteSettingsHidDevicesAsk", IDS_SETTINGS_SITE_SETTINGS_HID_DEVICES_ASK},
{"siteSettingsHidDevicesAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_HID_DEVICES_ASK_RECOMMENDED},
{"siteSettingsHidDevicesBlock",
IDS_SETTINGS_SITE_SETTINGS_HID_DEVICES_BLOCK},
{"siteSettingsMidiDevices", IDS_SETTINGS_SITE_SETTINGS_MIDI_DEVICES},
+ {"siteSettingsMidiDevicesMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_MIDI_DEVICES_MID_SENTENCE},
{"siteSettingsMidiDevicesAsk", IDS_SETTINGS_SITE_SETTINGS_MIDI_DEVICES_ASK},
{"siteSettingsMidiDevicesAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_MIDI_DEVICES_ASK_RECOMMENDED},
{"siteSettingsMidiDevicesBlock",
IDS_SETTINGS_SITE_SETTINGS_MIDI_DEVICES_BLOCK},
{"siteSettingsSerialPorts", IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS},
+ {"siteSettingsSerialPortsMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_MID_SENTENCE},
{"siteSettingsSerialPortsAsk", IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_ASK},
{"siteSettingsSerialPortsAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_ASK_RECOMMENDED},
{"siteSettingsSerialPortsBlock",
IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_BLOCK},
{"siteSettingsUsbDevices", IDS_SETTINGS_SITE_SETTINGS_USB_DEVICES},
+ {"siteSettingsUsbDevicesMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_USB_DEVICES_MID_SENTENCE},
{"siteSettingsUsbDevicesAsk", IDS_SETTINGS_SITE_SETTINGS_USB_DEVICES_ASK},
{"siteSettingsUsbDevicesAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_USB_DEVICES_ASK_RECOMMENDED},
@@ -1731,6 +1816,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_USB_DEVICES_BLOCK},
{"siteSettingsBluetoothDevices",
IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_DEVICES},
+ {"siteSettingsBluetoothDevicesMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_DEVICES_MID_SENTENCE},
{"siteSettingsBluetoothDevicesAsk",
IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_DEVICES_ASK},
{"siteSettingsBluetoothDevicesAskRecommended",
@@ -1739,6 +1826,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_DEVICES_BLOCK},
{"siteSettingsFileSystemWrite",
IDS_SETTINGS_SITE_SETTINGS_NATIVE_FILE_SYSTEM_WRITE},
+ {"siteSettingsFileSystemWriteMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_NATIVE_FILE_SYSTEM_WRITE_MID_SENTENCE},
{"siteSettingsFileSystemWriteAsk",
IDS_SETTINGS_SITE_SETTINGS_NATIVE_FILE_SYSTEM_WRITE_ASK},
{"siteSettingsFileSystemWriteAskRecommended",
@@ -1748,6 +1837,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsRemoveZoomLevel",
IDS_SETTINGS_SITE_SETTINGS_REMOVE_ZOOM_LEVEL},
{"siteSettingsZoomLevels", IDS_SETTINGS_SITE_SETTINGS_ZOOM_LEVELS},
+ {"siteSettingsZoomLevelsMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_ZOOM_LEVELS_MID_SENTENCE},
{"siteSettingsNoZoomedSites", IDS_SETTINGS_SITE_SETTINGS_NO_ZOOMED_SITES},
{"siteSettingsMaySaveCookies", IDS_SETTINGS_SITE_SETTINGS_MAY_SAVE_COOKIES},
{"siteSettingsAskFirst", IDS_SETTINGS_SITE_SETTINGS_ASK_FIRST},
@@ -1946,6 +2037,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_DEFAULT_BEHAVIOR_DESCRIPTION},
{"siteSettingsCustomizedBehaviors",
IDS_SETTINGS_SITE_SETTINGS_CUSTOMIZED_BEHAVIORS},
+ {"siteSettingsCustomizedBehaviorsDescription",
+ IDS_SETTINGS_SITE_SETTINGS_CUSTOMIZED_BEHAVIORS_DESCRIPTION},
{"siteSettingsAdsDescription", IDS_SETTINGS_SITE_SETTINGS_ADS_DESCRIPTION},
{"siteSettingsAdsAllowed", IDS_SETTINGS_SITE_SETTINGS_ADS_ALLOWED},
{"siteSettingsAdsBlocked", IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCKED},
@@ -2142,10 +2235,13 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsZoomLevelsDescription",
IDS_SETTINGS_SITE_SETTINGS_ZOOM_LEVELS_DESCRIPTION},
{"siteSettingsAds", IDS_SETTINGS_SITE_SETTINGS_ADS},
+ {"siteSettingsAdsMidSentence", IDS_SETTINGS_SITE_SETTINGS_ADS_MID_SENTENCE},
{"siteSettingsAdsBlock", IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK},
{"siteSettingsAdsBlockRecommended",
IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK_RECOMMENDED},
{"siteSettingsPaymentHandler", IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLER},
+ {"siteSettingsPaymentHandlerMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLER_MID_SENTENCE},
{"siteSettingsPaymentHandlerAllow",
IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLER_ALLOW},
{"siteSettingsPaymentHandlerAllowRecommended",
@@ -2158,6 +2254,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"noSitesFound", IDS_SETTINGS_SITE_SETTINGS_NO_SITES_FOUND},
{"siteSettingsBluetoothScanning",
IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_SCANNING},
+ {"siteSettingsBluetoothScanningMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_SCANNING_MID_SENTENCE},
{"siteSettingsBluetoothScanningAsk",
IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_SCANNING_ASK},
{"siteSettingsBluetoothScanningAskRecommended",
@@ -2165,33 +2263,41 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsBluetoothScanningBlock",
IDS_SETTINGS_SITE_SETTINGS_BLUETOOTH_SCANNING_BLOCK},
{"siteSettingsAr", IDS_SETTINGS_SITE_SETTINGS_AR},
+ {"siteSettingsArMidSentence", IDS_SETTINGS_SITE_SETTINGS_AR_MID_SENTENCE},
{"siteSettingsArAsk", IDS_SETTINGS_SITE_SETTINGS_AR_ASK},
{"siteSettingsArAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_AR_ASK_RECOMMENDED},
{"siteSettingsArBlock", IDS_SETTINGS_SITE_SETTINGS_AR_BLOCK},
{"siteSettingsVr", IDS_SETTINGS_SITE_SETTINGS_VR},
+ {"siteSettingsVrMidSentence", IDS_SETTINGS_SITE_SETTINGS_VR_MID_SENTENCE},
{"siteSettingsVrAsk", IDS_SETTINGS_SITE_SETTINGS_VR_ASK},
{"siteSettingsVrAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_VR_ASK_RECOMMENDED},
{"siteSettingsVrBlock", IDS_SETTINGS_SITE_SETTINGS_VR_BLOCK},
{"siteSettingsWindowPlacement",
IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT},
+ {"siteSettingsWindowPlacementMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_MID_SENTENCE},
{"siteSettingsWindowPlacementAsk",
IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_ASK},
{"siteSettingsWindowPlacementAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_ASK_RECOMMENDED},
{"siteSettingsWindowPlacementBlock",
IDS_SETTINGS_SITE_SETTINGS_WINDOW_PLACEMENT_BLOCK},
+ {"siteSettingsFontAccessMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_MID_SENTENCE},
{"siteSettingsFontAccessAsk", IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_ASK},
{"siteSettingsFontAccessBlock",
IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_BLOCK},
{"siteSettingsIdleDetection", IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION},
+ {"siteSettingsIdleDetectionMidSentence",
+ IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION_MID_SENTENCE},
{"siteSettingsIdleDetectionAsk",
IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION_ASK},
{"siteSettingsIdleDetectionBlock",
IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION_BLOCK},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
// These ones cannot be constexpr because we need to check base::FeatureList.
static webui::LocalizedString kSensorsLocalizedStrings[] = {
@@ -2199,6 +2305,10 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
base::FeatureList::IsEnabled(features::kGenericSensorExtraClasses)
? IDS_SETTINGS_SITE_SETTINGS_SENSORS
: IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS},
+ {"siteSettingsSensorsMidSentence",
+ base::FeatureList::IsEnabled(features::kGenericSensorExtraClasses)
+ ? IDS_SETTINGS_SITE_SETTINGS_SENSORS_MID_SENTENCE
+ : IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_MID_SENTENCE},
{"siteSettingsSensorsAllow",
base::FeatureList::IsEnabled(features::kGenericSensorExtraClasses)
? IDS_SETTINGS_SITE_SETTINGS_SENSORS_ALLOW
@@ -2208,7 +2318,7 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
? IDS_SETTINGS_SITE_SETTINGS_SENSORS_BLOCK
: IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCK},
};
- AddLocalizedStringsBulk(html_source, kSensorsLocalizedStrings);
+ html_source->AddLocalizedStrings(kSensorsLocalizedStrings);
html_source->AddBoolean(
"enableSafeBrowsingSubresourceFilter",
@@ -2220,10 +2330,6 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
base::FeatureList::IsEnabled(media::kAutoplayDisableSettings));
html_source->AddBoolean(
- "enableAutoplayWhitelistContentSetting",
- base::FeatureList::IsEnabled(media::kAutoplayWhitelistSettings));
-
- html_source->AddBoolean(
"enablePaymentHandlerContentSetting",
base::FeatureList::IsEnabled(features::kServiceWorkerPaymentApps));
@@ -2253,7 +2359,7 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
html_source->AddString("addSiteExceptionPlaceholder", "[*.]example.com");
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_CHROMEOS_LACROS)
void AddSystemStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"systemPageTitle", IDS_SETTINGS_SYSTEM},
@@ -2264,7 +2370,7 @@ void AddSystemStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_SYSTEM_HARDWARE_ACCELERATION_LABEL},
{"proxySettingsLabel", IDS_SETTINGS_SYSTEM_PROXY_SETTINGS_LABEL},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddString(
"proxySettingsExtensionLabel",
@@ -2381,8 +2487,11 @@ void AddSecurityKeysStrings(content::WebUIDataSource* html_source) {
{"securityKeysTitle", IDS_SETTINGS_SECURITY_KEYS_TITLE},
{"securityKeysTouchToContinue",
IDS_SETTINGS_SECURITY_KEYS_TOUCH_TO_CONTINUE},
+ {"securityKeysSetPinButton", IDS_SETTINGS_SECURITY_KEYS_SET_PIN_BUTTON},
+ {"securityKeysSamePINAsCurrent",
+ IDS_SETTINGS_SECURITY_KEYS_SAME_PIN_AS_CURRENT},
};
- AddLocalizedStringsBulk(html_source, kSecurityKeysStrings);
+ html_source->AddLocalizedStrings(kSecurityKeysStrings);
bool win_native_api_available = false;
#if defined(OS_WIN)
win_native_api_available =
@@ -2418,6 +2527,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
AddLanguagesStrings(html_source, profile);
AddOnStartupStrings(html_source);
AddPeopleStrings(html_source, profile);
+ AddPrivacySandboxStrings(html_source, profile);
AddPrivacyStrings(html_source, profile);
AddSafetyCheckStrings(html_source);
AddResetStrings(html_source, profile);
@@ -2426,13 +2536,16 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
AddSearchStrings(html_source);
AddSiteSettingsStrings(html_source, profile);
-#if defined(OS_CHROMEOS)
- AddChromeOSUserStrings(html_source, profile);
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
+ AddChromeOSSettingsStrings(html_source);
#else
AddDefaultBrowserStrings(html_source);
- AddImportDataStrings(html_source);
AddSystemStrings(html_source);
#endif
+
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
+ AddImportDataStrings(html_source);
+#endif
AddExtensionsStrings(html_source);
#if defined(USE_NSS_CERTS)
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 25b29e32c26..0759f545164 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
@@ -24,7 +24,6 @@
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
-#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
@@ -86,12 +85,12 @@ void ManageProfileHandler::RegisterMessages() {
}
void ManageProfileHandler::OnJavascriptAllowed() {
- observer_.Add(
+ observation_.Observe(
&g_browser_process->profile_manager()->GetProfileAttributesStorage());
}
void ManageProfileHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void ManageProfileHandler::OnProfileHighResAvatarLoaded(
@@ -131,11 +130,12 @@ void ManageProfileHandler::HandleGetAvailableIcons(
}
std::unique_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() {
- ProfileAttributesEntry* entry = nullptr;
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_->GetPath());
// TODO(msalama): Convert to a DCHECK.
- if (!g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile_->GetPath(), &entry)) {
+ if (!entry) {
LOG(ERROR) << "No profile attributes entry found for profile with path: "
<< profile_->GetPath();
return std::make_unique<base::ListValue>();
@@ -150,13 +150,11 @@ std::unique_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() {
profiles::GetCustomProfileAvatarIconsAndLabels(selected_avatar_idx));
if (entry->GetSigninState() == SigninState::kNotSignedIn) {
- if (base::FeatureList::IsEnabled(features::kNewProfilePicker)) {
- ProfileThemeColors colors = entry->GetProfileThemeColors();
- auto generic_avatar_info = profiles::GetDefaultProfileAvatarIconAndLabel(
- colors.default_avatar_fill_color, colors.default_avatar_stroke_color,
- selected_avatar_idx == profiles::GetPlaceholderAvatarIndex());
- avatars->Insert(0, std::move(generic_avatar_info));
- }
+ ProfileThemeColors colors = entry->GetProfileThemeColors();
+ auto generic_avatar_info = profiles::GetDefaultProfileAvatarIconAndLabel(
+ colors.default_avatar_fill_color, colors.default_avatar_stroke_color,
+ selected_avatar_idx == profiles::GetPlaceholderAvatarIndex());
+ avatars->Insert(0, std::move(generic_avatar_info));
return avatars;
}
@@ -221,9 +219,6 @@ void ManageProfileHandler::HandleSetProfileName(const base::ListValue* args) {
CHECK(args);
CHECK_EQ(1u, args->GetSize());
- if (profile_->IsLegacySupervised())
- return;
-
base::string16 new_profile_name;
CHECK(args->GetString(0, &new_profile_name));
@@ -258,8 +253,8 @@ void ManageProfileHandler::HandleRequestProfileShortcutStatus(
DCHECK(shortcut_manager);
shortcut_manager->HasProfileShortcuts(
profile_->GetPath(),
- base::Bind(&ManageProfileHandler::OnHasProfileShortcuts,
- weak_factory_.GetWeakPtr(), callback_id));
+ base::BindOnce(&ManageProfileHandler::OnHasProfileShortcuts,
+ weak_factory_.GetWeakPtr(), callback_id));
}
void ManageProfileHandler::OnHasProfileShortcuts(
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 3a597b12178..b65bafa027f 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
@@ -9,7 +9,7 @@
#include <string>
#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
@@ -91,8 +91,9 @@ class ManageProfileHandler : public settings::SettingsPageUIHandler,
Profile* profile_;
// Used to observe profile avatar updates.
- ScopedObserver<ProfileAttributesStorage, ProfileAttributesStorage::Observer>
- observer_{this};
+ base::ScopedObservation<ProfileAttributesStorage,
+ ProfileAttributesStorage::Observer>
+ observation_{this};
// For generating weak pointers to itself for callbacks.
base::WeakPtrFactory<ManageProfileHandler> weak_factory_{this};
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc
index 5938a35c2bc..a0fa5517e2d 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
-#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -43,9 +42,9 @@ class ManageProfileHandlerTest : public testing::Test {
void SetUp() override {
ASSERT_TRUE(profile_manager_.SetUp());
profile_ = profile_manager_.CreateTestingProfile("Profile 1");
- ASSERT_TRUE(
- profile_manager_.profile_attributes_storage()
- ->GetProfileAttributesWithPath(profile_->GetPath(), &entry_));
+ entry_ = profile_manager_.profile_attributes_storage()
+ ->GetProfileAttributesWithPath(profile_->GetPath());
+ ASSERT_NE(entry_, nullptr);
entry_->SetAvatarIconIndex(profiles::GetPlaceholderAvatarIndex());
handler_ = std::make_unique<TestManageProfileHandler>(profile_);
@@ -64,32 +63,30 @@ class ManageProfileHandlerTest : public testing::Test {
void VerifyIconListWithOnlyCustomAvatars(const base::Value* value,
size_t selected_index) {
- VerifyIconList(value, selected_index, false, false, false);
+ VerifyIconList(value, selected_index, false, false);
}
void VerifyIconList(const base::Value* value,
size_t selected_index,
bool gaia_included,
- bool gaia_selected,
- bool default_avatar_included) {
+ bool gaia_selected) {
const base::ListValue* icons = nullptr;
ASSERT_TRUE(value->GetAsList(&icons));
// Expect a non-empty list of dictionaries containing non-empty strings for
// profile avatar icon urls and labels.
EXPECT_FALSE(icons->empty());
- size_t i = (gaia_included || default_avatar_included) ? 1 : 0;
if (gaia_included) {
- ASSERT_FALSE(default_avatar_included);
VerifyGaiaAvatar(icons, gaia_selected);
- } else if (default_avatar_included) {
+ } else {
+ // Local profile
VerifyDefaultGenericAvatar(icons, selected_index);
}
bool selected_found =
gaia_selected ||
(selected_index == profiles::GetPlaceholderAvatarIndex());
- for (; i < icons->GetSize(); ++i) {
+ for (size_t i = 1; i < icons->GetSize(); ++i) {
const base::DictionaryValue* icon = nullptr;
EXPECT_TRUE(icons->GetDictionary(i, &icon));
std::string icon_url;
@@ -257,8 +254,7 @@ TEST_F(ManageProfileHandlerTest, GetAvailableIconsSignedInProfile) {
EXPECT_EQ("get-icons-callback-id", data.arg1()->GetString());
VerifyIconList(data.arg3(), /*selected_index=*/0,
/*gaia_included=*/true,
- /*gaia_selected=*/true,
- /*default_avatar_included=*/false);
+ /*gaia_selected=*/true);
web_ui()->ClearTrackedCalls();
@@ -272,8 +268,7 @@ TEST_F(ManageProfileHandlerTest, GetAvailableIconsSignedInProfile) {
EXPECT_EQ("available-icons-changed", data_1.arg1()->GetString());
VerifyIconList(data_1.arg2(), /*selected_index=*/30,
/*gaia_included=*/true,
- /*gaia_selected=*/false,
- /*default_avatar_included=*/false);
+ /*gaia_selected=*/false);
// Sign out.
entry()->SetAuthInfo("", base::string16(), false);
@@ -285,13 +280,10 @@ TEST_F(ManageProfileHandlerTest, GetAvailableIconsSignedInProfile) {
EXPECT_EQ("available-icons-changed", data_2.arg1()->GetString());
VerifyIconList(data_2.arg2(), /*selected_index=*/30,
/*gaia_included=*/false,
- /*gaia_selected=*/false,
- /*default_avatar_included=*/false);
+ /*gaia_selected=*/false);
}
TEST_F(ManageProfileHandlerTest, GetAvailableIconsLocalProfile) {
- base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitAndEnableFeature(features::kNewProfilePicker);
EXPECT_FALSE(entry()->IsUsingGAIAPicture());
EXPECT_EQ(entry()->GetAvatarIconIndex(),
profiles::GetPlaceholderAvatarIndex());
@@ -309,8 +301,7 @@ TEST_F(ManageProfileHandlerTest, GetAvailableIconsLocalProfile) {
EXPECT_EQ("get-icons-callback-id", callback_id);
VerifyIconList(data.arg3(), /*selected_index=*/entry()->GetAvatarIconIndex(),
/*gaia_included=*/false,
- /*gaia_selected=*/false,
- /*default_avatar_included=*/true);
+ /*gaia_selected=*/false);
// Sign in.
SetSignedInProfile();
@@ -321,8 +312,7 @@ TEST_F(ManageProfileHandlerTest, GetAvailableIconsLocalProfile) {
EXPECT_EQ("available-icons-changed", data_1.arg1()->GetString());
VerifyIconList(data_1.arg2(), /*selected_index=*/0,
/*gaia_included=*/true,
- /*gaia_selected=*/true,
- /*default_avatar_included=*/false);
+ /*gaia_selected=*/true);
}
TEST_F(ManageProfileHandlerTest, ProfileAvatarChangedWebUIEvent) {
@@ -339,8 +329,6 @@ TEST_F(ManageProfileHandlerTest, ProfileAvatarChangedWebUIEvent) {
}
TEST_F(ManageProfileHandlerTest, ProfileThemeColorsChangedWebUIEvent) {
- base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitAndEnableFeature(features::kNewProfilePicker);
ProfileThemeColors colors = {SK_ColorTRANSPARENT, SK_ColorBLACK,
SK_ColorWHITE};
entry()->SetProfileThemeColors(colors);
@@ -355,8 +343,7 @@ TEST_F(ManageProfileHandlerTest, ProfileThemeColorsChangedWebUIEvent) {
EXPECT_EQ("available-icons-changed", data.arg1()->GetString());
VerifyIconList(data.arg2(), /*selected_index=*/entry()->GetAvatarIconIndex(),
/*gaia_included=*/false,
- /*gaia_selected=*/false,
- /*default_avatar_included=*/true);
+ /*gaia_selected=*/false);
// Set custom avatar.
entry()->SetIsUsingDefaultAvatar(false);
@@ -372,8 +359,7 @@ TEST_F(ManageProfileHandlerTest, ProfileThemeColorsChangedWebUIEvent) {
VerifyIconList(data_1.arg2(),
/*selected_index=*/entry()->GetAvatarIconIndex(),
/*gaia_included=*/false,
- /*gaia_selected=*/false,
- /*default_avatar_included=*/true);
+ /*gaia_selected=*/false);
}
} // namespace settings
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 42d27c5dd19..23e35a3723d 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
@@ -30,19 +30,18 @@ const char kVideo[] = "camera";
namespace settings {
MediaDevicesSelectionHandler::MediaDevicesSelectionHandler(Profile* profile)
- : profile_(profile), observer_(this) {
-}
+ : profile_(profile) {}
MediaDevicesSelectionHandler::~MediaDevicesSelectionHandler() {
}
void MediaDevicesSelectionHandler::OnJavascriptAllowed() {
// Register to the device observer list to get up-to-date device lists.
- observer_.Add(MediaCaptureDevicesDispatcher::GetInstance());
+ observation_.Observe(MediaCaptureDevicesDispatcher::GetInstance());
}
void MediaDevicesSelectionHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
+ observation_.Reset();
}
void MediaDevicesSelectionHandler::RegisterMessages() {
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h
index bbf9313859e..fa364222f11 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MEDIA_DEVICES_SELECTION_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "content/public/browser/web_contents.h"
@@ -55,8 +55,9 @@ class MediaDevicesSelectionHandler
Profile* profile_; // Weak pointer.
- ScopedObserver<MediaCaptureDevicesDispatcher,
- MediaCaptureDevicesDispatcher::Observer> observer_;
+ base::ScopedObservation<MediaCaptureDevicesDispatcher,
+ MediaCaptureDevicesDispatcher::Observer>
+ observation_{this};
DISALLOW_COPY_AND_ASSIGN(MediaDevicesSelectionHandler);
};
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 6b0cd297bbe..36ddfefcbc5 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
@@ -96,12 +96,14 @@ void SecureDnsHandler::OnJavascriptAllowed() {
pref_registrar_.Init(g_browser_process->local_state());
pref_registrar_.Add(
prefs::kDnsOverHttpsMode,
- base::Bind(&SecureDnsHandler::SendSecureDnsSettingUpdatesToJavascript,
- base::Unretained(this)));
+ base::BindRepeating(
+ &SecureDnsHandler::SendSecureDnsSettingUpdatesToJavascript,
+ base::Unretained(this)));
pref_registrar_.Add(
prefs::kDnsOverHttpsTemplates,
- base::Bind(&SecureDnsHandler::SendSecureDnsSettingUpdatesToJavascript,
- base::Unretained(this)));
+ base::BindRepeating(
+ &SecureDnsHandler::SendSecureDnsSettingUpdatesToJavascript,
+ base::Unretained(this)));
}
void SecureDnsHandler::OnJavascriptDisallowed() {
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 3a5b7bd193f..b57dd85bbac 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
@@ -6,6 +6,7 @@
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/dns_probe_test_util.h"
#include "chrome/browser/net/secure_dns_config.h"
@@ -112,6 +113,8 @@ class SecureDnsHandlerTest : public InProcessBrowserTest {
void SetUpInProcessBrowserTestFixture() override {
// Initialize user policy.
ON_CALL(provider_, IsInitializationComplete(_)).WillByDefault(Return(true));
+ ON_CALL(provider_, IsFirstPolicyLoadComplete(_))
+ .WillByDefault(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
}
@@ -183,7 +186,7 @@ class SecureDnsHandlerTest : public InProcessBrowserTest {
std::unique_ptr<TestSecureDnsHandler> handler_;
content::TestWebUI web_ui_;
- policy::MockConfigurationPolicyProvider provider_;
+ testing::NiceMock<policy::MockConfigurationPolicyProvider> provider_;
private:
#if defined(OS_WIN)
@@ -266,7 +269,7 @@ IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, SecureDnsPolicyChange) {
// On platforms where enterprise policies do not have default values, test
// that DoH is disabled when non-DoH policies are set.
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(SecureDnsHandlerTest, OtherPoliciesSet) {
policy::PolicyMap policy_map;
SetPolicyForPolicyKey(&policy_map, policy::key::kIncognitoModeAvailability,
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 f26b210b3d2..4104be59f97 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
@@ -19,7 +19,6 @@
#include "device/fido/bio/enrollment_handler.h"
#include "device/fido/credential_management.h"
#include "device/fido/credential_management_handler.h"
-#include "device/fido/fido_discovery_factory.h"
#include "device/fido/pin.h"
#include "device/fido/reset_request_handler.h"
#include "device/fido/set_pin_request_handler.h"
@@ -36,7 +35,8 @@ base::flat_set<device::FidoTransportProtocol> supported_transports() {
return {device::FidoTransportProtocol::kUsbHumanInterfaceDevice};
}
-void HandleClose(base::Closure close_callback, const base::ListValue* args) {
+void HandleClose(base::RepeatingClosure close_callback,
+ const base::ListValue* args) {
DCHECK_EQ(0u, args->GetSize());
close_callback.Run();
}
@@ -53,6 +53,12 @@ base::DictionaryValue EncodeEnrollment(const std::vector<uint8_t>& id,
namespace settings {
+SecurityKeysHandlerBase::SecurityKeysHandlerBase() = default;
+SecurityKeysHandlerBase::SecurityKeysHandlerBase(
+ std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory)
+ : discovery_factory_(std::move(discovery_factory)) {}
+SecurityKeysHandlerBase::~SecurityKeysHandlerBase() = default;
+
void SecurityKeysHandlerBase::OnJavascriptAllowed() {}
void SecurityKeysHandlerBase::OnJavascriptDisallowed() {
@@ -108,22 +114,28 @@ void SecurityKeysPINHandler::HandleStartSetPIN(const base::ListValue* args) {
weak_factory_.GetWeakPtr()));
}
-void SecurityKeysPINHandler::OnGatherPIN(base::Optional<int64_t> num_retries) {
+void SecurityKeysPINHandler::OnGatherPIN(uint32_t current_min_pin_length,
+ uint32_t new_min_pin_length,
+ base::Optional<int64_t> num_retries) {
DCHECK_EQ(State::kStartSetPIN, state_);
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- base::Value::ListStorage list;
- list.emplace_back(0 /* process not complete */);
+ base::Value::DictStorage response;
+ response.emplace("done", false);
+ response.emplace("error", base::Value::Type::NONE);
+ response.emplace("currentMinPinLength",
+ static_cast<int>(current_min_pin_length));
+ response.emplace("newMinPinLength", static_cast<int>(new_min_pin_length));
if (num_retries) {
state_ = State::kGatherChangePIN;
- list.emplace_back(static_cast<int>(*num_retries));
+ response.emplace("retries", static_cast<int>(*num_retries));
} else {
state_ = State::kGatherNewPIN;
- list.emplace_back(base::Value::Type::NONE);
+ response.emplace("retries", base::Value::Type::NONE);
}
ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(list)));
+ base::Value(std::move(response)));
}
void SecurityKeysPINHandler::OnSetPINComplete(
@@ -139,11 +151,11 @@ void SecurityKeysPINHandler::OnSetPINComplete(
set_pin_.reset();
}
- base::Value::ListStorage list;
- list.emplace_back(1 /* process complete */);
- list.emplace_back(static_cast<int>(code));
+ base::Value::DictStorage response;
+ response.emplace("done", true);
+ response.emplace("error", static_cast<int>(code));
ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(std::move(list)));
+ base::Value(std::move(response)));
}
void SecurityKeysPINHandler::HandleSetPIN(const base::ListValue* args) {
@@ -158,7 +170,8 @@ void SecurityKeysPINHandler::HandleSetPIN(const base::ListValue* args) {
DCHECK((state_ == State::kGatherNewPIN) == old_pin.empty());
- CHECK(device::pin::IsValid(new_pin));
+ CHECK_EQ(device::pin::ValidatePIN(new_pin),
+ device::pin::PINEntryError::kNoError);
state_ = State::kSettingPIN;
set_pin_->ProvidePIN(old_pin, new_pin);
}
@@ -279,8 +292,34 @@ void SecurityKeysResetHandler::OnResetFinished(
}
SecurityKeysCredentialHandler::SecurityKeysCredentialHandler() = default;
+SecurityKeysCredentialHandler::SecurityKeysCredentialHandler(
+ std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory)
+ : SecurityKeysHandlerBase(std::move(discovery_factory)) {}
SecurityKeysCredentialHandler::~SecurityKeysCredentialHandler() = default;
+void SecurityKeysCredentialHandler::HandleStart(const base::ListValue* args) {
+ DCHECK_EQ(State::kNone, state_);
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(1u, args->GetSize());
+ DCHECK(!credential_management_);
+
+ AllowJavascript();
+ DCHECK(callback_id_.empty());
+ callback_id_ = args->GetList()[0].GetString();
+
+ state_ = State::kStart;
+ credential_management_ =
+ std::make_unique<device::CredentialManagementHandler>(
+ discovery_factory(), supported_transports(),
+ base::BindOnce(
+ &SecurityKeysCredentialHandler::OnCredentialManagementReady,
+ weak_factory_.GetWeakPtr()),
+ base::BindRepeating(&SecurityKeysCredentialHandler::OnGatherPIN,
+ weak_factory_.GetWeakPtr()),
+ base::BindOnce(&SecurityKeysCredentialHandler::OnFinished,
+ weak_factory_.GetWeakPtr()));
+}
+
void SecurityKeysCredentialHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"securityKeyCredentialManagementStart",
@@ -310,38 +349,12 @@ void SecurityKeysCredentialHandler::Close() {
// Invalidate all existing WeakPtrs so that no stale callbacks occur.
weak_factory_.InvalidateWeakPtrs();
state_ = State::kNone;
- discovery_factory_.reset();
credential_management_.reset();
callback_id_.clear();
credential_management_provide_pin_cb_.Reset();
DCHECK(!credential_management_provide_pin_cb_);
}
-void SecurityKeysCredentialHandler::HandleStart(const base::ListValue* args) {
- DCHECK_EQ(State::kNone, state_);
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK_EQ(1u, args->GetSize());
- DCHECK(!credential_management_);
- DCHECK(!discovery_factory_);
-
- AllowJavascript();
- DCHECK(callback_id_.empty());
- callback_id_ = args->GetList()[0].GetString();
-
- state_ = State::kStart;
- discovery_factory_ = std::make_unique<device::FidoDiscoveryFactory>();
- credential_management_ =
- std::make_unique<device::CredentialManagementHandler>(
- discovery_factory_.get(), supported_transports(),
- base::BindOnce(
- &SecurityKeysCredentialHandler::OnCredentialManagementReady,
- weak_factory_.GetWeakPtr()),
- base::BindRepeating(&SecurityKeysCredentialHandler::OnGatherPIN,
- weak_factory_.GetWeakPtr()),
- base::BindOnce(&SecurityKeysCredentialHandler::OnFinished,
- weak_factory_.GetWeakPtr()));
-}
-
void SecurityKeysCredentialHandler::HandlePIN(const base::ListValue* args) {
DCHECK_EQ(State::kPIN, state_);
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -451,6 +464,7 @@ void SecurityKeysCredentialHandler::OnHaveCredentials(
}
void SecurityKeysCredentialHandler::OnGatherPIN(
+ uint32_t min_pin_length,
int64_t num_retries,
base::OnceCallback<void(std::string)> callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -459,18 +473,21 @@ void SecurityKeysCredentialHandler::OnGatherPIN(
credential_management_provide_pin_cb_ = std::move(callback);
+ base::Value::ListStorage response;
+ response.emplace_back(static_cast<int>(min_pin_length));
if (state_ == State::kStart) {
// Resolve the promise to startCredentialManagement().
state_ = State::kPIN;
ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value());
+ base::Value(std::move(response)));
return;
}
// Resolve the promise to credentialManagementProvidePIN().
DCHECK_EQ(state_, State::kPIN);
+ response.emplace_back(static_cast<int>(num_retries));
ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(static_cast<int>(num_retries)));
+ base::Value(std::move(response)));
}
void SecurityKeysCredentialHandler::OnCredentialsDeleted(
@@ -496,7 +513,7 @@ void SecurityKeysCredentialHandler::OnFinished(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
int error;
-
+ bool requires_pin_change = false;
switch (status) {
case device::CredentialManagementStatus::kSoftPINBlock:
error = IDS_SETTINGS_SECURITY_KEYS_PIN_SOFT_LOCK;
@@ -509,23 +526,53 @@ void SecurityKeysCredentialHandler::OnFinished(
error = IDS_SETTINGS_SECURITY_KEYS_NO_CREDENTIAL_MANAGEMENT;
break;
case device::CredentialManagementStatus::kNoPINSet:
+ requires_pin_change = true;
error = IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_NO_PIN;
break;
case device::CredentialManagementStatus::kAuthenticatorResponseInvalid:
error = IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_ERROR;
break;
+ case device::CredentialManagementStatus::kForcePINChange:
+ requires_pin_change = true;
+ error = IDS_SETTINGS_SECURITY_KEYS_FORCE_PIN_CHANGE;
+ break;
case device::CredentialManagementStatus::kSuccess:
error = IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_REMOVED;
break;
}
FireWebUIListener("security-keys-credential-management-finished",
- base::Value(l10n_util::GetStringUTF8(std::move(error))));
+ base::Value(l10n_util::GetStringUTF8(error)),
+ base::Value(requires_pin_change));
}
SecurityKeysBioEnrollmentHandler::SecurityKeysBioEnrollmentHandler() = default;
+SecurityKeysBioEnrollmentHandler::SecurityKeysBioEnrollmentHandler(
+ std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory)
+ : SecurityKeysHandlerBase(std::move(discovery_factory)) {}
SecurityKeysBioEnrollmentHandler::~SecurityKeysBioEnrollmentHandler() = default;
+void SecurityKeysBioEnrollmentHandler::HandleStart(
+ const base::ListValue* args) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(state_, State::kNone);
+ DCHECK_EQ(1u, args->GetSize());
+ DCHECK(callback_id_.empty());
+
+ AllowJavascript();
+ state_ = State::kStart;
+ callback_id_ = args->GetList()[0].GetString();
+ bio_ = std::make_unique<device::BioEnrollmentHandler>(
+ supported_transports(),
+ base::BindOnce(&SecurityKeysBioEnrollmentHandler::OnReady,
+ weak_factory_.GetWeakPtr()),
+ base::BindOnce(&SecurityKeysBioEnrollmentHandler::OnError,
+ weak_factory_.GetWeakPtr()),
+ base::BindRepeating(&SecurityKeysBioEnrollmentHandler::OnGatherPIN,
+ weak_factory_.GetWeakPtr()),
+ discovery_factory());
+}
+
void SecurityKeysBioEnrollmentHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"securityKeyBioEnrollStart",
@@ -567,35 +614,11 @@ void SecurityKeysBioEnrollmentHandler::RegisterMessages() {
void SecurityKeysBioEnrollmentHandler::Close() {
weak_factory_.InvalidateWeakPtrs();
state_ = State::kNone;
- discovery_factory_.reset();
bio_.reset();
callback_id_.clear();
- discovery_factory_.reset();
provide_pin_cb_.Reset();
}
-void SecurityKeysBioEnrollmentHandler::HandleStart(
- const base::ListValue* args) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK_EQ(state_, State::kNone);
- DCHECK_EQ(1u, args->GetSize());
- DCHECK(callback_id_.empty());
-
- AllowJavascript();
- state_ = State::kStart;
- callback_id_ = args->GetList()[0].GetString();
- discovery_factory_ = std::make_unique<device::FidoDiscoveryFactory>();
- bio_ = std::make_unique<device::BioEnrollmentHandler>(
- supported_transports(),
- base::BindOnce(&SecurityKeysBioEnrollmentHandler::OnReady,
- weak_factory_.GetWeakPtr()),
- base::BindOnce(&SecurityKeysBioEnrollmentHandler::OnError,
- weak_factory_.GetWeakPtr()),
- base::BindRepeating(&SecurityKeysBioEnrollmentHandler::OnGatherPIN,
- weak_factory_.GetWeakPtr()),
- discovery_factory_.get());
-}
-
void SecurityKeysBioEnrollmentHandler::OnReady() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(bio_);
@@ -612,6 +635,7 @@ void SecurityKeysBioEnrollmentHandler::OnError(
state_ = State::kNone;
int error;
+ bool requires_pin_change = false;
switch (status) {
case device::BioEnrollmentStatus::kSoftPINBlock:
error = IDS_SETTINGS_SECURITY_KEYS_PIN_SOFT_LOCK;
@@ -623,18 +647,24 @@ void SecurityKeysBioEnrollmentHandler::OnError(
error = IDS_SETTINGS_SECURITY_KEYS_NO_BIOMETRIC_ENROLLMENT;
break;
case device::BioEnrollmentStatus::kNoPINSet:
- error = IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_NO_PIN;
+ requires_pin_change = true;
+ error = IDS_SETTINGS_SECURITY_KEYS_BIO_NO_PIN;
break;
case device::BioEnrollmentStatus::kAuthenticatorResponseInvalid:
error = IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_ERROR;
break;
+ case device::BioEnrollmentStatus::kForcePINChange:
+ requires_pin_change = true;
+ error = IDS_SETTINGS_SECURITY_KEYS_FORCE_PIN_CHANGE;
+ break;
case device::BioEnrollmentStatus::kSuccess:
error = IDS_SETTINGS_SECURITY_KEYS_CREDENTIAL_MANAGEMENT_REMOVED;
break;
}
FireWebUIListener("security-keys-bio-enroll-error",
- base::Value(l10n_util::GetStringUTF8(error)));
+ base::Value(l10n_util::GetStringUTF8(error)),
+ base::Value(requires_pin_change));
// If |callback_id_| is not empty, there is an ongoing operation,
// which means there is an unresolved Promise. Reject it so that
@@ -646,6 +676,7 @@ void SecurityKeysBioEnrollmentHandler::OnError(
}
void SecurityKeysBioEnrollmentHandler::OnGatherPIN(
+ uint32_t min_pin_length,
int64_t retries,
base::OnceCallback<void(std::string)> cb) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -653,8 +684,11 @@ void SecurityKeysBioEnrollmentHandler::OnGatherPIN(
DCHECK(state_ == State::kStart || state_ == State::kGatherPIN);
state_ = State::kGatherPIN;
provide_pin_cb_ = std::move(cb);
+ base::Value::ListStorage response;
+ response.emplace_back(static_cast<int>(min_pin_length));
+ response.emplace_back(static_cast<int>(retries));
ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
- base::Value(static_cast<int>(retries)));
+ base::Value(std::move(response)));
}
void SecurityKeysBioEnrollmentHandler::HandleProvidePIN(
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 cfb3b29b42f..b29ea5fd122 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
@@ -12,9 +12,9 @@
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "device/fido/fido_constants.h"
-
#include "device/fido/bio/enrollment.h"
+#include "device/fido/fido_constants.h"
+#include "device/fido/fido_discovery_factory.h"
namespace base {
class ListValue;
@@ -22,7 +22,6 @@ class ListValue;
namespace device {
struct AggregatedEnumerateCredentialsResponse;
-class FidoDiscoveryFactory;
class CredentialManagementHandler;
enum class CredentialManagementStatus;
class SetPINRequestHandler;
@@ -35,18 +34,30 @@ namespace settings {
// Base class for message handlers on the "Security Keys" settings subpage.
class SecurityKeysHandlerBase : public SettingsPageUIHandler {
+ public:
+ SecurityKeysHandlerBase(const SecurityKeysHandlerBase&) = delete;
+ SecurityKeysHandlerBase& operator=(const SecurityKeysHandlerBase&) = delete;
+
protected:
- SecurityKeysHandlerBase() = default;
+ SecurityKeysHandlerBase();
+ explicit SecurityKeysHandlerBase(
+ std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory);
+ ~SecurityKeysHandlerBase() override;
// Subclasses must implement close to invalidate all pending callbacks.
virtual void Close() = 0;
+ // Returns the discovery factory to be used for the request.
+ device::FidoDiscoveryFactory* discovery_factory() {
+ return discovery_factory_.get();
+ }
+
private:
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
- SecurityKeysHandlerBase(const SecurityKeysHandlerBase&) = delete;
- SecurityKeysHandlerBase& operator=(const SecurityKeysHandlerBase&) = delete;
+ std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory_ =
+ std::make_unique<device::FidoDiscoveryFactory>();
};
// SecurityKeysPINHandler processes messages from the "Create a PIN" dialog of
@@ -71,7 +82,9 @@ class SecurityKeysPINHandler : public SecurityKeysHandlerBase {
void Close() override;
void HandleStartSetPIN(const base::ListValue* args);
- void OnGatherPIN(base::Optional<int64_t> num_retries);
+ void OnGatherPIN(uint32_t current_min_pin_length,
+ uint32_t new_min_pin_length,
+ base::Optional<int64_t> num_retries);
void OnSetPINComplete(device::CtapDeviceResponseCode code);
void HandleSetPIN(const base::ListValue* args);
@@ -127,6 +140,11 @@ class SecurityKeysCredentialHandler : public SecurityKeysHandlerBase {
SecurityKeysCredentialHandler();
~SecurityKeysCredentialHandler() override;
+ protected:
+ explicit SecurityKeysCredentialHandler(
+ std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory);
+ void HandleStart(const base::ListValue* args);
+
private:
enum class State {
kNone,
@@ -140,7 +158,6 @@ class SecurityKeysCredentialHandler : public SecurityKeysHandlerBase {
void RegisterMessages() override;
void Close() override;
- void HandleStart(const base::ListValue* args);
void HandlePIN(const base::ListValue* args);
void HandleEnumerate(const base::ListValue* args);
void HandleDelete(const base::ListValue* args);
@@ -152,14 +169,15 @@ class SecurityKeysCredentialHandler : public SecurityKeysHandlerBase {
std::vector<device::AggregatedEnumerateCredentialsResponse>>
responses,
base::Optional<size_t> remaining_credentials);
- void OnGatherPIN(int64_t num_retries, base::OnceCallback<void(std::string)>);
+ void OnGatherPIN(uint32_t min_pin_length,
+ int64_t num_retries,
+ base::OnceCallback<void(std::string)>);
void OnCredentialsDeleted(device::CtapDeviceResponseCode status);
void OnFinished(device::CredentialManagementStatus status);
State state_ = State::kNone;
base::OnceCallback<void(std::string)> credential_management_provide_pin_cb_;
- std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory_;
std::unique_ptr<device::CredentialManagementHandler> credential_management_;
std::string callback_id_;
@@ -175,6 +193,11 @@ class SecurityKeysBioEnrollmentHandler : public SecurityKeysHandlerBase {
SecurityKeysBioEnrollmentHandler();
~SecurityKeysBioEnrollmentHandler() override;
+ protected:
+ explicit SecurityKeysBioEnrollmentHandler(
+ std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory);
+ void HandleStart(const base::ListValue* args);
+
private:
enum class State {
kNone,
@@ -190,10 +213,11 @@ class SecurityKeysBioEnrollmentHandler : public SecurityKeysHandlerBase {
void RegisterMessages() override;
void Close() override;
- void HandleStart(const base::ListValue* args);
void OnReady();
void OnError(device::BioEnrollmentStatus status);
- void OnGatherPIN(int64_t retries, base::OnceCallback<void(std::string)>);
+ void OnGatherPIN(uint32_t min_pin_length,
+ int64_t retries,
+ base::OnceCallback<void(std::string)>);
void HandleProvidePIN(const base::ListValue* args);
@@ -222,7 +246,6 @@ class SecurityKeysBioEnrollmentHandler : public SecurityKeysHandlerBase {
State state_ = State::kNone;
std::string callback_id_;
base::OnceCallback<void(std::string)> provide_pin_cb_;
- std::unique_ptr<device::FidoDiscoveryFactory> discovery_factory_;
std::unique_ptr<device::BioEnrollmentHandler> bio_;
base::WeakPtrFactory<SecurityKeysBioEnrollmentHandler> weak_factory_{this};
};
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler_unittest.cc
new file mode 100644
index 00000000000..8db5713bc90
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler_unittest.cc
@@ -0,0 +1,144 @@
+// 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/settings_security_key_handler.h"
+
+#include <memory>
+
+#include "chrome/grit/generated_resources.h"
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "content/public/test/test_web_ui.h"
+#include "device/fido/fake_fido_discovery.h"
+#include "device/fido/fido_discovery_factory.h"
+#include "device/fido/fido_types.h"
+#include "device/fido/virtual_fido_device_factory.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace settings {
+
+namespace {
+
+class TestSecurityKeysCredentialHandler : public SecurityKeysCredentialHandler {
+ public:
+ explicit TestSecurityKeysCredentialHandler(content::TestWebUI* web_ui)
+ : SecurityKeysCredentialHandler(
+ std::make_unique<device::test::VirtualFidoDeviceFactory>()) {
+ set_web_ui(web_ui);
+ AllowJavascriptForTesting();
+ }
+
+ using SecurityKeysCredentialHandler::HandleStart;
+
+ device::test::VirtualFidoDeviceFactory* GetDiscoveryFactory() {
+ return static_cast<device::test::VirtualFidoDeviceFactory*>(
+ discovery_factory());
+ }
+};
+
+class TestSecurityKeysBioEnrollmentHandler
+ : public SecurityKeysBioEnrollmentHandler {
+ public:
+ explicit TestSecurityKeysBioEnrollmentHandler(content::TestWebUI* web_ui)
+ : SecurityKeysBioEnrollmentHandler(
+ std::make_unique<device::test::VirtualFidoDeviceFactory>()) {
+ set_web_ui(web_ui);
+ AllowJavascriptForTesting();
+ }
+
+ using SecurityKeysBioEnrollmentHandler::HandleStart;
+
+ device::test::VirtualFidoDeviceFactory* GetDiscoveryFactory() {
+ return static_cast<device::test::VirtualFidoDeviceFactory*>(
+ discovery_factory());
+ }
+};
+
+} // namespace
+
+class SecurityKeysCredentialHandlerTest
+ : public ChromeRenderViewHostTestHarness {
+ protected:
+ void SetUp() override {
+ ChromeRenderViewHostTestHarness::SetUp();
+ web_ui_ = std::make_unique<content::TestWebUI>();
+ web_ui_->set_web_contents(web_contents());
+ handler_ =
+ std::make_unique<TestSecurityKeysCredentialHandler>(web_ui_.get());
+ web_ui_->ClearTrackedCalls();
+ }
+
+ std::unique_ptr<TestSecurityKeysCredentialHandler> handler_;
+ std::unique_ptr<content::TestWebUI> web_ui_;
+};
+
+TEST_F(SecurityKeysCredentialHandlerTest, TestForcePINChange) {
+ handler_->GetDiscoveryFactory()->mutable_state()->force_pin_change = true;
+ handler_->GetDiscoveryFactory()->mutable_state()->pin = "1234";
+ device::VirtualCtap2Device::Config config;
+ config.pin_support = true;
+ config.pin_uv_auth_token_support = true;
+ config.min_pin_length_support = true;
+ config.credential_management_support = true;
+ config.ctap2_versions = {device::Ctap2Version::kCtap2_1};
+ handler_->GetDiscoveryFactory()->SetCtap2Config(config);
+
+ std::string callback_id("start_callback_id");
+ base::ListValue args;
+ args.Append(callback_id);
+ handler_->HandleStart(&args);
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(web_ui_->call_data()[0]->arg1()->GetString(),
+ "security-keys-credential-management-finished");
+ EXPECT_EQ(
+ web_ui_->call_data()[0]->arg2()->GetString(),
+ l10n_util::GetStringUTF8(IDS_SETTINGS_SECURITY_KEYS_FORCE_PIN_CHANGE));
+ EXPECT_EQ(web_ui_->call_data()[0]->arg3()->GetBool(), true);
+}
+
+class SecurityKeysBioEnrollmentHandlerTest
+ : public ChromeRenderViewHostTestHarness {
+ protected:
+ void SetUp() override {
+ ChromeRenderViewHostTestHarness::SetUp();
+ web_ui_ = std::make_unique<content::TestWebUI>();
+ web_ui_->set_web_contents(web_contents());
+ handler_ =
+ std::make_unique<TestSecurityKeysBioEnrollmentHandler>(web_ui_.get());
+ web_ui_->ClearTrackedCalls();
+ }
+
+ std::unique_ptr<TestSecurityKeysBioEnrollmentHandler> handler_;
+ std::unique_ptr<content::TestWebUI> web_ui_;
+};
+
+TEST_F(SecurityKeysBioEnrollmentHandlerTest, TestForcePINChange) {
+ handler_->GetDiscoveryFactory()->mutable_state()->force_pin_change = true;
+ handler_->GetDiscoveryFactory()->mutable_state()->pin = "1234";
+ device::VirtualCtap2Device::Config config;
+ config.internal_uv_support = true;
+ config.bio_enrollment_support = true;
+ config.pin_support = true;
+ config.pin_uv_auth_token_support = true;
+ config.min_pin_length_support = true;
+ config.credential_management_support = true;
+ config.ctap2_versions = {device::Ctap2Version::kCtap2_1};
+ handler_->GetDiscoveryFactory()->SetCtap2Config(config);
+
+ std::string callback_id("start_callback_id");
+ base::ListValue args;
+ args.Append(callback_id);
+ handler_->HandleStart(&args);
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(web_ui_->call_data()[0]->arg1()->GetString(),
+ "security-keys-bio-enroll-error");
+ EXPECT_EQ(
+ web_ui_->call_data()[0]->arg2()->GetString(),
+ l10n_util::GetStringUTF8(IDS_SETTINGS_SECURITY_KEYS_FORCE_PIN_CHANGE));
+ EXPECT_EQ(web_ui_->call_data()[0]->arg3()->GetBool(), true);
+}
+
+} // namespace settings
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 4e299369dcf..0509d30670e 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
@@ -12,7 +12,7 @@
#include "base/bind.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/settings_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/web_ui.h"
#include "url/gurl.h"
@@ -66,8 +66,8 @@ void StartupPagesHandler::OnJavascriptAllowed() {
pref_change_registrar_.Init(prefService);
pref_change_registrar_.Add(
prefs::kURLsToRestoreOnStartup,
- base::Bind(&StartupPagesHandler::UpdateStartupPages,
- base::Unretained(this)));
+ base::BindRepeating(&StartupPagesHandler::UpdateStartupPages,
+ base::Unretained(this)));
}
void StartupPagesHandler::OnJavascriptDisallowed() {
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
index 9c535e816ff..ae1a6e96af2 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
@@ -17,6 +17,9 @@
#include "base/stl_util.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
+#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings.h"
+#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/hats/hats_service.h"
@@ -88,41 +91,41 @@
#endif
#endif // defined(OS_WIN)
-#if defined(OS_WIN) || defined(OS_CHROMEOS)
+#if defined(OS_WIN) || BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ui/webui/settings/languages_handler.h"
-#endif // defined(OS_WIN) || defined(OS_CHROMEOS)
-
-#if defined(OS_CHROMEOS)
+#endif // defined(OS_WIN) || BUILDFLAG(IS_CHROMEOS_ASH)
+
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/components/account_manager/account_manager.h"
+#include "ash/components/account_manager/account_manager_factory.h"
+#include "ash/constants/ash_features.h"
+#include "chrome/browser/ash/account_manager/account_manager_util.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
-#include "chrome/browser/chromeos/account_manager/account_manager_util.h"
#include "chrome/browser/chromeos/android_sms/android_sms_app_manager.h"
#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h"
#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h"
#include "chrome/browser/chromeos/phonehub/phone_hub_manager_factory.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.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/components/account_manager/account_manager.h"
-#include "chromeos/components/account_manager/account_manager_factory.h"
#include "chromeos/components/phonehub/phone_hub_manager.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/login/auth/password_visibility_utils.h"
#include "components/arc/arc_util.h"
#include "components/user_manager/user.h"
#include "ui/base/ui_base_features.h"
-#else // !defined(OS_CHROMEOS)
+#else // !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h"
#include "chrome/browser/ui/webui/settings/captions_handler.h"
#include "chrome/browser/ui/webui/settings/settings_default_browser_handler.h"
#include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h"
#include "chrome/browser/ui/webui/settings/system_handler.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if defined(USE_NSS_CERTS)
#include "chrome/browser/ui/webui/certificates_handler.h"
@@ -148,10 +151,10 @@ web_app::AppRegistrar& GetRegistrarForProfile(Profile* profile) {
SettingsUI::SettingsUI(content::WebUI* web_ui)
:
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true),
customize_themes_factory_receiver_(this),
-#else // !defined(OS_CHROMEOS)
+#else // !BUILDFLAG(IS_CHROMEOS_ASH)
content::WebUIController(web_ui),
#endif
webui_load_timer_(web_ui->GetWebContents(),
@@ -165,17 +168,21 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
AddSettingsPageUIHandler(std::make_unique<AppearanceHandler>(web_ui));
+// TODO(crbug.com/1147032): The certificates settings page is temporarily
+// disabled for Lacros-Chrome until a better solution is found.
+#if !BUILDFLAG(IS_CHROMEOS_LACROS)
#if defined(USE_NSS_CERTS)
AddSettingsPageUIHandler(
std::make_unique<certificate_manager::CertificatesHandler>());
#elif defined(OS_WIN) || defined(OS_MAC)
AddSettingsPageUIHandler(std::make_unique<NativeCertificatesHandler>());
#endif // defined(USE_NSS_CERTS)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
AddSettingsPageUIHandler(
chromeos::cert_provisioning::CertificateProvisioningUiHandler::
CreateForProfile(profile));
-#endif
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+#endif // !BUILDFLAG(IS_CHROMEOS_LACROS)
AddSettingsPageUIHandler(std::make_unique<AccessibilityMainHandler>());
AddSettingsPageUIHandler(std::make_unique<BrowserLifetimeHandler>());
@@ -192,13 +199,13 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
#if defined(OS_WIN)
AddSettingsPageUIHandler(std::make_unique<LanguagesHandler>());
#endif // defined(OS_WIN)
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
AddSettingsPageUIHandler(std::make_unique<LanguagesHandler>(profile));
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
AddSettingsPageUIHandler(
std::make_unique<MediaDevicesSelectionHandler>(profile));
-#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !defined(OS_CHROMEOS)
+#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH)
AddSettingsPageUIHandler(std::make_unique<MetricsReportingHandler>());
#endif
AddSettingsPageUIHandler(std::make_unique<OnStartupHandler>(profile));
@@ -216,7 +223,7 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
AddSettingsPageUIHandler(
std::make_unique<SecurityKeysBioEnrollmentHandler>());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
InitBrowserSettingsWebUIHandlers();
#else
AddSettingsPageUIHandler(
@@ -251,11 +258,6 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
base::FeatureList::IsEnabled(safe_browsing::kEnhancedProtection));
html_source->AddBoolean(
- "passwordsWeaknessCheck",
- base::FeatureList::IsEnabled(
- password_manager::features::kPasswordsWeaknessCheck));
-
- html_source->AddBoolean(
"editPasswordsInSettings",
base::FeatureList::IsEnabled(
password_manager::features::kEditPasswordsInSettings));
@@ -270,12 +272,14 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
password_manager::features::kEnablePasswordsAccountStorage));
html_source->AddBoolean(
+ "enableMovingMultiplePasswordsToAccount",
+ base::FeatureList::IsEnabled(
+ password_manager::features::kEnableMovingMultiplePasswordsToAccount));
+
+ html_source->AddBoolean(
"enableContentSettingsRedesign",
base::FeatureList::IsEnabled(features::kContentSettingsRedesign));
- html_source->AddBoolean("isEphemeralGuestProfile",
- profile->IsEphemeralGuestProfile());
-
#if defined(OS_WIN)
html_source->AddBoolean(
"safetyCheckChromeCleanerChildEnabled",
@@ -287,7 +291,7 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
features::kChromeCleanupScanCompletedNotification));
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
html_source->AddBoolean("splitSettingsSyncEnabled",
chromeos::features::IsSplitSettingsSyncEnabled());
html_source->AddBoolean("useBrowserSyncConsent",
@@ -302,10 +306,11 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
// This is the browser settings page.
html_source->AddBoolean("isOSSettings", false);
-#else // defined(OS_CHROMEOS)
- html_source->AddBoolean("newProfilePicker", base::FeatureList::IsEnabled(
- features::kNewProfilePicker));
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
+
+ html_source->AddBoolean(
+ "safetyCheckWeakPasswordsEnabled",
+ base::FeatureList::IsEnabled(features::kSafetyCheckWeakPasswords));
AddSettingsPageUIHandler(std::make_unique<AboutHandler>(profile));
AddSettingsPageUIHandler(std::make_unique<ResetSettingsHandler>(profile));
@@ -318,6 +323,16 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
"insecurePasswords", IDS_SETTINGS_INSECURE_PASSWORDS_COUNT);
plural_string_handler->AddLocalizedString("weakPasswords",
IDS_SETTINGS_WEAK_PASSWORDS_COUNT);
+ plural_string_handler->AddLocalizedString("securityKeysNewPIN",
+ IDS_SETTINGS_SECURITY_KEYS_NEW_PIN);
+ plural_string_handler->AddLocalizedString(
+ "movePasswordsToAccount",
+ IDS_SETTINGS_PASSWORD_MOVE_PASSWORDS_TO_ACCOUNT_COUNT);
+ plural_string_handler->AddLocalizedString(
+ "safetyCheckPasswordsCompromised",
+ IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT_SHORT);
+ plural_string_handler->AddLocalizedString(
+ "safetyCheckPasswordsWeak", IDS_SETTINGS_WEAK_PASSWORDS_COUNT_SHORT);
web_ui->AddMessageHandler(std::move(plural_string_handler));
// Add the metrics handler to write uma stats.
@@ -325,7 +340,7 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource(
html_source, base::make_span(kSettingsResources, kSettingsResourcesSize),
- "", IDR_SETTINGS_SETTINGS_HTML);
+ IDR_SETTINGS_SETTINGS_HTML);
AddLocalizedStrings(html_source, profile, web_ui->GetWebContents());
@@ -338,21 +353,30 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
profile, std::make_unique<FaviconSource>(
profile, chrome::FaviconUrlFormat::kFavicon2));
+ // Privacy Sandbox
+ bool sandbox_enabled = PrivacySandboxSettingsFactory::GetForProfile(profile)
+ ->PrivacySandboxSettingsFunctional();
+ html_source->AddBoolean("privacySandboxSettingsEnabled", sandbox_enabled);
+ if (sandbox_enabled) {
+ html_source->AddResourcePath(
+ "privacySandbox", IDR_SETTINGS_PRIVACY_SANDBOX_PRIVACY_SANDBOX_HTML);
+ }
+
TryShowHatsSurveyWithTimeout();
}
SettingsUI::~SettingsUI() = default;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void SettingsUI::InitBrowserSettingsWebUIHandlers() {
Profile* profile = Profile::FromWebUI(web_ui());
// TODO(jamescook): Sort out how account management is split between Chrome OS
// and browser settings.
- if (chromeos::IsAccountManagerAvailable(profile)) {
- chromeos::AccountManagerFactory* factory =
+ if (ash::IsAccountManagerAvailable(profile)) {
+ auto* factory =
g_browser_process->platform_part()->GetAccountManagerFactory();
- chromeos::AccountManager* account_manager =
+ auto* account_manager =
factory->GetAccountManager(profile->GetPath().value());
DCHECK(account_manager);
@@ -384,11 +408,8 @@ void SettingsUI::InitBrowserSettingsWebUIHandlers() {
android_sms_service ? android_sms_service->android_sms_app_manager()
: nullptr));
}
-
- web_ui()->AddMessageHandler(
- std::make_unique<chromeos::settings::AndroidAppsHandler>(profile));
}
-#else // defined(OS_CHROMEOS)
+#else // BUILDFLAG(IS_CHROMEOS_ASH)
void SettingsUI::BindInterface(
mojo::PendingReceiver<
customize_themes::mojom::CustomizeThemesHandlerFactory>
@@ -397,7 +418,7 @@ void SettingsUI::BindInterface(
customize_themes_factory_receiver_.reset();
customize_themes_factory_receiver_.Bind(std::move(pending_receiver));
}
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
void SettingsUI::AddSettingsPageUIHandler(
std::unique_ptr<content::WebUIMessageHandler> handler) {
@@ -415,7 +436,7 @@ void SettingsUI::TryShowHatsSurveyWithTimeout() {
}
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
void SettingsUI::CreateCustomizeThemesHandler(
mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
pending_client,
@@ -425,7 +446,7 @@ void SettingsUI::CreateCustomizeThemesHandler(
std::move(pending_client), std::move(pending_handler),
web_ui()->GetWebContents(), Profile::FromWebUI(web_ui()));
}
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
WEB_UI_CONTROLLER_TYPE_IMPL(SettingsUI)
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_ui.h b/chromium/chrome/browser/ui/webui/settings/settings_ui.h
index 6da24f5e2c8..e8e71c921c8 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_ui.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_ui.h
@@ -7,17 +7,18 @@
#include "base/macros.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/webui_load_timer.h"
#include "content/public/browser/web_ui_controller.h"
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
#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"
#include "ui/webui/resources/cr_components/customize_themes/customize_themes.mojom.h"
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
namespace content {
class WebUIMessageHandler;
@@ -27,22 +28,22 @@ namespace user_prefs {
class PrefRegistrySyncable;
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
class ChromeCustomizeThemesHandler;
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
namespace settings {
// The WebUI handler for chrome://settings.
class SettingsUI :
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// chrome://settings/manageProfile which only exists on !OS_CHROMEOS
// requires mojo bindings.
public ui::MojoWebUIController,
public customize_themes::mojom::CustomizeThemesHandlerFactory
-#else // !defined(OS_CHROMEOS)
+#else // !BUILDFLAG(IS_CHROMEOS_ASH)
public content::WebUIController
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
{
public:
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
@@ -50,18 +51,18 @@ class SettingsUI :
explicit SettingsUI(content::WebUI* web_ui);
~SettingsUI() override;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Initializes the WebUI message handlers for CrOS-specific settings that are
// still shown in the browser settings UI.
void InitBrowserSettingsWebUIHandlers();
-#else // defined(OS_CHROMEOS)
+#else // BUILDFLAG(IS_CHROMEOS_ASH)
// Instantiates the implementor of the
// customize_themes::mojom::CustomizeThemesHandlerFactory mojo interface
// passing the pending receiver that will be internally bound.
void BindInterface(mojo::PendingReceiver<
customize_themes::mojom::CustomizeThemesHandlerFactory>
pending_receiver);
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
private:
void AddSettingsPageUIHandler(
@@ -70,7 +71,7 @@ class SettingsUI :
// Makes a request to show a HaTS survey.
void TryShowHatsSurveyWithTimeout();
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
// customize_themes::mojom::CustomizeThemesHandlerFactory:
void CreateCustomizeThemesHandler(
mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
@@ -81,7 +82,7 @@ class SettingsUI :
std::unique_ptr<ChromeCustomizeThemesHandler> customize_themes_handler_;
mojo::Receiver<customize_themes::mojom::CustomizeThemesHandlerFactory>
customize_themes_factory_receiver_;
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
WebuiLoadTimer webui_load_timer_;
diff --git a/chromium/chrome/browser/ui/webui/settings_utils.cc b/chromium/chrome/browser/ui/webui/settings/settings_utils.cc
index 4347b446a88..63454ec5057 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_utils.cc
@@ -2,10 +2,12 @@
// 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_utils.h"
+#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"
@@ -27,6 +29,12 @@ base::RefCountedMemory* GetFaviconResourceBytes(ui::ScaleFactor scale_factor) {
IDR_SETTINGS_FAVICON, scale_factor);
}
+base::RefCountedMemory* GetPrivacySandboxFaviconResourceBytes(
+ ui::ScaleFactor scale_factor) {
+ return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
+ 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);
diff --git a/chromium/chrome/browser/ui/webui/settings_utils.h b/chromium/chrome/browser/ui/webui/settings/settings_utils.h
index fe166ec84a4..0c7e77d3373 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_utils.h
@@ -2,12 +2,13 @@
// 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_UTILS_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_UTILS_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_UTILS_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_UTILS_H_
#include <string>
#include "base/macros.h"
+#include "build/build_config.h"
#include "ui/base/resource/scale_factor.h"
class GURL;
@@ -37,6 +38,9 @@ bool FixupAndValidateStartupPage(const std::string& url_string,
base::RefCountedMemory* GetFaviconResourceBytes(ui::ScaleFactor scale_factor);
+base::RefCountedMemory* GetPrivacySandboxFaviconResourceBytes(
+ ui::ScaleFactor scale_factor);
+
#if defined(OS_MAC)
void ValidateSavedFonts(PrefService* prefs);
#endif
@@ -50,4 +54,4 @@ std::string ResolveFontList(const std::string& font_name_or_list);
} // namespace settings_utils
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_UTILS_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_UTILS_H_
diff --git a/chromium/chrome/browser/ui/webui/settings_utils_linux.cc b/chromium/chrome/browser/ui/webui/settings/settings_utils_linux.cc
index 0276b92724e..f46cb3e62d5 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils_linux.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_utils_linux.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_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.h"
#include <stddef.h>
@@ -89,8 +89,7 @@ bool StartProxyConfigUtil(const char* const command[]) {
// Detect, and if possible, start the appropriate proxy config utility. On
// failure to do so, show the Linux proxy config URL in a new tab instead.
-void DetectAndStartProxyConfigUtil(int render_process_id,
- int render_view_id) {
+void DetectAndStartProxyConfigUtil(int render_process_id, int render_view_id) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
std::unique_ptr<base::Environment> env(base::Environment::Create());
diff --git a/chromium/chrome/browser/ui/webui/settings_utils_mac.mm b/chromium/chrome/browser/ui/webui/settings/settings_utils_mac.mm
index 0611e978343..d6fdaaf7e57 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils_mac.mm
+++ b/chromium/chrome/browser/ui/webui/settings/settings_utils_mac.mm
@@ -4,7 +4,7 @@
#import <Cocoa/Cocoa.h>
-#include "chrome/browser/ui/webui/settings_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.h"
#include "base/logging.h"
#include "base/mac/mac_logging.h"
@@ -35,19 +35,19 @@ void ValidateFontFamily(PrefService* prefs, const char* family_pref_name) {
namespace settings_utils {
void ShowNetworkProxySettings(content::WebContents* web_contents) {
- NSArray* itemsToOpen = [NSArray arrayWithObject:[NSURL fileURLWithPath:
- @"/System/Library/PreferencePanes/Network.prefPane"]];
+ NSArray* itemsToOpen = [NSArray
+ arrayWithObject:[NSURL fileURLWithPath:@"/System/Library/PreferencePanes/"
+ @"Network.prefPane"]];
const char* proxyPrefCommand = "Proxies";
base::mac::ScopedAEDesc<> openParams;
- OSStatus status = AECreateDesc('ptru',
- proxyPrefCommand,
- strlen(proxyPrefCommand),
- openParams.OutPointer());
+ OSStatus status =
+ AECreateDesc('ptru', proxyPrefCommand, strlen(proxyPrefCommand),
+ openParams.OutPointer());
OSSTATUS_LOG_IF(ERROR, status != noErr, status)
<< "Failed to create open params";
- LSLaunchURLSpec launchSpec = { 0 };
+ LSLaunchURLSpec launchSpec = {0};
launchSpec.itemURLs = (CFArrayRef)itemsToOpen;
launchSpec.passThruParams = openParams;
launchSpec.launchFlags = kLSLaunchAsync | kLSLaunchDontAddToRecents;
@@ -56,11 +56,10 @@ void ShowNetworkProxySettings(content::WebContents* web_contents) {
void ShowManageSSLCertificates(content::WebContents* web_contents) {
NSString* const kKeychainBundleId = @"com.apple.keychainaccess";
- [[NSWorkspace sharedWorkspace]
- launchAppWithBundleIdentifier:kKeychainBundleId
- options:0L
- additionalEventParamDescriptor:nil
- launchIdentifier:nil];
+ [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:kKeychainBundleId
+ options:0L
+ additionalEventParamDescriptor:nil
+ launchIdentifier:nil];
}
void ValidateSavedFonts(PrefService* prefs) {
diff --git a/chromium/chrome/browser/ui/webui/settings_utils_unittest.cc b/chromium/chrome/browser/ui/webui/settings/settings_utils_unittest.cc
index 477cbf10728..e4b6f4c7397 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_utils_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_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
diff --git a/chromium/chrome/browser/ui/webui/settings_utils_win.cc b/chromium/chrome/browser/ui/webui/settings/settings_utils_win.cc
index 18d908eb7f6..30d6362c7f8 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils_win.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_utils_win.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_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.h"
#include <windows.h>
#include <shellapi.h>
@@ -38,9 +38,10 @@ class ManageCertificatesDialog : public ui::BaseShellDialogImpl {
// Shows the dialog and calls |callback| when the dialog closes. The caller
// must ensure the ManageCertificatesDialog remains valid until then.
- void Show(HWND parent, const base::Closure& callback) {
+ void Show(HWND parent, base::OnceClosure callback) {
if (IsRunningDialogForOwner(parent)) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
+ std::move(callback));
return;
}
@@ -53,7 +54,8 @@ class ManageCertificatesDialog : public ui::BaseShellDialogImpl {
base::BindOnce(&ManageCertificatesDialog::ShowOnDialogThread,
base::Unretained(this), parent),
base::BindOnce(&ManageCertificatesDialog::OnDialogClosed,
- base::Unretained(this), std::move(run_state), callback));
+ base::Unretained(this), std::move(run_state),
+ std::move(callback)));
}
private:
@@ -65,10 +67,10 @@ class ManageCertificatesDialog : public ui::BaseShellDialogImpl {
}
void OnDialogClosed(std::unique_ptr<RunState> run_state,
- const base::Closure& callback) {
+ base::OnceClosure callback) {
EndRun(std::move(run_state));
// May delete |this|.
- callback.Run();
+ std::move(callback).Run();
}
DISALLOW_COPY_AND_ASSIGN(ManageCertificatesDialog);
@@ -123,7 +125,7 @@ void ShowManageSSLCertificates(content::WebContents* web_contents) {
ManageCertificatesDialog* dialog = new ManageCertificatesDialog;
dialog->Show(
parent,
- base::Bind(&base::DeletePointer<ManageCertificatesDialog>, dialog));
+ base::BindOnce(&base::DeletePointer<ManageCertificatesDialog>, dialog));
}
} // namespace settings_utils
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 c8ada0fe8c2..3a5ab607cf1 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
@@ -10,16 +10,15 @@
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_features.h"
#include "components/google/core/common/google_util.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_manager/user_manager.h"
@@ -29,12 +28,14 @@
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
-#if defined(OS_CHROMEOS)
+#include "ui/chromeos/devicetype_utils.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/nearby_sharing/common/nearby_share_features.h"
-#endif // defined(OS_CHROMEOS)
+#include "chrome/common/url_constants.h"
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace settings {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
namespace {
// Generates a Google Help URL which includes a "board type" parameter. Some
@@ -86,7 +87,7 @@ void AddCaptionSubpageStrings(content::WebUIDataSource* html_source) {
{"captionsEnableLiveCaptionSubtitle",
IDS_SETTINGS_CAPTIONS_ENABLE_LIVE_CAPTION_SUBTITLE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
html_source->AddBoolean("enableLiveCaption",
base::FeatureList::IsEnabled(media::kLiveCaption));
@@ -99,7 +100,7 @@ void AddPersonalizationOptionsStrings(content::WebUIDataSource* html_source) {
{"urlKeyedAnonymizedDataCollectionDesc",
IDS_SETTINGS_ENABLE_URL_KEYED_ANONYMIZED_DATA_COLLECTION_DESC},
{"spellingPref", IDS_SETTINGS_SPELLING_PREF},
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
{"signinAllowedTitle", IDS_SETTINGS_SIGNIN_ALLOWED},
{"signinAllowedDescription", IDS_SETTINGS_SIGNIN_ALLOWED_DESC},
#endif
@@ -113,7 +114,7 @@ void AddPersonalizationOptionsStrings(content::WebUIDataSource* html_source) {
{"driveSuggestPref", IDS_DRIVE_SUGGEST_PREF},
{"driveSuggestPrefDesc", IDS_DRIVE_SUGGEST_PREF_DESC},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddSyncControlsStrings(content::WebUIDataSource* html_source) {
@@ -134,7 +135,7 @@ void AddSyncControlsStrings(content::WebUIDataSource* html_source) {
{"customizeSyncLabel", IDS_SETTINGS_CUSTOMIZE_SYNC},
{"syncData", IDS_SETTINGS_SYNC_DATA},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
void AddSyncAccountControlStrings(content::WebUIDataSource* html_source) {
@@ -152,10 +153,10 @@ void AddSyncAccountControlStrings(content::WebUIDataSource* html_source) {
{"useAnotherAccount", IDS_SETTINGS_PEOPLE_SYNC_ANOTHER_ACCOUNT},
{"syncAdvancedPageTitle", IDS_SETTINGS_NEW_SYNC_ADVANCED_PAGE_TITLE},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void AddPasswordPromptDialogStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"passwordPromptTitle", IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_TITLE},
@@ -164,7 +165,7 @@ void AddPasswordPromptDialogStrings(content::WebUIDataSource* html_source) {
{"passwordPromptPasswordLabel",
IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_PASSWORD_LABEL},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
#endif
@@ -205,7 +206,7 @@ void AddSyncPageStrings(content::WebUIDataSource* html_source) {
{"manageSyncedDataTitle",
IDS_SETTINGS_NEW_MANAGE_SYNCED_DATA_TITLE_UNIFIED_CONSENT},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
std::string sync_dashboard_url =
google_util::AppendGoogleLocaleParam(
@@ -232,24 +233,32 @@ void AddSyncPageStrings(content::WebUIDataSource* html_source) {
"encryptWithSyncPassphraseLabel",
l10n_util::GetStringFUTF8(
IDS_SETTINGS_ENCRYPT_WITH_SYNC_PASSPHRASE_LABEL,
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
GetHelpUrlWithBoard(chrome::kSyncEncryptionHelpURL)));
#else
base::ASCIIToUTF16(chrome::kSyncEncryptionHelpURL)));
#endif
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void AddNearbyShareData(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"nearbyShareTitle", IDS_SETTINGS_NEARBY_SHARE_TITLE},
+ {"nearbyShareSetUpButtonTitle",
+ IDS_SETTINGS_NEARBY_SHARE_SET_UP_BUTTON_TITLE},
{"nearbyShareDeviceNameRowTitle",
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_ROW_TITLE},
{"nearbyShareDeviceNameDialogTitle",
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_DIALOG_TITLE},
+ {"nearbyShareDeviceNameFieldLabel",
+ IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_FIELD_LABEL},
{"nearbyShareEditDeviceName", IDS_SETTINGS_NEARBY_SHARE_EDIT_DEVICE_NAME},
{"nearbyShareDeviceNameAriaDescription",
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_ARIA_DESCRIPTION},
+ {"nearbyShareManageContactsLabel",
+ IDS_SETTINGS_NEARBY_SHARE_MANAGE_CONTACTS_LABEL},
+ {"nearbyShareManageContactsRowTitle",
+ IDS_SETTINGS_NEARBY_SHARE_MANAGE_CONTACTS_ROW_TITLE},
{"nearbyShareEditDataUsage", IDS_SETTINGS_NEARBY_SHARE_EDIT_DATA_USAGE},
{"nearbyShareUpdateDataUsage",
IDS_SETTINGS_NEARBY_SHARE_UPDATE_DATA_USAGE},
@@ -260,9 +269,11 @@ void AddNearbyShareData(content::WebUIDataSource* html_source) {
{"nearbyShareDataUsageWifiOnlyDescription",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_WIFI_ONLY_DESCRIPTION},
{"nearbyShareDataUsageDataLabel",
- IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DATA_LABEL},
+ IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_MOBILE_DATA_LABEL},
{"nearbyShareDataUsageDataDescription",
- IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DATA_DESCRIPTION},
+ IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_MOBILE_DATA_DESCRIPTION},
+ {"nearbyShareDataUsageDataTooltip",
+ IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_MOBILE_DATA_TOOLTIP},
{"nearbyShareDataUsageOfflineLabel",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_OFFLINE_LABEL},
{"nearbyShareDataUsageOfflineDescription",
@@ -277,13 +288,16 @@ void AddNearbyShareData(content::WebUIDataSource* html_source) {
IDS_SETTINGS_NEARBY_SHARE_CONTACT_VISIBILITY_ROW_TITLE},
{"nearbyShareEditVisibility", IDS_SETTINGS_NEARBY_SHARE_EDIT_VISIBILITY},
{"nearbyShareVisibilityDialogTitle",
- IDS_SETTINGS_NEARBY_SHARE_VISIBILITY_DIALOG_TITLE}};
-
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ IDS_SETTINGS_NEARBY_SHARE_VISIBILITY_DIALOG_TITLE},
+ {"nearbyShareDescription", IDS_SETTINGS_NEARBY_SHARE_DESCRIPTION},
+ {"nearbyShareHighVisibilityTitle",
+ IDS_SETTINGS_NEARBY_SHARE_HIGH_VISIBILITY_TITLE},
+ {"nearbyShareHighVisibilityOn",
+ IDS_SETTINGS_NEARBY_SHARE_HIGH_VISIBILITY_ON},
+ {"nearbyShareHighVisibilityOff",
+ IDS_SETTINGS_NEARBY_SHARE_HIGH_VISIBILITY_OFF}};
- html_source->AddBoolean(
- "nearbySharingFeatureFlag",
- base::FeatureList::IsEnabled(features::kNearbySharing));
+ html_source->AddLocalizedStrings(kLocalizedStrings);
// To use lottie, the worker-src CSP needs to be updated for the web ui that
// is using it. Since as of now there are only a couple of webuis using
@@ -293,6 +307,6 @@ void AddNearbyShareData(content::WebUIDataSource* html_source) {
html_source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::WorkerSrc, "worker-src blob: 'self';");
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h b/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h
index cf4f17a0a5f..d0138b68721 100644
--- a/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h
+++ b/chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SHARED_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SHARED_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
+#include "build/chromeos_buildflags.h"
+
namespace content {
class WebUIDataSource;
} // namespace content
@@ -23,7 +25,7 @@ void AddSyncControlsStrings(content::WebUIDataSource* html_source);
// Adds strings used by the <settings-sync-account-control> element.
void AddSyncAccountControlStrings(content::WebUIDataSource* html_source);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Adds strings used by the <settings-password-prompt-dialog> element.
void AddPasswordPromptDialogStrings(content::WebUIDataSource* html_source);
#endif
@@ -31,10 +33,10 @@ void AddPasswordPromptDialogStrings(content::WebUIDataSource* html_source);
// Adds strings used by the <settings-sync-page> element.
void AddSyncPageStrings(content::WebUIDataSource* html_source);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Adds load time data used by the <settings-nearby-share-subpage>.
void AddNearbyShareData(content::WebUIDataSource* html_source);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace settings
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 9a28e12cad0..73dd3c48952 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -11,18 +11,18 @@
#include "base/barrier_closure.h"
#include "base/bind.h"
+#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/i18n/number_formatting.h"
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
-#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/bluetooth/bluetooth_chooser_context.h"
#include "chrome/browser/bluetooth/bluetooth_chooser_context_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
-#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/hid/hid_chooser_context.h"
#include "chrome/browser/hid/hid_chooser_context_factory.h"
#include "chrome/browser/infobars/infobar_service.h"
@@ -56,6 +56,7 @@
#include "components/permissions/permission_util.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
+#include "components/site_engagement/content/site_engagement_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -64,12 +65,12 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/permissions_data.h"
-#include "third_party/blink/public/common/loader/network_utils.h"
+#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "third_party/blink/public/common/page/page_zoom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/text/bytes_formatting.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "components/user_manager/user_manager.h"
#endif
@@ -234,8 +235,8 @@ void ConvertSiteGroupMapToListValue(
DCHECK(profile);
base::flat_set<std::string> installed_origins =
GetInstalledAppOrigins(profile, registrar);
- SiteEngagementService* engagement_service =
- SiteEngagementService::Get(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);
@@ -313,7 +314,7 @@ bool IsPatternValidForType(const std::string& pattern_string,
// return false with a string saying why.
GURL url(pattern_string);
if (url.is_valid() && map->IsRestrictedToSecureOrigins(content_type) &&
- !blink::network_utils::IsOriginSecure(url)) {
+ !network::IsUrlPotentiallyTrustworthy(url)) {
*out_error = l10n_util::GetStringUTF8(
IDS_SETTINGS_NOT_VALID_WEB_ADDRESS_FOR_CONTENT_TYPE);
return false;
@@ -520,33 +521,33 @@ void SiteSettingsHandler::OnJavascriptAllowed() {
// If the block autoplay pref changes send the new status.
pref_change_registrar_->Add(
prefs::kBlockAutoplayEnabled,
- base::Bind(&SiteSettingsHandler::SendBlockAutoplayStatus,
- base::Unretained(this)));
+ base::BindRepeating(&SiteSettingsHandler::SendBlockAutoplayStatus,
+ base::Unretained(this)));
// Listen for prefs that impact the effective cookie setting
pref_change_registrar_->Add(
prefs::kCookieControlsMode,
- base::Bind(&SiteSettingsHandler::SendCookieSettingDescription,
- base::Unretained(this)));
+ base::BindRepeating(&SiteSettingsHandler::SendCookieSettingDescription,
+ base::Unretained(this)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
pref_change_registrar_->Add(
prefs::kEnableDRM,
- base::Bind(&SiteSettingsHandler::OnPrefEnableDrmChanged,
- base::Unretained(this)));
+ base::BindRepeating(&SiteSettingsHandler::OnPrefEnableDrmChanged,
+ base::Unretained(this)));
#endif
}
void SiteSettingsHandler::OnJavascriptDisallowed() {
- observer_.RemoveAll();
- chooser_observer_.RemoveAll();
- host_zoom_map_subscription_.reset();
+ observations_.RemoveAllObservations();
+ chooser_observations_.RemoveAllObservations();
+ host_zoom_map_subscription_ = {};
pref_change_registrar_->Remove(prefs::kBlockAutoplayEnabled);
pref_change_registrar_->Remove(prefs::kCookieControlsMode);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
pref_change_registrar_->Remove(prefs::kEnableDRM);
#endif
- observed_profiles_.RemoveAll();
+ observed_profiles_.RemoveAllObservations();
}
void SiteSettingsHandler::OnGetUsageInfo() {
@@ -573,7 +574,7 @@ void SiteSettingsHandler::OnGetUsageInfo() {
base::Value(usage_string), base::Value(cookie_string));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void SiteSettingsHandler::OnPrefEnableDrmChanged() {
FireWebUIListener("prefEnableDrmChanged");
}
@@ -692,7 +693,7 @@ void SiteSettingsHandler::HandleSetDefaultValueForContentType(
site_settings::ContentSettingsTypeFromGroupName(content_type);
Profile* profile = profile_;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// ChromeOS special case: in Guest mode, settings are opened in Incognito
// mode so we need the original profile to actually modify settings.
if (user_manager::UserManager::Get()->IsLoggedInAsGuest())
@@ -1435,58 +1436,58 @@ void SiteSettingsHandler::EnsureCookiesTreeModelCreated() {
void SiteSettingsHandler::ObserveSourcesForProfile(Profile* profile) {
auto* map = HostContentSettingsMapFactory::GetForProfile(profile);
- if (!observer_.IsObserving(map))
- observer_.Add(map);
+ if (!observations_.IsObservingSource(map))
+ observations_.AddObservation(map);
auto* usb_context = UsbChooserContextFactory::GetForProfile(profile);
- if (!chooser_observer_.IsObserving(usb_context))
- chooser_observer_.Add(usb_context);
+ if (!chooser_observations_.IsObservingSource(usb_context))
+ chooser_observations_.AddObservation(usb_context);
auto* serial_context = SerialChooserContextFactory::GetForProfile(profile);
- if (!chooser_observer_.IsObserving(serial_context))
- chooser_observer_.Add(serial_context);
+ if (!chooser_observations_.IsObservingSource(serial_context))
+ chooser_observations_.AddObservation(serial_context);
auto* hid_context = HidChooserContextFactory::GetForProfile(profile);
- if (!chooser_observer_.IsObserving(hid_context))
- chooser_observer_.Add(hid_context);
+ if (!chooser_observations_.IsObservingSource(hid_context))
+ chooser_observations_.AddObservation(hid_context);
if (base::FeatureList::IsEnabled(
features::kWebBluetoothNewPermissionsBackend)) {
auto* bluetooth_context =
BluetoothChooserContextFactory::GetForProfile(profile);
- if (!chooser_observer_.IsObserving(bluetooth_context))
- chooser_observer_.Add(bluetooth_context);
+ if (!chooser_observations_.IsObservingSource(bluetooth_context))
+ chooser_observations_.AddObservation(bluetooth_context);
}
- observed_profiles_.Add(profile);
+ observed_profiles_.AddObservation(profile);
}
void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) {
auto* map = HostContentSettingsMapFactory::GetForProfile(profile);
- if (observer_.IsObserving(map))
- observer_.Remove(map);
+ if (observations_.IsObservingSource(map))
+ observations_.RemoveObservation(map);
auto* usb_context = UsbChooserContextFactory::GetForProfile(profile);
- if (chooser_observer_.IsObserving(usb_context))
- chooser_observer_.Remove(usb_context);
+ if (chooser_observations_.IsObservingSource(usb_context))
+ chooser_observations_.RemoveObservation(usb_context);
auto* serial_context = SerialChooserContextFactory::GetForProfile(profile);
- if (chooser_observer_.IsObserving(serial_context))
- chooser_observer_.Remove(serial_context);
+ if (chooser_observations_.IsObservingSource(serial_context))
+ chooser_observations_.RemoveObservation(serial_context);
auto* hid_context = HidChooserContextFactory::GetForProfile(profile);
- if (chooser_observer_.IsObserving(hid_context))
- chooser_observer_.Remove(hid_context);
+ if (chooser_observations_.IsObservingSource(hid_context))
+ chooser_observations_.RemoveObservation(hid_context);
if (base::FeatureList::IsEnabled(
features::kWebBluetoothNewPermissionsBackend)) {
auto* bluetooth_context =
BluetoothChooserContextFactory::GetForProfile(profile);
- if (chooser_observer_.IsObserving(bluetooth_context))
- chooser_observer_.Remove(bluetooth_context);
+ if (chooser_observations_.IsObservingSource(bluetooth_context))
+ chooser_observations_.RemoveObservation(bluetooth_context);
}
- observed_profiles_.Remove(profile);
+ observed_profiles_.RemoveObservation(profile);
}
void SiteSettingsHandler::TreeNodesAdded(ui::TreeModel* model,
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 54c9689d3f4..70758bf88d5 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
@@ -11,7 +11,8 @@
#include <string>
#include "base/containers/flat_set.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_multi_source_observation.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browsing_data/cookies_tree_model.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_observer.h"
@@ -68,7 +69,7 @@ class SiteSettingsHandler
void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node) override;
void TreeModelEndBatch(CookiesTreeModel* model) override;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// Alert the Javascript that the |kEnableDRM| pref has changed.
void OnPrefEnableDrmChanged();
#endif
@@ -87,7 +88,6 @@ class SiteSettingsHandler
ContentSettingsType guard_content_settings_type,
ContentSettingsType data_content_settings_type) override;
- // content::HostZoomMap subscription.
void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
private:
@@ -262,11 +262,11 @@ class SiteSettingsHandler
Profile* profile_;
web_app::AppRegistrar& app_registrar_;
- ScopedObserver<Profile, ProfileObserver> observed_profiles_{this};
+ base::ScopedMultiSourceObservation<Profile, ProfileObserver>
+ observed_profiles_{this};
// Keeps track of events related to zooming.
- std::unique_ptr<content::HostZoomMap::Subscription>
- host_zoom_map_subscription_;
+ base::CallbackListSubscription host_zoom_map_subscription_;
// The host for which to fetch usage.
std::string usage_host_;
@@ -275,13 +275,15 @@ class SiteSettingsHandler
std::string clearing_origin_;
// Change observer for content settings.
- ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_{
- this};
+ base::ScopedMultiSourceObservation<HostContentSettingsMap,
+ content_settings::Observer>
+ observations_{this};
// Change observer for chooser permissions.
- ScopedObserver<permissions::ChooserContextBase,
- permissions::ChooserContextBase::PermissionObserver>
- chooser_observer_{this};
+ base::ScopedMultiSourceObservation<
+ permissions::ChooserContextBase,
+ permissions::ChooserContextBase::PermissionObserver>
+ chooser_observations_{this};
// Change observer for prefs.
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
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 10d5fbfd319..b54f5d0d7fa 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
@@ -19,6 +19,7 @@
#include "base/test/simple_test_clock.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h"
@@ -67,7 +68,7 @@
#include "ui/base/text/bytes_formatting.h"
#include "ui/webui/webui_allowlist.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#endif
@@ -154,7 +155,7 @@ class SiteSettingsHandlerTest : public testing::Test {
ContentSettingsType::NOTIFICATIONS)),
kCookies(site_settings::ContentSettingsTypeToGroupName(
ContentSettingsType::COOKIES)) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
std::make_unique<chromeos::MockUserManager>());
#endif
@@ -494,7 +495,7 @@ class SiteSettingsHandlerTest : public testing::Test {
web_app::TestAppRegistrar app_registrar_;
content::TestWebUI web_ui_;
std::unique_ptr<SiteSettingsHandler> handler_;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
std::unique_ptr<user_manager::ScopedUserManager> user_manager_enabler_;
#endif
};
@@ -767,7 +768,7 @@ TEST_F(SiteSettingsHandlerTest, GetRecentSitePermissions) {
url1, ContentSettingsType::NOTIFICATIONS, false);
clock.Advance(base::TimeDelta::FromHours(2));
- map->SetContentSettingDefaultScope(url2, url2, ContentSettingsType::PLUGINS,
+ map->SetContentSettingDefaultScope(url2, url2, ContentSettingsType::IMAGES,
CONTENT_SETTING_ALLOW);
clock.Advance(base::TimeDelta::FromHours(1));
CreateIncognitoProfile();
@@ -775,7 +776,7 @@ TEST_F(SiteSettingsHandlerTest, GetRecentSitePermissions) {
HostContentSettingsMapFactory::GetForProfile(incognito_profile());
incognito_map->SetClockForTesting(&clock);
incognito_map->SetContentSettingDefaultScope(
- url1, url1, ContentSettingsType::PLUGINS, CONTENT_SETTING_ALLOW);
+ url1, url1, ContentSettingsType::IMAGES, CONTENT_SETTING_ALLOW);
clock.Advance(base::TimeDelta::FromHours(1));
permissions::PermissionDecisionAutoBlocker* incognito_auto_blocker =
@@ -2147,7 +2148,8 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
HandleGetChooserExceptionListForUsb) {
const std::string kUsbChooserGroupName =
site_settings::ContentSettingsTypeToGroupName(
- ContentSettingsType::USB_CHOOSER_DATA);
+ ContentSettingsType::USB_CHOOSER_DATA)
+ .as_string();
const base::Value& exceptions = GetChooserExceptionListFromWebUiCallData(
kUsbChooserGroupName, /*expected_total_calls=*/1u);
@@ -2163,7 +2165,8 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
HandleGetChooserExceptionListForUsbOffTheRecord) {
const std::string kUsbChooserGroupName =
site_settings::ContentSettingsTypeToGroupName(
- ContentSettingsType::USB_CHOOSER_DATA);
+ ContentSettingsType::USB_CHOOSER_DATA)
+ .as_string();
SetUpOffTheRecordUsbChooserContext();
web_ui()->ClearTrackedCalls();
@@ -2199,7 +2202,8 @@ TEST_F(SiteSettingsHandlerChooserExceptionTest,
HandleResetChooserExceptionForSiteForUsb) {
const std::string kUsbChooserGroupName =
site_settings::ContentSettingsTypeToGroupName(
- ContentSettingsType::USB_CHOOSER_DATA);
+ ContentSettingsType::USB_CHOOSER_DATA)
+ .as_string();
const auto kAndroidOrigin = url::Origin::Create(AndroidUrl());
const auto kChromiumOrigin = url::Origin::Create(ChromiumUrl());
const std::string kAndroidOriginStr = AndroidUrl().GetOrigin().spec();
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 cc79a7320b1..af39c456668 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc
@@ -9,8 +9,8 @@
#include <set>
#include <string>
+#include "base/containers/contains.h"
#include "base/feature_list.h"
-#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -80,7 +80,6 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
{ContentSettingsType::COOKIES, "cookies"},
{ContentSettingsType::IMAGES, "images"},
{ContentSettingsType::JAVASCRIPT, "javascript"},
- {ContentSettingsType::PLUGINS, "plugins"},
{ContentSettingsType::POPUPS, "popups"},
{ContentSettingsType::GEOLOCATION, "location"},
{ContentSettingsType::NOTIFICATIONS, "notifications"},
@@ -149,8 +148,12 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
{ContentSettingsType::INSECURE_PRIVATE_NETWORK, nullptr},
{ContentSettingsType::PERMISSION_AUTOREVOCATION_DATA, nullptr},
{ContentSettingsType::FILE_SYSTEM_LAST_PICKED_DIRECTORY, nullptr},
+ {ContentSettingsType::DISPLAY_CAPTURE, nullptr},
};
-static_assert(base::size(kContentSettingsTypeGroupNames) ==
+
+// TODO(crbug.com/1149878): After removing
+// ContentSettingsType::DEPRECATED_PLUGINS, remove +1.
+static_assert(base::size(kContentSettingsTypeGroupNames) + 1 ==
// ContentSettingsType starts at -1, so add 1 here.
static_cast<int32_t>(ContentSettingsType::NUM_TYPES) + 1,
"kContentSettingsTypeGroupNames should have "
@@ -374,7 +377,7 @@ bool HasRegisteredGroupName(ContentSettingsType type) {
return false;
}
-ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) {
+ContentSettingsType ContentSettingsTypeFromGroupName(base::StringPiece name) {
for (size_t i = 0; i < base::size(kContentSettingsTypeGroupNames); ++i) {
if (name == kContentSettingsTypeGroupNames[i].name)
return kContentSettingsTypeGroupNames[i].type;
@@ -384,7 +387,7 @@ ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) {
return ContentSettingsType::DEFAULT;
}
-std::string ContentSettingsTypeToGroupName(ContentSettingsType type) {
+base::StringPiece ContentSettingsTypeToGroupName(ContentSettingsType type) {
for (size_t i = 0; i < base::size(kContentSettingsTypeGroupNames); ++i) {
if (type == kContentSettingsTypeGroupNames[i].type) {
const char* name = kContentSettingsTypeGroupNames[i].name;
@@ -396,7 +399,7 @@ std::string ContentSettingsTypeToGroupName(ContentSettingsType type) {
NOTREACHED() << static_cast<int32_t>(type)
<< " is not a recognized content settings type.";
- return std::string();
+ return base::StringPiece();
}
std::vector<ContentSettingsType> ContentSettingsTypesFromGroupNames(
@@ -455,8 +458,7 @@ std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
const ContentSetting& setting,
const std::string& provider_name,
bool incognito,
- bool is_embargoed,
- bool is_discarded) {
+ bool is_embargoed) {
auto exception = std::make_unique<base::DictionaryValue>();
exception->SetString(kOrigin, pattern.ToString());
exception->SetString(kDisplayName, display_name);
@@ -473,7 +475,6 @@ std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
exception->SetString(kSource, provider_name);
exception->SetBoolean(kIncognito, incognito);
exception->SetBoolean(kIsEmbargoed, is_embargoed);
- exception->SetBoolean(kIsDiscarded, is_discarded);
return exception;
}
@@ -542,11 +543,6 @@ void GetExceptionsForContentType(
map->GetSettingsForOneType(type, &all_settings);
- // Will return only regular settings for a regular profile and only incognito
- // settings for an incognito Profile.
- ContentSettingsForOneType discarded_settings;
- map->GetDiscardedSettingsForOneType(type, &discarded_settings);
-
// Group settings by primary_pattern.
AllPatternsSettings all_patterns_settings;
for (const auto& setting : all_settings) {
@@ -670,15 +666,6 @@ void GetExceptionsForContentType(
for (auto& exception : one_provider_exceptions)
exceptions->Append(std::move(exception));
}
-
- for (auto& discarded_rule : discarded_settings) {
- exceptions->Append(GetExceptionForPage(
- discarded_rule.primary_pattern, discarded_rule.secondary_pattern,
- GetDisplayNameForPattern(discarded_rule.primary_pattern,
- extension_registry),
- discarded_rule.GetContentSetting(), discarded_rule.source, incognito,
- false /*is_embargoed*/, true /*is_discarded*/));
- }
}
void GetContentCategorySetting(const HostContentSettingsMap* map,
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 afd78140f71..34704af033a 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.h
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.h
@@ -13,6 +13,7 @@
#include <vector>
#include "base/strings/string16.h"
+#include "base/strings/string_piece.h"
#include "base/values.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
@@ -68,7 +69,6 @@ constexpr char kPolicyIndicator[] = "indicator";
constexpr char kSource[] = "source";
constexpr char kType[] = "type";
constexpr char kIsEmbargoed[] = "isEmbargoed";
-constexpr char kIsDiscarded[] = "isDiscarded";
enum class SiteSettingSource {
kAllowlist,
@@ -110,8 +110,8 @@ struct ManagedState {
bool HasRegisteredGroupName(ContentSettingsType type);
// Converts a ContentSettingsType to/from its group name identifier.
-ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name);
-std::string ContentSettingsTypeToGroupName(ContentSettingsType type);
+ContentSettingsType ContentSettingsTypeFromGroupName(base::StringPiece name);
+base::StringPiece ContentSettingsTypeToGroupName(ContentSettingsType type);
// Converts a ListValue of group names to a list of ContentSettingsTypes
std::vector<ContentSettingsType> ContentSettingsTypesFromGroupNames(
@@ -131,8 +131,7 @@ std::unique_ptr<base::DictionaryValue> GetExceptionForPage(
const ContentSetting& setting,
const std::string& provider_name,
bool incognito,
- bool is_embargoed = false,
- bool is_discarded = false);
+ bool is_embargoed = false);
// Helper function to construct a dictionary for a hosted app exception.
void AddExceptionForHostedApp(const std::string& url_pattern,
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 f1418e4d0fc..93d30f0b05d 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
@@ -8,6 +8,7 @@
#include "base/guid.h"
#include "base/json/json_reader.h"
#include "base/strings/utf_string_conversions.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/permissions/permission_decision_auto_blocker_factory.h"
#include "chrome/browser/usb/usb_chooser_context.h"
@@ -416,7 +417,7 @@ TEST_F(SiteSettingsHelperTest, ContentSettingSource) {
EXPECT_EQ(CONTENT_SETTING_ALLOW, content_setting);
// ChromeOS - DRM disabled.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
profile.GetPrefs()->SetBoolean(prefs::kEnableDRM, false);
// Note this is not testing |kContentType|, because this setting is only valid
// for protected content.
@@ -559,7 +560,8 @@ void ExpectValidSiteExceptionObject(const base::Value& actual_site_object,
TEST_F(SiteSettingsHelperTest, CreateChooserExceptionObject) {
const std::string kUsbChooserGroupName =
- ContentSettingsTypeToGroupName(ContentSettingsType::USB_CHOOSER_DATA);
+ ContentSettingsTypeToGroupName(ContentSettingsType::USB_CHOOSER_DATA)
+ .as_string();
const std::string& kPolicySource =
SiteSettingSourceToString(SiteSettingSource::kPolicy);
const std::string& kPreferenceSource =
@@ -751,7 +753,8 @@ void ExpectDisplayNameEq(const base::Value& actual_exception_object,
TEST_F(SiteSettingsHelperChooserExceptionTest,
GetChooserExceptionListFromProfile) {
const std::string kUsbChooserGroupName =
- ContentSettingsTypeToGroupName(ContentSettingsType::USB_CHOOSER_DATA);
+ ContentSettingsTypeToGroupName(ContentSettingsType::USB_CHOOSER_DATA)
+ .as_string();
const ChooserTypeNameEntry* chooser_type =
ChooserTypeFromGroupName(kUsbChooserGroupName);
const std::string& kPolicySource =
diff --git a/chromium/chrome/browser/ui/webui/settings/system_handler.cc b/chromium/chrome/browser/ui/webui/settings/system_handler.cc
index e6bd10d4d24..1c56b8ef0a9 100644
--- a/chromium/chrome/browser/ui/webui/settings/system_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/system_handler.cc
@@ -10,7 +10,7 @@
#include "base/metrics/user_metrics_action.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/gpu/gpu_mode_manager.h"
-#include "chrome/browser/ui/webui/settings_utils.h"
+#include "chrome/browser/ui/webui/settings/settings_utils.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/signin/DIR_METADATA b/chromium/chrome/browser/ui/webui/signin/DIR_METADATA
new file mode 100644
index 00000000000..5fad6891646
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "Services>SignIn"
+}
diff --git a/chromium/chrome/browser/ui/webui/signin/OWNERS b/chromium/chrome/browser/ui/webui/signin/OWNERS
index 1c786a84ea9..56a7a1e04ee 100644
--- a/chromium/chrome/browser/ui/webui/signin/OWNERS
+++ b/chromium/chrome/browser/ui/webui/signin/OWNERS
@@ -7,6 +7,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://chromeos/components/account_manager/OWNERS
-
-# COMPONENT: Services>SignIn
+per-file inline_login_*_chromeos*=file://ash/components/account_manager/OWNERS
+per-file signin_helper_chromeos.*=file://ash/components/account_manager/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
index 1d50fec34c7..964ad7e3728 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
@@ -35,6 +35,7 @@
#include "chrome/browser/ui/tab_dialogs.h"
#include "chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
+#include "chrome/browser/ui/webui/signin/signin_ui_error.h"
#include "chrome/browser/ui/webui/signin/signin_utils_desktop.h"
#include "chrome/browser/unified_consent/unified_consent_service_factory.h"
#include "components/keyed_service/content/browser_context_keyed_service_shutdown_notifier_factory.h"
@@ -161,18 +162,18 @@ void SetCurrentDiceTurnSyncOnHelper(Profile* profile,
// static
void DiceTurnSyncOnHelper::Delegate::ShowLoginErrorForBrowser(
- const std::string& email,
- const std::string& error_message,
+ const base::string16& email,
+ const base::string16& error_message,
Browser* browser) {
LoginUIServiceFactory::GetForProfile(browser->profile())
- ->DisplayLoginResult(browser, base::UTF8ToUTF16(error_message),
- base::UTF8ToUTF16(email));
+ ->DisplayLoginResult(browser, error_message, email);
}
// static
void DiceTurnSyncOnHelper::Delegate::
ShowEnterpriseAccountConfirmationForBrowser(
const std::string& email,
+ bool prompt_for_new_profile,
DiceTurnSyncOnHelper::SigninChoiceCallback callback,
Browser* browser) {
DCHECK(callback);
@@ -187,7 +188,7 @@ void DiceTurnSyncOnHelper::Delegate::
base::UserMetricsAction("Signin_Show_EnterpriseAccountPrompt"));
TabDialogs::FromWebContents(web_contents)
->ShowProfileSigninConfirmation(
- browser, browser->profile(), email,
+ browser, email, prompt_for_new_profile,
std::make_unique<SigninDialogDelegate>(std::move(callback)));
}
@@ -212,12 +213,13 @@ DiceTurnSyncOnHelper::DiceTurnSyncOnHelper(
shutdown_subscription_(
DiceTurnSyncOnHelperShutdownNotifierFactory::GetInstance()
->Get(profile)
- ->Subscribe(base::Bind(&DiceTurnSyncOnHelper::AbortAndDelete,
- base::Unretained(this)))) {
+ ->Subscribe(base::AdaptCallbackForRepeating(
+ base::BindOnce(&DiceTurnSyncOnHelper::AbortAndDelete,
+ base::Unretained(this))))) {
DCHECK(delegate_);
DCHECK(profile_);
// Should not start syncing if the profile is already authenticated
- DCHECK(!identity_manager_->HasPrimaryAccount());
+ DCHECK(!identity_manager_->HasPrimaryAccount(signin::ConsentLevel::kSync));
// Cancel any existing helper.
AttachToProfile();
@@ -280,15 +282,14 @@ DiceTurnSyncOnHelper::~DiceTurnSyncOnHelper() {
}
bool DiceTurnSyncOnHelper::HasCanOfferSigninError() {
- std::string error_msg;
- bool can_offer =
+ SigninUIError can_offer_error =
CanOfferSignin(profile_, CAN_OFFER_SIGNIN_FOR_ALL_ACCOUNTS,
- account_info_.gaia, account_info_.email, &error_msg);
- if (can_offer)
+ account_info_.gaia, account_info_.email);
+ if (can_offer_error.IsOk())
return false;
// Display the error message
- delegate_->ShowLoginError(account_info_.email, error_msg);
+ delegate_->ShowLoginError(can_offer_error);
return true;
}
@@ -442,6 +443,7 @@ void DiceTurnSyncOnHelper::CreateNewSignedInProfile() {
std::make_unique<DiceSignedInProfileCreator>(
profile_, account_info_.account_id,
/*local_profile_name=*/base::string16(), /*icon_index=*/base::nullopt,
+ /*use_guest=*/false,
base::BindOnce(&DiceTurnSyncOnHelper::OnNewSignedInProfileCreated,
base::Unretained(this)));
}
@@ -552,7 +554,17 @@ void DiceTurnSyncOnHelper::ShowSyncConfirmationUI() {
base::BindOnce(&DiceTurnSyncOnHelper::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(&DiceTurnSyncOnHelper::FinishSyncSetupAndDelete,
weak_pointer_factory_.GetWeakPtr()));
}
@@ -578,16 +590,21 @@ void DiceTurnSyncOnHelper::FinishSyncSetupAndDelete(
consent_service->SetUrlKeyedAnonymizedDataCollectionEnabled(true);
break;
}
- case LoginUIService::ABORT_SIGNIN:
+ case LoginUIService::ABORT_SYNC: {
auto* primary_account_mutator =
identity_manager_->GetPrimaryAccountMutator();
DCHECK(primary_account_mutator);
- primary_account_mutator->ClearPrimaryAccount(
- signin::PrimaryAccountMutator::ClearAccountsAction::kKeepAll,
+ primary_account_mutator->RevokeSyncConsent(
signin_metrics::ABORT_SIGNIN,
signin_metrics::SignoutDelete::IGNORE_METRIC);
AbortAndDelete();
return;
+ }
+ // No explicit action when the ui gets closed. If the embedder wants the
+ // helper to abort sync in this case, it must redirect this action to
+ // ABORT_SYNC.
+ case LoginUIService::UI_CLOSED:
+ break;
}
delete this;
}
@@ -606,8 +623,8 @@ void DiceTurnSyncOnHelper::SwitchToProfile(Profile* new_profile) {
shutdown_subscription_ =
DiceTurnSyncOnHelperShutdownNotifierFactory::GetInstance()
->Get(profile_)
- ->Subscribe(base::Bind(&DiceTurnSyncOnHelper::AbortAndDelete,
- base::Unretained(this)));
+ ->Subscribe(base::AdaptCallbackForRepeating(base::BindOnce(
+ &DiceTurnSyncOnHelper::AbortAndDelete, base::Unretained(this))));
delegate_->SwitchToProfile(new_profile);
// Since this is a fresh profile, it's better to remove the token if the user
// aborts the signin.
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h
index d909259b01d..186d279df43 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h
@@ -22,6 +22,7 @@
class Browser;
class DiceSignedInProfileCreator;
+class SigninUIError;
namespace signin {
class IdentityManager;
@@ -39,6 +40,8 @@ class DiceTurnSyncOnHelper
public policy::PolicyService::ProviderUpdateObserver {
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
+ // implies removing the account.
enum class SigninAbortedMode {
// The token is revoked and the account is signed out of the web.
REMOVE_ACCOUNT,
@@ -66,10 +69,7 @@ class DiceTurnSyncOnHelper
virtual ~Delegate() {}
// Shows a login error to the user.
- // TODO(crbug.com/1133189): Replace `error_message` with an enum as
- // different types of UI are shown for different actions.
- virtual void ShowLoginError(const std::string& email,
- const std::string& error_message) = 0;
+ virtual void ShowLoginError(const SigninUIError& error) = 0;
// Shows a confirmation dialog when the user was previously signed in with a
// different account in the same profile. |callback| must be called.
@@ -80,21 +80,34 @@ class DiceTurnSyncOnHelper
// Shows a confirmation dialog when the user is signing in a managed
// account. |callback| must be called.
+ // NOTE: When this is called, any subsequent call to
+ // ShowSync(Disabled)Confirmation will have is_managed_account set to true.
+ // The other implication is only partially true: for a managed account,
+ // ShowEnterpriseAccountConfirmation() must be called before calling
+ // ShowSyncConfirmation() but it does not have to be called before calling
+ // ShowSyncDisabledConfirmation(). Namely, Chrome can have clarity about
+ // sync being disabled even before fetching enterprise policies (e.g. sync
+ // engine gets a 'disabled-by-enterprise' error from the server).
virtual void ShowEnterpriseAccountConfirmation(
const std::string& email,
SigninChoiceCallback callback) = 0;
// Shows a sync confirmation screen offering to open the Sync settings.
// |callback| must be called.
+ // NOTE: The account is managed iff ShowEnterpriseAccountConfirmation() has
+ // been called before.
virtual void ShowSyncConfirmation(
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) = 0;
- // Shows a confirmation screen offering to stay signed-in or to signout.
- // |callback| must be called.
+ // 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
+ // called.
// TODO(crbug.com/1126913): Use a new enum for this callback with only
// values that make sense here (stay signed-in / signout).
virtual void ShowSyncDisabledConfirmation(
+ bool is_managed_account,
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) = 0;
@@ -104,20 +117,23 @@ class DiceTurnSyncOnHelper
// Informs the delegate that the flow is switching to a new profile.
virtual void SwitchToProfile(Profile* new_profile) = 0;
- protected:
// Shows the login error with `error_message` and `email` for `browser`.
// This helper is static because in some cases it needs to be called
// after this object gets destroyed.
- static void ShowLoginErrorForBrowser(const std::string& email,
- const std::string& error_message,
+ // TODO(crbug.com/1133189): Replace `email` and `error_message` with a
+ // `SigninUIError`.
+ static void ShowLoginErrorForBrowser(const base::string16& email,
+ const base::string16& error_message,
Browser* browser);
// Shows the enterprise account confirmation dialog with `email` for
- // `browser` and returns the result via `callback`. This helper is static
+ // `browser` and returns the result via `callback`. The variant of the
+ // dialog is based on `prompt_for_new_profile`. This helper is static
// because in some cases it needs to be called after this object gets
// destroyed.
static void ShowEnterpriseAccountConfirmationForBrowser(
const std::string& email,
+ bool prompt_for_new_profile,
DiceTurnSyncOnHelper::SigninChoiceCallback callback,
Browser* browser);
};
@@ -255,8 +271,7 @@ class DiceTurnSyncOnHelper
std::unique_ptr<SyncStartupTracker> sync_startup_tracker_;
std::unique_ptr<DiceSignedInProfileCreator> dice_signed_in_profile_creator_;
- std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>
- shutdown_subscription_;
+ base::CallbackListSubscription shutdown_subscription_;
base::WeakPtrFactory<DiceTurnSyncOnHelper> weak_pointer_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DiceTurnSyncOnHelper);
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc
index 519c896f095..b318d092d9e 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/signin/signin_email_confirmation_dialog.h"
+#include "chrome/browser/ui/webui/signin/signin_ui_error.h"
#include "chrome/common/url_constants.h"
namespace {
@@ -60,6 +61,15 @@ void OnEmailConfirmation(DiceTurnSyncOnHelper::SigninChoiceCallback callback,
NOTREACHED();
}
+void OnProfileCheckComplete(const std::string& email,
+ DiceTurnSyncOnHelper::SigninChoiceCallback callback,
+ Browser* browser,
+ bool prompt_for_new_profile) {
+ DiceTurnSyncOnHelper::Delegate::ShowEnterpriseAccountConfirmationForBrowser(
+ email, /*prompt_for_new_profile=*/prompt_for_new_profile,
+ std::move(callback), browser);
+}
+
} // namespace
DiceTurnSyncOnHelperDelegateImpl::DiceTurnSyncOnHelperDelegateImpl(
@@ -75,18 +85,21 @@ DiceTurnSyncOnHelperDelegateImpl::~DiceTurnSyncOnHelperDelegateImpl() {
}
void DiceTurnSyncOnHelperDelegateImpl::ShowLoginError(
- const std::string& email,
- const std::string& error_message) {
- DiceTurnSyncOnHelper::Delegate::ShowLoginErrorForBrowser(email, error_message,
- browser_);
+ const SigninUIError& error) {
+ DCHECK(!error.IsOk());
+ DiceTurnSyncOnHelper::Delegate::ShowLoginErrorForBrowser(
+ error.email(), error.message(), browser_);
}
void DiceTurnSyncOnHelperDelegateImpl::ShowEnterpriseAccountConfirmation(
const std::string& email,
DiceTurnSyncOnHelper::SigninChoiceCallback callback) {
browser_ = EnsureBrowser(browser_, profile_);
- DiceTurnSyncOnHelper::Delegate::ShowEnterpriseAccountConfirmationForBrowser(
- email, std::move(callback), browser_);
+ // Checking whether to show the prompt for a new profile is sometimes
+ // asynchronous.
+ ui::CheckShouldPromptForNewProfile(
+ profile_, base::BindOnce(&OnProfileCheckComplete, email,
+ std::move(callback), browser_));
}
void DiceTurnSyncOnHelperDelegateImpl::ShowSyncConfirmation(
@@ -94,13 +107,14 @@ void DiceTurnSyncOnHelperDelegateImpl::ShowSyncConfirmation(
callback) {
DCHECK(callback);
sync_confirmation_callback_ = std::move(callback);
- scoped_login_ui_service_observer_.Add(
+ scoped_login_ui_service_observation_.Observe(
LoginUIServiceFactory::GetForProfile(profile_));
browser_ = EnsureBrowser(browser_, profile_);
browser_->signin_view_controller()->ShowModalSyncConfirmationDialog();
}
void DiceTurnSyncOnHelperDelegateImpl::ShowSyncDisabledConfirmation(
+ bool is_managed_account,
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) {
// This is handled by the same UI element as the normal sync confirmation.
@@ -131,6 +145,9 @@ void DiceTurnSyncOnHelperDelegateImpl::SwitchToProfile(Profile* new_profile) {
void DiceTurnSyncOnHelperDelegateImpl::OnSyncConfirmationUIClosed(
LoginUIService::SyncConfirmationUIClosedResult result) {
DCHECK(sync_confirmation_callback_);
+ // Treat closing the ui as an implicit ABORT_SYNC action.
+ if (result == LoginUIService::UI_CLOSED)
+ result = LoginUIService::ABORT_SYNC;
std::move(sync_confirmation_callback_).Run(result);
}
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h
index e77f70630fa..e9682822785 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h
@@ -7,7 +7,7 @@
#include "base/callback_forward.h"
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h"
#include "chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h"
@@ -15,6 +15,7 @@
class Browser;
class Profile;
+class SigninUIError;
// Default implementation for DiceTurnSyncOnHelper::Delegate.
class DiceTurnSyncOnHelperDelegateImpl : public DiceTurnSyncOnHelper::Delegate,
@@ -26,8 +27,7 @@ class DiceTurnSyncOnHelperDelegateImpl : public DiceTurnSyncOnHelper::Delegate,
private:
// DiceTurnSyncOnHelper::Delegate:
- void ShowLoginError(const std::string& email,
- const std::string& error_message) override;
+ void ShowLoginError(const SigninUIError& error) override;
void ShowMergeSyncDataConfirmation(
const std::string& previous_email,
const std::string& new_email,
@@ -39,6 +39,7 @@ class DiceTurnSyncOnHelperDelegateImpl : public DiceTurnSyncOnHelper::Delegate,
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) override;
void ShowSyncDisabledConfirmation(
+ bool is_managed_account,
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) override;
void ShowSyncSettings() override;
@@ -55,8 +56,8 @@ class DiceTurnSyncOnHelperDelegateImpl : public DiceTurnSyncOnHelper::Delegate,
Profile* profile_;
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
sync_confirmation_callback_;
- ScopedObserver<LoginUIService, LoginUIService::Observer>
- scoped_login_ui_service_observer_{this};
+ base::ScopedObservation<LoginUIService, LoginUIService::Observer>
+ scoped_login_ui_service_observation_{this};
DISALLOW_COPY_AND_ASSIGN(DiceTurnSyncOnHelperDelegateImpl);
};
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc
index 10f004d8e96..5f0f4fa99ae 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc
@@ -14,6 +14,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/location.h"
+#include "base/optional.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/policy/cloud/user_policy_signin_service.h"
@@ -26,6 +27,7 @@
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/signin/test_signin_client_builder.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/ui/webui/signin/signin_ui_error.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
@@ -55,6 +57,7 @@ namespace {
const char kEmail[] = "foo@gmail.com";
const char kPreviousEmail[] = "notme@bar.com";
const char kEnterpriseEmail[] = "enterprise@managed.com";
+const char kEnterpriseHostedDomain[] = "managed.com";
const signin_metrics::AccessPoint kAccessPoint =
signin_metrics::AccessPoint::ACCESS_POINT_BOOKMARK_MANAGER;
@@ -78,8 +81,7 @@ class TestDiceTurnSyncOnHelperDelegate : public DiceTurnSyncOnHelper::Delegate {
private:
// DiceTurnSyncOnHelper::Delegate:
- void ShowLoginError(const std::string& email,
- const std::string& error_message) override;
+ void ShowLoginError(const SigninUIError& error) override;
void ShowMergeSyncDataConfirmation(
const std::string& previous_email,
const std::string& new_email,
@@ -91,8 +93,9 @@ class TestDiceTurnSyncOnHelperDelegate : public DiceTurnSyncOnHelper::Delegate {
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
callback) override;
void ShowSyncDisabledConfirmation(
+ bool is_managed_account,
base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
- callback) override {}
+ callback) override;
void ShowSyncSettings() override;
void SwitchToProfile(Profile* new_profile) override;
@@ -314,9 +317,18 @@ class DiceTurnSyncOnHelperTest : public testing::Test {
}
void UseEnterpriseAccount() {
- account_id_ =
- identity_test_env()->MakeAccountAvailable(kEnterpriseEmail).account_id;
+ CoreAccountInfo core_account_info =
+ identity_test_env()->MakeAccountAvailable(kEnterpriseEmail);
+ account_id_ = core_account_info.account_id;
user_policy_signin_service_->set_account(account_id_, kEnterpriseEmail);
+
+ // Update the account info to have a consistent hosted domain field.
+ base::Optional<AccountInfo> account_info =
+ identity_manager()->FindExtendedAccountInfoForAccountWithRefreshToken(
+ core_account_info);
+ EXPECT_TRUE(account_info);
+ account_info->hosted_domain = kEnterpriseHostedDomain;
+ signin::UpdateAccountInfoForAccount(identity_manager(), *account_info);
}
void UseInvalidAccount() { account_id_ = CoreAccountId("invalid_account"); }
@@ -346,27 +358,33 @@ class DiceTurnSyncOnHelperTest : public testing::Test {
Return(syncer::SyncService::TransportState::INITIALIZING));
}
+ void SetExpectationsForSyncDisabled(Profile* profile) {
+ syncer::MockSyncService* mock_sync_service = GetMockSyncService(profile);
+ ON_CALL(*mock_sync_service, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DisableReasonSet(
+ syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY)));
+ }
+
void CheckDelegateCalls() {
- EXPECT_EQ(expected_login_error_email_, login_error_email_);
- EXPECT_EQ(expected_login_error_message_, login_error_message_);
+ EXPECT_EQ(expected_login_error_, login_error_);
EXPECT_EQ(expected_merge_data_previous_email_, merge_data_previous_email_);
EXPECT_EQ(expected_merge_data_new_email_, merge_data_new_email_);
EXPECT_EQ(expected_enterprise_confirmation_email_,
enterprise_confirmation_email_);
EXPECT_EQ(expected_switched_to_new_profile_, switched_to_new_profile_);
EXPECT_EQ(expected_sync_confirmation_shown_, sync_confirmation_shown_);
+ EXPECT_EQ(expected_sync_disabled_confirmation_,
+ sync_disabled_confirmation_);
EXPECT_EQ(expected_sync_settings_shown_, sync_settings_shown_);
}
// Functions called by the DiceTurnSyncOnHelper::Delegate:
- void OnShowLoginError(const std::string& email,
- const std::string& error_message) {
+ void OnShowLoginError(const SigninUIError& error) {
EXPECT_FALSE(sync_confirmation_shown_);
- EXPECT_FALSE(email.empty());
- EXPECT_TRUE(login_error_email_.empty())
+ EXPECT_FALSE(error.IsOk());
+ EXPECT_FALSE(login_error_.has_value())
<< "Login error should be shown only once.";
- login_error_email_ = email;
- login_error_message_ = error_message; // May be empty.
+ login_error_ = error;
}
void OnShowMergeSyncDataConfirmation(
@@ -408,6 +426,18 @@ class DiceTurnSyncOnHelperTest : public testing::Test {
std::move(callback).Run(sync_confirmation_result_);
}
+ 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_ =
+ is_managed_account ? kShownManaged : kShownNonManaged;
+ if (run_delegate_callbacks_)
+ std::move(callback).Run(sync_confirmation_result_);
+ }
+
void OnShowSyncSettings() {
EXPECT_TRUE(sync_confirmation_shown_)
<< "Must show sync confirmation first";
@@ -454,23 +484,26 @@ class DiceTurnSyncOnHelperTest : public testing::Test {
}
protected:
+ // Type of sync disabled confirmation shown.
+ enum SyncDisabledConfirmation { kNotShown, kShownManaged, kShownNonManaged };
+
// Delegate behavior.
DiceTurnSyncOnHelper::SigninChoice merge_data_choice_ =
DiceTurnSyncOnHelper::SIGNIN_CHOICE_CANCEL;
DiceTurnSyncOnHelper::SigninChoice enterprise_choice_ =
DiceTurnSyncOnHelper::SIGNIN_CHOICE_CANCEL;
LoginUIService::SyncConfirmationUIClosedResult sync_confirmation_result_ =
- LoginUIService::SyncConfirmationUIClosedResult::ABORT_SIGNIN;
+ LoginUIService::SyncConfirmationUIClosedResult::ABORT_SYNC;
bool run_delegate_callbacks_ = true;
// Expected delegate calls.
- std::string expected_login_error_email_;
- std::string expected_login_error_message_;
+ base::Optional<SigninUIError> expected_login_error_;
std::string expected_enterprise_confirmation_email_;
std::string expected_merge_data_previous_email_;
std::string expected_merge_data_new_email_;
bool expected_switched_to_new_profile_ = false;
bool expected_sync_confirmation_shown_ = false;
+ SyncDisabledConfirmation expected_sync_disabled_confirmation_ = kNotShown;
bool expected_sync_settings_shown_ = false;
private:
@@ -492,13 +525,13 @@ class DiceTurnSyncOnHelperTest : public testing::Test {
// State of the delegate calls.
int delegate_destroyed_ = 0;
- std::string login_error_email_;
- std::string login_error_message_;
+ base::Optional<SigninUIError> login_error_;
std::string enterprise_confirmation_email_;
std::string merge_data_previous_email_;
std::string merge_data_new_email_;
bool switched_to_new_profile_ = false;
bool sync_confirmation_shown_ = false;
+ SyncDisabledConfirmation sync_disabled_confirmation_ = kNotShown;
bool sync_settings_shown_ = false;
};
@@ -511,9 +544,8 @@ TestDiceTurnSyncOnHelperDelegate::~TestDiceTurnSyncOnHelperDelegate() {
}
void TestDiceTurnSyncOnHelperDelegate::ShowLoginError(
- const std::string& email,
- const std::string& error_message) {
- test_fixture_->OnShowLoginError(email, error_message);
+ const SigninUIError& error) {
+ test_fixture_->OnShowLoginError(error);
}
void TestDiceTurnSyncOnHelperDelegate::ShowMergeSyncDataConfirmation(
@@ -537,6 +569,14 @@ void TestDiceTurnSyncOnHelperDelegate::ShowSyncConfirmation(
test_fixture_->OnShowSyncConfirmation(std::move(callback));
}
+void TestDiceTurnSyncOnHelperDelegate::ShowSyncDisabledConfirmation(
+ bool is_managed_account,
+ base::OnceCallback<void(LoginUIService::SyncConfirmationUIClosedResult)>
+ callback) {
+ test_fixture_->OnShowSyncDisabledConfirmation(is_managed_account,
+ std::move(callback));
+}
+
void TestDiceTurnSyncOnHelperDelegate::ShowSyncSettings() {
test_fixture_->OnShowSyncSettings();
}
@@ -557,7 +597,7 @@ TEST_F(DiceTurnSyncOnHelperTest, InvalidAccount) {
// Tests that the login error is displayed and that the account is kept.
TEST_F(DiceTurnSyncOnHelperTest, CanOfferSigninErrorKeepAccount) {
// Set expectations.
- expected_login_error_email_ = kEmail;
+ expected_login_error_ = SigninUIError::Other(kEmail);
// Configure the test.
profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
// Signin flow.
@@ -565,7 +605,8 @@ TEST_F(DiceTurnSyncOnHelperTest, CanOfferSigninErrorKeepAccount) {
DiceTurnSyncOnHelper::SigninAbortedMode::KEEP_ACCOUNT);
base::RunLoop().RunUntilIdle();
// Check expectations.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
@@ -573,7 +614,7 @@ TEST_F(DiceTurnSyncOnHelperTest, CanOfferSigninErrorKeepAccount) {
// Tests that the login error is displayed and that the account is removed.
TEST_F(DiceTurnSyncOnHelperTest, CanOfferSigninErrorRemoveAccount) {
// Set expectations.
- expected_login_error_email_ = kEmail;
+ expected_login_error_ = SigninUIError::Other(kEmail);
// Configure the test.
profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
// Signin flow.
@@ -581,11 +622,106 @@ TEST_F(DiceTurnSyncOnHelperTest, CanOfferSigninErrorRemoveAccount) {
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
base::RunLoop().RunUntilIdle();
// Check expectations.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
+// Tests that the sync disabled message is displayed and that the account is
+// removed upon the ABORT_SYNC action.
+TEST_F(DiceTurnSyncOnHelperTest, SyncDisabledAbortRemoveAccount) {
+ // Set expectations.
+ expected_sync_disabled_confirmation_ = kShownNonManaged;
+ SetExpectationsForSyncDisabled(profile());
+ // Configure the test.
+ sync_confirmation_result_ =
+ LoginUIService::SyncConfirmationUIClosedResult::ABORT_SYNC;
+
+ // Signin flow.
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ CreateDiceTurnOnSyncHelper(
+ DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
+ base::RunLoop().RunUntilIdle();
+ // Check expectations.
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
+ CheckDelegateCalls();
+}
+
+// Tests that the sync disabled message is displayed and that the account is
+// removed upon the ABORT_SYNC action (despite SigninAbortedMode::KEEP_ACCOUNT).
+TEST_F(DiceTurnSyncOnHelperTest, SyncDisabledAbortKeepAccount) {
+ // Set expectations.
+ expected_sync_disabled_confirmation_ = kShownNonManaged;
+ SetExpectationsForSyncDisabled(profile());
+ // Configure the test.
+ sync_confirmation_result_ =
+ LoginUIService::SyncConfirmationUIClosedResult::ABORT_SYNC;
+
+ // Signin flow.
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ CreateDiceTurnOnSyncHelper(
+ DiceTurnSyncOnHelper::SigninAbortedMode::KEEP_ACCOUNT);
+ base::RunLoop().RunUntilIdle();
+ // Check expectations.
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
+ CheckDelegateCalls();
+}
+
+// Tests that the sync disabled message is displayed and that the account is
+// kept upon the SYNC_WITH_DEFAULT_SETTINGS action.
+TEST_F(DiceTurnSyncOnHelperTest, SyncDisabledContinueKeepAccount) {
+ // Set expectations.
+ expected_sync_disabled_confirmation_ = kShownNonManaged;
+ SetExpectationsForSyncDisabled(profile());
+ // Configure the test.
+ sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
+ SYNC_WITH_DEFAULT_SETTINGS;
+
+ // Signin flow.
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ CreateDiceTurnOnSyncHelper(
+ DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
+ base::RunLoop().RunUntilIdle();
+ // Check expectations.
+ EXPECT_TRUE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
+ CheckDelegateCalls();
+}
+
+// Tests that the sync disabled message is displayed and that the account is
+// kept upon the SYNC_WITH_DEFAULT_SETTINGS action.
+TEST_F(DiceTurnSyncOnHelperTest, SyncDisabledManagedContinueKeepAccount) {
+ // Reset the account info to be an enterprise account.
+ UseEnterpriseAccount();
+ // Set expectations.
+ expected_sync_disabled_confirmation_ = kShownManaged;
+ SetExpectationsForSyncDisabled(profile());
+ // Configure the test.
+ sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
+ SYNC_WITH_DEFAULT_SETTINGS;
+
+ // Signin flow.
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ CreateDiceTurnOnSyncHelper(
+ DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
+ base::RunLoop().RunUntilIdle();
+ // Check expectations.
+ EXPECT_TRUE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
+ EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
+ CheckDelegateCalls();
+}
+
// Aborts the flow after the cross account dialog.
TEST_F(DiceTurnSyncOnHelperTest, CrossAccountAbort) {
// Set expectations.
@@ -598,7 +734,8 @@ TEST_F(DiceTurnSyncOnHelperTest, CrossAccountAbort) {
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
@@ -618,7 +755,8 @@ TEST_F(DiceTurnSyncOnHelperTest, CrossAccountContinue) {
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
@@ -640,7 +778,8 @@ TEST_F(DiceTurnSyncOnHelperTest, CrossAccountNewProfile) {
DiceTurnSyncOnHelper::SigninAbortedMode::KEEP_ACCOUNT);
// Check expectations.
base::RunLoop().RunUntilIdle(); // Profile creation is asynchronous.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
// The token has been removed from the source profile even though
// KEEP_ACCOUNT was used.
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
@@ -658,7 +797,8 @@ TEST_F(DiceTurnSyncOnHelperTest, EnterpriseConfirmationAbort) {
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
@@ -676,7 +816,8 @@ TEST_F(DiceTurnSyncOnHelperTest, DISABLED_EnterpriseConfirmationContinue) {
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
@@ -697,7 +838,8 @@ TEST_F(DiceTurnSyncOnHelperTest, EnterpriseConfirmationNewProfile) {
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
base::RunLoop().RunUntilIdle(); // Profile creation is asynchronous.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
@@ -713,11 +855,13 @@ TEST_F(DiceTurnSyncOnHelperTest, UndoSync) {
.Times(0);
// Signin flow.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_FALSE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
@@ -737,11 +881,13 @@ TEST_F(DiceTurnSyncOnHelperTest, ConfigureSync) {
sync_confirmation_result_ =
LoginUIService::SyncConfirmationUIClosedResult::CONFIGURE_SYNC_FIRST;
// Signin flow.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
- EXPECT_TRUE(identity_manager()->HasPrimaryAccount());
+ EXPECT_TRUE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
}
@@ -758,12 +904,14 @@ TEST_F(DiceTurnSyncOnHelperTest, StartSync) {
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
SYNC_WITH_DEFAULT_SETTINGS;
// Signin flow.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
- EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId());
+ EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId(
+ signin::ConsentLevel::kSync));
CheckDelegateCalls();
}
@@ -787,13 +935,15 @@ TEST_F(DiceTurnSyncOnHelperTest, ShowSyncDialogForEndConsumerAccount) {
EXPECT_FALSE(url_keyed_collection_helper->IsEnabled());
// Signin flow.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check expectations.
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
- EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId());
+ EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId(
+ signin::ConsentLevel::kSync));
CheckDelegateCalls();
EXPECT_TRUE(url_keyed_collection_helper->IsEnabled());
}
@@ -813,14 +963,16 @@ TEST_F(DiceTurnSyncOnHelperTest,
SetExpectationsForSyncStartupPending(profile());
// Signin flow.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
DiceTurnSyncOnHelper* dice_sync_starter = CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check that the primary account was set with IdentityManager, but the sync
// confirmation dialog was not yet shown.
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
- EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId());
+ EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId(
+ signin::ConsentLevel::kSync));
CheckDelegateCalls();
// Simulate that sync startup has completed.
@@ -847,14 +999,16 @@ TEST_F(DiceTurnSyncOnHelperTest,
SetExpectationsForSyncStartupPending(profile());
// Signin flow.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
DiceTurnSyncOnHelper* dice_sync_starter = CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check that the primary account was set with IdentityManager, but the sync
// confirmation dialog was not yet shown.
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
- EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId());
+ EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId(
+ signin::ConsentLevel::kSync));
CheckDelegateCalls();
// Simulate that sync startup has completed.
@@ -881,14 +1035,16 @@ TEST_F(DiceTurnSyncOnHelperTest,
SetExpectationsForSyncStartupPending(profile());
// Signin flow.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
DiceTurnSyncOnHelper* dice_sync_starter = CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check that the primary account was added to the token service and in the
// sign-in manager.
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
- EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId());
+ EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId(
+ signin::ConsentLevel::kSync));
CheckDelegateCalls();
// Simulate that sync startup has failed.
@@ -917,14 +1073,16 @@ TEST_F(DiceTurnSyncOnHelperTest,
SetExpectationsForSyncStartupPending(profile());
// Signin flow.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
DiceTurnSyncOnHelper* dice_sync_starter = CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check that the primary account was set with IdentityManager, but the sync
// confirmation dialog was not yet shown.
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
- EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId());
+ EXPECT_EQ(account_id(), identity_manager()->GetPrimaryAccountId(
+ signin::ConsentLevel::kSync));
CheckDelegateCalls();
// Simulate that sync startup has failed.
@@ -956,7 +1114,8 @@ TEST_F(DiceTurnSyncOnHelperTest, ProfileDeletion) {
// Dialog has been shown.
EXPECT_EQ(kEmail, enterprise_confirmation_email());
// But signin is not finished.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
// Delete the profile.
ClearProfile();
@@ -972,7 +1131,8 @@ TEST_F(DiceTurnSyncOnHelperTest, AbortExisting) {
CreateDiceTurnOnSyncHelper(
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT);
// Check that it did not complete.
- EXPECT_FALSE(identity_manager()->HasPrimaryAccount());
+ EXPECT_FALSE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
CheckDelegateCalls();
@@ -986,7 +1146,8 @@ TEST_F(DiceTurnSyncOnHelperTest, AbortExisting) {
DiceTurnSyncOnHelper::SigninAbortedMode::KEEP_ACCOUNT);
// Check that it completed.
CheckDelegateCalls();
- EXPECT_TRUE(identity_manager()->HasPrimaryAccount());
+ EXPECT_TRUE(
+ identity_manager()->HasPrimaryAccount(signin::ConsentLevel::kSync));
// The token is still there, even though the first helper had REMOVE_ACCOUNT.
EXPECT_TRUE(identity_manager()->HasAccountWithRefreshToken(account_id()));
// Both delegates were destroyed.
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 ef369697d99..a223bfb9422 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
@@ -5,17 +5,22 @@
#include "chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h"
#include "base/bind.h"
+#include "base/metrics/field_trial_params.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/enterprise/browser_management/browser_management_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.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/identity_manager_factory.h"
+#include "chrome/browser/signin/signin_features.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
+#include "components/policy/core/common/management/management_service.h"
+#include "components/policy/core/common/management/platform_management_service.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
@@ -35,7 +40,7 @@ bool IsManaged(const AccountInfo& info) {
DiceWebSigninInterceptHandler::DiceWebSigninInterceptHandler(
const DiceWebSigninInterceptor::Delegate::BubbleParameters&
bubble_parameters,
- base::OnceCallback<void(bool)> callback)
+ base::OnceCallback<void(SigninInterceptionUserChoice)> callback)
: bubble_parameters_(bubble_parameters), callback_(std::move(callback)) {
DCHECK(callback_);
}
@@ -52,6 +57,9 @@ void DiceWebSigninInterceptHandler::RegisterMessages() {
base::BindRepeating(&DiceWebSigninInterceptHandler::HandleCancel,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "guest", base::BindRepeating(&DiceWebSigninInterceptHandler::HandleGuest,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"pageLoaded",
base::BindRepeating(&DiceWebSigninInterceptHandler::HandlePageLoaded,
base::Unretained(this)));
@@ -60,11 +68,11 @@ void DiceWebSigninInterceptHandler::RegisterMessages() {
void DiceWebSigninInterceptHandler::OnJavascriptAllowed() {
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()));
- identity_observer_.Add(identity_manager);
+ identity_observation_.Observe(identity_manager);
}
void DiceWebSigninInterceptHandler::OnJavascriptDisallowed() {
- identity_observer_.RemoveAll();
+ identity_observation_.Reset();
}
void DiceWebSigninInterceptHandler::OnExtendedAccountInfoUpdated(
@@ -97,12 +105,17 @@ const AccountInfo& DiceWebSigninInterceptHandler::intercepted_account() {
void DiceWebSigninInterceptHandler::HandleAccept(const base::ListValue* args) {
if (callback_)
- std::move(callback_).Run(true);
+ std::move(callback_).Run(SigninInterceptionUserChoice::kAccept);
}
void DiceWebSigninInterceptHandler::HandleCancel(const base::ListValue* args) {
if (callback_)
- std::move(callback_).Run(false);
+ std::move(callback_).Run(SigninInterceptionUserChoice::kDecline);
+}
+
+void DiceWebSigninInterceptHandler::HandleGuest(const base::ListValue* args) {
+ if (callback_)
+ std::move(callback_).Run(SigninInterceptionUserChoice::kGuest);
}
void DiceWebSigninInterceptHandler::HandlePageLoaded(
@@ -128,14 +141,8 @@ void DiceWebSigninInterceptHandler::HandlePageLoaded(
// reasonable defaults.
if (primary_account().hosted_domain.empty())
bubble_parameters_.primary_account.hosted_domain = kNoHostedDomainFound;
- if (primary_account().given_name.empty()) {
- ProfileAttributesEntry* entry = nullptr;
- g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile->GetPath(), &entry);
- bubble_parameters_.primary_account.given_name =
- base::UTF16ToUTF8(entry->GetName());
- }
+ if (primary_account().given_name.empty())
+ bubble_parameters_.primary_account.given_name = primary_account().email;
const base::Value& callback_id = args->GetList()[0];
ResolveJavascriptCallback(callback_id, GetInterceptionParametersValue());
@@ -173,6 +180,8 @@ base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
l10n_util::GetStringUTF8(confirmButtonStringID));
parameters.SetStringKey("cancelButtonLabel",
l10n_util::GetStringUTF8(cancelButtonStringID));
+ parameters.SetBoolKey("showGuestOption",
+ bubble_parameters_.show_guest_option);
parameters.SetKey("interceptedAccount",
GetAccountInfoValue(intercepted_account()));
parameters.SetStringKey("headerBackgroundColor",
@@ -185,6 +194,25 @@ base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
return parameters;
}
+bool DiceWebSigninInterceptHandler::ShouldShowManagedDeviceVersion() const {
+ // This checks if the current profile is managed, which is a conservative
+ // approximation of whether the new profile will be managed (this is because
+ // the current profile may have policies coming from Sync, but the new profile
+ // won't have Sync enabled, at least initially).
+ // There are two possible improvements of this approximation:
+ // - checking the browser policies that are not specific to this profile (e.g.
+ // by supporting the nullptr profile in BrowserManagementService)
+ // - or anticipating that the user may enable Sync in the new profile and
+ // check the cloud policies attached to the intercepted account (requires
+ // network requests).
+ return policy::PlatformManagementService::GetInstance()
+ .GetManagementAuthorityTrustworthiness() >
+ policy::ManagementAuthorityTrustworthiness::NONE ||
+ policy::BrowserManagementService(Profile::FromWebUI(web_ui()))
+ .GetManagementAuthorityTrustworthiness() >
+ policy::ManagementAuthorityTrustworthiness::NONE;
+}
+
std::string DiceWebSigninInterceptHandler::GetHeaderText() {
switch (bubble_parameters_.interception_type) {
case DiceWebSigninInterceptor::SigninInterceptionType::kEnterprise:
@@ -198,48 +226,61 @@ std::string DiceWebSigninInterceptHandler::GetHeaderText() {
}
std::string DiceWebSigninInterceptHandler::GetBodyTitle() {
- switch (bubble_parameters_.interception_type) {
- case DiceWebSigninInterceptor::SigninInterceptionType::kEnterprise:
- if (!IsManaged(primary_account())) {
- return l10n_util::GetStringUTF8(
- IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_BUBBLE_TITLE);
+ if (bubble_parameters_.interception_type ==
+ DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch) {
+ return l10n_util::GetStringUTF8(
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_TITLE);
+ }
+
+ // For profile creations, the title is controlled by an experiment. Expected
+ // values for the parameter are 1, 2 or 3.
+ // The version 3 is specific to the "consumer" bubble and is not supported by
+ // the enterprise bubble (which defaults to version 1 in that case).
+ int string_version = base::GetFieldTrialParamByFeatureAsInt(
+ kDiceWebSigninInterceptionFeature, "title_version",
+ /*default_value=*/1);
+
+ int string_id = IDS_SIGNIN_DICE_WEB_INTERCEPT_CREATE_BUBBLE_TITLE_V1;
+ switch (string_version) {
+ case 2:
+ string_id = IDS_SIGNIN_DICE_WEB_INTERCEPT_CREATE_BUBBLE_TITLE_V2;
+ break;
+ case 3:
+ // Only use version 3 for consumer bubble.
+ if (bubble_parameters_.interception_type ==
+ DiceWebSigninInterceptor::SigninInterceptionType::kMultiUser) {
+ string_id = IDS_SIGNIN_DICE_WEB_INTERCEPT_CREATE_BUBBLE_TITLE_V3;
}
- FALLTHROUGH;
- case DiceWebSigninInterceptor::SigninInterceptionType::kMultiUser:
- return l10n_util::GetStringUTF8(
- IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_TITLE);
- case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch:
- return l10n_util::GetStringUTF8(
- IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_TITLE);
+ break;
+ default:
+ // For default or invalid parameters, there is nothing to do.
+ break;
}
+
+ return l10n_util::GetStringUTF8(string_id);
}
std::string DiceWebSigninInterceptHandler::GetBodyText() {
switch (bubble_parameters_.interception_type) {
case DiceWebSigninInterceptor::SigninInterceptionType::kEnterprise:
- if (IsManaged(intercepted_account()) && IsManaged(primary_account())) {
- return l10n_util::GetStringFUTF8(
- IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_ENTERPRISE_BUBBLE_DESC,
- base::UTF8ToUTF16(intercepted_account().hosted_domain),
- base::UTF8ToUTF16(primary_account().hosted_domain));
- } else if (IsManaged(intercepted_account())) {
- return l10n_util::GetStringFUTF8(
- IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_CONSUMER_BUBBLE_DESC,
- base::UTF8ToUTF16(intercepted_account().hosted_domain));
- } else {
- return l10n_util::GetStringFUTF8(
- IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_ENTERPRISE_BUBBLE_DESC,
- base::UTF8ToUTF16(intercepted_account().given_name),
- base::UTF8ToUTF16(primary_account().hosted_domain));
- }
+ return ShouldShowManagedDeviceVersion()
+ ? l10n_util::GetStringFUTF8(
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_BUBBLE_DESC_MANAGED_DEVICE,
+ base::UTF8ToUTF16(intercepted_account().email))
+ : l10n_util::GetStringFUTF8(
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_BUBBLE_DESC,
+ base::UTF8ToUTF16(primary_account().email));
case DiceWebSigninInterceptor::SigninInterceptionType::kMultiUser:
- return l10n_util::GetStringFUTF8(
- IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC,
- base::UTF8ToUTF16(intercepted_account().given_name));
+ return ShouldShowManagedDeviceVersion()
+ ? l10n_util::GetStringFUTF8(
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC_MANAGED_DEVICE,
+ base::UTF8ToUTF16(primary_account().given_name),
+ base::UTF8ToUTF16(intercepted_account().email))
+ : l10n_util::GetStringFUTF8(
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC,
+ base::UTF8ToUTF16(primary_account().given_name));
case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch:
- return l10n_util::GetStringFUTF8(
- IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_DESC,
- base::UTF8ToUTF16(intercepted_account().email),
- base::UTF8ToUTF16(intercepted_account().given_name));
+ return l10n_util::GetStringUTF8(
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_DESC);
}
}
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 57a3214e1a7..21436394367 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
@@ -10,7 +10,7 @@
#include <string>
#include "base/callback.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/values.h"
#include "chrome/browser/signin/dice_web_signin_interceptor.h"
#include "components/signin/public/identity_manager/account_info.h"
@@ -27,7 +27,7 @@ class DiceWebSigninInterceptHandler : public content::WebUIMessageHandler,
DiceWebSigninInterceptHandler(
const DiceWebSigninInterceptor::Delegate::BubbleParameters&
bubble_parameters,
- base::OnceCallback<void(bool)> callback);
+ base::OnceCallback<void(SigninInterceptionUserChoice)> callback);
~DiceWebSigninInterceptHandler() override;
DiceWebSigninInterceptHandler(const DiceWebSigninInterceptHandler&) = delete;
@@ -48,21 +48,27 @@ class DiceWebSigninInterceptHandler : public content::WebUIMessageHandler,
void HandleAccept(const base::ListValue* args);
void HandleCancel(const base::ListValue* args);
+ void HandleGuest(const base::ListValue* args);
void HandlePageLoaded(const base::ListValue* args);
// Gets the values sent to javascript.
base::Value GetAccountInfoValue(const AccountInfo& info);
base::Value GetInterceptionParametersValue();
+ // The dialog string is different when the device is managed. This function
+ // returns whether the version for managed devices should be used.
+ bool ShouldShowManagedDeviceVersion() const;
+
std::string GetHeaderText();
std::string GetBodyTitle();
std::string GetBodyText();
- ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
- identity_observer_{this};
+ base::ScopedObservation<signin::IdentityManager,
+ signin::IdentityManager::Observer>
+ identity_observation_{this};
DiceWebSigninInterceptor::Delegate::BubbleParameters bubble_parameters_;
- base::OnceCallback<void(bool)> callback_;
+ base::OnceCallback<void(SigninInterceptionUserChoice)> callback_;
};
#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_DICE_WEB_SIGNIN_INTERCEPT_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.cc b/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.cc
index 3530b489a96..0bdf991a189 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.cc
@@ -7,13 +7,16 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
+#include "chrome/grit/generated_resources.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 "third_party/skia/include/core/SkColor.h"
+#include "ui/base/webui/resource_path.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/resources/grit/webui_generated_resources.h"
#include "ui/resources/grit/webui_resources.h"
@@ -23,20 +26,29 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
content::WebUIDataSource* source = content::WebUIDataSource::Create(
chrome::kChromeUIDiceWebSigninInterceptHost);
source->SetDefaultResource(IDR_SIGNIN_DICE_WEB_INTERCEPT_HTML);
- source->AddResourcePath("dice_web_signin_intercept_app.js",
- IDR_SIGNIN_DICE_WEB_INTERCEPT_APP_JS);
- source->AddResourcePath("dice_web_signin_intercept_browser_proxy.js",
- IDR_SIGNIN_DICE_WEB_INTERCEPT_BROWSER_PROXY_JS);
- source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS);
- source->AddResourcePath("signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS);
-
- // Resources for testing.
+
+ static constexpr webui::ResourcePath kResources[] = {
+ {"dice_web_signin_intercept_app.js",
+ IDR_SIGNIN_DICE_WEB_INTERCEPT_APP_JS},
+ {"dice_web_signin_intercept_browser_proxy.js",
+ IDR_SIGNIN_DICE_WEB_INTERCEPT_BROWSER_PROXY_JS},
+ {"signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS},
+ {"signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS},
+ // Resources for testing.
+ {"test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS},
+ {"test_loader_util.js", IDR_WEBUI_JS_TEST_LOADER_UTIL_JS},
+ {"test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML},
+ };
+ source->AddResourcePaths(kResources);
+
+ source->AddLocalizedString("guestLink",
+ IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_GUEST_LINK);
+ source->UseStringsJs();
+
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
"script-src chrome://resources chrome://test 'self';");
source->DisableTrustedTypesCSP();
- source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
- source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
@@ -46,7 +58,7 @@ DiceWebSigninInterceptUI::~DiceWebSigninInterceptUI() = default;
void DiceWebSigninInterceptUI::Initialize(
const DiceWebSigninInterceptor::Delegate::BubbleParameters&
bubble_parameters,
- base::OnceCallback<void(bool)> callback) {
+ base::OnceCallback<void(SigninInterceptionUserChoice)> callback) {
web_ui()->AddMessageHandler(std::make_unique<DiceWebSigninInterceptHandler>(
bubble_parameters, std::move(callback)));
}
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.h b/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.h
index 7f0793bb858..f937ed0afb7 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.h
+++ b/chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.h
@@ -23,9 +23,10 @@ class DiceWebSigninInterceptUI : public content::WebUIController {
DiceWebSigninInterceptUI& operator=(const DiceWebSigninInterceptUI&) = delete;
// Initializes the DiceWebSigninInterceptUI.
- void Initialize(const DiceWebSigninInterceptor::Delegate::BubbleParameters&
- bubble_parameters,
- base::OnceCallback<void(bool)> callback);
+ void Initialize(
+ const DiceWebSigninInterceptor::Delegate::BubbleParameters&
+ bubble_parameters,
+ base::OnceCallback<void(SigninInterceptionUserChoice)> callback);
private:
WEB_UI_CONTROLLER_TYPE_DECL();
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.cc
index b527b831195..97b05489183 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.cc
@@ -7,22 +7,23 @@
#include <algorithm>
#include <string>
+#include "ash/constants/ash_features.h"
+#include "ash/constants/ash_pref_names.h"
#include "ash/public/cpp/window_backdrop.h"
#include "ash/public/cpp/window_properties.h"
+#include "base/callback_helpers.h"
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/json/json_writer.h"
#include "base/macros.h"
#include "base/metrics/histogram_functions.h"
-#include "chrome/browser/chromeos/arc/arc_util.h"
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/supervised_user/supervised_user_features.h"
#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
#include "chrome/common/webui_url_constants.h"
-#include "chromeos/constants/chromeos_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/session_manager/core/session_manager.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
@@ -44,12 +45,6 @@ InlineLoginDialogChromeOS* dialog = nullptr;
constexpr int kSigninDialogWidth = 768;
constexpr int kSigninDialogHeight = 640;
-// Keep in sync with resources/chromeos/account_manager_error.js
-enum class AccountManagerErrorType {
- kSecondaryAccountsDisabled = 0,
- kChildUserArcDisabled = 1
-};
-
bool IsDeviceAccountEmail(const std::string& email) {
auto* active_user = user_manager::UserManager::Get()->GetActiveUser();
return active_user &&
@@ -66,8 +61,7 @@ GURL GetUrlWithEmailParam(base::StringPiece url_string,
return url;
}
-GURL GetInlineLoginUrl(const std::string& email,
- const InlineLoginDialogChromeOS::Source& source) {
+GURL GetInlineLoginUrl(const std::string& email) {
if (IsDeviceAccountEmail(email)) {
// It's a device account re-auth.
return GetUrlWithEmailParam(chrome::kChromeUIChromeSigninURL, email);
@@ -79,53 +73,35 @@ GURL GetInlineLoginUrl(const std::string& email,
}
// Addition of secondary Google Accounts is allowed.
- if (!ProfileManager::GetActiveUserProfile()->IsChild()) {
- return GetUrlWithEmailParam(chrome::kChromeUIChromeSigninURL, email);
+ if (ProfileManager::GetActiveUserProfile()->IsChild()) {
+ return GetUrlWithEmailParam(
+ SupervisedUserService::GetEduCoexistenceLoginUrl(), email);
}
- // User type is Child.
- if (!arc::IsSecondaryAccountForChildEnabled() &&
- source == InlineLoginDialogChromeOS::Source::kArc) {
- return GURL(chrome::kChromeUIAccountManagerErrorURL);
- }
- return GetUrlWithEmailParam(
- SupervisedUserService::GetEduCoexistenceLoginUrl(), email);
+ return GetUrlWithEmailParam(chrome::kChromeUIChromeSigninURL, email);
}
} // namespace
// static
-const char InlineLoginDialogChromeOS::kAccountAdditionSource[] =
- "AccountManager.AccountAdditionSource";
+bool InlineLoginDialogChromeOS::IsShown() {
+ return dialog != nullptr;
+}
// static
-void InlineLoginDialogChromeOS::Show(const std::string& email,
- const Source& source) {
- base::UmaHistogramEnumeration(kAccountAdditionSource, source);
- // If the dialog was triggered as a response to background request, it could
- // get displayed on the lock screen. In this case it is safe to ignore it,
- // since in this case user will get it again after a request to Google
- // properties.
- if (session_manager::SessionManager::Get()->IsUserSessionBlocked())
- return;
-
- if (dialog) {
- dialog->dialog_window()->Focus();
- return;
- }
-
- // Will be deleted by |SystemWebDialogDelegate::OnDialogClosed|.
- dialog =
- new InlineLoginDialogChromeOS(GetInlineLoginUrl(email, source), source);
- dialog->ShowSystemDialog();
-
- // TODO(crbug.com/1016828): Remove/update this after the dialog behavior on
- // Chrome OS is defined.
- ash::WindowBackdrop::Get(dialog->dialog_window())
- ->SetBackdropType(ash::WindowBackdrop::BackdropType::kSemiOpaque);
+void InlineLoginDialogChromeOS::ShowDeprecated(
+ const std::string& email,
+ const ::account_manager::AccountManagerFacade::AccountAdditionSource&
+ source) {
+ base::UmaHistogramEnumeration(
+ account_manager::AccountManagerFacade::kAccountAdditionSource, source);
+ ShowInternal(email);
}
-void InlineLoginDialogChromeOS::Show(const Source& source) {
- Show(/* email= */ std::string(), source);
+// static
+void InlineLoginDialogChromeOS::ShowDeprecated(
+ const ::account_manager::AccountManagerFacade::AccountAdditionSource&
+ source) {
+ ShowDeprecated(/* email= */ std::string(), source);
}
// static
@@ -159,31 +135,56 @@ gfx::Point InlineLoginDialogChromeOS::GetDialogPosition(const gfx::Size& size) {
}
void InlineLoginDialogChromeOS::AddObserver(
- web_modal::ModalDialogHostObserver* observer) {}
+ web_modal::ModalDialogHostObserver* observer) {
+ modal_dialog_host_observer_list_.AddObserver(observer);
+}
void InlineLoginDialogChromeOS::RemoveObserver(
- web_modal::ModalDialogHostObserver* observer) {}
+ web_modal::ModalDialogHostObserver* observer) {
+ modal_dialog_host_observer_list_.RemoveObserver(observer);
+}
void InlineLoginDialogChromeOS::SetEduCoexistenceFlowResult(
EduCoexistenceFlowResult result) {
edu_coexistence_flow_result_ = result;
}
-InlineLoginDialogChromeOS::InlineLoginDialogChromeOS(const Source& source)
- : InlineLoginDialogChromeOS(GetInlineLoginUrl(std::string(), source),
- source) {}
+InlineLoginDialogChromeOS::InlineLoginDialogChromeOS()
+ : InlineLoginDialogChromeOS(GetInlineLoginUrl(std::string())) {}
-InlineLoginDialogChromeOS::InlineLoginDialogChromeOS(const GURL& url,
- const Source& source)
+InlineLoginDialogChromeOS::InlineLoginDialogChromeOS(const GURL& url)
: SystemWebDialogDelegate(url, base::string16() /* title */),
delegate_(this),
- source_(source),
url_(url) {
DCHECK(!dialog);
dialog = this;
}
+InlineLoginDialogChromeOS::InlineLoginDialogChromeOS(
+ const GURL& url,
+ base::OnceClosure close_dialog_closure)
+ : SystemWebDialogDelegate(url, base::string16() /* title */),
+ delegate_(this),
+ url_(url),
+ close_dialog_closure_(std::move(close_dialog_closure)) {
+ DCHECK(!dialog);
+ dialog = this;
+}
+
InlineLoginDialogChromeOS::~InlineLoginDialogChromeOS() {
+ for (auto& observer : modal_dialog_host_observer_list_)
+ observer.OnHostDestroying();
+
+ if (webui()) {
+ web_modal::WebContentsModalDialogManager::FromWebContents(
+ webui()->GetWebContents())
+ ->SetDelegate(nullptr);
+ }
+
+ if (!close_dialog_closure_.is_null()) {
+ std::move(close_dialog_closure_).Run();
+ }
+
DCHECK_EQ(this, dialog);
dialog = nullptr;
}
@@ -195,26 +196,10 @@ void InlineLoginDialogChromeOS::GetDialogSize(gfx::Size* size) const {
std::min(kSigninDialogHeight, display.work_area().height()));
}
-std::string InlineLoginDialogChromeOS::GetDialogArgs() const {
- if (url_.GetWithEmptyPath() !=
- GURL(chrome::kChromeUIAccountManagerErrorURL)) {
- return std::string();
- }
-
- AccountManagerErrorType error =
- AccountManagerErrorType::kSecondaryAccountsDisabled;
- if (source_ == Source::kArc &&
- ProfileManager::GetActiveUserProfile()->IsChild() &&
- ProfileManager::GetActiveUserProfile()->GetPrefs()->GetBoolean(
- chromeos::prefs::kSecondaryGoogleAccountSigninAllowed)) {
- error = AccountManagerErrorType::kChildUserArcDisabled;
- }
-
- std::string data;
- base::DictionaryValue dialog_args;
- dialog_args.SetInteger("errorType", static_cast<int>(error));
- base::JSONWriter::Write(dialog_args, &data);
- return data;
+ui::ModalType InlineLoginDialogChromeOS::GetDialogModalType() const {
+ return chromeos::features::IsAccountManagementFlowsV2Enabled()
+ ? ui::MODAL_TYPE_SYSTEM
+ : ui::MODAL_TYPE_NONE;
}
bool InlineLoginDialogChromeOS::ShouldShowDialogTitle() const {
@@ -240,4 +225,42 @@ void InlineLoginDialogChromeOS::OnDialogClosed(const std::string& json_retval) {
SystemWebDialogDelegate::OnDialogClosed(json_retval);
}
+// static
+void InlineLoginDialogChromeOS::Show(base::OnceClosure close_dialog_closure) {
+ Show(/* email= */ std::string(), std::move(close_dialog_closure));
+}
+
+// static
+void InlineLoginDialogChromeOS::Show(const std::string& email,
+ base::OnceClosure close_dialog_closure) {
+ ShowInternal(email, std::move(close_dialog_closure));
+}
+
+// static
+void InlineLoginDialogChromeOS::ShowInternal(
+ const std::string& email,
+ base::OnceClosure close_dialog_closure) {
+ // If the dialog was triggered as a response to background request, it could
+ // get displayed on the lock screen. In this case it is safe to ignore it,
+ // since in this case user will get it again after a request to Google
+ // properties.
+ if (session_manager::SessionManager::Get()->IsUserSessionBlocked())
+ return;
+
+ if (dialog) {
+ dialog->dialog_window()->Focus();
+ return;
+ }
+
+ // Will be deleted by |SystemWebDialogDelegate::OnDialogClosed|.
+ dialog = new InlineLoginDialogChromeOS(GetInlineLoginUrl(email),
+ std::move(close_dialog_closure));
+ dialog->ShowSystemDialog();
+
+ // TODO(crbug.com/1016828): Remove/update this after the dialog behavior on
+ // Chrome OS is defined.
+ ash::WindowBackdrop::Get(dialog->dialog_window())
+ ->SetBackdropType(ash::WindowBackdrop::BackdropType::kSemiOpaque);
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h
index a4b3e12a6a3..013153af41b 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h
@@ -7,14 +7,22 @@
#include <string>
+#include "ash/components/account_manager/account_manager.h"
#include "base/macros.h"
+#include "base/observer_list.h"
#include "base/optional.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
#include "chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.h"
+#include "components/account_manager_core/account_manager_facade.h"
+#include "components/web_modal/modal_dialog_host.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
class GURL;
+namespace ash {
+class AccountManagerUIImpl;
+}
+
namespace chromeos {
// Extends from |SystemWebDialogDelegate| to create an always-on-top but movable
@@ -23,34 +31,6 @@ namespace chromeos {
class InlineLoginDialogChromeOS : public SystemWebDialogDelegate,
public web_modal::WebContentsModalDialogHost {
public:
- static const char kAccountAdditionSource[];
-
- // The source UX surface used for launching the account addition /
- // re-authentication dialog. This should be as specific as possible.
- // These values are persisted to logs. Entries should not be renumbered and
- // numeric values should never be reused.
- // Note: Please update |AccountManagerAccountAdditionSource| in enums.xml
- // after adding new values.
- enum class Source : int {
- // Settings > Add account button.
- kSettingsAddAccountButton = 0,
- // Settings > Sign in again button.
- kSettingsReauthAccountButton = 1,
- // Launched from an ARC application.
- kArc = 2,
- // Launched automatically from Chrome content area. As of now, this is
- // possible only when an account requires re-authentication.
- kContentArea = 3,
- // Print Preview dialog.
- kPrintPreviewDialog = 4,
- // Account Manager migration welcome screen.
- kAccountManagerMigrationWelcomeScreen = 5,
- // Onboarding.
- kOnboarding = 6,
-
- kMaxValue = kOnboarding
- };
-
// Represents the last reached step in the flow.
// Keep in sync with
// chrome/browser/resources/chromeos/edu_login/edu_login_util.js
@@ -66,14 +46,25 @@ class InlineLoginDialogChromeOS : public SystemWebDialogDelegate,
kMaxValue = kFlowCompleted
};
+ static bool IsShown();
+
// Displays the dialog. |email| pre-fills the account email field in the
// sign-in dialog - useful for account re-authentication. |source| specifies
// the source UX surface used for launching the dialog.
- static void Show(const std::string& email, const Source& source);
+ // DEPRECATED: Use AccountManagerFacade instead (see
+ // https://crbug.com/1140469).
+ static void ShowDeprecated(
+ const std::string& email,
+ const ::account_manager::AccountManagerFacade::AccountAdditionSource&
+ source);
// Displays the dialog for account addition. |source| specifies the source UX
// surface used for launching the dialog.
- static void Show(const Source& source);
+ // DEPRECATED: Use AccountManagerFacade instead (see
+ // https://crbug.com/1140469).
+ static void ShowDeprecated(
+ const ::account_manager::AccountManagerFacade::AccountAdditionSource&
+ source);
// Updates the value of the last reached step in 'Add Account' flow for child
// users. Before the dialog will close, this value will be reported to UMA.
@@ -88,25 +79,49 @@ class InlineLoginDialogChromeOS : public SystemWebDialogDelegate,
gfx::Point GetDialogPosition(const gfx::Size& size) override;
void AddObserver(web_modal::ModalDialogHostObserver* observer) override;
void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override;
+
void SetEduCoexistenceFlowResult(EduCoexistenceFlowResult result);
protected:
- explicit InlineLoginDialogChromeOS(const Source& source);
- InlineLoginDialogChromeOS(const GURL& url, const Source& source);
+ InlineLoginDialogChromeOS();
+ explicit InlineLoginDialogChromeOS(const GURL& url);
+
+ InlineLoginDialogChromeOS(const GURL& url,
+ base::OnceClosure close_dialog_closure);
~InlineLoginDialogChromeOS() override;
// ui::WebDialogDelegate overrides
void GetDialogSize(gfx::Size* size) const override;
- std::string GetDialogArgs() const override;
+ ui::ModalType GetDialogModalType() const override;
bool ShouldShowDialogTitle() const override;
void OnDialogShown(content::WebUI* webui) override;
void OnDialogClosed(const std::string& json_retval) override;
private:
+ // `Show` method can be called directly only by `AccountManagerUIImpl` class.
+ // To show the dialog, use `AccountManagerFacade`.
+ friend class ash::AccountManagerUIImpl;
+
+ // Displays the dialog. |close_dialog_closure| will be called when the dialog
+ // is closed.
+ static void Show(base::OnceClosure close_dialog_closure);
+
+ // Displays the dialog. |email| pre-fills the account email field in the
+ // sign-in dialog - useful for account re-authentication.
+ // |close_dialog_closure| will be called when the dialog is closed.
+ static void Show(const std::string& email,
+ base::OnceClosure close_dialog_closure);
+
+ static void ShowInternal(
+ const std::string& email,
+ base::OnceClosure close_dialog_closure = base::DoNothing());
+
InlineLoginHandlerModalDelegate delegate_;
- const Source source_;
const GURL url_;
base::Optional<EduCoexistenceFlowResult> edu_coexistence_flow_result_;
+ base::OnceClosure close_dialog_closure_;
+ base::ObserverList<web_modal::ModalDialogHostObserver>::Unchecked
+ modal_dialog_host_observer_list_;
DISALLOW_COPY_AND_ASSIGN(InlineLoginDialogChromeOS);
};
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
new file mode 100644
index 00000000000..ce3b9b8bc50
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_browsertest.cc
@@ -0,0 +1,74 @@
+// 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.
+
+#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h"
+
+#include "chrome/test/base/in_process_browser_test.h"
+#include "components/constrained_window/constrained_window_views.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/test/browser_test.h"
+#include "ui/views/accessibility/view_accessibility.h"
+#include "ui/views/test/widget_test.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/window/dialog_delegate.h"
+
+namespace chromeos {
+namespace {
+
+// Subclass to access protected constructor and protected methods.
+class TestInlineLoginDialogChromeOS : public InlineLoginDialogChromeOS {
+ public:
+ TestInlineLoginDialogChromeOS() = default;
+ using SystemWebDialogDelegate::dialog_window;
+};
+
+// A simulated modal dialog. Taking focus seems important to repro the crash,
+// but I'm not sure why.
+class ChildModalDialogDelegate : public views::DialogDelegateView {
+ public:
+ ChildModalDialogDelegate() {
+ // Our views::Widget will delete us.
+ DCHECK(owned_by_widget());
+ SetModalType(ui::MODAL_TYPE_CHILD);
+ SetFocusBehavior(FocusBehavior::ALWAYS);
+ // Dialogs that take focus must have a name to pass accessibility checks.
+ GetViewAccessibility().OverrideName("Test dialog");
+ }
+ ChildModalDialogDelegate(const ChildModalDialogDelegate&) = delete;
+ ChildModalDialogDelegate& operator=(const ChildModalDialogDelegate&) = delete;
+ ~ChildModalDialogDelegate() override = default;
+};
+
+using InlineLoginDialogChromeOSTest = InProcessBrowserTest;
+
+// Regression test for use-after-free and crash. https://1170577
+IN_PROC_BROWSER_TEST_F(InlineLoginDialogChromeOSTest,
+ CanOpenChildModelDialogThenCloseParent) {
+ // Show the dialog. It is owned by the views system.
+ TestInlineLoginDialogChromeOS* login_dialog =
+ new TestInlineLoginDialogChromeOS();
+ login_dialog->ShowSystemDialog();
+
+ // Create a child modal dialog, similar to an http auth modal dialog.
+ content::WebContents* web_contents =
+ login_dialog->GetWebUIForTest()->GetWebContents();
+ ASSERT_TRUE(web_contents);
+ // The ChildModalDialogDelegate is owned by the views system.
+ constrained_window::ShowWebModalDialogViews(new ChildModalDialogDelegate,
+ web_contents);
+
+ // Close the parent window.
+ views::Widget* login_widget =
+ views::Widget::GetWidgetForNativeWindow(login_dialog->dialog_window());
+ views::test::WidgetDestroyedWaiter waiter(login_widget);
+ login_dialog->Close();
+ waiter.Wait();
+
+ // No crash.
+}
+
+} // namespace
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_onboarding.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_onboarding.cc
index e4cc4915f42..3eef888c118 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_onboarding.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos_onboarding.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/supervised_user/supervised_user_features.h"
+#include "components/account_manager_core/account_manager_facade.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/widget/widget.h"
@@ -70,8 +71,9 @@ InlineLoginDialogChromeOSOnboarding* InlineLoginDialogChromeOSOnboarding::Show(
DCHECK(base::FeatureList::IsEnabled(supervised_users::kEduCoexistenceFlowV2));
base::UmaHistogramEnumeration(
- InlineLoginDialogChromeOS::kAccountAdditionSource,
- InlineLoginDialogChromeOS::Source::kOnboarding);
+ account_manager::AccountManagerFacade::kAccountAdditionSource,
+ ::account_manager::AccountManagerFacade::AccountAdditionSource::
+ kOnboarding);
DCHECK(window);
@@ -85,9 +87,7 @@ InlineLoginDialogChromeOSOnboarding* InlineLoginDialogChromeOSOnboarding::Show(
InlineLoginDialogChromeOSOnboarding::InlineLoginDialogChromeOSOnboarding(
const gfx::Size& size,
base::OnceCallback<void(void)> dialog_closed_callback)
- : InlineLoginDialogChromeOS(InlineLoginDialogChromeOS::Source::kOnboarding),
- size_(size),
- dialog_closed_callback_(std::move(dialog_closed_callback)) {
+ : size_(size), dialog_closed_callback_(std::move(dialog_closed_callback)) {
set_modal_type(ui::MODAL_TYPE_CHILD);
}
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 6169bab8421..25a5f214eb4 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
@@ -15,13 +15,14 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
-#include "chrome/browser/ui/user_manager.h"
+#include "chrome/browser/ui/profile_picker.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "chrome/common/pref_names.h"
#include "components/metrics/metrics_pref_names.h"
@@ -37,9 +38,9 @@
const char kSignInPromoQueryKeyShowAccountManagement[] =
"showAccountManagement";
-InlineLoginHandler::InlineLoginHandler() {}
+InlineLoginHandler::InlineLoginHandler() = default;
-InlineLoginHandler::~InlineLoginHandler() {}
+InlineLoginHandler::~InlineLoginHandler() = default;
void InlineLoginHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
@@ -63,6 +64,10 @@ void InlineLoginHandler::RegisterMessages() {
base::Unretained(this)));
}
+void InlineLoginHandler::OnJavascriptDisallowed() {
+ weak_ptr_factory_.InvalidateWeakPtrs();
+}
+
void InlineLoginHandler::HandleInitializeMessage(const base::ListValue* args) {
AllowJavascript();
content::WebContents* contents = web_ui()->GetWebContents();
@@ -229,10 +234,10 @@ void InlineLoginHandler::HandleSwitchToFullTabMessage(
}
void InlineLoginHandler::HandleDialogClose(const base::ListValue* args) {
-#if !defined(OS_CHROMEOS)
- // Does nothing if user manager is not showing.
- UserManagerProfileDialog::HideDialog();
-#endif // !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
+ // Does nothing if profile picker is not showing.
+ ProfilePickerForceSigninDialog::HideDialog();
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
}
void InlineLoginHandler::CloseDialogFromJavascript() {
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 ad371ccb5c9..4503b6d0d65 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
@@ -32,6 +32,7 @@ class InlineLoginHandler : public content::WebUIMessageHandler {
// content::WebUIMessageHandler overrides:
void RegisterMessages() override;
+ void OnJavascriptDisallowed() override;
protected:
// Enum for gaia auth mode, must match AuthMode defined in
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 7dde311eb0b..d22510b08c4 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,6 +7,9 @@
#include <memory>
#include <string>
+#include "ash/components/account_manager/account_manager_ash.h"
+#include "ash/components/account_manager/account_manager_factory.h"
+#include "ash/constants/ash_pref_names.h"
#include "base/base64.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -15,20 +18,19 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
-#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/child_accounts/secondary_account_consent_logger.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/chrome_device_id_helper.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/supervised_user/supervised_user_features.h"
#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/webui/chromeos/edu_coexistence_consent_tracker.h"
+#include "chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_state_tracker.h"
#include "chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.h"
#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/components/account_manager/account_manager_factory.h"
-#include "chromeos/constants/chromeos_features.h"
#include "chromeos/dbus/util/version_loader.h"
+#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/identity_manager.h"
@@ -40,6 +42,8 @@
namespace chromeos {
namespace {
+using ::ash::AccountManager;
+
constexpr char kCrosAddAccountFlow[] = "crosAddAccount";
constexpr char kCrosAddAccountEduFlow[] = "crosAddAccountEdu";
@@ -79,109 +83,14 @@ std::string GetInlineLoginFlowName(Profile* profile, const std::string* email) {
return kCrosAddAccountEduFlow;
}
-// A helper class for completing the inline login flow. Primarily, it is
-// responsible for exchanging the auth code, obtained after a successful user
-// sign in, for OAuth tokens and subsequently populating Chrome OS
-// AccountManager with these tokens.
-// This object is supposed to be used in a one-shot fashion and it deletes
-// itself after its work is complete.
-class SigninHelper : public GaiaAuthConsumer {
- public:
- SigninHelper(
- chromeos::AccountManager* account_manager,
- const base::RepeatingClosure& close_dialog_closure,
- scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
- const std::string& gaia_id,
- const std::string& email,
- const std::string& auth_code,
- const std::string& signin_scoped_device_id)
- : account_manager_(account_manager),
- close_dialog_closure_(close_dialog_closure),
- email_(email),
- url_loader_factory_(url_loader_factory),
- gaia_auth_fetcher_(this,
- gaia::GaiaSource::kChrome,
- url_loader_factory) {
- account_key_ = ::account_manager::AccountKey{
- gaia_id, account_manager::AccountType::kGaia};
-
- DCHECK(!signin_scoped_device_id.empty());
- gaia_auth_fetcher_.StartAuthCodeForOAuth2TokenExchangeWithDeviceId(
- auth_code, signin_scoped_device_id);
- }
-
- ~SigninHelper() override = default;
-
- protected:
- // GaiaAuthConsumer overrides.
- void OnClientOAuthSuccess(const ClientOAuthResult& result) override {
- // Flow of control after this call:
- // |AccountManager::UpsertAccount| updates / inserts the account and calls
- // its |Observer|s, one of which is
- // |ProfileOAuth2TokenServiceDelegateChromeOS|.
- // |ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted| seeds the
- // Gaia id and email id for this account in |AccountTrackerService| and
- // invokes |FireRefreshTokenAvailable|. This causes the account to propagate
- // throughout the Identity Service chain, including in
- // |AccountFetcherService|. |AccountFetcherService::OnRefreshTokenAvailable|
- // invokes |AccountTrackerService::StartTrackingAccount|, triggers a fetch
- // for the account information from Gaia and updates this information into
- // |AccountTrackerService|. At this point the account will be fully added to
- // the system.
- UpsertAccount(result.refresh_token);
-
- CloseDialogAndExit();
- }
-
- void OnClientOAuthFailure(const GoogleServiceAuthError& error) override {
- // TODO(sinhak): Display an error.
- CloseDialogAndExit();
- }
-
- void UpsertAccount(const std::string& refresh_token) {
- account_manager_->UpsertAccount(account_key_, email_, refresh_token);
- }
-
- void CloseDialogAndExit() {
- close_dialog_closure_.Run();
- Exit();
- }
-
- void Exit() {
- base::SequencedTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
- }
-
- chromeos::AccountManager* GetAccountManager() { return account_manager_; }
-
- const std::string GetEmail() { return email_; }
-
- const scoped_refptr<network::SharedURLLoaderFactory> GetUrlLoaderFactory() {
- return url_loader_factory_;
- }
-
- private:
- // A non-owning pointer to Chrome OS AccountManager.
- chromeos::AccountManager* const account_manager_;
- // A closure to close the hosting dialog window.
- base::RepeatingClosure close_dialog_closure_;
- // The user's AccountKey for which |this| object has been created.
- ::account_manager::AccountKey account_key_;
- // The user's email for which |this| object has been created.
- const std::string email_;
- scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
- // Used for exchanging auth code for OAuth tokens.
- GaiaAuthFetcher gaia_auth_fetcher_;
-
- DISALLOW_COPY_AND_ASSIGN(SigninHelper);
-};
-
// A version of SigninHelper for child users. After obtaining OAuth token it
// logs the parental consent with provided parent id and rapt. After successful
// consent logging populates Chrome OS AccountManager with the token.
class ChildSigninHelper : public SigninHelper {
public:
ChildSigninHelper(
- chromeos::AccountManager* account_manager,
+ ash::AccountManager* account_manager,
+ crosapi::AccountManagerAsh* account_manager_ash,
const base::RepeatingClosure& close_dialog_closure,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const std::string& gaia_id,
@@ -193,6 +102,7 @@ class ChildSigninHelper : public SigninHelper {
const std::string& parent_obfuscated_gaia_id,
const std::string& re_auth_proof_token)
: SigninHelper(account_manager,
+ account_manager_ash,
close_dialog_closure,
url_loader_factory,
gaia_id,
@@ -229,12 +139,10 @@ class ChildSigninHelper : public SigninHelper {
UMA_HISTOGRAM_ENUMERATION("Signin.SecondaryAccountConsentLog", result);
secondary_account_consent_logger_.reset();
if (result == SecondaryAccountConsentLogger::Result::kSuccess) {
- // The EDU account has been added/reauthenticated. Mark migration to ARC++
- // as completed.
- if (arc::IsSecondaryAccountForChildEnabled()) {
- pref_service_->SetBoolean(prefs::kEduCoexistenceArcMigrationCompleted,
- true);
- }
+ // The EDU account has been added/re-authenticated. Mark migration to
+ // ARC++ as completed.
+ pref_service_->SetBoolean(::prefs::kEduCoexistenceArcMigrationCompleted,
+ true);
UpsertAccount(refresh_token);
} else {
@@ -261,7 +169,8 @@ class ChildSigninHelper : public SigninHelper {
class EduCoexistenceChildSigninHelper : public SigninHelper {
public:
EduCoexistenceChildSigninHelper(
- chromeos::AccountManager* account_manager,
+ ash::AccountManager* account_manager,
+ crosapi::AccountManagerAsh* account_manager_ash,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const std::string& gaia_id,
const std::string& email,
@@ -270,6 +179,7 @@ class EduCoexistenceChildSigninHelper : public SigninHelper {
PrefService* pref_service,
const content::WebUI* web_ui)
: SigninHelper(account_manager,
+ account_manager_ash,
// EduCoexistenceChildSigninHelper will not be closing the
// dialog. Therefore, passing a void callback.
base::DoNothing(),
@@ -280,7 +190,13 @@ class EduCoexistenceChildSigninHelper : public SigninHelper {
signin_scoped_device_id),
pref_service_(pref_service),
web_ui_(web_ui),
- account_email_(email) {}
+ account_email_(email) {
+ // Account has been authorized i.e. family link user has entered the
+ // correct user name and password for their edu accounts. Account hasn't
+ // been added into account manager yet.
+ EduCoexistenceStateTracker::Get()->OnWebUiStateChanged(
+ web_ui_, EduCoexistenceStateTracker::FlowResult::kAccountAuthorized);
+ }
EduCoexistenceChildSigninHelper(const EduCoexistenceChildSigninHelper&) =
delete;
@@ -291,7 +207,7 @@ class EduCoexistenceChildSigninHelper : public SigninHelper {
protected:
// GaiaAuthConsumer overrides.
void OnClientOAuthSuccess(const ClientOAuthResult& result) override {
- EduCoexistenceConsentTracker::Get()->WaitForEduConsent(
+ EduCoexistenceStateTracker::Get()->SetEduConsentCallback(
web_ui_, account_email_,
base::BindOnce(&EduCoexistenceChildSigninHelper::OnConsentLogged,
weak_ptr_factory_.GetWeakPtr(), result.refresh_token));
@@ -299,12 +215,10 @@ class EduCoexistenceChildSigninHelper : public SigninHelper {
void OnConsentLogged(const std::string& refresh_token, bool success) {
if (success) {
- // The EDU account has been added/reauthenticated. Mark migration to ARC++
- // as completed.
- if (arc::IsSecondaryAccountForChildEnabled()) {
- pref_service_->SetBoolean(prefs::kEduCoexistenceArcMigrationCompleted,
- true);
- }
+ // The EDU account has been added/re-authenticated. Mark migration to
+ // ARC++ as completed.
+ pref_service_->SetBoolean(::prefs::kEduCoexistenceArcMigrationCompleted,
+ true);
UpsertAccount(refresh_token);
} else {
@@ -337,6 +251,14 @@ InlineLoginHandlerChromeOS::InlineLoginHandlerChromeOS(
InlineLoginHandlerChromeOS::~InlineLoginHandlerChromeOS() = default;
+// static
+void InlineLoginHandlerChromeOS::RegisterProfilePrefs(
+ PrefRegistrySimple* registry) {
+ registry->RegisterBooleanPref(
+ chromeos::prefs::kShouldSkipInlineLoginWelcomePage,
+ false /*default_value*/);
+}
+
void InlineLoginHandlerChromeOS::RegisterMessages() {
InlineLoginHandler::RegisterMessages();
@@ -349,6 +271,10 @@ void InlineLoginHandlerChromeOS::RegisterMessages() {
"getAccounts",
base::BindRepeating(&InlineLoginHandlerChromeOS::GetAccountsInSession,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "skipWelcomePage",
+ base::BindRepeating(&InlineLoginHandlerChromeOS::HandleSkipWelcomePage,
+ base::Unretained(this)));
}
void InlineLoginHandlerChromeOS::SetExtraInitParams(
@@ -395,10 +321,14 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const std::string& email,
// TODO(sinhak): Do not depend on Profile unnecessarily. When multiprofile on
// Chrome OS is released, get rid of |AccountManagerFactory| and get
// AccountManager directly from |g_browser_process|.
- chromeos::AccountManager* account_manager =
+ auto* account_manager = g_browser_process->platform_part()
+ ->GetAccountManagerFactory()
+ ->GetAccountManager(profile->GetPath().value());
+
+ crosapi::AccountManagerAsh* account_manager_ash =
g_browser_process->platform_part()
->GetAccountManagerFactory()
- ->GetAccountManager(profile->GetPath().value());
+ ->GetAccountManagerAsh(profile->GetPath().value());
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile);
@@ -423,15 +353,15 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const std::string& email,
// ChildSigninHelper deletes itself after its work is done.
new ChildSigninHelper(
- account_manager, close_dialog_closure_,
+ account_manager, account_manager_ash, close_dialog_closure_,
profile->GetURLLoaderFactory(), gaia_id, email, auth_code,
GetAccountDeviceId(GetSigninScopedDeviceIdForProfile(profile),
gaia_id),
identity_manager, profile->GetPrefs(), *parentId, *rapt);
} else {
new EduCoexistenceChildSigninHelper(
- account_manager, profile->GetURLLoaderFactory(), gaia_id, email,
- auth_code,
+ account_manager, account_manager_ash, profile->GetURLLoaderFactory(),
+ gaia_id, email, auth_code,
GetAccountDeviceId(GetSigninScopedDeviceIdForProfile(profile),
gaia_id),
profile->GetPrefs(), web_ui());
@@ -442,8 +372,8 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const std::string& email,
// SigninHelper deletes itself after its work is done.
new SigninHelper(
- account_manager, close_dialog_closure_, profile->GetURLLoaderFactory(),
- gaia_id, email, auth_code,
+ account_manager, account_manager_ash, close_dialog_closure_,
+ profile->GetURLLoaderFactory(), gaia_id, email, auth_code,
GetAccountDeviceId(GetSigninScopedDeviceIdForProfile(profile), gaia_id));
}
@@ -462,10 +392,9 @@ void InlineLoginHandlerChromeOS::GetAccountsInSession(
const base::ListValue* args) {
const std::string& callback_id = args->GetList()[0].GetString();
const Profile* profile = Profile::FromWebUI(web_ui());
- chromeos::AccountManager* account_manager =
- g_browser_process->platform_part()
- ->GetAccountManagerFactory()
- ->GetAccountManager(profile->GetPath().value());
+ auto* account_manager = g_browser_process->platform_part()
+ ->GetAccountManagerFactory()
+ ->GetAccountManager(profile->GetPath().value());
account_manager->GetAccounts(
base::BindOnce(&InlineLoginHandlerChromeOS::OnGetAccounts,
@@ -490,4 +419,12 @@ void InlineLoginHandlerChromeOS::OnGetAccounts(
std::move(account_emails));
}
+void InlineLoginHandlerChromeOS::HandleSkipWelcomePage(
+ const base::ListValue* args) {
+ bool skip;
+ CHECK(args->GetBoolean(0, &skip));
+ Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
+ chromeos::prefs::kShouldSkipInlineLoginWelcomePage, skip);
+}
+
} // namespace chromeos
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 bca1c4a0e51..591e35205f4 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
@@ -7,13 +7,15 @@
#include <string>
+#include "ash/components/account_manager/account_manager.h"
#include "base/macros.h"
#include "chrome/browser/ui/webui/signin/inline_login_handler.h"
-#include "chromeos/components/account_manager/account_manager.h"
#include "components/account_manager_core/account.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "google_apis/gaia/gaia_auth_fetcher.h"
+class PrefRegistrySimple;
+
namespace chromeos {
class InlineLoginHandlerChromeOS : public InlineLoginHandler {
@@ -22,6 +24,8 @@ class InlineLoginHandlerChromeOS : public InlineLoginHandler {
const base::RepeatingClosure& close_dialog_closure);
~InlineLoginHandlerChromeOS() override;
+ static void RegisterProfilePrefs(PrefRegistrySimple* registry);
+
// InlineLoginHandler overrides.
void RegisterMessages() override;
void SetExtraInitParams(base::DictionaryValue& params) override;
@@ -41,6 +45,7 @@ class InlineLoginHandlerChromeOS : public InlineLoginHandler {
void GetAccountsInSession(const base::ListValue* args);
void OnGetAccounts(const std::string& callback_id,
const std::vector<::account_manager::Account>& accounts);
+ void HandleSkipWelcomePage(const base::ListValue* args);
base::RepeatingClosure close_dialog_closure_;
base::WeakPtrFactory<InlineLoginHandlerChromeOS> weak_factory_{this};
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
index d0614926b5d..673f0fc9459 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
@@ -12,12 +12,14 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
+#include "base/feature_list.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/single_thread_task_runner.h"
+#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -30,6 +32,7 @@
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_window.h"
+#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/about_signin_internals_factory.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/chrome_device_id_helper.h"
@@ -42,16 +45,21 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/profile_picker.h"
+#include "chrome/browser/ui/signin/profile_colors_util.h"
+#include "chrome/browser/ui/signin/profile_customization_bubble_sync_controller.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/browser/ui/user_manager.h"
+#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.h"
#include "chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
+#include "chrome/browser/ui/webui/signin/signin_ui_error.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "chrome/browser/ui/webui/signin/signin_utils_desktop.h"
+#include "chrome/common/search/selected_colors_info.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
@@ -60,6 +68,7 @@
#include "components/signin/core/browser/about_signin_internals.h"
#include "components/signin/public/base/signin_metrics.h"
#include "components/signin/public/base/signin_pref_names.h"
+#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/accounts_cookie_mutator.h"
#include "components/signin/public/identity_manager/accounts_mutator.h"
#include "components/signin/public/identity_manager/identity_manager.h"
@@ -214,9 +223,10 @@ void SetProfileLocked(const base::FilePath profile_path, bool locked) {
if (!profile_path.empty()) {
ProfileManager* profile_manager = g_browser_process->profile_manager();
if (profile_manager) {
- ProfileAttributesEntry* entry;
- if (profile_manager->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile_path, &entry)) {
+ ProfileAttributesEntry* entry =
+ profile_manager->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_path);
+ if (entry) {
if (locked)
entry->LockForceSigninProfile(true);
else
@@ -226,27 +236,42 @@ void SetProfileLocked(const base::FilePath profile_path, bool locked) {
}
}
+void SetProfileName(const base::FilePath& profile_path,
+ const base::string16 name) {
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_path);
+ if (!entry) {
+ NOTREACHED();
+ return;
+ }
+
+ entry->SetLocalProfileName(name, /*is_default_name=*/false);
+}
+
void UnlockProfileAndHideLoginUI(const base::FilePath profile_path,
InlineLoginHandlerImpl* handler) {
SetProfileLocked(profile_path, false);
handler->CloseDialogFromJavascript();
- UserManager::Hide();
+ ProfilePicker::Hide();
}
void LockProfileAndShowUserManager(const base::FilePath& profile_path) {
SetProfileLocked(profile_path, true);
- UserManager::Show(profile_path,
- profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
+ ProfilePicker::Show(ProfilePicker::EntryPoint::kProfileLocked);
}
// Callback for DiceTurnOnSyncHelper.
void OnSyncSetupComplete(Profile* profile,
const std::string& username,
- const std::string& password) {
+ const std::string& password,
+ bool is_force_sign_in_with_usermanager) {
DCHECK(signin_util::IsForceSigninEnabled());
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile);
- bool has_primary_account = identity_manager->HasPrimaryAccount();
+ bool has_primary_account =
+ identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync);
if (has_primary_account && !password.empty()) {
scoped_refptr<password_manager::PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile,
@@ -261,9 +286,33 @@ void OnSyncSetupComplete(Profile* profile,
LocalAuth::SetLocalAuthCredentials(profile, password);
}
+ if (has_primary_account && is_force_sign_in_with_usermanager &&
+ base::FeatureList::IsEnabled(features::kNewProfilePicker)) {
+ CoreAccountInfo primary_account =
+ identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSync);
+ base::Optional<AccountInfo> primary_account_info =
+ identity_manager->FindExtendedAccountInfoForAccountWithRefreshToken(
+ primary_account);
+ base::string16 profile_name;
+ if (primary_account_info.has_value()) {
+ profile_name =
+ profiles::GetDefaultNameForNewSignedInProfile(*primary_account_info);
+ } else {
+ profile_name =
+ profiles::GetDefaultNameForNewSignedInProfileWithIncompleteInfo(
+ primary_account);
+ }
+ SetProfileName(profile->GetPath(), profile_name);
+ Browser* browser = chrome::FindBrowserWithProfile(profile);
+ if (browser) {
+ ApplyProfileColorAndShowCustomizationBubbleWhenNoValueSynced(
+ browser, GenerateNewProfileColor().color);
+ }
+ }
+
if (!has_primary_account) {
BrowserList::CloseAllBrowsersWithProfile(
- profile, base::Bind(&LockProfileAndShowUserManager),
+ profile, base::BindRepeating(&LockProfileAndShowUserManager),
// Cannot be called because skip_beforeunload is true.
BrowserList::CloseCallback(),
/*skip_beforeunload=*/true);
@@ -313,8 +362,9 @@ void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) {
// window won't be opened until now.
UnlockProfileAndHideLoginUI(profile_->GetPath(), handler_.get());
profiles::OpenBrowserWindowForProfile(
- base::Bind(&InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened,
- base::Unretained(this), result),
+ base::BindRepeating(
+ &InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened,
+ base::Unretained(this), result),
true, false, true, profile_, create_status_);
} else {
OnClientOAuthSuccessAndBrowserOpened(result, profile_, create_status_);
@@ -355,14 +405,15 @@ void InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened(
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile_);
- std::string primary_email = identity_manager->GetPrimaryAccountInfo().email;
+ std::string primary_email =
+ identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
+ .email;
if (gaia::AreEmailsSame(email_, primary_email) &&
reason == HandlerSigninReason::UNLOCK && !password_.empty() &&
profiles::IsLockAvailable(profile_)) {
LocalAuth::SetLocalAuthCredentials(profile_, password_);
}
-#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
if (!password_.empty()) {
scoped_refptr<password_manager::PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile_,
@@ -374,7 +425,7 @@ void InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened(
SAVED_ON_CHROME_SIGNIN);
}
}
-#endif
+
if (reason == HandlerSigninReason::UNLOCK) {
DCHECK(!identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
.IsEmpty());
@@ -394,7 +445,7 @@ void InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened(
}
identity_manager->GetAccountsCookieMutator()->AddAccountToCookie(
- identity_manager->GetPrimaryAccountId(),
+ identity_manager->GetPrimaryAccountId(signin::ConsentLevel::kSync),
gaia::GaiaSource::kPrimaryAccountManager, {});
signin_metrics::LogSigninReason(
@@ -428,7 +479,7 @@ void InlineSigninHelper::UntrustedSigninConfirmed(
base::RecordAction(base::UserMetricsAction("Signin_Undo_Signin"));
BrowserList::CloseAllBrowsersWithProfile(
- profile_, base::Bind(&LockProfileAndShowUserManager),
+ profile_, base::BindRepeating(&LockProfileAndShowUserManager),
// Cannot be called because skip_beforeunload is true.
BrowserList::CloseCallback(),
/*skip_beforeunload=*/true);
@@ -438,7 +489,7 @@ void InlineSigninHelper::CreateSyncStarter(const std::string& refresh_token) {
DCHECK(signin_util::IsForceSigninEnabled());
signin::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile_);
- if (identity_manager->HasPrimaryAccount()) {
+ if (identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync)) {
// Already signed in, nothing to do.
return;
}
@@ -460,7 +511,8 @@ void InlineSigninHelper::CreateSyncStarter(const std::string& refresh_token) {
signin::GetSigninReasonForEmbeddedPromoURL(current_url_), account_id,
DiceTurnSyncOnHelper::SigninAbortedMode::REMOVE_ACCOUNT,
std::move(delegate),
- base::BindOnce(&OnSyncSetupComplete, profile_, email_, password_));
+ base::BindOnce(&OnSyncSetupComplete, profile_, email_, password_,
+ is_force_sign_in_with_usermanager_));
}
void InlineSigninHelper::OnClientOAuthFailure(
@@ -627,7 +679,7 @@ void InlineLoginHandlerImpl::CompleteLogin(const std::string& email,
ProfileManager* manager = g_browser_process->profile_manager();
base::FilePath path = profiles::GetPathOfProfileWithEmail(manager, email);
if (path.empty())
- path = UserManager::GetSigninProfilePath();
+ path = ProfilePicker::GetForceSigninProfilePath();
if (path.empty())
return;
@@ -738,19 +790,21 @@ void InlineLoginHandlerImpl::FinishCompleteLogin(
if (reason == HandlerSigninReason::UNLOCK) {
std::string primary_username =
IdentityManagerFactory::GetForProfile(profile)
- ->GetPrimaryAccountInfo()
+ ->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
.email;
if (!gaia::AreEmailsSame(default_email, primary_username))
can_offer_for = CAN_OFFER_SIGNIN_FOR_SECONDARY_ACCOUNT;
}
- std::string error_msg;
- bool can_offer = reason == HandlerSigninReason::FETCH_LST_ONLY ||
- CanOfferSignin(profile, can_offer_for, params.gaia_id,
- params.email, &error_msg);
- if (!can_offer) {
- params.handler->HandleLoginError(error_msg,
- base::UTF8ToUTF16(params.email));
+ SigninUIError can_offer_error = SigninUIError::Ok();
+ if (reason != HandlerSigninReason::FETCH_LST_ONLY) {
+ can_offer_error =
+ CanOfferSignin(profile, can_offer_for, params.gaia_id, params.email);
+ }
+ if (!can_offer_error.IsOk()) {
+ params.handler->HandleLoginError(
+ base::UTF16ToUTF8(can_offer_error.message()),
+ base::UTF8ToUTF16(params.email));
return;
}
@@ -804,7 +858,7 @@ void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg,
if (profile->IsSystemProfile())
profile = g_browser_process->profile_manager()->GetProfileByPath(
- UserManager::GetSigninProfilePath());
+ ProfilePicker::GetForceSigninProfilePath());
if (!error_msg.empty()) {
LoginUIServiceFactory::GetForProfile(profile)->DisplayLoginResult(
browser, base::UTF8ToUTF16(error_msg), email);
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
index 0a278abbf90..76f73ef8fa1 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
@@ -72,7 +72,8 @@ class InlineLoginHandlerImpl : public InlineLoginHandler {
base::Value edu_login_params) override;
// This struct exists to pass parameters to the FinishCompleteLogin() method,
- // since the base::Bind() call does not support this many template args.
+ // since the base::BindRepeating() call does not support this many template
+ // args.
struct FinishCompleteLoginParams {
public:
FinishCompleteLoginParams(InlineLoginHandlerImpl* handler,
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 c6544bcfede..5bc7bc72da0 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
@@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -30,26 +31,30 @@
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_switches.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
+#include "ui/base/webui/web_ui_util.h"
#include "ui/resources/grit/webui_resources.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "ash/constants/ash_features.h"
+#include "ash/constants/ash_pref_names.h"
+#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/supervised_user/supervised_user_features.h"
+#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.h"
-#include "chrome/browser/ui/webui/chromeos/edu_coexistence_login_handler_chromeos.h"
+#include "chrome/browser/ui/webui/chromeos/edu_coexistence/edu_coexistence_login_handler_chromeos.h"
+#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h"
+#include "components/prefs/pref_service.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/chromeos/devicetype_utils.h"
#include "ui/strings/grit/ui_strings.h"
#else
#include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h"
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
namespace {
-constexpr char kResourcesGeneratedPath[] =
- "@out_folder@/gen/chrome/browser/resources/";
-
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void AddEduStrings(content::WebUIDataSource* source,
const base::string16& username) {
source->AddLocalizedString("okButton", IDS_APP_OK);
@@ -101,16 +106,17 @@ void AddEduStrings(content::WebUIDataSource* source,
IDS_EDU_COEXISTENCE_ERROR_HEADING);
source->AddLocalizedString("eduCoexistenceErrorDescription",
IDS_EDU_COEXISTENCE_ERROR_DESCRIPTION);
+ source->AddLocalizedString("loadingMessage", IDS_LOGIN_GAIA_LOADING_MESSAGE);
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
-content::WebUIDataSource* CreateWebUIDataSource() {
+content::WebUIDataSource* CreateWebUIDataSource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost);
webui::SetupWebUIDataSource(
source,
base::make_span(kGaiaAuthHostResources, kGaiaAuthHostResourcesSize),
- kResourcesGeneratedPath, IDR_INLINE_LOGIN_HTML);
+ IDR_INLINE_LOGIN_HTML);
// Only add a filter when runing as test.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@@ -124,7 +130,10 @@ content::WebUIDataSource* CreateWebUIDataSource() {
static constexpr webui::ResourcePath kResources[] = {
{"inline_login_app.js", IDR_INLINE_LOGIN_APP_JS},
{"inline_login_browser_proxy.js", IDR_INLINE_LOGIN_BROWSER_PROXY_JS},
-#if defined(OS_CHROMEOS)
+ {"webview_saml_injected.js", IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS},
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ {"welcome_page_app.js", IDR_INLINE_LOGIN_WELCOME_PAGE_APP_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},
{"edu", IDR_EDU_LOGIN_EDU_LOGIN_HTML},
@@ -148,8 +157,8 @@ content::WebUIDataSource* CreateWebUIDataSource() {
{"edu_coexistence_ui.js", IDR_EDU_COEXISTENCE_EDU_COEXISTENCE_UI_JS},
{"edu_coexistence_controller.js",
IDR_EDU_COEXISTENCE_EDU_COEXISTENCE_CONTROLLER_JS},
- {"chromeos/add_supervision/post_message_api.m.js",
- IDR_ADD_SUPERVISION_POST_MESSAGE_API_M_JS},
+ {"chromeos/add_supervision/post_message_api.js",
+ IDR_ADD_SUPERVISION_POST_MESSAGE_API_JS},
{"edu_coexistence_browser_proxy.js",
IDR_EDU_COEXISTENCE_EDU_COEXISTENCE_BROWSER_PROXY_JS},
{"edu_coexistence_button.js",
@@ -162,37 +171,69 @@ content::WebUIDataSource* CreateWebUIDataSource() {
{"edu_coexistence_css.js", IDR_EDU_COEXISTENCE_EDU_COEXISTENCE_CSS_JS},
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
+ {"account_manager_welcome_1x.png", IDR_ACCOUNT_MANAGER_WELCOME_1X_PNG},
+ {"account_manager_welcome_2x.png", IDR_ACCOUNT_MANAGER_WELCOME_2X_PNG},
{"googleg.svg", IDR_ACCOUNT_MANAGER_WELCOME_GOOGLE_LOGO_SVG},
#endif
- {"family_link_logo.svg", IDR_FAMILY_LINK_LOGO_SVG},
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
};
+ source->AddResourcePaths(kResources);
- webui::AddResourcePathsBulk(source, kResources);
+ static constexpr webui::LocalizedString kLocalizedStrings[] = {
+ {"title", IDS_CHROME_SIGNIN_TITLE},
+ {"accessibleCloseButtonLabel", IDS_SIGNIN_ACCESSIBLE_CLOSE_BUTTON},
+ {"accessibleBackButtonLabel", IDS_SIGNIN_ACCESSIBLE_BACK_BUTTON},
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ {"ok", IDS_APP_OK},
+ {"accountManagerDialogWelcomeTitle",
+ IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_TITLE},
+ {"accountManagerDialogWelcomeCheckbox",
+ IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_CHECKBOX},
+ {"accountManagerErrorNoInternetTitle",
+ IDS_ACCOUNT_MANAGER_ERROR_NO_INTERNET_TITLE},
+ {"accountManagerErrorNoInternetBody",
+ IDS_ACCOUNT_MANAGER_ERROR_NO_INTERNET_BODY},
+ {"accountManagerErrorCannotAddAccountTitle",
+ IDS_ACCOUNT_MANAGER_ERROR_CANNOT_ADD_ACCOUNT_TITLE},
+ {"accountManagerErrorCannotAddAccountBody",
+ IDS_ACCOUNT_MANAGER_ERROR_CANNOT_ADD_ACCOUNT_BODY},
+#endif
+ };
+ source->AddLocalizedStrings(kLocalizedStrings);
- source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE);
- source->AddLocalizedString(
- "accessibleCloseButtonLabel", IDS_SIGNIN_ACCESSIBLE_CLOSE_BUTTON);
- source->AddLocalizedString(
- "accessibleBackButtonLabel", IDS_SIGNIN_ACCESSIBLE_BACK_BUTTON);
-#if defined(OS_CHROMEOS)
- source->AddLocalizedString("accountManagerErrorNoInternetTitle",
- IDS_ACCOUNT_MANAGER_ERROR_NO_INTERNET_TITLE);
- source->AddLocalizedString("accountManagerErrorNoInternetBody",
- IDS_ACCOUNT_MANAGER_ERROR_NO_INTERNET_BODY);
- source->AddLocalizedString(
- "accountManagerErrorCannotAddAccountTitle",
- IDS_ACCOUNT_MANAGER_ERROR_CANNOT_ADD_ACCOUNT_TITLE);
- source->AddLocalizedString("accountManagerErrorCannotAddAccountBody",
- IDS_ACCOUNT_MANAGER_ERROR_CANNOT_ADD_ACCOUNT_BODY);
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+ source->AddBoolean("isAccountManagementFlowsV2Enabled",
+ chromeos::features::IsAccountManagementFlowsV2Enabled());
+ source->AddBoolean("shouldSkipWelcomePage",
+ profile->GetPrefs()->GetBoolean(
+ chromeos::prefs::kShouldSkipInlineLoginWelcomePage));
+ source->AddString(
+ "accountManagerDialogWelcomeBody",
+ l10n_util::GetStringFUTF16(
+ IDS_ACCOUNT_MANAGER_DIALOG_WELCOME_BODY,
+ base::UTF8ToUTF16(
+ chrome::GetOSSettingsUrl(
+ chromeos::settings::mojom::kMyAccountsSubpagePath)
+ .spec()),
+ ui::GetChromeOSDeviceName()));
+
+ user_manager::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
+ DCHECK(user);
+ source->AddString("userName", user->GetGivenName());
+ source->AddString("accountManagerOsSettingsUrl",
+ chrome::GetOSSettingsUrl(
+ chromeos::settings::mojom::kMyAccountsSubpagePath)
+ .spec());
#endif
+
return source;
}
// Returns whether |url| can be displayed in a chrome://chrome-signin tab,
// depending on the signin reason that is encoded in the url.
bool IsValidChromeSigninReason(const GURL& url) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
return true;
#else
signin_metrics::Reason reason =
@@ -220,7 +261,7 @@ bool IsValidChromeSigninReason(const GURL& url) {
return false;
}
NOTREACHED();
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
}
} // namespace
@@ -230,15 +271,15 @@ InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
return;
Profile* profile = Profile::FromWebUI(web_ui);
- content::WebUIDataSource* source = CreateWebUIDataSource();
-#if defined(OS_CHROMEOS)
+ content::WebUIDataSource* source = CreateWebUIDataSource(profile);
+#if BUILDFLAG(IS_CHROMEOS_ASH)
base::string16 username =
chromeos::ProfileHelper::Get()->GetUserByProfile(profile)->GetGivenName();
AddEduStrings(source, username);
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
content::WebUIDataSource::Add(profile, source);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
web_ui->AddMessageHandler(
std::make_unique<chromeos::InlineLoginHandlerChromeOS>(
base::BindRepeating(&WebDialogUIBase::CloseDialog,
@@ -262,7 +303,7 @@ InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
#else
web_ui->AddMessageHandler(std::make_unique<InlineLoginHandlerImpl>());
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc b/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
index 99a690256e8..5fddfe996f0 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
@@ -17,12 +18,12 @@
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/common/url_constants.h"
-#if !defined(OS_CHROMEOS)
-#include "chrome/browser/ui/user_manager.h"
-#endif // !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ui/profile_picker.h"
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
LoginUIService::LoginUIService(Profile* profile)
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
: profile_(profile)
#endif
{
@@ -59,18 +60,18 @@ void LoginUIService::SyncConfirmationUIClosed(
void LoginUIService::ShowExtensionLoginPrompt(bool enable_sync,
const std::string& email_hint) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
NOTREACHED();
#else
// There is no sign-in flow for guest or system profile.
if (profile_->IsGuestSession() || profile_->IsSystemProfile())
return;
// Locked profile should be unlocked with UserManager only.
- ProfileAttributesEntry* entry;
- if (g_browser_process->profile_manager()
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile_->GetPath(), &entry) &&
- entry->IsSigninRequired()) {
+ .GetProfileAttributesWithPath(profile_->GetPath());
+ if (entry && entry->IsSigninRequired()) {
return;
}
@@ -95,7 +96,7 @@ void LoginUIService::ShowExtensionLoginPrompt(bool enable_sync,
void LoginUIService::DisplayLoginResult(Browser* browser,
const base::string16& error_message,
const base::string16& email) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// ChromeOS doesn't have the avatar bubble so it never calls this function.
NOTREACHED();
#else
@@ -105,8 +106,9 @@ void LoginUIService::DisplayLoginResult(Browser* browser,
if (!error_message.empty()) {
if (browser) {
browser->signin_view_controller()->ShowModalSigninErrorDialog();
- } else if (profile_->GetPath() == UserManager::GetSigninProfilePath()) {
- UserManagerProfileDialog::DisplayErrorMessage();
+ } else if (profile_->GetPath() ==
+ ProfilePicker::GetForceSigninProfilePath()) {
+ ProfilePickerForceSigninDialog::DisplayErrorMessage();
} else {
LOG(ERROR) << "Unable to show Login error message: " << error_message;
}
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service.h b/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
index 1f96eb9c1c5..00f29ff1093 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
+#include "build/chromeos_buildflags.h"
#include "components/keyed_service/core/keyed_service.h"
class Browser;
@@ -41,8 +42,11 @@ class LoginUIService : public KeyedService {
SYNC_WITH_DEFAULT_SETTINGS,
// Show the user the sync settings before starting sync.
CONFIGURE_SYNC_FIRST,
- // The signing process was aborted, don't start sync or show settings.
- ABORT_SIGNIN,
+ // Turn sync on process was aborted, don't start sync or show settings.
+ ABORT_SYNC,
+ // The dialog got closed without any explicit user action. The impact of
+ // this action depends on the particular flow.
+ UI_CLOSED,
};
// Interface for obervers of LoginUIService.
@@ -107,7 +111,7 @@ class LoginUIService : public KeyedService {
private:
// Weak pointers to the recently opened UIs, with the most recent in front.
std::list<LoginUI*> ui_list_;
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
Profile* profile_;
#endif
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc b/chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
index e050533f2d7..479e48dc4fc 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -16,7 +17,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h"
@@ -102,7 +103,7 @@ TEST_F(LoginUIServiceTest, SetProfileBlockingErrorMessage) {
EXPECT_TRUE(service.IsDisplayingProfileBlockedErrorMessage());
}
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
class LoginUIServiceExtensionLoginPromptTest
: public BrowserWithTestWindowTest {
public:
@@ -156,10 +157,11 @@ TEST_F(LoginUIServiceExtensionLoginPromptTest, Show) {
}
TEST_F(LoginUIServiceExtensionLoginPromptTest, AsLockedProfile) {
- ProfileAttributesEntry* entry;
- ASSERT_TRUE(g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile()->GetPath(), &entry));
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile()->GetPath());
+ ASSERT_NE(entry, nullptr);
entry->SetIsSigninRequired(true);
service_->ShowExtensionLoginPrompt(/*restricted_to_primary_account=*/true,
/*email_hint=*/std::string());
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 4dda183432c..d82d5a5974e 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
@@ -7,13 +7,14 @@
#include "base/bind.h"
#include "base/notreached.h"
#include "base/run_loop.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
@@ -26,6 +27,7 @@
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/signin/public/identity_manager/consent_level.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
@@ -81,9 +83,14 @@ class SignInObserver : public signin::IdentityManager::Observer {
FAIL() << "Sign in observer timed out!";
}
- void OnPrimaryAccountSet(
- const CoreAccountInfo& primary_account_info) override {
- DVLOG(1) << "Google signin succeeded.";
+ void OnPrimaryAccountChanged(
+ const signin::PrimaryAccountChangeEvent& event) override {
+ if (event.GetEventTypeFor(signin::ConsentLevel::kSync) !=
+ signin::PrimaryAccountChangeEvent::Type::kSet) {
+ return;
+ }
+
+ DVLOG(1) << "Sign in finished: Sync primary account was set.";
signed_in_ = true;
QuitLoopRunner();
}
@@ -195,7 +202,7 @@ enum class SyncConfirmationDialogAction { kConfirm, kCancel };
enum class ReauthDialogAction { kConfirm, kCancel };
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
std::string GetButtonIdForSyncConfirmationDialogAction(
SyncConfirmationDialogAction action) {
switch (action) {
@@ -264,7 +271,7 @@ bool IsElementReady(content::WebContents* web_contents,
web_contents, find_element_js, &message));
return message == "Ok";
}
-#endif // !defined(OS_CHROMEOS)
+#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
} // namespace
@@ -274,7 +281,7 @@ class SigninViewControllerTestUtil {
static bool TryDismissSyncConfirmationDialog(
Browser* browser,
SyncConfirmationDialogAction action) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
NOTREACHED();
return false;
#else
@@ -303,7 +310,7 @@ class SigninViewControllerTestUtil {
static bool TryCompleteSigninEmailConfirmationDialog(
Browser* browser,
SigninEmailConfirmationDialog::Action action) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
NOTREACHED();
return false;
#else
@@ -336,7 +343,7 @@ class SigninViewControllerTestUtil {
static bool TryCompleteReauthConfirmationDialog(Browser* browser,
ReauthDialogAction action) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
NOTREACHED();
return false;
#else
@@ -435,19 +442,20 @@ void ExecuteJsToSigninInSigninFrame(Browser* browser,
bool SignInWithUI(Browser* browser,
const std::string& username,
const std::string& password) {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
NOTREACHED();
return false;
#else
SignInObserver signin_observer;
- ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
- scoped_signin_observer(&signin_observer);
- scoped_signin_observer.Add(
+ base::ScopedObservation<signin::IdentityManager,
+ signin::IdentityManager::Observer>
+ scoped_signin_observation(&signin_observer);
+ scoped_signin_observation.Observe(
IdentityManagerFactory::GetForProfile(browser->profile()));
signin_metrics::AccessPoint access_point =
signin_metrics::AccessPoint::ACCESS_POINT_MENU;
- chrome::ShowBrowserSignin(browser, access_point);
+ chrome::ShowBrowserSignin(browser, access_point, signin::ConsentLevel::kSync);
content::WebContents* active_contents =
browser->tab_strip_model()->GetActiveWebContents();
DCHECK(active_contents);
@@ -465,9 +473,9 @@ bool DismissSyncConfirmationDialog(Browser* browser,
base::TimeDelta timeout,
SyncConfirmationDialogAction action) {
SyncConfirmationClosedObserver confirmation_closed_observer;
- ScopedObserver<LoginUIService, LoginUIService::Observer>
- scoped_confirmation_closed_observer(&confirmation_closed_observer);
- scoped_confirmation_closed_observer.Add(
+ base::ScopedObservation<LoginUIService, LoginUIService::Observer>
+ scoped_confirmation_closed_observation(&confirmation_closed_observer);
+ scoped_confirmation_closed_observation.Observe(
LoginUIServiceFactory::GetForProfile(browser->profile()));
const base::Time expire_time = base::Time::Now() + timeout;
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.cc b/chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.cc
index 5a82c1b499f..6cea5b550dd 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.h"
+#include "chrome/browser/search/chrome_colors/chrome_colors_service.h"
#include "chrome/common/search/generated_colors_info.h"
#include "chrome/common/themes/autogenerated_theme_util.h"
#include "ui/base/l10n/l10n_util.h"
@@ -21,6 +22,8 @@ ProfileCreationCustomizeThemesHandler::
void ProfileCreationCustomizeThemesHandler::ApplyAutogeneratedTheme(
SkColor frame_color) {
+ chrome_colors::ChromeColorsService::RecordColorAppliedHistogram(
+ chrome_colors::kOtherColorId);
auto theme = customize_themes::mojom::Theme::New();
theme->type = customize_themes::mojom::ThemeType::kAutogenerated;
auto theme_colors = customize_themes::mojom::ThemeColors::New();
@@ -34,13 +37,17 @@ void ProfileCreationCustomizeThemesHandler::ApplyAutogeneratedTheme(
}
void ProfileCreationCustomizeThemesHandler::ApplyDefaultTheme() {
+ chrome_colors::ChromeColorsService::RecordColorAppliedHistogram(
+ chrome_colors::kDefaultColorId);
auto theme = customize_themes::mojom::Theme::New();
theme->type = customize_themes::mojom::ThemeType::kDefault;
- theme->info = customize_themes::mojom::ThemeInfo::NewChromeThemeId(-1);
+ theme->info = customize_themes::mojom::ThemeInfo::NewChromeThemeId(
+ chrome_colors::kDefaultColorId);
remote_client_->SetTheme(std::move(theme));
}
void ProfileCreationCustomizeThemesHandler::ApplyChromeTheme(int32_t id) {
+ chrome_colors::ChromeColorsService::RecordColorAppliedHistogram(id);
auto theme = customize_themes::mojom::Theme::New();
theme->type = customize_themes::mojom::ThemeType::kChrome;
theme->info = customize_themes::mojom::ThemeInfo::NewChromeThemeId(id);
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 fdd23f908cd..80408938859 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.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_contents.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/webui/web_ui_util.h"
@@ -46,34 +47,32 @@ void ProfileCustomizationHandler::RegisterMessages() {
}
void ProfileCustomizationHandler::OnJavascriptAllowed() {
- observed_profile_.Add(
+ observed_profile_.Observe(
&g_browser_process->profile_manager()->GetProfileAttributesStorage());
}
void ProfileCustomizationHandler::OnJavascriptDisallowed() {
- observed_profile_.RemoveAll();
+ observed_profile_.Reset();
}
void ProfileCustomizationHandler::OnProfileAvatarChanged(
const base::FilePath& profile_path) {
- if (profile_path != profile_path_)
- return;
- UpdateProfileInfo();
+ UpdateProfileInfo(profile_path);
}
void ProfileCustomizationHandler::OnProfileHighResAvatarLoaded(
const base::FilePath& profile_path) {
- if (profile_path != profile_path_)
- return;
- UpdateProfileInfo();
+ UpdateProfileInfo(profile_path);
}
void ProfileCustomizationHandler::OnProfileThemeColorsChanged(
const base::FilePath& profile_path) {
- DCHECK(IsJavascriptAllowed());
- if (profile_path != profile_path_)
- return;
- UpdateProfileInfo();
+ UpdateProfileInfo(profile_path);
+}
+
+void ProfileCustomizationHandler::OnProfileHostedDomainChanged(
+ const base::FilePath& profile_path) {
+ UpdateProfileInfo(profile_path);
}
void ProfileCustomizationHandler::HandleInitialized(
@@ -91,14 +90,18 @@ void ProfileCustomizationHandler::HandleDone(const base::ListValue* args) {
base::TrimWhitespace(profile_name, base::TRIM_ALL, &profile_name);
DCHECK(!profile_name.empty());
- GetProfileEntry()->SetLocalProfileName(profile_name);
+ GetProfileEntry()->SetLocalProfileName(profile_name,
+ /*is_default_name=*/false);
if (done_closure_)
std::move(done_closure_).Run();
}
-void ProfileCustomizationHandler::UpdateProfileInfo() {
+void ProfileCustomizationHandler::UpdateProfileInfo(
+ const base::FilePath& profile_path) {
DCHECK(IsJavascriptAllowed());
+ if (profile_path != profile_path_)
+ return;
FireWebUIListener("on-profile-info-changed", GetProfileInfoValue());
}
@@ -119,14 +122,16 @@ base::Value ProfileCustomizationHandler::GetProfileInfoValue() {
profiles::GetSizedAvatarIcon(entry->GetAvatarIcon(avatar_icon_size), true,
avatar_icon_size, avatar_icon_size);
dict.SetStringKey("pictureUrl", webui::GetBitmapDataUrl(icon.AsBitmap()));
+ dict.SetBoolKey("isManaged",
+ AccountInfo::IsManaged(entry->GetHostedDomain()));
return dict;
}
ProfileAttributesEntry* ProfileCustomizationHandler::GetProfileEntry() const {
- ProfileAttributesEntry* entry = nullptr;
- g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile_path_, &entry);
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_path_);
DCHECK(entry);
return entry;
}
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 b9cb5d9c81b..f505cdb8849 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/profile_customization_handler.h
@@ -9,7 +9,7 @@
#include "base/callback.h"
#include "base/files/file_path.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
namespace base {
@@ -39,6 +39,8 @@ class ProfileCustomizationHandler : public content::WebUIMessageHandler,
void OnProfileHighResAvatarLoaded(
const base::FilePath& profile_path) override;
void OnProfileThemeColorsChanged(const base::FilePath& profile_path) override;
+ void OnProfileHostedDomainChanged(
+ const base::FilePath& profile_path) override;
private:
// Handlers for messages from javascript.
@@ -46,7 +48,9 @@ class ProfileCustomizationHandler : public content::WebUIMessageHandler,
void HandleDone(const base::ListValue* args);
// Sends an updated profile info (avatar and colors) to the WebUI.
- void UpdateProfileInfo();
+ // `profile_path` is the path of the profile being updated, this function does
+ // nothing if the profile path does not match the current profile.
+ void UpdateProfileInfo(const base::FilePath& profile_path);
// Computes the profile info (avatar and colors) to be sent to the WebUI.
base::Value GetProfileInfoValue();
@@ -55,7 +59,8 @@ class ProfileCustomizationHandler : public content::WebUIMessageHandler,
ProfileAttributesEntry* GetProfileEntry() const;
base::FilePath profile_path_;
- ScopedObserver<ProfileAttributesStorage, ProfileAttributesStorage::Observer>
+ base::ScopedObservation<ProfileAttributesStorage,
+ ProfileAttributesStorage::Observer>
observed_profile_{this};
// Called when the "Done" button has been pressed.
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 f4e11e5bf84..02d53bfc69c 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_customization_ui.cc
@@ -20,6 +20,7 @@
#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 "ui/base/webui/resource_path.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/resources/grit/webui_generated_resources.h"
#include "ui/resources/grit/webui_resources.h"
@@ -29,22 +30,24 @@ ProfileCustomizationUI::ProfileCustomizationUI(content::WebUI* web_ui)
customize_themes_factory_receiver_(this) {
content::WebUIDataSource* source = content::WebUIDataSource::Create(
chrome::kChromeUIProfileCustomizationHost);
+ webui::SetJSModuleDefaults(source);
source->SetDefaultResource(IDR_PROFILE_CUSTOMIZATION_HTML);
- source->AddResourcePath("profile_customization_app.js",
- IDR_PROFILE_CUSTOMIZATION_APP_JS);
- source->AddResourcePath("profile_customization_browser_proxy.js",
- IDR_PROFILE_CUSTOMIZATION_BROWSER_PROXY_JS);
- source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS);
- source->AddResourcePath("signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS);
+ static constexpr webui::ResourcePath kResources[] = {
+ {"profile_customization_app.js", IDR_PROFILE_CUSTOMIZATION_APP_JS},
+ {"profile_customization_browser_proxy.js",
+ IDR_PROFILE_CUSTOMIZATION_BROWSER_PROXY_JS},
+ {"signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS},
+ {"signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS},
+ };
+ source->AddResourcePaths(kResources);
// Localized strings.
- source->UseStringsJs();
- source->EnableReplaceI18nInJS();
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"profileCustomizationDoneLabel",
IDS_PROFILE_CUSTOMIZATION_DONE_BUTTON_LABEL},
{"profileCustomizationPickThemeTitle",
IDS_PROFILE_CUSTOMIZATION_PICK_THEME_TITLE},
+ {"profileCustomizationInputLabel", IDS_PROFILE_CUSTOMIZATION_INPUT_LABEL},
// Color picker strings:
{"colorPickerLabel", IDS_NTP_CUSTOMIZE_COLOR_PICKER_LABEL},
@@ -52,27 +55,16 @@ ProfileCustomizationUI::ProfileCustomizationUI(content::WebUI* web_ui)
{"thirdPartyThemeDescription", IDS_NTP_CUSTOMIZE_3PT_THEME_DESC},
{"uninstallThirdPartyThemeButton", IDS_NTP_CUSTOMIZE_3PT_THEME_UNINSTALL},
};
- webui::AddLocalizedStringsBulk(source, kLocalizedStrings);
+ source->AddLocalizedStrings(kLocalizedStrings);
// loadTimeData.
Profile* profile = Profile::FromWebUI(web_ui);
- ProfileAttributesEntry* entry = nullptr;
- g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile->GetPath(), &entry);
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile->GetPath());
source->AddString("profileName",
base::UTF16ToUTF8(entry->GetLocalProfileName()));
- source->AddBoolean("isManaged",
- !entry->GetHostedDomain().empty() &&
- entry->GetHostedDomain() != kNoHostedDomainFound);
-
- // Resources for testing.
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test 'self';");
- source->DisableTrustedTypesCSP();
- source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
- source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML);
content::WebUIDataSource::Add(profile, source);
}
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 81f0c0cdb01..5073dbcd727 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc
@@ -8,6 +8,7 @@
#include "base/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/optional.h"
+#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/util/values/values_util.h"
#include "chrome/browser/browser_process.h"
@@ -24,16 +25,22 @@
#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_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/profile_picker.h"
#include "chrome/browser/ui/signin/profile_colors_util.h"
+#include "chrome/browser/ui/singleton_tabs.h"
+#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/profile_helper.h"
+#include "chrome/browser/ui/webui/signin/login_ui_service.h"
+#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/search/generated_colors_info.h"
#include "chrome/common/themes/autogenerated_theme_util.h"
#include "chrome/common/webui_url_constants.h"
#include "components/signin/public/identity_manager/account_info.h"
+#include "components/startup_metric_utils/browser/startup_metric_utils.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
@@ -58,10 +65,6 @@ enum class ProfilePickerAction {
kMaxValue = kDeleteProfile,
};
-bool IsManaged(const std::string& hosted_domain) {
- return !hosted_domain.empty() && hosted_domain != kNoHostedDomainFound;
-}
-
base::Optional<SkColor> GetChromeColorColorById(int color_id) {
for (chrome_colors::ColorInfo color_info :
chrome_colors::kGeneratedColorsInfo) {
@@ -85,7 +88,7 @@ void RecordNewProfileSpec(base::Optional<SkColor> profile_color,
int theme_id =
profile_color.has_value()
? chrome_colors::ChromeColorsService::GetColorId(*profile_color)
- : -1;
+ : chrome_colors::kDefaultColorId;
base::UmaHistogramSparse("ProfilePicker.NewProfileTheme", theme_id);
if (ProfileShortcutManager::IsFeatureEnabled()) {
@@ -145,6 +148,26 @@ base::Value CreateAutogeneratedProfileThemeInfo(int color_id,
avatar_icon_size);
}
+void OpenOnSelectProfileTargetUrl(Browser* browser) {
+ GURL target_page_url = ProfilePicker::GetOnSelectProfileTargetUrl();
+ if (target_page_url.is_empty())
+ return;
+
+ if (target_page_url.spec() == chrome::kChromeUIHelpURL) {
+ chrome::ShowAboutChrome(browser);
+ } else if (target_page_url.spec() == chrome::kChromeUISettingsURL) {
+ chrome::ShowSettings(browser);
+ } else if (target_page_url.spec() == ProfilePicker::kTaskManagerUrl) {
+ chrome::OpenTaskManager(browser);
+
+ } else {
+ NavigateParams params(
+ GetSingletonTabNavigateParams(browser, target_page_url));
+ params.path_behavior = NavigateParams::RESPECT;
+ ShowSingletonTabOverwritingNTP(browser, &params);
+ }
+}
+
} // namespace
ProfilePickerHandler::ProfilePickerHandler() = default;
@@ -206,10 +229,25 @@ void ProfilePickerHandler::RegisterMessages() {
base::BindRepeating(
&ProfilePickerHandler::HandleLoadSignInProfileCreationFlow,
base::Unretained(this)));
+ // TODO(crbug.com/1115056): Consider renaming this message to
+ // 'createLocalProfile' as this is only used for local profiles.
+ web_ui()->RegisterMessageCallback(
+ "getAvailableIcons",
+ base::BindRepeating(&ProfilePickerHandler::HandleGetAvailableIcons,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"createProfile",
base::BindRepeating(&ProfilePickerHandler::HandleCreateProfile,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "setProfileName",
+ base::BindRepeating(&ProfilePickerHandler::HandleSetProfileName,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "recordSignInPromoImpression",
+ base::BindRepeating(
+ &ProfilePickerHandler::HandleRecordSignInPromoImpression,
+ base::Unretained(this)));
}
void ProfilePickerHandler::OnJavascriptAllowed() {
@@ -221,6 +259,7 @@ void ProfilePickerHandler::OnJavascriptDisallowed() {
g_browser_process->profile_manager()
->GetProfileAttributesStorage()
.RemoveObserver(this);
+ weak_factory_.InvalidateWeakPtrs();
}
void ProfilePickerHandler::HandleMainViewInitialize(
@@ -249,18 +288,34 @@ void ProfilePickerHandler::HandleLaunchSelectedProfile(
if (!profile_path)
return;
- ProfileAttributesEntry* entry;
- if (!g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(*profile_path, &entry)) {
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(*profile_path);
+ if (!entry) {
NOTREACHED();
return;
}
if (entry->IsSigninRequired()) {
- // The new profile picker does not yet support force signin policy and
- // should not be accessible for devices with this policy.
- NOTREACHED();
+ DCHECK(signin_util::IsForceSigninEnabled());
+ if (entry->GetActiveTime() != base::Time()) {
+ // If force-sign-in is enabled, do not allow users to sign in to a
+ // pre-existing locked profile, as this may force unexpected profile data
+ // merge. We consider a profile as pre-existing if it has been actived
+ // previously. A pre-existed profile can still be used if it has been
+ // signed in with an email address matched RestrictSigninToPattern policy
+ // already.
+ LoginUIServiceFactory::GetForProfile(
+ Profile::FromWebUI(web_ui())->GetOriginalProfile())
+ ->SetProfileBlockingErrorMessage();
+ ProfilePickerForceSigninDialog::ShowDialogAndDisplayErrorMessage(
+ web_ui()->GetWebContents()->GetBrowserContext());
+ } else {
+ // Fresh sign in via profile picker without existing email address.
+ ProfilePickerForceSigninDialog::ShowForceSigninDialog(
+ web_ui()->GetWebContents()->GetBrowserContext(), *profile_path);
+ }
return;
}
@@ -275,8 +330,8 @@ void ProfilePickerHandler::HandleLaunchGuestProfile(
// TODO(crbug.com/1063856): Add check |IsGuestModeEnabled| once policy
// checking has been added to the UI.
profiles::SwitchToGuestProfile(
- base::Bind(&ProfilePickerHandler::OnSwitchToProfileComplete,
- weak_factory_.GetWeakPtr(), false, false));
+ base::BindRepeating(&ProfilePickerHandler::OnSwitchToProfileComplete,
+ weak_factory_.GetWeakPtr(), false, false));
}
void ProfilePickerHandler::HandleAskOnStartupChanged(
@@ -330,32 +385,35 @@ void ProfilePickerHandler::HandleGetProfileThemeInfo(
ResolveJavascriptCallback(callback_id, std::move(dict));
}
+void ProfilePickerHandler::HandleGetAvailableIcons(
+ const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(1U, args->GetSize());
+ const base::Value& callback_id = args->GetList()[0];
+ ResolveJavascriptCallback(callback_id,
+ *profiles::GetCustomProfileAvatarIconsAndLabels());
+}
+
void ProfilePickerHandler::HandleCreateProfile(const base::ListValue* args) {
- // profileName, profileColor, avatarUrl, isGeneric, createShortcut
- CHECK_EQ(5U, args->GetList().size());
+ CHECK_EQ(4U, args->GetList().size());
base::string16 profile_name =
base::UTF8ToUTF16(args->GetList()[0].GetString());
// profileColor is undefined for the default theme.
base::Optional<SkColor> profile_color;
if (args->GetList()[1].is_int())
profile_color = args->GetList()[1].GetInt();
- std::string avatar_url = args->GetList()[2].GetString();
- bool is_generic = args->GetList()[3].GetBool();
- bool create_shortcut = args->GetList()[4].GetBool();
- DCHECK(base::IsStringASCII(avatar_url));
+ size_t avatar_index = args->GetList()[2].GetInt();
+ bool create_shortcut = args->GetList()[3].GetBool();
base::TrimWhitespace(profile_name, base::TRIM_ALL, &profile_name);
CHECK(!profile_name.empty());
- if (is_generic) {
- avatar_url = profiles::GetDefaultAvatarIconUrl(
- profiles::GetPlaceholderAvatarIndex());
- }
#ifndef NDEBUG
- size_t icon_index;
- DCHECK(profiles::IsDefaultAvatarIconUrl(avatar_url, &icon_index));
+ DCHECK(profiles::IsDefaultAvatarIconIndex(avatar_index));
#endif
- ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_PROFILE_PICKER);
+ std::string avatar_url = profiles::GetDefaultAvatarIconUrl(avatar_index);
+ ProfileMetrics::LogProfileAddNewUser(
+ ProfileMetrics::ADD_NEW_PROFILE_PICKER_LOCAL);
ProfileManager::CreateMultiProfileAsync(
profile_name, avatar_url,
base::BindRepeating(&ProfilePickerHandler::OnProfileCreated,
@@ -392,8 +450,7 @@ void ProfilePickerHandler::OnProfileCreated(
}
}
- if (IsJavascriptAllowed())
- FireWebUIListener("create-profile-finished", base::Value());
+ FireWebUIListener("create-profile-finished", base::Value());
}
void ProfilePickerHandler::OnProfileCreationSuccess(
@@ -420,11 +477,16 @@ void ProfilePickerHandler::OnProfileCreationSuccess(
shortcut_manager->CreateProfileShortcut(profile->GetPath());
}
+ if (base::FeatureList::IsEnabled(features::kSignInProfileCreation)) {
+ // Skip the FRE for this profile if sign-in was offered as part of the flow.
+ profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
+ }
+
RecordNewProfileSpec(profile_color, create_shortcut);
// Launch profile and close the picker.
profiles::OpenBrowserWindowForProfile(
- base::Bind(&ProfilePickerHandler::OnSwitchToProfileComplete,
- weak_factory_.GetWeakPtr(), true, false),
+ base::BindRepeating(&ProfilePickerHandler::OnSwitchToProfileComplete,
+ weak_factory_.GetWeakPtr(), true, false),
false, // Don't create a window if one already exists.
true, // Create a first run window.
false, // There is no need to unblock all extensions because we only open
@@ -433,6 +495,34 @@ void ProfilePickerHandler::OnProfileCreationSuccess(
profile, Profile::CREATE_STATUS_INITIALIZED);
}
+void ProfilePickerHandler::HandleRecordSignInPromoImpression(
+ const base::ListValue* /*args*/) {
+ signin_metrics::RecordSigninImpressionUserActionForAccessPoint(
+ signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER);
+}
+
+void ProfilePickerHandler::HandleSetProfileName(const base::ListValue* args) {
+ CHECK_EQ(2U, args->GetSize());
+ const base::Value& profile_path_value = args->GetList()[0];
+ base::Optional<base::FilePath> profile_path =
+ util::ValueToFilePath(profile_path_value);
+
+ if (!profile_path) {
+ NOTREACHED();
+ return;
+ }
+ base::string16 profile_name =
+ base::UTF8ToUTF16(args->GetList()[1].GetString());
+ base::TrimWhitespace(profile_name, base::TRIM_ALL, &profile_name);
+ CHECK(!profile_name.empty());
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_path.value());
+ CHECK(entry);
+ entry->SetLocalProfileName(profile_name, /*is_default_name=*/false);
+}
+
void ProfilePickerHandler::HandleRemoveProfile(const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
const base::Value& profile_path_value = args->GetList()[0];
@@ -484,9 +574,6 @@ void ProfilePickerHandler::GatherProfileStatistics(Profile* profile) {
void ProfilePickerHandler::OnProfileStatisticsReceived(
base::FilePath profile_path,
profiles::ProfileCategoryStats result) {
- if (!IsJavascriptAllowed())
- return;
-
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetKey("profilePath", util::FilePathToValue(profile_path));
base::Value stats(base::Value::Type::DICTIONARY);
@@ -501,16 +588,23 @@ void ProfilePickerHandler::OnProfileStatisticsReceived(
void ProfilePickerHandler::HandleLoadSignInProfileCreationFlow(
const base::ListValue* args) {
- DCHECK(args->GetList()[0].is_int());
- SkColor profile_color = args->GetList()[0].GetInt();
+ CHECK_EQ(1U, args->GetSize());
+ SkColor profile_color;
+ if (args->GetList()[0].is_int()) {
+ profile_color = args->GetList()[0].GetInt();
+ } else {
+ // The profile color must provided in `args` unless the force signin is
+ // enabled.
+ DCHECK(signin_util::IsForceSigninEnabled());
+ profile_color = GenerateNewProfileColor().color;
+ }
ProfilePicker::SwitchToSignIn(
- profile_color, base::BindOnce(&ProfilePickerHandler::OnLoadSigninFailed,
+ profile_color, base::BindOnce(&ProfilePickerHandler::OnLoadSigninFinished,
weak_factory_.GetWeakPtr()));
}
-void ProfilePickerHandler::OnLoadSigninFailed() {
- if (IsJavascriptAllowed())
- FireWebUIListener("load-signin-failed", base::Value());
+void ProfilePickerHandler::OnLoadSigninFinished(bool success) {
+ FireWebUIListener("load-signin-finished", base::Value(success));
}
void ProfilePickerHandler::OnSwitchToProfileComplete(
@@ -521,13 +615,14 @@ void ProfilePickerHandler::OnSwitchToProfileComplete(
Browser* browser = chrome::FindAnyBrowser(profile, false);
DCHECK(browser);
DCHECK(browser->window());
- if (open_settings) {
- chrome::ShowSettingsSubPage(browser, chrome::kManageProfileSubPage);
- }
if (new_profile) {
RecordProfilePickerAction(ProfilePickerAction::kLaunchNewProfile);
- } else if (profile->IsGuestSession()) {
+ ProfilePicker::Hide();
+ return;
+ }
+
+ if (profile->IsGuestSession() || profile->IsEphemeralGuestProfile()) {
RecordProfilePickerAction(ProfilePickerAction::kLaunchGuestProfile);
} else {
RecordProfilePickerAction(
@@ -535,6 +630,16 @@ void ProfilePickerHandler::OnSwitchToProfileComplete(
? ProfilePickerAction::kLaunchExistingProfileCustomizeSettings
: ProfilePickerAction::kLaunchExistingProfile);
}
+
+ if (open_settings) {
+ // User clicked 'Edit' from the profile card menu.
+ chrome::ShowSettingsSubPage(browser, chrome::kManageProfileSubPage);
+ } else {
+ // Opens a target url upon user selecting a pre-existing profile. For
+ // new profiles the chrome welcome page is displayed.
+ OpenOnSelectProfileTargetUrl(browser);
+ }
+
ProfilePicker::Hide();
}
@@ -543,12 +648,50 @@ void ProfilePickerHandler::PushProfilesList() {
FireWebUIListener("profiles-list-changed", GetProfilesList());
}
-base::Value ProfilePickerHandler::GetProfilesList() {
- base::ListValue profiles_list;
- std::vector<ProfileAttributesEntry*> entries =
+void ProfilePickerHandler::SetProfilesOrder(
+ const std::vector<ProfileAttributesEntry*>& entries) {
+ profiles_order_.clear();
+ size_t index = 0;
+ for (const ProfileAttributesEntry* entry : entries) {
+ profiles_order_[entry->GetPath()] = index++;
+ }
+}
+
+std::vector<ProfileAttributesEntry*>
+ProfilePickerHandler::GetProfileAttributes() {
+ std::vector<ProfileAttributesEntry*> ordered_entries =
g_browser_process->profile_manager()
->GetProfileAttributesStorage()
- .GetAllProfilesAttributesSortedByName();
+ .GetAllProfilesAttributesSortedByLocalProfilName();
+ base::EraseIf(ordered_entries, [](const ProfileAttributesEntry* entry) {
+ return entry->IsGuest() || entry->IsOmitted();
+ });
+ size_t number_of_profiles = ordered_entries.size();
+
+ if (profiles_order_.size() != number_of_profiles) {
+ // Should only happen the first time the function is called.
+ // Profile creation and deletion are handled at
+ // 'OnProfileAdded', 'OnProfileWasRemoved'.
+ DCHECK(!profiles_order_.size());
+ SetProfilesOrder(ordered_entries);
+ return ordered_entries;
+ }
+
+ // Vector of nullptr entries.
+ std::vector<ProfileAttributesEntry*> entries(number_of_profiles);
+ for (ProfileAttributesEntry* entry : ordered_entries) {
+ DCHECK(profiles_order_.find(entry->GetPath()) != profiles_order_.end());
+ size_t index = profiles_order_[entry->GetPath()];
+ DCHECK_LT(index, number_of_profiles);
+ DCHECK(!entries[index]);
+ entries[index] = entry;
+ }
+ return entries;
+}
+
+base::Value ProfilePickerHandler::GetProfilesList() {
+ base::ListValue profiles_list;
+ std::vector<ProfileAttributesEntry*> entries = GetProfileAttributes();
const int avatar_icon_size =
kProfileCardAvatarSize * web_ui()->GetDeviceScaleFactor();
for (const ProfileAttributesEntry* entry : entries) {
@@ -559,12 +702,13 @@ base::Value ProfilePickerHandler::GetProfilesList() {
profile_entry->SetBoolPath(
"isSyncing", entry->GetSigninState() ==
SigninState::kSignedInWithConsentedPrimaryAccount);
- // GAIA name/user name can be empty, if the profile is not signed in to
+ profile_entry->SetBoolPath("needsSignin", entry->IsSigninRequired());
+ // GAIA full name/user name can be empty, if the profile is not signed in to
// chrome.
- profile_entry->SetString("gaiaName", entry->GetGAIANameToDisplay());
+ profile_entry->SetString("gaiaName", entry->GetGAIAName());
profile_entry->SetString("userName", entry->GetUserName());
- profile_entry->SetBoolPath("isManaged",
- IsManaged(entry->GetHostedDomain()));
+ profile_entry->SetBoolPath(
+ "isManaged", AccountInfo::IsManaged(entry->GetHostedDomain()));
gfx::Image icon =
profiles::GetSizedAvatarIcon(entry->GetAvatarIcon(avatar_icon_size),
true, avatar_icon_size, avatar_icon_size);
@@ -575,7 +719,37 @@ base::Value ProfilePickerHandler::GetProfilesList() {
return std::move(profiles_list);
}
+void ProfilePickerHandler::AddProfileToList(
+ const base::FilePath& profile_path) {
+ size_t number_of_profiles = profiles_order_.size();
+ profiles_order_[profile_path] = number_of_profiles;
+}
+
+bool ProfilePickerHandler::RemoveProfileFromList(
+ const base::FilePath& profile_path) {
+ auto remove_it = profiles_order_.find(profile_path);
+ // Guest and omitted profiles aren't added to the list.
+ if (remove_it == profiles_order_.end())
+ return false;
+
+ size_t index = remove_it->second;
+ profiles_order_.erase(remove_it);
+ for (auto& it : profiles_order_) {
+ if (it.second > index)
+ --it.second;
+ }
+ return true;
+}
+
void ProfilePickerHandler::OnProfileAdded(const base::FilePath& profile_path) {
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_path);
+ CHECK(entry);
+ if (entry->IsGuest() || entry->IsOmitted())
+ return;
+ AddProfileToList(profile_path);
PushProfilesList();
}
@@ -583,7 +757,26 @@ void ProfilePickerHandler::OnProfileWasRemoved(
const base::FilePath& profile_path,
const base::string16& profile_name) {
DCHECK(IsJavascriptAllowed());
- FireWebUIListener("profile-removed", util::FilePathToValue(profile_path));
+ if (RemoveProfileFromList(profile_path))
+ FireWebUIListener("profile-removed", util::FilePathToValue(profile_path));
+}
+
+void ProfilePickerHandler::OnProfileIsOmittedChanged(
+ const base::FilePath& profile_path) {
+ if (profile_path == ProfileManager::GetGuestProfilePath())
+ return;
+ ProfileAttributesEntry* entry =
+ g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_path);
+ CHECK(entry);
+ if (entry->IsOmitted()) {
+ if (RemoveProfileFromList(profile_path))
+ PushProfilesList();
+ } else {
+ AddProfileToList(profile_path);
+ PushProfilesList();
+ }
}
void ProfilePickerHandler::OnProfileAvatarChanged(
@@ -602,10 +795,19 @@ void ProfilePickerHandler::OnProfileNameChanged(
PushProfilesList();
}
+void ProfilePickerHandler::OnProfileHostedDomainChanged(
+ const base::FilePath& profile_path) {
+ PushProfilesList();
+}
+
void ProfilePickerHandler::DidFirstVisuallyNonEmptyPaint() {
DCHECK(!creation_time_on_startup_.is_null());
+ auto now = base::TimeTicks::Now();
base::UmaHistogramTimes("ProfilePicker.StartupTime.FirstPaint",
- base::TimeTicks::Now() - creation_time_on_startup_);
+ now - creation_time_on_startup_);
+ startup_metric_utils::RecordExternalStartupMetric(
+ "ProfilePicker.StartupTime.FirstPaint.FromApplicationStart", now,
+ /*set_non_browser_ui_displayed=*/true);
// Stop observing so that the histogram is only recorded once.
Observe(nullptr);
}
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 30e541606ad..666ed5368b5 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h
@@ -5,6 +5,9 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_PICKER_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_PICKER_HANDLER_H_
+#include <unordered_map>
+
+#include "base/gtest_prod_util.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/values.h"
@@ -32,6 +35,8 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
void OnJavascriptDisallowed() override;
private:
+ friend class ProfilePickerHandlerTest;
+
void HandleMainViewInitialize(const base::ListValue* args);
void HandleLaunchSelectedProfile(bool open_settings,
const base::ListValue* args);
@@ -39,14 +44,19 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
void HandleAskOnStartupChanged(const base::ListValue* args);
void HandleRemoveProfile(const base::ListValue* args);
void HandleGetProfileStatistics(const base::ListValue* args);
+ void HandleSetProfileName(const base::ListValue* args);
// TODO(crbug.com/1115056): Move to new handler for profile creation.
void HandleLoadSignInProfileCreationFlow(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 OnLoadSigninFailed();
+ // |args| is unused.
+ void HandleRecordSignInPromoImpression(const base::ListValue* args);
+
+ void OnLoadSigninFinished(bool success);
void GatherProfileStatistics(Profile* profile);
void OnProfileStatisticsReceived(base::FilePath profile_path,
profiles::ProfileCategoryStats result);
@@ -63,26 +73,46 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
Profile* profile);
void PushProfilesList();
base::Value GetProfilesList();
+ // Adds a profile with `profile_path` to `profiles_order_`.
+ void AddProfileToList(const base::FilePath& profile_path);
+ // Removes a profile with `profile_path` from `profiles_order_`. Returns
+ // true if the profile was found and removed. Otherwise, returns false.
+ bool RemoveProfileFromList(const base::FilePath& profile_path);
// ProfileAttributesStorage::Observer:
void OnProfileAdded(const base::FilePath& profile_path) override;
void OnProfileWasRemoved(const base::FilePath& profile_path,
const base::string16& profile_name) override;
+ void OnProfileIsOmittedChanged(const base::FilePath& profile_path) override;
void OnProfileAvatarChanged(const base::FilePath& profile_path) override;
void OnProfileHighResAvatarLoaded(
const base::FilePath& profile_path) override;
void OnProfileNameChanged(const base::FilePath& profile_path,
const base::string16& old_profile_name) override;
+ void OnProfileHostedDomainChanged(
+ const base::FilePath& profile_path) override;
// content::WebContentsObserver:
void DidFirstVisuallyNonEmptyPaint() override;
void OnVisibilityChanged(content::Visibility visibility) override;
+ // Sets 'profiles_order_' that is used to freeze the order of the profiles on
+ // the picker when it was first shown.
+ void SetProfilesOrder(const std::vector<ProfileAttributesEntry*>& entries);
+
+ // Returns the list of profiles in the same order as when the picker
+ // was first shown. Guest profile is not included here.
+ std::vector<ProfileAttributesEntry*> GetProfileAttributes();
+
// Creation time of the handler, to measure performance on startup. Only set
// when the picker is shown on startup.
base::TimeTicks creation_time_on_startup_;
bool main_view_initialized_ = false;
+ // The order of the profiles when the picker was first shown. This is used
+ // to freeze the order of profiles on the picker. Newly added profiles, will
+ // be added to the end of the list.
+ std::unordered_map<base::FilePath, size_t> profiles_order_;
base::WeakPtrFactory<ProfilePickerHandler> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ProfilePickerHandler);
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
new file mode 100644
index 00000000000..86ed0d24b64
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler_unittest.cc
@@ -0,0 +1,222 @@
+// 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.
+
+#include "chrome/browser/ui/webui/signin/profile_picker_handler.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/util/values/values_util.h"
+#include "chrome/browser/profiles/profile_attributes_entry.h"
+#include "chrome/test/base/testing_browser_process.h"
+#include "chrome/test/base/testing_profile_manager.h"
+#include "components/signin/public/identity_manager/account_info.h"
+#include "content/public/test/browser_task_environment.h"
+#include "content/public/test/test_web_ui.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+void VerifyProfileEntry(const base::Value& value,
+ ProfileAttributesEntry* entry) {
+ EXPECT_EQ(*value.FindKey("profilePath"),
+ util::FilePathToValue(entry->GetPath()));
+ EXPECT_EQ(*value.FindStringKey("localProfileName"),
+ base::UTF16ToUTF8(entry->GetLocalProfileName()));
+ EXPECT_EQ(value.FindBoolKey("isSyncing"),
+ entry->GetSigninState() ==
+ SigninState::kSignedInWithConsentedPrimaryAccount);
+ EXPECT_EQ(value.FindBoolKey("needsSignin"), entry->IsSigninRequired());
+ EXPECT_EQ(*value.FindStringKey("gaiaName"),
+ base::UTF16ToUTF8(entry->GetGAIANameToDisplay()));
+ EXPECT_EQ(*value.FindStringKey("userName"),
+ base::UTF16ToUTF8(entry->GetUserName()));
+ EXPECT_EQ(value.FindBoolKey("isManaged"),
+ AccountInfo::IsManaged(entry->GetHostedDomain()));
+}
+
+class ProfilePickerHandlerTest : public testing::Test {
+ public:
+ ProfilePickerHandlerTest()
+ : profile_manager_(TestingBrowserProcess::GetGlobal()) {}
+
+ void SetUp() override {
+ ASSERT_TRUE(profile_manager_.SetUp());
+ handler_.set_web_ui(&web_ui_);
+ }
+ void VerifyProfileListWasPushed(
+ const std::vector<ProfileAttributesEntry*>& ordered_profile_entries) {
+ ASSERT_TRUE(!web_ui()->call_data().empty());
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ ASSERT_EQ("cr.webUIListenerCallback", data.function_name());
+ ASSERT_EQ("profiles-list-changed", data.arg1()->GetString());
+ size_t size = data.arg2()->GetList().size();
+ ASSERT_EQ(size, ordered_profile_entries.size());
+ for (size_t i = 0; i < size; ++i) {
+ VerifyProfileEntry(data.arg2()->GetList()[i], ordered_profile_entries[i]);
+ }
+ }
+
+ void VerifyProfileWasRemoved(const base::FilePath& profile_path) {
+ ASSERT_TRUE(!web_ui()->call_data().empty());
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ ASSERT_EQ("cr.webUIListenerCallback", data.function_name());
+ ASSERT_EQ("profile-removed", data.arg1()->GetString());
+ ASSERT_EQ(*data.arg2(), util::FilePathToValue(profile_path));
+ }
+
+ void InitializeMainViewAndVerifyProfileList(
+ const std::vector<ProfileAttributesEntry*>& ordered_profile_entries) {
+ base::ListValue empty_args;
+ handler()->HandleMainViewInitialize(&empty_args);
+ VerifyProfileListWasPushed(ordered_profile_entries);
+ }
+
+ // Creates a new testing profile and returns its `ProfileAttributesEntry`.
+ ProfileAttributesEntry* CreateTestingProfile(
+ const std::string& profile_name) {
+ auto* profile = profile_manager()->CreateTestingProfile(profile_name);
+ ProfileAttributesEntry* entry =
+ profile_manager()
+ ->profile_attributes_storage()
+ ->GetProfileAttributesWithPath(profile->GetPath());
+ CHECK(entry);
+ return entry;
+ }
+
+ TestingProfileManager* profile_manager() { return &profile_manager_; }
+ content::TestWebUI* web_ui() { return &web_ui_; }
+ ProfilePickerHandler* handler() { return &handler_; }
+
+ private:
+ content::BrowserTaskEnvironment task_environment_;
+ TestingProfileManager profile_manager_;
+ content::TestWebUI web_ui_;
+ ProfilePickerHandler handler_;
+};
+
+TEST_F(ProfilePickerHandlerTest, OrderedAlphabeticallyOnInit) {
+ ProfileAttributesEntry* profile_a = CreateTestingProfile("A");
+ ProfileAttributesEntry* profile_d = CreateTestingProfile("D");
+ ProfileAttributesEntry* profile_c = CreateTestingProfile("C");
+ ProfileAttributesEntry* profile_b = CreateTestingProfile("B");
+
+ InitializeMainViewAndVerifyProfileList(
+ {profile_a, profile_b, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+}
+
+TEST_F(ProfilePickerHandlerTest, AddProfile) {
+ ProfileAttributesEntry* profile_a = CreateTestingProfile("A");
+ ProfileAttributesEntry* profile_c = CreateTestingProfile("C");
+ ProfileAttributesEntry* profile_d = CreateTestingProfile("D");
+
+ InitializeMainViewAndVerifyProfileList({profile_a, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+
+ // A new profile should be added to the end of the list.
+ ProfileAttributesEntry* profile_b = CreateTestingProfile("B");
+ VerifyProfileListWasPushed({profile_a, profile_c, profile_d, profile_b});
+ web_ui()->ClearTrackedCalls();
+}
+
+TEST_F(ProfilePickerHandlerTest, AddProfileToEmptyList) {
+ InitializeMainViewAndVerifyProfileList({});
+ web_ui()->ClearTrackedCalls();
+
+ ProfileAttributesEntry* profile = CreateTestingProfile("Profile");
+ VerifyProfileListWasPushed({profile});
+ web_ui()->ClearTrackedCalls();
+}
+
+TEST_F(ProfilePickerHandlerTest, RenameProfile) {
+ ProfileAttributesEntry* profile_a = CreateTestingProfile("A");
+ ProfileAttributesEntry* profile_b = CreateTestingProfile("B");
+ ProfileAttributesEntry* profile_c = CreateTestingProfile("C");
+ ProfileAttributesEntry* profile_d = CreateTestingProfile("D");
+
+ InitializeMainViewAndVerifyProfileList(
+ {profile_a, profile_b, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+
+ // The profile list doesn't get re-ordered after a rename.
+ profile_b->SetLocalProfileName(base::UTF8ToUTF16("X"), false);
+ VerifyProfileListWasPushed({profile_a, profile_b, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+}
+
+TEST_F(ProfilePickerHandlerTest, RemoveProfile) {
+ ProfileAttributesEntry* profile_a = CreateTestingProfile("A");
+ ProfileAttributesEntry* profile_b = CreateTestingProfile("B");
+ ProfileAttributesEntry* profile_c = CreateTestingProfile("C");
+ ProfileAttributesEntry* profile_d = CreateTestingProfile("D");
+
+ InitializeMainViewAndVerifyProfileList(
+ {profile_a, profile_b, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+
+ base::FilePath b_path = profile_b->GetPath();
+ profile_manager()->DeleteTestingProfile("B");
+ VerifyProfileWasRemoved(b_path);
+ web_ui()->ClearTrackedCalls();
+
+ // Verify that the next profile push is correct.
+ ProfileAttributesEntry* profile_e = CreateTestingProfile("E");
+ VerifyProfileListWasPushed({profile_a, profile_c, profile_d, profile_e});
+ web_ui()->ClearTrackedCalls();
+}
+
+TEST_F(ProfilePickerHandlerTest, RemoveOmittedProfile) {
+ ProfileAttributesEntry* profile_a = CreateTestingProfile("A");
+ ProfileAttributesEntry* profile_d = CreateTestingProfile("D");
+ ProfileAttributesEntry* profile_c = CreateTestingProfile("C");
+ ProfileAttributesEntry* profile_b = CreateTestingProfile("B");
+ profile_b->SetIsEphemeral(true);
+ profile_b->SetIsOmitted(true);
+
+ InitializeMainViewAndVerifyProfileList({profile_a, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+
+ profile_manager()->DeleteTestingProfile("B");
+ // No callbacks should be called.
+ ASSERT_TRUE(web_ui()->call_data().empty());
+ web_ui()->ClearTrackedCalls();
+
+ // Verify that the next profile push is correct.
+ ProfileAttributesEntry* profile_e = CreateTestingProfile("E");
+ VerifyProfileListWasPushed({profile_a, profile_c, profile_d, profile_e});
+ web_ui()->ClearTrackedCalls();
+}
+
+TEST_F(ProfilePickerHandlerTest, MarkProfileAsOmitted) {
+ ProfileAttributesEntry* profile_a = CreateTestingProfile("A");
+ ProfileAttributesEntry* profile_b = CreateTestingProfile("B");
+ ProfileAttributesEntry* profile_c = CreateTestingProfile("C");
+ ProfileAttributesEntry* profile_d = CreateTestingProfile("D");
+
+ InitializeMainViewAndVerifyProfileList(
+ {profile_a, profile_b, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+
+ profile_b->SetIsEphemeral(true);
+ profile_b->SetIsOmitted(true);
+ VerifyProfileListWasPushed({profile_a, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+
+ // Omitted profile is appended to the end of the profile list.
+ profile_b->SetIsOmitted(false);
+ VerifyProfileListWasPushed({profile_a, profile_c, profile_d, profile_b});
+ web_ui()->ClearTrackedCalls();
+}
+
+TEST_F(ProfilePickerHandlerTest, OmittedProfileOnInit) {
+ ProfileAttributesEntry* profile_a = CreateTestingProfile("A");
+ ProfileAttributesEntry* profile_b = CreateTestingProfile("B");
+ ProfileAttributesEntry* profile_c = CreateTestingProfile("C");
+ ProfileAttributesEntry* profile_d = CreateTestingProfile("D");
+ profile_b->SetIsEphemeral(true);
+ profile_b->SetIsOmitted(true);
+
+ InitializeMainViewAndVerifyProfileList({profile_a, profile_c, profile_d});
+ web_ui()->ClearTrackedCalls();
+
+ profile_b->SetIsOmitted(false);
+ VerifyProfileListWasPushed({profile_a, profile_c, profile_d, profile_b});
+ web_ui()->ClearTrackedCalls();
+}
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 385c15b6f8c..36a36bc4a05 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc
@@ -9,7 +9,9 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/policy/browser_signin_policy_handler.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
+#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/ui/profile_picker.h"
#include "chrome/browser/ui/ui_features.h"
@@ -71,22 +73,35 @@ bool IsBrowserSigninAllowed() {
policy::BrowserSigninMode::kDisabled;
}
+bool IsSignInProfileCreationFlowSupported() {
+ return AccountConsistencyModeManager::IsDiceSignInAllowed() &&
+ base::FeatureList::IsEnabled(features::kSignInProfileCreation);
+}
+
void AddStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"mainViewTitle", IDS_PROFILE_PICKER_MAIN_VIEW_TITLE},
{"mainViewSubtitle", IDS_PROFILE_PICKER_MAIN_VIEW_SUBTITLE},
{"addSpaceButton", IDS_PROFILE_PICKER_ADD_SPACE_BUTTON},
{"askOnStartupCheckboxText", IDS_PROFILE_PICKER_ASK_ON_STARTUP},
{"browseAsGuestButton", IDS_PROFILE_PICKER_BROWSE_AS_GUEST_BUTTON},
+ {"needsSigninPrompt",
+ IDS_PROFILE_PICKER_PROFILE_CARD_NEEDS_SIGNIN_PROMPT},
+ {"profileCardButtonLabel", IDS_PROFILE_PICKER_PROFILE_CARD_LABEL},
+ {"profileCardInputLabel", IDS_PROFILE_PICKER_PROFILE_CARD_INPUT_LABEL},
{"menu", IDS_MENU},
- {"profileMenuName", IDS_PROFILE_PICKER_PROFILE_MENU_BUTTON_NAME},
+ {"cancel", IDS_CANCEL},
+ {"profileMenuName", IDS_SETTINGS_MORE_ACTIONS},
{"profileMenuRemoveText", IDS_PROFILE_PICKER_PROFILE_MENU_REMOVE_TEXT},
{"profileMenuCustomizeText",
IDS_PROFILE_PICKER_PROFILE_MENU_CUSTOMIZE_TEXT},
{"removeWarningLocalProfile",
IDS_PROFILE_PICKER_REMOVE_WARNING_LOCAL_PROFILE},
+ {"removeWarningLocalProfileTitle",
+ IDS_PROFILE_PICKER_REMOVE_WARNING_LOCAL_PROFILE_TITLE},
{"removeWarningSignedInProfile",
IDS_PROFILE_PICKER_REMOVE_WARNING_SIGNED_IN_PROFILE},
+ {"removeWarningSignedInProfileTitle",
+ IDS_PROFILE_PICKER_REMOVE_WARNING_SIGNED_IN_PROFILE_TITLE},
{"removeWarningHistory", IDS_PROFILE_PICKER_REMOVE_WARNING_HISTORY},
{"removeWarningPasswords", IDS_PROFILE_PICKER_REMOVE_WARNING_PASSWORDS},
{"removeWarningBookmarks", IDS_PROFILE_PICKER_REMOVE_WARNING_BOOKMARKS},
@@ -104,6 +119,8 @@ void AddStrings(content::WebUIDataSource* html_source) {
IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_NOT_NOW_BUTTON_LABEL},
{"localProfileCreationTitle",
IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_TITLE},
+ {"localProfileCreationCustomizeAvatarLabel",
+ IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_CUSTOMIZE_AVATAR_BUTTON_LABEL},
{"localProfileCreationThemeText",
IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_THEME_TEXT},
{"createProfileNamePlaceholder",
@@ -112,6 +129,11 @@ void AddStrings(content::WebUIDataSource* html_source) {
IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_SHORTCUT_TEXT},
{"createProfileConfirm",
IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_DONE},
+ {"defaultAvatarLabel", IDS_DEFAULT_AVATAR_LABEL_26},
+ {"selectAnAvatarDialogTitle",
+ IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_AVATAR_TEXT},
+ {"selectAvatarDoneButtonLabel",
+ IDS_PROFILE_PICKER_PROFILE_CREATION_FLOW_LOCAL_PROFILE_CREATION_AVATAR_DONE},
// Color picker.
{"colorPickerLabel", IDS_NTP_CUSTOMIZE_COLOR_PICKER_LABEL},
@@ -119,24 +141,33 @@ void AddStrings(content::WebUIDataSource* html_source) {
{"thirdPartyThemeDescription", IDS_NTP_CUSTOMIZE_3PT_THEME_DESC},
{"uninstallThirdPartyThemeButton", IDS_NTP_CUSTOMIZE_3PT_THEME_UNINSTALL},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
+ html_source->AddLocalizedString("mainViewTitle",
+ ProfilePicker::Shown()
+ ? IDS_PROFILE_PICKER_MAIN_VIEW_TITLE_V2
+ : IDS_PROFILE_PICKER_MAIN_VIEW_TITLE);
+
ProfilePicker::AvailabilityOnStartup availability_on_startup =
static_cast<ProfilePicker::AvailabilityOnStartup>(
g_browser_process->local_state()->GetInteger(
prefs::kBrowserProfilePickerAvailabilityOnStartup));
- html_source->AddBoolean("disableAskOnStartup",
- availability_on_startup !=
- ProfilePicker::AvailabilityOnStartup::kEnabled);
+ bool disable_ask_on_startup =
+ availability_on_startup !=
+ ProfilePicker::AvailabilityOnStartup::kEnabled ||
+ !base::FeatureList::IsEnabled(kEnableProfilePickerOnStartupFeature);
+ html_source->AddBoolean("disableAskOnStartup", disable_ask_on_startup);
html_source->AddBoolean("askOnStartup",
g_browser_process->local_state()->GetBoolean(
prefs::kBrowserShowProfilePickerOnStartup));
- html_source->AddBoolean(
- "signInProfileCreationFlowSupported",
- base::FeatureList::IsEnabled(features::kProfilesUIRevamp));
+ html_source->AddBoolean("signInProfileCreationFlowSupported",
+ IsSignInProfileCreationFlowSupported());
html_source->AddString("minimumPickerSize",
base::StringPrintf("%ipx", kMinimumPickerSizePx));
+ html_source->AddInteger("placeholderAvatarIndex",
+ profiles::GetPlaceholderAvatarIndex());
+
// Add policies.
html_source->AddBoolean("isBrowserSigninAllowed", IsBrowserSigninAllowed());
html_source->AddBoolean("isForceSigninEnabled",
@@ -146,7 +177,6 @@ void AddStrings(content::WebUIDataSource* html_source) {
IsProfileCreationAllowed());
html_source->AddBoolean("profileShortcutsEnabled",
ProfileShortcutManager::IsFeatureEnabled());
- // TODO(crbug.com/1063856): Check if |BrowserSignin| device policy exists.
}
} // namespace
@@ -171,7 +201,7 @@ ProfilePickerUI::ProfilePickerUI(content::WebUI* web_ui)
AddStrings(html_source);
webui::SetupWebUIDataSource(
html_source,
- base::make_span(kProfilePickerResources, kProfilePickerResourcesSize), "",
+ base::make_span(kProfilePickerResources, kProfilePickerResourcesSize),
IDR_PROFILE_PICKER_PROFILE_PICKER_HTML);
content::WebUIDataSource::Add(profile, html_source);
}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
deleted file mode 100644
index 88988609d35..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
+++ /dev/null
@@ -1,290 +0,0 @@
-// Copyright 2016 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/signin/signin_create_profile_handler.h"
-
-#include <stddef.h>
-#include <string>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/files/file_path.h"
-#include "base/metrics/histogram_macros.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/task_runner_util.h"
-#include "base/threading/thread_restrictions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/profiles/profile_attributes_entry.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/profiles/profile_metrics.h"
-#include "chrome/browser/profiles/profiles_state.h"
-#include "chrome/browser/signin/signin_error_controller_factory.h"
-#include "chrome/browser/signin/signin_util.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/user_manager.h"
-#include "chrome/browser/ui/webui/profile_helper.h"
-#include "chrome/browser/ui/webui/signin/signin_utils.h"
-#include "chrome/common/buildflags.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 "components/prefs/pref_service.h"
-#include "components/strings/grit/components_strings.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/web_ui.h"
-#include "ui/base/l10n/l10n_util.h"
-
-SigninCreateProfileHandler::SigninCreateProfileHandler() = default;
-
-SigninCreateProfileHandler::~SigninCreateProfileHandler() {
- BrowserList::RemoveObserver(this);
-}
-
-void SigninCreateProfileHandler::GetLocalizedValues(
- base::DictionaryValue* localized_strings) {
- localized_strings->SetString(
- "createDesktopShortcutLabel",
- l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_DESKTOP_SHORTCUT_LABEL));
- localized_strings->SetString("createProfileConfirm",
- l10n_util::GetStringUTF16(IDS_ADD));
- localized_strings->SetString("learnMore",
- l10n_util::GetStringUTF16(IDS_LEARN_MORE));
- localized_strings->SetString(
- "createProfileTitle",
- l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_TITLE));
- localized_strings->SetString(
- "createProfileNamePlaceholder",
- l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_NAME_PLACEHOLDER));
- localized_strings->SetString(
- "exitAndChildlockLabel",
- l10n_util::GetStringUTF16(
- IDS_PROFILES_PROFILE_SIGNOUT_BUTTON));
-}
-
-void SigninCreateProfileHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "createProfile",
- base::BindRepeating(&SigninCreateProfileHandler::CreateProfile,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "requestDefaultProfileIcons",
- base::BindRepeating(
- &SigninCreateProfileHandler::RequestDefaultProfileIcons,
- base::Unretained(this)));
-}
-
-void SigninCreateProfileHandler::OnBrowserAdded(Browser* browser) {
- // Only respond to one OnBrowserAdded.
- BrowserList::RemoveObserver(this);
- UserManager::Hide();
-}
-
-void SigninCreateProfileHandler::OpenNewWindowForProfile(
- Profile* profile,
- Profile::CreateStatus status) {
- profiles::OpenBrowserWindowForProfile(
- base::Bind(&SigninCreateProfileHandler::OnBrowserReadyCallback,
- weak_ptr_factory_.GetWeakPtr()),
- false, // Don't create a window if one already exists.
- true, // Create a first run window.
- false, // There is no need to unblock all extensions because we only open
- // browser window if the Profile is not locked. Hence there is no
- // extension blocked.
- profile, status);
-}
-
-void SigninCreateProfileHandler::OpenForceSigninDialogForProfile(
- Profile* profile) {
- UserManagerProfileDialog::ShowForceSigninDialog(
- web_ui()->GetWebContents()->GetBrowserContext(), profile->GetPath());
-}
-
-void SigninCreateProfileHandler::DoCreateProfile(const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut) {
- ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_DIALOG);
-
- profile_path_being_created_ = ProfileManager::CreateMultiProfileAsync(
- name, icon_url,
- base::BindRepeating(&SigninCreateProfileHandler::OnProfileCreated,
- weak_ptr_factory_.GetWeakPtr(), create_shortcut));
-}
-
-void SigninCreateProfileHandler::RequestDefaultProfileIcons(
- const base::ListValue* args) {
- web_ui()->CallJavascriptFunctionUnsafe(
- "cr.webUIListenerCallback", base::Value("profile-icons-received"),
- *profiles::GetCustomProfileAvatarIconsAndLabels());
-}
-
-void SigninCreateProfileHandler::CreateProfile(const base::ListValue* args) {
- if (!profiles::IsMultipleProfilesEnabled())
- return;
-
- // We can have only one in progress profile creation
- // at any given moment, if new ones are initiated just
- // ignore them until we are done with the old one.
- if (profile_creation_type_ != NO_CREATION_IN_PROGRESS)
- return;
-
- profile_creation_type_ = NON_SUPERVISED_PROFILE_CREATION;
-
- DCHECK(profile_path_being_created_.empty());
- profile_creation_start_time_ = base::TimeTicks::Now();
-
- base::string16 name;
- std::string icon_url;
- bool create_shortcut = false;
- if (args->GetString(0, &name) && args->GetString(1, &icon_url)) {
- DCHECK(base::IsStringASCII(icon_url));
- base::TrimWhitespace(name, base::TRIM_ALL, &name);
- CHECK(!name.empty());
-#ifndef NDEBUG
- size_t icon_index;
- DCHECK(profiles::IsDefaultAvatarIconUrl(icon_url, &icon_index));
-#endif
- args->GetBoolean(2, &create_shortcut);
- }
- DoCreateProfile(name, icon_url, create_shortcut);
-}
-
-void SigninCreateProfileHandler::OnProfileCreated(
- bool create_shortcut,
- Profile* profile,
- Profile::CreateStatus status) {
- if (status != Profile::CREATE_STATUS_CREATED)
- RecordProfileCreationMetrics(status);
-
- switch (status) {
- case Profile::CREATE_STATUS_LOCAL_FAIL: {
- ShowProfileCreationError(profile, GetProfileCreationErrorMessageLocal());
- break;
- }
- case Profile::CREATE_STATUS_CREATED: {
- // Do nothing for an intermediate status.
- break;
- }
- case Profile::CREATE_STATUS_INITIALIZED: {
- HandleProfileCreationSuccess(create_shortcut, profile);
- break;
- }
- // User-initiated cancellation is handled in CancelProfileRegistration and
- // does not call this callback.
- case Profile::CREATE_STATUS_CANCELED:
- case Profile::CREATE_STATUS_REMOTE_FAIL:
- case Profile::MAX_CREATE_STATUS: {
- NOTREACHED();
- break;
- }
- }
-}
-
-void SigninCreateProfileHandler::HandleProfileCreationSuccess(
- bool create_shortcut,
- Profile* profile) {
- switch (profile_creation_type_) {
- case NON_SUPERVISED_PROFILE_CREATION: {
- CreateShortcutAndShowSuccess(create_shortcut, profile);
- break;
- }
- case NO_CREATION_IN_PROGRESS:
- NOTREACHED();
- break;
- }
-}
-
-void SigninCreateProfileHandler::CreateShortcutAndShowSuccess(
- bool create_shortcut,
- Profile* profile) {
- if (create_shortcut) {
- DCHECK(ProfileShortcutManager::IsFeatureEnabled());
- ProfileShortcutManager* shortcut_manager =
- g_browser_process->profile_manager()->profile_shortcut_manager();
- DCHECK(shortcut_manager);
- if (shortcut_manager)
- shortcut_manager->CreateProfileShortcut(profile->GetPath());
- }
-
- DCHECK_EQ(profile_path_being_created_.value(), profile->GetPath().value());
- profile_path_being_created_.clear();
- DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
-
- bool is_force_signin_enabled = signin_util::IsForceSigninEnabled();
- bool open_new_window = !is_force_signin_enabled;
-
- web_ui()->CallJavascriptFunctionUnsafe(
- "cr.webUIListenerCallback",
- GetWebUIListenerName(PROFILE_CREATION_SUCCESS));
-
- if (open_new_window) {
- // Opening the new window must be the last action, after all callbacks
- // have been run, to give them a chance to initialize the profile.
- OpenNewWindowForProfile(profile, Profile::CREATE_STATUS_INITIALIZED);
- } else if (is_force_signin_enabled) {
- OpenForceSigninDialogForProfile(profile);
- }
- profile_creation_type_ = NO_CREATION_IN_PROGRESS;
-}
-
-void SigninCreateProfileHandler::ShowProfileCreationError(
- Profile* profile,
- const base::string16& error) {
- DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
- web_ui()->CallJavascriptFunctionUnsafe(
- "cr.webUIListenerCallback", GetWebUIListenerName(PROFILE_CREATION_ERROR),
- base::Value(error));
- // The ProfileManager calls us back with a NULL profile in some cases.
- if (profile) {
- webui::DeleteProfileAtPath(profile->GetPath(),
- ProfileMetrics::DELETE_PROFILE_SETTINGS);
- }
- profile_creation_type_ = NO_CREATION_IN_PROGRESS;
- profile_path_being_created_.clear();
-}
-
-void SigninCreateProfileHandler::RecordProfileCreationMetrics(
- Profile::CreateStatus status) {
- UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult", status,
- Profile::MAX_CREATE_STATUS);
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "Profile.CreateTimeNoTimeout",
- base::TimeTicks::Now() - profile_creation_start_time_);
-}
-
-base::string16 SigninCreateProfileHandler::GetProfileCreationErrorMessageLocal()
- const {
- return l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_LOCAL_ERROR);
-}
-
-void SigninCreateProfileHandler::OnBrowserReadyCallback(
- Profile* profile,
- Profile::CreateStatus profile_create_status) {
- Browser* browser = chrome::FindAnyBrowser(profile, false);
- // Closing the User Manager before the window is created can flakily cause
- // Chrome to close.
- if (browser && browser->window())
- UserManager::Hide();
- else
- BrowserList::AddObserver(this);
-}
-
-base::Value SigninCreateProfileHandler::GetWebUIListenerName(
- ProfileCreationStatus status) const {
- switch (status) {
- case PROFILE_CREATION_SUCCESS:
- return base::Value("create-profile-success");
- case PROFILE_CREATION_ERROR:
- return base::Value("create-profile-error");
- }
- NOTREACHED();
- return base::Value(std::string());
-}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h
deleted file mode 100644
index 020f91adad3..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2016 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_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_
-
-#include <string>
-
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/time/time.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_window.h"
-#include "chrome/browser/ui/browser_list_observer.h"
-#include "chrome/common/buildflags.h"
-#include "content/public/browser/web_ui_message_handler.h"
-#include "google_apis/gaia/google_service_auth_error.h"
-
-namespace base {
-class DictionaryValue;
-class ListValue;
-}
-
-// Handler for the 'create profile' page.
-class SigninCreateProfileHandler : public content::WebUIMessageHandler,
- public BrowserListObserver {
- public:
- SigninCreateProfileHandler();
- ~SigninCreateProfileHandler() override;
-
- void GetLocalizedValues(base::DictionaryValue* localized_strings);
-
- // WebUIMessageHandler:
- void RegisterMessages() override;
-
- // BrowserListObserver:
- void OnBrowserAdded(Browser* browser) override;
-
- protected:
- // These methods are virtual for testing.
- // Opens a new window for |profile|.
- virtual void OpenNewWindowForProfile(Profile* profile,
- Profile::CreateStatus status);
-
- // Opens a new signin dialog for |profile|.
- virtual void OpenForceSigninDialogForProfile(Profile* profile);
-
- // Asynchronously creates and initializes a new profile.
- virtual void DoCreateProfile(const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut);
-
- private:
- friend class TestSigninCreateProfileHandler;
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- ReturnDefaultProfileIcons);
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- ReturnSignedInProfiles);
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- CreateProfile);
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- CreateProfileWithForceSignin);
- // Represents the final profile creation status. It is used to map
- // the status to the javascript method to be called.
- enum ProfileCreationStatus {
- PROFILE_CREATION_SUCCESS,
- PROFILE_CREATION_ERROR,
- };
-
- // Represents the type of the in progress profile creation operation.
- // It is used to map the type of the profile creation operation to the
- // correct UMA metric name.
- enum ProfileCreationOperationType {
- NON_SUPERVISED_PROFILE_CREATION,
- NO_CREATION_IN_PROGRESS
- };
-
- // Callback for the "requestDefaultProfileIcons" message.
- // Sends the array of default profile icon URLs to WebUI.
- void RequestDefaultProfileIcons(const base::ListValue* args);
-
- // Asynchronously creates and initializes a new profile.
- // The arguments are as follows:
- // 0: name (string)
- // 1: icon (string)
- // 2: a flag stating whether we should create a profile desktop shortcut
- // (optional, boolean)
- void CreateProfile(const base::ListValue* args);
-
- // If a local error occurs during profile creation, then show an appropriate
- // error message. Otherwise, update the UI as the final task after a new
- // profile has been created.
- void OnProfileCreated(bool create_shortcut,
- Profile* profile,
- Profile::CreateStatus status);
-
- void HandleProfileCreationSuccess(bool create_shortcut,
- Profile* profile);
-
- // Creates desktop shortcut and updates the UI to indicate success
- // when creating a profile.
- void CreateShortcutAndShowSuccess(bool create_shortcut,
- Profile* profile);
-
- // This callback is run after a new browser (but not the window) has been
- // created for the new profile.
- void OnBrowserReadyCallback(Profile* profile, Profile::CreateStatus status);
-
- // Updates the UI to show an error when creating a profile.
- void ShowProfileCreationError(Profile* profile, const base::string16& error);
-
- // Records UMA histograms relevant to profile creation.
- void RecordProfileCreationMetrics(Profile::CreateStatus status);
-
- base::string16 GetProfileCreationErrorMessageLocal() const;
-
- base::Value GetWebUIListenerName(ProfileCreationStatus status) const;
-
- // Used to allow canceling a profile creation (particularly a supervised-user
- // registration) in progress. Set when profile creation is begun, and
- // cleared when all the callbacks have been run and creation is complete.
- base::FilePath profile_path_being_created_;
-
- // Used to track how long profile creation takes.
- base::TimeTicks profile_creation_start_time_;
-
- // Indicates the type of the in progress profile creation operation.
- // The value is only relevant while we are creating/importing a profile.
- ProfileCreationOperationType profile_creation_type_ = NO_CREATION_IN_PROGRESS;
-
- base::WeakPtrFactory<SigninCreateProfileHandler> weak_ptr_factory_{this};
-
- DISALLOW_COPY_AND_ASSIGN(SigninCreateProfileHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_CREATE_PROFILE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc
deleted file mode 100644
index 4a165763d8a..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc
+++ /dev/null
@@ -1,205 +0,0 @@
-// Copyright 2016 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/signin/signin_create_profile_handler.h"
-
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/prefs/browser_prefs.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_attributes_entry.h"
-#include "chrome/browser/profiles/profile_attributes_storage.h"
-#include "chrome/browser/profiles/profile_avatar_icon_util.h"
-#include "chrome/browser/signin/signin_error_controller_factory.h"
-#include "chrome/browser/signin/signin_util.h"
-#include "chrome/browser/ui/webui/signin/signin_utils.h"
-#include "chrome/common/buildflags.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/grit/generated_resources.h"
-#include "chrome/test/base/browser_with_test_window_test.h"
-#include "chrome/test/base/testing_browser_process.h"
-#include "chrome/test/base/testing_profile_manager.h"
-#include "components/sync/model/sync_data.h"
-#include "components/sync/protocol/sync.pb.h"
-#include "components/sync/test/model/fake_sync_change_processor.h"
-#include "components/sync/test/model/sync_error_factory_mock.h"
-#include "components/sync_preferences/testing_pref_service_syncable.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/base/l10n/l10n_util.h"
-
-// Gmock matchers and actions.
-using testing::_;
-using testing::Invoke;
-
-namespace {
-
-const char kTestProfileName[] = "test-profile-name";
-
-const char kTestWebUIResponse[] = "cr.webUIListenerCallback";
-
-} // namespace
-
-class TestSigninCreateProfileHandler : public SigninCreateProfileHandler {
- public:
- explicit TestSigninCreateProfileHandler(
- content::WebUI* web_ui,
- TestingProfileManager* profile_manager)
- : profile_manager_(profile_manager) {
- set_web_ui(web_ui);
- }
-
- // Mock this method since it tries to create a profile asynchronously and the
- // test terminates before the callback gets called.
- MOCK_METHOD3(DoCreateProfile,
- void(const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut));
-
- // Creates the profile synchronously, sets the appropriate flag and calls the
- // callback method to resume profile creation flow.
- void RealDoCreateProfile(const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut) {
- // Create the profile synchronously.
- Profile* profile = profile_manager_->CreateTestingProfile(
- kTestProfileName,
- std::unique_ptr<sync_preferences::TestingPrefServiceSyncable>(), name,
- 0, std::string(), TestingProfile::TestingFactories());
-
- // Set the flag used to track the state of the creation flow.
- profile_path_being_created_ = profile->GetPath();
-
- // Call the callback method to resume profile creation flow.
- SigninCreateProfileHandler::OnProfileCreated(
- create_shortcut,
- profile,
- Profile::CREATE_STATUS_INITIALIZED);
- }
-
- // Mock this method to track when an attempt to open a new browser window for
- // the newly created profile is made.
- MOCK_METHOD2(OpenNewWindowForProfile,
- void(Profile* profile, Profile::CreateStatus status));
-
- // Mock this method so that we don't actually open the signin dialog during
- // the test.
- MOCK_METHOD1(OpenForceSigninDialogForProfile, void(Profile* profile));
-
- private:
- TestingProfileManager* profile_manager_;
- DISALLOW_COPY_AND_ASSIGN(TestSigninCreateProfileHandler);
-};
-
-class SigninCreateProfileHandlerTest : public BrowserWithTestWindowTest {
- public:
- SigninCreateProfileHandlerTest()
- : web_ui_(new content::TestWebUI) {}
-
- void SetUp() override {
- BrowserWithTestWindowTest::SetUp();
- profile_manager()->DeleteAllTestingProfiles();
-
- handler_ = std::make_unique<TestSigninCreateProfileHandler>(
- web_ui(), profile_manager());
- }
-
- void TearDown() override {
- handler_.reset();
- BrowserWithTestWindowTest::TearDown();
- }
-
- content::TestWebUI* web_ui() {
- return web_ui_.get();
- }
-
- TestSigninCreateProfileHandler* handler() {
- return handler_.get();
- }
-
- private:
- std::unique_ptr<content::TestWebUI> web_ui_;
- std::unique_ptr<TestSigninCreateProfileHandler> handler_;
-};
-
-TEST_F(SigninCreateProfileHandlerTest, ReturnDefaultProfileIcons) {
- // Request default profile information.
- base::ListValue list_args;
- handler()->RequestDefaultProfileIcons(&list_args);
-
- // Expect one JS callbacks for the profile avatar icons.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("profile-icons-received", callback_name);
-
- const base::ListValue* profile_icons;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsList(&profile_icons));
- EXPECT_NE(0U, profile_icons->GetSize());
-}
-
-TEST_F(SigninCreateProfileHandlerTest, CreateProfile) {
- // Expect the call to create the profile.
- EXPECT_CALL(*handler(), DoCreateProfile(_, _, _))
- .WillOnce(Invoke(handler(),
- &TestSigninCreateProfileHandler::RealDoCreateProfile));
-
- // Expect a new browser window for the new profile to be opened.
- EXPECT_CALL(*handler(), OpenNewWindowForProfile(_, _));
-
- // Expect no signin dialog opened for the new profile.
- EXPECT_CALL(*handler(), OpenForceSigninDialogForProfile(_)).Times(0);
-
- // Create a profile.
- base::ListValue list_args;
- list_args.AppendString(kTestProfileName);
- list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
- list_args.AppendBoolean(false); // create_shortcut
- handler()->CreateProfile(&list_args);
-
- // Expect a JS callbacks with the new profile information.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("create-profile-success", callback_name);
-}
-
-TEST_F(SigninCreateProfileHandlerTest, CreateProfileWithForceSignin) {
- signin_util::SetForceSigninForTesting(true);
- ASSERT_TRUE(signin_util::IsForceSigninEnabled());
-
- // Expect the call to create the profile.
- EXPECT_CALL(*handler(), DoCreateProfile(_, _, _))
- .WillOnce(Invoke(handler(),
- &TestSigninCreateProfileHandler::RealDoCreateProfile));
-
- // Expect no new browser window for the new profile.
- EXPECT_CALL(*handler(), OpenNewWindowForProfile(_, _)).Times(0);
-
- // Expect a signin dialog opened for the new profile.
- EXPECT_CALL(*handler(), OpenForceSigninDialogForProfile(_)).Times(1);
-
- base::ListValue list_args;
- list_args.AppendString(kTestProfileName);
- list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
- list_args.AppendBoolean(false); // create_shortcut
- handler()->CreateProfile(&list_args);
-
- // Expect a JS callbacks with the new profile information.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("create-profile-success", callback_name);
-
- signin_util::SetForceSigninForTesting(false);
-}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_email_confirmation_ui.cc b/chromium/chrome/browser/ui/webui/signin/signin_email_confirmation_ui.cc
index 4d2d43c7508..d16230faf80 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_email_confirmation_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_email_confirmation_ui.cc
@@ -14,6 +14,7 @@
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "ui/base/webui/resource_path.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
@@ -27,9 +28,14 @@ SigninEmailConfirmationUI::SigninEmailConfirmationUI(content::WebUI* web_ui)
source->UseStringsJs();
source->EnableReplaceI18nInJS();
source->SetDefaultResource(IDR_SIGNIN_EMAIL_CONFIRMATION_HTML);
- source->AddResourcePath("signin_email_confirmation_app.js",
- IDR_SIGNIN_EMAIL_CONFIRMATION_APP_JS);
- source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS);
+
+ static constexpr webui::ResourcePath kResources[] = {
+ {"signin_email_confirmation_app.js",
+ IDR_SIGNIN_EMAIL_CONFIRMATION_APP_JS},
+ {"signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS},
+ {"signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS},
+ };
+ source->AddResourcePaths(kResources);
static constexpr webui::LocalizedString kStrings[] = {
{"signinEmailConfirmationTitle", IDS_SIGNIN_EMAIL_CONFIRMATION_TITLE},
@@ -46,7 +52,7 @@ SigninEmailConfirmationUI::SigninEmailConfirmationUI(content::WebUI* web_ui)
{"signinEmailConfirmationCloseLabel",
IDS_SIGNIN_EMAIL_CONFIRMATION_CLOSE_BUTTON_LABEL},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
base::DictionaryValue strings;
webui::SetLoadTimeDataDefaults(g_browser_process->GetApplicationLocale(),
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_error_handler.cc b/chromium/chrome/browser/ui/webui/signin/signin_error_handler.cc
index 3c206e17792..e21d1ce282e 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_error_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_error_handler.cc
@@ -10,7 +10,7 @@
#include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/user_manager.h"
+#include "chrome/browser/ui/profile_picker.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "content/public/browser/web_ui.h"
#include "url/gurl.h"
@@ -18,7 +18,7 @@
SigninErrorHandler::SigninErrorHandler(Browser* browser, bool is_system_profile)
: browser_(browser), is_system_profile_(is_system_profile) {
// |browser_| must not be null when this dialog is presented from the
- // user manager.
+ // profile picker.
DCHECK(browser_ || is_system_profile_);
BrowserList::AddObserver(this);
}
@@ -93,7 +93,7 @@ void SigninErrorHandler::HandleInitializedWithSize(
void SigninErrorHandler::CloseDialog() {
if (is_system_profile_) {
- CloseUserManagerProfileDialog();
+ CloseProfilePickerForceSigninDialog();
} else if (browser_){
CloseBrowserModalSigninDialog();
}
@@ -103,6 +103,6 @@ void SigninErrorHandler::CloseBrowserModalSigninDialog() {
browser_->signin_view_controller()->CloseModalSignin();
}
-void SigninErrorHandler::CloseUserManagerProfileDialog() {
- UserManagerProfileDialog::HideDialog();
+void SigninErrorHandler::CloseProfilePickerForceSigninDialog() {
+ ProfilePickerForceSigninDialog::HideDialog();
}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_error_handler.h b/chromium/chrome/browser/ui/webui/signin/signin_error_handler.h
index b168eb13b77..6e0b6ab1fde 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_error_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/signin_error_handler.h
@@ -68,13 +68,13 @@ class SigninErrorHandler : public content::WebUIMessageHandler,
// Closes the modal sign-in view dialog.
//
- // Virtual, so that it can be overriden from unit tests.
+ // Virtual, so that it can be overridden from unit tests.
virtual void CloseBrowserModalSigninDialog();
- // Closes the user manager profile dialog.
+ // Closes the profile picker profile dialog.
//
- // Virtual, so that it can be overriden from unit tests.
- virtual void CloseUserManagerProfileDialog();
+ // Virtual, so that it can be overridden from unit tests.
+ virtual void CloseProfilePickerForceSigninDialog();
private:
// Weak reference to the browser that showed the sign-in error dialog.
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc
index 362f08bf1fa..e7ec53c6071 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc
@@ -27,7 +27,7 @@ class TestingSigninErrorHandler : public SigninErrorHandler {
content::WebUI* web_ui)
: SigninErrorHandler(browser, is_system_profile),
browser_modal_dialog_did_close_(false),
- user_manager_profile_dialog_did_close_(false) {
+ profile_picker_force_signin_dialog_did_close_(false) {
set_web_ui(web_ui);
}
@@ -36,9 +36,9 @@ class TestingSigninErrorHandler : public SigninErrorHandler {
SigninErrorHandler::CloseBrowserModalSigninDialog();
}
- void CloseUserManagerProfileDialog() override {
- user_manager_profile_dialog_did_close_ = true;
- SigninErrorHandler::CloseUserManagerProfileDialog();
+ void CloseProfilePickerForceSigninDialog() override {
+ profile_picker_force_signin_dialog_did_close_ = true;
+ SigninErrorHandler::CloseProfilePickerForceSigninDialog();
}
using SigninErrorHandler::HandleSwitchToExistingProfile;
@@ -50,13 +50,13 @@ class TestingSigninErrorHandler : public SigninErrorHandler {
return browser_modal_dialog_did_close_;
}
- bool user_manager_profile_dialog_did_close() {
- return user_manager_profile_dialog_did_close_;
+ bool profile_picker_force_signin_dialog_did_close() {
+ return profile_picker_force_signin_dialog_did_close_;
}
private:
bool browser_modal_dialog_did_close_;
- bool user_manager_profile_dialog_did_close_;
+ bool profile_picker_force_signin_dialog_did_close_;
DISALLOW_COPY_AND_ASSIGN(TestingSigninErrorHandler);
};
@@ -89,7 +89,7 @@ class SigninErrorHandlerTest : public BrowserWithTestWindowTest {
web_ui()->AddMessageHandler(std::move(handler));
}
- void CreateHandlerInUserManager() {
+ void CreateHandlerInProfilePicker() {
DCHECK(!handler_);
auto handler = std::make_unique<TestingSigninErrorHandler>(
nullptr /* browser */, true /* is_system_profile */, web_ui());
@@ -168,13 +168,13 @@ TEST_F(SigninErrorHandlerTest, InBrowserTestConfirm) {
EXPECT_TRUE(handler()->browser_modal_dialog_did_close());
}
-TEST_F(SigninErrorHandlerTest, InUserManagerTestConfirm) {
- CreateHandlerInUserManager();
+TEST_F(SigninErrorHandlerTest, InProfilePickerTestConfirm) {
+ CreateHandlerInProfilePicker();
base::ListValue args;
handler()->HandleConfirm(&args);
// Confirm simply closes the dialog.
- EXPECT_TRUE(handler()->user_manager_profile_dialog_did_close());
+ EXPECT_TRUE(handler()->profile_picker_force_signin_dialog_did_close());
}
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_error_ui.cc b/chromium/chrome/browser/ui/webui/signin/signin_error_ui.cc
index 3c7c629f5e2..5b8de88ee0e 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_error_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_error_ui.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/user_manager.h"
+#include "chrome/browser/ui/profile_picker.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/signin/signin_error_handler.h"
@@ -28,6 +28,7 @@
#include "content/public/browser/web_ui_data_source.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/webui/resource_path.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/text_elider.h"
@@ -35,7 +36,7 @@ SigninErrorUI::SigninErrorUI(content::WebUI* web_ui)
: SigninWebDialogUI(web_ui) {
Profile* webui_profile = Profile::FromWebUI(web_ui);
if (webui_profile->IsSystemProfile()) {
- InitializeMessageHandlerForUserManager();
+ InitializeMessageHandlerForProfilePicker();
}
}
@@ -44,7 +45,7 @@ void SigninErrorUI::InitializeMessageHandlerWithBrowser(Browser* browser) {
Initialize(browser, false /* is_system_profile */);
}
-void SigninErrorUI::InitializeMessageHandlerForUserManager() {
+void SigninErrorUI::InitializeMessageHandlerForProfilePicker() {
Initialize(nullptr, true /* is_system_profile */);
}
@@ -56,7 +57,7 @@ void SigninErrorUI::Initialize(Browser* browser, bool is_system_profile) {
if (is_system_profile) {
signin_profile = g_browser_process->profile_manager()->GetProfileByPath(
- UserManager::GetSigninProfilePath());
+ ProfilePicker::GetForceSigninProfilePath());
// Sign in is completed before profile creation.
if (!signin_profile)
signin_profile = webui_profile->GetOriginalProfile();
@@ -70,9 +71,13 @@ void SigninErrorUI::Initialize(Browser* browser, bool is_system_profile) {
source->UseStringsJs();
source->EnableReplaceI18nInJS();
source->SetDefaultResource(IDR_SIGNIN_ERROR_HTML);
- source->AddResourcePath("signin_error_app.js", IDR_SIGNIN_ERROR_APP_JS);
- source->AddResourcePath("signin_error.js", IDR_SIGNIN_ERROR_JS);
- source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS);
+ static constexpr webui::ResourcePath kResources[] = {
+ {"signin_error_app.js", IDR_SIGNIN_ERROR_APP_JS},
+ {"signin_error.js", IDR_SIGNIN_ERROR_JS},
+ {"signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS},
+ {"signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS},
+ };
+ source->AddResourcePaths(kResources);
source->AddBoolean("isSystemProfile", is_system_profile);
// Retrieve the last signin error message and email used.
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_error_ui.h b/chromium/chrome/browser/ui/webui/signin/signin_error_ui.h
index ce7985c6b43..3d0760f7bbc 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_error_ui.h
+++ b/chromium/chrome/browser/ui/webui/signin/signin_error_ui.h
@@ -23,7 +23,7 @@ class SigninErrorUI : public SigninWebDialogUI {
void InitializeMessageHandlerWithBrowser(Browser* browser) override;
private:
- void InitializeMessageHandlerForUserManager();
+ void InitializeMessageHandlerForProfilePicker();
void Initialize(Browser* browser, bool is_system_profile);
DISALLOW_COPY_AND_ASSIGN(SigninErrorUI);
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc
new file mode 100644
index 00000000000..0e2a7bdf447
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.cc
@@ -0,0 +1,101 @@
+// 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.
+
+#include "chrome/browser/ui/webui/signin/signin_helper_chromeos.h"
+
+#include "ash/components/account_manager/account_manager.h"
+#include "ash/components/account_manager/account_manager_ash.h"
+#include "components/account_manager_core/account.h"
+#include "google_apis/gaia/gaia_auth_fetcher.h"
+
+namespace chromeos {
+
+SigninHelper::SigninHelper(
+ ash::AccountManager* account_manager,
+ crosapi::AccountManagerAsh* account_manager_ash,
+ const base::RepeatingClosure& close_dialog_closure,
+ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
+ const std::string& gaia_id,
+ const std::string& email,
+ const std::string& auth_code,
+ const std::string& signin_scoped_device_id)
+ : account_manager_(account_manager),
+ account_manager_ash_(account_manager_ash),
+ close_dialog_closure_(close_dialog_closure),
+ email_(email),
+ url_loader_factory_(std::move(url_loader_factory)),
+ gaia_auth_fetcher_(this, gaia::GaiaSource::kChrome, url_loader_factory_) {
+ account_key_ =
+ account_manager::AccountKey{gaia_id, account_manager::AccountType::kGaia};
+
+ DCHECK(!signin_scoped_device_id.empty());
+ gaia_auth_fetcher_.StartAuthCodeForOAuth2TokenExchangeWithDeviceId(
+ auth_code, signin_scoped_device_id);
+}
+
+SigninHelper::~SigninHelper() = default;
+
+void SigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) {
+ // Flow of control after this call:
+ // |AccountManager::UpsertAccount| updates / inserts the account and calls
+ // its |Observer|s, one of which is
+ // |ProfileOAuth2TokenServiceDelegateChromeOS|.
+ // |ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted| seeds the
+ // Gaia id and email id for this account in |AccountTrackerService| and
+ // invokes |FireRefreshTokenAvailable|. This causes the account to propagate
+ // throughout the Identity Service chain, including in
+ // |AccountFetcherService|. |AccountFetcherService::OnRefreshTokenAvailable|
+ // invokes |AccountTrackerService::StartTrackingAccount|, triggers a fetch
+ // for the account information from Gaia and updates this information into
+ // |AccountTrackerService|. At this point the account will be fully added to
+ // the system.
+ UpsertAccount(result.refresh_token);
+
+ CloseDialogAndExit();
+}
+
+void SigninHelper::OnClientOAuthFailure(const GoogleServiceAuthError& error) {
+ // TODO(sinhak): Display an error.
+
+ // Notify `AccountManagerAsh` about account addition failure and send `error`.
+ account_manager_ash_->OnAccountAdditionFinished(
+ account_manager::AccountAdditionResult(
+ account_manager::AccountAdditionResult::Status::kNetworkError,
+ error));
+ CloseDialogAndExit();
+}
+
+void SigninHelper::UpsertAccount(const std::string& refresh_token) {
+ account_manager_->UpsertAccount(account_key_, email_, refresh_token);
+
+ // Notify `AccountManagerAsh` about successful account addition and send
+ // the account.
+ account_manager_ash_->OnAccountAdditionFinished(
+ account_manager::AccountAdditionResult(
+ account_manager::AccountAdditionResult::Status::kSuccess,
+ account_manager::Account{account_key_, email_}));
+}
+
+void SigninHelper::CloseDialogAndExit() {
+ close_dialog_closure_.Run();
+ Exit();
+}
+
+void SigninHelper::Exit() {
+ base::SequencedTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
+}
+
+ash::AccountManager* SigninHelper::GetAccountManager() {
+ return account_manager_;
+}
+
+std::string SigninHelper::GetEmail() {
+ return email_;
+}
+
+scoped_refptr<network::SharedURLLoaderFactory>
+SigninHelper::GetUrlLoaderFactory() {
+ return url_loader_factory_;
+}
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h
new file mode 100644
index 00000000000..25d07b07e36
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/signin_helper_chromeos.h
@@ -0,0 +1,81 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_HELPER_CHROMEOS_H_
+#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_HELPER_CHROMEOS_H_
+
+#include "ash/components/account_manager/account_manager.h"
+#include "ash/components/account_manager/account_manager_ash.h"
+#include "components/account_manager_core/account.h"
+#include "google_apis/gaia/gaia_auth_consumer.h"
+#include "google_apis/gaia/gaia_auth_fetcher.h"
+#include "services/network/public/cpp/shared_url_loader_factory.h"
+
+namespace ash {
+class AccountManager;
+}
+
+namespace chromeos {
+
+// A helper class for completing the inline login flow. Primarily, it is
+// responsible for exchanging the auth code, obtained after a successful user
+// sign in, for OAuth tokens and subsequently populating Chrome OS
+// AccountManager with these tokens.
+// This object is supposed to be used in a one-shot fashion and it deletes
+// itself after its work is complete.
+class SigninHelper : public GaiaAuthConsumer {
+ public:
+ SigninHelper(
+ ash::AccountManager* account_manager,
+ crosapi::AccountManagerAsh* account_manager_ash,
+ const base::RepeatingClosure& close_dialog_closure,
+ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
+ const std::string& gaia_id,
+ const std::string& email,
+ const std::string& auth_code,
+ const std::string& signin_scoped_device_id);
+
+ SigninHelper(const SigninHelper&) = delete;
+ SigninHelper& operator=(const SigninHelper&) = delete;
+ ~SigninHelper() override;
+
+ protected:
+ // GaiaAuthConsumer overrides.
+ void OnClientOAuthSuccess(const ClientOAuthResult& result) override;
+ void OnClientOAuthFailure(const GoogleServiceAuthError& error) override;
+
+ void UpsertAccount(const std::string& refresh_token);
+
+ // Closes the inline login dialog and calls `Exit`.
+ void CloseDialogAndExit();
+
+ // Deletes this object.
+ void Exit();
+
+ ash::AccountManager* GetAccountManager();
+
+ // Returns email address of the account being added.
+ std::string GetEmail();
+
+ scoped_refptr<network::SharedURLLoaderFactory> GetUrlLoaderFactory();
+
+ private:
+ // A non-owning pointer to Chrome OS AccountManager.
+ ash::AccountManager* const account_manager_;
+ // A non-owning pointer to AccountManagerAsh.
+ crosapi::AccountManagerAsh* const account_manager_ash_;
+ // A closure to close the hosting dialog window.
+ base::RepeatingClosure close_dialog_closure_;
+ // The user's AccountKey for which |this| object has been created.
+ account_manager::AccountKey account_key_;
+ // The user's email for which |this| object has been created.
+ const std::string email_;
+ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
+ // Used for exchanging auth code for OAuth tokens.
+ GaiaAuthFetcher gaia_auth_fetcher_;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_HELPER_CHROMEOS_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.cc b/chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.cc
index 3b127dc784c..0d4d887fa41 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.cc
@@ -19,7 +19,7 @@ SigninReauthHandler::SigninReauthHandler(
: controller_(controller),
string_to_grd_id_map_(std::move(string_to_grd_id_map)) {
DCHECK(controller_);
- controller_observer_.Add(controller_);
+ controller_observation_.Observe(controller_);
}
SigninReauthHandler::~SigninReauthHandler() = default;
@@ -49,7 +49,7 @@ void SigninReauthHandler::OnJavascriptAllowed() {
}
void SigninReauthHandler::OnReauthControllerDestroyed() {
- controller_observer_.RemoveAll();
+ controller_observation_.Reset();
controller_ = nullptr;
}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.h b/chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.h
index 0e4912de805..8fafcf5c9d2 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/signin_reauth_handler.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_REAUTH_HANDLER_H_
#include "base/containers/flat_map.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/ui/signin_reauth_view_controller.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -54,9 +55,9 @@ class SigninReauthHandler : public content::WebUIMessageHandler,
// May be null if |controller_| gets destroyed earlier than |this|.
SigninReauthViewController* controller_;
- ScopedObserver<SigninReauthViewController,
- SigninReauthViewController::Observer>
- controller_observer_{this};
+ base::ScopedObservation<SigninReauthViewController,
+ SigninReauthViewController::Observer>
+ controller_observation_{this};
// Mapping between strings displayed in the UI corresponding to this handler
// and their respective GRD IDs.
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_reauth_ui.cc b/chromium/chrome/browser/ui/webui/signin/signin_reauth_ui.cc
index 9b5f00e5c9e..8ef00596a76 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_reauth_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_reauth_ui.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/signin/reauth_util.h"
#include "chrome/browser/ui/signin_reauth_view_controller.h"
#include "chrome/browser/ui/webui/signin/signin_reauth_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
@@ -28,6 +29,7 @@
#include "google_apis/gaia/core_account_id.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/webui/resource_path.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/image/image.h"
#include "ui/resources/grit/webui_generated_resources.h"
@@ -62,30 +64,24 @@ SigninReauthUI::SigninReauthUI(content::WebUI* web_ui)
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUISigninReauthHost);
- source->UseStringsJs();
- source->EnableReplaceI18nInJS();
+ webui::SetJSModuleDefaults(source);
source->SetDefaultResource(IDR_SIGNIN_REAUTH_HTML);
- source->AddResourcePath("signin_reauth_app.js", IDR_SIGNIN_REAUTH_APP_JS);
- source->AddResourcePath("signin_reauth_browser_proxy.js",
- IDR_SIGNIN_REAUTH_BROWSER_PROXY_JS);
- source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS);
+
+ static constexpr webui::ResourcePath kResources[] = {
+ {"signin_reauth_app.js", IDR_SIGNIN_REAUTH_APP_JS},
+ {"signin_reauth_browser_proxy.js", IDR_SIGNIN_REAUTH_BROWSER_PROXY_JS},
+ {"signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS},
+ {"signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS},
+ // Resources for the account passwords reauth.
+ {"images/signin_reauth_illustration.svg",
+ IDR_SIGNIN_REAUTH_IMAGES_ACCOUNT_PASSWORDS_REAUTH_ILLUSTRATION_SVG},
+ {"images/signin_reauth_illustration_dark.svg",
+ IDR_SIGNIN_REAUTH_IMAGES_ACCOUNT_PASSWORDS_REAUTH_ILLUSTRATION_DARK_SVG},
+ };
+ source->AddResourcePaths(kResources);
+
source->AddString("accountImageUrl", GetAccountImageURL(profile));
- // Resources for testing.
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test 'self';");
- source->DisableTrustedTypesCSP();
- source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
- source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML);
-
- // Resources for the account passwords reauth.
- source->AddResourcePath(
- "images/signin_reauth_illustration.svg",
- IDR_SIGNIN_REAUTH_IMAGES_ACCOUNT_PASSWORDS_REAUTH_ILLUSTRATION_SVG);
- source->AddResourcePath(
- "images/signin_reauth_illustration_dark.svg",
- IDR_SIGNIN_REAUTH_IMAGES_ACCOUNT_PASSWORDS_REAUTH_ILLUSTRATION_DARK_SVG);
AddStringResource(source, "signinReauthTitle",
IDS_ACCOUNT_PASSWORDS_REAUTH_TITLE);
AddStringResource(source, "signinReauthDesc",
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_ui_error.cc b/chromium/chrome/browser/ui/webui/signin/signin_ui_error.cc
new file mode 100644
index 00000000000..7f021d0239d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/signin_ui_error.cc
@@ -0,0 +1,88 @@
+/// 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.
+
+#include "chrome/browser/ui/webui/signin/signin_ui_error.h"
+
+#include <tuple>
+
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/grit/chromium_strings.h"
+#include "chrome/grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+// static
+SigninUIError SigninUIError::Ok() {
+ return SigninUIError(Type::kOk, std::string(), base::string16());
+}
+
+// static
+SigninUIError SigninUIError::Other(const std::string& email) {
+ return SigninUIError(Type::kOther, email, base::string16());
+}
+
+// static
+SigninUIError SigninUIError::UsernameNotAllowedByPatternFromPrefs(
+ const std::string& email) {
+ return SigninUIError(
+ Type::kUsernameNotAllowedByPatternFromPrefs, email,
+ l10n_util::GetStringUTF16(IDS_SYNC_LOGIN_NAME_PROHIBITED));
+}
+
+// static
+SigninUIError SigninUIError::WrongReauthAccount(
+ const std::string& email,
+ const std::string& current_email) {
+ return SigninUIError(
+ Type::kWrongReauthAccount, email,
+ l10n_util::GetStringFUTF16(IDS_SYNC_WRONG_EMAIL,
+ base::UTF8ToUTF16(current_email)));
+}
+
+// static
+SigninUIError SigninUIError::AccountAlreadyUsedByAnotherProfile(
+ const std::string& email) {
+ return SigninUIError(
+ Type::kAccountAlreadyUsedByAnotherProfile, email,
+ l10n_util::GetStringUTF16(IDS_SYNC_USER_NAME_IN_USE_ERROR));
+}
+
+// static
+SigninUIError SigninUIError::ProfileWasUsedByAnotherAccount(
+ const std::string& email,
+ const std::string& last_email) {
+ return SigninUIError(
+ Type::kProfileWasUsedByAnotherAccount, email,
+ l10n_util::GetStringFUTF16(IDS_SYNC_USED_PROFILE_ERROR,
+ base::UTF8ToUTF16(last_email)));
+}
+
+bool SigninUIError::IsOk() const {
+ return type_ == Type::kOk;
+}
+
+SigninUIError::Type SigninUIError::type() const {
+ return type_;
+}
+
+const base::string16& SigninUIError::email() const {
+ return email_;
+}
+
+const base::string16& SigninUIError::message() const {
+ return message_;
+}
+
+bool SigninUIError::operator==(const SigninUIError& other) const {
+ return std::tie(type_, email_, message_) ==
+ std::tie(other.type_, other.email_, other.message_);
+}
+
+bool SigninUIError::operator!=(const SigninUIError& other) const {
+ return !(*this == other);
+}
+
+SigninUIError::SigninUIError(Type type,
+ const std::string& email,
+ const base::string16& error_message)
+ : type_(type), email_(base::UTF8ToUTF16(email)), message_(error_message) {}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_ui_error.h b/chromium/chrome/browser/ui/webui/signin/signin_ui_error.h
new file mode 100644
index 00000000000..6c49516feb3
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/signin_ui_error.h
@@ -0,0 +1,62 @@
+/// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_UI_ERROR_H_
+#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_UI_ERROR_H_
+
+#include <string>
+
+#include "base/strings/string16.h"
+
+// Holds different sign-in error types along with error messages for displaying
+// in the UI.
+class SigninUIError {
+ public:
+ // An error type.
+ // Different types of UI might be shown for different error types.
+ enum class Type {
+ kOk,
+ kOther,
+ kUsernameNotAllowedByPatternFromPrefs,
+ kWrongReauthAccount,
+ kAccountAlreadyUsedByAnotherProfile,
+ kProfileWasUsedByAnotherAccount,
+ };
+
+ // Following static functions construct a `SigninUIError` with a corresponding
+ // type and error message.
+ static SigninUIError Ok();
+ static SigninUIError Other(const std::string& email);
+ static SigninUIError UsernameNotAllowedByPatternFromPrefs(
+ const std::string& email);
+ static SigninUIError WrongReauthAccount(const std::string& email,
+ const std::string& current_email);
+ static SigninUIError AccountAlreadyUsedByAnotherProfile(
+ const std::string& email);
+ static SigninUIError ProfileWasUsedByAnotherAccount(
+ const std::string& email,
+ const std::string& last_email);
+
+ // Returns true if the instance contains a non-error type.
+ bool IsOk() const;
+
+ Type type() const;
+ const base::string16& email() const;
+ const base::string16& message() const;
+
+ bool operator==(const SigninUIError& other) const;
+ bool operator!=(const SigninUIError& other) const;
+
+ private:
+ SigninUIError(Type type,
+ const std::string& email,
+ const base::string16& error_message);
+
+ // Don't forget to update operator==() when adding new class members.
+ Type type_;
+ base::string16 email_;
+ base::string16 message_;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_UI_ERROR_H_
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 9352d9826af..6acf6a18238 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.cc
@@ -15,6 +15,7 @@
#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"
@@ -24,55 +25,45 @@
#include "google_apis/gaia/gaia_auth_util.h"
#include "ui/base/l10n/l10n_util.h"
-bool CanOfferSignin(Profile* profile,
- CanOfferSigninType can_offer,
- const std::string& gaia_id,
- const std::string& email,
- std::string* error_message) {
- if (error_message)
- error_message->clear();
-
+SigninUIError CanOfferSignin(Profile* profile,
+ CanOfferSigninType can_offer,
+ const std::string& gaia_id,
+ const std::string& email) {
if (!profile)
- return false;
+ return SigninUIError::Other(email);
if (!profile->GetPrefs()->GetBoolean(prefs::kSigninAllowed))
- return false;
+ return SigninUIError::Other(email);
if (!ChromeSigninClient::ProfileAllowsSigninCookies(profile))
- return false;
+ return SigninUIError::Other(email);
if (!email.empty()) {
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile);
if (!identity_manager)
- return false;
+ return SigninUIError::Other(email);
// Make sure this username is not prohibited by policy.
if (!signin::IsUsernameAllowedByPatternFromPrefs(
g_browser_process->local_state(), email)) {
- if (error_message) {
- error_message->assign(
- l10n_util::GetStringUTF8(IDS_SYNC_LOGIN_NAME_PROHIBITED));
- }
- return false;
+ return SigninUIError::UsernameNotAllowedByPatternFromPrefs(email);
}
if (can_offer == CAN_OFFER_SIGNIN_FOR_SECONDARY_ACCOUNT)
- return true;
+ return SigninUIError::Ok();
// If the identity manager already has a primary account, then this is a
// re-auth scenario. Make sure the email just signed in corresponds to
// the one sign in manager expects.
- std::string current_email = identity_manager->GetPrimaryAccountInfo().email;
+ std::string current_email =
+ identity_manager->GetPrimaryAccountInfo(signin::ConsentLevel::kSync)
+ .email;
const bool same_email = gaia::AreEmailsSame(current_email, email);
if (!current_email.empty() && !same_email) {
UMA_HISTOGRAM_ENUMERATION("Signin.Reauth",
signin_metrics::HISTOGRAM_ACCOUNT_MISSMATCH,
signin_metrics::HISTOGRAM_REAUTH_MAX);
- if (error_message) {
- error_message->assign(l10n_util::GetStringFUTF8(
- IDS_SYNC_WRONG_EMAIL, base::UTF8ToUTF16(current_email)));
- }
- return false;
+ return SigninUIError::WrongReauthAccount(email, current_email);
}
// If some profile, not just the current one, is already connected to this
@@ -96,11 +87,7 @@ bool CanOfferSignin(Profile* profile,
std::string profile_email = base::UTF16ToUTF8(entry->GetUserName());
if (gaia_id == profile_gaia_id ||
gaia::AreEmailsSame(email, profile_email)) {
- if (error_message) {
- error_message->assign(
- l10n_util::GetStringUTF8(IDS_SYNC_USER_NAME_IN_USE_ERROR));
- }
- return false;
+ return SigninUIError::AccountAlreadyUsedByAnotherProfile(email);
}
}
}
@@ -109,17 +96,13 @@ bool CanOfferSignin(Profile* profile,
// With force sign in enabled, cross account sign in is not allowed.
if (signin_util::IsForceSigninEnabled() &&
IsCrossAccountError(profile, email, gaia_id)) {
- if (error_message) {
- std::string last_email =
- profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername);
- error_message->assign(l10n_util::GetStringFUTF8(
- IDS_SYNC_USED_PROFILE_ERROR, base::UTF8ToUTF16(last_email)));
- }
- return false;
+ std::string last_email =
+ profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername);
+ return SigninUIError::ProfileWasUsedByAnotherAccount(email, last_email);
}
}
- return true;
+ return SigninUIError::Ok();
}
bool IsCrossAccountError(Profile* profile,
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 9407fa275a7..0eb11010f05 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.h
+++ b/chromium/chrome/browser/ui/webui/signin/signin_utils_desktop.h
@@ -8,6 +8,7 @@
#include <string>
class Profile;
+class SigninUIError;
// Argument for |CanOfferSignin|.
enum CanOfferSigninType {
@@ -15,14 +16,13 @@ enum CanOfferSigninType {
CAN_OFFER_SIGNIN_FOR_SECONDARY_ACCOUNT
};
-// Returns true if sign-in is allowed for account with |email| and |gaia_id| to
-// |profile|. If the sign-in is not allowed, then the error message is passed
-// to the called in |out_error_message|
-bool CanOfferSignin(Profile* profile,
- CanOfferSigninType can_offer_type,
- const std::string& gaia_id,
- const std::string& email,
- std::string* out_error_message);
+// Returns a non-error if sign-in is allowed for account with |email| and
+// |gaia_id| to |profile|. If the sign-in is not allowed, then the error type
+// and the error message are passed in the returned value.
+SigninUIError CanOfferSignin(Profile* profile,
+ CanOfferSigninType can_offer_type,
+ 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.
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 92894c66400..2953d8d1d0d 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
@@ -55,8 +55,7 @@ SyncConfirmationHandler::~SyncConfirmationHandler() {
// Abort signin and prevent sync from starting if none of the actions on the
// sync confirmation dialog are taken by the user.
if (!did_user_explicitly_interact_) {
- HandleUndo(nullptr);
- base::RecordAction(base::UserMetricsAction("Signin_Abort_Signin"));
+ CloseModalSigninWindow(LoginUIService::UI_CLOSED);
}
}
@@ -101,7 +100,7 @@ void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) {
void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) {
did_user_explicitly_interact_ = true;
- CloseModalSigninWindow(LoginUIService::ABORT_SIGNIN);
+ CloseModalSigninWindow(LoginUIService::ABORT_SYNC);
}
void SyncConfirmationHandler::HandleAccountImageRequest(
@@ -163,18 +162,16 @@ void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) {
return;
}
- std::string picture_url_to_load;
GURL picture_gurl(picture_url);
- if (picture_gurl.is_valid()) {
- picture_url_to_load =
- signin::GetAvatarImageURLWithOptions(picture_gurl, kProfileImageSize,
- false /* no_silhouette */)
- .spec();
- } else {
- // Use the placeholder avatar icon until the account picture URL is fetched.
- picture_url_to_load = profiles::GetPlaceholderAvatarIconUrl();
+ if (!picture_gurl.is_valid()) {
+ // As long as the provided gaia picture is not valid, stick to the default
+ // avatar provided in the load-time data.
+ return;
}
- base::Value picture_url_value(picture_url_to_load);
+
+ GURL picture_gurl_with_options = signin::GetAvatarImageURLWithOptions(
+ picture_gurl, kProfileImageSize, false /* no_silhouette */);
+ base::Value picture_url_value(picture_gurl_with_options.spec());
AllowJavascript();
FireWebUIListener("account-image-changed", picture_url_value);
@@ -205,9 +202,12 @@ void SyncConfirmationHandler::CloseModalSigninWindow(
base::RecordAction(
base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings"));
break;
- case LoginUIService::ABORT_SIGNIN:
+ case LoginUIService::ABORT_SYNC:
base::RecordAction(base::UserMetricsAction("Signin_Undo_Signin"));
break;
+ case LoginUIService::UI_CLOSED:
+ base::RecordAction(base::UserMetricsAction("Signin_Abort_Signin"));
+ break;
}
LoginUIServiceFactory::GetForProfile(profile_)->SyncConfirmationUIClosed(
result);
@@ -229,7 +229,6 @@ void SyncConfirmationHandler::HandleInitializedWithSize(
}
if (!primary_account_info->IsValid()) {
- SetUserImageURL(kNoPictureURLFound);
identity_manager_->AddObserver(this);
} else {
SetUserImageURL(primary_account_info->picture_url);
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 d17b918ffde..15ea67b8746 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
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/values.h"
@@ -74,9 +74,8 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
SyncConfirmationHandlerTest()
: did_user_explicitly_interact_(false),
on_sync_confirmation_ui_closed_called_(false),
- sync_confirmation_ui_closed_result_(LoginUIService::ABORT_SIGNIN),
- web_ui_(new content::TestWebUI),
- login_ui_service_observer_(this) {}
+ sync_confirmation_ui_closed_result_(LoginUIService::ABORT_SYNC),
+ web_ui_(new content::TestWebUI) {}
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
@@ -94,12 +93,12 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile());
account_info_ =
identity_test_env()->MakePrimaryAccountAvailable("foo@example.com");
- login_ui_service_observer_.Add(
+ login_ui_service_observation_.Observe(
LoginUIServiceFactory::GetForProfile(profile()));
}
void TearDown() override {
- login_ui_service_observer_.RemoveAll();
+ login_ui_service_observation_.Reset();
sync_confirmation_ui_.reset();
web_ui_.reset();
identity_test_env_adaptor_.reset();
@@ -170,17 +169,16 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
IdentityManagerFactory::GetForProfile(profile());
base::Optional<AccountInfo> primary_account =
identity_manager->FindExtendedAccountInfoForAccountWithRefreshToken(
- identity_manager->GetPrimaryAccountInfo());
+ identity_manager->GetPrimaryAccountInfo(
+ signin::ConsentLevel::kSync));
+ EXPECT_TRUE(primary_account);
- std::string original_picture_url =
- primary_account ? primary_account->picture_url : std::string();
+ std::string gaia_picture_url = primary_account->picture_url;
std::string expected_picture_url =
- original_picture_url.empty()
- ? profiles::GetPlaceholderAvatarIconUrl()
- : signin::GetAvatarImageURLWithOptions(GURL(original_picture_url),
- kExpectedProfileImageSize,
- false /* no_silhouette */)
- .spec();
+ signin::GetAvatarImageURLWithOptions(GURL(gaia_picture_url),
+ kExpectedProfileImageSize,
+ false /* no_silhouette */)
+ .spec();
std::string passed_picture_url;
ASSERT_TRUE(call_data.arg2()->GetAsString(&passed_picture_url));
EXPECT_EQ(expected_picture_url, passed_picture_url);
@@ -200,8 +198,8 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
TestingSyncConfirmationHandler* handler_; // Not owned.
base::UserActionTester user_action_tester_;
std::unordered_map<std::string, int> string_to_grd_id_map_;
- ScopedObserver<LoginUIService, LoginUIService::Observer>
- login_ui_service_observer_;
+ base::ScopedObservation<LoginUIService, LoginUIService::Observer>
+ login_ui_service_observation_{this};
base::HistogramTester histogram_tester_;
std::unique_ptr<IdentityTestEnvironmentProfileAdaptor>
identity_test_env_adaptor_;
@@ -234,16 +232,16 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) {
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
handler()->HandleInitializedWithSize(&args);
- ASSERT_EQ(1U, web_ui()->call_data().size());
- ExpectAccountImageChanged(*web_ui()->call_data()[0]);
+ // No callback called when there's no account image available.
+ ASSERT_EQ(0U, web_ui()->call_data().size());
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info_.account_id, account_info_.email, account_info_.gaia, "",
"full_name", "given_name", "locale",
"http://picture.example.com/picture.jpg");
- ASSERT_EQ(2U, web_ui()->call_data().size());
- ExpectAccountImageChanged(*web_ui()->call_data()[1]);
+ ASSERT_EQ(1U, web_ui()->call_data().size());
+ ExpectAccountImageChanged(*web_ui()->call_data()[0]);
}
TEST_F(SyncConfirmationHandlerTest,
@@ -251,7 +249,7 @@ TEST_F(SyncConfirmationHandlerTest,
base::ListValue args;
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
handler()->HandleInitializedWithSize(&args);
- EXPECT_EQ(1U, web_ui()->call_data().size());
+ EXPECT_EQ(0U, web_ui()->call_data().size());
AccountInfo account_info =
identity_test_env()->MakeAccountAvailable("bar@example.com");
@@ -262,7 +260,7 @@ TEST_F(SyncConfirmationHandlerTest,
// Updating the account info of a secondary account should not update the
// image of the sync confirmation dialog.
- EXPECT_EQ(1U, web_ui()->call_data().size());
+ EXPECT_EQ(0U, web_ui()->call_data().size());
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info_.account_id, account_info_.email, account_info_.gaia, "",
@@ -271,8 +269,8 @@ TEST_F(SyncConfirmationHandlerTest,
// Updating the account info of the primary account should update the
// image of the sync confirmation dialog.
- ASSERT_EQ(2U, web_ui()->call_data().size());
- ExpectAccountImageChanged(*web_ui()->call_data()[1]);
+ ASSERT_EQ(1U, web_ui()->call_data().size());
+ ExpectAccountImageChanged(*web_ui()->call_data()[0]);
}
TEST_F(SyncConfirmationHandlerTest, TestHandleUndo) {
@@ -280,7 +278,7 @@ TEST_F(SyncConfirmationHandlerTest, TestHandleUndo) {
did_user_explicitly_interact_ = true;
EXPECT_TRUE(on_sync_confirmation_ui_closed_called_);
- EXPECT_EQ(LoginUIService::ABORT_SIGNIN, sync_confirmation_ui_closed_result_);
+ EXPECT_EQ(LoginUIService::ABORT_SYNC, sync_confirmation_ui_closed_result_);
EXPECT_EQ(1, user_action_tester()->GetActionCount("Signin_Undo_Signin"));
EXPECT_EQ(0, user_action_tester()->GetActionCount(
"Signin_Signin_WithDefaultSyncSettings"));
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 add9e138f35..dcaf46e7ea5 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/signin/profile_colors_util.h"
#include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -24,89 +25,55 @@
#include "content/public/browser/web_ui_data_source.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/webui/resource_path.h"
#include "ui/base/webui/web_ui_util.h"
+#include "ui/gfx/color_utils.h"
#include "ui/resources/grit/webui_generated_resources.h"
#include "ui/resources/grit/webui_resources.h"
SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
- : SigninWebDialogUI(web_ui) {
- Profile* profile = Profile::FromWebUI(web_ui);
+ : SigninWebDialogUI(web_ui), profile_(Profile::FromWebUI(web_ui)) {
+ // Initializing the WebUIDataSource in the constructor is needed for polymer
+ // tests.
+ Initialize(/*profile_creation_flow_color=*/base::nullopt);
+}
+
+SyncConfirmationUI::~SyncConfirmationUI() = default;
+
+void SyncConfirmationUI::InitializeMessageHandlerWithBrowser(Browser* browser) {
+ InitializeMessageHandler(browser);
+}
+
+void SyncConfirmationUI::InitializeMessageHandlerForCreationFlow(
+ SkColor profile_color) {
+ // Redo the initialization with `profile_color`.
+ Initialize(profile_color);
+ InitializeMessageHandler(/*browser=*/nullptr);
+}
+
+void SyncConfirmationUI::Initialize(
+ base::Optional<SkColor> profile_creation_flow_color) {
const bool is_sync_allowed =
- ProfileSyncServiceFactory::IsSyncAllowed(profile);
+ ProfileSyncServiceFactory::IsSyncAllowed(profile_);
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUISyncConfirmationHost);
source->UseStringsJs();
source->EnableReplaceI18nInJS();
- source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS);
- source->AddResourcePath("sync_confirmation_browser_proxy.js",
- IDR_SYNC_CONFIRMATION_BROWSER_PROXY_JS);
- source->AddResourcePath("sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS);
+ static constexpr webui::ResourcePath kResources[] = {
+ {"signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS},
+ {"signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS},
+ {"sync_confirmation_browser_proxy.js",
+ IDR_SYNC_CONFIRMATION_BROWSER_PROXY_JS},
+ {"sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS},
+ };
+ source->AddResourcePaths(kResources);
if (is_sync_allowed) {
- source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
- source->AddResourcePath("test_loader.html",
- IDR_WEBUI_HTML_TEST_LOADER_HTML);
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources chrome://test 'self';");
-
- source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML);
- source->AddResourcePath("sync_confirmation_app.js",
- IDR_SYNC_CONFIRMATION_APP_JS);
-
- source->AddResourcePath(
- "images/sync_confirmation_illustration.svg",
- IDR_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_ILLUSTRATION_SVG);
- source->AddResourcePath(
- "images/sync_confirmation_illustration_dark.svg",
- IDR_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_ILLUSTRATION_DARK_SVG);
-
- AddStringResource(source, "syncConfirmationTitle",
- IDS_SYNC_CONFIRMATION_TITLE);
- AddStringResource(source, "syncConfirmationSyncInfoTitle",
- IDS_SYNC_CONFIRMATION_SYNC_INFO_TITLE);
- AddStringResource(source, "syncConfirmationSyncInfoDesc",
- IDS_SYNC_CONFIRMATION_SYNC_INFO_DESC);
- AddStringResource(source, "syncConfirmationSettingsInfo",
- IDS_SYNC_CONFIRMATION_SETTINGS_INFO);
- AddStringResource(source, "syncConfirmationSettingsLabel",
- IDS_SYNC_CONFIRMATION_SETTINGS_BUTTON_LABEL);
- AddStringResource(source, "syncConfirmationConfirmLabel",
- IDS_SYNC_CONFIRMATION_CONFIRM_BUTTON_LABEL);
- AddStringResource(source, "syncConfirmationUndoLabel", IDS_CANCEL);
-
- constexpr int kAccountPictureSize = 68;
- std::string custom_picture_url = profiles::GetPlaceholderAvatarIconUrl();
- signin::IdentityManager* identity_manager =
- IdentityManagerFactory::GetForProfile(profile);
- base::Optional<AccountInfo> primary_account_info =
- identity_manager->FindExtendedAccountInfoForAccountWithRefreshToken(
- identity_manager->GetPrimaryAccountInfo());
- GURL account_picture_url(primary_account_info
- ? primary_account_info->picture_url
- : std::string());
- if (account_picture_url.is_valid()) {
- custom_picture_url = signin::GetAvatarImageURLWithOptions(
- account_picture_url, kAccountPictureSize,
- false /* no_silhouette */)
- .spec();
- }
- source->AddString("accountPictureUrl", custom_picture_url);
+ InitializeForSyncConfirmation(source, profile_creation_flow_color);
} else {
- source->SetDefaultResource(IDR_SYNC_DISABLED_CONFIRMATION_HTML);
- source->AddResourcePath("sync_disabled_confirmation_app.js",
- IDR_SYNC_DISABLED_CONFIRMATION_APP_JS);
-
- AddStringResource(source, "syncDisabledConfirmationTitle",
- IDS_SYNC_DISABLED_CONFIRMATION_CHROME_SYNC_TITLE);
- AddStringResource(source, "syncDisabledConfirmationDetails",
- IDS_SYNC_DISABLED_CONFIRMATION_DETAILS);
- AddStringResource(source, "syncDisabledConfirmationConfirmLabel",
- IDS_SYNC_DISABLED_CONFIRMATION_CONFIRM_BUTTON_LABEL);
- AddStringResource(source, "syncDisabledConfirmationUndoLabel",
- IDS_SYNC_DISABLED_CONFIRMATION_UNDO_BUTTON_LABEL);
+ InitializeForSyncDisabled(source);
}
source->DisableTrustedTypesCSP();
@@ -116,19 +83,97 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
g_browser_process->GetApplicationLocale(), &strings);
source->AddLocalizedStrings(strings);
- content::WebUIDataSource::Add(profile, source);
+ content::WebUIDataSource::Add(profile_, source);
}
-SyncConfirmationUI::~SyncConfirmationUI() {}
-
-void SyncConfirmationUI::InitializeMessageHandlerWithBrowser(Browser* browser) {
+void SyncConfirmationUI::InitializeMessageHandler(Browser* browser) {
web_ui()->AddMessageHandler(std::make_unique<SyncConfirmationHandler>(
- browser->profile(), js_localized_string_to_ids_map_, browser));
+ profile_, js_localized_string_to_ids_map_, browser));
}
-void SyncConfirmationUI::InitializeMessageHandlerWithProfile(Profile* profile) {
- web_ui()->AddMessageHandler(std::make_unique<SyncConfirmationHandler>(
- profile, js_localized_string_to_ids_map_));
+void SyncConfirmationUI::InitializeForSyncConfirmation(
+ content::WebUIDataSource* source,
+ base::Optional<SkColor> profile_creation_flow_color) {
+ // Resources for testing.
+ source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
+ source->AddResourcePath("test_loader_util.js",
+ IDR_WEBUI_JS_TEST_LOADER_UTIL_JS);
+ source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML);
+
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::ScriptSrc,
+ "script-src chrome://resources chrome://test 'self';");
+
+ AddStringResource(source, "syncConfirmationTitle",
+ IDS_SYNC_CONFIRMATION_TITLE);
+ AddStringResource(source, "syncConfirmationSyncInfoTitle",
+ IDS_SYNC_CONFIRMATION_SYNC_INFO_TITLE);
+ AddStringResource(source, "syncConfirmationSyncInfoDesc",
+ IDS_SYNC_CONFIRMATION_SYNC_INFO_DESC);
+ AddStringResource(source, "syncConfirmationSettingsInfo",
+ IDS_SYNC_CONFIRMATION_SETTINGS_INFO);
+ AddStringResource(source, "syncConfirmationSettingsLabel",
+ IDS_SYNC_CONFIRMATION_SETTINGS_BUTTON_LABEL);
+ AddStringResource(source, "syncConfirmationConfirmLabel",
+ IDS_SYNC_CONFIRMATION_CONFIRM_BUTTON_LABEL);
+
+ const int kAccountPictureSize = 128;
+ std::string avatar_picture_url;
+ if (profile_creation_flow_color.has_value()) {
+ SkColor fill_color = *profile_creation_flow_color;
+ gfx::Image avatar_picture = profiles::GetPlaceholderAvatarIconWithColors(
+ /*fill_color=*/fill_color,
+ /*stroke_color=*/GetAvatarStrokeColor(fill_color), kAccountPictureSize);
+ avatar_picture_url = webui::GetBitmapDataUrl(avatar_picture.AsBitmap());
+ } else {
+ avatar_picture_url = profiles::GetPlaceholderAvatarIconUrl();
+ }
+ source->AddString("accountPictureUrl", avatar_picture_url);
+
+ source->AddResourcePath("sync_confirmation_app.js",
+ IDR_SYNC_CONFIRMATION_APP_JS);
+ source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML);
+
+ source->AddBoolean("isProfileCreationFlow",
+ profile_creation_flow_color.has_value());
+ if (!profile_creation_flow_color.has_value()) {
+ AddStringResource(source, "syncConfirmationUndoLabel", IDS_CANCEL);
+
+ source->AddResourcePath(
+ "images/sync_confirmation_illustration.svg",
+ IDR_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_ILLUSTRATION_SVG);
+ source->AddResourcePath(
+ "images/sync_confirmation_illustration_dark.svg",
+ IDR_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_ILLUSTRATION_DARK_SVG);
+ return;
+ }
+
+ AddStringResource(source, "syncConfirmationUndoLabel", IDS_NO_THANKS);
+ source->AddString("highlightColor", color_utils::SkColorToRgbaString(
+ *profile_creation_flow_color));
+
+ source->AddResourcePath(
+ "images/sync_confirmation_refreshed_illustration.svg",
+ IDR_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_REFRESHED_ILLUSTRATION_SVG);
+ source->AddResourcePath(
+ "images/sync_confirmation_refreshed_illustration_dark.svg",
+ IDR_SYNC_CONFIRMATION_IMAGES_SYNC_CONFIRMATION_REFRESHED_ILLUSTRATION_DARK_SVG);
+}
+
+void SyncConfirmationUI::InitializeForSyncDisabled(
+ content::WebUIDataSource* source) {
+ source->SetDefaultResource(IDR_SYNC_DISABLED_CONFIRMATION_HTML);
+ source->AddResourcePath("sync_disabled_confirmation_app.js",
+ IDR_SYNC_DISABLED_CONFIRMATION_APP_JS);
+
+ AddStringResource(source, "syncDisabledConfirmationTitle",
+ IDS_SYNC_DISABLED_CONFIRMATION_CHROME_SYNC_TITLE);
+ AddStringResource(source, "syncDisabledConfirmationDetails",
+ IDS_SYNC_DISABLED_CONFIRMATION_DETAILS);
+ AddStringResource(source, "syncDisabledConfirmationConfirmLabel",
+ IDS_SYNC_DISABLED_CONFIRMATION_CONFIRM_BUTTON_LABEL);
+ AddStringResource(source, "syncDisabledConfirmationUndoLabel",
+ IDS_SYNC_DISABLED_CONFIRMATION_UNDO_BUTTON_LABEL);
}
void SyncConfirmationUI::AddStringResource(content::WebUIDataSource* source,
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 5d1cdbafa04..923a0ace370 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.h
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.h
@@ -35,11 +35,18 @@ class SyncConfirmationUI : public SigninWebDialogUI {
// SigninWebDialogUI:
void InitializeMessageHandlerWithBrowser(Browser* browser) override;
- // Initializes the message handler when there's no browser for `profile`
- // available (such as in the profile creation flow).
- void InitializeMessageHandlerWithProfile(Profile* profile);
+ // Initializes the message handler for the profile creation flow (when there's
+ // no browser available).
+ void InitializeMessageHandlerForCreationFlow(SkColor profile_color);
private:
+ void Initialize(base::Optional<SkColor> profile_creation_flow_color);
+ void InitializeMessageHandler(Browser* browser);
+ void InitializeForSyncConfirmation(
+ content::WebUIDataSource* source,
+ base::Optional<SkColor> profile_creation_flow_color);
+ void InitializeForSyncDisabled(content::WebUIDataSource* source);
+
// Adds a string resource with the given GRD |ids| 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
@@ -51,6 +58,8 @@ class SyncConfirmationUI : public SigninWebDialogUI {
// For consent auditing.
std::unordered_map<std::string, int> js_localized_string_to_ids_map_;
+ Profile* const profile_;
+
DISALLOW_COPY_AND_ASSIGN(SyncConfirmationUI);
};
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
deleted file mode 100644
index 5a93b86d270..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
+++ /dev/null
@@ -1,869 +0,0 @@
-// Copyright 2013 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/signin/user_manager_screen_handler.h"
-
-#include <stddef.h>
-
-#include <utility>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/callback_helpers.h"
-#include "base/location.h"
-#include "base/macros.h"
-#include "base/metrics/histogram_macros.h"
-#include "base/metrics/user_metrics.h"
-#include "base/single_thread_task_runner.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "base/util/values/values_util.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_attributes_entry.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/profiles/profile_metrics.h"
-#include "chrome/browser/profiles/profile_statistics.h"
-#include "chrome/browser/profiles/profile_statistics_factory.h"
-#include "chrome/browser/profiles/profile_window.h"
-#include "chrome/browser/profiles/profiles_state.h"
-#include "chrome/browser/signin/local_auth.h"
-#include "chrome/browser/signin/signin_util.h"
-#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/browser_dialogs.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/browser_list_observer.h"
-#include "chrome/browser/ui/chrome_pages.h"
-#include "chrome/browser/ui/singleton_tabs.h"
-#include "chrome/browser/ui/user_manager.h"
-#include "chrome/browser/ui/webui/profile_helper.h"
-#include "chrome/browser/ui/webui/signin/login_ui_service.h"
-#include "chrome/browser/ui/webui/signin/login_ui_service_factory.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 "components/account_id/account_id.h"
-#include "components/prefs/pref_service.h"
-#include "components/strings/grit/components_strings.h"
-#include "content/public/browser/storage_partition.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "google_apis/gaia/gaia_auth_fetcher.h"
-#include "google_apis/gaia/gaia_constants.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/webui/web_ui_util.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/image/image_util.h"
-
-namespace {
-// User dictionary keys.
-const char kKeyUsername[] = "username";
-const char kKeyDisplayName[]= "displayName";
-const char kKeyEmailAddress[] = "emailAddress";
-const char kKeyProfilePath[] = "profilePath";
-const char kKeyPublicAccount[] = "publicAccount";
-const char kKeyLegacySupervisedUser[] = "legacySupervisedUser";
-const char kKeyChildUser[] = "childUser";
-const char kKeyCanRemove[] = "canRemove";
-const char kKeyIsOwner[] = "isOwner";
-const char kKeyIsDesktop[] = "isDesktopUser";
-const char kKeyAvatarUrl[] = "userImage";
-const char kKeyNeedsSignin[] = "needsSignin";
-const char kKeyHasLocalCreds[] = "hasLocalCreds";
-const char kKeyIsProfileLoaded[] = "isProfileLoaded";
-
-// JS API callback names.
-const char kJsApiUserManagerInitialize[] = "userManagerInitialize";
-const char kJsApiUserManagerAuthLaunchUser[] = "authenticatedLaunchUser";
-const char kJsApiUserManagerLaunchGuest[] = "launchGuest";
-const char kJsApiUserManagerLaunchUser[] = "launchUser";
-const char kJsApiUserManagerRemoveUser[] = "removeUser";
-const char kJsApiUserManagerLogRemoveUserWarningShown[] =
- "logRemoveUserWarningShown";
-const char kJsApiUserManagerRemoveUserWarningLoadStats[] =
- "removeUserWarningLoadStats";
-const char kJsApiUserManagerAreAllProfilesLocked[] =
- "areAllProfilesLocked";
-const size_t kSigninAvatarIconSize = 180;
-const int kMaxOAuthRetries = 3;
-
-std::string GetAvatarImage(const ProfileAttributesEntry* entry) {
- bool is_gaia_picture = entry->IsUsingGAIAPicture() &&
- entry->GetGAIAPicture() != nullptr;
-
- // If the avatar is too small (i.e. the old-style low resolution avatar),
- // it will be pixelated when displayed in the User Manager, so we should
- // return the placeholder avatar instead.
- gfx::Image avatar_image = entry->GetAvatarIcon();
- if (avatar_image.Width() <= profiles::kAvatarIconSize ||
- avatar_image.Height() <= profiles::kAvatarIconSize) {
- avatar_image = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- profiles::GetPlaceholderAvatarIconResourceID());
- }
- gfx::Image resized_image = profiles::GetSizedAvatarIcon(
- avatar_image, is_gaia_picture, kSigninAvatarIconSize,
- kSigninAvatarIconSize);
- return webui::GetBitmapDataUrl(resized_image.AsBitmap());
-}
-
-bool IsGuestModeEnabled() {
- PrefService* service = g_browser_process->local_state();
- DCHECK(service);
- return service->GetBoolean(prefs::kBrowserGuestModeEnabled);
-}
-
-bool IsAddPersonEnabled() {
- PrefService* service = g_browser_process->local_state();
- DCHECK(service);
- return service->GetBoolean(prefs::kBrowserAddPersonEnabled);
-}
-
-// Executes the action specified by the URL's Hash parameter, if any. Deletes
-// itself after the action would be performed.
-class UrlHashHelper : public BrowserListObserver {
- public:
- UrlHashHelper(Browser* browser, const std::string& hash);
- ~UrlHashHelper() override;
-
- void ExecuteUrlHash();
-
- // BrowserListObserver overrides:
- void OnBrowserRemoved(Browser* browser) override;
-
- private:
- Browser* browser_;
- Profile* profile_;
- std::string hash_;
-
- DISALLOW_COPY_AND_ASSIGN(UrlHashHelper);
-};
-
-UrlHashHelper::UrlHashHelper(Browser* browser, const std::string& hash)
- : browser_(browser),
- profile_(browser->profile()),
- hash_(hash) {
- BrowserList::AddObserver(this);
-}
-
-UrlHashHelper::~UrlHashHelper() {
- BrowserList::RemoveObserver(this);
-}
-
-void UrlHashHelper::OnBrowserRemoved(Browser* browser) {
- if (browser == browser_)
- browser_ = nullptr;
-}
-
-void UrlHashHelper::ExecuteUrlHash() {
- Browser* target_browser = browser_;
- if (!target_browser) {
- target_browser = chrome::FindLastActiveWithProfile(profile_);
- if (!target_browser)
- return;
- }
-
- if (hash_ == profiles::kUserManagerSelectProfileTaskManager)
- chrome::OpenTaskManager(target_browser);
- else if (hash_ == profiles::kUserManagerSelectProfileAboutChrome)
- chrome::ShowAboutChrome(target_browser);
- else if (hash_ == profiles::kUserManagerSelectProfileChromeSettings)
- chrome::ShowSettings(target_browser);
-}
-
-void HandleLogRemoveUserWarningShown(const base::ListValue* args) {
- ProfileMetrics::LogProfileDeleteUser(
- ProfileMetrics::DELETE_PROFILE_USER_MANAGER_SHOW_WARNING);
-}
-
-void DisplayErrorMessage(const base::string16 error_message,
- content::WebUI* web_ui) {
- LoginUIServiceFactory::GetForProfile(
- Profile::FromWebUI(web_ui)->GetOriginalProfile())
- ->DisplayLoginResult(nullptr, error_message, base::string16());
- UserManagerProfileDialog::ShowDialogAndDisplayErrorMessage(
- web_ui->GetWebContents()->GetBrowserContext());
-}
-
-void RecordAuthenticatedLaunchUserEvent(
- const AuthenticatedLaunchUserEvent& event) {
- UMA_HISTOGRAM_ENUMERATION(kAuthenticatedLaunchUserEventMetricsName, event,
- AuthenticatedLaunchUserEvent::EVENT_COUNT);
-}
-
-} // namespace
-
-const char kAuthenticatedLaunchUserEventMetricsName[] =
- "Signin.AuthenticatedLaunchUserEvent";
-
-// ProfileUpdateObserver ------------------------------------------------------
-
-class UserManagerScreenHandler::ProfileUpdateObserver
- : public ProfileAttributesStorage::Observer {
- public:
- ProfileUpdateObserver(
- ProfileManager* profile_manager, UserManagerScreenHandler* handler)
- : profile_manager_(profile_manager),
- user_manager_handler_(handler) {
- DCHECK(profile_manager_);
- DCHECK(user_manager_handler_);
- profile_manager_->GetProfileAttributesStorage().AddObserver(this);
- }
-
- ~ProfileUpdateObserver() override {
- DCHECK(profile_manager_);
- profile_manager_->GetProfileAttributesStorage().RemoveObserver(this);
- }
-
- private:
- // ProfileAttributesStorage::Observer implementation:
- // If any change has been made to a profile, propagate it to all the
- // visible user manager screens.
- void OnProfileAdded(const base::FilePath& profile_path) override {
- user_manager_handler_->SendUserList();
- }
-
- void OnProfileWasRemoved(const base::FilePath& profile_path,
- const base::string16& profile_name) override {
- // TODO(noms): Change 'SendUserList' to 'removeUser' JS-call when
- // UserManager is able to find pod belonging to removed user.
- user_manager_handler_->SendUserList();
- }
-
- void OnProfileNameChanged(const base::FilePath& profile_path,
- const base::string16& old_profile_name) override {
- user_manager_handler_->SendUserList();
- }
-
- void OnProfileAvatarChanged(const base::FilePath& profile_path) override {
- user_manager_handler_->SendUserList();
- }
-
- void OnProfileHighResAvatarLoaded(
- const base::FilePath& profile_path) override {
- user_manager_handler_->SendUserList();
- }
-
- void OnProfileSigninRequiredChanged(
- const base::FilePath& profile_path) override {
- user_manager_handler_->SendUserList();
- }
-
- void OnProfileIsOmittedChanged(
- const base::FilePath& profile_path) override {
- user_manager_handler_->SendUserList();
- }
-
- ProfileManager* profile_manager_;
-
- UserManagerScreenHandler* user_manager_handler_; // Weak; owns us.
-
- DISALLOW_COPY_AND_ASSIGN(ProfileUpdateObserver);
-};
-
-// UserManagerScreenHandler ---------------------------------------------------
-
-UserManagerScreenHandler::UserManagerScreenHandler() {
- profile_attributes_storage_observer_.reset(
- new UserManagerScreenHandler::ProfileUpdateObserver(
- g_browser_process->profile_manager(), this));
-
- // TODO(mahmadi): Remove the following once prefs are cleared for everyone.
- PrefService* service = g_browser_process->local_state();
- DCHECK(service);
-
- const PrefService::Preference* guest_mode_enabled_pref =
- service->FindPreference(prefs::kBrowserGuestModeEnabled);
- const PrefService::Preference* add_person_enabled_pref =
- service->FindPreference(prefs::kBrowserAddPersonEnabled);
-
- if (guest_mode_enabled_pref->HasUserSetting() ||
- add_person_enabled_pref->HasUserSetting()) {
- service->ClearPref(guest_mode_enabled_pref->name());
- service->ClearPref(add_person_enabled_pref->name());
- base::RecordAction(
- base::UserMetricsAction("UserManager_Cleared_Legacy_User_Prefs"));
- }
-}
-
-UserManagerScreenHandler::~UserManagerScreenHandler() {
- BrowserList::RemoveObserver(this);
-}
-
-void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) {
- // If the URL has a hash parameter, store it for later.
- args->GetString(0, &url_hash_);
-
- SendUserList();
- web_ui()->CallJavascriptFunctionUnsafe(
- "cr.ui.UserManager.showUserManagerScreen",
- base::Value(IsGuestModeEnabled()), base::Value(IsAddPersonEnabled()));
-}
-
-void UserManagerScreenHandler::HandleAuthenticatedLaunchUser(
- const base::ListValue* args) {
- const base::Value* profile_path_value;
- if (!args->Get(0, &profile_path_value))
- return;
-
- base::Optional<base::FilePath> profile_path =
- util::ValueToFilePath(*profile_path_value);
- if (!profile_path)
- return;
-
- ProfileAttributesEntry* entry;
- if (!g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(*profile_path, &entry)) {
- return;
- }
-
- base::string16 email_address;
- if (!args->GetString(1, &email_address))
- return;
-
- std::string password;
- if (!args->GetString(2, &password))
- return;
-
- authenticating_profile_path_ = *profile_path;
- email_address_ = base::UTF16ToUTF8(email_address);
-
- // Only try to validate locally or check the password change detection
- // if we actually have a local credential saved.
- if (!entry->GetLocalAuthCredentials().empty()) {
- RecordAuthenticatedLaunchUserEvent(
- AuthenticatedLaunchUserEvent::LOCAL_REAUTH_DIALOG);
- if (LocalAuth::ValidateLocalAuthCredentials(entry, password)) {
- ReportAuthenticationResult(true, ProfileMetrics::AUTH_LOCAL);
- return;
- }
-
- // This could be a mis-typed password or typing a new password while we
- // still have a hash of the old one. The new way of checking a password
- // change makes use of a token so we do that... if it's available.
- if (!oauth_client_) {
- oauth_client_ = std::make_unique<gaia::GaiaOAuthClient>(
- content::BrowserContext::GetDefaultStoragePartition(
- web_ui()->GetWebContents()->GetBrowserContext())
- ->GetURLLoaderFactoryForBrowserProcess());
- }
-
- const std::string token = entry->GetPasswordChangeDetectionToken();
- if (!token.empty()) {
- oauth_client_->GetTokenHandleInfo(token, kMaxOAuthRetries, this);
- return;
- }
- }
-
- content::BrowserContext* browser_context =
- web_ui()->GetWebContents()->GetBrowserContext();
-
- if (!email_address_.empty() && entry->IsAuthenticated()) {
- // In order to support the upgrade case where we have a local hash but no
- // password token, the user must perform a full online reauth.
- RecordAuthenticatedLaunchUserEvent(
- AuthenticatedLaunchUserEvent::GAIA_REAUTH_DIALOG);
- UserManagerProfileDialog::ShowUnlockDialogWithProfilePath(
- browser_context, email_address_, *profile_path);
- } else if (entry->IsSigninRequired() && entry->IsSupervised()) {
- // Supervised profile will only be locked when force-sign-in is enabled
- // and it shouldn't be unlocked. Display the error message directly via
- // the system profile to avoid profile creation.
- RecordAuthenticatedLaunchUserEvent(
- AuthenticatedLaunchUserEvent::SUPERVISED_PROFILE_BLOCKED_WARNING);
- DisplayErrorMessage(
- l10n_util::GetStringUTF16(IDS_SUPERVISED_USER_NOT_ALLOWED_BY_POLICY),
- web_ui());
- } else if (entry->IsSigninRequired() && signin_util::IsForceSigninEnabled() &&
- entry->GetActiveTime() != base::Time()) {
- // If force-sign-in is enabled, do not allow users to sign in to a
- // pre-existing locked profile, as this may force unexpected profile data
- // merge. We consider a profile as pre-existing if it has been actived
- // previously. A pre-existed profile can still be used if it has been signed
- // in with an email address matched RestrictSigninToPattern policy already.
- RecordAuthenticatedLaunchUserEvent(
- AuthenticatedLaunchUserEvent::USED_PROFILE_BLOCKED_WARNING);
- LoginUIServiceFactory::GetForProfile(
- Profile::FromWebUI(web_ui())->GetOriginalProfile())
- ->SetProfileBlockingErrorMessage();
- UserManagerProfileDialog::ShowDialogAndDisplayErrorMessage(
- web_ui()->GetWebContents()->GetBrowserContext());
- } else {
- // Fresh sign in via user manager without existing email address.
- DCHECK(signin_util::IsForceSigninEnabled());
- RecordAuthenticatedLaunchUserEvent(
- AuthenticatedLaunchUserEvent::FORCED_PRIMARY_SIGNIN_DIALOG);
- UserManagerProfileDialog::ShowForceSigninDialog(browser_context,
- *profile_path);
- }
-}
-
-void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) {
- DCHECK(args);
- const base::Value* profile_path_value;
- if (!args->Get(0, &profile_path_value)) {
- NOTREACHED();
- return;
- }
-
- base::Optional<base::FilePath> profile_path =
- util::ValueToFilePath(*profile_path_value);
- if (!profile_path) {
- NOTREACHED();
- return;
- }
-
- DCHECK(profiles::IsMultipleProfilesEnabled());
-
- if (!signin_util::IsForceSigninEnabled() &&
- profiles::AreAllNonChildNonSupervisedProfilesLocked()) {
- web_ui()->CallJavascriptFunctionUnsafe(
- "cr.webUIListenerCallback", base::Value("show-error-dialog"),
- base::Value(l10n_util::GetStringUTF8(
- IDS_USER_MANAGER_REMOVE_PROFILE_PROFILES_LOCKED_ERROR)));
- return;
- }
-
- // The callback is run if the only profile has been deleted, and a new
- // profile has been created to replace it.
- webui::DeleteProfileAtPath(*profile_path,
- ProfileMetrics::DELETE_PROFILE_USER_MANAGER);
-}
-
-void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) {
- if (IsGuestModeEnabled()) {
- profiles::SwitchToGuestProfile(
- base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
- weak_ptr_factory_.GetWeakPtr()));
- } else {
- // The UI should have prevented the user from allowing the selection of
- // guest mode.
- NOTREACHED();
- }
-}
-
-void UserManagerScreenHandler::HandleAreAllProfilesLocked(
- const base::ListValue* args) {
- std::string webui_callback_id;
- CHECK_EQ(1U, args->GetSize());
- bool success = args->GetString(0, &webui_callback_id);
- DCHECK(success);
-
- AllowJavascript();
- ResolveJavascriptCallback(
- base::Value(webui_callback_id),
- base::Value(profiles::AreAllNonChildNonSupervisedProfilesLocked()));
-}
-
-void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
- const base::Value* profile_path_value = NULL;
- if (!args->Get(0, &profile_path_value))
- return;
-
- base::Optional<base::FilePath> profile_path =
- util::ValueToFilePath(*profile_path_value);
- if (!profile_path)
- return;
-
- ProfileAttributesEntry* entry;
- if (!g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(*profile_path, &entry)) {
- NOTREACHED();
- return;
- }
-
- // It's possible that a user breaks into the user-manager page using the
- // JavaScript Inspector and causes a "locked" profile to call this
- // unauthenticated version of "launch" instead of the proper one. Thus,
- // we have to validate in (secure) C++ code that it really is a profile
- // not needing authentication. If it is, just ignore the "launch" request.
- if (entry->IsSigninRequired())
- return;
-
- profiles::SwitchToProfile(
- *profile_path, false, /* reuse any existing windows */
- base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats(
- const base::ListValue* args) {
- const base::Value* profile_path_value;
-
- if (!args->Get(0, &profile_path_value))
- return;
-
- base::Time start_time = base::Time::Now();
- base::Optional<base::FilePath> profile_path =
- util::ValueToFilePath(*profile_path_value);
- if (!profile_path)
- return;
-
- base::Value return_profile_path(profile_path->value());
- Profile* profile =
- g_browser_process->profile_manager()->GetProfileByPath(*profile_path);
-
- if (profile) {
- GatherStatistics(start_time, profile);
- } else {
- g_browser_process->profile_manager()->LoadProfileByPath(
- *profile_path, false,
- base::BindOnce(&UserManagerScreenHandler::GatherStatistics,
- weak_ptr_factory_.GetWeakPtr(), start_time));
- }
-}
-
-void UserManagerScreenHandler::GatherStatistics(base::Time start_time,
- Profile* profile) {
- if (profile) {
- ProfileStatisticsFactory::GetForProfile(profile)->GatherStatistics(
- base::Bind(&UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback,
- weak_ptr_factory_.GetWeakPtr(), profile->GetPath(),
- start_time));
- }
-}
-
-void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback(
- base::FilePath profile_path,
- base::Time start_time,
- profiles::ProfileCategoryStats result) {
- // Copy result into return_value.
- base::DictionaryValue return_value;
- for (const auto& item : result) {
- auto stat = std::make_unique<base::DictionaryValue>();
- stat->SetKey("count", base::Value(item.count));
- return_value.SetWithoutPathExpansion(item.category, std::move(stat));
- }
- web_ui()->CallJavascriptFunctionUnsafe("updateRemoveWarningDialog",
- base::Value(profile_path.value()),
- return_value);
-}
-
-void UserManagerScreenHandler::OnGetTokenInfoResponse(
- std::unique_ptr<base::DictionaryValue> token_info) {
- // Password is unchanged so user just mistyped it. Ask again.
- ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED);
-}
-
-void UserManagerScreenHandler::OnOAuthError() {
- // Password has changed. Go through online signin flow.
- DCHECK(!email_address_.empty());
- oauth_client_.reset();
- UserManagerProfileDialog::ShowUnlockDialog(
- web_ui()->GetWebContents()->GetBrowserContext(), email_address_);
-}
-
-void UserManagerScreenHandler::OnNetworkError(int response_code) {
- // Inconclusive but can't do real signin without being online anyway.
- oauth_client_.reset();
- ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED_OFFLINE);
-}
-
-void UserManagerScreenHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- kJsApiUserManagerInitialize,
- base::BindRepeating(&UserManagerScreenHandler::HandleInitialize,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- kJsApiUserManagerAuthLaunchUser,
- base::BindRepeating(
- &UserManagerScreenHandler::HandleAuthenticatedLaunchUser,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- kJsApiUserManagerLaunchGuest,
- base::BindRepeating(&UserManagerScreenHandler::HandleLaunchGuest,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- kJsApiUserManagerLaunchUser,
- base::BindRepeating(&UserManagerScreenHandler::HandleLaunchUser,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- kJsApiUserManagerRemoveUser,
- base::BindRepeating(&UserManagerScreenHandler::HandleRemoveUser,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- kJsApiUserManagerLogRemoveUserWarningShown,
- base::BindRepeating(&HandleLogRemoveUserWarningShown));
- web_ui()->RegisterMessageCallback(
- kJsApiUserManagerRemoveUserWarningLoadStats,
- base::BindRepeating(
- &UserManagerScreenHandler::HandleRemoveUserWarningLoadStats,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- kJsApiUserManagerAreAllProfilesLocked,
- base::BindRepeating(&UserManagerScreenHandler::HandleAreAllProfilesLocked,
- base::Unretained(this)));
-
- // Unused callbacks from screen_account_picker.js
- web_ui()->RegisterMessageCallback("accountPickerReady", base::DoNothing());
- web_ui()->RegisterMessageCallback("loginUIStateChanged", base::DoNothing());
- web_ui()->RegisterMessageCallback("hideCaptivePortal", base::DoNothing());
- web_ui()->RegisterMessageCallback("getTabletModeState", base::DoNothing());
- // Unused callbacks from display_manager.js
- web_ui()->RegisterMessageCallback("showAddUser", base::DoNothing());
- web_ui()->RegisterMessageCallback("updateCurrentScreen", base::DoNothing());
- web_ui()->RegisterMessageCallback("updateOobeUIState", base::DoNothing());
- web_ui()->RegisterMessageCallback("loginVisible", base::DoNothing());
- // Unused callbacks from user_pod_row.js
- web_ui()->RegisterMessageCallback("focusPod", base::DoNothing());
- web_ui()->RegisterMessageCallback("noPodFocused", base::DoNothing());
-}
-
-void UserManagerScreenHandler::OnBrowserAdded(Browser* browser) {
- // Only respond to one Browser Opened event.
- BrowserList::RemoveObserver(this);
-
- // Unlock the profile after browser opens so startup can read the lock bit.
- // Any necessary authentication must have been successful to reach this point.
- ProfileAttributesEntry* entry = nullptr;
- if (!browser->profile()->IsGuestSession()) {
- bool has_entry = g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(
- browser->profile()->GetPath(), &entry);
- DCHECK(has_entry);
- // If force sign in is enabled and profile is not signed in, do not close
- // UserManager and unlock profile.
- if (signin_util::IsForceSigninEnabled() && !entry->IsAuthenticated())
- return;
- entry->SetIsSigninRequired(false);
- }
-
- if (!url_hash_.empty()) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::BindOnce(&UrlHashHelper::ExecuteUrlHash,
- base::Owned(new UrlHashHelper(browser, url_hash_))));
- }
-
- // This call is last as it deletes this object.
- UserManager::Hide();
-}
-
-void UserManagerScreenHandler::GetLocalizedValues(
- base::DictionaryValue* localized_strings) {
- // For Control Bar.
- localized_strings->SetString("signedIn",
- l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_ACTIVE_USER));
- localized_strings->SetString("addUser",
- l10n_util::GetStringUTF16(IDS_ADD_USER_BUTTON));
- localized_strings->SetString("cancel", l10n_util::GetStringUTF16(IDS_CANCEL));
- localized_strings->SetString(
- "browseAsGuest", l10n_util::GetStringUTF16(IDS_BROWSE_AS_GUEST_BUTTON));
- localized_strings->SetString("addSupervisedUser",
- l10n_util::GetStringUTF16(IDS_CREATE_LEGACY_SUPERVISED_USER_MENU_LABEL));
-
- // For AccountPickerScreen.
- localized_strings->SetString("screenType", "login-add-user");
- localized_strings->SetString("highlightStrength", "normal");
- localized_strings->SetString("title",
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
- localized_strings->SetString("passwordHint",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_EMPTY_PASSWORD_TEXT));
- localized_strings->SetString("signingIn",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_SIGNING_IN));
- localized_strings->SetString("podMenuButtonAccessibleName",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_MENU_BUTTON_ACCESSIBLE_NAME));
- localized_strings->SetString("podMenuRemoveItemAccessibleName",
- l10n_util::GetStringUTF16(
- IDS_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME));
- localized_strings->SetString("removeUser",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON));
- localized_strings->SetString("passwordFieldAccessibleName",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_PASSWORD_FIELD_ACCESSIBLE_NAME));
-
- // For AccountPickerScreen, the remove user warning overlay.
- localized_strings->SetString("removeUserWarningButtonTitle",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON));
- localized_strings->SetString(
- "removeUserWarningTextNonSync",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC));
- localized_strings->SetString("removeUserWarningTextHistory",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_HISTORY));
- localized_strings->SetString("removeUserWarningTextPasswords",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_PASSWORDS));
- localized_strings->SetString("removeUserWarningTextBookmarks",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BOOKMARKS));
- localized_strings->SetString(
- "removeUserWarningTextAutofill",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_AUTOFILL));
- localized_strings->SetString("removeUserWarningTextCalculating",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_CALCULATING));
- localized_strings->SetString(
- "removeUserWarningTextSync",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC));
- localized_strings->SetString("removeLegacySupervisedUserWarningText",
- l10n_util::GetStringFUTF16(
- IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING,
- base::UTF8ToUTF16(
- chrome::kLegacySupervisedUserManagementDisplayURL)));
- localized_strings->SetString(
- "removeNonOwnerUserWarningText",
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_NON_OWNER_USER_REMOVE_WARNING));
-
- // Strings needed for the User Manager tutorial slides.
- localized_strings->SetString("tutorialNext",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_NEXT));
- localized_strings->SetString("tutorialDone",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_DONE));
- localized_strings->SetString("slideWelcomeTitle",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_SLIDE_INTRO_TITLE));
- localized_strings->SetString("slideWelcomeText",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_SLIDE_INTRO_TEXT));
- localized_strings->SetString("slideYourChromeTitle",
- l10n_util::GetStringUTF16(
- IDS_USER_MANAGER_TUTORIAL_SLIDE_YOUR_CHROME_TITLE));
- localized_strings->SetString("slideYourChromeText", l10n_util::GetStringUTF16(
- IDS_USER_MANAGER_TUTORIAL_SLIDE_YOUR_CHROME_TEXT));
- localized_strings->SetString("slideGuestsTitle",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_SLIDE_GUEST_TITLE));
- localized_strings->SetString("slideGuestsText",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_SLIDE_GUEST_TEXT));
- localized_strings->SetString("slideFriendsTitle",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_SLIDE_FRIENDS_TITLE));
- localized_strings->SetString("slideFriendsText",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_SLIDE_FRIENDS_TEXT));
- localized_strings->SetString("slideCompleteTitle",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_SLIDE_OUTRO_TITLE));
- localized_strings->SetString("slideCompleteText",
- l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_SLIDE_OUTRO_TEXT));
- localized_strings->SetString("slideCompleteUserNotFound",
- l10n_util::GetStringUTF16(
- IDS_USER_MANAGER_TUTORIAL_SLIDE_OUTRO_USER_NOT_FOUND));
- localized_strings->SetString("slideCompleteAddUser",
- l10n_util::GetStringUTF16(
- IDS_USER_MANAGER_TUTORIAL_SLIDE_OUTRO_ADD_USER));
-
- // Strings needed for the user_pod_template public account div, but not ever
- // actually displayed for desktop users.
- localized_strings->SetString("publicAccountReminder", "");
- localized_strings->SetString("publicSessionLanguageAndInput", "");
- localized_strings->SetString("publicAccountEnter", "");
- localized_strings->SetString("publicAccountEnterAccessibleName", "");
- localized_strings->SetString("publicAccountMonitoringWarning", "");
- localized_strings->SetString("publicAccountLearnMore", "");
- localized_strings->SetString("publicAccountMonitoringInfo", "");
- localized_strings->SetString("publicAccountMonitoringInfoItem1", "");
- localized_strings->SetString("publicAccountMonitoringInfoItem2", "");
- localized_strings->SetString("publicAccountMonitoringInfoItem3", "");
- localized_strings->SetString("publicAccountMonitoringInfoItem4", "");
- localized_strings->SetString("publicSessionSelectLanguage", "");
- localized_strings->SetString("publicSessionSelectKeyboard", "");
- localized_strings->SetString("signinBannerText", "");
- localized_strings->SetString("multiProfilesRestrictedPolicyTitle", "");
- localized_strings->SetString("multiProfilesNotAllowedPolicyMsg", "");
- localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg", "");
- localized_strings->SetString("multiProfilesOwnerPrimaryOnlyMsg", "");
-
- // Error message when trying to add a profile while all profiles are locked.
- localized_strings->SetString("addProfileAllProfilesLockedError",
- l10n_util::GetStringUTF16(
- IDS_USER_MANAGER_ADD_PROFILE_PROFILES_LOCKED_ERROR));
- // Error message when trying to browse as guest while all profiles are locked.
- localized_strings->SetString("browseAsGuestAllProfilesLockedError",
- l10n_util::GetStringUTF16(
- IDS_USER_MANAGER_GO_GUEST_PROFILES_LOCKED_ERROR));
-
- base::string16 prompt_message;
- if (signin_util::IsForceSigninEnabled()) {
- prompt_message = l10n_util::GetStringUTF16(IDS_USER_MANAGER_PROMPT_MESSAGE);
- }
-
- localized_strings->SetString("userManagerPromptMessage", prompt_message);
-}
-
-void UserManagerScreenHandler::SendUserList() {
- base::ListValue users_list;
- std::vector<ProfileAttributesEntry*> entries =
- g_browser_process->profile_manager()->GetProfileAttributesStorage().
- GetAllProfilesAttributesSortedByName();
-
- for (const ProfileAttributesEntry* entry : entries) {
- // Don't show profiles still in the middle of being set up as new legacy
- // supervised users.
- if (entry->IsOmitted())
- continue;
-
- auto profile_value = std::make_unique<base::DictionaryValue>();
- base::FilePath profile_path = entry->GetPath();
-
- profile_value->SetString(kKeyUsername, entry->GetUserName());
- profile_value->SetString(kKeyEmailAddress, entry->GetUserName());
- profile_value->SetString(kKeyDisplayName,
- profiles::GetAvatarNameForProfile(profile_path));
- profile_value->SetKey(kKeyProfilePath, util::FilePathToValue(profile_path));
- profile_value->SetBoolean(kKeyPublicAccount, false);
- profile_value->SetBoolean(kKeyLegacySupervisedUser,
- entry->IsLegacySupervised());
- profile_value->SetBoolean(kKeyChildUser, entry->IsChild());
- profile_value->SetBoolean(kKeyNeedsSignin, entry->IsSigninRequired());
- profile_value->SetBoolean(kKeyHasLocalCreds,
- !entry->GetLocalAuthCredentials().empty());
- profile_value->SetBoolean(kKeyIsOwner, false);
- profile_value->SetBoolean(kKeyCanRemove, true);
- profile_value->SetBoolean(kKeyIsDesktop, true);
- profile_value->SetString(kKeyAvatarUrl, GetAvatarImage(entry));
-
- // GetProfileByPath returns a pointer if the profile is fully loaded, NULL
- // otherwise.
- Profile* profile =
- g_browser_process->profile_manager()->GetProfileByPath(profile_path);
- profile_value->SetBoolean(kKeyIsProfileLoaded, profile != nullptr);
-
- users_list.Append(std::move(profile_value));
- }
-
- web_ui()->CallJavascriptFunctionUnsafe("login.AccountPickerScreen.loadUsers",
- users_list,
- base::Value(IsGuestModeEnabled()));
-
- // This is the latest C++ code we have in the flow to show the UserManager.
- // This may be invoked more than once per UserManager lifetime; the
- // UserManager will ensure all relevant logging only happens once.
- UserManager::OnUserManagerShown();
-}
-
-void UserManagerScreenHandler::ReportAuthenticationResult(
- bool success,
- ProfileMetrics::ProfileAuth auth) {
- email_address_.clear();
-
- if (success) {
- profiles::SwitchToProfile(
- authenticating_profile_path_, true,
- base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
- weak_ptr_factory_.GetWeakPtr()));
- } else {
- web_ui()->CallJavascriptFunctionUnsafe(
- "cr.ui.UserManager.showSignInError", base::Value(0),
- base::Value(l10n_util::GetStringUTF8(
- auth == ProfileMetrics::AUTH_FAILED_OFFLINE
- ? IDS_LOGIN_ERROR_AUTHENTICATING_OFFLINE
- : IDS_LOGIN_ERROR_AUTHENTICATING)),
- base::Value(""), base::Value(0));
- }
-}
-
-// This callback is run after switching to a new profile has finished. This
-// means either a new browser has been created (but not the window), or an
-// existing one has been found. The HideUserManager task needs to be posted
-// since closing the User Manager before the window is created can flakily
-// cause Chrome to close.
-void UserManagerScreenHandler::OnSwitchToProfileComplete(
- Profile* profile, Profile::CreateStatus profile_create_status) {
- Browser* browser = chrome::FindAnyBrowser(profile, false);
- if (browser && browser->window())
- OnBrowserAdded(browser);
- else
- BrowserList::AddObserver(this);
-}
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h b/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h
deleted file mode 100644
index 87dc7337a26..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright 2013 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_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_
-
-#include <map>
-#include <memory>
-#include <string>
-
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/task/cancelable_task_tracker.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_metrics.h"
-#include "chrome/browser/profiles/profile_statistics.h"
-#include "chrome/browser/ui/browser_list_observer.h"
-#include "content/public/browser/web_ui_message_handler.h"
-#include "google_apis/gaia/gaia_oauth_client.h"
-
-class Browser;
-
-namespace base {
-class DictionaryValue;
-class FilePath;
-class ListValue;
-}
-
-extern const char kAuthenticatedLaunchUserEventMetricsName[];
-
-// UI event when user click a locked profile. It must matches the
-// AuthenticatedLaunchUserEvent in enums.xml
-enum AuthenticatedLaunchUserEvent {
- LOCAL_REAUTH_DIALOG,
- GAIA_REAUTH_DIALOG,
- SUPERVISED_PROFILE_BLOCKED_WARNING,
- USED_PROFILE_BLOCKED_WARNING,
- FORCED_PRIMARY_SIGNIN_DIALOG,
- EVENT_COUNT,
-};
-
-class UserManagerScreenHandler : public content::WebUIMessageHandler,
- public BrowserListObserver,
- public gaia::GaiaOAuthClient::Delegate {
- public:
- UserManagerScreenHandler();
- ~UserManagerScreenHandler() override;
-
- void GetLocalizedValues(base::DictionaryValue* localized_strings);
-
- private:
- // An observer for any changes to Profiles in the ProfileAttributesStorage so
- // that all the visible user manager screens can be updated.
- class ProfileUpdateObserver;
-
- // WebUIMessageHandler:
- void RegisterMessages() override;
-
- // BrowserListObserver:
- void OnBrowserAdded(Browser* browser) override;
-
- void HandleInitialize(const base::ListValue* args);
- void HandleAuthenticatedLaunchUser(const base::ListValue* args);
- void HandleLaunchGuest(const base::ListValue* args);
- void HandleLaunchUser(const base::ListValue* args);
- void HandleRemoveUser(const base::ListValue* args);
- void HandleAreAllProfilesLocked(const base::ListValue* args);
- void HandleRemoveUserWarningLoadStats(const base::ListValue* args);
-
- // Function used to gather statistics from a profile.
- void GatherStatistics(base::Time start_time, Profile* profile);
-
- // Callback function used by HandleRemoveUserWarningLoadStats
- void RemoveUserDialogLoadStatsCallback(base::FilePath profile_path,
- base::Time start_time,
- profiles::ProfileCategoryStats result);
-
- // gaia::GaiaOAuthClient::Delegate:
- void OnGetTokenInfoResponse(
- std::unique_ptr<base::DictionaryValue> token_info) override;
- void OnOAuthError() override;
- void OnNetworkError(int response_code) override;
-
- // Sends user list to account chooser.
- void SendUserList();
-
- // Pass success/failure information back to the web page.
- void ReportAuthenticationResult(bool success,
- ProfileMetrics::ProfileAuth metric);
-
- // Perform cleanup once the profile and browser are open.
- void OnSwitchToProfileComplete(Profile* profile,
- Profile::CreateStatus profile_create_status);
-
- // Observes the ProfileAttributesStorage and gets notified when a profile has
- // been modified, so that the displayed user pods can be updated.
- std::unique_ptr<ProfileUpdateObserver> profile_attributes_storage_observer_;
-
- // Authenticator used when local-auth fails.
- std::unique_ptr<gaia::GaiaOAuthClient> oauth_client_;
-
- // The path of the profile currently being authenticated.
- base::FilePath authenticating_profile_path_;
-
- // Login email held during on-line auth for later use.
- std::string email_address_;
-
- // URL hash, used to key post-profile actions if present.
- std::string url_hash_;
-
- // The CancelableTaskTracker is currently used by GetProfileStatistics
- base::CancelableTaskTracker tracker_;
-
- base::WeakPtrFactory<UserManagerScreenHandler> weak_ptr_factory_{this};
-
- DISALLOW_COPY_AND_ASSIGN(UserManagerScreenHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_ui.cc b/chromium/chrome/browser/ui/webui/signin/user_manager_ui.cc
deleted file mode 100644
index c7c8799b868..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/user_manager_ui.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2016 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/signin/user_manager_ui.h"
-
-#include <memory>
-#include <string>
-
-#include "base/feature_list.h"
-#include "base/values.h"
-#include "build/branding_buildflags.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_shortcut_manager.h"
-#include "chrome/browser/signin/signin_util.h"
-#include "chrome/browser/ui/webui/signin/signin_create_profile_handler.h"
-#include "chrome/browser/ui/webui/signin/signin_utils.h"
-#include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
-#include "chrome/browser/ui/webui/theme_source.h"
-#include "chrome/browser/ui/webui/webui_util.h"
-#include "chrome/common/buildflags.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/browser_resources.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/webui/web_ui_util.h"
-
-UserManagerUI::UserManagerUI(content::WebUI* web_ui) : WebUIController(web_ui) {
- auto signin_create_profile_handler =
- std::make_unique<SigninCreateProfileHandler>();
- signin_create_profile_handler_ = signin_create_profile_handler.get();
- web_ui->AddMessageHandler(std::move(signin_create_profile_handler));
- auto user_manager_screen_handler =
- std::make_unique<UserManagerScreenHandler>();
- user_manager_screen_handler_ = user_manager_screen_handler.get();
- web_ui->AddMessageHandler(std::move(user_manager_screen_handler));
-
- base::DictionaryValue localized_strings;
- GetLocalizedStrings(&localized_strings);
-
- Profile* profile = Profile::FromWebUI(web_ui);
-
- // Set up the chrome://md-user-manager/ source.
- content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings));
-
- // Set up the chrome://theme/ source
- content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
-}
-
-UserManagerUI::~UserManagerUI() {}
-
-content::WebUIDataSource* UserManagerUI::CreateUIDataSource(
- const base::DictionaryValue& localized_strings) {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIMdUserManagerHost);
-
- source->DisableTrustedTypesCSP();
-
- source->AddLocalizedStrings(localized_strings);
- source->AddBoolean("profileShortcutsEnabled",
- ProfileShortcutManager::IsFeatureEnabled());
- source->AddBoolean("isForceSigninEnabled",
- signin_util::IsForceSigninEnabled());
-
- source->UseStringsJs();
-
- static constexpr webui::ResourcePath kResources[] = {
- {"control_bar.html", IDR_CONTROL_BAR_HTML},
- {"control_bar.js", IDR_CONTROL_BAR_JS},
- {"create_profile.html", IDR_CREATE_PROFILE_HTML},
- {"create_profile.js", IDR_CREATE_PROFILE_JS},
- {"error_dialog.html", IDR_ERROR_DIALOG_HTML},
- {"error_dialog.js", IDR_ERROR_DIALOG_JS},
- {"profile_browser_proxy.html", IDR_PROFILE_BROWSER_PROXY_HTML},
- {"profile_browser_proxy.js", IDR_PROFILE_BROWSER_PROXY_JS},
- {"shared_styles.html", IDR_USER_MANAGER_SHARED_STYLES_HTML},
- {"strings.html", IDR_USER_MANAGER_STRINGS_HTML},
- {"user_manager.js", IDR_USER_MANAGER_JS},
- {"user_manager_pages.html", IDR_USER_MANAGER_PAGES_HTML},
- {"user_manager_pages.js", IDR_USER_MANAGER_PAGES_JS},
- {"user_manager_tutorial.html", IDR_USER_MANAGER_TUTORIAL_HTML},
- {"user_manager_tutorial.js", IDR_USER_MANAGER_TUTORIAL_JS},
- };
- webui::AddResourcePathsBulk(source, kResources);
-
- source->SetDefaultResource(IDR_USER_MANAGER_HTML);
-
- return source;
-}
-
-void UserManagerUI::GetLocalizedStrings(
- base::DictionaryValue* localized_strings) {
- user_manager_screen_handler_->GetLocalizedValues(localized_strings);
- signin_create_profile_handler_->GetLocalizedValues(localized_strings);
- const std::string& app_locale = g_browser_process->GetApplicationLocale();
- webui::SetLoadTimeDataDefaults(app_locale, localized_strings);
-
-#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
- localized_strings->SetString("buildType", "chrome");
-#else
- localized_strings->SetString("buildType", "chromium");
-#endif
-}
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_ui.h b/chromium/chrome/browser/ui/webui/signin/user_manager_ui.h
deleted file mode 100644
index 3a346cfd302..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/user_manager_ui.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2016 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_SIGNIN_USER_MANAGER_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_UI_H_
-
-#include "base/macros.h"
-#include "content/public/browser/web_ui_controller.h"
-
-class SigninCreateProfileHandler;
-class UserManagerScreenHandler;
-
-namespace base {
-class DictionaryValue;
-}
-namespace content {
-class WebUIDataSource;
-}
-
-// A WebUI dialog to display available users.
-class UserManagerUI : public content::WebUIController {
- public:
- explicit UserManagerUI(content::WebUI* web_ui);
- ~UserManagerUI() override;
-
- private:
- content::WebUIDataSource* CreateUIDataSource(
- const base::DictionaryValue& localized_strings);
- void GetLocalizedStrings(base::DictionaryValue* localized_strings);
-
- SigninCreateProfileHandler* signin_create_profile_handler_ = nullptr;
- UserManagerScreenHandler* user_manager_screen_handler_ = nullptr;
-
- DISALLOW_COPY_AND_ASSIGN(UserManagerUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
deleted file mode 100644
index 56594542eac..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
+++ /dev/null
@@ -1,237 +0,0 @@
-// Copyright 2013 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/bind.h"
-#include "base/command_line.h"
-#include "base/run_loop.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/test/metrics/histogram_tester.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/profiles/profile_window.h"
-#include "chrome/browser/profiles/profiles_state.h"
-#include "chrome/browser/signin/signin_util.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/browser/ui/webui/signin/login_ui_service.h"
-#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
-#include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/chromium_strings.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/testing_browser_process.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/test/browser_test.h"
-#include "content/public/test/browser_test_utils.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/l10n/l10n_util.h"
-
-using ::testing::_;
-
-class MockLoginUIService : public LoginUIService {
- public:
- explicit MockLoginUIService(content::BrowserContext* context)
- : LoginUIService(static_cast<Profile*>(context)) {}
- ~MockLoginUIService() override {}
- MOCK_METHOD3(DisplayLoginResult,
- void(Browser* browser,
- const base::string16& error_message,
- const base::string16& email));
- MOCK_METHOD0(SetProfileBlockingErrorMessage, void(void));
-};
-
-std::unique_ptr<KeyedService> CreateLoginUIService(
- content::BrowserContext* context) {
- return std::make_unique<MockLoginUIService>(context);
-}
-
-class UserManagerUIBrowserTest : public InProcessBrowserTest,
- public testing::WithParamInterface<bool> {
- public:
- UserManagerUIBrowserTest() {}
-};
-
-IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, PageLoads) {
- ui_test_utils::NavigateToURL(
- browser(), GURL(chrome::kChromeUIMdUserManagerUrl));
- content::WebContents* web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
-
- base::string16 title = web_contents->GetTitle();
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), title);
-
- // If the page has loaded correctly, then there should be an account picker.
- int num_account_pickers = -1;
- ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
- web_contents,
- "domAutomationController.send("
- "document.getElementsByClassName('account-picker').length)",
- &num_account_pickers));
- EXPECT_EQ(1, num_account_pickers);
-
- int num_pods = -1;
- ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
- web_contents,
- "domAutomationController.send("
- "parseInt(document.getElementById('pod-row').getAttribute('ncolumns')))",
- &num_pods));
-
- // There should be one user pod for each profile.
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- EXPECT_EQ(num_pods, static_cast<int>(profile_manager->GetNumberOfProfiles()));
-}
-
-// https://crbug.com/945795
-IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest,
- DISABLED_PageRedirectsToAboutChrome) {
- std::string user_manager_url = chrome::kChromeUIMdUserManagerUrl;
- user_manager_url += profiles::kUserManagerSelectProfileAboutChrome;
-
- ui_test_utils::NavigateToURL(browser(), GURL(user_manager_url));
- content::WebContents* web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
-
- // If this is a Windows style path, escape all the slashes.
- std::string profile_path;
- base::ReplaceChars(browser()->profile()->GetPath().MaybeAsASCII(),
- "\\", "\\\\", &profile_path);
-
- std::string launch_js =
- base::StringPrintf("Oobe.launchUser('%s')", profile_path.c_str());
-
- bool result = content::ExecuteScript(web_contents, launch_js);
- EXPECT_TRUE(result);
- base::RunLoop().RunUntilIdle();
-
- content::WebContents* about_chrome_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- GURL current_URL = about_chrome_contents->GetVisibleURL();
- EXPECT_EQ(GURL(chrome::kChromeUIHelpURL), current_URL);
-}
-
-class UserManagerUIAuthenticatedUserBrowserTest
- : public UserManagerUIBrowserTest {
- public:
- void Init() {
- ui_test_utils::NavigateToURL(browser(),
- GURL(chrome::kChromeUIMdUserManagerUrl));
- web_contents_ = browser()->tab_strip_model()->GetActiveWebContents();
- profile_ = browser()->profile();
- EXPECT_TRUE(
- g_browser_process->profile_manager()
- ->GetProfileAttributesStorage()
- .GetProfileAttributesWithPath(profile_->GetPath(), &entry_));
- }
-
- void LaunchAuthenticatedUser(const std::string& email) {
- std::string profile_path;
- base::ReplaceChars(profile_->GetPath().MaybeAsASCII(), "\\", "\\\\",
- &profile_path);
- std::string launch_js = base::StringPrintf(
- "chrome.send('authenticatedLaunchUser', ['%s', '%s', ''])",
- profile_path.c_str(), email.c_str());
- EXPECT_TRUE(content::ExecuteScript(web_contents_, launch_js));
- }
-
- content::WebContents* web_contents_;
- Profile* profile_;
- ProfileAttributesEntry* entry_;
- base::HistogramTester histogram_tester_;
-};
-
-IN_PROC_BROWSER_TEST_F(UserManagerUIAuthenticatedUserBrowserTest, Reauth) {
- Init();
- signin_util::SetForceSigninForTesting(true);
- entry_->SetLocalAuthCredentials("1mock_credentials");
- // Consent profile's primary account.
- entry_->SetAuthInfo("gaia_id", base::string16(), true);
-
- LaunchAuthenticatedUser("email@mock.com");
-
- histogram_tester_.ExpectBucketCount(
- kAuthenticatedLaunchUserEventMetricsName,
- AuthenticatedLaunchUserEvent::LOCAL_REAUTH_DIALOG, 1);
- histogram_tester_.ExpectBucketCount(
- kAuthenticatedLaunchUserEventMetricsName,
- AuthenticatedLaunchUserEvent::GAIA_REAUTH_DIALOG, 1);
- histogram_tester_.ExpectTotalCount(kAuthenticatedLaunchUserEventMetricsName,
- 2);
-}
-
-IN_PROC_BROWSER_TEST_F(UserManagerUIAuthenticatedUserBrowserTest,
- SigninButUnconsentedUserBlocked) {
- Init();
- signin_util::SetForceSigninForTesting(true);
-
- // Unconsent profile's primary account is used locked due to force sign in.
- entry_->SetIsSigninRequired(true);
- entry_->SetActiveTimeToNow();
- entry_->SetAuthInfo("gaia_id", base::string16(), false);
-
- MockLoginUIService* service = static_cast<MockLoginUIService*>(
- LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_, base::BindRepeating(&CreateLoginUIService)));
- EXPECT_CALL(*service, SetProfileBlockingErrorMessage());
-
- LaunchAuthenticatedUser("email@mock.com");
-
- histogram_tester_.ExpectUniqueSample(
- kAuthenticatedLaunchUserEventMetricsName,
- AuthenticatedLaunchUserEvent::USED_PROFILE_BLOCKED_WARNING, 1);
- signin_util::ResetForceSigninForTesting();
-}
-
-IN_PROC_BROWSER_TEST_F(UserManagerUIAuthenticatedUserBrowserTest,
- SupervisedUserBlocked) {
- Init();
- entry_->SetIsSigninRequired(true);
- entry_->SetSupervisedUserId("supervised_user_id");
- MockLoginUIService* service = static_cast<MockLoginUIService*>(
- LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_, base::BindRepeating(&CreateLoginUIService)));
- EXPECT_CALL(*service, DisplayLoginResult(_, _, _));
-
- LaunchAuthenticatedUser("");
- histogram_tester_.ExpectUniqueSample(
- kAuthenticatedLaunchUserEventMetricsName,
- AuthenticatedLaunchUserEvent::SUPERVISED_PROFILE_BLOCKED_WARNING, 1);
-}
-
-IN_PROC_BROWSER_TEST_F(UserManagerUIAuthenticatedUserBrowserTest,
- NormalUserBlocked) {
- Init();
- signin_util::SetForceSigninForTesting(true);
- entry_->SetIsSigninRequired(true);
- entry_->SetActiveTimeToNow();
- MockLoginUIService* service = static_cast<MockLoginUIService*>(
- LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_, base::BindRepeating(&CreateLoginUIService)));
- EXPECT_CALL(*service, SetProfileBlockingErrorMessage());
-
- LaunchAuthenticatedUser("");
-
- histogram_tester_.ExpectUniqueSample(
- kAuthenticatedLaunchUserEventMetricsName,
- AuthenticatedLaunchUserEvent::USED_PROFILE_BLOCKED_WARNING, 1);
- signin_util::ResetForceSigninForTesting();
-}
-
-IN_PROC_BROWSER_TEST_F(UserManagerUIAuthenticatedUserBrowserTest,
- ForcedPrimarySignin) {
- Init();
- signin_util::SetForceSigninForTesting(true);
-
- LaunchAuthenticatedUser("");
-
- histogram_tester_.ExpectUniqueSample(
- kAuthenticatedLaunchUserEventMetricsName,
- AuthenticatedLaunchUserEvent::FORCED_PRIMARY_SIGNIN_DIALOG, 1);
-}
-
-// TODO(mlerman): Test that unlocking a locked profile causes the extensions
-// service to become unblocked.
diff --git a/chromium/chrome/browser/ui/webui/supervised_user_internals_ui.h b/chromium/chrome/browser/ui/webui/supervised_user_internals_ui.h
deleted file mode 100644
index ff12e938ac0..00000000000
--- a/chromium/chrome/browser/ui/webui/supervised_user_internals_ui.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2015 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_SUPERVISED_USER_INTERNALS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SUPERVISED_USER_INTERNALS_UI_H_
-
-#include "base/macros.h"
-#include "content/public/browser/web_ui_controller.h"
-
-// The implementation for the chrome://supervised-user-internals page.
-class SupervisedUserInternalsUI : public content::WebUIController {
- public:
- explicit SupervisedUserInternalsUI(content::WebUI* web_ui);
- ~SupervisedUserInternalsUI() override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SupervisedUserInternalsUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SUPERVISED_USER_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/DIR_METADATA b/chromium/chrome/browser/ui/webui/sync_file_system_internals/DIR_METADATA
new file mode 100644
index 00000000000..0f092479c54
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/DIR_METADATA
@@ -0,0 +1,4 @@
+monorail {
+ component: "Blink>Storage>FileSystem"
+}
+team_email: "storage-dev@chromium.org"
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS b/chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS
index 0d7e100e97d..20f262936de 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS
@@ -2,6 +2,3 @@ calvinlo@chromium.org
kinuko@chromium.org
nhiroki@chromium.org
pwnall@chromium.org
-
-# TEAM: storage-dev@chromium.org
-# COMPONENT: Blink>Storage>FileSystem
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.cc b/chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.cc
index 5f2cc65f9ef..93669a82fd9 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.cc
@@ -22,24 +22,24 @@ DumpDatabaseHandler::~DumpDatabaseHandler() {}
void DumpDatabaseHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"getDatabaseDump",
- base::BindRepeating(&DumpDatabaseHandler::GetDatabaseDump,
+ base::BindRepeating(&DumpDatabaseHandler::HandleGetDatabaseDump,
base::Unretained(this)));
}
-void DumpDatabaseHandler::GetDatabaseDump(const base::ListValue*) {
- std::unique_ptr<base::ListValue> list;
+void DumpDatabaseHandler::HandleGetDatabaseDump(const base::ListValue* args) {
+ AllowJavascript();
sync_file_system::SyncFileSystemService* sync_service =
SyncFileSystemServiceFactory::GetForProfile(profile_);
if (sync_service) {
- sync_service->DumpDatabase(
- base::Bind(&DumpDatabaseHandler::DidGetDatabaseDump,
- base::Unretained(this)));
+ sync_service->DumpDatabase(base::AdaptCallbackForRepeating(base::BindOnce(
+ &DumpDatabaseHandler::DidGetDatabaseDump, base::Unretained(this),
+ args->GetList()[0].GetString() /* callback_id */)));
}
}
-void DumpDatabaseHandler::DidGetDatabaseDump(const base::ListValue& list) {
- web_ui()->CallJavascriptFunctionUnsafe("DumpDatabase.onGetDatabaseDump",
- list);
+void DumpDatabaseHandler::DidGetDatabaseDump(std::string callback_id,
+ const base::ListValue& list) {
+ ResolveJavascriptCallback(base::Value(callback_id), list);
}
} // namespace syncfs_internals
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.h b/chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.h
index d59091314dc..cf0d02a2e87 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.h
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/dump_database_handler.h
@@ -22,8 +22,8 @@ class DumpDatabaseHandler : public content::WebUIMessageHandler {
void RegisterMessages() override;
private:
- void GetDatabaseDump(const base::ListValue* args);
- void DidGetDatabaseDump(const base::ListValue& list);
+ void HandleGetDatabaseDump(const base::ListValue* args);
+ void DidGetDatabaseDump(std::string callback_id, const base::ListValue& list);
Profile* profile_;
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 4bba1bc4040..a3d83c0c8ad 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,10 +35,10 @@ namespace {
// ExtensionStatusesHandler and FileMetadataHandler.
void ConvertExtensionStatusToDictionary(
const base::WeakPtr<extensions::ExtensionService>& extension_service,
- const base::Callback<void(const base::ListValue&)>& callback,
+ base::OnceCallback<void(const base::ListValue&)> callback,
const std::map<GURL, std::string>& status_map) {
if (!extension_service) {
- callback.Run(base::ListValue());
+ std::move(callback).Run(base::ListValue());
return;
}
@@ -63,7 +63,7 @@ void ConvertExtensionStatusToDictionary(
list.Append(std::move(dict));
}
- callback.Run(list);
+ std::move(callback).Run(list);
}
} // namespace
@@ -76,48 +76,50 @@ ExtensionStatusesHandler::~ExtensionStatusesHandler() {}
void ExtensionStatusesHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"getExtensionStatuses",
- base::BindRepeating(&ExtensionStatusesHandler::GetExtensionStatuses,
+ base::BindRepeating(&ExtensionStatusesHandler::HandleGetExtensionStatuses,
base::Unretained(this)));
}
// static
void ExtensionStatusesHandler::GetExtensionStatusesAsDictionary(
Profile* profile,
- const base::Callback<void(const base::ListValue&)>& callback) {
+ base::OnceCallback<void(const base::ListValue&)> callback) {
DCHECK(profile);
sync_file_system::SyncFileSystemService* sync_service =
SyncFileSystemServiceFactory::GetForProfile(profile);
if (!sync_service) {
- callback.Run(base::ListValue());
+ std::move(callback).Run(base::ListValue());
return;
}
extensions::ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile)->extension_service();
if (!extension_service) {
- callback.Run(base::ListValue());
+ std::move(callback).Run(base::ListValue());
return;
}
- sync_service->GetExtensionStatusMap(base::Bind(
- &ConvertExtensionStatusToDictionary,
- extension_service->AsWeakPtr(), callback));
+ sync_service->GetExtensionStatusMap(
+ base::BindOnce(&ConvertExtensionStatusToDictionary,
+ extension_service->AsWeakPtr(), std::move(callback)));
}
-void ExtensionStatusesHandler::GetExtensionStatuses(
+void ExtensionStatusesHandler::HandleGetExtensionStatuses(
const base::ListValue* args) {
+ AllowJavascript();
DCHECK(args);
GetExtensionStatusesAsDictionary(
profile_,
- base::Bind(&ExtensionStatusesHandler::DidGetExtensionStatuses,
- weak_ptr_factory_.GetWeakPtr()));
+ base::BindOnce(&ExtensionStatusesHandler::DidGetExtensionStatuses,
+ weak_ptr_factory_.GetWeakPtr(),
+ args->GetList()[0].GetString() /* callback_id */));
}
void ExtensionStatusesHandler::DidGetExtensionStatuses(
+ std::string callback_id,
const base::ListValue& list) {
- web_ui()->CallJavascriptFunctionUnsafe(
- "ExtensionStatuses.onGetExtensionStatuses", list);
+ ResolveJavascriptCallback(base::Value(callback_id), list);
}
} // namespace syncfs_internals
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 60880338cc5..19b0c95846b 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
@@ -27,14 +27,15 @@ class ExtensionStatusesHandler : public content::WebUIMessageHandler {
// extension drop down.
static void GetExtensionStatusesAsDictionary(
Profile* profile,
- const base::Callback<void(const base::ListValue&)>& callback);
+ base::OnceCallback<void(const base::ListValue&)> callback);
// WebUIMessageHandler implementation.
void RegisterMessages() override;
private:
- void GetExtensionStatuses(const base::ListValue* args);
- void DidGetExtensionStatuses(const base::ListValue& list);
+ void HandleGetExtensionStatuses(const base::ListValue* args);
+ void DidGetExtensionStatuses(std::string callback_id,
+ const base::ListValue& list);
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 173d9dd5252..3bfd716580a 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
@@ -32,18 +32,20 @@ FileMetadataHandler::~FileMetadataHandler() {}
void FileMetadataHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "getExtensions", base::BindRepeating(&FileMetadataHandler::GetExtensions,
- base::Unretained(this)));
+ "getExtensions",
+ base::BindRepeating(&FileMetadataHandler::HandleGetExtensions,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getFileMetadata",
- base::BindRepeating(&FileMetadataHandler::GetFileMetadata,
+ base::BindRepeating(&FileMetadataHandler::HandleGetFileMetadata,
base::Unretained(this)));
}
-void FileMetadataHandler::GetFileMetadata(
- const base::ListValue* args) {
- std::string extension_id;
- if (!args->GetString(0, &extension_id) || extension_id.empty()) {
+void FileMetadataHandler::HandleGetFileMetadata(const base::ListValue* args) {
+ AllowJavascript();
+ std::string callback_id = args->GetList()[0].GetString();
+ std::string extension_id = args->GetList()[1].GetString();
+ if (extension_id.empty()) {
LOG(WARNING) << "GetFileMetadata() Extension ID wasn't given";
return;
}
@@ -58,26 +60,30 @@ void FileMetadataHandler::GetFileMetadata(
SyncFileSystemServiceFactory::GetForProfile(profile_);
if (!sync_service)
return;
- sync_service->DumpFiles(origin,
- base::Bind(&FileMetadataHandler::DidGetFileMetadata,
- weak_factory_.GetWeakPtr()));
+ sync_service->DumpFiles(
+ origin, base::AdaptCallbackForRepeating(
+ base::BindOnce(&FileMetadataHandler::DidGetFileMetadata,
+ weak_factory_.GetWeakPtr(), callback_id)));
}
-void FileMetadataHandler::GetExtensions(const base::ListValue* args) {
+void FileMetadataHandler::HandleGetExtensions(const base::ListValue* args) {
+ AllowJavascript();
DCHECK(args);
ExtensionStatusesHandler::GetExtensionStatusesAsDictionary(
profile_,
- base::Bind(&FileMetadataHandler::DidGetExtensions,
- weak_factory_.GetWeakPtr()));
+ base::BindOnce(&FileMetadataHandler::DidGetExtensions,
+ weak_factory_.GetWeakPtr(),
+ args->GetList()[0].GetString() /* callback_id */));
}
-void FileMetadataHandler::DidGetExtensions(const base::ListValue& list) {
- web_ui()->CallJavascriptFunctionUnsafe("FileMetadata.onGetExtensions", list);
+void FileMetadataHandler::DidGetExtensions(std::string callback_id,
+ const base::ListValue& list) {
+ ResolveJavascriptCallback(base::Value(callback_id), list);
}
-void FileMetadataHandler::DidGetFileMetadata(const base::ListValue& files) {
- web_ui()->CallJavascriptFunctionUnsafe("FileMetadata.onGetFileMetadata",
- files);
+void FileMetadataHandler::DidGetFileMetadata(std::string callback_id,
+ const base::ListValue& files) {
+ ResolveJavascriptCallback(base::Value(callback_id), files);
}
} // namespace syncfs_internals
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 5a387e05e12..64d6e08c7aa 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
@@ -31,11 +31,12 @@ class FileMetadataHandler : public content::WebUIMessageHandler {
void RegisterMessages() override;
private:
- void GetExtensions(const base::ListValue* args);
- void DidGetExtensions(const base::ListValue& list);
+ void HandleGetExtensions(const base::ListValue* args);
+ void DidGetExtensions(std::string callback_id, const base::ListValue& list);
- void GetFileMetadata(const base::ListValue* args);
- void DidGetFileMetadata(const base::ListValue& files);
+ void HandleGetFileMetadata(const base::ListValue* args);
+ void DidGetFileMetadata(std::string callback_id,
+ const base::ListValue& files);
Profile* profile_;
base::WeakPtrFactory<FileMetadataHandler> weak_factory_{this};
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 826b133c48c..ad56afd938c 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
@@ -54,23 +54,25 @@ SyncFileSystemInternalsHandler::~SyncFileSystemInternalsHandler() {
void SyncFileSystemInternalsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"getServiceStatus",
- base::BindRepeating(&SyncFileSystemInternalsHandler::GetServiceStatus,
- base::Unretained(this)));
+ base::BindRepeating(
+ &SyncFileSystemInternalsHandler::HandleGetServiceStatus,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "getLog", base::BindRepeating(&SyncFileSystemInternalsHandler::GetLog,
- base::Unretained(this)));
+ "getLog",
+ base::BindRepeating(&SyncFileSystemInternalsHandler::HandleGetLog,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"clearLogs",
- base::BindRepeating(&SyncFileSystemInternalsHandler::ClearLogs,
+ base::BindRepeating(&SyncFileSystemInternalsHandler::HandleClearLogs,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getNotificationSource",
base::BindRepeating(
- &SyncFileSystemInternalsHandler::GetNotificationSource,
+ &SyncFileSystemInternalsHandler::HandleGetNotificationSource,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"observeTaskLog",
- base::BindRepeating(&SyncFileSystemInternalsHandler::ObserveTaskLog,
+ base::BindRepeating(&SyncFileSystemInternalsHandler::HandleObserveTaskLog,
base::Unretained(this)));
}
@@ -85,8 +87,7 @@ void SyncFileSystemInternalsHandler::OnSyncStateUpdated(
// TODO(calvinlo): OnSyncStateUpdated should be updated to also provide the
// notification mechanism (XMPP or Polling).
- web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetServiceStatus",
- base::Value(state_string));
+ FireWebUIListener("service-status-changed", base::Value(state_string));
}
void SyncFileSystemInternalsHandler::OnFileSynced(
@@ -108,11 +109,12 @@ void SyncFileSystemInternalsHandler::OnLogRecorded(
std::unique_ptr<base::ListValue> details(new base::ListValue);
details->AppendStrings(task_log.details);
dict.Set("details", std::move(details));
- web_ui()->CallJavascriptFunctionUnsafe("TaskLog.onTaskLogRecorded", dict);
+ FireWebUIListener("task-log-recorded", dict);
}
-void SyncFileSystemInternalsHandler::GetServiceStatus(
+void SyncFileSystemInternalsHandler::HandleGetServiceStatus(
const base::ListValue* args) {
+ AllowJavascript();
SyncServiceState state_enum = sync_file_system::SYNC_SERVICE_DISABLED;
sync_file_system::SyncFileSystemService* sync_service =
SyncFileSystemServiceFactory::GetForProfile(profile_);
@@ -120,29 +122,30 @@ void SyncFileSystemInternalsHandler::GetServiceStatus(
state_enum = sync_service->GetSyncServiceState();
const std::string state_string = chrome_apps::api::sync_file_system::ToString(
chrome_apps::api::SyncServiceStateToExtensionEnum(state_enum));
- web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetServiceStatus",
- base::Value(state_string));
+ ResolveJavascriptCallback(args->GetList()[0] /* callback_id */,
+ base::Value(state_string));
}
-void SyncFileSystemInternalsHandler::GetNotificationSource(
+void SyncFileSystemInternalsHandler::HandleGetNotificationSource(
const base::ListValue* args) {
+ AllowJavascript();
drive::DriveNotificationManager* drive_notification_manager =
drive::DriveNotificationManagerFactory::FindForBrowserContext(profile_);
if (!drive_notification_manager)
return;
bool xmpp_enabled = drive_notification_manager->push_notification_enabled();
std::string notification_source = xmpp_enabled ? "XMPP" : "Polling";
- web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetNotificationSource",
- base::Value(notification_source));
+ ResolveJavascriptCallback(args->GetList()[0] /* callback_id */,
+ base::Value(notification_source));
}
-void SyncFileSystemInternalsHandler::GetLog(
- const base::ListValue* args) {
+void SyncFileSystemInternalsHandler::HandleGetLog(const base::ListValue* args) {
+ AllowJavascript();
const std::vector<EventLogger::Event> log =
sync_file_system::util::GetLogHistory();
int last_log_id_sent;
- if (!args->GetInteger(0, &last_log_id_sent))
+ if (!args->GetInteger(1, &last_log_id_sent))
last_log_id_sent = -1;
// Collate events which haven't been sent to WebUI yet.
@@ -162,14 +165,15 @@ void SyncFileSystemInternalsHandler::GetLog(
if (list.empty())
return;
- web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetLog", list);
+ ResolveJavascriptCallback(args->GetList()[0] /* callback_id */, list);
}
-void SyncFileSystemInternalsHandler::ClearLogs(const base::ListValue* args) {
+void SyncFileSystemInternalsHandler::HandleClearLogs(
+ const base::ListValue* args) {
sync_file_system::util::ClearLog();
}
-void SyncFileSystemInternalsHandler::ObserveTaskLog(
+void SyncFileSystemInternalsHandler::HandleObserveTaskLog(
const base::ListValue* args) {
sync_file_system::SyncFileSystemService* sync_service =
SyncFileSystemServiceFactory::GetForProfile(profile_);
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h b/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h
index bbfe6106ab4..7c532d4bd8f 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h
@@ -47,11 +47,11 @@ class SyncFileSystemInternalsHandler
const sync_file_system::TaskLogger::TaskLog& task_log) override;
private:
- void GetServiceStatus(const base::ListValue* args);
- void GetNotificationSource(const base::ListValue* args);
- void GetLog(const base::ListValue* args);
- void ClearLogs(const base::ListValue* args);
- void ObserveTaskLog(const base::ListValue* args);
+ void HandleGetServiceStatus(const base::ListValue* args);
+ void HandleGetNotificationSource(const base::ListValue* args);
+ void HandleGetLog(const base::ListValue* args);
+ void HandleClearLogs(const base::ListValue* args);
+ void HandleObserveTaskLog(const base::ListValue* args);
Profile* profile_;
bool observing_task_log_;
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.cc b/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.cc
index bdc01392797..4cd5ff6fd41 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.cc
@@ -11,8 +11,10 @@
#include "chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.h"
#include "chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.h"
#include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/sync_file_system_internals_resources.h"
+#include "chrome/grit/sync_file_system_internals_resources_map.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -23,20 +25,9 @@ content::WebUIDataSource* CreateSyncFileSystemInternalsHTMLSource() {
content::WebUIDataSource::Create(
chrome::kChromeUISyncFileSystemInternalsHost);
source->UseStringsJs();
- source->AddResourcePath(
- "utils.js",
- IDR_SYNC_FILE_SYSTEM_INTERNALS_UTILS_JS);
- source->AddResourcePath(
- "extension_statuses.js",
- IDR_SYNC_FILE_SYSTEM_INTERNALS_EXTENSION_STATUSES_JS);
- source->AddResourcePath(
- "file_metadata.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_FILE_METADATA_JS);
- source->AddResourcePath(
- "sync_service.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_SYNC_SERVICE_JS);
- source->AddResourcePath(
- "task_log.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_TASK_LOG_JS);
- source->AddResourcePath(
- "dump_database.js", IDR_SYNC_FILE_SYSTEM_INTERNALS_DUMP_DATABASE_JS);
+ source->AddResourcePaths(
+ base::make_span(kSyncFileSystemInternalsResources,
+ kSyncFileSystemInternalsResourcesSize));
source->SetDefaultResource(IDR_SYNC_FILE_SYSTEM_INTERNALS_MAIN_HTML);
return source;
}
diff --git a/chromium/chrome/browser/ui/webui/sync_internals/OWNERS b/chromium/chrome/browser/ui/webui/sync_internals/OWNERS
new file mode 100644
index 00000000000..261ab189a66
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/sync_internals/OWNERS
@@ -0,0 +1 @@
+file://components/sync/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_browsertest.js
index a37f2713dac..3a0aa976740 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_browsertest.js
@@ -27,13 +27,6 @@ SyncInternalsWebUITest.prototype = {
*/
runAccessibilityChecks: false,
- /** @override */
- preLoad: function() {
- this.makeAndRegisterMockHandler([
- 'getAllNodes',
- ]);
- },
-
/**
* Checks aboutInfo's details section for the specified field.
* @param {boolean} isValid Whether the field is valid.
@@ -334,12 +327,9 @@ TEST_F('SyncInternalsWebUITest', 'SearchTabDoesntChangeOnItemSelect',
});
TEST_F('SyncInternalsWebUITest', 'NodeBrowserTest', function() {
- const getAllNodesSavedArgs = new SaveMockArguments();
- this.mockHandler.expects(once()).
- getAllNodes(getAllNodesSavedArgs.match(ANYTHING)).
- will(callFunctionWithSavedArgs(getAllNodesSavedArgs,
- chrome.sync.getAllNodesCallback,
- HARD_CODED_ALL_NODES));
+ chrome.sync.getAllNodes = (callback) => {
+ callback(HARD_CODED_ALL_NODES);
+ };
// Hit the refresh button.
$('node-browser-refresh-button').click();
@@ -347,7 +337,7 @@ TEST_F('SyncInternalsWebUITest', 'NodeBrowserTest', function() {
// Check that the refresh time was updated.
expectNotEquals($('node-browser-refresh-time').textContent, 'Never');
- // Verify some hard-coded assumptions. These depend on the vaue of the
+ // Verify some hard-coded assumptions. These depend on the value of the
// hard-coded nodes, specified elsewhere in this file.
// Start with the tree itself.
@@ -370,12 +360,9 @@ TEST_F('SyncInternalsWebUITest', 'NodeBrowserTest', function() {
});
TEST_F('SyncInternalsWebUITest', 'NodeBrowserRefreshOnTabSelect', function() {
- const getAllNodesSavedArgs = new SaveMockArguments();
- this.mockHandler.expects(once()).
- getAllNodes(getAllNodesSavedArgs.match(ANYTHING)).
- will(callFunctionWithSavedArgs(getAllNodesSavedArgs,
- chrome.sync.getAllNodesCallback,
- HARD_CODED_ALL_NODES));
+ chrome.sync.getAllNodes = (callback) => {
+ callback(HARD_CODED_ALL_NODES);
+ };
// Should start with non-refreshed node browser.
expectEquals($('node-browser-refresh-time').textContent, 'Never');
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
index 214fa4ce2a9..b149bee7c50 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.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/sync_internals_message_handler.h"
+#include "chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h"
#include <utility>
#include <vector>
@@ -368,8 +368,8 @@ void SyncInternalsMessageHandler::OnInvalidationReceived(
void SyncInternalsMessageHandler::HandleJsEvent(
const std::string& name,
const syncer::JsEventDetails& details) {
- DVLOG(1) << "Handling event: " << name
- << " with details " << details.ToString();
+ DVLOG(1) << "Handling event: " << name << " with details "
+ << details.ToString();
DispatchEvent(name, details.Get());
}
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h
index b28f34fd2c7..5b473f3472c 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.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_SYNC_INTERNALS_MESSAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HANDLER_H_
#include <memory>
#include <string>
@@ -143,4 +143,4 @@ class SyncInternalsMessageHandler : public content::WebUIMessageHandler,
DISALLOW_COPY_AND_ASSIGN(SyncInternalsMessageHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_MESSAGE_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_MESSAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler_unittest.cc
index d476a6bee71..cb01769aa02 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler_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/sync_internals_message_handler.h"
+#include "chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h"
#include <memory>
#include <utility>
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_ui.cc b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_ui.cc
index 14105efa6c8..c8c52da9654 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_ui.cc
@@ -2,12 +2,12 @@
// 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/sync_internals_ui.h"
+#include "chrome/browser/ui/webui/sync_internals/sync_internals_ui.h"
#include <memory>
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/sync_internals_message_handler.h"
+#include "chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
#include "components/grit/sync_driver_resources.h"
@@ -54,7 +54,7 @@ content::WebUIDataSource* CreateSyncInternalsHTMLSource() {
{syncer::sync_ui_util::kInvalidationsJS,
IDR_SYNC_DRIVER_SYNC_INTERNALS_INVALIDATIONS_JS},
};
- webui::AddResourcePathsBulk(source, kResources);
+ source->AddResourcePaths(kResources);
source->SetDefaultResource(IDR_SYNC_DRIVER_SYNC_INTERNALS_INDEX_HTML);
return source;
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_ui.h b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_ui.h
index e1a773d53e7..8a0e174bbd9 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/sync_internals/sync_internals_ui.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_SYNC_INTERNALS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_UI_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
@@ -19,4 +19,4 @@ class SyncInternalsUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(SyncInternalsUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SYNC_INTERNALS_SYNC_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/system_info_ui.cc b/chromium/chrome/browser/ui/webui/system_info_ui.cc
index 5515358df3a..a9d39ab1105 100644
--- a/chromium/chrome/browser/ui/webui/system_info_ui.cc
+++ b/chromium/chrome/browser/ui/webui/system_info_ui.cc
@@ -61,7 +61,7 @@ content::WebUIDataSource* CreateSystemInfoUIDataSource() {
{"collapseBtn", IDS_ABOUT_SYS_COLLAPSE},
{"parseError", IDS_ABOUT_SYS_PARSE_ERROR},
};
- AddLocalizedStringsBulk(html_source, kStrings);
+ html_source->AddLocalizedStrings(kStrings);
html_source->AddResourcePath("about_sys.js", IDR_ABOUT_SYS_JS);
html_source->AddResourcePath("about_sys.css", IDR_ABOUT_SYS_CSS);
diff --git a/chromium/chrome/browser/ui/webui/tab_search/DIR_METADATA b/chromium/chrome/browser/ui/webui/tab_search/DIR_METADATA
new file mode 100644
index 00000000000..c7355b5d5cf
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/tab_search/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>TabSearch"
+}
diff --git a/chromium/chrome/browser/ui/webui/tab_search/OWNERS b/chromium/chrome/browser/ui/webui/tab_search/OWNERS
index 3cddfa6e370..37e9563c28d 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/OWNERS
+++ b/chromium/chrome/browser/ui/webui/tab_search/OWNERS
@@ -5,5 +5,3 @@ romanarora@chromium.org
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: UI>Browser>TabSearch
diff --git a/chromium/chrome/browser/ui/webui/tab_search/tab_search.mojom b/chromium/chrome/browser/ui/webui/tab_search/tab_search.mojom
index 4447b144831..e2f0d589721 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/tab_search.mojom
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search.mojom
@@ -6,14 +6,15 @@ module tab_search.mojom;
import "mojo/public/mojom/base/time.mojom";
-// Collection of WindowTabs of a profile.
-struct ProfileTabs {
- array<WindowTabs> windows;
+// Collection of window details associated with a profile.
+struct ProfileData {
+ array<Window> windows;
};
-// Collection of Tab of a window.
-struct WindowTabs {
+// Properties and tabs associated with a window.
+struct Window {
bool active;
+ uint32 height;
array<Tab> tabs;
};
@@ -83,8 +84,8 @@ interface PageHandler {
// Close a specific tab.
CloseTab(int32 tab_id);
- // Get tabs grouped by windows for the current profile.
- GetProfileTabs() => (ProfileTabs profile_tabs);
+ // Get window and tab data for the current profile.
+ GetProfileData() => (ProfileData profile_data);
// Get tab groups for the current profile.
GetTabGroups() => (TabGroups tab_groups);
@@ -104,12 +105,17 @@ interface PageHandler {
// WebUI-side handler for requests from the browser.
interface Page {
- // Callback when any tabs in the current profile are
- // selected/inserted/moved/replaced
- TabsChanged();
-
- // Callback when a tab is updated within the same web contents.
- // e.g. url, title or favicon changed.
+ // Called when we require a full refresh of the JS's tab list data structures.
+ // Typically used when tabs in the current profile are deleted, inserted,
+ // moved or replaced.
+ // `profile_tabs` is a collection of all open tabs in the current profile.
+ // This is always populated with at least 1 (the currently active) tab.
+ TabsChanged(ProfileData profile_tabs);
+
+ // Called when a tab's data has changed and we need only issue an update for
+ // that specific tab in the JS's data structures. Typically used for url,
+ // title, or favicon changes. `tab` is always populated with the latest data
+ // for the affected tab.
TabUpdated(Tab tab);
// Callback when tabs are removed.
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 759bd9fcd0d..c0110fff236 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
@@ -15,6 +15,7 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "base/trace_event/trace_event.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/profiles/profile.h"
@@ -31,7 +32,7 @@ namespace {
constexpr base::TimeDelta kTabsChangeDelay =
base::TimeDelta::FromMilliseconds(50);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char kFeedbackCategoryTag[] = "FromTabSearch";
#else
constexpr char kFeedbackCategoryTag[] = "FromTabSearchBrowser";
@@ -45,7 +46,6 @@ TabSearchPageHandler::TabSearchPageHandler(
ui::MojoBubbleWebUIController* webui_controller)
: receiver_(this, std::move(receiver)),
page_(std::move(page)),
- browser_(chrome::FindLastActive()),
web_ui_(web_ui),
webui_controller_(webui_controller),
debounce_timer_(std::make_unique<base::RetainingOneShotTimer>(
@@ -53,7 +53,7 @@ TabSearchPageHandler::TabSearchPageHandler(
kTabsChangeDelay,
base::BindRepeating(&TabSearchPageHandler::NotifyTabsChanged,
base::Unretained(this)))) {
- DCHECK(browser_);
+ Observe(web_ui_->GetWebContents());
browser_tab_strip_tracker_.Init();
}
@@ -71,33 +71,24 @@ void TabSearchPageHandler::CloseTab(int32_t tab_id) {
if (!optional_details)
return;
- const TabDetails& details = optional_details.value();
- bool tab_closed = details.tab_strip_model->CloseWebContentsAt(
- details.index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
-
++num_tabs_closed_;
- if (tab_closed)
- NotifyTabsChanged();
+ // CloseTab() can target the WebContents hosting Tab Search if the Tab Search
+ // WebUI is open in a chrome browser tab rather than its bubble. In this case
+ // CloseWebContentsAt() closes the WebContents hosting this
+ // TabSearchPageHandler object, causing it to be immediately destroyed. Ensure
+ // that no further actions are performed following the call to
+ // CloseWebContentsAt(). See (https://crbug.com/1175507).
+ 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);
+ // Do not add code past this point.
}
-void TabSearchPageHandler::GetProfileTabs(GetProfileTabsCallback callback) {
- TRACE_EVENT0("browser", "TabSearchPageHandler::GetProfileTabs");
- auto profile_tabs = tab_search::mojom::ProfileTabs::New();
- Profile* profile = browser_->profile();
- for (auto* browser : *BrowserList::GetInstance()) {
- if (browser->profile() != profile)
- continue;
- TabStripModel* tab_strip_model = browser->tab_strip_model();
- auto window_tabs = tab_search::mojom::WindowTabs::New();
- window_tabs->active = (browser == browser_);
- for (int i = 0; i < tab_strip_model->count(); ++i) {
- window_tabs->tabs.push_back(
- GetTabData(tab_strip_model, tab_strip_model->GetWebContentsAt(i), i));
- }
- profile_tabs->windows.push_back(std::move(window_tabs));
- }
-
+void TabSearchPageHandler::GetProfileData(GetProfileDataCallback callback) {
+ TRACE_EVENT0("browser", "custom_metric:TabSearchPageHandler:GetProfileTabs");
+ auto profile_tabs = CreateProfileData();
// On first run record the number of windows and tabs open for the given
// profile.
if (!sent_initial_payload_) {
@@ -115,9 +106,8 @@ void TabSearchPageHandler::GetProfileTabs(GetProfileTabsCallback callback) {
base::Optional<TabSearchPageHandler::TabDetails>
TabSearchPageHandler::GetTabDetails(int32_t tab_id) {
- Profile* profile = browser_->profile();
for (auto* browser : *BrowserList::GetInstance()) {
- if (browser->profile() != profile) {
+ if (!ShouldTrackBrowser(browser)) {
continue;
}
@@ -140,7 +130,10 @@ void TabSearchPageHandler::GetTabGroups(GetTabGroupsCallback callback) {
}
void TabSearchPageHandler::ShowFeedbackPage() {
- chrome::ShowFeedbackPage(browser_,
+ Browser* browser = chrome::FindLastActive();
+ if (!browser)
+ return;
+ chrome::ShowFeedbackPage(browser,
chrome::FeedbackSource::kFeedbackSourceTabSearch,
std::string() /* description_template */,
std::string() /* description_placeholder_text */,
@@ -168,6 +161,27 @@ void TabSearchPageHandler::ShowUI() {
embedder->ShowUI();
}
+tab_search::mojom::ProfileDataPtr TabSearchPageHandler::CreateProfileData() {
+ auto profile_data = tab_search::mojom::ProfileData::New();
+ Browser* active_browser = chrome::FindLastActive();
+ if (!active_browser)
+ return profile_data;
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (!ShouldTrackBrowser(browser))
+ continue;
+ TabStripModel* tab_strip_model = browser->tab_strip_model();
+ auto window = tab_search::mojom::Window::New();
+ window->active = (browser == active_browser);
+ window->height = browser->window()->GetContentsSize().height();
+ for (int i = 0; i < tab_strip_model->count(); ++i) {
+ window->tabs.push_back(
+ GetTabData(tab_strip_model, tab_strip_model->GetWebContentsAt(i), i));
+ }
+ profile_data->windows.push_back(std::move(window));
+ }
+ return profile_data;
+}
+
tab_search::mojom::TabPtr TabSearchPageHandler::GetTabData(
TabStripModel* tab_strip_model,
content::WebContents* contents,
@@ -208,8 +222,10 @@ void TabSearchPageHandler::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) {
- if (browser_tab_strip_tracker_.is_processing_initial_browsers())
+ if (webui_hidden_ ||
+ browser_tab_strip_tracker_.is_processing_initial_browsers()) {
return;
+ }
if (change.type() == TabStripModelChange::kRemoved) {
std::vector<int> tab_ids;
for (auto& content_with_index : change.GetRemove()->contents) {
@@ -225,6 +241,8 @@ void TabSearchPageHandler::OnTabStripModelChanged(
void TabSearchPageHandler::TabChangedAt(content::WebContents* contents,
int index,
TabChangeType change_type) {
+ if (webui_hidden_)
+ return;
// TODO(crbug.com/1112496): Support more values for TabChangeType and filter
// out the changes we are not interested in.
if (change_type != TabChangeType::kAll)
@@ -232,7 +250,7 @@ void TabSearchPageHandler::TabChangedAt(content::WebContents* contents,
Browser* browser = chrome::FindBrowserWithWebContents(contents);
if (!browser)
return;
- TRACE_EVENT0("browser", "TabSearchPageHandler::TabChangedAt");
+ TRACE_EVENT0("browser", "custom_metric:TabSearchPageHandler:TabChangedAt");
page_->TabUpdated(GetTabData(browser->tab_strip_model(), contents, index));
}
@@ -242,12 +260,17 @@ void TabSearchPageHandler::ScheduleDebounce() {
}
void TabSearchPageHandler::NotifyTabsChanged() {
- page_->TabsChanged();
+ page_->TabsChanged(CreateProfileData());
debounce_timer_->Stop();
}
bool TabSearchPageHandler::ShouldTrackBrowser(Browser* browser) {
- return browser->profile() == browser_->profile();
+ return browser->profile() == Profile::FromWebUI(web_ui_) &&
+ browser->type() == Browser::Type::TYPE_NORMAL;
+}
+
+void TabSearchPageHandler::OnVisibilityChanged(content::Visibility visibility) {
+ webui_hidden_ = visibility == content::Visibility::HIDDEN;
}
void TabSearchPageHandler::SetTimerForTesting(
diff --git a/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.h b/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.h
index 55475d31a09..daabd11d2fe 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.h
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/webui/tab_search/tab_search.mojom.h"
+#include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
@@ -31,7 +32,8 @@ enum class TabSearchCloseAction {
class TabSearchPageHandler : public tab_search::mojom::PageHandler,
public TabStripModelObserver,
- public BrowserTabStripTrackerDelegate {
+ public BrowserTabStripTrackerDelegate,
+ public content::WebContentsObserver {
public:
TabSearchPageHandler(
mojo::PendingReceiver<tab_search::mojom::PageHandler> receiver,
@@ -44,7 +46,7 @@ class TabSearchPageHandler : public tab_search::mojom::PageHandler,
// tab_search::mojom::PageHandler:
void CloseTab(int32_t tab_id) override;
- void GetProfileTabs(GetProfileTabsCallback callback) override;
+ void GetProfileData(GetProfileDataCallback callback) override;
void GetTabGroups(GetTabGroupsCallback callback) override;
void ShowFeedbackPage() override;
void SwitchToTab(
@@ -66,6 +68,9 @@ class TabSearchPageHandler : public tab_search::mojom::PageHandler,
// BrowserTabStripTrackerDelegate:
bool ShouldTrackBrowser(Browser* browser) override;
+ // content::WebContentsObserver:
+ void OnVisibilityChanged(content::Visibility visibility) override;
+
protected:
void SetTimerForTesting(std::unique_ptr<base::RetainingOneShotTimer> timer);
@@ -80,6 +85,8 @@ class TabSearchPageHandler : public tab_search::mojom::PageHandler,
int index;
};
+ tab_search::mojom::ProfileDataPtr CreateProfileData();
+
tab_search::mojom::TabPtr GetTabData(TabStripModel* tab_strip_model,
content::WebContents* contents,
int index);
@@ -95,11 +102,11 @@ class TabSearchPageHandler : public tab_search::mojom::PageHandler,
mojo::Receiver<tab_search::mojom::PageHandler> receiver_;
mojo::Remote<tab_search::mojom::Page> page_;
- Browser* const browser_;
content::WebUI* const web_ui_;
ui::MojoBubbleWebUIController* const webui_controller_;
BrowserTabStripTracker browser_tab_strip_tracker_{this, this};
std::unique_ptr<base::RetainingOneShotTimer> debounce_timer_;
+ bool webui_hidden_ = false;
// Tracks how many times |CloseTab()| has been evoked for the currently open
// instance of Tab Search for logging in UMA.
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 fce77f17bfd..3b1ccff17b9 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
@@ -8,6 +8,7 @@
#include "base/test/metrics/histogram_tester.h"
#include "base/timer/mock_timer.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
@@ -29,12 +30,14 @@ constexpr char kTabUrl2[] = "http://foo/2";
constexpr char kTabUrl3[] = "http://foo/3";
constexpr char kTabUrl4[] = "http://foo/4";
constexpr char kTabUrl5[] = "http://foo/5";
+constexpr char kTabUrl6[] = "http://foo/6";
constexpr char kTabName1[] = "Tab 1";
constexpr char kTabName2[] = "Tab 2";
constexpr char kTabName3[] = "Tab 3";
constexpr char kTabName4[] = "Tab 4";
constexpr char kTabName5[] = "Tab 5";
+constexpr char kTabName6[] = "Tab 6";
class MockPage : public tab_search::mojom::Page {
public:
@@ -47,7 +50,7 @@ class MockPage : public tab_search::mojom::Page {
}
mojo::Receiver<tab_search::mojom::Page> receiver_{this};
- MOCK_METHOD0(TabsChanged, void());
+ MOCK_METHOD1(TabsChanged, void(tab_search::mojom::ProfileDataPtr));
MOCK_METHOD1(TabUpdated, void(tab_search::mojom::TabPtr));
MOCK_METHOD1(TabsRemoved, void(const std::vector<int32_t>& tab_ids));
};
@@ -68,7 +71,7 @@ void ExpectNewTab(const tab_search::mojom::Tab* tab,
EXPECT_GT(tab->last_active_time_ticks, base::TimeTicks());
}
-void ExpectProfileTabs(tab_search::mojom::ProfileTabs* profile_tabs) {
+void ExpectProfileTabs(tab_search::mojom::ProfileData* profile_tabs) {
ASSERT_EQ(2u, profile_tabs->windows.size());
auto* window1 = profile_tabs->windows[0].get();
ASSERT_EQ(2u, window1->tabs.size());
@@ -104,6 +107,9 @@ class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
public:
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
+ web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(profile()));
+ web_ui_.set_web_contents(web_contents_.get());
profile2_ = profile_manager()->CreateTestingProfile(
"testing_profile2", nullptr, base::string16(), 0, std::string(),
GetTestingFactories());
@@ -111,6 +117,7 @@ class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
browser3_ =
CreateTestBrowser(browser()->profile()->GetPrimaryOTRProfile(), false);
browser4_ = CreateTestBrowser(profile2(), false);
+ browser5_ = CreateTestBrowser(profile1(), true);
BrowserList::SetLastActive(browser1());
webui_controller_ =
std::make_unique<ui::MojoBubbleWebUIController>(web_ui());
@@ -123,9 +130,12 @@ class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
browser2()->tab_strip_model()->CloseAllTabs();
browser3()->tab_strip_model()->CloseAllTabs();
browser4()->tab_strip_model()->CloseAllTabs();
+ browser5()->tab_strip_model()->CloseAllTabs();
browser2_.reset();
browser3_.reset();
browser4_.reset();
+ browser5_.reset();
+ web_contents_.reset();
BrowserWithTestWindowTest::TearDown();
}
@@ -145,6 +155,9 @@ class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
// Browser with a different profile of the default browser.
Browser* browser4() { return browser4_.get(); }
+ // Browser with the same profile but not normal type.
+ Browser* browser5() { return browser5_.get(); }
+
TestTabSearchPageHandler* handler() { return handler_.get(); }
void FireTimer() { handler_->mock_debounce_timer()->Fire(); }
bool IsTimerRunning() { return handler_->mock_debounce_timer()->IsRunning(); }
@@ -172,25 +185,28 @@ class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
return browser;
}
+ std::unique_ptr<content::WebContents> web_contents_;
content::TestWebUI web_ui_;
Profile* profile2_;
std::unique_ptr<Browser> browser2_;
std::unique_ptr<Browser> browser3_;
std::unique_ptr<Browser> browser4_;
+ std::unique_ptr<Browser> browser5_;
std::unique_ptr<TestTabSearchPageHandler> handler_;
std::unique_ptr<ui::MojoBubbleWebUIController> webui_controller_;
};
TEST_F(TabSearchPageHandlerTest, GetTabs) {
- // Browser3 and browser4 are using different profiles, thus their tabs should
- // not be accessible.
+ // Browser3 and browser4 are using different profiles, browser5 is not a
+ // normal type browser, thus their tabs should not be accessible.
+ AddTabWithTitle(browser5(), GURL(kTabUrl6), kTabName6);
AddTabWithTitle(browser4(), GURL(kTabUrl5), kTabName5);
AddTabWithTitle(browser3(), GURL(kTabUrl4), kTabName4);
AddTabWithTitle(browser2(), GURL(kTabUrl3), kTabName3);
AddTabWithTitle(browser1(), GURL(kTabUrl2), kTabName2);
AddTabWithTitle(browser1(), GURL(kTabUrl1), kTabName1);
- EXPECT_CALL(page_, TabsChanged()).Times(1);
+ EXPECT_CALL(page_, TabsChanged(_)).Times(1);
EXPECT_CALL(page_, TabUpdated(_)).Times(2);
EXPECT_CALL(page_, TabsRemoved(_)).Times(2);
handler()->mock_debounce_timer()->Fire();
@@ -199,9 +215,9 @@ TEST_F(TabSearchPageHandlerTest, GetTabs) {
int32_t tab_id3 = 0;
// Get Tabs.
- tab_search::mojom::PageHandler::GetProfileTabsCallback callback1 =
+ tab_search::mojom::PageHandler::GetProfileDataCallback callback1 =
base::BindLambdaForTesting(
- [&](tab_search::mojom::ProfileTabsPtr profile_tabs) {
+ [&](tab_search::mojom::ProfileDataPtr profile_tabs) {
ASSERT_EQ(2u, profile_tabs->windows.size());
auto* window1 = profile_tabs->windows[0].get();
ASSERT_TRUE(window1->active);
@@ -226,7 +242,7 @@ TEST_F(TabSearchPageHandlerTest, GetTabs) {
tab_id2 = tab2->tab_id;
tab_id3 = tab3->tab_id;
});
- handler()->GetProfileTabs(std::move(callback1));
+ handler()->GetProfileData(std::move(callback1));
// Switch to 2nd tab.
auto switch_to_tab_info = tab_search::mojom::SwitchToTabInfo::New();
@@ -234,12 +250,12 @@ TEST_F(TabSearchPageHandlerTest, GetTabs) {
handler()->SwitchToTab(std::move(switch_to_tab_info));
// Get Tabs again to verify tab switch.
- tab_search::mojom::PageHandler::GetProfileTabsCallback callback2 =
+ tab_search::mojom::PageHandler::GetProfileDataCallback callback2 =
base::BindLambdaForTesting(
- [&](tab_search::mojom::ProfileTabsPtr profile_tabs) {
+ [&](tab_search::mojom::ProfileDataPtr profile_tabs) {
ExpectProfileTabs(profile_tabs.get());
});
- handler()->GetProfileTabs(std::move(callback2));
+ handler()->GetProfileData(std::move(callback2));
// Switch to 3rd tab.
switch_to_tab_info = tab_search::mojom::SwitchToTabInfo::New();
@@ -247,19 +263,19 @@ TEST_F(TabSearchPageHandlerTest, GetTabs) {
handler()->SwitchToTab(std::move(switch_to_tab_info));
// Get Tabs again to verify tab switch.
- tab_search::mojom::PageHandler::GetProfileTabsCallback callback3 =
+ tab_search::mojom::PageHandler::GetProfileDataCallback callback3 =
base::BindLambdaForTesting(
- [&](tab_search::mojom::ProfileTabsPtr profile_tabs) {
+ [&](tab_search::mojom::ProfileDataPtr profile_tabs) {
ExpectProfileTabs(profile_tabs.get());
});
- handler()->GetProfileTabs(std::move(callback3));
+ handler()->GetProfileData(std::move(callback3));
}
// Ensure that repeated tab model changes do not result in repeated calls to
// TabsChanged() and TabsChanged() is only called when the page handler's
// timer fires.
TEST_F(TabSearchPageHandlerTest, TabsChanged) {
- EXPECT_CALL(page_, TabsChanged()).Times(3);
+ EXPECT_CALL(page_, TabsChanged(_)).Times(3);
EXPECT_CALL(page_, TabUpdated(_)).Times(1);
EXPECT_CALL(page_, TabsRemoved(_)).Times(3);
FireTimer(); // Will call TabsChanged().
@@ -290,7 +306,7 @@ TEST_F(TabSearchPageHandlerTest, TabsChanged) {
// Ensure that tab model changes in a browser with a different profile
// will not call TabsChanged().
TEST_F(TabSearchPageHandlerTest, TabsNotChanged) {
- EXPECT_CALL(page_, TabsChanged()).Times(1);
+ EXPECT_CALL(page_, TabsChanged(_)).Times(1);
EXPECT_CALL(page_, TabUpdated(_)).Times(0);
FireTimer(); // Will call TabsChanged().
ASSERT_FALSE(IsTimerRunning());
@@ -309,7 +325,7 @@ bool VerifyTabUpdated(const tab_search::mojom::TabPtr& tab) {
// Verify tab update event is called correctly with data
TEST_F(TabSearchPageHandlerTest, TabUpdated) {
- EXPECT_CALL(page_, TabsChanged()).Times(1);
+ EXPECT_CALL(page_, TabsChanged(_)).Times(1);
EXPECT_CALL(page_, TabUpdated(Truly(VerifyTabUpdated))).Times(1);
EXPECT_CALL(page_, TabsRemoved(_)).Times(1);
AddTabWithTitle(browser1(), GURL(kTabUrl1), kTabName1);
@@ -328,7 +344,6 @@ TEST_F(TabSearchPageHandlerTest, CloseTab) {
int tab_id = extensions::ExtensionTabUtil::GetTabId(
browser2()->tab_strip_model()->GetWebContentsAt(0));
- EXPECT_CALL(page_, TabsChanged()).Times(1);
EXPECT_CALL(page_, TabUpdated(_)).Times(1);
EXPECT_CALL(page_, TabsRemoved(_)).Times(3);
handler()->CloseTab(tab_id);
@@ -337,7 +352,7 @@ TEST_F(TabSearchPageHandlerTest, CloseTab) {
}
// TODO(crbug.com/1128855): Fix the test for Lacros build.
-#if BUILDFLAG(IS_LACROS)
+#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_ShowFeedbackPage DISABLED_ShowFeedbackPage
#else
#define MAYBE_ShowFeedbackPage ShowFeedbackPage
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 71e82d131aa..c546a23c8b0 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
@@ -44,7 +44,7 @@ TabSearchUI::TabSearchUI(content::WebUI* web_ui)
{"a11yFoundTabFor", IDS_TAB_SEARCH_A11Y_FOUND_TAB_FOR},
{"a11yFoundTabsFor", IDS_TAB_SEARCH_A11Y_FOUND_TABS_FOR},
};
- AddLocalizedStringsBulk(source, kStrings);
+ source->AddLocalizedStrings(kStrings);
source->AddBoolean(
"submitFeedbackEnabled",
@@ -74,7 +74,7 @@ TabSearchUI::TabSearchUI(content::WebUI* web_ui)
webui::SetupWebUIDataSource(
source, base::make_span(kTabSearchResources, kTabSearchResourcesSize),
- /*generated_path=*/std::string(), IDR_TAB_SEARCH_TAB_SEARCH_PAGE_HTML);
+ IDR_TAB_SEARCH_TAB_SEARCH_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
source);
diff --git a/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.h b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.h
index 352b6c21446..08b30d920fa 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.h
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.h
@@ -30,6 +30,10 @@ class TabSearchUI : public ui::MojoBubbleWebUIController,
void BindInterface(
mojo::PendingReceiver<tab_search::mojom::PageHandlerFactory> receiver);
+ TabSearchPageHandler* page_handler_for_testing() {
+ return page_handler_.get();
+ }
+
private:
// tab_search::mojom::PageHandlerFactory
void CreatePageHandler(
diff --git a/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_browsertest.cc
index a0c042760e4..bf18d85ff84 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_browsertest.cc
@@ -10,10 +10,12 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/ui_features.h"
+#include "chrome/browser/ui/webui/tab_search/tab_search_ui.h"
#include "chrome/common/chrome_isolated_world_ids.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
+#include "content/public/test/test_utils.h"
class TabSearchUIBrowserTest : public InProcessBrowserTest {
public:
@@ -48,6 +50,12 @@ class TabSearchUIBrowserTest : public InProcessBrowserTest {
return browser()->tab_strip_model()->GetActiveWebContents();
}
+ TabSearchUI* GetWebUIController() {
+ return webui_contents_->GetWebUI()
+ ->GetController()
+ ->template GetAs<TabSearchUI>();
+ }
+
protected:
std::unique_ptr<content::WebContents> webui_contents_;
@@ -61,7 +69,7 @@ class TabSearchUIBrowserTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(TabSearchUIBrowserTest, InitialTabItemsListed) {
const std::string tab_items_js =
"const tabItems = document.querySelector('tab-search-app').shadowRoot"
- " .getElementById('tabsList').shadowRoot"
+ " .getElementById('tabsList')"
" .querySelectorAll('tab-search-item');";
int tab_item_count =
content::EvalJs(webui_contents_.get(), tab_items_js + "tabItems.length",
@@ -82,7 +90,8 @@ IN_PROC_BROWSER_TEST_F(TabSearchUIBrowserTest, SwitchToTabAction) {
const std::string tab_item_js = base::StringPrintf(
"document.querySelector('tab-search-app').shadowRoot"
- " .getElementById('tabsList').shadowRoot.getElementById('%s')",
+ " .getElementById('tabsList')"
+ " .querySelector('tab-search-item[id=\"%s\"]')",
base::NumberToString(tab_id).c_str());
ASSERT_TRUE(content::ExecJs(webui_contents_.get(), tab_item_js + ".click()",
content::EXECUTE_SCRIPT_DEFAULT_OPTIONS,
@@ -98,7 +107,8 @@ IN_PROC_BROWSER_TEST_F(TabSearchUIBrowserTest, CloseTabAction) {
const std::string tab_item_button_js = base::StringPrintf(
"document.querySelector('tab-search-app').shadowRoot"
- " .getElementById('tabsList').shadowRoot.getElementById('%s')"
+ " .getElementById('tabsList')"
+ " .querySelector('tab-search-item[id=\"%s\"]')"
" .shadowRoot.getElementById('closeButton')",
base::NumberToString(tab_id).c_str());
ASSERT_TRUE(content::ExecJs(webui_contents_.get(),
@@ -116,3 +126,43 @@ IN_PROC_BROWSER_TEST_F(TabSearchUIBrowserTest, CloseTabAction) {
ASSERT_EQ(open_tab_ids.end(),
std::find(open_tab_ids.begin(), open_tab_ids.end(), tab_id));
}
+
+// When hosting the Tab Search UI as a browser tab, ensure that closing the tab
+// hosting Tab Search does not result in any UAF errors. Test for regression
+// (https://crbug.com/1175507).
+IN_PROC_BROWSER_TEST_F(TabSearchUIBrowserTest,
+ CloseTabSearchAsBrowserTabDoesNotCrash) {
+ AppendTab(chrome::kChromeUITabSearchURL);
+ auto* tab_strip_model = browser()->tab_strip_model();
+ ASSERT_EQ(5, tab_strip_model->GetTabCount());
+ content::WebContents* tab_contents = tab_strip_model->GetWebContentsAt(4);
+ const int tab_id = extensions::ExtensionTabUtil::GetTabId(
+ tab_strip_model->GetWebContentsAt(4));
+
+ // Finish loading after initializing.
+ ASSERT_TRUE(content::WaitForLoadStop(tab_contents));
+
+ TabSearchPageHandler* page_handler = tab_contents->GetWebUI()
+ ->GetController()
+ ->template GetAs<TabSearchUI>()
+ ->page_handler_for_testing();
+ ASSERT_NE(nullptr, page_handler);
+ content::WebContentsDestroyedWatcher close_observer(tab_contents);
+ page_handler->CloseTab(tab_id);
+ tab_contents->DispatchBeforeUnload(false /* auto_cancel */);
+ close_observer.Wait();
+ ASSERT_EQ(4, tab_strip_model->GetTabCount());
+
+ // Check to make sure the browser tab hosting Tab Search has been closed but
+ // the rest remain.
+ int tab_count = tab_strip_model->GetTabCount();
+ ASSERT_EQ(4, tab_count);
+
+ std::vector<int> open_tab_ids(tab_count);
+ for (int tab_index = 0; tab_index < tab_count; tab_index++) {
+ open_tab_ids.push_back(extensions::ExtensionTabUtil::GetTabId(
+ tab_strip_model->GetWebContentsAt(tab_index)));
+ }
+ ASSERT_EQ(open_tab_ids.end(),
+ std::find(open_tab_ids.begin(), open_tab_ids.end(), tab_id));
+}
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/DIR_METADATA b/chromium/chrome/browser/ui/webui/tab_strip/DIR_METADATA
new file mode 100644
index 00000000000..8325efaab7d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/tab_strip/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>WebUI"
+}
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/OWNERS b/chromium/chrome/browser/ui/webui/tab_strip/OWNERS
index b84c705bb6e..c4454dd4ad5 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/OWNERS
+++ b/chromium/chrome/browser/ui/webui/tab_strip/OWNERS
@@ -1,4 +1,2 @@
dpapad@chromium.org
johntlee@chromium.org
-
-# COMPONENT: UI>Browser>WebUI
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.cc b/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.cc
index 6f76ac6f688..1e5b2141834 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.cc
@@ -15,15 +15,13 @@ ChromeContentBrowserClientTabStripPart::
~ChromeContentBrowserClientTabStripPart() = default;
void ChromeContentBrowserClientTabStripPart::OverrideWebkitPrefs(
- content::RenderViewHost* rvh,
+ content::WebContents* web_contents,
blink::web_pref::WebPreferences* web_prefs) {
- content::WebContents* contents =
- content::WebContents::FromRenderViewHost(rvh);
-
- if (!contents)
+ if (!web_contents)
return;
- content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
+ content::NavigationEntry* entry =
+ web_contents->GetController().GetVisibleEntry();
GURL url = entry ? entry->GetURL() : GURL();
if (url.host_piece() != chrome::kChromeUITabStripHost) {
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.h b/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.h
index 2edc7d30c13..11206f34221 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.h
+++ b/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.h
@@ -17,7 +17,7 @@ class ChromeContentBrowserClientTabStripPart
~ChromeContentBrowserClientTabStripPart() override;
// ChromeContentBrowserClientParts:
- void OverrideWebkitPrefs(content::RenderViewHost* rvh,
+ void OverrideWebkitPrefs(content::WebContents* web_contents,
blink::web_pref::WebPreferences* web_prefs) override;
private:
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 e8d9e91c92f..79694dfef5b 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
@@ -47,7 +47,7 @@ TabStripUI::TabStripUI(content::WebUI* web_ui)
content::WebUIDataSource::Create(chrome::kChromeUITabStripHost);
webui::SetupWebUIDataSource(
html_source, base::make_span(kTabStripResources, kTabStripResourcesSize),
- "", IDR_TAB_STRIP_TAB_STRIP_HTML);
+ IDR_TAB_STRIP_TAB_STRIP_HTML);
html_source->AddString("tabIdDataType", kWebUITabIdDataType);
html_source->AddString("tabGroupIdDataType", kWebUITabGroupIdDataType);
@@ -82,7 +82,7 @@ TabStripUI::TabStripUI(content::WebUI* web_ui)
{"unnamedGroupLabel", IDS_GROUP_AX_LABEL_UNNAMED_GROUP_FORMAT},
{"namedGroupLabel", IDS_GROUP_AX_LABEL_NAMED_GROUP_FORMAT},
};
- AddLocalizedStringsBulk(html_source, kStrings);
+ html_source->AddLocalizedStrings(kStrings);
content::WebUIDataSource::Add(profile, html_source);
content::URLDataSource::Add(
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 1b7f85054c2..976587b5cf3 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
@@ -110,15 +110,29 @@ IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest, ActivatingTabClosesEmbedder) {
ISOLATED_WORLD_ID_CHROME_INTERNAL));
}
-// Flaky.
-// TODO(https://crbug.com/1132300): Re-enable.
-IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest,
- DISABLED_InvokesEditDialogForGroups) {
+IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest, InvokesEditDialogForGroups) {
using ::testing::_;
tab_groups::TabGroupId group_id =
browser()->tab_strip_model()->AddToNewGroup({0});
+ // Wait for the front-end to receive the new group and create the tab-group
+ // element.
+ const std::string get_group_promise_js =
+ "new Promise((resolve) => {"
+ " const interval = setInterval(() => {"
+ " if (document.querySelector('tabstrip-tab-list').shadowRoot"
+ " .querySelector('tabstrip-tab-group')) {"
+ " resolve(true);"
+ " clearInterval(interval);"
+ " }"
+ " }, 100);"
+ "});";
+ ASSERT_TRUE(content::EvalJs(webui_contents_.get(), get_group_promise_js,
+ content::EXECUTE_SCRIPT_DEFAULT_OPTIONS,
+ ISOLATED_WORLD_ID_CHROME_INTERNAL)
+ .ExtractBool());
+
const std::string get_chip_js =
"const chip = document.querySelector('tabstrip-tab-list')"
" .shadowRoot.querySelector('tabstrip-tab-group')"
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler.cc b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler.cc
index f615ed446e8..3e92e9fb1ec 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler.cc
@@ -3,12 +3,16 @@
// found in the LICENSE file.
#include "chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler.h"
+
+#include <algorithm>
#include <memory>
+#include "base/containers/span.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/values.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/favicon/favicon_utils.h"
@@ -39,6 +43,7 @@
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/range/range.h"
namespace {
@@ -147,17 +152,29 @@ 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
TabStripUIHandler::TabStripUIHandler(Browser* browser,
TabStripUIEmbedder* embedder)
: browser_(browser),
embedder_(embedder),
- thumbnail_tracker_(base::Bind(&TabStripUIHandler::HandleThumbnailUpdate,
- base::Unretained(this))),
+ thumbnail_tracker_(
+ base::BindRepeating(&TabStripUIHandler::HandleThumbnailUpdate,
+ base::Unretained(this))),
tab_before_unload_tracker_(
- base::Bind(&TabStripUIHandler::OnTabCloseCancelled,
- base::Unretained(this))) {}
+ base::BindRepeating(&TabStripUIHandler::OnTabCloseCancelled,
+ base::Unretained(this))) {}
TabStripUIHandler::~TabStripUIHandler() = default;
void TabStripUIHandler::NotifyLayoutChanged() {
@@ -200,12 +217,13 @@ void TabStripUIHandler::OnTabGroupChanged(const TabGroupChange& change) {
}
case TabGroupChange::kMoved: {
+ const int start_tab = browser_->tab_strip_model()
+ ->group_model()
+ ->GetTabGroup(change.group)
+ ->ListTabs()
+ .start();
FireWebUIListener("tab-group-moved", base::Value(change.group.ToString()),
- base::Value(browser_->tab_strip_model()
- ->group_model()
- ->GetTabGroup(change.group)
- ->ListTabs()
- .front()));
+ base::Value(start_tab));
break;
}
@@ -261,11 +279,19 @@ void TabStripUIHandler::OnTabStripModelChanged(
base::Optional<tab_groups::TabGroupId> tab_group_id =
tab_strip_model->GetTabGroupForTab(move->to_index);
if (tab_group_id.has_value()) {
- const std::vector<int> tabs_in_group =
- tab_strip_model->group_model()
- ->GetTabGroup(tab_group_id.value())
- ->ListTabs();
- if (tabs_in_group == selection.new_model.selected_indices()) {
+ 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,
@@ -327,67 +353,71 @@ void TabStripUIHandler::TabBlockedStateChanged(content::WebContents* contents,
// content::WebUIMessageHandler:
void TabStripUIHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "createNewTab", base::Bind(&TabStripUIHandler::HandleCreateNewTab,
- base::Unretained(this)));
+ "createNewTab",
+ base::BindRepeating(&TabStripUIHandler::HandleCreateNewTab,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "getTabs",
- base::Bind(&TabStripUIHandler::HandleGetTabs, base::Unretained(this)));
+ "getTabs", base::BindRepeating(&TabStripUIHandler::HandleGetTabs,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getGroupVisualData",
- base::Bind(&TabStripUIHandler::HandleGetGroupVisualData,
- base::Unretained(this)));
+ base::BindRepeating(&TabStripUIHandler::HandleGetGroupVisualData,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "getThemeColors", base::Bind(&TabStripUIHandler::HandleGetThemeColors,
- base::Unretained(this)));
+ "getThemeColors",
+ base::BindRepeating(&TabStripUIHandler::HandleGetThemeColors,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "groupTab",
- base::Bind(&TabStripUIHandler::HandleGroupTab, base::Unretained(this)));
+ "groupTab", base::BindRepeating(&TabStripUIHandler::HandleGroupTab,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "ungroupTab",
- base::Bind(&TabStripUIHandler::HandleUngroupTab, base::Unretained(this)));
+ "ungroupTab", base::BindRepeating(&TabStripUIHandler::HandleUngroupTab,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "moveGroup",
- base::Bind(&TabStripUIHandler::HandleMoveGroup, base::Unretained(this)));
+ "moveGroup", base::BindRepeating(&TabStripUIHandler::HandleMoveGroup,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "moveTab",
- base::Bind(&TabStripUIHandler::HandleMoveTab, base::Unretained(this)));
+ "moveTab", base::BindRepeating(&TabStripUIHandler::HandleMoveTab,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"setThumbnailTracked",
- base::Bind(&TabStripUIHandler::HandleSetThumbnailTracked,
- base::Unretained(this)));
+ base::BindRepeating(&TabStripUIHandler::HandleSetThumbnailTracked,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "closeContainer", base::Bind(&TabStripUIHandler::HandleCloseContainer,
- base::Unretained(this)));
+ "closeContainer",
+ base::BindRepeating(&TabStripUIHandler::HandleCloseContainer,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "closeTab",
- base::Bind(&TabStripUIHandler::HandleCloseTab, base::Unretained(this)));
+ "closeTab", base::BindRepeating(&TabStripUIHandler::HandleCloseTab,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"showBackgroundContextMenu",
- base::Bind(&TabStripUIHandler::HandleShowBackgroundContextMenu,
- base::Unretained(this)));
+ base::BindRepeating(&TabStripUIHandler::HandleShowBackgroundContextMenu,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"showEditDialogForGroup",
- base::Bind(&TabStripUIHandler::HandleShowEditDialogForGroup,
- base::Unretained(this)));
+ base::BindRepeating(&TabStripUIHandler::HandleShowEditDialogForGroup,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"showTabContextMenu",
- base::Bind(&TabStripUIHandler::HandleShowTabContextMenu,
- base::Unretained(this)));
+ base::BindRepeating(&TabStripUIHandler::HandleShowTabContextMenu,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "getLayout",
- base::Bind(&TabStripUIHandler::HandleGetLayout, base::Unretained(this)));
+ "getLayout", base::BindRepeating(&TabStripUIHandler::HandleGetLayout,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"reportTabActivationDuration",
- base::Bind(&TabStripUIHandler::HandleReportTabActivationDuration,
- base::Unretained(this)));
+ base::BindRepeating(&TabStripUIHandler::HandleReportTabActivationDuration,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"reportTabDataReceivedDuration",
- base::Bind(&TabStripUIHandler::HandleReportTabDataReceivedDuration,
- base::Unretained(this)));
+ base::BindRepeating(
+ &TabStripUIHandler::HandleReportTabDataReceivedDuration,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"reportTabCreationDuration",
- base::Bind(&TabStripUIHandler::HandleReportTabCreationDuration,
- base::Unretained(this)));
+ base::BindRepeating(&TabStripUIHandler::HandleReportTabCreationDuration,
+ base::Unretained(this)));
}
void TabStripUIHandler::HandleCreateNewTab(const base::ListValue* args) {
@@ -520,21 +550,18 @@ void TabStripUIHandler::HandleGetThemeColors(const base::ListValue* args) {
ThemeProperties::COLOR_TAB_FOREGROUND_ACTIVE_FRAME_ACTIVE),
/* 16% opacity */ 0.16 * 255)));
- colors.SetString("--tabstrip-tab-loading-spinning-color",
- color_utils::SkColorToRgbaString(embedder_->GetColor(
- ThemeProperties::COLOR_TAB_THROBBER_SPINNING)));
+ std::string throbber_color = color_utils::SkColorToRgbaString(
+ embedder_->GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING));
+ colors.SetString("--tabstrip-tab-loading-spinning-color", throbber_color);
colors.SetString("--tabstrip-tab-waiting-spinning-color",
color_utils::SkColorToRgbaString(embedder_->GetColor(
ThemeProperties::COLOR_TAB_THROBBER_WAITING)));
colors.SetString("--tabstrip-indicator-recording-color",
- color_utils::SkColorToRgbaString(embedder_->GetColor(
- ThemeProperties::COLOR_TAB_ALERT_RECORDING)));
- colors.SetString("--tabstrip-indicator-pip-color",
- color_utils::SkColorToRgbaString(embedder_->GetColor(
- ThemeProperties::COLOR_TAB_PIP_PLAYING)));
- colors.SetString("--tabstrip-indicator-capturing-color",
- color_utils::SkColorToRgbaString(embedder_->GetColor(
- ThemeProperties::COLOR_TAB_ALERT_CAPTURING)));
+ color_utils::SkColorToRgbaString(
+ ui::NativeTheme::GetInstanceForWeb()->GetSystemColor(
+ ui::NativeTheme::kColorId_AlertSeverityHigh)));
+ colors.SetString("--tabstrip-indicator-pip-color", throbber_color);
+ colors.SetString("--tabstrip-indicator-capturing-color", throbber_color);
colors.SetString("--tabstrip-tab-blocked-color",
color_utils::SkColorToRgbaString(
ui::NativeTheme::GetInstanceForWeb()->GetSystemColor(
@@ -544,7 +571,7 @@ void TabStripUIHandler::HandleGetThemeColors(const base::ListValue* args) {
ui::NativeTheme::GetInstanceForWeb()->GetSystemColor(
ui::NativeTheme::kColorId_FocusedBorderColor)));
-#if !defined(OS_CHROMEOS)
+#if !BUILDFLAG(IS_CHROMEOS_ASH)
colors.SetString(
"--tabstrip-scrollbar-thumb-color-rgb",
color_utils::SkColorToRgbString(color_utils::GetColorWithMaxContrast(
@@ -606,9 +633,10 @@ void TabStripUIHandler::HandleMoveGroup(const base::ListValue* args) {
TabGroup* group =
source_browser->tab_strip_model()->group_model()->GetTabGroup(
group_id.value());
+ const gfx::Range tabs_in_group = group->ListTabs();
if (source_browser == target_browser) {
- if (group->ListTabs().front() == to_index) {
+ if (static_cast<int>(tabs_in_group.start()) == to_index) {
// If the group is already in place, don't move it. This may happen
// if multiple drag events happen while the tab group is still
// being moved.
@@ -621,8 +649,8 @@ void TabStripUIHandler::HandleMoveGroup(const base::ListValue* args) {
int active_index =
target_browser->tab_strip_model()->selection_model().active();
ui::ListSelectionModel group_selection;
- group_selection.SetSelectedIndex(group->ListTabs().front());
- group_selection.SetSelectionFromAnchorTo(group->ListTabs().back());
+ group_selection.SetSelectedIndex(tabs_in_group.start());
+ group_selection.SetSelectionFromAnchorTo(tabs_in_group.end() - 1);
group_selection.set_active(active_index);
target_browser->tab_strip_model()->SetSelectionFromModel(group_selection);
@@ -634,12 +662,10 @@ void TabStripUIHandler::HandleMoveGroup(const base::ListValue* args) {
group_id.value(),
base::Optional<tab_groups::TabGroupVisualData>{*group->visual_data()});
- std::vector<int> source_tab_indices = group->ListTabs();
- int tab_count = source_tab_indices.size();
+ gfx::Range source_tab_indices = group->ListTabs();
+ const int tab_count = source_tab_indices.length();
+ const int from_index = source_tab_indices.start();
for (int i = 0; i < tab_count; i++) {
- // The index needs to account for the tabs being detached, as they will
- // cause the indices to shift.
- int from_index = source_tab_indices[i] - i;
tab_strip_ui::MoveTabAcrossWindows(source_browser, from_index,
target_browser, to_index + i, group_id);
}
@@ -833,9 +859,11 @@ void TabStripUIHandler::HandleReportTabCreationDuration(
void TabStripUIHandler::HandleThumbnailUpdate(
content::WebContents* tab,
ThumbnailTracker::CompressedThumbnailData image) {
- // Send base-64 encoded image to JS side.
- std::string data_uri =
- webui::MakeDataURIForImage(base::make_span(image->data), "jpeg");
+ // Send base-64 encoded image to JS side. If |image| is blank (i.e.
+ // there is no data), send a blank URI.
+ std::string data_uri;
+ if (image)
+ data_uri = webui::MakeDataURIForImage(base::make_span(image->data), "jpeg");
const int tab_id = extensions::ExtensionTabUtil::GetTabId(tab);
FireWebUIListener("tab-thumbnail-updated", base::Value(tab_id),
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler_unittest.cc
index 3c1f9a7db6b..15c3626066e 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_handler_unittest.cc
@@ -229,13 +229,13 @@ TEST_F(TabStripUIHandlerTest, MoveGroup) {
args.AppendInteger(new_index);
handler()->HandleMoveGroup(&args);
- std::vector<int> tabs_in_group = browser()
- ->tab_strip_model()
- ->group_model()
- ->GetTabGroup(group_id)
- ->ListTabs();
- ASSERT_EQ(new_index, tabs_in_group.front());
- ASSERT_EQ(new_index, tabs_in_group.back());
+ 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);
EXPECT_EQ(1U, web_ui()->call_data().size());
const content::TestWebUI::CallData& call_data =
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 df257b0298a..1b23814e6f2 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
@@ -22,6 +22,7 @@
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/clipboard/custom_data_helper.h"
#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/gfx/range/range.h"
namespace tab_strip_ui {
@@ -122,7 +123,7 @@ bool DropTabsInNewBrowser(Browser* new_browser,
return false;
Browser* source_browser = nullptr;
- std::vector<int> tab_indices_to_move;
+ gfx::Range tab_indices_to_move;
base::Optional<tab_groups::TabGroupId> source_group_id;
// TODO(https://crbug.com/1069869): de-duplicate with
@@ -141,7 +142,7 @@ bool DropTabsInNewBrowser(Browser* new_browser,
/* contents = */ nullptr, &source_index)) {
return false;
}
- tab_indices_to_move.push_back(source_index);
+ tab_indices_to_move = gfx::Range(source_index, source_index + 1);
} else {
std::string group_id_utf8 = base::UTF16ToUTF8(group_id_str);
source_browser =
@@ -162,8 +163,8 @@ bool DropTabsInNewBrowser(Browser* new_browser,
*source_group_id, *source_group->visual_data());
}
- for (size_t i = 0; i < tab_indices_to_move.size(); ++i) {
- int source_index = tab_indices_to_move[i] - i;
+ const int source_index = tab_indices_to_move.start();
+ for (size_t i = 0; i < tab_indices_to_move.length(); ++i) {
MoveTabAcrossWindows(source_browser, source_index, new_browser, i,
source_group_id);
}
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc b/chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc
index 161644f993a..ab1b9ea52c3 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker.cc
@@ -8,21 +8,24 @@
#include <utility>
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/thumbnails/thumbnail_tab_helper.h"
#include "content/public/browser/web_contents_observer.h"
// Handles requests for a given tab's thumbnail and watches for thumbnail
// updates for the lifetime of the tab.
-class ThumbnailTracker::ContentsData : public content::WebContentsObserver,
- public ThumbnailImage::Observer {
+class ThumbnailTracker::ContentsData : public content::WebContentsObserver {
public:
ContentsData(ThumbnailTracker* parent, content::WebContents* contents)
: content::WebContentsObserver(contents), parent_(parent) {
thumbnail_ = parent_->thumbnail_getter_.Run(contents);
- if (thumbnail_)
- observer_.Add(thumbnail_.get());
+ if (!thumbnail_)
+ return;
+
+ subscription_ = thumbnail_->Subscribe();
+ subscription_->SetCompressedImageCallback(base::BindRepeating(
+ &ContentsData::ThumbnailImageCallback, base::Unretained(this)));
}
void RequestThumbnail() {
@@ -35,7 +38,7 @@ class ThumbnailTracker::ContentsData : public content::WebContentsObserver,
// We must un-observe each ThumbnailImage when the WebContents it came from
// closes.
if (thumbnail_) {
- observer_.Remove(thumbnail_.get());
+ subscription_.reset();
thumbnail_.reset();
}
@@ -43,23 +46,21 @@ class ThumbnailTracker::ContentsData : public content::WebContentsObserver,
parent_->ContentsClosed(web_contents());
}
- // ThumbnailImage::Observer:
- void OnCompressedThumbnailDataAvailable(
- CompressedThumbnailData thumbnail_image) override {
- parent_->ThumbnailUpdated(web_contents(), thumbnail_image);
+ private:
+ void ThumbnailImageCallback(CompressedThumbnailData image) {
+ parent_->ThumbnailUpdated(web_contents(), image);
}
- private:
ThumbnailTracker* parent_;
scoped_refptr<ThumbnailImage> thumbnail_;
- ScopedObserver<ThumbnailImage, ThumbnailImage::Observer> observer_{this};
+ std::unique_ptr<ThumbnailImage::Subscription> subscription_;
DISALLOW_COPY_AND_ASSIGN(ContentsData);
};
ThumbnailTracker::ThumbnailTracker(ThumbnailUpdatedCallback callback)
: ThumbnailTracker(std::move(callback),
- base::Bind(GetThumbnailFromTabHelper)) {}
+ base::BindRepeating(GetThumbnailFromTabHelper)) {}
ThumbnailTracker::ThumbnailTracker(ThumbnailUpdatedCallback callback,
GetThumbnailCallback thumbnail_getter)
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker_unittest.cc b/chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker_unittest.cc
index f5668777afb..92c6c42020f 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/thumbnail_tracker_unittest.cc
@@ -44,8 +44,8 @@ class ThumbnailTrackerTest : public ::testing::Test,
ThumbnailTrackerTest()
: thumbnail_tracker_(
thumbnail_updated_callback_.Get(),
- base::Bind(&ThumbnailTrackerTest::GetTestingThumbnail,
- base::Unretained(this))) {}
+ base::BindRepeating(&ThumbnailTrackerTest::GetTestingThumbnail,
+ base::Unretained(this))) {}
static SkBitmap CreateTestingBitmap() {
SkBitmap bitmap;
diff --git a/chromium/chrome/browser/ui/webui/test_data_source.cc b/chromium/chrome/browser/ui/webui/test_data_source.cc
index 7747acb4477..15a78cbeaac 100644
--- a/chromium/chrome/browser/ui/webui/test_data_source.cc
+++ b/chromium/chrome/browser/ui/webui/test_data_source.cc
@@ -38,8 +38,18 @@ TestDataSource::TestDataSource(std::string root) {
gen_root_ = exe_dir.AppendASCII("gen/chrome/test/data/" + root)
.NormalizePathSeparators();
DCHECK(exe_dir.IsParent(gen_root_));
+
+ custom_paths_ = {
+ {"/chai.js", "third_party/chaijs/chai.js"},
+ {"/mocha.js", "third_party/mocha/mocha.js"},
+ {"/test_loader.html", "ui/webui/resources/html/test_loader.html"},
+ {"/test_loader.js", "ui/webui/resources/js/test_loader.js"},
+ {"/test_loader_util.js", "ui/webui/resources/js/test_loader_util.js"},
+ };
}
+TestDataSource::~TestDataSource() = default;
+
std::string TestDataSource::GetSource() {
return "test";
}
@@ -56,14 +66,16 @@ void TestDataSource::StartDataRequest(
}
std::string TestDataSource::GetMimeType(const std::string& path) {
- if (base::EndsWith(path, ".html", base::CompareCase::INSENSITIVE_ASCII) ||
+ std::string clean_path = GetURLForPath(path).path();
+ if (base::EndsWith(clean_path, ".html",
+ base::CompareCase::INSENSITIVE_ASCII) ||
base::StartsWith(GetURLForPath(path).query(), 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(path, ".js", base::CompareCase::INSENSITIVE_ASCII))
+ CHECK(base::EndsWith(clean_path, ".js", base::CompareCase::INSENSITIVE_ASCII))
<< "Tried to read file with unexpected type from test data source: "
<< path;
return "application/javascript";
@@ -104,12 +116,14 @@ void TestDataSource::ReadFile(
GURL url = GetURLForPath(path);
CHECK(url.is_valid());
- if (url.path() == "/chai.js") {
+
+ // First check if a custom path mapping exists for the requested URL.
+ auto it = custom_paths_.find(url.path());
+ if (it != custom_paths_.end()) {
base::FilePath src_root;
CHECK(base::PathService::Get(base::DIR_SOURCE_ROOT, &src_root));
base::FilePath file_path =
- src_root.AppendASCII("third_party/chaijs/chai.js")
- .NormalizePathSeparators();
+ src_root.AppendASCII(it->second).NormalizePathSeparators();
CHECK(base::ReadFileToString(file_path, &content))
<< url.spec() << "=" << file_path.value();
scoped_refptr<base::RefCountedString> response =
@@ -133,17 +147,20 @@ void TestDataSource::ReadFile(
<< url.spec() << "=" << file_path.value();
content = "<script type=\"module\" src=\"" + js_path + "\"></script>";
} else {
- // Try the |src_root_| folder first.
+ // Try the |gen_root_| folder first, covering cases where the test file is
+ // generated at build time. We do this first as if a test file exists under
+ // the same name in the src and gen directories, the generated file is
+ // generally the desired file (for example, may have been preprocessed).
base::FilePath file_path =
- src_root_.Append(base::FilePath::FromUTF8Unsafe(path));
+ gen_root_.Append(base::FilePath::FromUTF8Unsafe(path));
if (base::PathExists(file_path)) {
CHECK(base::ReadFileToString(file_path, &content))
<< url.spec() << "=" << file_path.value();
} else {
- // Then try the |gen_root_| folder, covering cases where the test file is
+ // Then try the |src_root_| folder, covering cases where the test file is
// generated at build time.
base::FilePath file_path =
- gen_root_.Append(base::FilePath::FromUTF8Unsafe(path));
+ src_root_.Append(base::FilePath::FromUTF8Unsafe(path));
CHECK(base::ReadFileToString(file_path, &content))
<< url.spec() << "=" << file_path.value();
}
diff --git a/chromium/chrome/browser/ui/webui/test_data_source.h b/chromium/chrome/browser/ui/webui/test_data_source.h
index 5048d07d7d7..57cab7197d0 100644
--- a/chromium/chrome/browser/ui/webui/test_data_source.h
+++ b/chromium/chrome/browser/ui/webui/test_data_source.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_TEST_DATA_SOURCE_H_
#define CHROME_BROWSER_UI_WEBUI_TEST_DATA_SOURCE_H_
+#include <map>
#include <string>
#include "base/files/file_path.h"
@@ -16,7 +17,7 @@
class TestDataSource : public content::URLDataSource {
public:
explicit TestDataSource(std::string root);
- ~TestDataSource() override = default;
+ ~TestDataSource() override;
private:
void StartDataRequest(
@@ -42,6 +43,7 @@ class TestDataSource : public content::URLDataSource {
base::FilePath src_root_;
base::FilePath gen_root_;
+ std::map<std::string, std::string> custom_paths_;
DISALLOW_COPY_AND_ASSIGN(TestDataSource);
};
diff --git a/chromium/chrome/browser/ui/webui/test_files_request_filter.cc b/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
index 7b971f56cf1..72f46a3fda6 100644
--- a/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
+++ b/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
@@ -52,7 +52,7 @@ void HandleTestFileRequestCallback(
namespace test {
content::WebUIDataSource::HandleRequestCallback GetTestFilesRequestFilter() {
- return base::Bind(&HandleTestFileRequestCallback);
+ return base::BindRepeating(&HandleTestFileRequestCallback);
}
content::WebUIDataSource::ShouldHandleRequestCallback
diff --git a/chromium/chrome/browser/ui/webui/theme_handler.cc b/chromium/chrome/browser/ui/webui/theme_handler.cc
index a1d7401a815..2198f534cc6 100644
--- a/chromium/chrome/browser/ui/webui/theme_handler.cc
+++ b/chromium/chrome/browser/ui/webui/theme_handler.cc
@@ -40,12 +40,12 @@ void ThemeHandler::OnJavascriptAllowed() {
content::Source<ThemeService>(
ThemeServiceFactory::GetForProfile(GetProfile())));
// Or native theme change.
- theme_observer_.Add(ui::NativeTheme::GetInstanceForNativeUi());
+ theme_observation_.Observe(ui::NativeTheme::GetInstanceForNativeUi());
}
void ThemeHandler::OnJavascriptDisallowed() {
registrar_.RemoveAll();
- theme_observer_.RemoveAll();
+ theme_observation_.Reset();
}
void ThemeHandler::Observe(int type,
diff --git a/chromium/chrome/browser/ui/webui/theme_handler.h b/chromium/chrome/browser/ui/webui/theme_handler.h
index 5de97849396..f7c0c351f31 100644
--- a/chromium/chrome/browser/ui/webui/theme_handler.h
+++ b/chromium/chrome/browser/ui/webui/theme_handler.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_THEME_HANDLER_H_
#include "base/macros.h"
-#include "base/scoped_observer.h"
+#include "base/scoped_observation.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -54,8 +54,8 @@ class ThemeHandler : public content::WebUIMessageHandler,
content::NotificationRegistrar registrar_;
- ScopedObserver<ui::NativeTheme, ui::NativeThemeObserver> theme_observer_{
- this};
+ base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
+ theme_observation_{this};
DISALLOW_COPY_AND_ASSIGN(ThemeHandler);
};
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 0d5c90ec6ee..ec016a9aae1 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
@@ -12,7 +12,6 @@
#include "base/callback_helpers.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/translate/translate_service.h"
@@ -22,21 +21,20 @@
#include "components/translate/core/browser/translate_download_manager.h"
#include "components/translate/core/browser/translate_error_details.h"
#include "components/translate/core/browser/translate_event_details.h"
+#include "components/translate/core/browser/translate_manager.h"
#include "components/translate/core/browser/translate_pref_names.h"
#include "components/translate/core/browser/translate_prefs.h"
#include "components/translate/core/common/language_detection_details.h"
#include "components/variations/service/variations_service.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
ChromeTranslateInternalsHandler::ChromeTranslateInternalsHandler() {
- notification_registrar_.Add(this,
- chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
- content::NotificationService::AllSources());
+ detection_subscription_ =
+ translate::TranslateManager::RegisterLanguageDetectedCallback(
+ base::BindRepeating(
+ &ChromeTranslateInternalsHandler::LanguageDetected,
+ base::Unretained(this)));
}
ChromeTranslateInternalsHandler::~ChromeTranslateInternalsHandler() {}
@@ -67,22 +65,7 @@ void ChromeTranslateInternalsHandler::RegisterMessages() {
RegisterMessageCallbacks();
}
-void ChromeTranslateInternalsHandler::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, type);
-
- content::WebContents* web_contents =
- content::Source<content::WebContents>(source).ptr();
- const translate::LanguageDetectionDetails* language_detection_details =
- content::Details<const translate::LanguageDetectionDetails>(details)
- .ptr();
- if (web_contents->GetBrowserContext()->IsOffTheRecord() ||
- !GetTranslateClient()->IsTranslatableURL(
- language_detection_details->url)) {
- return;
- }
-
- AddLanguageDetectionDetails(*language_detection_details);
+void ChromeTranslateInternalsHandler::LanguageDetected(
+ const translate::LanguageDetectionDetails& details) {
+ AddLanguageDetectionDetails(details);
}
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 0b5ea14feaf..1307c0585bb 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
@@ -7,17 +7,15 @@
#include <string>
+#include "base/callback_list.h"
#include "base/macros.h"
#include "components/translate/translate_internals/translate_internals_handler.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui_message_handler.h"
// The handler for JavaScript messages for chrome://translate-internals.
class ChromeTranslateInternalsHandler
: public translate::TranslateInternalsHandler,
- public content::WebUIMessageHandler,
- public content::NotificationObserver {
+ public content::WebUIMessageHandler {
public:
ChromeTranslateInternalsHandler();
~ChromeTranslateInternalsHandler() override;
@@ -34,15 +32,12 @@ class ChromeTranslateInternalsHandler
// content::WebUIMessageHandler methods:
void RegisterMessages() override;
- // content::NotificationObserver implementation:
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
+ void LanguageDetected(const translate::LanguageDetectionDetails& details);
private:
- content::NotificationRegistrar notification_registrar_;
+ base::CallbackListSubscription detection_subscription_;
DISALLOW_COPY_AND_ASSIGN(ChromeTranslateInternalsHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_CHROME_TRANSLATE_INTERNALS_HANDLER_H_ \ No newline at end of file
+#endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_CHROME_TRANSLATE_INTERNALS_HANDLER_H_
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 74131bfe53c..719ae2bce9e 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
@@ -41,8 +41,8 @@ content::WebUIDataSource* CreateTranslateInternalsHTMLSource() {
source->AddString(key, value);
}
- // Current cld-version is "3".
- source->AddString("cld-version", "3");
+ // Current language detection model is "CLD3".
+ source->AddString("model-version", "CLD3");
return source;
}
diff --git a/chromium/chrome/browser/ui/webui/usb_internals/DIR_METADATA b/chromium/chrome/browser/ui/webui/usb_internals/DIR_METADATA
new file mode 100644
index 00000000000..d8d7bf94433
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/usb_internals/DIR_METADATA
@@ -0,0 +1,4 @@
+monorail {
+ component: "Blink>USB"
+}
+team_email: "webusb@chromium.org"
diff --git a/chromium/chrome/browser/ui/webui/usb_internals/OWNERS b/chromium/chrome/browser/ui/webui/usb_internals/OWNERS
index e59c8c5d296..bb9c68a5250 100644
--- a/chromium/chrome/browser/ui/webui/usb_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/usb_internals/OWNERS
@@ -2,6 +2,3 @@ per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
file://chrome/browser/usb/OWNERS
-
-# COMPONENT: Blink>USB
-# TEAM: webusb@chromium.org
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 477d124842a..f3594ffbf67 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
@@ -30,12 +30,12 @@ UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui)
{"usb_manager_test.mojom-webui.js",
IDR_USB_DEVICE_MANAGER_TEST_MOJOM_WEBUI_JS},
};
- webui::AddResourcePathsBulk(source, kPaths);
+ source->AddResourcePaths(kPaths);
webui::SetupWebUIDataSource(
source,
- base::make_span(kUsbInternalsResources, kUsbInternalsResourcesSize), "",
- IDR_USB_INTERNALS_HTML);
+ base::make_span(kUsbInternalsResources, kUsbInternalsResourcesSize),
+ IDR_USB_INTERNALS_USB_INTERNALS_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
diff --git a/chromium/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc b/chromium/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc
index 1de3e95e081..f1bf3dfe10a 100644
--- a/chromium/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc
@@ -10,8 +10,8 @@
#include "content/public/browser/web_ui.h"
UserActionsUIHandler::UserActionsUIHandler()
- : action_callback_(base::Bind(&UserActionsUIHandler::OnUserAction,
- base::Unretained(this))) {}
+ : action_callback_(base::BindRepeating(&UserActionsUIHandler::OnUserAction,
+ base::Unretained(this))) {}
UserActionsUIHandler::~UserActionsUIHandler() {
base::RemoveActionCallback(action_callback_);
diff --git a/chromium/chrome/browser/ui/webui/util/DIR_METADATA b/chromium/chrome/browser/ui/webui/util/DIR_METADATA
new file mode 100644
index 00000000000..8325efaab7d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/util/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>WebUI"
+}
diff --git a/chromium/chrome/browser/ui/webui/util/OWNERS b/chromium/chrome/browser/ui/webui/util/OWNERS
index 13b837bc5f2..36eec6a4fbf 100644
--- a/chromium/chrome/browser/ui/webui/util/OWNERS
+++ b/chromium/chrome/browser/ui/webui/util/OWNERS
@@ -2,5 +2,3 @@ dpapad@chromium.org
johntlee@chromium.org
robliao@chromium.org
tluk@chromium.org
-
-# COMPONENT: UI>Browser>WebUI \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/version_handler.cc b/chromium/chrome/browser/ui/webui/version/version_handler.cc
index 374a98da430..c38ef0830f3 100644
--- a/chromium/chrome/browser/ui/webui/version_handler.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_handler.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/version_handler.h"
+#include "chrome/browser/ui/webui/version/version_handler.h"
#include <stddef.h>
@@ -54,8 +54,7 @@ void GetFilePaths(const base::FilePath& profile_path,
VersionHandler::VersionHandler() {}
-VersionHandler::~VersionHandler() {
-}
+VersionHandler::~VersionHandler() {}
void VersionHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
diff --git a/chromium/chrome/browser/ui/webui/version_handler.h b/chromium/chrome/browser/ui/webui/version/version_handler.h
index db208ac96f2..8c0c75deb5e 100644
--- a/chromium/chrome/browser/ui/webui/version_handler.h
+++ b/chromium/chrome/browser/ui/webui/version/version_handler.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_VERSION_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_VERSION_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_H_
#include <vector>
@@ -48,4 +48,4 @@ class VersionHandler : public content::WebUIMessageHandler {
DISALLOW_COPY_AND_ASSIGN(VersionHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_VERSION_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/version_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.cc
index 869f34ae0b5..fdde9bc2c1b 100644
--- a/chromium/chrome/browser/ui/webui/version_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.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/version_handler_chromeos.h"
+#include "chrome/browser/ui/webui/version/version_handler_chromeos.h"
#include "base/bind.h"
#include "base/task/post_task.h"
diff --git a/chromium/chrome/browser/ui/webui/version_handler_chromeos.h b/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.h
index 0bc597a3270..b831a0f087a 100644
--- a/chromium/chrome/browser/ui/webui/version_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/version/version_handler_chromeos.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_VERSION_HANDLER_CHROMEOS_H_
-#define CHROME_BROWSER_UI_WEBUI_VERSION_HANDLER_CHROMEOS_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_CHROMEOS_H_
+#define CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_CHROMEOS_H_
#include <string>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/ui/webui/version_handler.h"
+#include "chrome/browser/ui/webui/version/version_handler.h"
#include "chromeos/dbus/util/version_loader.h"
// VersionHandlerChromeOS is responsible for loading the Chrome OS
@@ -33,4 +33,4 @@ class VersionHandlerChromeOS : public VersionHandler {
DISALLOW_COPY_AND_ASSIGN(VersionHandlerChromeOS);
};
-#endif // CHROME_BROWSER_UI_WEBUI_VERSION_HANDLER_CHROMEOS_H_
+#endif // CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_CHROMEOS_H_
diff --git a/chromium/chrome/browser/ui/webui/version_handler_win.cc b/chromium/chrome/browser/ui/webui/version/version_handler_win.cc
index 7ce031e4fed..541c822887e 100644
--- a/chromium/chrome/browser/ui/webui/version_handler_win.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_handler_win.cc
@@ -2,14 +2,14 @@
// 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/version_handler_win.h"
+#include "chrome/browser/ui/webui/version/version_handler_win.h"
#include "base/bind.h"
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/win/windows_version.h"
-#include "chrome/browser/ui/webui/version_util_win.h"
+#include "chrome/browser/ui/webui/version/version_util_win.h"
#include "content/public/browser/web_ui.h"
VersionHandlerWindows::VersionHandlerWindows() {}
diff --git a/chromium/chrome/browser/ui/webui/version_handler_win.h b/chromium/chrome/browser/ui/webui/version/version_handler_win.h
index 2c424dcc2f2..01d389dd9a8 100644
--- a/chromium/chrome/browser/ui/webui/version_handler_win.h
+++ b/chromium/chrome/browser/ui/webui/version/version_handler_win.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_VERSION_HANDLER_WIN_H_
-#define CHROME_BROWSER_UI_WEBUI_VERSION_HANDLER_WIN_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_WIN_H_
+#define CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_WIN_H_
#include <string>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/ui/webui/version_handler.h"
+#include "chrome/browser/ui/webui/version/version_handler.h"
// VersionHandlerWindows is responsible for loading the Windows OS version.
class VersionHandlerWindows : public VersionHandler {
@@ -32,4 +32,4 @@ class VersionHandlerWindows : public VersionHandler {
DISALLOW_COPY_AND_ASSIGN(VersionHandlerWindows);
};
-#endif // CHROME_BROWSER_UI_WEBUI_VERSION_HANDLER_WIN_H_
+#endif // CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_HANDLER_WIN_H_
diff --git a/chromium/chrome/browser/ui/webui/version_handler_win_unittest.cc b/chromium/chrome/browser/ui/webui/version/version_handler_win_unittest.cc
index 9345bb0a240..3e9f9fae4c3 100644
--- a/chromium/chrome/browser/ui/webui/version_handler_win_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_handler_win_unittest.cc
@@ -2,12 +2,12 @@
// 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/version_handler_win.h"
+#include "chrome/browser/ui/webui/version/version_handler_win.h"
#include "base/test/scoped_os_info_override_win.h"
#include "base/test/test_reg_util_win.h"
#include "base/win/registry.h"
-#include "chrome/browser/ui/webui/version_handler_win.h"
+#include "chrome/browser/ui/webui/version/version_handler_win.h"
#include "testing/gtest/include/gtest/gtest.h"
class WebUIWindowsVersion : public testing::Test {
diff --git a/chromium/chrome/browser/ui/webui/version_ui.cc b/chromium/chrome/browser/ui/webui/version/version_ui.cc
index 6352e6db826..a2d5348fa26 100644
--- a/chromium/chrome/browser/ui/webui/version_ui.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_ui.cc
@@ -2,23 +2,25 @@
// 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/version_ui.h"
+#include "chrome/browser/ui/webui/version/version_ui.h"
#include <memory>
#include "base/command_line.h"
#include "base/i18n/message_formatter.h"
+#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
-#include "chrome/browser/chrome_content_browser_client.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/version_handler.h"
-#include "chrome/browser/ui/webui/version_util_win.h"
+#include "chrome/browser/ui/webui/version/version_handler.h"
+#include "chrome/browser/ui/webui/version/version_util_win.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
+#include "components/embedder_support/user_agent_utils.h"
#include "components/grit/components_resources.h"
#include "components/strings/grit/components_chromium_strings.h"
#include "components/strings/grit/components_strings.h"
@@ -38,8 +40,8 @@
#include "chrome/browser/ui/webui/theme_source.h"
#endif
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/ui/webui/version_handler_chromeos.h"
+#if BUILDFLAG(IS_CHROMEOS_ASH)
+#include "chrome/browser/ui/webui/version/version_handler_chromeos.h"
#endif
#if defined(OS_MAC)
@@ -47,7 +49,7 @@
#endif
#if defined(OS_WIN)
-#include "chrome/browser/ui/webui/version_handler_win.h"
+#include "chrome/browser/ui/webui/version/version_handler_win.h"
#endif
using content::WebUIDataSource;
@@ -70,19 +72,19 @@ WebUIDataSource* CreateVersionUIDataSource() {
{version_ui::kProfilePathName, IDS_VERSION_UI_PROFILE_PATH},
{version_ui::kVariationsName, IDS_VERSION_UI_VARIATIONS},
{version_ui::kVariationsCmdName, IDS_VERSION_UI_VARIATIONS_CMD},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
{version_ui::kARC, IDS_ARC_LABEL},
{version_ui::kPlatform, IDS_PLATFORM_LABEL},
{version_ui::kCustomizationId, IDS_VERSION_UI_CUSTOMIZATION_ID},
{version_ui::kFirmwareVersion, IDS_VERSION_UI_FIRMWARE_VERSION},
#else
{version_ui::kOSName, IDS_VERSION_UI_OS},
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if defined(OS_ANDROID)
{version_ui::kGmsName, IDS_VERSION_UI_GMS},
#endif // OS_ANDROID
};
- AddLocalizedStringsBulk(html_source, kStrings);
+ html_source->AddLocalizedStrings(kStrings);
VersionUI::AddVersionDetailStrings(html_source);
@@ -100,7 +102,7 @@ VersionUI::VersionUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
web_ui->AddMessageHandler(std::make_unique<VersionHandlerChromeOS>());
#elif defined(OS_WIN)
web_ui->AddMessageHandler(std::make_unique<VersionHandlerWindows>());
@@ -170,7 +172,8 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) {
l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT),
base::Time::Now()));
html_source->AddString(version_ui::kCL, version_info::GetLastChange());
- html_source->AddString(version_ui::kUserAgent, GetUserAgent());
+ html_source->AddString(version_ui::kUserAgent,
+ embedder_support::GetUserAgent());
// Note that the executable path and profile path are retrieved asynchronously
// and returned in VersionHandler::OnGotFilePaths. The area is initially
// blank.
@@ -179,7 +182,7 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) {
#if defined(OS_MAC)
html_source->AddString(version_ui::kOSType, base::mac::GetOSDisplayName());
-#elif !defined(OS_CHROMEOS)
+#elif !BUILDFLAG(IS_CHROMEOS_ASH)
html_source->AddString(version_ui::kOSType, version_info::GetOSType());
#endif // OS_MAC
@@ -193,7 +196,8 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) {
#if defined(OS_WIN)
html_source->AddString(
version_ui::kCommandLine,
- base::CommandLine::ForCurrentProcess()->GetCommandLineString());
+ base::AsString16(
+ base::CommandLine::ForCurrentProcess()->GetCommandLineString()));
#elif defined(OS_POSIX)
std::string command_line;
typedef std::vector<std::string> ArgvList;
diff --git a/chromium/chrome/browser/ui/webui/version_ui.h b/chromium/chrome/browser/ui/webui/version/version_ui.h
index 29a29217423..4ba0c5d61bf 100644
--- a/chromium/chrome/browser/ui/webui/version_ui.h
+++ b/chromium/chrome/browser/ui/webui/version/version_ui.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_VERSION_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_VERSION_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UI_H_
#include "base/macros.h"
#include "content/public/browser/web_ui_controller.h"
@@ -26,4 +26,4 @@ class VersionUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(VersionUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_VERSION_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/version_util_win.cc b/chromium/chrome/browser/ui/webui/version/version_util_win.cc
index aeca237461c..5eb0bcfe2bf 100644
--- a/chromium/chrome/browser/ui/webui/version_util_win.cc
+++ b/chromium/chrome/browser/ui/webui/version/version_util_win.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/version_util_win.h"
+#include "chrome/browser/ui/webui/version/version_util_win.h"
#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/win/windows_version.h"
#include "chrome/install_static/install_details.h"
#include "components/strings/grit/components_strings.h"
@@ -74,11 +75,11 @@ std::string GetFullWindowsVersion() {
}
base::string16 GetCohortVersionInfo() {
- base::string16 update_cohort_name =
+ std::wstring update_cohort_name =
install_static::InstallDetails::Get().update_cohort_name();
if (!update_cohort_name.empty()) {
return l10n_util::GetStringFUTF16(IDS_VERSION_UI_COHORT_NAME,
- update_cohort_name);
+ base::WideToUTF16(update_cohort_name));
}
return base::string16();
diff --git a/chromium/chrome/browser/ui/webui/version_util_win.h b/chromium/chrome/browser/ui/webui/version/version_util_win.h
index d5347321e8a..b328bd5a6db 100644
--- a/chromium/chrome/browser/ui/webui/version_util_win.h
+++ b/chromium/chrome/browser/ui/webui/version/version_util_win.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_VERSION_UTIL_WIN_H_
-#define CHROME_BROWSER_UI_WEBUI_VERSION_UTIL_WIN_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UTIL_WIN_H_
+#define CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UTIL_WIN_H_
#include <string>
@@ -24,4 +24,4 @@ base::string16 GetCohortVersionInfo();
} // namespace win
} // namespace version_utils
-#endif // CHROME_BROWSER_UI_WEBUI_VERSION_UTIL_WIN_H_
+#endif // CHROME_BROWSER_UI_WEBUI_VERSION_VERSION_UTIL_WIN_H_
diff --git a/chromium/chrome/browser/ui/webui/video_tutorials/DIR_METADATA b/chromium/chrome/browser/ui/webui/video_tutorials/DIR_METADATA
new file mode 100644
index 00000000000..966408a373e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/video_tutorials/DIR_METADATA
@@ -0,0 +1,4 @@
+monorail {
+ component: "Upboarding>VideoTutorials"
+}
+team_email: "chrome-upboarding-eng@google.com"
diff --git a/chromium/chrome/browser/ui/webui/video_tutorials/OWNERS b/chromium/chrome/browser/ui/webui/video_tutorials/OWNERS
index 4ed34726dac..36c3bec3a13 100644
--- a/chromium/chrome/browser/ui/webui/video_tutorials/OWNERS
+++ b/chromium/chrome/browser/ui/webui/video_tutorials/OWNERS
@@ -1,4 +1 @@
file://chrome/browser/video_tutorials/OWNERS
-
-# TEAM: chrome-upboarding-eng@google.com
-# COMPONENT: Upboarding>VideoTutorials
diff --git a/chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.h b/chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.h
deleted file mode 100644
index 219e14db26d..00000000000
--- a/chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2019 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_VIDEO_TUTORIALS_VIDEO_PLAYER_SOURCE_H_
-#define CHROME_BROWSER_UI_WEBUI_VIDEO_TUTORIALS_VIDEO_PLAYER_SOURCE_H_
-
-#include "content/public/browser/web_ui_data_source.h"
-
-namespace video_tutorials {
-
-// The data source creation for chrome-untrusted://video-tutorials/.
-content::WebUIDataSource* CreateVideoPlayerUntrustedDataSource();
-
-} // namespace video_tutorials
-
-#endif // CHROME_BROWSER_UI_WEBUI_VIDEO_TUTORIALS_VIDEO_PLAYER_SOURCE_H_
diff --git a/chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.cc b/chromium/chrome/browser/ui/webui/video_tutorials/video_player_ui.cc
index aac47cf20f3..e0bc9e9d3a2 100644
--- a/chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.cc
+++ b/chromium/chrome/browser/ui/webui/video_tutorials/video_player_ui.cc
@@ -1,17 +1,31 @@
-// Copyright 2020 The Chromium Authors. All rights reserved.
+// 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.
-#include "chrome/browser/ui/webui/video_tutorials/video_player_source.h"
+#include "chrome/browser/ui/webui/video_tutorials/video_player_ui.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
+#include "content/public/browser/web_contents.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"
namespace video_tutorials {
-// static
-content::WebUIDataSource* CreateVideoPlayerUntrustedDataSource() {
+VideoPlayerUIConfig::VideoPlayerUIConfig()
+ : WebUIConfig(content::kChromeUIUntrustedScheme,
+ chrome::kChromeUIUntrustedVideoTutorialsHost) {}
+
+VideoPlayerUIConfig::~VideoPlayerUIConfig() = default;
+
+std::unique_ptr<content::WebUIController>
+VideoPlayerUIConfig::CreateWebUIController(content::WebUI* web_ui) {
+ return std::make_unique<VideoPlayerUI>(web_ui);
+}
+
+VideoPlayerUI::VideoPlayerUI(content::WebUI* web_ui)
+ : ui::UntrustedWebUIController(web_ui) {
content::WebUIDataSource* source = content::WebUIDataSource::Create(
chrome::kChromeUIUntrustedVideoPlayerUrl);
source->AddResourcePath("", IDR_VIDEO_PLAYER_HTML);
@@ -26,11 +40,11 @@ content::WebUIDataSource* CreateVideoPlayerUntrustedDataSource() {
network::mojom::CSPDirectiveName::MediaSrc, "media-src https:;");
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::StyleSrc, "style-src 'self';");
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome-untrusted://resources/ 'self';");
- return source;
+ auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
+ content::WebUIDataSource::Add(browser_context, source);
}
+VideoPlayerUI::~VideoPlayerUI() = default;
+
} // namespace video_tutorials
diff --git a/chromium/chrome/browser/ui/webui/video_tutorials/video_player_ui.h b/chromium/chrome/browser/ui/webui/video_tutorials/video_player_ui.h
new file mode 100644
index 00000000000..2dec90567dd
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/video_tutorials/video_player_ui.h
@@ -0,0 +1,36 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_VIDEO_TUTORIALS_VIDEO_PLAYER_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_VIDEO_TUTORIALS_VIDEO_PLAYER_UI_H_
+
+#include "ui/webui/untrusted_web_ui_controller.h"
+#include "ui/webui/webui_config.h"
+
+namespace content {
+class WebUI;
+} // namespace content
+
+namespace video_tutorials {
+
+class VideoPlayerUIConfig : public ui::WebUIConfig {
+ public:
+ VideoPlayerUIConfig();
+ ~VideoPlayerUIConfig() override;
+
+ std::unique_ptr<content::WebUIController> CreateWebUIController(
+ content::WebUI* web_ui) override;
+};
+
+class VideoPlayerUI : public ui::UntrustedWebUIController {
+ public:
+ explicit VideoPlayerUI(content::WebUI* web_ui);
+ VideoPlayerUI(const VideoPlayerUI&) = delete;
+ VideoPlayerUI& operator=(const VideoPlayerUI&) = delete;
+ ~VideoPlayerUI() override;
+};
+
+} // namespace video_tutorials
+
+#endif // CHROME_BROWSER_UI_WEBUI_VIDEO_TUTORIALS_VIDEO_PLAYER_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc b/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
index d755bb79c75..6037116676b 100644
--- a/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
+++ b/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
@@ -14,7 +14,6 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_frame_host.h"
-#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/test/test_utils.h"
@@ -22,21 +21,15 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
-using content::RenderViewHost;
+WebUITestHandler::WebUITestHandler() = default;
+WebUITestHandler::~WebUITestHandler() = default;
-WebUITestHandler::WebUITestHandler()
- : test_done_(false),
- test_succeeded_(false),
- run_test_done_(false),
- run_test_succeeded_(false) {}
-
-WebUITestHandler::~WebUITestHandler() {}
-
-void WebUITestHandler::PreloadJavaScript(const base::string16& js_text,
- RenderViewHost* preload_host) {
- DCHECK(preload_host);
+void WebUITestHandler::PreloadJavaScript(
+ const base::string16& js_text,
+ content::RenderFrameHost* preload_frame) {
+ DCHECK(preload_frame);
mojo::AssociatedRemote<chrome::mojom::ChromeRenderFrame> chrome_render_frame;
- preload_host->GetMainFrame()->GetRemoteAssociatedInterfaces()->GetInterface(
+ preload_frame->GetRemoteAssociatedInterfaces()->GetInterface(
&chrome_render_frame);
chrome_render_frame->ExecuteWebUIJavaScript(js_text);
}
diff --git a/chromium/chrome/browser/ui/webui/web_ui_test_handler.h b/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
index 90c461d8f08..d6a72f21110 100644
--- a/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
+++ b/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
@@ -16,7 +16,7 @@ class Value;
} // namespace base
namespace content {
-class RenderViewHost;
+class RenderFrameHost;
}
// This class registers test framework specific handlers on WebUI objects.
@@ -25,10 +25,10 @@ class WebUITestHandler {
WebUITestHandler();
virtual ~WebUITestHandler();
- // Sends a message through |preload_host| with the |js_text| to preload at the
- // appropriate time before the onload call is made.
+ // Sends a message through |preload_frame| with the |js_text| to preload at
+ // the appropriate time before the onload call is made.
void PreloadJavaScript(const base::string16& js_text,
- content::RenderViewHost* preload_host);
+ content::RenderFrameHost* preload_frame);
// Runs |js_text| in this object's WebUI frame. Does not wait for any result.
void RunJavaScript(const base::string16& js_text);
@@ -56,22 +56,22 @@ class WebUITestHandler {
bool WaitForResult();
// Received test pass/fail;
- bool test_done_;
+ bool test_done_ = false;
// Pass fail result of current test.
- bool test_succeeded_;
+ bool test_succeeded_ = false;
// Test code finished trying to execute. This will be set to true when the
// selected tab is done with this execution request whether it was able to
// parse/execute the javascript or not.
- bool run_test_done_;
+ bool run_test_done_ = false;
// Test code was able to execute successfully. This is *NOT* the test
// pass/fail.
- bool run_test_succeeded_;
+ bool run_test_succeeded_ = false;
// Quits the currently running RunLoop.
- base::Closure quit_closure_;
+ base::RepeatingClosure quit_closure_;
DISALLOW_COPY_AND_ASSIGN(WebUITestHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/webapks_handler.cc b/chromium/chrome/browser/ui/webui/webapks/webapks_handler.cc
index e7417b006aa..c30a2dcb406 100644
--- a/chromium/chrome/browser/ui/webui/webapks_handler.cc
+++ b/chromium/chrome/browser/ui/webui/webapks/webapks_handler.cc
@@ -2,17 +2,17 @@
// 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/webapks_handler.h"
+#include "chrome/browser/ui/webui/webapks/webapks_handler.h"
#include <string>
#include "base/bind.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
-#include "chrome/browser/android/color_helpers.h"
#include "chrome/browser/android/shortcut_helper.h"
#include "content/public/browser/web_ui.h"
#include "third_party/blink/public/common/manifest/manifest_util.h"
+#include "ui/android/color_helpers.h"
#include "ui/gfx/color_utils.h"
WebApksHandler::WebApksHandler()
@@ -64,9 +64,9 @@ void WebApksHandler::OnWebApkInfoRetrieved(const WebApkInfo& webapk_info) {
result.SetString("orientation", blink::WebScreenOrientationLockTypeToString(
webapk_info.orientation));
result.SetString("themeColor",
- OptionalSkColorToString(webapk_info.theme_color));
+ ui::OptionalSkColorToString(webapk_info.theme_color));
result.SetString("backgroundColor",
- OptionalSkColorToString(webapk_info.background_color));
+ ui::OptionalSkColorToString(webapk_info.background_color));
result.SetDouble("lastUpdateCheckTimeMs",
webapk_info.last_update_check_time.ToJsTime());
result.SetDouble("lastUpdateCompletionTimeMs",
diff --git a/chromium/chrome/browser/ui/webui/webapks_handler.h b/chromium/chrome/browser/ui/webui/webapks/webapks_handler.h
index bcb67234f20..a4a25f7ced6 100644
--- a/chromium/chrome/browser/ui/webui/webapks_handler.h
+++ b/chromium/chrome/browser/ui/webui/webapks/webapks_handler.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_WEBAPKS_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_WEBAPKS_HANDLER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_WEBAPKS_WEBAPKS_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_WEBAPKS_WEBAPKS_HANDLER_H_
#include <memory>
@@ -45,4 +45,4 @@ class WebApksHandler : public content::WebUIMessageHandler {
DISALLOW_COPY_AND_ASSIGN(WebApksHandler);
};
-#endif // CHROME_BROWSER_UI_WEBUI_WEBAPKS_HANDLER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_WEBAPKS_WEBAPKS_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/webapks_ui.cc b/chromium/chrome/browser/ui/webui/webapks/webapks_ui.cc
index 9e45e8dc7d6..b4a89b0c27a 100644
--- a/chromium/chrome/browser/ui/webui/webapks_ui.cc
+++ b/chromium/chrome/browser/ui/webui/webapks/webapks_ui.cc
@@ -2,15 +2,17 @@
// 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/webapks_ui.h"
+#include "chrome/browser/ui/webui/webapks/webapks_ui.h"
#include <memory>
#include <string>
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/webapks_handler.h"
+#include "chrome/browser/ui/webui/webapks/webapks_handler.h"
+#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
-#include "chrome/grit/webapks_ui_resources.h"
+#include "chrome/grit/webapks_resources.h"
+#include "chrome/grit/webapks_resources_map.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -22,9 +24,10 @@ WebUIDataSource* CreateWebApksUIDataSource() {
WebUIDataSource* html_source =
WebUIDataSource::Create(chrome::kChromeUIWebApksHost);
html_source->UseStringsJs();
- html_source->AddResourcePath("webapks.js", IDR_WEBAPKS_UI_JS);
- html_source->AddResourcePath("about_webapks.css", IDR_WEBAPKS_UI_CSS);
- html_source->SetDefaultResource(IDR_WEBAPKS_UI_HTML);
+
+ html_source->AddResourcePaths(
+ base::make_span(kWebapksResources, kWebapksResourcesSize));
+ html_source->SetDefaultResource(IDR_WEBAPKS_ABOUT_WEBAPKS_HTML);
return html_source;
}
diff --git a/chromium/chrome/browser/ui/webui/webapks_ui.h b/chromium/chrome/browser/ui/webui/webapks/webapks_ui.h
index c2a1f0c95f9..6c1f52df633 100644
--- a/chromium/chrome/browser/ui/webui/webapks_ui.h
+++ b/chromium/chrome/browser/ui/webui/webapks/webapks_ui.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_WEBAPKS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_WEBAPKS_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_WEBAPKS_WEBAPKS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_WEBAPKS_WEBAPKS_UI_H_
#include "base/macros.h"
#include "content/public/browser/web_ui_controller.h"
@@ -18,4 +18,4 @@ class WebApksUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(WebApksUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_WEBAPKS_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_WEBAPKS_WEBAPKS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/webui_js_exception/webui_js_exception_ui.cc b/chromium/chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.cc
index 97ae8b73923..be51a55bc25 100644
--- a/chromium/chrome/browser/ui/webui/webui_js_exception/webui_js_exception_ui.cc
+++ b/chromium/chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.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/webui_js_exception/webui_js_exception_ui.h"
+#include "chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.h"
#include <ios>
@@ -13,35 +13,34 @@
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/webui_url_constants.h"
-#include "chrome/grit/webui_js_exception_resources.h"
-#include "chrome/grit/webui_js_exception_resources_map.h"
+#include "chrome/grit/webui_js_error_resources.h"
+#include "chrome/grit/webui_js_error_resources_map.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_features.h"
-WebUIJsExceptionUI::WebUIJsExceptionUI(content::WebUI* web_ui)
+WebUIJsErrorUI::WebUIJsErrorUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) {
#if !defined(OS_WIN) && !defined(OS_FUCHSIA)
- VLOG(3) << std::boolalpha << "chrome://webuijsexception loading. "
+ VLOG(3) << std::boolalpha << "chrome://webuijserror loading. "
<< "Experiment state: send javascript errors is "
<< base::FeatureList::IsEnabled(
features::kSendWebUIJavaScriptErrorReports)
<< " and send to prod is "
<< features::kWebUIJavaScriptErrorReportsSendToProductionParam.Get();
#else
- VLOG(3) << std::boolalpha << "chrome://webuijsexception loading.";
+ VLOG(3) << "chrome://webuijserror loading.";
#endif
content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIWebUIJsExceptionHost);
- webui::SetupWebUIDataSource(source,
- base::make_span(kWebuiJsExceptionResources,
- kWebuiJsExceptionResourcesSize),
- std::string(),
- IDR_WEBUI_JS_EXCEPTION_WEBUI_JS_EXCEPTION_HTML);
+ content::WebUIDataSource::Create(chrome::kChromeUIWebUIJsErrorHost);
+ webui::SetupWebUIDataSource(
+ source,
+ base::make_span(kWebuiJsErrorResources, kWebuiJsErrorResourcesSize),
+ IDR_WEBUI_JS_ERROR_WEBUI_JS_ERROR_HTML);
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, source);
}
-WebUIJsExceptionUI::~WebUIJsExceptionUI() = default;
+WebUIJsErrorUI::~WebUIJsErrorUI() = default;
-WEB_UI_CONTROLLER_TYPE_IMPL(WebUIJsExceptionUI)
+WEB_UI_CONTROLLER_TYPE_IMPL(WebUIJsErrorUI)
diff --git a/chromium/chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.h b/chromium/chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.h
new file mode 100644
index 00000000000..69037ab7c0e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/webui_js_error/webui_js_error_ui.h
@@ -0,0 +1,22 @@
+// 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_WEBUI_JS_ERROR_WEBUI_JS_ERROR_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_WEBUI_JS_ERROR_WEBUI_JS_ERROR_UI_H_
+
+#include "content/public/browser/web_ui_controller.h"
+
+// The WebUI that controls chrome://webuijserror.
+class WebUIJsErrorUI : public content::WebUIController {
+ public:
+ explicit WebUIJsErrorUI(content::WebUI* web_ui);
+ ~WebUIJsErrorUI() override;
+ WebUIJsErrorUI(const WebUIJsErrorUI&) = delete;
+ WebUIJsErrorUI& operator=(const WebUIJsErrorUI&) = delete;
+
+ private:
+ WEB_UI_CONTROLLER_TYPE_DECL();
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_WEBUI_JS_ERROR_WEBUI_JS_ERROR_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/webui_js_exception/webui_js_exception_ui.h b/chromium/chrome/browser/ui/webui/webui_js_exception/webui_js_exception_ui.h
deleted file mode 100644
index d49f35a52d5..00000000000
--- a/chromium/chrome/browser/ui/webui/webui_js_exception/webui_js_exception_ui.h
+++ /dev/null
@@ -1,22 +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_WEBUI_JS_EXCEPTION_WEBUI_JS_EXCEPTION_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_WEBUI_JS_EXCEPTION_WEBUI_JS_EXCEPTION_UI_H_
-
-#include "content/public/browser/web_ui_controller.h"
-
-// The WebUI that controls chrome://webuijsexception.
-class WebUIJsExceptionUI : public content::WebUIController {
- public:
- explicit WebUIJsExceptionUI(content::WebUI* web_ui);
- ~WebUIJsExceptionUI() override;
- WebUIJsExceptionUI(const WebUIJsExceptionUI&) = delete;
- WebUIJsExceptionUI& operator=(const WebUIJsExceptionUI&) = delete;
-
- private:
- WEB_UI_CONTROLLER_TYPE_DECL();
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_WEBUI_JS_EXCEPTION_WEBUI_JS_EXCEPTION_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/webui_util.cc b/chromium/chrome/browser/ui/webui/webui_util.cc
index c8b71838306..8097c617748 100644
--- a/chromium/chrome/browser/ui/webui/webui_util.cc
+++ b/chromium/chrome/browser/ui/webui/webui_util.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/webui_util.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "content/public/browser/web_ui_data_source.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "ui/base/webui/web_ui_util.h"
@@ -12,7 +13,7 @@
#include "ui/resources/grit/webui_resources.h"
#include "ui/resources/grit/webui_resources_map.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -22,9 +23,7 @@
namespace webui {
-namespace {
-
-void SetupPolymer3Defaults(content::WebUIDataSource* source) {
+void SetJSModuleDefaults(content::WebUIDataSource* source) {
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
"script-src chrome://resources chrome://test 'self';");
@@ -33,50 +32,21 @@ void SetupPolymer3Defaults(content::WebUIDataSource* source) {
source->UseStringsJs();
source->EnableReplaceI18nInJS();
source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS);
+ source->AddResourcePath("test_loader_util.js",
+ IDR_WEBUI_JS_TEST_LOADER_UTIL_JS);
source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER_HTML);
}
-} // namespace
-
void SetupWebUIDataSource(content::WebUIDataSource* source,
- base::span<const GritResourceMap> resources,
- const std::string& generated_path,
+ base::span<const ResourcePath> resources,
int default_resource) {
- SetupPolymer3Defaults(source);
- // TODO (crbug.com/1132403): Replace usages of |generated_path| with the new
- // |resource_path| GRD property, and remove from here.
- bool has_gen_path = !generated_path.empty();
- for (const GritResourceMap& resource : resources) {
- std::string path = resource.name;
- if (has_gen_path && path.rfind(generated_path, 0) == 0) {
- path = path.substr(generated_path.size());
- }
-
- source->AddResourcePath(path, resource.value);
- }
+ SetJSModuleDefaults(source);
+ source->AddResourcePaths(resources);
source->AddResourcePath("", default_resource);
}
-void AddLocalizedStringsBulk(content::WebUIDataSource* html_source,
- base::span<const LocalizedString> strings) {
- for (const auto& str : strings)
- html_source->AddLocalizedString(str.name, str.id);
-}
-
-void AddResourcePathsBulk(content::WebUIDataSource* source,
- base::span<const ResourcePath> paths) {
- for (const auto& path : paths)
- source->AddResourcePath(path.path, path.id);
-}
-
-void AddResourcePathsBulk(content::WebUIDataSource* source,
- base::span<const GritResourceMap> resources) {
- for (const auto& resource : resources)
- source->AddResourcePath(resource.name, resource.value);
-}
-
bool IsEnterpriseManaged() {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
return connector->IsEnterpriseManaged();
diff --git a/chromium/chrome/browser/ui/webui/webui_util.h b/chromium/chrome/browser/ui/webui/webui_util.h
index 79148416201..25fb46c86ff 100644
--- a/chromium/chrome/browser/ui/webui/webui_util.h
+++ b/chromium/chrome/browser/ui/webui/webui_util.h
@@ -9,8 +9,7 @@
#include "base/containers/span.h"
#include "base/strings/string_piece.h"
-
-struct GritResourceMap;
+#include "ui/base/webui/resource_path.h"
namespace content {
class WebUIDataSource;
@@ -18,37 +17,19 @@ class WebUIDataSource;
namespace webui {
-struct LocalizedString;
-
-struct ResourcePath {
- const char* path;
- int id;
-};
+// Performs common setup steps for a |source| using JS modules: enable i18n
+// string replacements, adding test resources, and updating CSP/trusted types to
+// allow tests to work.
+// UIs that don't have a dedicated grd file should generally use this utility.
+void SetJSModuleDefaults(content::WebUIDataSource* source);
-// Performs common setup steps for |source|, assuming it is using Polymer 3,
-// by adding all resources, setting the default resource, setting up i18n,
-// and ensuring that tests work correctly by updating the CSP and adding the
-// test loader files.
+// Calls SetJSModuleDefaults(), and additionally adds all resources in the
+// resource map to |source| and sets |default_resource| as the default resource.
+// UIs that have a dedicated grd file should generally use this utility.
void SetupWebUIDataSource(content::WebUIDataSource* source,
- base::span<const GritResourceMap> resources,
- const std::string& generated_path,
+ base::span<const ResourcePath> resources,
int default_resource);
-// Calls content::WebUIDataSource::AddLocalizedString() in a for-loop for
-// |strings|. Reduces code size vs. reimplementing the same for-loop.
-void AddLocalizedStringsBulk(content::WebUIDataSource* html_source,
- base::span<const LocalizedString> strings);
-
-// Calls content::WebUIDataSource::AddResourcePath() in a for-loop for |paths|.
-// Reduces code size vs. reimplementing the same for-loop.
-void AddResourcePathsBulk(content::WebUIDataSource* source,
- base::span<const ResourcePath> paths);
-
-// AddResourcePathsBulk() variant that works with GritResourceMap.
-// Use base::make_span(kResourceMap, kResourceMapSize).
-void AddResourcePathsBulk(content::WebUIDataSource* source,
- base::span<const GritResourceMap> resources);
-
// Returns whether the device is enterprise managed. Note that on Linux, there's
// no good way of detecting whether the device is managed, so always return
// false.
diff --git a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
index 38f39d7c046..0ed03532c86 100644
--- a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
@@ -7,6 +7,7 @@
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
#include "chrome/browser/signin/signin_promo.h"
@@ -31,7 +32,7 @@
// http://crbug.com/653353
#if !defined(OS_MAC)
-#if !defined(OS_CHROMEOS) && defined(USE_AURA)
+#if !BUILDFLAG(IS_CHROMEOS_ASH) && defined(USE_AURA)
#include "ui/aura/window.h"
namespace {
@@ -122,7 +123,7 @@ class WebUIWebViewBrowserTest : public WebUIBrowserTest {
}
GURL GetWebViewEnabledWebUIURL() const {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
return GURL(chrome::kChromeUIOobeURL).Resolve("/login");
#else
return GURL(signin::GetEmbeddedPromoURL(
@@ -146,7 +147,7 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, DisplayNone) {
}
// TODO(crbug.com/861600) Flaky on CrOS trybots.
-#if defined(OS_CHROMEOS) && !defined(NDEBUG)
+#if BUILDFLAG(IS_CHROMEOS_ASH) && !defined(NDEBUG)
#define MAYBE_ExecuteScriptCode DISABLED_ExecuteScriptCode
#else
#define MAYBE_ExecuteScriptCode ExecuteScriptCode
@@ -167,7 +168,7 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, ExecuteScriptCodeFromFile) {
}
// TODO(crbug.com/751907) Flaky on CrOS trybots.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_AddContentScript DISABLED_AddContentScript
#else
#define MAYBE_AddContentScript AddContentScript
@@ -180,7 +181,7 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, MAYBE_AddContentScript) {
}
// TODO(crbug.com/751907) Flaky on CrOS trybots.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_AddMultiContentScripts DISABLED_AddMultiContentScripts
#else
#define MAYBE_AddMultiContentScripts AddMultiContentScripts
@@ -194,7 +195,7 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, MAYBE_AddMultiContentScripts) {
}
// TODO(crbug.com/751907) Flaky on CrOS trybots.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_AddContentScriptWithSameNameShouldOverwriteTheExistingOne \
DISABLED_AddContentScriptWithSameNameShouldOverwriteTheExistingOne
#else
@@ -211,7 +212,7 @@ IN_PROC_BROWSER_TEST_F(
base::Value(GetTestUrl("empty.html").spec())));
}
-#if defined(OS_CHROMEOS) && !defined(NDEBUG)
+#if BUILDFLAG(IS_CHROMEOS_ASH) && !defined(NDEBUG)
// TODO(crbug.com/859320) Fails on CrOS dbg with --enable-features=Mash.
#define MAYBE_AddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView \
DISABLED_AddContentScriptToOneWebViewShouldNotInjectToTheOtherWebView
@@ -230,7 +231,7 @@ IN_PROC_BROWSER_TEST_F(
}
// TODO(crbug.com/751907) Flaky on CrOS trybots.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_AddAndRemoveContentScripts DISABLED_AddAndRemoveContentScripts
#else
#define MAYBE_AddAndRemoveContentScripts AddAndRemoveContentScripts
@@ -244,7 +245,8 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest,
base::Value(GetTestUrl("empty.html").spec())));
}
-#if defined(OS_CHROMEOS) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER))
+#if BUILDFLAG(IS_CHROMEOS_ASH) && \
+ (!defined(NDEBUG) || defined(ADDRESS_SANITIZER))
// TODO(crbug.com/859320) Fails on CrOS dbg with --enable-features=Mash.
// TODO(crbug.com/893472) Flaky on CrOS ASan LSan
#define MAYBE_AddContentScriptsWithNewWindowAPI \
@@ -274,7 +276,7 @@ IN_PROC_BROWSER_TEST_F(
}
// TODO(crbug.com/662673) Flaky on CrOS trybots.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_ContentScriptExistsAsLongAsWebViewTagExists \
DISABLED_ContentScriptExistsAsLongAsWebViewTagExists
#else
@@ -298,7 +300,7 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, AddContentScriptWithCode) {
base::Value(GetTestUrl("empty.html").spec())));
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// TODO(crbug.com/662673) Flaky on CrOS trybots.
#define MAYBE_AddContentScriptIncognito DISABLED_AddContentScriptIncognito
// Right now we only have incognito WebUI on CrOS, but this should
@@ -325,7 +327,7 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, ContextMenuInspectElement) {
EXPECT_FALSE(menu.IsItemPresent(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
}
-#if !defined(OS_CHROMEOS) && defined(USE_AURA)
+#if !BUILDFLAG(IS_CHROMEOS_ASH) && defined(USE_AURA)
IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, DISABLED_DragAndDropToInput) {
ui_test_utils::NavigateToURL(browser(), GetWebViewEnabledWebUIURL());
ASSERT_TRUE(
diff --git a/chromium/chrome/browser/ui/webui/welcome/DIR_METADATA b/chromium/chrome/browser/ui/webui/welcome/DIR_METADATA
new file mode 100644
index 00000000000..1448c9ccbaf
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/welcome/DIR_METADATA
@@ -0,0 +1,3 @@
+monorail {
+ component: "UI>Browser>FirstRun"
+}
diff --git a/chromium/chrome/browser/ui/webui/welcome/OWNERS b/chromium/chrome/browser/ui/webui/welcome/OWNERS
index 7f0fbc064f0..90c0002b3ab 100644
--- a/chromium/chrome/browser/ui/webui/welcome/OWNERS
+++ b/chromium/chrome/browser/ui/webui/welcome/OWNERS
@@ -1,3 +1 @@
johntlee@chromium.org
-
-# COMPONENT: UI>Browser>FirstRun
diff --git a/chromium/chrome/browser/ui/webui/welcome/helpers.cc b/chromium/chrome/browser/ui/webui/welcome/helpers.cc
index 52e2eb385a7..5d3237bb18f 100644
--- a/chromium/chrome/browser/ui/webui/welcome/helpers.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/helpers.cc
@@ -226,9 +226,9 @@ bool HasModulesToShow(Profile* profile) {
// Modules won't have lasting effect if profile is ephemeral, so we can skip.
ProfileAttributesStorage& storage =
g_browser_process->profile_manager()->GetProfileAttributesStorage();
- ProfileAttributesEntry* entry = nullptr;
- if (storage.GetProfileAttributesWithPath(profile->GetPath(), &entry) &&
- entry->IsEphemeral()) {
+ ProfileAttributesEntry* entry =
+ storage.GetProfileAttributesWithPath(profile->GetPath());
+ if (entry && entry->IsEphemeral()) {
return false;
}
diff --git a/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc
index 78991207d00..c523fee6939 100644
--- a/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc
@@ -56,7 +56,8 @@ void WelcomeHandler::HandleActivateSignIn(const base::ListValue* args) {
result_ = WelcomeResult::STARTED_SIGN_IN;
base::RecordAction(base::UserMetricsAction("WelcomePage_SignInClicked"));
- if (IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount()) {
+ if (IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount(
+ signin::ConsentLevel::kSync)) {
// In general, this page isn't shown to signed-in users; however, if one
// should arrive here, then opening the sign-in dialog will likely lead
// to a crash. Thus, we just act like sign-in was "successful" and whisk
diff --git a/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
index 01550f7f8e3..07aa2ed29b1 100644
--- a/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
@@ -107,7 +107,7 @@ void AddStrings(content::WebUIDataSource* html_source) {
{"landingNewUser", IDS_WELCOME_LANDING_NEW_USER},
{"landingExistingUser", IDS_WELCOME_LANDING_EXISTING_USER},
};
- AddLocalizedStringsBulk(html_source, kLocalizedStrings);
+ html_source->AddLocalizedStrings(kLocalizedStrings);
}
} // namespace
@@ -130,7 +130,7 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
content::WebUIDataSource::Create(url.host());
webui::SetupWebUIDataSource(
html_source, base::make_span(kWelcomeResources, kWelcomeResourcesSize),
- "", IDR_WELCOME_WELCOME_HTML);
+ IDR_WELCOME_WELCOME_HTML);
// Add welcome strings.
AddStrings(html_source);
@@ -161,7 +161,7 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
{"images/set_default_dark.svg", IDR_WELCOME_SET_DEFAULT_DARK},
{"images/set_default_light.svg", IDR_WELCOME_SET_DEFAULT_LIGHT},
};
- webui::AddResourcePathsBulk(html_source, kPaths);
+ html_source->AddResourcePaths(kPaths);
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
#if defined(OS_WIN)