summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/ui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-11-18 16:35:47 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-11-18 15:45:54 +0000
commit32f5a1c56531e4210bc4cf8d8c7825d66e081888 (patch)
treeeeeec6822f4d738d8454525233fd0e2e3a659e6d /chromium/chrome/browser/ui
parent99677208ff3b216fdfec551fbe548da5520cd6fb (diff)
BASELINE: Update Chromium to 87.0.4280.67
Change-Id: Ib157360be8c2ffb2c73125751a89f60e049c1d54 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui')
-rw-r--r--chromium/chrome/browser/ui/BUILD.gn294
-rw-r--r--chromium/chrome/browser/ui/android/appmenu/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn3
-rw-r--r--chromium/chrome/browser/ui/android/favicon/BUILD.gn9
-rw-r--r--chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd442
-rw-r--r--chromium/chrome/browser/ui/ash/holding_space/BUILD.gn56
-rw-r--r--chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn10
-rw-r--r--chromium/chrome/browser/ui/messages/android/BUILD.gn1
-rw-r--r--chromium/chrome/browser/ui/webui/DEPS9
-rw-r--r--chromium/chrome/browser/ui/webui/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc59
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.h36
-rw-r--r--chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc166
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc94
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_webui_navigation_browsertest.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_installer/crostini_installer_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/edu_account_login_handler_chromeos.cc7
-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.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/file_manager/BUILD.gn9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/file_manager/OWNERS6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager.mojom34
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.h50
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_ui.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_ui.h48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc93
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h31
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc68
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/cookie_waiter.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/cookie_waiter.h40
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc55
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc101
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc47
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.h5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc84
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h56
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc532
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h91
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_ui.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h1
-rw-r--r--chromium/chrome/browser/ui/webui/commander/commander_handler.cc89
-rw-r--r--chromium/chrome/browser/ui/webui/commander/commander_handler.h73
-rw-r--r--chromium/chrome/browser/ui/webui/commander/commander_ui.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/commander/commander_ui.h28
-rw-r--r--chromium/chrome/browser/ui/webui/commander/commander_ui_browsertest.cc137
-rw-r--r--chromium/chrome/browser/ui/webui/customize_themes/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/customize_themes/README6
-rw-r--r--chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.cc157
-rw-r--r--chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h74
-rw-r--r--chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler_unittest.cc293
-rw-r--r--chromium/chrome/browser/ui/webui/device_log_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads.mojom11
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h8
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_ui.h5
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.h7
-rw-r--r--chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/internals/web_app/web_app_internals_page_handler_impl.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui_handler.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc125
-rw-r--r--chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_internals_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.cc74
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_contact_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_http_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn6
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share.mojom125
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h22
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui_browsertest.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/nearby_share_target_types.mojom17
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/public/mojom/BUILD.gn5
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom105
-rw-r--r--chromium/chrome/browser/ui/webui/nearby_share/shared_resources.cc120
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom125
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc314
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h45
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h46
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler_unittest.cc106
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.cc117
-rw-r--r--chromium/chrome/browser/ui/webui/new_tab_page/untrusted_source.h14
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom9
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/policy_ui_handler.cc70
-rw-r--r--chromium/chrome/browser/ui/webui/policy_ui_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler_unittest.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_metrics.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h15
-rw-r--r--chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later.mojom10
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_page_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_page_handler_unittest.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/read_later/read_later_ui.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc40
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/about_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc123
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h23
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.cc98
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler.h26
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/ambient_mode_handler_unittest.cc289
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes_util.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc80
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc46
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/files_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc158
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.h12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/main_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc143
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_manager.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_sections.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc153
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.cc106
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/plugin_vm_handler.h28
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.h12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.cc (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.cc)27
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.h)41
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker_unittest.cc (renamed from chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker_unittest.cc)14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_handler_unittest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/search_section.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.cc68
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h52
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc68
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler.h19
-rw-r--r--chromium/chrome/browser/ui/webui/settings/safety_check_handler_unittest.cc165
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc192
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_secure_dns_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_ui.cc64
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_ui.h48
-rw-r--r--chromium/chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/signin/OWNERS6
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_web_signin_intercept_ui.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc86
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h17
-rw-r--r--chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc47
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/BUILD.gn9
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom72
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc363
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h103
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc70
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h51
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/BUILD.gn1
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search.mojom39
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_page_handler_unittest.cc70
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.cc62
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_ui.h21
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_browsertest.cc116
-rw-r--r--chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_embedder.h19
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part.h4
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part_browsertest.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/tab_strip/tab_strip_ui_browsertest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/version_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/video_tutorials/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.h17
-rw-r--r--chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc1
293 files changed, 7670 insertions, 2825 deletions
diff --git a/chromium/chrome/browser/ui/BUILD.gn b/chromium/chrome/browser/ui/BUILD.gn
index 15657bbf7f7..ff864397556 100644
--- a/chromium/chrome/browser/ui/BUILD.gn
+++ b/chromium/chrome/browser/ui/BUILD.gn
@@ -28,12 +28,6 @@ import("//ui/base/ui_features.gni")
import("//ui/ozone/ozone.gni")
import("//ui/views/features.gni")
-# Reset sources_assignment_filter for the BUILD.gn file to prevent
-# regression during the migration of Chromium away from the feature.
-# See docs/no_sources_assignment_filter.md for more information.
-# TODO(crbug.com/1018739): remove this when migration is done.
-set_sources_assignment_filter([])
-
# Use a static library here because many test binaries depend on this but don't
# require many files from it. This makes linking more efficient.
static_library("ui") {
@@ -141,6 +135,8 @@ static_library("ui") {
"profile_chooser_constants.h",
"profile_error_dialog.cc",
"profile_error_dialog.h",
+ "read_later/reading_list_model_factory.cc",
+ "read_later/reading_list_model_factory.h",
"recently_audible_helper.cc",
"recently_audible_helper.h",
"screen_capture_notification_ui.h",
@@ -372,7 +368,6 @@ static_library("ui") {
"//chrome/browser/image_decoder",
"//chrome/browser/media:mojo_bindings",
"//chrome/browser/media/feeds:mojo_bindings",
- "//chrome/browser/nearby_sharing/common",
"//chrome/browser/profiling_host",
"//chrome/browser/resources/invalidations:invalidations_resources",
"//chrome/browser/resources/media:webrtc_logs_resources",
@@ -389,6 +384,7 @@ static_library("ui") {
"//chrome/browser/ui/webui/read_later:mojo_bindings",
"//chrome/browser/ui/webui/tab_search:mojo_bindings",
"//chrome/browser/ui/webui/usb_internals:mojo_bindings",
+ "//chrome/browser/video_tutorials",
"//chrome/common",
"//chrome/common/net",
"//chrome/common/search:mojo_bindings",
@@ -453,7 +449,6 @@ static_library("ui") {
"//components/metrics_services_manager",
"//components/navigation_metrics",
"//components/net_log",
- "//components/ntp_snippets",
"//components/ntp_tiles",
"//components/offline_pages/buildflags",
"//components/omnibox/browser",
@@ -588,6 +583,7 @@ static_library("ui") {
"//ui/surface",
"//ui/web_dialogs",
"//ui/webui",
+ "//ui/webui/resources/cr_components/customize_themes:mojom",
"//v8:v8_version",
]
allow_circular_includes_from +=
@@ -606,18 +602,14 @@ static_library("ui") {
"//chrome/app:chromium_strings",
"//chrome/browser/notifications/scheduler/public",
"//chrome/browser/ui/webui/explore_sites_internals:mojo_bindings",
- "//chrome/browser/ui/webui/snippets_internals:mojo_bindings",
+ "//chrome/browser/ui/webui/feed_internals:mojo_bindings",
"//components/browser_ui/util/android",
+ "//components/feed/core/common:feed_core_common",
+ "//components/feed/core/v2:feed_core_v2",
+ "//components/infobars/content",
"//components/query_tiles",
"//components/security_state/content/android",
]
- if (enable_feed_in_chrome) {
- deps += [
- "//chrome/browser/ui/webui/feed_internals:mojo_bindings",
- "//components/feed/core/common:feed_core_common",
- "//components/feed/core/v2:feed_core_v2",
- ]
- }
} else {
# !is_android
deps += [ "//components/autofill/content/browser/webauthn" ]
@@ -737,8 +729,6 @@ static_library("ui") {
"android/passwords/credential_leak_dialog_view_android.h",
"android/passwords/manual_filling_view_android.cc",
"android/passwords/manual_filling_view_android.h",
- "android/passwords/onboarding_dialog_view.cc",
- "android/passwords/onboarding_dialog_view.h",
"android/passwords/password_generation_dialog_view_android.cc",
"android/passwords/password_generation_dialog_view_android.h",
"android/passwords/password_generation_editing_popup_view_android.cc",
@@ -781,21 +771,27 @@ 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/snippets_internals/snippets_internals_page_handler.cc",
- "webui/snippets_internals/snippets_internals_page_handler.h",
- "webui/snippets_internals/snippets_internals_ui.cc",
- "webui/snippets_internals/snippets_internals_ui.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",
]
- if (enable_feed_in_chrome) {
+ if (enable_feed_v1 || enable_feed_v2) {
sources += [
- "webui/feed_internals/feed_internals_page_handler.cc",
- "webui/feed_internals/feed_internals_page_handler.h",
"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",
"webui/feed_internals/feedv2_internals_page_handler.h",
]
@@ -920,6 +916,7 @@ static_library("ui") {
"commander/commander_backend.h",
"commander/commander_controller.cc",
"commander/commander_controller.h",
+ "commander/commander_frontend.h",
"commander/commander_view_model.cc",
"commander/commander_view_model.h",
"commander/fuzzy_finder.cc",
@@ -997,6 +994,10 @@ static_library("ui") {
"global_media_controls/overlay_media_notifications_manager.h",
"global_media_controls/overlay_media_notifications_manager_impl.cc",
"global_media_controls/overlay_media_notifications_manager_impl.h",
+ "global_media_controls/presentation_request_notification_item.cc",
+ "global_media_controls/presentation_request_notification_item.h",
+ "global_media_controls/presentation_request_notification_provider.cc",
+ "global_media_controls/presentation_request_notification_provider.h",
"hats/hats_helper.cc",
"hats/hats_helper.h",
"hats/hats_service.cc",
@@ -1013,11 +1014,10 @@ static_library("ui") {
"hung_renderer/hung_renderer_core.h",
"in_product_help/active_tab_tracker.cc",
"in_product_help/active_tab_tracker.h",
- "in_product_help/global_media_controls_in_product_help.cc",
- "in_product_help/global_media_controls_in_product_help.h",
- "in_product_help/global_media_controls_in_product_help_factory.cc",
- "in_product_help/global_media_controls_in_product_help_factory.h",
- "in_product_help/in_product_help.h",
+ "in_product_help/feature_promo_controller.cc",
+ "in_product_help/feature_promo_controller.h",
+ "in_product_help/feature_promo_snooze_service.cc",
+ "in_product_help/feature_promo_snooze_service.h",
"in_product_help/reopen_tab_in_product_help.cc",
"in_product_help/reopen_tab_in_product_help.h",
"in_product_help/reopen_tab_in_product_help_factory.cc",
@@ -1043,6 +1043,8 @@ static_library("ui") {
"media_router/media_cast_mode.h",
"media_router/media_router_file_dialog.cc",
"media_router/media_router_file_dialog.h",
+ "media_router/media_router_ui.cc",
+ "media_router/media_router_ui.h",
"media_router/media_router_ui_helper.cc",
"media_router/media_router_ui_helper.h",
"media_router/media_router_ui_service.cc",
@@ -1107,8 +1109,6 @@ static_library("ui") {
"passwords/credential_manager_dialog_controller.h",
"passwords/credential_manager_dialog_controller_impl.cc",
"passwords/credential_manager_dialog_controller_impl.h",
- "passwords/google_password_manager_navigation_throttle.cc",
- "passwords/google_password_manager_navigation_throttle.h",
"passwords/manage_passwords_icon_view.h",
"passwords/manage_passwords_ui_controller.cc",
"passwords/manage_passwords_ui_controller.h",
@@ -1122,8 +1122,6 @@ static_library("ui") {
"pdf/chrome_pdf_web_contents_helper_client.cc",
"pdf/chrome_pdf_web_contents_helper_client.h",
"permission_bubble/permission_prompt.h",
- "read_later/reading_list_model_factory.cc",
- "read_later/reading_list_model_factory.h",
"sad_tab.cc",
"sad_tab.h",
"sad_tab_helper.cc",
@@ -1162,6 +1160,8 @@ static_library("ui") {
"startup/automation_infobar_delegate.h",
"startup/google_api_keys_infobar_delegate.cc",
"startup/google_api_keys_infobar_delegate.h",
+ "startup/launch_mode_recorder.cc",
+ "startup/launch_mode_recorder.h",
"startup/obsolete_system_infobar_delegate.cc",
"startup/obsolete_system_infobar_delegate.h",
"startup/startup_browser_creator.cc",
@@ -1248,6 +1248,11 @@ static_library("ui") {
"thumbnails/thumbnail_image.h",
"thumbnails/thumbnail_readiness_tracker.cc",
"thumbnails/thumbnail_readiness_tracker.h",
+ "thumbnails/thumbnail_scheduler.h",
+ "thumbnails/thumbnail_scheduler_impl.cc",
+ "thumbnails/thumbnail_scheduler_impl.h",
+ "thumbnails/thumbnail_stats_tracker.cc",
+ "thumbnails/thumbnail_stats_tracker.h",
"thumbnails/thumbnail_tab_helper.cc",
"thumbnails/thumbnail_tab_helper.h",
"toolbar/app_menu_icon_controller.cc",
@@ -1284,6 +1289,10 @@ static_library("ui") {
"unload_controller.h",
"views/eye_dropper/eye_dropper.cc",
"views/eye_dropper/eye_dropper.h",
+ "views/eye_dropper/eye_dropper_view.cc",
+ "views/eye_dropper/eye_dropper_view.h",
+ "views/eye_dropper/eye_dropper_view_mac.h",
+ "views/eye_dropper/eye_dropper_view_mac.mm",
"webui/app_launcher_login_handler.cc",
"webui/app_launcher_login_handler.h",
"webui/app_management/app_management_page_handler.cc",
@@ -1294,6 +1303,12 @@ static_library("ui") {
"webui/bookmarks/bookmarks_ui.h",
"webui/chrome_web_contents_handler.cc",
"webui/chrome_web_contents_handler.h",
+ "webui/commander/commander_handler.cc",
+ "webui/commander/commander_handler.h",
+ "webui/commander/commander_ui.cc",
+ "webui/commander/commander_ui.h",
+ "webui/customize_themes/chrome_customize_themes_handler.cc",
+ "webui/customize_themes/chrome_customize_themes_handler.h",
"webui/devtools_ui.cc",
"webui/devtools_ui.h",
"webui/devtools_ui_data_source.cc",
@@ -1340,20 +1355,6 @@ 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/nearby_internals/nearby_internals_contact_handler.cc",
- "webui/nearby_internals/nearby_internals_contact_handler.h",
- "webui/nearby_internals/nearby_internals_http_handler.cc",
- "webui/nearby_internals/nearby_internals_http_handler.h",
- "webui/nearby_internals/nearby_internals_logs_handler.cc",
- "webui/nearby_internals/nearby_internals_logs_handler.h",
- "webui/nearby_internals/nearby_internals_ui.cc",
- "webui/nearby_internals/nearby_internals_ui.h",
- "webui/nearby_internals/nearby_internals_ui_trigger_handler.cc",
- "webui/nearby_internals/nearby_internals_ui_trigger_handler.h",
- "webui/nearby_share/nearby_share_dialog_ui.cc",
- "webui/nearby_share/nearby_share_dialog_ui.h",
- "webui/nearby_share/shared_resources.cc",
- "webui/nearby_share/shared_resources.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",
@@ -1482,6 +1483,7 @@ static_library("ui") {
"webui/tab_search/tab_search_page_handler.h",
"webui/tab_search/tab_search_ui.cc",
"webui/tab_search/tab_search_ui.h",
+ "webui/tab_search/tab_search_ui_embedder.h",
"webui/theme_handler.cc",
"webui/theme_handler.h",
"webui/theme_source.cc",
@@ -1499,40 +1501,34 @@ static_library("ui") {
]
deps += [
"//base/util/values:values_util",
- "//build:lacros_buildflags",
+ "//build:chromeos_buildflags",
"//chrome/app/vector_icons",
"//chrome/browser:theme_properties",
"//chrome/browser/media/kaleidoscope/mojom",
"//chrome/browser/media/router",
- "//chrome/browser/nearby_sharing/certificates",
- "//chrome/browser/nearby_sharing/client",
- "//chrome/browser/nearby_sharing/contacts",
- "//chrome/browser/nearby_sharing/local_device_data",
- "//chrome/browser/nearby_sharing/logging",
- "//chrome/browser/nearby_sharing/logging:util",
- "//chrome/browser/nearby_sharing/proto",
"//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/shopping_tasks:mojo_bindings",
"//chrome/browser/ui/color:color_headers",
"//chrome/browser/ui/color:mixers",
"//chrome/browser/ui/webui/app_management:mojo_bindings",
"//chrome/browser/ui/webui/internals/web_app:mojo_bindings",
- "//chrome/browser/ui/webui/nearby_share:mojom",
- "//chrome/browser/ui/webui/nearby_share/public/mojom",
"//chrome/common:buildflags",
- "//chrome/common/media_router/mojom:media_router",
"//chrome/common/search:generate_chrome_colors_info",
"//chrome/common/search:mojo_bindings",
"//chrome/common/themes:autogenerated_theme_util",
"//components/feedback/proto",
"//components/keep_alive_registry",
+ "//components/media_router/common/mojom:media_router",
"//components/network_session_configurator/common",
"//components/page_load_metrics/browser",
"//components/performance_manager:site_data_proto",
+ "//components/printing/browser",
"//components/profile_metrics",
+ "//components/safe_browsing/core/common:safe_browsing_policy_handler",
"//components/safety_check",
"//components/search_provider_logos",
"//components/services/app_service/public/cpp:app_update",
@@ -1643,6 +1639,8 @@ static_library("ui") {
"app_list/arc/arc_app_icon.h",
"app_list/arc/arc_app_icon_descriptor.cc",
"app_list/arc/arc_app_icon_descriptor.h",
+ "app_list/arc/arc_app_icon_factory.cc",
+ "app_list/arc/arc_app_icon_factory.h",
"app_list/arc/arc_app_launcher.cc",
"app_list/arc/arc_app_launcher.h",
"app_list/arc/arc_app_list_prefs.cc",
@@ -1720,10 +1718,10 @@ static_library("ui") {
"app_list/search/arc/arc_playstore_search_result.h",
"app_list/search/assistant_search_provider.cc",
"app_list/search/assistant_search_provider.h",
+ "app_list/search/assistant_text_search_provider.cc",
+ "app_list/search/assistant_text_search_provider.h",
"app_list/search/chrome_search_result.cc",
"app_list/search/chrome_search_result.h",
- "app_list/search/common/file_icon_util.cc",
- "app_list/search/common/file_icon_util.h",
"app_list/search/common/url_icon_source.cc",
"app_list/search/common/url_icon_source.h",
"app_list/search/cros_action_history/cros_action_recorder.cc",
@@ -1738,6 +1736,12 @@ static_library("ui") {
"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",
+ "app_list/search/files/drive_zero_state_provider.h",
+ "app_list/search/files/file_result.cc",
+ "app_list/search/files/file_result.h",
+ "app_list/search/files/item_suggest_cache.cc",
+ "app_list/search/files/item_suggest_cache.h",
"app_list/search/launcher_search/launcher_search_icon_image_loader.cc",
"app_list/search/launcher_search/launcher_search_icon_image_loader.h",
"app_list/search/launcher_search/launcher_search_icon_image_loader_impl.cc",
@@ -1862,12 +1866,30 @@ static_library("ui") {
"ash/chrome_screenshot_grabber_test_observer.h",
"ash/chrome_shell_delegate.cc",
"ash/chrome_shell_delegate.h",
+ "ash/clipboard_image_model_factory_impl.cc",
+ "ash/clipboard_image_model_factory_impl.h",
+ "ash/clipboard_image_model_request.cc",
+ "ash/clipboard_image_model_request.h",
"ash/clipboard_util.cc",
"ash/clipboard_util.h",
+ "ash/holding_space/holding_space_client_impl.cc",
+ "ash/holding_space/holding_space_client_impl.h",
+ "ash/holding_space/holding_space_downloads_delegate.cc",
+ "ash/holding_space/holding_space_downloads_delegate.h",
+ "ash/holding_space/holding_space_file_system_delegate.cc",
+ "ash/holding_space/holding_space_file_system_delegate.h",
"ash/holding_space/holding_space_keyed_service.cc",
"ash/holding_space/holding_space_keyed_service.h",
+ "ash/holding_space/holding_space_keyed_service_delegate.cc",
+ "ash/holding_space/holding_space_keyed_service_delegate.h",
"ash/holding_space/holding_space_keyed_service_factory.cc",
"ash/holding_space/holding_space_keyed_service_factory.h",
+ "ash/holding_space/holding_space_persistence_delegate.cc",
+ "ash/holding_space/holding_space_persistence_delegate.h",
+ "ash/holding_space/holding_space_thumbnail_loader.cc",
+ "ash/holding_space/holding_space_thumbnail_loader.h",
+ "ash/holding_space/holding_space_util.cc",
+ "ash/holding_space/holding_space_util.h",
"ash/image_downloader_impl.cc",
"ash/image_downloader_impl.h",
"ash/ime_controller_client.cc",
@@ -1951,8 +1973,11 @@ static_library("ui") {
"ash/launcher/shelf_spinner_item_controller.h",
"ash/login_screen_client.cc",
"ash/login_screen_client.h",
+ "ash/login_screen_shown_observer.h",
"ash/media_client_impl.cc",
"ash/media_client_impl.h",
+ "ash/media_notification_provider_impl.cc",
+ "ash/media_notification_provider_impl.h",
"ash/multi_user/multi_profile_support.cc",
"ash/multi_user/multi_profile_support.h",
"ash/multi_user/multi_user_context_menu.h",
@@ -1975,6 +2000,8 @@ static_library("ui") {
"ash/network/network_state_notifier.h",
"ash/network/tether_notification_presenter.cc",
"ash/network/tether_notification_presenter.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",
"ash/screen_orientation_delegate_chromeos.h",
"ash/session_controller_client_impl.cc",
@@ -2060,8 +2087,14 @@ static_library("ui") {
"views/profiles/profile_indicator_icon.h",
"views/relaunch_notification/relaunch_notification_controller_platform_impl_chromeos.cc",
"views/relaunch_notification/relaunch_notification_controller_platform_impl_chromeos.h",
- "views/sharesheet_bubble_view.cc",
- "views/sharesheet_bubble_view.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",
@@ -2147,10 +2180,6 @@ static_library("ui") {
"webui/chromeos/drive_internals_ui.h",
"webui/chromeos/edu_account_login_handler_chromeos.cc",
"webui/chromeos/edu_account_login_handler_chromeos.h",
- "webui/chromeos/file_manager/file_manager_page_handler.cc",
- "webui/chromeos/file_manager/file_manager_page_handler.h",
- "webui/chromeos/file_manager/file_manager_ui.cc",
- "webui/chromeos/file_manager/file_manager_ui.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",
@@ -2161,6 +2190,12 @@ static_library("ui") {
"webui/chromeos/image_source.h",
"webui/chromeos/in_session_password_change/confirm_password_change_handler.cc",
"webui/chromeos/in_session_password_change/confirm_password_change_handler.h",
+ "webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc",
+ "webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h",
+ "webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc",
+ "webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h",
+ "webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc",
+ "webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h",
"webui/chromeos/in_session_password_change/password_change_dialogs.cc",
"webui/chromeos/in_session_password_change/password_change_dialogs.h",
"webui/chromeos/in_session_password_change/password_change_handler.cc",
@@ -2189,6 +2224,8 @@ static_library("ui") {
"webui/chromeos/login/base_screen_handler.h",
"webui/chromeos/login/base_webui_handler.cc",
"webui/chromeos/login/base_webui_handler.h",
+ "webui/chromeos/login/cookie_waiter.cc",
+ "webui/chromeos/login/cookie_waiter.h",
"webui/chromeos/login/core_oobe_handler.cc",
"webui/chromeos/login/core_oobe_handler.h",
"webui/chromeos/login/debug/debug_overlay_handler.cc",
@@ -2302,6 +2339,10 @@ static_library("ui") {
"webui/chromeos/machine_learning/machine_learning_internals_page_handler.h",
"webui/chromeos/machine_learning/machine_learning_internals_ui.cc",
"webui/chromeos/machine_learning/machine_learning_internals_ui.h",
+ "webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc",
+ "webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h",
+ "webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc",
+ "webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h",
"webui/chromeos/multidevice_internals/multidevice_internals_ui.cc",
"webui/chromeos/multidevice_internals/multidevice_internals_ui.h",
"webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc",
@@ -2354,6 +2395,20 @@ static_library("ui") {
"webui/help/version_updater_chromeos.h",
"webui/management_ui_handler_chromeos.cc",
"webui/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",
+ "webui/nearby_internals/nearby_internals_http_handler.h",
+ "webui/nearby_internals/nearby_internals_logs_handler.cc",
+ "webui/nearby_internals/nearby_internals_logs_handler.h",
+ "webui/nearby_internals/nearby_internals_ui.cc",
+ "webui/nearby_internals/nearby_internals_ui.h",
+ "webui/nearby_internals/nearby_internals_ui_trigger_handler.cc",
+ "webui/nearby_internals/nearby_internals_ui_trigger_handler.h",
+ "webui/nearby_share/nearby_share_dialog_ui.cc",
+ "webui/nearby_share/nearby_share_dialog_ui.h",
+ "webui/nearby_share/shared_resources.cc",
+ "webui/nearby_share/shared_resources.h",
"webui/settings/chromeos/about_section.cc",
"webui/settings/chromeos/about_section.h",
"webui/settings/chromeos/accessibility_handler.cc",
@@ -2457,17 +2512,19 @@ static_library("ui") {
"webui/settings/chromeos/quick_unlock_handler.h",
"webui/settings/chromeos/reset_section.cc",
"webui/settings/chromeos/reset_section.h",
+ "webui/settings/chromeos/search/per_session_settings_user_action_tracker.cc",
+ "webui/settings/chromeos/search/per_session_settings_user_action_tracker.h",
"webui/settings/chromeos/search/search_concept.h",
"webui/settings/chromeos/search/search_handler.cc",
"webui/settings/chromeos/search/search_handler.h",
"webui/settings/chromeos/search/search_tag_registry.cc",
"webui/settings/chromeos/search/search_tag_registry.h",
- "webui/settings/chromeos/search/settings_user_action_tracker.cc",
- "webui/settings/chromeos/search/settings_user_action_tracker.h",
"webui/settings/chromeos/search_section.cc",
"webui/settings/chromeos/search_section.h",
"webui/settings/chromeos/server_printer_url_util.cc",
"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/wallpaper_handler.cc",
"webui/settings/chromeos/wallpaper_handler.h",
"webui/settings/tts_handler.cc",
@@ -2493,13 +2550,21 @@ static_library("ui") {
"//ash/public/cpp",
"//ash/public/cpp/app_list/vector_icons",
"//ash/public/cpp/resources:ash_public_unscaled_resources",
- "//ash/public/cpp/vector_icons",
"//ash/shortcut_viewer",
- "//build:lacros_buildflags",
+ "//build:chromeos_buildflags",
"//chrome/app:generated_resources",
"//chrome/browser/chromeos",
"//chrome/browser/chromeos:backdrop_wallpaper_proto",
"//chrome/browser/chromeos/crostini:crostini_installer_types_mojom",
+ "//chrome/browser/nearby_sharing:share_target",
+ "//chrome/browser/nearby_sharing/certificates",
+ "//chrome/browser/nearby_sharing/client",
+ "//chrome/browser/nearby_sharing/common",
+ "//chrome/browser/nearby_sharing/contacts",
+ "//chrome/browser/nearby_sharing/local_device_data",
+ "//chrome/browser/nearby_sharing/logging",
+ "//chrome/browser/nearby_sharing/logging:util",
+ "//chrome/browser/nearby_sharing/proto",
"//chrome/browser/resources:bluetooth_pairing_dialog_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",
@@ -2511,8 +2576,9 @@ static_library("ui") {
"//chrome/browser/ui/webui/chromeos/add_supervision:mojo_bindings",
"//chrome/browser/ui/webui/chromeos/crostini_installer:mojo_bindings",
"//chrome/browser/ui/webui/chromeos/crostini_upgrader:mojo_bindings",
- "//chrome/browser/ui/webui/chromeos/file_manager:mojo_bindings",
"//chrome/browser/ui/webui/chromeos/machine_learning:mojo_bindings",
+ "//chrome/browser/ui/webui/nearby_share:mojom",
+ "//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/services/file_util/public/cpp",
@@ -2520,7 +2586,11 @@ static_library("ui") {
"//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/diagnostics_ui",
+ "//chromeos/components/drivefs/mojom:mojom",
"//chromeos/components/help_app_ui",
"//chromeos/components/local_search_service:local_search_service",
"//chromeos/components/media_app_ui",
@@ -2528,6 +2598,7 @@ static_library("ui") {
"//chromeos/components/multidevice/debug_webui",
"//chromeos/components/multidevice/logging",
"//chromeos/components/phonehub",
+ "//chromeos/components/phonehub:debug",
"//chromeos/components/print_management",
"//chromeos/components/proximity_auth",
"//chromeos/components/quick_answers",
@@ -2570,6 +2641,8 @@ static_library("ui") {
"//chromeos/settings",
"//chromeos/strings",
"//chromeos/system",
+ "//chromeos/ui",
+ "//chromeos/ui/vector_icons",
"//components/arc",
"//components/assist_ranker",
"//components/assist_ranker/proto",
@@ -2579,6 +2652,7 @@ static_library("ui") {
"//components/login",
"//components/metrics/structured:structured_events",
"//components/services/app_service/public/cpp:app_file_handling",
+ "//components/services/app_service/public/cpp:app_share_target",
"//components/services/app_service/public/cpp:app_update",
"//components/services/app_service/public/cpp:icon_loader",
"//components/services/app_service/public/cpp:instance_update",
@@ -2612,6 +2686,7 @@ static_library("ui") {
]
}
deps += [
+ "//chromeos/components/file_manager:file_manager_ui",
"//chromeos/components/sample_system_web_app_ui",
"//chromeos/components/telemetry_extension_ui",
]
@@ -2665,6 +2740,8 @@ static_library("ui") {
"views/autofill/payments/webauthn_dialog_view_impl.h",
"views/close_bubble_on_tab_activation_helper.cc",
"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",
@@ -2715,8 +2792,6 @@ static_library("ui") {
"sync/one_click_signin_links_delegate_impl.h",
"user_manager.cc",
"user_manager.h",
- "views/external_protocol_dialog.cc",
- "views/external_protocol_dialog.h",
"views/profiles/badged_profile_photo.cc",
"views/profiles/badged_profile_photo.h",
"views/profiles/profile_picker_view.cc",
@@ -2783,10 +2858,7 @@ static_library("ui") {
"webui/welcome/welcome_ui.h",
]
- deps += [
- "//components/country_codes",
- "//ui/webui/resources/cr_components/customize_themes:mojom",
- ]
+ deps += [ "//components/country_codes" ]
if (enable_dice_support) {
sources += [
@@ -2914,6 +2986,8 @@ static_library("ui") {
"cocoa/renderer_context_menu/render_view_context_menu_mac.mm",
"cocoa/renderer_context_menu/render_view_context_menu_mac_cocoa.h",
"cocoa/renderer_context_menu/render_view_context_menu_mac_cocoa.mm",
+ "cocoa/rosetta_required_infobar_delegate.h",
+ "cocoa/rosetta_required_infobar_delegate.mm",
"cocoa/scoped_menu_bar_lock.h",
"cocoa/scoped_menu_bar_lock.mm",
"cocoa/share_menu_controller.h",
@@ -2945,6 +3019,8 @@ 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",
@@ -2973,6 +3049,7 @@ static_library("ui") {
"//extensions/components/native_app_window",
"//third_party/google_toolbox_for_mac",
"//third_party/mozilla",
+ "//third_party/widevine/cdm:buildflags",
"//ui/accelerated_widget_mac:accelerated_widget_mac",
]
include_dirs = [ "$target_gen_dir" ]
@@ -3013,8 +3090,6 @@ static_library("ui") {
"views/color_chooser_win.cc",
"views/critical_notification_bubble_view.cc",
"views/critical_notification_bubble_view.h",
- "views/eye_dropper/eye_dropper_win.cc",
- "views/eye_dropper/eye_dropper_win.h",
"views/frame/browser_desktop_window_tree_host.h",
"views/frame/browser_desktop_window_tree_host_win.cc",
"views/frame/browser_desktop_window_tree_host_win.h",
@@ -3160,13 +3235,7 @@ static_library("ui") {
}
if (use_x11) {
- sources += [
- "views/frame/native_browser_frame_factory_aurax11.cc",
- "views/javascript_app_modal_dialog_views_x11.cc",
- "views/javascript_app_modal_dialog_views_x11.h",
- "views/javascript_app_modal_event_blocker_x11.cc",
- "views/javascript_app_modal_event_blocker_x11.h",
- ]
+ sources += [ "views/frame/native_browser_frame_factory_aurax11.cc" ]
deps += [
"//ui/events/devices",
"//ui/events/devices/x11",
@@ -3360,6 +3429,8 @@ static_library("ui") {
"views/chrome_web_dialog_view.h",
"views/collected_cookies_views.cc",
"views/collected_cookies_views.h",
+ "views/commander_frontend_views.cc",
+ "views/commander_frontend_views.h",
"views/confirm_bubble_views.cc",
"views/confirm_bubble_views.h",
"views/constrained_web_dialog_delegate_views.cc",
@@ -3431,6 +3502,8 @@ static_library("ui") {
"views/find_bar_host.h",
"views/find_bar_view.cc",
"views/find_bar_view.h",
+ "views/flying_indicator.cc",
+ "views/flying_indicator.h",
"views/folder_upload_confirmation_view.cc",
"views/folder_upload_confirmation_view.h",
"views/frame/app_menu_button.cc",
@@ -3490,11 +3563,13 @@ static_library("ui") {
"views/global_media_controls/media_dialog_view.cc",
"views/global_media_controls/media_dialog_view.h",
"views/global_media_controls/media_dialog_view_observer.h",
- "views/global_media_controls/media_notification_audio_device_selector_view.cc",
- "views/global_media_controls/media_notification_audio_device_selector_view.h",
- "views/global_media_controls/media_notification_audio_device_selector_view_delegate.h",
"views/global_media_controls/media_notification_container_impl_view.cc",
"views/global_media_controls/media_notification_container_impl_view.h",
+ "views/global_media_controls/media_notification_device_entry_ui.cc",
+ "views/global_media_controls/media_notification_device_entry_ui.h",
+ "views/global_media_controls/media_notification_device_selector_view.cc",
+ "views/global_media_controls/media_notification_device_selector_view.h",
+ "views/global_media_controls/media_notification_device_selector_view_delegate.h",
"views/global_media_controls/media_notification_list_view.cc",
"views/global_media_controls/media_notification_list_view.h",
"views/global_media_controls/media_toolbar_button_view.cc",
@@ -3517,12 +3592,10 @@ static_library("ui") {
"views/in_product_help/feature_promo_bubble_view.h",
"views/in_product_help/feature_promo_colors.cc",
"views/in_product_help/feature_promo_colors.h",
- "views/in_product_help/feature_promo_controller.cc",
- "views/in_product_help/feature_promo_controller.h",
"views/in_product_help/feature_promo_controller_views.cc",
"views/in_product_help/feature_promo_controller_views.h",
- "views/in_product_help/global_media_controls_promo_controller.cc",
- "views/in_product_help/global_media_controls_promo_controller.h",
+ "views/in_product_help/feature_promo_registry.cc",
+ "views/in_product_help/feature_promo_registry.h",
"views/in_product_help/reopen_tab_promo_controller.cc",
"views/in_product_help/reopen_tab_promo_controller.h",
"views/infobars/alternate_nav_infobar_view.cc",
@@ -3569,6 +3642,8 @@ static_library("ui") {
"views/location_bar/permission_chip.h",
"views/location_bar/selected_keyword_view.cc",
"views/location_bar/selected_keyword_view.h",
+ "views/location_bar/star_menu_model.cc",
+ "views/location_bar/star_menu_model.h",
"views/location_bar/star_view.cc",
"views/location_bar/star_view.h",
"views/location_bar/zoom_bubble_view.cc",
@@ -3596,8 +3671,6 @@ static_library("ui") {
"views/media_router/media_remoting_dialog_view.h",
"views/media_router/media_router_dialog_controller_views.cc",
"views/media_router/media_router_dialog_controller_views.h",
- "views/media_router/media_router_views_ui.cc",
- "views/media_router/media_router_views_ui.h",
"views/media_router/presentation_receiver_window_factory.cc",
"views/media_router/presentation_receiver_window_frame.cc",
"views/media_router/presentation_receiver_window_frame.h",
@@ -3619,6 +3692,8 @@ static_library("ui") {
"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",
+ "views/omnibox/omnibox_mouse_enter_exit_handler.h",
"views/omnibox/omnibox_popup_contents_view.cc",
"views/omnibox/omnibox_popup_contents_view.h",
"views/omnibox/omnibox_result_view.cc",
@@ -3782,8 +3857,6 @@ static_library("ui") {
"views/reader_mode/reader_mode_icon_view.h",
"views/relaunch_notification/relaunch_notification_controller.cc",
"views/relaunch_notification/relaunch_notification_controller.h",
- "views/relaunch_notification/relaunch_notification_metrics.cc",
- "views/relaunch_notification/relaunch_notification_metrics.h",
"views/relaunch_notification/relaunch_required_timer.cc",
"views/relaunch_notification/relaunch_required_timer.h",
"views/relaunch_notification/relaunch_required_timer_internal.cc",
@@ -3866,12 +3939,12 @@ static_library("ui") {
"views/tabs/tab_group_underline.h",
"views/tabs/tab_group_views.cc",
"views/tabs/tab_group_views.h",
- "views/tabs/tab_groups_iph_controller.cc",
- "views/tabs/tab_groups_iph_controller.h",
"views/tabs/tab_hover_card_bubble_view.cc",
"views/tabs/tab_hover_card_bubble_view.h",
"views/tabs/tab_icon.cc",
"views/tabs/tab_icon.h",
+ "views/tabs/tab_search_button.cc",
+ "views/tabs/tab_search_button.h",
"views/tabs/tab_slot_view.cc",
"views/tabs/tab_slot_view.h",
"views/tabs/tab_strip.cc",
@@ -3910,8 +3983,6 @@ static_library("ui") {
"views/toolbar/home_button.h",
"views/toolbar/reload_button.cc",
"views/toolbar/reload_button.h",
- "views/toolbar/sharesheet_button.cc",
- "views/toolbar/sharesheet_button.h",
"views/toolbar/toolbar_account_icon_container_view.cc",
"views/toolbar/toolbar_account_icon_container_view.h",
"views/toolbar/toolbar_action_view.cc",
@@ -3973,6 +4044,7 @@ static_library("ui") {
"views/webauthn/sheet_view_factory.h",
"views/webauthn/webauthn_hover_button.cc",
"views/webauthn/webauthn_hover_button.h",
+ "views/window_name_prompt.cc",
"webauthn/account_hover_list_model.cc",
"webauthn/account_hover_list_model.h",
"webauthn/authenticator_request_sheet_model.cc",
@@ -3989,7 +4061,7 @@ static_library("ui") {
]
deps += [
- "//base/util/ranges",
+ "//base",
"//base/util/timer",
"//chrome/browser/ui/views",
"//chrome/common/qr_code_generator",
@@ -4133,13 +4205,6 @@ static_library("ui") {
if (is_chrome_branded) {
deps += [ "//chrome/browser/ui/media_router/internal/vector_icons" ]
}
-
- if (enable_tab_search) {
- sources += [
- "views/tabs/tab_search_button.cc",
- "views/tabs/tab_search_button.h",
- ]
- }
}
if (use_aura) {
@@ -4158,6 +4223,7 @@ static_library("ui") {
"views/apps/shaped_app_window_targeter.cc",
"views/apps/shaped_app_window_targeter.h",
"views/dropdown_bar_host_aura.cc",
+ "views/eye_dropper/eye_dropper_view_aura.cc",
"views/renderer_context_menu/render_view_context_menu_views.cc",
"views/renderer_context_menu/render_view_context_menu_views.h",
"views/tab_contents/chrome_web_contents_view_delegate_views.cc",
@@ -4299,7 +4365,11 @@ static_library("ui") {
deps += [ "//apps/ui/views" ]
}
if (use_aura) {
- sources += [ "views/chrome_javascript_app_modal_view_factory_views.cc" ]
+ sources += [
+ "views/chrome_javascript_app_modal_view_factory_views.cc",
+ "views/javascript_app_modal_event_blocker.cc",
+ "views/javascript_app_modal_event_blocker.h",
+ ]
deps += [ "//ui/wm/public" ]
}
}
@@ -4446,6 +4516,8 @@ static_library("ui") {
sources += [
"views/frame/webui_tab_strip_container_view.cc",
"views/frame/webui_tab_strip_container_view.h",
+ "views/frame/webui_tab_strip_field_trial.cc",
+ "views/frame/webui_tab_strip_field_trial.h",
"views/toolbar/webui_tab_counter_button.cc",
"views/toolbar/webui_tab_counter_button.h",
"webui/tab_strip/chrome_content_browser_client_tab_strip_part.cc",
diff --git a/chromium/chrome/browser/ui/android/appmenu/BUILD.gn b/chromium/chrome/browser/ui/android/appmenu/BUILD.gn
index 9baf59a2d98..d35c204280f 100644
--- a/chromium/chrome/browser/ui/android/appmenu/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/appmenu/BUILD.gn
@@ -9,6 +9,7 @@ android_library("java") {
sources = [
"java/src/org/chromium/chrome/browser/ui/appmenu/AppMenuBlocker.java",
"java/src/org/chromium/chrome/browser/ui/appmenu/AppMenuButtonHelper.java",
+ "java/src/org/chromium/chrome/browser/ui/appmenu/AppMenuClickHandler.java",
"java/src/org/chromium/chrome/browser/ui/appmenu/AppMenuCoordinator.java",
"java/src/org/chromium/chrome/browser/ui/appmenu/AppMenuDelegate.java",
"java/src/org/chromium/chrome/browser/ui/appmenu/AppMenuHandler.java",
@@ -42,5 +43,4 @@ android_resources("java_resources") {
"//components/browser_ui/styles/android:java_resources",
"//ui/android:ui_java_resources",
]
- create_srcjar = false
}
diff --git a/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn b/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
index d06aceed744..a677a598fc8 100644
--- a/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/appmenu/internal/BUILD.gn
@@ -54,7 +54,6 @@ android_resources("java_resources") {
"//chrome/browser/ui/android/appmenu:java_resources",
"//components/browser_ui/widget/android:java_resources",
]
- create_srcjar = false
}
android_library("javatests") {
@@ -97,7 +96,6 @@ android_library("javatests") {
android_resources("test_java_resources") {
testonly = true
- create_srcjar = false
sources = [
"test/java/res/drawable/test_ic_arrow_downward_black_24dp.xml",
"test/java/res/drawable/test_ic_arrow_forward_black_24dp.xml",
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 20669904a80..186177a2231 100644
--- a/chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/default_browser_promo/BUILD.gn
@@ -6,6 +6,7 @@ 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",
@@ -35,7 +36,6 @@ android_resources("java_resources") {
"//components/browser_ui/widget/android:java_resources",
"//ui/android:ui_java_resources",
]
- create_srcjar = false
}
java_library("junit") {
@@ -62,7 +62,6 @@ android_library("javatests") {
":java",
"//base:base_java",
"//base:base_java_test_support",
- "//chrome/android:chrome_java",
"//chrome/browser/android/lifecycle:java",
"//chrome/browser/flags:java",
"//chrome/test/android:chrome_java_test_support",
diff --git a/chromium/chrome/browser/ui/android/favicon/BUILD.gn b/chromium/chrome/browser/ui/android/favicon/BUILD.gn
index f5330113267..7873c66b1c4 100644
--- a/chromium/chrome/browser/ui/android/favicon/BUILD.gn
+++ b/chromium/chrome/browser/ui/android/favicon/BUILD.gn
@@ -1,6 +1,7 @@
# 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") {
@@ -53,11 +54,11 @@ android_resources("java_resources") {
"java/res/drawable-xxhdpi/default_favicon.png",
"java/res/drawable-xxxhdpi/chromelogo16.png",
"java/res/drawable-xxxhdpi/default_favicon.png",
- "java/res/values/colors.xml",
"java/res/values/dimens.xml",
]
- create_srcjar = false
-
- deps = [ "//ui/android:ui_java_resources" ]
+ deps = [
+ "//components/browser_ui/styles/android:java_resources",
+ "//ui/android:ui_java_resources",
+ ]
}
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 9824f8f3e1e..8e0c4da9d76 100644
--- a/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chromium/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -275,6 +275,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_SIGNIN_PREF_DISALLOWED_TITLE" desc="Title for the signin entry in Settings when signin is disallowed.">
+ Not signed in
+ </message>
<message name="IDS_SIGNIN_PREF_SUMMARY" desc="Summary for the entry in Settings to sign in to Chrome, explaining benefits of signing in.">
Sync and personalize across devices
</message>
@@ -297,6 +300,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_SIGN_OUT_AND_TURN_OFF_SYNC" desc="The text for a preferences row that for signs out the user and turns off sync.">
Sign out and turn off sync
</message>
+ <message name="IDS_SIGN_OUT" desc="The text for a preference row that signs out the user.">
+ Sign out
+ </message>
<message name="IDS_MANAGE_YOUR_GOOGLE_ACCOUNT" desc="Title for link to Google Account Page to manage account settings.">
Manage your Google Account
</message>
@@ -315,6 +321,12 @@ CHAR-LIMIT guidelines:
<message name="IDS_PREFS_GOOGLE_SERVICES" desc="Title for the group of preferences that control non-personalized Google services. This group contains preferences for data that is not tied to user's Google Account. [CHAR-LIMIT=40]">
Google services
</message>
+ <message name="IDS_OFFER_CHROME_SIGNIN_TITLE" desc="Title for a checkbox in Google services that controls sign-in and sync prompts.">
+ Allow Chrome sign-in
+ </message>
+ <message name="IDS_OFFER_CHROME_SIGNIN_SUMMARY" desc="Summary for a checkbox in Google services that controls sign-in and sync prompts.">
+ Show Chrome sign-in prompts when you sign in to your Google Account
+ </message>
<message name="IDS_AUTOCOMPLETE_SEARCHES_AND_URLS_TITLE" desc="Title for a checkbox in Settings that controls URL and search autocompletion and informs the user about the data shared by this feature.">
Autocomplete searches and URLs
</message>
@@ -339,9 +351,15 @@ CHAR-LIMIT guidelines:
<message name="IDS_URL_KEYED_ANONYMIZED_DATA_SUMMARY" desc="Summary for a checkbox in Settings that controls non-personalized URL collection and informs the user about the data shared by this feature.">
Sends URLs of pages you visit to Google
</message>
- <message name="IDS_PRIVACY_SYNC_AND_SERVICES_LINK" desc="The text for Privacy preferences that is shown after all preference rows.">
+ <message name="IDS_PRIVACY_SYNC_AND_SERVICES_LINK_LEGACY" desc="The text for Privacy preferences that is shown after all preference rows.">
For more settings that relate to privacy, security, and data collection, see <ph name="BEGIN_LINK">&lt;link&gt;</ph>Sync and Google services<ph name="END_LINK">&lt;/link&gt;</ph>
</message>
+ <message name="IDS_PRIVACY_SYNC_AND_SERVICES_LINK_SYNC_ON" desc="The text for Privacy preferences that is shown after all preference rows. This version of the text is shown if Sync has been turned on.">
+ For more settings that relate to privacy, security, and data collection, see <ph name="BEGIN_LINK1">&lt;link1&gt;</ph>Sync<ph name="END_LINK1">&lt;/link1&gt;</ph> and <ph name="BEGIN_LINK2">&lt;link2&gt;</ph>Google services<ph name="END_LINK2">&lt;/link2&gt;</ph>
+ </message>
+ <message name="IDS_PRIVACY_SYNC_AND_SERVICES_LINK_SYNC_OFF" desc="The text for Privacy preferences that is shown after all preference rows. This version of the text is shown if Sync hasn't been turned on.">
+ For more settings that relate to privacy, security, and data collection, see <ph name="BEGIN_LINK">&lt;link&gt;</ph>Google services<ph name="END_LINK">&lt;/link&gt;</ph>
+ </message>
<message name="IDS_USAGE_AND_CRASH_REPORTS_TITLE" desc="Title for a preference that enables sending usage statistics and crash reports.">
Help improve Chrome's features and performance
</message>
@@ -647,6 +665,13 @@ CHAR-LIMIT guidelines:
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
+ </message>
+ <message name="IDS_ENHANCED_PROTECTION_PROMO_DESCRIPTION" desc="The description displayed on enhanced protection promo card, which guides the user to the chrome settings page to select the enhanced protection option.">
+ Enhanced protection does more to block phishing and malware
+ </message>
<!-- Notifications preferences -->
<message name="IDS_PREFS_NOTIFICATIONS" desc="Title for Notification preferences.">
@@ -1088,15 +1113,42 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_LANGUAGE_SETTINGS" desc="Title for the Languages settings screen that allows users to manage their languages preferences. [CHAR-LIMIT=32]">
Languages
</message>
+ <message name="IDS_APP_LANGUAGE_TITLE" desc="Title of Language settings section to change Chrome’s user interface language. [CHAR-LIMIT=32]">
+ <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph>’s language
+ </message>
+ <message name="IDS_DEFAULT_LANG_SUBTITLE" desc="Subtite to use for the device’s default language. [CHAR-LIMIT=42]">
+ Default device language
+ </message>
<message name="IDS_ADD_LANGUAGE" desc="Title for the screen that allows users to add languages to their preferred language list. [CHAR-LIMIT=32]">
Add language
</message>
+ <message name="IDS_CHANGE_CHROME_LANG" desc="Title of page to select a language within Chrome's language settings. [CHAR-LIMIT=32]">
+ Change language
+ </message>
+ <message name="IDS_LANGUAGES_SELECT" desc="Option in overflow menu on Language settings page to change Chrome’s user interface language. [CHAR-LIMIT=32]">
+ Select language
+ </message>
+ <message name="IDS_LANGUAGES_SELECT_SUGGESTED" desc="Title appearing above list of languages ordered based on what users in that country might select. [CHAR-LIMIT=32]">
+ Suggested languages
+ </message>
+ <message name="IDS_LANGUAGES_SELECT_OTHER" desc="Subtite appearing above list of all languages not likely to be selected by users in that country. [CHAR-LIMIT=32]">
+ Other languages
+ </message>
+ <message name="IDS_LANGUAGES_CONTENT_TITLE" desc="Title of Language settings section to add or remove preferred content languages. Content languages are selected by the user and tell Chrome what language the user prefers webpage content in. [CHAR-LIMIT=32]">
+ Content languages
+ </message>
+ <message name="IDS_LANGUAGES_CONTENT_DESCRIPTION" desc="Description of Content language on the Language settings screen. Appears above a list of one or more languages that the user selects to tell Chrome which languages they prefer webpage content in.">
+ To show content in your preferred languages, the sites you visit can see your preferences
+ </message>
<message name="IDS_LANGUAGES_LIST_DESCRIPTION" desc="Description on the Languages settings screen. Appears above a list of one or more languages that the user selects, to tell Chrome which languages they prefer to use to read website content.">
Websites will show text in your preferred language, when possible.
</message>
<message name="IDS_LANGUAGES_OFFER_TRANSLATE_SWITCH" desc="Appears next to the 'offer to translate' switch that controls whether or not Chrome will display the Google Translate UI on web pages that are not in the user's preferred language(s).">
Offer to translate pages in other languages
</message>
+ <message name="IDS_LANGUAGES_SEND_TRANSLATE_SWITCH" desc="Appears next to the switch controlling whether or not Chrome will offer to translate pages in other languages. When enabled the Google Translate UI will be displayed on web pages that are not in the user's preferred language(s).">
+ Offer to send pages in other languages to Google Translate
+ </message>
<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>
@@ -1109,6 +1161,36 @@ Your Google account may have other forms of browsing history like searches and a
<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>
+ <message name="IDS_LANGUAGES_SPLIT_DOWNLOADING" desc="Text to display next to a language when it is being downloaded to use as Chrome's UI. [CHAR-LIMIT=32]">
+ Downloading <ph name="LANG">%1$s<ex>Hindi</ex></ph>…
+ </message>
+ <message name="IDS_LANGUAGES_SPLIT_READY" desc="Text to display when a language pack has been downloaded. The user needs to restart Chrome to use the new language as Chrome's UI.">
+ Language ready, restart <ph name="APP_NAME">%1$s<ex>Chrome</ex></ph>
+ </message>
+ <message name="IDS_LANGUAGES_INFOBAR_READY" desc="Infobar text to appear when a new language pack has been downloaded. [CHAR-LIMIT=32]">
+ <ph name="LANG">%1$s<ex>Hindi</ex></ph> is ready.
+ </message>
+ <message name="IDS_LANGUAGES_INFOBAR_RESTART" desc="The clickable link letting the user know they can click to restart Chrome. [CHAR-LIMIT=32]">
+ Restart Chrome
+ </message>
+ <message name="IDS_LANGUAGES_SETTINGS_TITLE" desc="Title of Language settings section to control translation preferences. [CHAR-LIMIT=32]">
+ Translation settings
+ </message>
+ <message name="IDS_LANGUAGES_SETTINGS_ADVANCED" desc="Title of Language settings section that will show advanced translation settings. [CHAR-LIMIT=32]">
+ Advanced
+ </message>
+ <message name="IDS_LANGUAGES_SETTINGS_TARGET" desc="Title of Translation settings for the current translate targert. Tapping this opens a new screen to select the target language. [CHAR-LIMIT=32]">
+ Translate into this language
+ </message>
+ <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.">
+ Don’t offer to translate these languages
+ </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>
<!-- 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.">
@@ -1396,15 +1478,21 @@ Your Google account may have other forms of browsing history like searches and a
</message>
<!-- Sync strings in account management dialog -->
- <message name="IDS_SYNC_ANDROID_MASTER_SYNC_DISABLED" desc="Message to show when Android master sync flag is disabled">
+ <message name="IDS_SYNC_ANDROID_SYSTEM_SYNC_DISABLED" desc="Message to show when Android system-level sync flag is disabled">
Android system sync disabled
</message>
<message name="IDS_SYNC_IS_DISABLED" desc="Message to show when Chrome sync is disabled">
Sync is off
</message>
- <message name="IDS_SYNC_SETTINGS_NOT_CONFIRMED" desc="The error message to display when sign-in was interrupted and the user didn't review the sync settings.">
+ <message name="IDS_SYNC_DATA_TYPES_OFF" desc="Message to show when all sync data types are off">
+ No data selected to sync
+ </message>
+ <message name="IDS_SYNC_SETTINGS_NOT_CONFIRMED_LEGACY" desc="The error message to display when sign-in was interrupted and the user didn't review the sync settings.">
Initial sync setup was not finished. Sync is off.
</message>
+ <message name="IDS_SYNC_SETTINGS_NOT_CONFIRMED" desc="The error message to display when sign-in was interrupted and the user didn't review the sync settings.">
+ Tap to set up sync
+ </message>
<message name="IDS_SYNC_IS_DISABLED_BY_ADMINISTRATOR" desc="Message to show when Chrome sync is disabled by administrator">
Sync is disabled by your administrator
</message>
@@ -1689,6 +1777,9 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Enter your passphrase to start sync
</message>
<message name="IDS_HINT_SYNC_SETTINGS_NOT_CONFIRMED_DESCRIPTION" desc="The error message to display when sign-in was interrupted and the user didn't review the sync settings.">
+ Choose what to sync below
+ </message>
+ <message name="IDS_HINT_SYNC_SETTINGS_NOT_CONFIRMED_DESCRIPTION_LEGACY" desc="The error message to display when sign-in was interrupted and the user didn't review the sync settings.">
To start sync, turn on "Sync your Chrome data".
</message>
<message name="IDS_HINT_OTHER_SYNC_ERRORS" desc="Hint message to resolve sync errors not listed independently.">
@@ -1711,12 +1802,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_SYNC_SETUP_INCOMPLETE_ERROR_CARD_CONFIRM_BUTTON" desc="Positive button text for advanced sync interrupted error in sync error cards.">
- Confirm sync
- </message>
- <message name="IDS_SYNC_SETUP_INCOMPLETE_ERROR_CARD_CANCEL_BUTTON" desc="Negative button text for advanced sync interrupted error in sync error cards. This button turns off Sync.">
- Cancel sync setup
- </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>
@@ -2057,7 +2142,7 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
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 web app
+ Install app
</message>
<message name="IDS_APP_BANNER_ADD" desc="A button in an app banner to confirm adding a site to homescreen">
Add
@@ -2288,7 +2373,7 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_DOWNLOAD_MANAGER_SEARCH" desc="Placeholder text for the input field that allows users to search downloads.">
Search your downloads
</message>
- <message name="IDS_DOWNLOAD_MANAGER_LIST_ITEM_DESCRIPTION" desc="Text containing the download list item description.">
+ <message name="IDS_DOWNLOAD_MANAGER_LIST_ITEM_DESCRIPTION" desc="Text containing the download list item description. This is also used warn user that the current download location does not have enough space.">
<ph name="FILE_SIZE">%1$s<ex>1.56 MB</ex></ph> <ph name="SEPARATOR">•</ph> <ph name="DESCRIPTION">%2$s<ex>www.example.com</ex></ph>
</message>
<message name="IDS_DOWNLOAD_MANAGER_LIST_ITEM_DESCRIPTION_NO_SIZE" desc="Text containing the download list item description.">
@@ -2397,16 +2482,22 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SIGNIN_ADD_ACCOUNT_TO_DEVICE" desc="Text for adding another Google Account to device in the web sign-in flow and account picker dialog, users will be asked to add an account to his device when this text is tapped">
Add account to device
</message>
- <message name="IDS_SIGNIN_INCOGNITO_MODE_PRIMARY" desc="Text for signing in incognito mode.">
- Go Incognito mode
- </message>
- <message name="IDS_SIGNIN_INCOGNITO_MODE_SECONDARY" desc="Secondary text for signing in incognito mode.">
- To sign in temporarily
+ <message name="IDS_SIGNIN_INCOGNITO_BUTTON" desc="Button text to open the incognito interstitial in the web sign-in account picker bottom sheet">
+ Open an Incognito tab
</message>
<message name="IDS_SIGNIN_GMS_UPDATING" desc="Message notifying user that Google Play Services is still updating.">
Waiting for Google Play Services to finish updating
</message>
+ <!-- Strings for Incognito Interstitial. -->
+ <message name="IDS_INCOGNITO_INTERSTITIAL_TITLE" desc="The title of the incognito interstitial bottom sheet.">
+ Use Incognito to sign in
+ </message>
+ <message name="IDS_INCOGNITO_INTERSTITIAL_MESSAGE" desc="The content of Incognito interstitial which is shown when a user is in the sign-in flow and they want to go Incognito mode to continue signing in. Before they go Incognito mode they would be presented with an Incognito interstitial and this message is part of that interstitial which would inform how activity in Incognito may be visbile to others and how data from the Incognito session can be cleared.">
+In Incognito, your activity <ph name="BEGIN_BOLD1">&lt;b1&gt;</ph>might still be visible <ph name="END_BOLD1">&lt;/b1&gt;</ph>to websites that you visit, your employer or school, and your internet service provider.
+
+Data from your Incognito session will only be cleared from Chrome when you <ph name="BEGIN_BOLD2">&lt;b2&gt;</ph>close all Incognito tabs<ph name="END_BOLD2">&lt;/b2&gt;</ph>.
+ </message>
<!-- Strings for Streamlined Signin and Unified Consent. -->
<message name="IDS_SIGNIN_TITLE" desc="Title for the screen that asks users to sign-in and turn on Sync. [CHAR-LIMIT=27]">
Turn on sync?
@@ -2430,7 +2521,7 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Choose an account
</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">
- You’ll be signed in with your Google Account\n(this won’t turn on Chrome Sync)
+ Sign in to this site and Chrome with your Google Account. You can turn on sync later.
</message>
<message name="IDS_SIGNIN_ACCOUNT_PICKER_BOTTOM_SHEET_SIGNIN_TITLE" desc="The title of the account picker bottom sheet tells that the user is in the process of signing in with their Google Account">
Signing in...
@@ -2441,6 +2532,9 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SIGNIN_ACCOUNT_PICKER_GENERAL_ERROR_SUBTITLE" desc="The subtitle of the account picker bottom sheet when something went wrong in the sign-in process">
Chrome couldn’t verify your information
</message>
+ <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_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>
@@ -2480,9 +2574,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SIGNIN_PROMO_CHOOSE_ANOTHER_ACCOUNT" desc="Button that the user can press if they want to select a different account before signing in. This button is shown below 'Continue as Joe Doe' button that signs user in with default account.">
Choose another account
</message>
- <message name="IDS_SIGNIN_PROMO_STATUS_MESSAGE" desc="Title string for 'Turn on sync' sync promos.">
- Sync is off
- </message>
<message name="IDS_SYNC_PROMO_TURN_ON_SYNC" desc="Button that the user can press if they want to turn on sync with this account.">
Turn on sync
</message>
@@ -2492,15 +2583,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
</message>
<!-- New Tab Page strings -->
- <message name="IDS_EXPLORE_OFFLINE_CARD_TITLE" desc="Card title text informing the user that they can explore the offline feed. ">
- Keep exploring offline
- </message>
- <message name="IDS_EXPLORE_OFFLINE_CARD_DESCRIPTION" desc="Card description text informing the user that they can consume the videos, articles and other content even though they are offline. ">
- Get articles, videos, and other content from sites you like, even if you’re offline or your connection is poor.
- </message>
- <message name="IDS_EXPLORE_OFFLINE_CARD_EXPLORE" desc="Button text on the explore offline card on new tab page that shows up when the user is offline. Clicking on this button will take the user to downloads home where they can consume articles, audios and videos while being offline.">
- Explore
- </message>
<message name="IDS_RECENT_TABS" desc="Text for button to show 'Recent tabs', i.e. recently closed tabs and tabs that are open on other devices [CHAR-LIMIT=20]">
Recent tabs
</message>
@@ -2631,6 +2713,67 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
See popular websites by tapping the "Top sites" button
</message>
+ <!-- Video tutorials -->
+ <message name="IDS_VIDEO_TUTORIALS_CARD_CHROME_INTRO" desc="Card text prompting user to learn about an introduction to chrome. Tapping on this card will open a video tutorial.">
+ How to use Chrome
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_CARD_SEARCH" desc="Card text prompting user to learn about how to search using chrome. Tapping on this card will open a video tutorial.">
+ How to search with Chrome
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_CARD_VOICE_SEARCH" desc="Card text prompting user to learn about how use voice search inside chrome. Tapping on this card will open a video tutorial.">
+ How to search with your voice
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_CARD_DOWNLOAD" desc="Card text prompting user to learn about how to download content using chrome. Tapping on this card will open a video tutorial.">
+ How to download content for later
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_CARD_ALL_VIDEOS" desc="Card text prompting user to tap on this card and explore videos on various aspects of chrome. Tapping on this card will open up a page listing all the available video tutorials.">
+ Videos about how to use Chrome
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_LEARN_CHROME" desc="Header text for the video tutorials home page that lists all the video tutorials.">
+ Learn Chrome
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_POPULAR_VIDEOS" desc="Header text for the video tutorials carousel on the help and feedback page.">
+ Popular videos
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_TILE_CHROME_INTRO" desc="Text under image tile prompting user to learn about an introduction to chrome. Tapping on this image will open a video tutorial.">
+ Navigate Chrome
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_TILE_SEARCH" desc="Text under image tile prompting user to learn about how to search using chrome. Tapping on this image will open a video tutorial.">
+ Search the internet
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_TILE_VOICE_SEARCH" desc="Text under image tile prompting user to learn about how use voice search inside chrome. Tapping on this image will open a video tutorial.">
+ Use voice search
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_TILE_DOWNLOAD" desc="Text under image tile prompting user to learn about how to download content using chrome. Tapping on this image will open a video tutorial.">
+ Download content
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_LANGUAGE_PICKER_TITLE" desc="Label text in the video player prompting user to pick a language.">
+ Pick your language
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_WATCH" desc="Button text in the video player prompting user to watch the video.">
+ Watch
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_TRY_NOW" desc="Button text in the video player prompting user to try out the steps mentioned in the tutorial.">
+ Try now
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_WATCH_NEXT_VIDEO" desc="Button text in the video player prompting user to watch the next video.">
+ Watch next video
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_CHANGE_LANGUAGE" desc="Button text in the video player prompting user to change the language.">
+ Change <ph name="LANGUAGE">%1$s<ex>Hindi</ex></ph>?
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_ACCESSIBILITY_SHARE" desc="Accessibility text in the video player describing that users can tap on this icon to share the video.">
+ Share
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_ACCESSIBILITY_CLOSE" desc="Accessibility text in the video player describing that users can tap on this icon to close the video.">
+ Close
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_IPH_TAP_HERE_TO_START" desc="In-product help bubble text prompting user to click on the search box to start.">
+ Tap here to start
+ </message>
+ <message name="IDS_VIDEO_TUTORIALS_IPH_TAP_VOICE_ICON_TO_START" desc="In-product help bubble text prompting user to start typing on the search box or tap on the microphone icon to start a voice search.">
+ Type here or tap the voice icon to start
+ </message>
<!-- Toolbar button strings -->
<message name="IDS_OPEN_TABS" desc="Text for button to enter the tab switcher and show tabs that are open on this device">
@@ -2740,6 +2883,12 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_MENU_GROUP_TABS" desc="Menu item for grouping tabs. [CHAR-LIMIT=27]">
Group tabs
</message>
+ <message name="IDS_MENU_GET_IMAGE_DESCRIPTIONS" desc="Menu item to start getting alt text accessibility image labels/descriptions [CHAR-LIMIT=27]">
+ Get image descriptions
+ </message>
+ <message name="IDS_MENU_STOP_IMAGE_DESCRIPTIONS" desc="Menu item to stop getting alt text accessibility image labels/descriptions [CHAR-LIMIT=27]">
+ Stop image descriptions
+ </message>
<!-- Bookmarks strings -->
<message name="IDS_BOOKMARKS" desc="Title of the bookmarks page, which shows a list of the user's bookmarks. [CHAR-LIMIT=18]">
@@ -2835,6 +2984,41 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
URL required
</message>
+ <!-- Read later strings -->
+ <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_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
+ </message>
+ <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.">
+ You have <ph name="READING_LIST_COUNT">%1$d<ex>5</ex></ph> pages
+ </message>
+ <message name="IDS_READING_LIST_UNREAD_PAGE_COUNT" desc="Inform the user about the number of unread reading list items.">
+ <ph name="READING_LIST_COUNT">%1$d<ex>5</ex></ph> unread pages
+ </message>
+ <message name="IDS_READING_LIST_INTRO_TEXT" desc="The text on the reading list in product help bubble and other UIs to introduce the feature to the user.">
+ Save this page for later and 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
+ </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.">
Viewing an offline copy of this page
@@ -2896,7 +3080,7 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_LOCATION_BAR_PREVIEW_LITE_PAGE_STATUS" desc="An indication in the location bar that the page the user is viewing has been modified in order to speed up the page load or decrease the amount of data used to load the page. [CHAR-LIMIT=10]">
Lite
</message>
- <message name="IDS_LOCATION_BAR_PAINT_PREVIEW_PAGE_STATUS" desc="An indication in the location bar that the page the user is viewing is a paint preview of the original page. [CHAR-LIMIT=10]" translateable="false">
+ <message name="IDS_LOCATION_BAR_PAINT_PREVIEW_PAGE_STATUS" desc="An indication in the location bar that the page the user is viewing is a paint preview of the original page. [CHAR-LIMIT=10]">
Preview
</message>
@@ -2938,9 +3122,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_MENU_OS_VERSION_UNSUPPORTED" desc="Content description for the menu button when it is covered by the warning icon that is displayed when the current Android OS version is unsupported.">
Chrome can’t update. More options
</message>
- <message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_SEARCH_ACCELERATOR" desc="Content description for the search accelerator button">
- Search
- </message>
<message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_SITE_INFO" desc="Content description for the page icon that gives more site information when clicked. The icon can be a magnifier for search result pages, or other icons representing the page state.">
Site information
</message>
@@ -2959,12 +3140,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_NEW_INCOGNITO_TAB" desc="Content description for the new incognito tab button.">
New incognito tab
</message>
- <message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_CLOSE_ALL_TABS" desc="Content description for the close all tabs button.">
- Close all tabs
- </message>
- <message name="IDS_ACCESSIBILITY_TOOLBAR_BTN_CLOSE_ALL_INCOGNITO_TABS" desc="Content description for the close all incognito tabs button.">
- Close all incognito tabs
- </message>
<message name="IDS_ACCESSIBILITY_INCOGNITO_BADGE" desc="Content description for the badge indicating that the user is in Incognito mode.">
Incognito mode
</message>
@@ -3016,13 +3191,18 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_ACCESSIBILITY_TABSTRIP_INCOGNITO_IDENTIFIER_SELECTED" desc="Content description for the tab that is selected in incognito mode">
Selected Incognito Tab
</message>
- <message name="IDS_ACCESSIBILITY_OMNIBOX_BTN_REFINE" desc="Content description for the omnibox refine button.">
- Refine
+ <message name="IDS_ACCESSIBILITY_OMNIBOX_BTN_REFINE" desc="Content description for the omnibox refine button followed with the text or URL that will be shown in the Omnibox if the user clicks the refine button, eg. User input 'The' may offer a suggestion 'The meaning of life' or 'thewirecutter.com'.">
+ Refine: <ph name="REFINE_TEXT">%1$s<ex>The meaning of life</ex></ph>
</message>
<message name="IDS_ACCESSIBILITY_OMNIBOX_SWITCH_TO_TAB" desc="Content description for the omnibox switch to tab button.">
Switch To Tab
</message>
-
+ <message name="IDS_ACCESSIBILITY_OMNIBOX_SHOWING_SUGGESTIONS_FOR_WEBSITE" desc="Whenever the User is visiting a Website, when they click the Omnibox, we will announce this message, if we have suggestions to show.">
+ Showing suggestions for <ph name="WEBSITE_TITLE">%1$s<ex>Crater Lake National Park (U.S. National Park Service)</ex></ph>
+ </message>
+ <message name="IDS_ACCESSIBILITY_OMNIBOX_MOST_VISITED_TILE" desc="When the user focuses a Frequently Visited URL tile suggestion, the tile will be crome://announced according to the following pattern">
+ <ph name="WEBSITE_TITLE">%1$s<ex>Crater Lake National Park (U.S. National Park Service)</ex></ph>: <ph name="WEBSITE_URL">%1$s<ex>https://www.nps.gov/crla</ex></ph>
+ </message>
<message name="IDS_ACCESSIBILITY_SHARE_SELECTED_ITEMS" desc="Content description for the button to share selected items. [ICU Syntax]">
{NUM_SELECTED, plural,
@@ -3248,78 +3428,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<ph name="BEGIN_LINK">&lt;link&gt;</ph>Get help<ph name="END_LINK">&lt;/link&gt;</ph>
</message>
- <!-- Contacts Picker strings -->
- <message name="IDS_CONTACTS_PICKER_SEARCH" desc="The hint text for the search box for contacts.">
- Search your contacts
- </message>
- <message name="IDS_CONTACTS_PICKER_SELECT_CONTACTS" desc="The label at the top of the dialog that allows users to select contacts from their device and share the details with a web page.">
- Select contacts
- </message>
- <message name="IDS_CONTACTS_PICKER_SELECT_CONTACT" desc="The label at the top of the dialog that allows users to select a single contact from their device and share the details with a web page.">
- Select a contact
- </message>
- <message name="IDS_CONTACTS_PICKER_ALL_CONTACTS" desc="The label associated with the select all checkbox, indicating that all the contacts will be selected.">
- All contacts
- </message>
- <message name="IDS_CONTACTS_PICKER_NO_CONTACTS_FOUND" desc="The label shown when no contacts are found (e.g. none exist on the device).">
- No contacts found
- </message>
- <message name="IDS_TOP_VIEW_NAMES_FILTER_LABEL" desc="The label shown for the names filter toggle button (allowing the user to exclude names).">
- Names
- </message>
- <message name="IDS_TOP_VIEW_ADDRESS_FILTER_LABEL" desc="The label shown for the address filter toggle button (allowing the user to exclude names).">
- Addresses
- </message>
- <message name="IDS_TOP_VIEW_EMAIL_FILTER_LABEL" desc="The label shown for the email filter toggle button (allowing the user to exclude emails).">
- Email addresses
- </message>
- <message name="IDS_TOP_VIEW_TELEPHONE_FILTER_LABEL" desc="The label shown for the telephone filter toggle button (allowing the user to exclude telephones).">
- Phone numbers
- </message>
- <message name="IDS_TOP_VIEW_ICON_FILTER_LABEL" desc="The label shown for the icon filter toggle button (allowing the user to exclude icons).">
- Profile photos
- </message>
- <message name="IDS_CONTACTS_PICKER_MORE_DETAILS" desc="Label describing that the user has one or more telephone/emails (used for either).">
- {DETAIL_COUNT, plural,
- =1 {(+ 1 more)}
- other {(+ # more)}}
- </message>
- <message name="IDS_DISCLAIMER_SHARING_CONTACT_DETAILS" desc="Label describing what will happen with the contact details that are being shared.">
- The contacts you select will be shared with <ph name="BEGIN_BOLD">&lt;b&gt;</ph><ph name="SITE">%1$s<ex>https://www.google.com</ex></ph><ph name="END_BOLD">&lt;/b&gt;</ph>.
- </message>
-
- <!-- Photo Picker strings -->
- <message name="IDS_DECODER_DESCRIPTION" desc="The title for the image decoder utility service.">
- Image decoder
- </message>
- <message name="IDS_FAST_FORWARD_HINT" desc="The hint string shown when a user drags the tumb in the video seeker (reminding them of an easier way to skip ahead/go back).">
- Double tap video left or right to skip 10s
- </message>
- <message name="IDS_ACCESSIBILITY_PLAY_VIDEO" desc="The accessibility string for the play video button.">
- Play video
- </message>
- <message name="IDS_ACCESSIBILITY_PAUSE_VIDEO" desc="The accessibility string for the pause video button.">
- Pause video
- </message>
- <message name="IDS_ACCESSIBILITY_MUTE_VIDEO" desc="The accessibility string for the mute video button.">
- Mute video
- </message>
- <message name="IDS_ACCESSIBILITY_UNMUTE_VIDEO" desc="The accessibility string for the unmute video button.">
- Unmute video
- </message>
- <message name="IDS_ACCESSIBILITY_FULL_SCREEN" desc="The accessibility string for the full screen video button.">
- Full screen
- </message>
- <message name="IDS_ACCESSIBILITY_EXIT_FULL_SCREEN" desc="The accessibility string for the exiting of full screen video button.">
- Exit full screen
- </message>
- <message name="IDS_ACCESSIBILITY_VIDEO_PLAYER" desc="The accessibility string for the video player.">
- Video player
- </message>
- <message name="IDS_ACCESSIBILITY_PLAYBACK_TIME" desc="The accessibility string for how much time has elapsed while viewing the video and how long the video is in total.">
- Elapsed time <ph name="ELAPSED_TIME">%1$s<ex>0:01</ex></ph> of <ph name="TOTAL_TIME">%2$s<ex>0:45</ex></ph>.
- </message>
-
<!-- Special locale UI strings -->
<message name="IDS_SEARCH_WITH_SOGOU" desc="Text telling the user that the search engine will be switched to Sogou.">
Search with Sogou
@@ -3350,7 +3458,7 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Running in Chrome
</message>
<message name="IDS_TWA_RUNNING_IN_CHROME_V2" desc="Updated message on a snackbar indicating that the current Activity may use Chrome data (the rest of the app may not be).">
- You'll see your <ph name="SITE_NAME">%1$s<ex>www.youtube.com</ex></ph> sign-in status, browsing data, and site data in Chrome.
+ You'll see your <ph name="SITE_NAME">%1$s<ex>www.youtube.com</ex></ph> sign-in status, browsing data, and site data in Chrome
</message>
<message name="IDS_GOT_IT" desc="Button for the user to accept a disclosure/message">
Got it
@@ -3666,6 +3774,24 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SHARING_HUB_SYNC_DISABLED_TEXT" desc="Text to show when sync is disabled on the current device.">
To share this page to another device, turn on sync in Chrome settings
</message>
+ <message name="IDS_SHARING_HUB_STORAGE_DISABLED_TEXT" desc="Text to show when storage permission is disabled.">
+ You have disabled Storage access, please go to Settings to enable it.
+ </message>
+ <message name="IDS_SHARING_HUB_OPEN_SETTINGS_LABEL" desc="Label for the open settings button.">
+ Open Settings
+ </message>
+ <message name="IDS_SHARING_HUB_AUDIO_PREVIEW_SUBTITLE" desc="Subtitle shown in the preview of Sharing Hub audio file shares.">
+ audio
+ </message>
+ <message name="IDS_SHARING_HUB_IMAGE_PREVIEW_SUBTITLE" desc="Subtitle shown in the preview of Sharing Hub image shares.">
+ image
+ </message>
+ <message name="IDS_SHARING_HUB_TEXT_PREVIEW_SUBTITLE" desc="Subtitle shown in the preview of Sharing Hub text file shares.">
+ text
+ </message>
+ <message name="IDS_SHARING_HUB_VIDEO_PREVIEW_SUBTITLE" desc="Subtitle shown in the preview of Sharing Hub video file shares.">
+ video
+ </message>
<!-- ClickToCall -->
<message name="IDS_CLICK_TO_CALL_NOTIFICATION_TEXT" desc="Text displayed in a click to call notification to call on a number.">
@@ -3726,43 +3852,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Send text to Your Devices
</message>
- <!-- Chrome Duet -->
- <message name="IDS_IPH_DUET_HOME_BUTTON_TITLE" desc="This string appears in an overlay that explains a new UI to users. The title of the feature highlight bubble that explains what is home button in bottom toolbar for.">
- Get back home easily
- </message>
- <message name="IDS_IPH_DUET_HOME_BUTTON_DESCRIPTION" desc="This string appears in an overlay that explains a new UI to users. The text in the feature highlight bubble that explains what is home button in bottom toolbar for.">
- Tap here to quickly access your homepage from anywhere
- </message>
- <message name="IDS_IPH_DUET_SEARCH_TITLE" desc="This string appears in an overlay that explains a new UI to users. 'Search' refers to searching the web, and 'explore' refers to Chrome's suggested content.">
- Search &amp; explore
- </message>
- <message name="IDS_IPH_DUET_SEARCH_DESCRIPTION" desc="This string appears in an overlay that explains a new UI to users. 'From here' is a generic directional cue: don't worry about the direction, as it is clarified by the way the overlay is shown.">
- From here, you can search the web, share with friends, and see open pages
- </message>
- <message name="IDS_IPH_DUET_TAB_SWITCHER_TITLE" desc="This string appears in an overlay that explains a new UI to users. The title of the feature highlight bubble that explains what is tab switcher in bottom toolbar for.">
- See all your open tabs
- </message>
- <message name="IDS_IPH_DUET_TAB_SWITCHER_DESCRIPTION" desc="This string appears in an overlay that explains a new UI to users. The text in the feature highlight bubble that explains what is tab switcher in bottom toolbar for.">
- Tap here to create new tabs and go back to previous ones
- </message>
-
- <!-- Photo picker -->
- <message name="IDS_PHOTO_PICKER_SELECT_IMAGES" desc="The label in the title bar of the Photo Picker dialog, suggesting that the user can make multiple selections.">
- Select images
- </message>
- <message name="IDS_PHOTO_PICKER_SELECT_IMAGE" desc="The label in the title bar of the Photo Picker dialog, suggesting that the user can make a single selection.">
- Select an image
- </message>
- <message name="IDS_PHOTO_PICKER_CAMERA" desc="The label for the Camera action in the Photo Picker (opening the camera system intent).">
- Camera
- </message>
- <message name="IDS_PHOTO_PICKER_BROWSE" desc="The label for the Browse action in the Photo Picker (browsing for photos).">
- Browse
- </message>
- <message name="IDS_PHOTO_PICKER_VIDEO_DURATION" desc="The label showing the duration time and current position of the video, as in: 0:01 / 0:10.">
- <ph name="POSITION">%1$s<ex>0:01</ex></ph> / <ph name="DURATION">%2$s<ex>0:10</ex></ph>
- </message>
-
<!-- Interventions -->
<message name="IDS_REDIRECT_BLOCKED_MESSAGE" desc="The message stating that a redirect (noun) was blocked on this page. This will be followed on a separate line with the address the user was being redirected to.">
Redirect blocked:
@@ -3904,6 +3993,10 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
More
</message>
+ <message name="IDS_SHARING_COPY" desc="Label for the Copy button in the sharing hub.">
+ Copy
+ </message>
+
<message name="IDS_SHARING_COPY_URL" desc="Label for the Copy URL button in the sharing hub.">
Copy link
</message>
@@ -3924,6 +4017,10 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Link to text
</message>
+ <message name="IDS_SHARING_COPIED" desc="Text shown in the toast notification when Copy is selected in the sharing hub.">
+ Copied
+ </message>
+
<message name="IDS_TEXT_COPIED" desc="Text shown in the toast notification when Copy Text is selected in the sharing hub.">
Text Copied
</message>
@@ -3976,12 +4073,8 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
chrome_qrcode_<ph name="CURRENT_TIMESTAMP_MS">%1$s<ex>1582667748515</ex></ph>
</message>
- <message name="IDS_LINK_TO_TEXT_SUCCESS_MESSAGE" desc="Message displayed when link to highlighted text is successfully created.">
- Share link to the highlighted text in an app
- </message>
-
- <message name="IDS_LINK_TO_TEXT_FAILURE_MESSAGE" desc="Message displayed when link to highlighted text was not possible to create.">
- Can't create link to text. Share link to page in an app.
+ <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.
</message>
<!-- Share Screenshot strings -->
@@ -4001,6 +4094,10 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Share
</message>
+ <message name="IDS_SCREENSHOT_TITLE_FOR_SHARE" desc="The title shared with the screenshot.">
+ Screenshot <ph name="CURRENT_DATE_ISO">%1$s<ex>2020-09-16</ex></ph>
+ </message>
+
<message name="IDS_SCREENSHOT_FILENAME_PREFIX" desc="File name prefix for downloaded screenshot that is followed by timestamp.">
chrome_screenshot_<ph name="CURRENT_TIMESTAMP_MS">%1$s<ex>1582667748515</ex></ph>
</message>
@@ -4025,19 +4122,20 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_PAINT_PREVIEW_DEMO_PLAYBACK_START" desc="Toast message displayed when paint preview starts displaying. Used in paint preview demo mode." translateable="false">
Displaying Paint Preview. Press back to exit the Paint Preview demo.
</message>
- <message name="IDS_PAINT_PREVIEW_DEMO_PLAYBACK_END" desc="Toast message displayed when the user exits paint preview demo. Used in paint preview demo mode." translateable="false">
- Exited Paint Preview demo.
- </message>
<message name="IDS_PAINT_PREVIEW_DEMO_PLAYBACK_FAILURE" desc="Toast message displayed when there is a failure in playing back a paint preview for the demo. Used in paint preview demo mode." translateable="false">
Paint Preview playback failed.
</message>
<!-- Paint Preview Startup Experiment -->
- <message name="IDS_PAINT_PREVIEW_STARTUP_UPGRADE_SNACKBAR_MESSAGE" desc="Message displayed on a snackbar when a paint preview is shown on startup, telling the user that this is a preview of the page" translateable="false">
- This is a preview
+ <message name="IDS_PAINT_PREVIEW_STARTUP_UPGRADE_SNACKBAR_MESSAGE" desc="Message displayed on a snackbar when a paint preview is shown on startup, telling the user that this is a preview of the page">
+ Previewing this page
</message>
- <message name="IDS_PAINT_PREVIEW_STARTUP_UPGRADE_SNACKBAR_ACTION" desc="Text displayed on the action button of snackbar, promting user to switch to the live page and exist paint preivew." translateable="false">
- View live page
+ <message name="IDS_PAINT_PREVIEW_STARTUP_UPGRADE_SNACKBAR_ACTION" desc="Text displayed on the action button of snackbar, promting user to switch to the live page and exit paint preivew. [CHAR-LIMIT=12]">
+ Reload
+ </message>
+ <message name="IDS_PAINT_PREVIEW_STARTUP_AUTO_UPGRADE_TOAST" desc="Text displayed as a toast message when paint preview
+ is automatically removed and live tab is shown.">
+ Viewing live page
</message>
<!-- Default Browser Promo Strings-->
@@ -4092,6 +4190,20 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_CHROME_REENGAGEMENT_NOTIFICATION_3_DESCRIPTION" desc="The title of a notification shown to suggest that users use Chrome. Users probably have not opened Chrome in a while. Promotes data savings and relevant news.">
Save up to 60% data, read today's news
</message>
+
+ <!-- Get Image Descriptions -->
+ <message name="IDS_IMAGE_DESCRIPTIONS_DIALOG_HEADER" desc="Header for confirmation dialog to enable image descriptions.">
+ Get image descriptions?
+ </message>
+ <message name="IDS_IMAGE_DESCRIPTIONS_DIALOG_CONTENT" desc="Content for confirmation dialog to enable image descriptions.">
+ Images are sent to Google to improve descriptions for you.
+ </message>
+ <message name="IDS_IMAGE_DESCRIPTIONS_DIALOG_OPTION_ONLY_ON_WIFI" desc="Option for confirmation dialog to enable image descriptions.">
+ Only on Wi-Fi
+ </message>
+ <message name="IDS_IMAGE_DESCRIPTIONS_DIALOG_GET_DESCRIPTIONS_BUTTON" desc="Button for dialog to enable option to get image descriptions.">
+ Get descriptions
+ </message>
</messages>
</release>
</grit>
diff --git a/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn b/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn
new file mode 100644
index 00000000000..1f1e836f719
--- /dev/null
+++ b/chromium/chrome/browser/ui/ash/holding_space/BUILD.gn
@@ -0,0 +1,56 @@
+# 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.
+
+source_set("browser_tests") {
+ testonly = true
+
+ defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
+
+ sources = [
+ "//chrome/browser/ui/ash/holding_space/holding_space_client_impl_browsertest.cc",
+ "//chrome/browser/ui/ash/holding_space/holding_space_keyed_service_browsertest.cc",
+ "//chrome/browser/ui/ash/holding_space/holding_space_ui_browsertest.cc",
+ ]
+
+ deps = [
+ ":test_support",
+ "//ash:test_support",
+ "//ash/public/cpp",
+ "//base/test:test_support",
+ "//chrome/browser",
+ "//chrome/browser/chromeos",
+ "//chrome/browser/extensions",
+ "//chrome/browser/ui",
+ "//chrome/test:test_support_ui",
+ "//content/test:test_support",
+ "//ui/aura",
+ "//ui/base",
+ "//ui/events:test_support",
+ "//ui/views",
+ "//ui/wm/public",
+ ]
+}
+
+source_set("test_support") {
+ testonly = true
+
+ sources = [
+ "//chrome/browser/ui/ash/holding_space/holding_space_browsertest_base.cc",
+ "//chrome/browser/ui/ash/holding_space/holding_space_browsertest_base.h",
+ ]
+
+ deps = [
+ "//ash:test_support",
+ "//ash/public/cpp",
+ "//base/test:test_support",
+ "//chrome/browser",
+ "//chrome/browser/chromeos",
+ "//chrome/browser/extensions",
+ "//chrome/browser/ui",
+ "//chrome/test:test_support_ui",
+ "//chromeos/dbus/session_manager",
+ "//components/session_manager/core",
+ "//ui/views",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn b/chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn
index 8ad2efbcbc3..be88b8ab2af 100644
--- a/chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn
+++ b/chromium/chrome/browser/ui/cocoa/notifications/BUILD.gn
@@ -32,6 +32,9 @@ mac_app_bundle("alert_notification_xpc_service") {
"AppKit.framework",
"Foundation.framework",
]
+ weak_frameworks = [
+ "UserNotifications.framework", # macOS 10.14
+ ]
ldflags = []
if (is_component_build) {
@@ -48,13 +51,20 @@ mac_app_bundle("alert_notification_xpc_service") {
static_library("common") {
sources = [
+ "notification_builder_base.h",
+ "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",
+ "unnotification_builder_mac.mm",
+ "unnotification_response_builder_mac.h",
+ "unnotification_response_builder_mac.mm",
"xpc_mach_port.h",
"xpc_mach_port.mm",
]
diff --git a/chromium/chrome/browser/ui/messages/android/BUILD.gn b/chromium/chrome/browser/ui/messages/android/BUILD.gn
index 0a6ba7c451b..9ab66142513 100644
--- a/chromium/chrome/browser/ui/messages/android/BUILD.gn
+++ b/chromium/chrome/browser/ui/messages/android/BUILD.gn
@@ -4,7 +4,6 @@
import("//build/config/android/rules.gni")
android_resources("java_resources") {
- create_srcjar = false
sources = [
"java/res/drawable/snackbar_background_tablet.xml",
"java/res/layout/snackbar.xml",
diff --git a/chromium/chrome/browser/ui/webui/DEPS b/chromium/chrome/browser/ui/webui/DEPS
index 6a321049a58..35b8fd79336 100644
--- a/chromium/chrome/browser/ui/webui/DEPS
+++ b/chromium/chrome/browser/ui/webui/DEPS
@@ -10,11 +10,4 @@ include_rules = [
"+third_party/angle", # For ANGLE version.
"+third_party/brotli", # For compressed resources.
"+third_party/zlib/zlib.h", # For compression level constants.
-]
-
-specific_include_rules = {
- "chrome_webui_navigation_browsertest.cc": [
- "+content/browser/frame_host/render_frame_host_impl.h",
- "+content/common/frame.mojom.h",
- ],
-} \ No newline at end of file
+] \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/OWNERS b/chromium/chrome/browser/ui/webui/OWNERS
index 3b8b0cac132..db0825c6759 100644
--- a/chromium/chrome/browser/ui/webui/OWNERS
+++ b/chromium/chrome/browser/ui/webui/OWNERS
@@ -20,8 +20,6 @@ per-file ntp_tiles_internals_ui.*=file://components/ntp_tiles/OWNERS
per-file signin_internals_ui*=achuith@chromium.org
-per-file snippets_internals*=file://components/ntp_snippets/OWNERS
-
per-file sync_internals*=file://components/sync/OWNERS
per-file invalidations_message_handler.*=file://components/invalidation/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
index 60ec5a0f600..18e0b1ab487 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
+++ b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
@@ -101,8 +101,14 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
{"menuHelpCenter", IDS_BOOKMARK_MANAGER_MENU_HELP_CENTER},
{"menuImport", IDS_BOOKMARK_MANAGER_MENU_IMPORT},
{"menuOpenAllNewTab", IDS_BOOKMARK_MANAGER_MENU_OPEN_ALL},
+ {"menuOpenAllNewTabWithCount",
+ IDS_BOOKMARK_MANAGER_MENU_OPEN_ALL_WITH_COUNT},
{"menuOpenAllNewWindow", IDS_BOOKMARK_MANAGER_MENU_OPEN_ALL_NEW_WINDOW},
+ {"menuOpenAllNewWindowWithCount",
+ IDS_BOOKMARK_MANAGER_MENU_OPEN_ALL_NEW_WINDOW_WITH_COUNT},
{"menuOpenAllIncognito", IDS_BOOKMARK_MANAGER_MENU_OPEN_ALL_INCOGNITO},
+ {"menuOpenAllIncognitoWithCount",
+ IDS_BOOKMARK_MANAGER_MENU_OPEN_ALL_INCOGNITO_WITH_COUNT},
{"menuOpenNewTab", IDS_BOOKMARK_MANAGER_MENU_OPEN_IN_NEW_TAB},
{"menuOpenNewWindow", IDS_BOOKMARK_MANAGER_MENU_OPEN_IN_NEW_WINDOW},
{"menuOpenIncognito", IDS_BOOKMARK_MANAGER_MENU_OPEN_INCOGNITO},
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 4e7648d1a13..22a5e408268 100644
--- a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler.cc
@@ -14,7 +14,6 @@
#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.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"
@@ -165,7 +164,12 @@ CertificateProvisioningUiHandler::CertificateProvisioningUiHandler(
: scheduler_for_user_(scheduler_for_user),
scheduler_for_device_(ShouldUseDeviceWideProcesses(user_profile)
? scheduler_for_device
- : nullptr) {}
+ : nullptr) {
+ if (scheduler_for_user_)
+ observed_schedulers_.Add(scheduler_for_user_);
+ if (scheduler_for_device_)
+ observed_schedulers_.Add(scheduler_for_device_);
+}
CertificateProvisioningUiHandler::~CertificateProvisioningUiHandler() = default;
@@ -185,6 +189,34 @@ void CertificateProvisioningUiHandler::RegisterMessages() {
base::Unretained(this)));
}
+void CertificateProvisioningUiHandler::OnVisibleStateChanged() {
+ // If Javascript is not allowed yet, we don't need to cache the update,
+ // because the UI will request a refresh during its first message to the
+ // handler.
+ if (!IsJavascriptAllowed())
+ return;
+ if (hold_back_updates_timer_.IsRunning()) {
+ update_after_hold_back_ = true;
+ return;
+ }
+ constexpr base::TimeDelta kTimeToHoldBackUpdates =
+ base::TimeDelta::FromMilliseconds(300);
+ hold_back_updates_timer_.Start(
+ FROM_HERE, kTimeToHoldBackUpdates,
+ base::BindOnce(
+ &CertificateProvisioningUiHandler::OnHoldBackUpdatesTimerExpired,
+ weak_ptr_factory_.GetWeakPtr()));
+
+ RefreshCertificateProvisioningProcesses();
+}
+
+unsigned int
+CertificateProvisioningUiHandler::ReadAndResetUiRefreshCountForTesting() {
+ unsigned int value = ui_refresh_count_for_testing_;
+ ui_refresh_count_for_testing_ = 0;
+ return value;
+}
+
void CertificateProvisioningUiHandler::
HandleRefreshCertificateProvisioningProcesses(const base::ListValue* args) {
CHECK_EQ(0U, args->GetSize());
@@ -214,21 +246,6 @@ void CertificateProvisioningUiHandler::
return;
scheduler->UpdateOneCert(cert_profile_id.GetString());
-
- // Send an update to the UI immediately to reflect a possible status change.
- RefreshCertificateProvisioningProcesses();
-
- // Trigger a refresh in a few seconds, in case the state has triggered a
- // refresh with the server.
- // TODO(https://crbug.com/1045895): Use a real observer instead.
- constexpr base::TimeDelta kTimeToWaitBeforeRefresh =
- base::TimeDelta::FromSeconds(10);
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE,
- base::BindOnce(&CertificateProvisioningUiHandler::
- RefreshCertificateProvisioningProcesses,
- weak_ptr_factory_.GetWeakPtr()),
- kTimeToWaitBeforeRefresh);
}
void CertificateProvisioningUiHandler::
@@ -244,10 +261,18 @@ void CertificateProvisioningUiHandler::
/*is_device_wide=*/true);
}
+ ++ui_refresh_count_for_testing_;
FireWebUIListener("certificate-provisioning-processes-changed",
std::move(all_processes));
}
+void CertificateProvisioningUiHandler::OnHoldBackUpdatesTimerExpired() {
+ if (update_after_hold_back_) {
+ update_after_hold_back_ = false;
+ RefreshCertificateProvisioningProcesses();
+ }
+}
+
// static
bool CertificateProvisioningUiHandler::ShouldUseDeviceWideProcesses(
Profile* user_profile) {
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 b8e0abaa377..8732b3481e1 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,10 @@
#include <utility>
#include "base/memory/weak_ptr.h"
+#include "base/scoped_observer.h"
+#include "base/timer/timer.h"
#include "base/values.h"
+#include "chrome/browser/chromeos/cert_provisioning/cert_provisioning_scheduler.h"
#include "content/public/browser/web_ui_message_handler.h"
class Profile;
@@ -16,9 +19,9 @@ class Profile;
namespace chromeos {
namespace cert_provisioning {
-class CertProvisioningScheduler;
-
-class CertificateProvisioningUiHandler : public content::WebUIMessageHandler {
+class CertificateProvisioningUiHandler
+ : public content::WebUIMessageHandler,
+ public CertProvisioningSchedulerObserver {
public:
// Creates a CertificateProvisioningUiHandler for |user_profile|, which uses:
// (*) The CertProvisioningScheduler associated with |user_profile|, if any.
@@ -51,6 +54,13 @@ class CertificateProvisioningUiHandler : public content::WebUIMessageHandler {
// content::WebUIMessageHandler.
void RegisterMessages() override;
+ // CertProvisioningSchedulerObserver:
+ void OnVisibleStateChanged() override;
+
+ // For testing: Reads the count of UI refreshes sent to the WebUI (since
+ // instantiation or the last call to this function) and resets it to 0.
+ unsigned int ReadAndResetUiRefreshCountForTesting();
+
private:
// Send the list of certificate provisioning processes to the UI, triggered by
// the UI when it loads.
@@ -70,6 +80,9 @@ class CertificateProvisioningUiHandler : public content::WebUIMessageHandler {
// Send the list of certificate provisioning processes to the UI.
void RefreshCertificateProvisioningProcesses();
+ // Called when the |hold_back_updates_timer_| expires.
+ void OnHoldBackUpdatesTimerExpired();
+
// Returns true if device-wide certificate provisioning processes should be
// displayed, i.e. if the |user_profile| is affiliated.
static bool ShouldUseDeviceWideProcesses(Profile* user_profile);
@@ -82,6 +95,23 @@ class CertificateProvisioningUiHandler : public content::WebUIMessageHandler {
// Unowned.
CertProvisioningScheduler* const scheduler_for_device_;
+ // When this timer is running, updates provided by the schedulers should not
+ // be forwarded to the UI until it fires. Used to prevent spamming the UI if
+ // many events come in in rapid succession.
+ base::OneShotTimer hold_back_updates_timer_;
+
+ // When this is true, an update should be sent to the UI when
+ // |hold_back_updates_timer_| fires.
+ bool update_after_hold_back_ = false;
+
+ // Keeps track of the count of UI refreshes sent to the WebUI.
+ unsigned int ui_refresh_count_for_testing_ = 0;
+
+ // Keeps track of the CertProvisioningSchedulers that this UI handler
+ // observes.
+ ScopedObserver<CertProvisioningScheduler, CertProvisioningSchedulerObserver>
+ observed_schedulers_{this};
+
base::WeakPtrFactory<CertificateProvisioningUiHandler> weak_ptr_factory_{
this};
};
diff --git a/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/certificate_provisioning_ui_handler_unittest.cc
index 05862353c15..abf57ab87ae 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
@@ -36,6 +36,8 @@ namespace {
using ::testing::Return;
using ::testing::ReturnPointee;
using ::testing::ReturnRef;
+using ::testing::SaveArg;
+using ::testing::StrictMock;
using ::testing::UnorderedElementsAre;
// Extracted from a X.509 certificate using the command:
@@ -137,20 +139,28 @@ class CertificateProvisioningUiHandlerTestBase : public ::testing::Test {
profile_helper_for_testing_.GetProfile()));
web_ui_.set_web_contents(web_contents_.get());
- auto handler = std::make_unique<CertificateProvisioningUiHandler>(
- GetProfile(), &scheduler_for_user_, &scheduler_for_device_);
- handler_ = handler.get();
- web_ui_.AddMessageHandler(std::move(handler));
-
EXPECT_CALL(scheduler_for_user_, GetWorkers)
.WillRepeatedly(ReturnRef(user_workers_));
EXPECT_CALL(scheduler_for_user_, GetFailedCertProfileIds)
.WillRepeatedly(ReturnRef(user_failed_workers_));
+ EXPECT_CALL(scheduler_for_user_, AddObserver(_))
+ .WillOnce(SaveArg<0>(&scheduler_observer_for_user_));
+ EXPECT_CALL(scheduler_for_user_, RemoveObserver(_)).Times(1);
+
+ if (user_is_affiliated) {
+ EXPECT_CALL(scheduler_for_device_, GetWorkers)
+ .WillRepeatedly(ReturnRef(device_workers_));
+ EXPECT_CALL(scheduler_for_device_, GetFailedCertProfileIds)
+ .WillRepeatedly(ReturnRef(device_failed_workers_));
+ EXPECT_CALL(scheduler_for_device_, AddObserver(_))
+ .WillOnce(SaveArg<0>(&scheduler_observer_for_device_));
+ EXPECT_CALL(scheduler_for_device_, RemoveObserver(_)).Times(1);
+ }
- EXPECT_CALL(scheduler_for_device_, GetWorkers)
- .WillRepeatedly(ReturnRef(device_workers_));
- EXPECT_CALL(scheduler_for_device_, GetFailedCertProfileIds)
- .WillRepeatedly(ReturnRef(device_failed_workers_));
+ auto handler = std::make_unique<CertificateProvisioningUiHandler>(
+ GetProfile(), &scheduler_for_user_, &scheduler_for_device_);
+ handler_ = handler.get();
+ web_ui_.AddMessageHandler(std::move(handler));
}
~CertificateProvisioningUiHandlerTestBase() override {}
@@ -166,20 +176,14 @@ class CertificateProvisioningUiHandlerTestBase : public ::testing::Test {
crypto::EnsureNSSInit();
}
- void RefreshCertProvisioningProcesses(
+ // Use in ASSERT_NO_FATAL_FAILURE.
+ void ExtractCertProvisioningProcesses(
+ std::vector<base::Value>& args,
base::Value* out_all_processes,
std::vector<std::string>* out_profile_ids) {
- content::TestWebUIListenerObserver result_waiter(
- &web_ui_, "certificate-provisioning-processes-changed");
-
- base::ListValue args;
- web_ui_.HandleReceivedMessage("refreshCertificateProvisioningProcessses",
- &args);
-
- result_waiter.Wait();
- ASSERT_EQ(1U, result_waiter.args().size());
- ASSERT_TRUE(result_waiter.args()[0].is_list());
- *out_all_processes = std::move(result_waiter.args()[0]);
+ ASSERT_EQ(1U, args.size());
+ ASSERT_TRUE(args[0].is_list());
+ *out_all_processes = std::move(args[0]);
// Extract all profile ids for easier verification.
if (!out_profile_ids)
@@ -192,21 +196,40 @@ class CertificateProvisioningUiHandlerTestBase : public ::testing::Test {
}
}
+ // Use in ASSERT_NO_FATAL_FAILURE.
+ void RefreshCertProvisioningProcesses(
+ base::Value* out_all_processes,
+ std::vector<std::string>* out_profile_ids) {
+ content::TestWebUIListenerObserver result_waiter(
+ &web_ui_, "certificate-provisioning-processes-changed");
+
+ base::ListValue args;
+ web_ui_.HandleReceivedMessage("refreshCertificateProvisioningProcessses",
+ &args);
+
+ result_waiter.Wait();
+ ASSERT_NO_FATAL_FAILURE(ExtractCertProvisioningProcesses(
+ result_waiter.args(), out_all_processes, out_profile_ids));
+ }
+
protected:
Profile* GetProfile() { return profile_helper_for_testing_.GetProfile(); }
std::string der_encoded_spki_;
- content::BrowserTaskEnvironment task_environment_;
+ content::BrowserTaskEnvironment task_environment_{
+ base::test::TaskEnvironment::TimeSource::MOCK_TIME};
ProfileHelperForTesting profile_helper_for_testing_;
WorkerMap user_workers_;
base::flat_map<CertProfileId, FailedWorkerInfo> user_failed_workers_;
- MockCertProvisioningScheduler scheduler_for_user_;
+ StrictMock<MockCertProvisioningScheduler> scheduler_for_user_;
+ CertProvisioningSchedulerObserver* scheduler_observer_for_user_ = nullptr;
WorkerMap device_workers_;
base::flat_map<CertProfileId, FailedWorkerInfo> device_failed_workers_;
- MockCertProvisioningScheduler scheduler_for_device_;
+ StrictMock<MockCertProvisioningScheduler> scheduler_for_device_;
+ CertProvisioningSchedulerObserver* scheduler_observer_for_device_ = nullptr;
content::TestWebUI web_ui_;
std::unique_ptr<content::WebContents> web_contents_;
@@ -266,14 +289,14 @@ TEST_F(CertificateProvisioningUiHandlerTest, HasProcesses) {
R"({
"certProfileId": "user_cert_profile_1",
"isDeviceWide": false,
- "publicKey": "$1",
+ "publicKey": "$0",
"stateId": 1,
- "status": "$0",
+ "status": "$1",
"timeSinceLastUpdate": ""
})",
- {l10n_util::GetStringUTF8(
- IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING),
- kFormattedPublicKey}));
+ {kFormattedPublicKey,
+ l10n_util::GetStringUTF8(
+ IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING)}));
}
TEST_F(CertificateProvisioningUiHandlerAffiliatedTest, HasProcessesAffiliated) {
@@ -304,28 +327,93 @@ TEST_F(CertificateProvisioningUiHandlerAffiliatedTest, HasProcessesAffiliated) {
R"({
"certProfileId": "user_cert_profile_1",
"isDeviceWide": false,
- "publicKey": "$1",
+ "publicKey": "$0",
"stateId": 1,
- "status": "$0",
+ "status": "$1",
"timeSinceLastUpdate": ""
})",
- {l10n_util::GetStringUTF8(
- IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING),
- kFormattedPublicKey}));
+ {kFormattedPublicKey,
+ l10n_util::GetStringUTF8(
+ IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING)}));
EXPECT_EQ(
GetByProfileId(all_processes, "device_cert_profile_1"),
FormatJsonDict(
R"({
"certProfileId": "device_cert_profile_1",
"isDeviceWide": true,
- "publicKey": "$1",
+ "publicKey": "$0",
"stateId": 10,
- "status": "$0",
+ "status": "$1",
+ "timeSinceLastUpdate": ""
+ })",
+ {kFormattedPublicKey,
+ l10n_util::GetStringUTF8(
+ IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_FAILURE)}));
+}
+
+TEST_F(CertificateProvisioningUiHandlerTest, Updates) {
+ base::Value all_processes;
+ std::vector<std::string> profile_ids;
+
+ // Perform an initial JS-side initiated refresh so that javascript is
+ // considered allowed by the UI handler.
+ ASSERT_NO_FATAL_FAILURE(
+ RefreshCertProvisioningProcesses(&all_processes, &profile_ids));
+ ASSERT_THAT(profile_ids, UnorderedElementsAre());
+ EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
+
+ 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);
+
+ // The user worker triggers an update
+ content::TestWebUIListenerObserver result_waiter_1(
+ &web_ui_, "certificate-provisioning-processes-changed");
+
+ scheduler_observer_for_user_->OnVisibleStateChanged();
+
+ EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
+ result_waiter_1.Wait();
+ ASSERT_NO_FATAL_FAILURE(ExtractCertProvisioningProcesses(
+ result_waiter_1.args(), &all_processes, &profile_ids));
+
+ // Only the user worker is expected to be displayed in the UI, because the
+ // user is not affiliated.
+ ASSERT_THAT(profile_ids, UnorderedElementsAre("user_cert_profile_1"));
+
+ EXPECT_EQ(
+ GetByProfileId(all_processes, "user_cert_profile_1"),
+ FormatJsonDict(
+ R"({
+ "certProfileId": "user_cert_profile_1",
+ "isDeviceWide": false,
+ "publicKey": "$0",
+ "stateId": 1,
+ "status": "$1",
"timeSinceLastUpdate": ""
})",
- {l10n_util::GetStringUTF8(
- IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_FAILURE),
- kFormattedPublicKey}));
+ {kFormattedPublicKey,
+ l10n_util::GetStringUTF8(
+ IDS_SETTINGS_CERTIFICATE_MANAGER_PROVISIONING_STATUS_PREPARING_CSR_WAITING)}));
+
+ content::TestWebUIListenerObserver result_waiter_2(
+ &web_ui_, "certificate-provisioning-processes-changed");
+ scheduler_observer_for_user_->OnVisibleStateChanged();
+ // Another update does not trigger a UI update for the holdoff time.
+ task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(299));
+ EXPECT_EQ(0U, handler_->ReadAndResetUiRefreshCountForTesting());
+
+ // When the holdoff time has elapsed, an UI update is triggered.
+ task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(2));
+ EXPECT_EQ(1U, handler_->ReadAndResetUiRefreshCountForTesting());
+ result_waiter_2.Wait();
+
+ base::Value all_processes_2;
+ ASSERT_NO_FATAL_FAILURE(ExtractCertProvisioningProcesses(
+ result_waiter_2.args(), &all_processes_2, /*profile_ids=*/nullptr));
+ EXPECT_EQ(all_processes, all_processes_2);
}
} // namespace
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 51882065eb3..e42e6dd995e 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
@@ -4,7 +4,6 @@
#include "base/macros.h"
#include "base/strings/string_piece.h"
-#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -17,7 +16,6 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
-#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
@@ -140,13 +138,11 @@ IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, LargeResourceScale) {
EXPECT_NE(net::OK, observer.net_error());
}
-class ChromeURLDataManagerTestWithWebUIReportOnlyTrustedTypesEnabled
+class ChromeURLDataManagerWebUITrustedTypesTest
: public InProcessBrowserTest,
public testing::WithParamInterface<const char*> {
public:
- ChromeURLDataManagerTestWithWebUIReportOnlyTrustedTypesEnabled() {
- feature_list_.InitAndEnableFeature(features::kWebUIReportOnlyTrustedTypes);
- }
+ ChromeURLDataManagerWebUITrustedTypesTest() = default;
void CheckTrustedTypesViolation(base::StringPiece url) {
std::string message_filter1 = "*This document requires*assignment*";
@@ -164,15 +160,11 @@ class ChromeURLDataManagerTestWithWebUIReportOnlyTrustedTypesEnabled
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(
- ChromeURLDataManagerTestWithWebUIReportOnlyTrustedTypesEnabled,
- NoTrustedTypesViolation) {
+IN_PROC_BROWSER_TEST_P(ChromeURLDataManagerWebUITrustedTypesTest,
+ NoTrustedTypesViolation) {
CheckTrustedTypesViolation(GetParam());
}
@@ -216,6 +208,7 @@ static constexpr const char* const kChromeUrls[] = {
"chrome://identity-internals",
"chrome://indexeddb-internals",
"chrome://inspect",
+ "chrome://internals/web-app",
"chrome://interstitials/ssl",
"chrome://interventions-internals",
"chrome://invalidations",
@@ -279,6 +272,8 @@ static constexpr const char* const kChromeUrls[] = {
"chrome://welcome",
#if defined(OS_ANDROID)
"chrome://explore-sites-internals",
+ "chrome://internals/notifications",
+ "chrome://internals/query-tiles",
"chrome://offline-internals",
"chrome://webapks",
#endif
@@ -325,7 +320,6 @@ static constexpr const char* const kChromeUrls[] = {
#endif
};
-INSTANTIATE_TEST_SUITE_P(
- ,
- ChromeURLDataManagerTestWithWebUIReportOnlyTrustedTypesEnabled,
- ::testing::ValuesIn(kChromeUrls));
+INSTANTIATE_TEST_SUITE_P(,
+ ChromeURLDataManagerWebUITrustedTypesTest,
+ ::testing::ValuesIn(kChromeUrls));
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 aa93a9ddd7f..c9abbd97037 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
@@ -17,12 +17,14 @@
#include "chrome/browser/accessibility/accessibility_ui.h"
#include "chrome/browser/browser_features.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"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/search/ntp_features.h"
#include "chrome/browser/search/suggestions/suggestions_ui.h"
#include "chrome/browser/ui/webui/about_ui.h"
#include "chrome/browser/ui/webui/autofill_and_password_manager_internals/autofill_internals_ui.h"
@@ -32,7 +34,9 @@
#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"
@@ -54,7 +58,6 @@
#include "chrome/browser/ui/webui/media/media_history_ui.h"
#include "chrome/browser/ui/webui/media/webrtc_logs_ui.h"
#include "chrome/browser/ui/webui/memory_internals_ui.h"
-#include "chrome/browser/ui/webui/nearby_internals/nearby_internals_ui.h"
#include "chrome/browser/ui/webui/net_export_ui.h"
#include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
#include "chrome/browser/ui/webui/ntp_tiles_internals_ui.h"
@@ -118,13 +121,10 @@
#if defined(OS_ANDROID)
#include "chrome/browser/ui/webui/explore_sites_internals/explore_sites_internals_ui.h"
#include "chrome/browser/ui/webui/offline/offline_internals_ui.h"
-#include "chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h"
#include "chrome/browser/ui/webui/webapks_ui.h"
#include "components/feed/buildflags.h"
#include "components/feed/feed_feature_list.h"
-#if BUILDFLAG(ENABLE_FEED_IN_CHROME)
#include "chrome/browser/ui/webui/feed_internals/feed_internals_ui.h"
-#endif // BUILDFLAG(ENABLE_FEED_IN_CHROME)
#else // defined(OS_ANDROID)
#include "chrome/browser/media/feeds/media_feeds_service.h"
#include "chrome/browser/media/kaleidoscope/constants.h"
@@ -138,7 +138,6 @@
#include "chrome/browser/ui/webui/inspect_ui.h"
#include "chrome/browser/ui/webui/management_ui.h"
#include "chrome/browser/ui/webui/media_router/media_router_internals_ui.h"
-#include "chrome/browser/ui/webui/nearby_share/nearby_share_dialog_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"
@@ -160,6 +159,8 @@
#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_service_factory.h"
#include "chrome/browser/chromeos/printing/print_management/printing_manager.h"
#include "chrome/browser/chromeos/printing/print_management/printing_manager_factory.h"
+#include "chrome/browser/chromeos/scanning/scan_service.h"
+#include "chrome/browser/chromeos/scanning/scan_service_factory.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"
@@ -175,7 +176,6 @@
#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/file_manager/file_manager_ui.h"
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_ui.h"
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
@@ -191,9 +191,13 @@
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.h"
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.h"
#include "chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_ui.h"
+#include "chrome/browser/ui/webui/nearby_internals/nearby_internals_ui.h"
+#include "chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h"
#include "chromeos/components/camera_app_ui/camera_app_ui.h"
#include "chromeos/components/camera_app_ui/url_constants.h"
+#include "chromeos/components/diagnostics_ui/diagnostics_ui.h"
+#include "chromeos/components/diagnostics_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"
@@ -214,6 +218,8 @@
#if defined(OS_CHROMEOS) && !defined(OFFICIAL_BUILD)
#include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_ui.h"
+#include "chromeos/components/file_manager/file_manager_ui.h"
+#include "chromeos/components/file_manager/url_constants.h"
#include "chromeos/components/sample_system_web_app_ui/sample_system_web_app_ui.h"
#include "chromeos/components/sample_system_web_app_ui/url_constants.h"
#include "chromeos/components/telemetry_extension_ui/telemetry_extension_ui.h"
@@ -361,6 +367,24 @@ NewWebUI<chromeos::printing::printing_manager::PrintManagementUI>(
base::BindRepeating(&BindPrintManagement, Profile::FromWebUI(web_ui)));
}
+void BindScanService(
+ Profile* profile,
+ mojo::PendingReceiver<chromeos::scanning::mojom::ScanService>
+ pending_receiver) {
+ chromeos::ScanService* service =
+ chromeos::ScanServiceFactory::GetForBrowserContext(profile);
+ if (service)
+ service->BindInterface(std::move(pending_receiver));
+}
+
+template <>
+WebUIController* NewWebUI<chromeos::ScanningUI>(WebUI* web_ui,
+ const GURL& url) {
+ return new chromeos::ScanningUI(
+ web_ui,
+ base::BindRepeating(&BindScanService, Profile::FromWebUI(web_ui)));
+}
+
void BindMultiDeviceSetup(
Profile* profile,
mojo::PendingReceiver<chromeos::multidevice_setup::mojom::MultiDeviceSetup>
@@ -534,20 +558,14 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
// Bookmarks are part of NTP on Android.
if (url.host_piece() == chrome::kChromeUIBookmarksHost)
return &NewWebUI<BookmarksUI>;
+ if (url.host_piece() == chrome::kChromeUICommanderHost)
+ return &NewWebUI<CommanderUI>;
// Downloads list on Android uses the built-in download manager.
if (url.host_piece() == chrome::kChromeUIDownloadsHost)
return &NewWebUI<DownloadsUI>;
// Identity API is not available on Android.
if (url.host_piece() == chrome::kChromeUIIdentityInternalsHost)
return &NewWebUI<IdentityInternalsUI>;
- if (base::FeatureList::IsEnabled(features::kNearbySharing)) {
- if (url.host_piece() == chrome::kChromeUINearbyInternalsHost)
- return &NewWebUI<NearbyInternalsUI>;
- if (url.host_piece() == chrome::kChromeUINearbyShareHost &&
- profile->IsRegularProfile()) {
- return &NewWebUI<nearby_share::NearbyShareDialogUI>;
- }
- }
if (url.host_piece() == chrome::kChromeUINewTabHost)
return &NewWebUI<NewTabUI>;
if (url.host_piece() == chrome::kChromeUINewTabPageHost)
@@ -584,14 +602,14 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
#if defined(OS_CHROMEOS)
if (url.host_piece() == chrome::kChromeUIPasswordChangeHost) {
if (!profile->GetPrefs()->GetBoolean(
- prefs::kSamlInSessionPasswordChangeEnabled)) {
+ chromeos::prefs::kSamlInSessionPasswordChangeEnabled)) {
return nullptr;
}
return &NewWebUI<chromeos::PasswordChangeUI>;
}
if (url.host_piece() == chrome::kChromeUIConfirmPasswordChangeHost) {
if (!profile->GetPrefs()->GetBoolean(
- prefs::kSamlInSessionPasswordChangeEnabled)) {
+ chromeos::prefs::kSamlInSessionPasswordChangeEnabled)) {
return nullptr;
}
return &NewWebUI<chromeos::ConfirmPasswordChangeUI>;
@@ -599,11 +617,18 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() ==
chrome::kChromeUIUrgentPasswordExpiryNotificationHost) {
if (!profile->GetPrefs()->GetBoolean(
- prefs::kSamlInSessionPasswordChangeEnabled)) {
+ chromeos::prefs::kSamlInSessionPasswordChangeEnabled)) {
return nullptr;
}
return &NewWebUI<chromeos::UrgentPasswordExpiryNotificationUI>;
}
+ if (url.host_piece() == chrome::kChromeUILockScreenStartReauthHost) {
+ if (!profile->GetPrefs()->GetBoolean(
+ chromeos::prefs::kSamlLockScreenReauthenticationEnabled)) {
+ return nullptr;
+ }
+ return &NewWebUI<chromeos::LockScreenStartReauthUI>;
+ }
if (url.host_piece() == chrome::kChromeUIAccountManagerErrorHost)
return &NewWebUI<chromeos::AccountManagerErrorUI>;
if (url.host_piece() == chrome::kChromeUIAccountManagerWelcomeHost)
@@ -629,9 +654,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::CryptohomeUI>;
if (url.host_piece() == chrome::kChromeUIDriveInternalsHost)
return &NewWebUI<chromeos::DriveInternalsUI>;
- if (base::FeatureList::IsEnabled(chromeos::features::kFilesSWA) &&
- url.host_piece() == chrome::kChromeUIFileManagerHost)
- return &NewWebUI<chromeos::file_manager::FileManagerUI>;
if (url.host_piece() == chrome::kChromeUIFirstRunHost)
return &NewWebUI<chromeos::FirstRunUI>;
if (url.host_piece() == chromeos::kChromeUIHelpAppHost)
@@ -652,6 +674,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::settings::OSSettingsUI>;
if (url.host_piece() == chrome::kChromeUIPowerHost)
return &NewWebUI<chromeos::PowerUI>;
+ if (base::FeatureList::IsEnabled(chromeos::features::kDiagnosticsApp) &&
+ url.host_piece() == chromeos::kChromeUIDiagnosticsAppHost) {
+ return &NewWebUI<chromeos::DiagnosticsUI>;
+ }
if (base::FeatureList::IsEnabled(
chromeos::features::kPrintJobManagementApp) &&
url.host_piece() == chromeos::kChromeUIPrintManagementHost)
@@ -672,6 +698,12 @@ 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 (url.host_piece() == chrome::kChromeUISetTimeHost)
return &NewWebUI<chromeos::SetTimeUI>;
if (url.host_piece() == chrome::kChromeUISlowHost)
@@ -691,7 +723,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
web_app::SystemAppType::CAMERA)) {
return &NewWebUI<chromeos::CameraAppUI>;
}
-
+ if (base::FeatureList::IsEnabled(features::kNearbySharing)) {
+ if (url.host_piece() == chrome::kChromeUINearbyInternalsHost)
+ return &NewWebUI<NearbyInternalsUI>;
+ }
if (url.host_piece() == chrome::kChromeUIArcGraphicsTracingHost)
return &NewWebUI<chromeos::ArcGraphicsTracingUI<
chromeos::ArcGraphicsTracingMode::kFull>>;
@@ -706,6 +741,8 @@ 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::kChromeUISampleSystemWebAppHost)
return &NewWebUI<chromeos::SampleSystemWebAppUI>;
if (url.host_piece() == chromeos::kChromeUITelemetryExtensionHost) {
@@ -723,15 +760,11 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<OfflineInternalsUI>;
if (url.host_piece() == chrome::kChromeUISnippetsInternalsHost &&
!profile->IsOffTheRecord()) {
- if (!base::FeatureList::IsEnabled(feed::kInterestFeedContentSuggestions)) {
- return &NewWebUI<SnippetsInternalsUI>;
- } else {
-#if BUILDFLAG(ENABLE_FEED_IN_CHROME)
- return &NewWebUI<FeedInternalsUI>;
+#if BUILDFLAG(ENABLE_FEED_V1) || BUILDFLAG(ENABLE_FEED_V2)
+ return &NewWebUI<FeedInternalsUI>;
#else
- return nullptr;
-#endif // BUILDFLAG(ENABLE_FEED_IN_CHROME)
- }
+ return nullptr;
+#endif // BUILDFLAG(ENABLE_FEED_V1) || BUILDFLAG(ENABLE_FEED_V2)
}
if (url.host_piece() == chrome::kChromeUIWebApksHost)
return &NewWebUI<WebApksUI>;
@@ -1018,7 +1051,8 @@ bool ChromeWebUIControllerFactory::IsWebUIAllowedToMakeNetworkRequests(
// https://crbug.com/859345
origin.host() == chrome::kChromeUIDownloadsHost ||
// TODO(crbug.com/1076506): remove when change to iframed OneGoogleBar.
- origin.host() == chrome::kChromeUINewTabPageHost;
+ (origin.host() == chrome::kChromeUINewTabPageHost &&
+ !base::FeatureList::IsEnabled(ntp_features::kIframeOneGoogleBar));
}
ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() = default;
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 1023da7f2bd..30a12dfc8f4 100644
--- a/chromium/chrome/browser/ui/webui/chrome_webui_navigation_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chrome_webui_navigation_browsertest.cc
@@ -8,8 +8,6 @@
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "content/browser/frame_host/render_frame_host_impl.h"
-#include "content/common/frame.mojom.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
@@ -20,19 +18,6 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/url_constants.h"
-namespace {
-
-content::mojom::OpenURLParamsPtr CreateOpenURLParams(const GURL& url) {
- auto params = content::mojom::OpenURLParams::New();
- params->url = url;
- params->disposition = WindowOpenDisposition::CURRENT_TAB;
- params->should_replace_current_entry = false;
- params->user_gesture = true;
- return params;
-}
-
-} // namespace
-
// Tests embedder specific behavior of WebUIs.
class ChromeWebUINavigationBrowserTest : public InProcessBrowserTest {
public:
@@ -76,9 +61,8 @@ IN_PROC_BROWSER_TEST_F(ChromeWebUINavigationBrowserTest,
EXPECT_EQ("about:blank", child->GetLastCommittedURL());
content::TestNavigationObserver observer(web_contents);
- static_cast<content::RenderFrameHostImpl*>(child)->OpenURL(
- CreateOpenURLParams(
- content::GetWebUIURL("web-ui/title1.html?noxfo=true")));
+ content::PwnMessageHelper::OpenURL(
+ child, content::GetWebUIURL("web-ui/title1.html?noxfo=true"));
observer.Wait();
// Retrieve the RenderFrameHost again since it might have been swapped.
@@ -115,9 +99,8 @@ IN_PROC_BROWSER_TEST_F(
content::AddUntrustedDataSource(browser()->profile(), "test-iframe-host",
csp);
- static_cast<content::RenderFrameHostImpl*>(child)->OpenURL(
- CreateOpenURLParams(
- content::GetChromeUntrustedUIURL("test-iframe-host/title1.html")));
+ content::PwnMessageHelper::OpenURL(
+ child, content::GetChromeUntrustedUIURL("test-iframe-host/title1.html"));
observer.Wait();
// Retrieve the RenderFrameHost again since it might have been swapped.
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
index 23b88fbdb7c..04f89448390 100644
--- 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
@@ -32,37 +32,6 @@ constexpr int kDialogWidthPx = 650;
CellularSetupDialog* dialog_instance = nullptr;
-// Used to attach an instance of the CellularSetup service to a BrowserContext.
-class CellularSetupServiceHolder : public base::SupportsUserData::Data {
- public:
- CellularSetupServiceHolder() = default;
- ~CellularSetupServiceHolder() override = default;
-
- void BindReceiver(mojo::PendingReceiver<mojom::CellularSetup> receiver) {
- service_.BindReceiver(std::move(receiver));
- }
-
- private:
- CellularSetupImpl service_;
-
- DISALLOW_COPY_AND_ASSIGN(CellularSetupServiceHolder);
-};
-
-const char kCellularSetupServiceHolderKey[] = "cellular_setup_service_holder";
-
-CellularSetupServiceHolder* GetOrCreateServiceHolder(
- content::BrowserContext* browser_context) {
- auto* holder = static_cast<CellularSetupServiceHolder*>(
- browser_context->GetUserData(kCellularSetupServiceHolderKey));
- if (!holder) {
- auto new_holder = std::make_unique<CellularSetupServiceHolder>();
- holder = new_holder.get();
- browser_context->SetUserData(kCellularSetupServiceHolderKey,
- std::move(new_holder));
- }
- return holder;
-}
-
} // namespace
// static
@@ -84,7 +53,9 @@ void CellularSetupDialog::ShowDialog(const std::string& cellular_network_guid) {
CellularSetupDialog::CellularSetupDialog()
: SystemWebDialogDelegate(GURL(chrome::kChromeUICellularSetupUrl),
- base::string16()) {}
+ base::string16()) {
+ set_can_resize(false);
+}
CellularSetupDialog::~CellularSetupDialog() = default;
@@ -92,10 +63,6 @@ void CellularSetupDialog::GetDialogSize(gfx::Size* size) const {
size->SetSize(kDialogWidthPx, kDialogHeightPx);
}
-bool CellularSetupDialog::CanResizeDialog() const {
- return false;
-}
-
void CellularSetupDialog::OnDialogClosed(const std::string& json_retval) {
DCHECK(this == dialog_instance);
dialog_instance = nullptr;
@@ -131,8 +98,7 @@ CellularSetupDialogUI::~CellularSetupDialogUI() = default;
void CellularSetupDialogUI::BindInterface(
mojo::PendingReceiver<mojom::CellularSetup> receiver) {
- GetOrCreateServiceHolder(web_ui()->GetWebContents()->GetBrowserContext())
- ->BindReceiver(std::move(receiver));
+ CellularSetupImpl::CreateAndBindToReciever(std::move(receiver));
}
WEB_UI_CONTROLLER_TYPE_IMPL(CellularSetupDialogUI)
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
index 6b7f05ee2da..d30bec2c336 100644
--- 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
@@ -25,7 +25,6 @@ class CellularSetupDialog : public SystemWebDialogDelegate {
// ui::WebDialogDelegate
void GetDialogSize(gfx::Size* size) const override;
- bool CanResizeDialog() const override;
void OnDialogClosed(const std::string& json_retval) override;
private:
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 ed762b3237d..dbda9f704ab 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
@@ -18,9 +18,16 @@ namespace cellular_setup {
namespace {
constexpr webui::LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
+ {"activationCode", IDS_CELLULAR_SETUP_ESIM_PAGE_ACTIVATION_CODE},
{"cancel", IDS_CANCEL},
{"back", IDS_CELLULAR_SETUP_BACK_LABEL},
- {"finish", IDS_CELLULAR_SETUP_FINISH_LABEL},
+ {"done", IDS_CELLULAR_SETUP_DONE_LABEL},
+ {"eSimFlowSetup", IDS_CELLULAR_SETUP_CELLULAR_SETUP_PAGE_ESIM_LABEL},
+ {"eSimFlowSetupMessage",
+ IDS_CELLULAR_SETUP_CELLULAR_SETUP_PAGE_ESIM_MESSAGE},
+ {"establishNetworkConnectionMessage",
+ IDS_CELLULAR_SETUP_ESTABLISH_NETWORK_CONNECTION},
+ {"next", IDS_CELLULAR_SETUP_NEXT_LABEL},
{"tryAgain", IDS_CELLULAR_SETUP_TRY_AGAIN_LABEL},
{"simDetectPageTitle", IDS_CELLULAR_SETUP_SIM_DETECT_PAGE_TITLE},
{"simDetectPageErrorTitle", IDS_CELLULAR_SETUP_SIM_DETECT_PAGE_ERROR_TITLE},
@@ -34,11 +41,14 @@ constexpr webui::LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
IDS_CELLULAR_SETUP_PROVISIONING_PAGE_ERROR_TITLE},
{"provisioningPageErrorMessage",
IDS_CELLULAR_SETUP_PROVISIONING_PAGE_ERROR_MESSAGE},
+ {"pSimFlowSetup", IDS_CELLULAR_SETUP_CELLULAR_SETUP_PAGE_PSIM_LABEL},
+ {"pSimFlowSetupMessage",
+ IDS_CELLULAR_SETUP_CELLULAR_SETUP_PAGE_PSIM_MESSAGE},
{"finalPageTitle", IDS_CELLULAR_SETUP_FINAL_PAGE_TITLE},
{"finalPageMessage", IDS_CELLULAR_SETUP_FINAL_PAGE_MESSAGE},
{"finalPageErrorTitle", IDS_CELLULAR_SETUP_FINAL_PAGE_ERROR_TITLE},
- {"finalPageErrorMessage", IDS_CELLULAR_SETUP_FINAL_PAGE_ERROR_MESSAGE}};
-
+ {"finalPageErrorMessage", IDS_CELLULAR_SETUP_FINAL_PAGE_ERROR_MESSAGE},
+ {"scanQRCode", IDS_CELLULAR_SETUP_ESIM_PAGE_SCAN_QR_CODE}};
} // namespace
void AddLocalizedStrings(content::WebUIDataSource* html_source) {
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 2264f8ecfdb..c1733e81683 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
@@ -62,7 +62,9 @@ void MobileSetupDialog::ShowByNetworkId(const std::string& network_id) {
MobileSetupDialog::MobileSetupDialog(const NetworkState& network)
: SystemWebDialogDelegate(
GetURL(network),
- l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE)) {}
+ l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE)) {
+ set_can_resize(true);
+}
MobileSetupDialog::~MobileSetupDialog() {
dialog_instance = nullptr;
@@ -72,10 +74,6 @@ void MobileSetupDialog::GetDialogSize(gfx::Size* size) const {
size->SetSize(kMobileSetupDialogWidth, kMobileSetupDialogHeight);
}
-bool MobileSetupDialog::CanResizeDialog() const {
- return true;
-}
-
std::string MobileSetupDialog::GetDialogArgs() const {
return std::string();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h
index 4739b83e39e..8365de5ea97 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h
@@ -24,7 +24,6 @@ class MobileSetupDialog : public SystemWebDialogDelegate {
// ui::WebDialogDelegate
void GetDialogSize(gfx::Size* size) const override;
- bool CanResizeDialog() const override;
std::string GetDialogArgs() const override;
void OnCloseContents(content::WebContents* source,
bool* out_close_dialog) override;
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 c5c2c9bef95..9a46512691f 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
@@ -49,7 +49,6 @@ void AddStringResources(content::WebUIDataSource* source) {
{"errorTitle", IDS_CROSTINI_INSTALLER_ERROR_TITLE},
{"loadTerminaError", IDS_CROSTINI_INSTALLER_LOAD_TERMINA_ERROR},
- {"startConciergeError", IDS_CROSTINI_INSTALLER_START_CONCIERGE_ERROR},
{"createDiskImageError", IDS_CROSTINI_INSTALLER_CREATE_DISK_IMAGE_ERROR},
{"startTerminaVmError", IDS_CROSTINI_INSTALLER_START_TERMINA_VM_ERROR},
{"startContainerError", IDS_CROSTINI_INSTALLER_START_CONTAINER_ERROR},
@@ -61,7 +60,6 @@ void AddStringResources(content::WebUIDataSource* source) {
{"unknownError", IDS_CROSTINI_INSTALLER_UNKNOWN_ERROR},
{"loadTerminaMessage", IDS_CROSTINI_INSTALLER_LOAD_TERMINA_MESSAGE},
- {"startConciergeMessage", IDS_CROSTINI_INSTALLER_START_CONCIERGE_MESSAGE},
{"createDiskImageMessage",
IDS_CROSTINI_INSTALLER_CREATE_DISK_IMAGE_MESSAGE},
{"startTerminaVmMessage",
diff --git a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc
index 17062eab6d3..3ce24bcec8c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_dialog.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/webui/chromeos/crostini_upgrader/crostini_upgrader_ui.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
@@ -63,6 +64,8 @@ CrostiniUpgraderDialog::CrostiniUpgraderDialog(
DCHECK(profile_);
crostini::CrostiniManager::GetForProfile(profile_)->SetCrostiniDialogStatus(
crostini::DialogType::UPGRADER, true);
+ set_can_minimize(true);
+ set_can_resize(false);
}
CrostiniUpgraderDialog::~CrostiniUpgraderDialog() {
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 0df942b9520..f6560a693ec 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
@@ -43,7 +43,7 @@ class CrostiniUpgraderDialogBrowserTest : public CrostiniDialogBrowserTest {
chromeos::CrostiniUpgraderDialog* GetCrostiniUpgraderDialog() {
auto url = GURL{chrome::kChromeUICrostiniUpgraderUrl};
- return reinterpret_cast<chromeos::CrostiniUpgraderDialog*>(
+ return static_cast<chromeos::CrostiniUpgraderDialog*>(
chromeos::SystemWebDialogDelegate::FindInstance(url.spec()));
}
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 6a9d0c38941..46ac48bf29f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/values.h"
#include "chromeos/dbus/cryptohome/cryptohome_client.h"
+#include "chromeos/dbus/cryptohome/rpc.pb.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
@@ -39,6 +40,11 @@ void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) {
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()),
base::BindOnce(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread,
@@ -59,6 +65,21 @@ 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);
+ return;
+ }
+ auto reply_proto = reply->GetExtension(cryptohome::GetTpmStatusReply::reply);
+
+ SetCryptohomeProperty("has-reset-lock-permissions",
+ base::Value(reply_proto.has_reset_lock_permissions()));
+}
+
void CryptohomeWebUIHandler::OnCryptohomeBoolProperty(
const std::string& destination_id,
base::Optional<bool> result) {
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 890066643bb..855eb2c390e 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
@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
+#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/dbus_method_call_status.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -45,6 +46,9 @@ 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);
+
// Sets textcontent of the element whose id is |destination_id| to |value|.
void SetCryptohomeProperty(const std::string& destination_id,
const base::Value& value);
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 f66a8354b4a..b4af30e5729 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
@@ -226,7 +226,7 @@ void EduAccountLoginHandler::FetchFamilyMembers() {
family_fetcher_ = std::make_unique<FamilyInfoFetcher>(
this, IdentityManagerFactory::GetForProfile(profile),
- account_manager->GetUrlLoaderFactory());
+ profile->GetURLLoaderFactory());
family_fetcher_->StartGetFamilyMembers();
}
@@ -261,7 +261,8 @@ void EduAccountLoginHandler::FetchAccessToken(
&EduAccountLoginHandler::CreateReAuthProofTokenForParent,
base::Unretained(this), std::move(obfuscated_gaia_id),
std::move(password)),
- signin::PrimaryAccountAccessTokenFetcher::Mode::kImmediate);
+ signin::PrimaryAccountAccessTokenFetcher::Mode::kImmediate,
+ signin::ConsentLevel::kNotRequired);
}
void EduAccountLoginHandler::FetchReAuthProofTokenForParent(
@@ -277,7 +278,7 @@ void EduAccountLoginHandler::FetchReAuthProofTokenForParent(
DCHECK(account_manager);
gaia_auth_fetcher_ = std::make_unique<GaiaAuthFetcher>(
- this, gaia::GaiaSource::kChrome, account_manager->GetUrlLoaderFactory());
+ this, gaia::GaiaSource::kChrome, profile->GetURLLoaderFactory());
gaia_auth_fetcher_->StartCreateReAuthProofTokenForParent(
child_oauth_access_token, parent_obfuscated_gaia_id, parent_credential);
}
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 40bff048c98..c10b83d35c3 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
@@ -645,4 +645,8 @@ void DeviceEmulatorMessageHandler::MouseExists(bool exists) {
FireWebUIListener("mouse-exists-changed", base::Value(exists));
}
+void DeviceEmulatorMessageHandler::PointingStickExists(bool exists) {
+ // TODO(crbug.com/1114828): support fake pointing sticks.
+}
+
} // namespace chromeos
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 9a59d740741..4d99b157710 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
@@ -124,6 +124,7 @@ class DeviceEmulatorMessageHandler :
// system::PointerDeviceObserver::Observer:
void TouchpadExists(bool exists) override;
void MouseExists(bool exists) override;
+ void PointingStickExists(bool exists) override;
bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_;
std::unique_ptr<BluetoothObserver> bluetooth_observer_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/file_manager/BUILD.gn b/chromium/chrome/browser/ui/webui/chromeos/file_manager/BUILD.gn
deleted file mode 100644
index db7d34aef49..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/file_manager/BUILD.gn
+++ /dev/null
@@ -1,9 +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.
-
-import("//mojo/public/tools/bindings/mojom.gni")
-
-mojom("mojo_bindings") {
- sources = [ "file_manager.mojom" ]
-}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/file_manager/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/file_manager/OWNERS
deleted file mode 100644
index 25274255588..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/file_manager/OWNERS
+++ /dev/null
@@ -1,6 +0,0 @@
-file://ui/file_manager/OWNERS
-
-per-file *.mojom=set noparent
-per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: Platform>Apps>FileManager
diff --git a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager.mojom b/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager.mojom
deleted file mode 100644
index 2d913845705..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager.mojom
+++ /dev/null
@@ -1,34 +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.
-
-module chromeos.file_manager.mojom;
-
-// Lives in the browser process. A renderer uses this to link itself with
-// a page handler.
-interface PageHandlerFactory {
- // Create a page handler for the file manager and link it to the UI.
- CreatePageHandler(pending_remote<Page> page,
- pending_receiver<PageHandler> handler);
-};
-
-// Lives in the browser process. A renderer uses this to control/query the
-// backend of the app.
-interface PageHandler {
- // Getter example.
- GetFoo() => (string foo);
- // Setter example.
- SetFoo(string foo);
- // Fire-an-forget action example.
- DoABarrelRoll();
-};
-
-// Lives in the renderer process. The browser uses this to send status
-// updates to the web page in the renderer and in rare cases to fetch
-// some info from there.
-interface Page {
- // Notification example.
- OnSomethingHappened(string something, string other);
- // Reverse getter example. Unlikely something like that will be needed.
- GetBar(string foo) => (string bar);
-};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.cc
deleted file mode 100644
index 52255d05a86..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// 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/file_manager/file_manager_ui.h"
-
-#include "base/bind.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.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"
-
-namespace chromeos {
-namespace file_manager {
-
-FileManagerPageHandler::FileManagerPageHandler(
- mojo::PendingReceiver<mojom::PageHandler> pending_receiver,
- mojo::PendingRemote<mojom::Page> pending_page)
- : receiver_{this, std::move(pending_receiver)},
- page_{std::move(pending_page)} {}
-
-FileManagerPageHandler::~FileManagerPageHandler() = default;
-
-void FileManagerPageHandler::GetFoo(GetFooCallback callback) {
- std::move(callback).Run(foo_);
-}
-
-void FileManagerPageHandler::SetFoo(const std::string& foo) {
- foo_ = foo;
-}
-
-void FileManagerPageHandler::DoABarrelRoll() {
- barrel_roll_timer_.Start(
- FROM_HERE, base::TimeDelta::FromSeconds(1),
- base::BindOnce(&FileManagerPageHandler::OnBarrelRollDone,
- base::Unretained(this)));
-}
-
-void FileManagerPageHandler::OnBarrelRollDone() {
- page_->GetBar(foo_, base::BindOnce(&FileManagerPageHandler::OnBarReceived,
- base::Unretained(this)));
-}
-
-void FileManagerPageHandler::OnBarReceived(const std::string& bar) {
- page_->OnSomethingHappened(foo_, bar);
-}
-
-} // namespace file_manager
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.h b/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.h
deleted file mode 100644
index 603c6898f0d..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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_FILE_MANAGER_FILE_MANAGER_PAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_FILE_MANAGER_FILE_MANAGER_PAGE_HANDLER_H_
-
-#include <memory>
-
-#include "base/macros.h"
-#include "base/timer/timer.h"
-#include "chrome/browser/ui/webui/chromeos/file_manager/file_manager.mojom.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "mojo/public/cpp/bindings/pending_remote.h"
-#include "mojo/public/cpp/bindings/receiver.h"
-#include "mojo/public/cpp/bindings/remote.h"
-
-namespace chromeos {
-namespace file_manager {
-
-// Class backing the page's functionality.
-class FileManagerPageHandler : public mojom::PageHandler {
- public:
- FileManagerPageHandler(
- mojo::PendingReceiver<mojom::PageHandler> pending_receiver,
- mojo::PendingRemote<mojom::Page> pending_page);
- ~FileManagerPageHandler() override;
-
- private:
- // mojom::PageHandler:
- void GetFoo(GetFooCallback callback) override;
- void SetFoo(const std::string& foo) override;
- void DoABarrelRoll() override;
-
- void OnBarrelRollDone();
- void OnBarReceived(const std::string& bar);
-
- mojo::Receiver<mojom::PageHandler> receiver_;
- mojo::Remote<mojom::Page> page_;
-
- std::string foo_;
- base::OneShotTimer barrel_roll_timer_;
-
- DISALLOW_COPY_AND_ASSIGN(FileManagerPageHandler);
-};
-
-} // namespace file_manager
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_FILE_MANAGER_FILE_MANAGER_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_ui.cc
deleted file mode 100644
index 88d3cb9fab5..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_ui.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// 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/file_manager/file_manager_ui.h"
-
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/chromeos/file_manager/file_manager_page_handler.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"
-
-namespace chromeos {
-namespace file_manager {
-
-FileManagerUI::FileManagerUI(content::WebUI* web_ui)
- : MojoWebUIController(web_ui) {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIFileManagerHost);
- source->AddResourcePath("file_manager.css", IDR_FILE_MANAGER_CSS);
- source->AddResourcePath("file_manager.js", IDR_FILE_MANAGER_JS);
- source->AddResourcePath("file_manager.mojom-lite.js",
- IDR_FILE_MANAGER_MOJO_LITE_JS);
- source->AddResourcePath("browser_proxy.js", IDR_FILE_MANAGER_PROXY_JS);
-
- // Default content for chrome://file-manager: ensures unhandled URLs return
- // 404 rather than content from SetDefaultResource().
- source->AddResourcePath("", IDR_FILE_MANAGER_HTML);
-
- Profile* profile = Profile::FromWebUI(web_ui);
- content::WebUIDataSource::Add(profile, source);
-}
-
-FileManagerUI::~FileManagerUI() = default;
-
-void FileManagerUI::BindInterface(
- mojo::PendingReceiver<mojom::PageHandlerFactory> pending_receiver) {
- if (page_factory_receiver_.is_bound()) {
- page_factory_receiver_.reset();
- }
- page_factory_receiver_.Bind(std::move(pending_receiver));
-}
-
-void FileManagerUI::CreatePageHandler(
- mojo::PendingRemote<mojom::Page> pending_page,
- mojo::PendingReceiver<mojom::PageHandler> pending_page_handler) {
- DCHECK(pending_page.is_valid());
-
- page_handler_ = std::make_unique<FileManagerPageHandler>(
- std::move(pending_page_handler), std::move(pending_page));
-}
-
-WEB_UI_CONTROLLER_TYPE_IMPL(FileManagerUI)
-
-} // namespace file_manager
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_ui.h b/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_ui.h
deleted file mode 100644
index 5db5287d360..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/file_manager/file_manager_ui.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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_FILE_MANAGER_FILE_MANAGER_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_FILE_MANAGER_FILE_MANAGER_UI_H_
-
-#include <memory>
-
-#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/file_manager/file_manager.mojom.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "mojo/public/cpp/bindings/pending_remote.h"
-#include "mojo/public/cpp/bindings/receiver.h"
-#include "ui/webui/mojo_web_ui_controller.h"
-
-namespace chromeos {
-namespace file_manager {
-
-class FileManagerPageHandler;
-
-// The WebUI controller for chrome://file-manager.
-class FileManagerUI : public ui::MojoWebUIController,
- public mojom::PageHandlerFactory {
- public:
- explicit FileManagerUI(content::WebUI* web_ui);
- ~FileManagerUI() override;
-
- void BindInterface(
- mojo::PendingReceiver<mojom::PageHandlerFactory> pending_receiver);
-
- private:
- // mojom::PageHandlerFactory:
- void CreatePageHandler(
- mojo::PendingRemote<mojom::Page> pending_page,
- mojo::PendingReceiver<mojom::PageHandler> pending_page_handler) override;
-
- mojo::Receiver<mojom::PageHandlerFactory> page_factory_receiver_{this};
- std::unique_ptr<FileManagerPageHandler> page_handler_;
-
- WEB_UI_CONTROLLER_TYPE_DECL();
- DISALLOW_COPY_AND_ASSIGN(FileManagerUI);
-};
-
-} // namespace file_manager
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_FILE_MANAGER_FILE_MANAGER_UI_H_
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
new file mode 100644
index 00000000000..0275b3f2117
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.cc
@@ -0,0 +1,93 @@
+// 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/in_session_password_change/lock_screen_reauth_dialogs.h"
+
+#include <memory>
+
+#include "base/bind.h"
+#include "base/json/json_writer.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"
+#include "chrome/grit/generated_resources.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
+#include "ui/strings/grit/ui_strings.h"
+
+namespace chromeos {
+
+namespace {
+
+LockScreenStartReauthDialog* g_dialog = nullptr;
+
+constexpr gfx::Size kLockScreenReauthSize(768, 640);
+
+gfx::Size FitSizeToDisplay(const gfx::Size& desired) {
+ 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.SetToMin(desired);
+ return display_size;
+}
+
+} // namespace
+
+BaseLockDialog::BaseLockDialog(GURL url, gfx::Size desired_size)
+ : SystemWebDialogDelegate(url, /*title=*/base::string16()),
+ desired_size_(desired_size) {}
+
+BaseLockDialog::~BaseLockDialog() {}
+
+void BaseLockDialog::GetDialogSize(gfx::Size* size) const {
+ *size = FitSizeToDisplay(desired_size_);
+}
+
+void BaseLockDialog::AdjustWidgetInitParams(views::Widget::InitParams* params) {
+ params->type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
+}
+
+ui::ModalType BaseLockDialog::GetDialogModalType() const {
+ return ui::ModalType::MODAL_TYPE_SYSTEM;
+}
+
+void LockScreenStartReauthDialog::Show() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (g_dialog) {
+ g_dialog->Focus();
+ return;
+ }
+ g_dialog = new LockScreenStartReauthDialog();
+ g_dialog->ShowSystemDialog();
+}
+
+void LockScreenStartReauthDialog::Dismiss() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (g_dialog)
+ g_dialog->Close();
+}
+
+bool LockScreenStartReauthDialog::IsRunning() {
+ return g_dialog;
+}
+
+LockScreenStartReauthDialog::LockScreenStartReauthDialog()
+ : BaseLockDialog(GURL(chrome::kChromeUILockScreenStartReauthURL),
+ kLockScreenReauthSize) {}
+
+LockScreenStartReauthDialog::~LockScreenStartReauthDialog() {
+ DCHECK_EQ(this, g_dialog);
+ g_dialog = nullptr;
+}
+
+} // namespace chromeos
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
new file mode 100644
index 00000000000..f46252c1240
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h
@@ -0,0 +1,44 @@
+// 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_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_REAUTH_DIALOGS_H_
+#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/ui/webui/chromeos/system_web_dialog_delegate.h"
+#include "ui/web_dialogs/web_dialog_ui.h"
+
+namespace chromeos {
+
+// A modal system dialog without any frame decorating it.
+class BaseLockDialog : public SystemWebDialogDelegate {
+ protected:
+ BaseLockDialog(GURL url, gfx::Size desired_size);
+ BaseLockDialog(BaseLockDialog const&) = delete;
+ ~BaseLockDialog() override;
+
+ // ui::WebDialogDelegate:
+ void GetDialogSize(gfx::Size* size) const override;
+ void AdjustWidgetInitParams(views::Widget::InitParams* params) override;
+ ui::ModalType GetDialogModalType() const override;
+
+ private:
+ gfx::Size desired_size_;
+};
+
+class LockScreenStartReauthDialog : public BaseLockDialog {
+ public:
+ LockScreenStartReauthDialog();
+ LockScreenStartReauthDialog(LockScreenStartReauthDialog const&) = delete;
+ ~LockScreenStartReauthDialog() override;
+
+ void Show();
+ void Dismiss();
+ bool IsRunning();
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_REAUTH_DIALOGS_H_
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
new file mode 100644
index 00000000000..58d29d6f3b8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc
@@ -0,0 +1,21 @@
+// 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/in_session_password_change/lock_screen_reauth_handler.h"
+
+namespace chromeos {
+
+LockScreenReauthHandler::LockScreenReauthHandler() = default;
+LockScreenReauthHandler::~LockScreenReauthHandler() = default;
+
+void LockScreenReauthHandler::HandleInitialize(const base::ListValue* value) {}
+
+void LockScreenReauthHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "initialize",
+ base::BindRepeating(&LockScreenReauthHandler::HandleInitialize,
+ weak_factory_.GetWeakPtr()));
+}
+
+} // namespace chromeos \ No newline at end of file
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
new file mode 100644
index 00000000000..f8871e143b7
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h
@@ -0,0 +1,31 @@
+// 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_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_REAUTH_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_REAUTH_HANDLER_H_
+
+#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 "content/public/browser/web_ui_message_handler.h"
+
+namespace chromeos {
+
+class LockScreenReauthHandler : public content::WebUIMessageHandler {
+ public:
+ LockScreenReauthHandler();
+ ~LockScreenReauthHandler() override;
+
+ void RegisterMessages() override;
+
+ void HandleInitialize(const base::ListValue*);
+
+ private:
+ base::WeakPtrFactory<LockScreenReauthHandler> weak_factory_{this};
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_REAUTH_HANDLER_H_
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
new file mode 100644
index 00000000000..b3582159170
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.cc
@@ -0,0 +1,68 @@
+// 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/in_session_password_change/lock_screen_start_reauth_ui.h"
+
+#include <memory>
+
+#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
+#include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_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_data_source.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace chromeos {
+
+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);
+ std::string email;
+ if (user) {
+ email = user->GetDisplayEmail();
+ }
+
+ content::WebUIDataSource* source = content::WebUIDataSource::Create(
+ chrome::kChromeUILockScreenStartReauthHost);
+
+ web_ui->AddMessageHandler(std::make_unique<LockScreenReauthHandler>());
+
+ // TODO(crbug.com/1098690): Trusted Type Polymer
+ source->DisableTrustedTypesCSP();
+
+ 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,
+ base::UTF8ToUTF16(email)));
+
+ source->AddString("lockScreenVerifyButton",
+ l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_VERIFY_BUTTON));
+ source->AddString(
+ "lockScreenVerifyAgainButton",
+ l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_VERIFY_AGAIN_BUTTON));
+ source->AddString("lockScreenCancelButton",
+ l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_CANCEL_BUTTON));
+ source->AddString("loginWelcomeMessage",
+ l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_VERIFY_ACCOUNT));
+ source->AddString(
+ "loginWelcomeMessageWithError",
+ l10n_util::GetStringUTF16(IDS_LOCK_SCREEN_VERIFICATION_FAILED));
+
+ source->SetDefaultResource(IDR_LOCK_SCREEN_REAUTH_HTML);
+
+ source->AddResourcePath("authenticator.js", IDR_GAIA_AUTH_AUTHENTICATOR_JS);
+
+ source->AddResourcePath("lock_screen_reauth.js", IDR_LOCK_SCREEN_REAUTH_JS);
+
+ content::WebUIDataSource::Add(profile, source);
+}
+
+LockScreenStartReauthUI::~LockScreenStartReauthUI() = default;
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h
new file mode 100644
index 00000000000..99dfba9ecf0
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_start_reauth_ui.h
@@ -0,0 +1,21 @@
+// 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_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_START_REAUTH_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_START_REAUTH_UI_H_
+
+#include "ui/web_dialogs/web_dialog_ui.h"
+
+namespace chromeos {
+
+// For chrome:://lock-reauth
+class LockScreenStartReauthUI : public ui::WebDialogUI {
+ public:
+ explicit LockScreenStartReauthUI(content::WebUI* web_ui);
+ ~LockScreenStartReauthUI() override;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IN_SESSION_PASSWORD_CHANGE_LOCK_SCREEN_START_REAUTH_UI_H_
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 fa57cf5d524..d4c4c277913 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
@@ -10,10 +10,10 @@
#include "base/macros.h"
#include "base/values.h"
#include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.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 "chrome/common/pref_names.h"
#include "chromeos/login/auth/saml_password_attributes.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.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 008f444d6c4..3eeb1111dd3 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
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/strings/utf_string_conversions.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"
@@ -17,7 +18,6 @@
#include "chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.h"
#include "chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
-#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
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 803ccc56925..c75bc74cd03 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
@@ -59,9 +59,9 @@ void AppDownloadingScreenHandler::Bind(AppDownloadingScreen* screen) {
}
void AppDownloadingScreenHandler::Show() {
- ShowScreen(kScreenId);
- CallJS("login.AppDownloadingScreen.updateNumberOfSelectedApps",
- base::Value(GetNumberOfUserSelectedApps()));
+ base::DictionaryValue data;
+ data.SetKey("numOfApps", base::Value(GetNumberOfUserSelectedApps()));
+ ShowScreenWithData(kScreenId, &data);
}
void AppDownloadingScreenHandler::Hide() {}
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 fd90616362b..0b3cd2c5239 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
@@ -17,6 +17,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chrome/grit/generated_resources.h"
+#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/services/assistant/public/cpp/assistant_prefs.h"
#include "chromeos/services/assistant/public/cpp/assistant_service.h"
#include "chromeos/services/assistant/public/cpp/features.h"
@@ -147,6 +148,7 @@ 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());
BaseScreenHandler::GetAdditionalParameters(dict);
@@ -603,4 +605,17 @@ void AssistantOptInFlowScreenHandler::HandleFlowInitialized(
SendGetSettingsRequest();
}
+bool AssistantOptInFlowScreenHandler::DeviceHasBattery() {
+ // Assume that the device has a battery if we can't determine otherwise.
+ if (!chromeos::PowerManagerClient::Get())
+ return true;
+
+ auto status = PowerManagerClient::Get()->GetLastStatus();
+ if (!status.has_value() || !status->has_battery_state())
+ return true;
+
+ return status->battery_state() !=
+ power_manager::PowerSupplyProperties_BatteryState_NOT_PRESENT;
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h
index cff23bb6dcd..1c3af8a14ef 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h
@@ -128,6 +128,9 @@ class AssistantOptInFlowScreenHandler
void HandleFlowFinished();
void HandleFlowInitialized(const int flow_type);
+ // Power related
+ bool DeviceHasBattery();
+
AssistantOptInFlowScreen* screen_ = nullptr;
base::OnceClosure on_initialized_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/cookie_waiter.cc b/chromium/chrome/browser/ui/webui/chromeos/login/cookie_waiter.cc
new file mode 100644
index 00000000000..c0cd0246920
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/cookie_waiter.cc
@@ -0,0 +1,34 @@
+// 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/cookie_waiter.h"
+
+#include "google_apis/gaia/gaia_urls.h"
+
+namespace chromeos {
+
+namespace {
+
+constexpr base::TimeDelta kCookieDelay = base::TimeDelta::FromSeconds(20);
+
+}
+
+CookieWaiter::CookieWaiter(network::mojom::CookieManager* cookie_manager,
+ const std::string& cookie_name,
+ base::RepeatingClosure on_cookie_change,
+ base::OnceClosure on_timeout)
+ : on_cookie_change_(std::move(on_cookie_change)) {
+ cookie_manager->AddCookieChangeListener(
+ GaiaUrls::GetInstance()->gaia_url(), cookie_name,
+ cookie_listener_.BindNewPipeAndPassRemote());
+ waiting_timer_.Start(FROM_HERE, kCookieDelay, std::move(on_timeout));
+}
+
+CookieWaiter::~CookieWaiter() = default;
+
+void CookieWaiter::OnCookieChange(const net::CookieChangeInfo&) {
+ on_cookie_change_.Run();
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/cookie_waiter.h b/chromium/chrome/browser/ui/webui/chromeos/login/cookie_waiter.h
new file mode 100644
index 00000000000..57cb3ad7b92
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/cookie_waiter.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_CHROMEOS_LOGIN_COOKIE_WAITER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_COOKIE_WAITER_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "base/timer/timer.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+#include "services/network/public/mojom/cookie_manager.mojom.h"
+
+namespace chromeos {
+
+class CookieWaiter : public network::mojom::CookieChangeListener {
+ public:
+ CookieWaiter(network::mojom::CookieManager* cookie_manager,
+ const std::string& cookie_name,
+ base::RepeatingClosure on_cookie_change,
+ base::OnceClosure on_timeout);
+ ~CookieWaiter() override;
+
+ CookieWaiter(const CookieWaiter&) = delete;
+ CookieWaiter& operator=(const CookieWaiter&) = delete;
+
+ // network::mojom::CookieChangeListener:
+ void OnCookieChange(const net::CookieChangeInfo&) override;
+
+ private:
+ base::RepeatingClosure on_cookie_change_;
+
+ mojo::Receiver<network::mojom::CookieChangeListener> cookie_listener_{this};
+ base::OneShotTimer waiting_timer_;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_COOKIE_WAITER_H_
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 56bc0e18885..515dad16e0e 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
@@ -39,8 +39,7 @@ void DemoPreferencesScreenHandler::Bind(DemoPreferencesScreen* screen) {
void DemoPreferencesScreenHandler::SetInputMethodId(
const std::string& input_method) {
- CallJS("login.DemoPreferencesScreen.setInputMethodIdFromBackend",
- input_method);
+ CallJS("login.DemoPreferencesScreen.setSelectedKeyboard", input_method);
}
void DemoPreferencesScreenHandler::Initialize() {}
@@ -59,7 +58,8 @@ void DemoPreferencesScreenHandler::DeclareLocalizedValues(
builder->Add("countryDropdownLabel", IDS_COUNTRY_DROPDOWN_LABEL);
}
-void DemoPreferencesScreenHandler::DeclareJSCallbacks() {
+void DemoPreferencesScreenHandler::RegisterMessages() {
+ BaseScreenHandler::RegisterMessages();
AddCallback("DemoPreferencesScreen.setLocaleId",
&DemoPreferencesScreenHandler::HandleSetLocaleId);
AddCallback("DemoPreferencesScreen.setInputMethodId",
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h
index f3a82273bf9..03d93cc2e96 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h
@@ -52,7 +52,9 @@ class DemoPreferencesScreenHandler : public BaseScreenHandler,
void Initialize() override;
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void DeclareJSCallbacks() override;
+
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
private:
void HandleSetLocaleId(const std::string& language_id);
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 2d8e5df5ace..ae5b4f263aa 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
@@ -31,6 +31,7 @@
#include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h"
#include "chrome/browser/policy/enrollment_status.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/login/cookie_waiter.h"
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/network/network_state.h"
@@ -64,6 +65,8 @@ const char kEnrollmentModeUIRecovery[] = "recovery";
constexpr char kActiveDirectoryJoinHistogram[] =
"Enterprise.ActiveDirectoryJoin";
+constexpr char kOAUTHCodeCookie[] = "oauth_code";
+
// Converts |mode| to a mode identifier for the UI.
std::string EnrollmentModeToUIMode(policy::EnrollmentConfig::Mode mode) {
switch (mode) {
@@ -769,7 +772,41 @@ void EnrollmentScreenHandler::HandleCompleteLogin(const std::string& user) {
content::StoragePartition* partition =
signin_partition_manager->GetCurrentStoragePartition();
- partition->GetCookieManagerForBrowserProcess()->GetCookieList(
+ // Validity check that partition did not change during enrollment flow.
+ DCHECK_EQ(signin_partition_manager->GetCurrentStoragePartitionName(),
+ signin_partition_name_);
+
+ network::mojom::CookieManager* cookie_manager =
+ partition->GetCookieManagerForBrowserProcess();
+ if (!oauth_code_waiter_) {
+ // Set listener before requesting the cookies to avoid race conditions.
+ oauth_code_waiter_ = std::make_unique<CookieWaiter>(
+ cookie_manager, kOAUTHCodeCookie,
+ base::BindRepeating(&EnrollmentScreenHandler::
+ ContinueAuthenticationWhenCookiesAvailable,
+ weak_ptr_factory_.GetWeakPtr(), user),
+ base::BindOnce(&EnrollmentScreenHandler::OnCookieWaitTimeout,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+
+ ContinueAuthenticationWhenCookiesAvailable(user);
+}
+
+void EnrollmentScreenHandler::ContinueAuthenticationWhenCookiesAvailable(
+ const std::string& user) {
+ login::SigninPartitionManager* signin_partition_manager =
+ login::SigninPartitionManager::Factory::GetForBrowserContext(
+ Profile::FromWebUI(web_ui()));
+ content::StoragePartition* partition =
+ signin_partition_manager->GetCurrentStoragePartition();
+
+ // Validity check that partition did not change during enrollment flow.
+ DCHECK_EQ(signin_partition_manager->GetCurrentStoragePartitionName(),
+ signin_partition_name_);
+
+ network::mojom::CookieManager* cookie_manager =
+ partition->GetCookieManagerForBrowserProcess();
+ cookie_manager->GetCookieList(
GaiaUrls::GetInstance()->gaia_url(),
net::CookieOptions::MakeAllInclusive(),
base::BindOnce(&EnrollmentScreenHandler::OnGetCookiesForCompleteLogin,
@@ -782,18 +819,27 @@ void EnrollmentScreenHandler::OnGetCookiesForCompleteLogin(
const net::CookieAccessResultList& excluded_cookies) {
std::string auth_code;
for (const auto& cookie_with_access_result : cookies) {
- if (cookie_with_access_result.cookie.Name() == "oauth_code") {
+ if (cookie_with_access_result.cookie.Name() == kOAUTHCodeCookie) {
auth_code = cookie_with_access_result.cookie.Value();
break;
}
}
- DCHECK(!auth_code.empty());
+ if (auth_code.empty()) {
+ // Will try again from oauth_code_waiter callback.
+ return;
+ }
+ oauth_code_waiter_.reset();
DCHECK(controller_);
controller_->OnLoginDone(gaia::SanitizeEmail(user), auth_code);
}
+void EnrollmentScreenHandler::OnCookieWaitTimeout() {
+ oauth_code_waiter_.reset();
+ ShowError(IDS_LOGIN_FATAL_ERROR_NO_AUTH_TOKEN, true);
+}
+
void EnrollmentScreenHandler::HandleAdCompleteLogin(
const std::string& machine_name,
const std::string& distinguished_name,
@@ -874,7 +920,10 @@ void EnrollmentScreenHandler::DoShow() {
void EnrollmentScreenHandler::DoShowWithPartition(
const std::string& partition_name) {
base::DictionaryValue screen_data;
+
screen_data.SetString("webviewPartitionName", partition_name);
+ signin_partition_name_ = partition_name;
+
screen_data.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec());
screen_data.SetString("clientId",
GaiaUrls::GetInstance()->oauth2_chrome_client_id());
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 4feaf4b6886..40ab4597faf 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
@@ -21,6 +21,7 @@
namespace chromeos {
+class CookieWaiter;
class ErrorScreensHistogramHelper;
class HelpAppLauncher;
@@ -98,6 +99,9 @@ class EnrollmentScreenHandler
// Implements NetworkStateInformer::NetworkStateInformerObserver
void UpdateState(NetworkError::ErrorReason reason) override;
+ void ContinueAuthenticationWhenCookiesAvailable(const std::string& user);
+ void OnCookieWaitTimeout();
+
private:
// Handlers for WebUI messages.
void HandleToggleFakeEnrollment();
@@ -182,11 +186,15 @@ class EnrollmentScreenHandler
ErrorScreen* error_screen_ = nullptr;
+ std::string signin_partition_name_;
+
std::unique_ptr<ErrorScreensHistogramHelper> histogram_helper_;
// Help application used for help dialogs.
scoped_refptr<HelpAppLauncher> help_app_;
+ std::unique_ptr<CookieWaiter> oauth_code_waiter_;
+
base::WeakPtrFactory<EnrollmentScreenHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(EnrollmentScreenHandler);
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 3f17f0c6335..75bc4b30919 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
@@ -92,10 +92,6 @@ void EulaScreenHandler::DeclareLocalizedValues(
builder->Add("eulaSystemSecuritySettings", IDS_EULA_SYSTEM_SECURITY_SETTING);
builder->Add("eulaTpmDesc", IDS_EULA_SECURE_MODULE_DESCRIPTION);
- builder->Add("eulaTpmKeyDesc", IDS_EULA_SECURE_MODULE_KEY_DESCRIPTION);
- builder->Add("eulaTpmDescPowerwash",
- IDS_EULA_SECURE_MODULE_KEY_DESCRIPTION_POWERWASH);
- builder->Add("eulaTpmBusy", IDS_EULA_SECURE_MODULE_BUSY);
::login::GetSecureModuleUsed(base::BindOnce(
&EulaScreenHandler::UpdateLocalizedValues, weak_factory_.GetWeakPtr()));
@@ -144,7 +140,6 @@ void EulaScreenHandler::Initialize() {
}
void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) {
- CallJS("login.EulaScreen.setTpmPassword", tpm_password);
CallJS("login.EulaScreen.showSecuritySettingsDialog");
}
@@ -166,10 +161,6 @@ void EulaScreenHandler::UpdateLocalizedValues(
&updated_secure_module_strings);
if (secure_module_used == ::login::SecureModuleUsed::TPM) {
builder->Add("eulaTpmDesc", IDS_EULA_TPM_DESCRIPTION);
- builder->Add("eulaTpmKeyDesc", IDS_EULA_TPM_KEY_DESCRIPTION);
- builder->Add("eulaTpmDescPowerwash",
- IDS_EULA_TPM_KEY_DESCRIPTION_POWERWASH);
- builder->Add("eulaTpmBusy", IDS_EULA_TPM_BUSY);
core_oobe_view_->ReloadEulaContent(updated_secure_module_strings);
}
}
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 0c7fcc05f97..4a6dbf31f48 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
@@ -45,7 +45,6 @@
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
-#include "chrome/browser/chromeos/net/network_portal_detector_impl.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"
@@ -54,6 +53,7 @@
#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/signin_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h"
@@ -74,6 +74,7 @@
#include "chromeos/login/auth/saml_password_attributes.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"
@@ -107,8 +108,6 @@ namespace {
const char kAuthIframeParentName[] = "signin-frame";
-const char kRestrictiveProxyURL[] = "https://www.google.com/generate_204";
-
const char kEndpointGen[] = "1.0";
const char kOAUTHCodeCookie[] = "oauth_code";
@@ -124,8 +123,6 @@ enum class ChromeOSSamlApiUsed {
kMaxValue = kSamlApiNotUsed,
};
-constexpr base::TimeDelta kCookieDelay = base::TimeDelta::FromSeconds(20);
-
void RecordAPILogin(bool is_third_party_idp, bool is_api_used) {
ChromeOSSamlApiUsed login_type;
if (!is_third_party_idp) {
@@ -217,6 +214,18 @@ void UpdateAuthParams(base::DictionaryValue* params,
params->SetString("flow", "nosignup");
}
+bool ShouldCheckUserTypeBeforeAllowing() {
+ if (!chromeos::features::IsFamilyLinkOnSchoolDeviceEnabled())
+ return false;
+
+ CrosSettings* cros_settings = CrosSettings::Get();
+ bool family_link_allowed = false;
+ cros_settings->GetBoolean(kAccountsPrefFamilyLinkAccountsAllowed,
+ &family_link_allowed);
+
+ return family_link_allowed;
+}
+
void RecordSAMLScrapingVerificationResultInHistogram(bool success) {
UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success);
}
@@ -286,10 +295,6 @@ bool ExtractSamlPasswordAttributesEnabled() {
return base::FeatureList::IsEnabled(::features::kInSessionPasswordChange);
}
-bool GaiaActionButtonsEnabled() {
- return base::FeatureList::IsEnabled(chromeos::features::kGaiaActionButtons);
-}
-
PinDialogManager* GetLoginScreenPinDialogManager() {
DCHECK(ProfileHelper::IsSigninProfileInitialized());
CertificateProviderService* certificate_provider_service =
@@ -349,8 +354,8 @@ GaiaScreenHandler::GaiaScreenHandler(
}
GaiaScreenHandler::~GaiaScreenHandler() {
- if (network_portal_detector_)
- network_portal_detector_->RemoveObserver(this);
+ if (network_portal_detector::IsInitialized())
+ network_portal_detector::GetInstance()->RemoveObserver(this);
if (is_security_token_pin_enabled_)
GetLoginScreenPinDialogManager()->RemovePinDialogHost(this);
}
@@ -364,13 +369,8 @@ void GaiaScreenHandler::MaybePreloadAuthExtension() {
VLOG(1) << "MaybePreloadAuthExtension";
- if (!network_portal_detector_) {
- NetworkPortalDetectorImpl* detector = new NetworkPortalDetectorImpl();
- detector->set_portal_test_url(GURL(kRestrictiveProxyURL));
- network_portal_detector_.reset(detector);
- network_portal_detector_->AddObserver(this);
- network_portal_detector_->Enable(true);
- }
+ 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.
@@ -580,10 +580,11 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
params.SetString("lsbReleaseBoard", base::SysInfo::GetLsbReleaseBoard());
params.SetString("webviewPartitionName", partition_name);
+ signin_partition_name_ = partition_name;
params.SetBoolean("extractSamlPasswordAttributes",
ExtractSamlPasswordAttributesEnabled());
- params.SetBoolean("enableGaiaActionButtons", GaiaActionButtonsEnabled());
+ params.SetBoolean("enableGaiaActionButtons", true);
if (public_saml_url_fetcher_) {
params.SetBoolean("startsOnSamlPage", true);
@@ -639,9 +640,11 @@ void GaiaScreenHandler::DeclareLocalizedValues(
builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML);
builder->Add("backButton", IDS_ACCNAME_BACK);
builder->Add("closeButton", IDS_CLOSE);
- builder->Add("whitelistErrorConsumer", IDS_LOGIN_ERROR_ALLOWLIST);
- builder->Add("whitelistErrorEnterprise",
+ builder->Add("allowlistErrorConsumer", IDS_LOGIN_ERROR_ALLOWLIST);
+ builder->Add("allowlistErrorEnterprise",
IDS_ENTERPRISE_LOGIN_ERROR_ALLOWLIST);
+ builder->Add("allowlistErrorEnterpriseAndFamilyLink",
+ IDS_ENTERPRISE_AND_FAMILY_LINK_LOGIN_ERROR_ALLOWLIST);
builder->Add("tryAgainButton", IDS_ALLOWLIST_ERROR_TRY_AGAIN_BUTTON);
builder->Add("learnMoreButton", IDS_LEARN_MORE);
builder->Add("gaiaLoading", IDS_LOGIN_GAIA_LOADING_MESSAGE);
@@ -782,15 +785,17 @@ void GaiaScreenHandler::OnPortalDetectionCompleted(
LoadAuthExtension(true /* force */, false /* offline */);
}
-void GaiaScreenHandler::OnCookieChange(const net::CookieChangeInfo& change) {
- ContinueAuthenticationWhenCookiesAvailable();
-}
-
void GaiaScreenHandler::HandleIdentifierEntered(const std::string& user_email) {
+ // We cannot tell a user type from the identifier, so we delay checking if
+ // the account should be allowed.
+ if (ShouldCheckUserTypeBeforeAllowing())
+ return;
+
if (LoginDisplayHost::default_host() &&
!LoginDisplayHost::default_host()->IsUserAllowlisted(
user_manager::known_user::GetAccountId(
- user_email, std::string() /* id */, AccountType::UNKNOWN))) {
+ user_email, std::string() /* id */, AccountType::UNKNOWN),
+ base::nullopt)) {
ShowAllowlistCheckFailedError();
}
}
@@ -934,6 +939,17 @@ void GaiaScreenHandler::HandleCompleteAuthentication(
DCHECK(!email.empty());
DCHECK(!gaia_id.empty());
+
+ // Execute delayed allowlist check that is based on user type.
+ const user_manager::UserType user_type =
+ GetUsertypeFromServicesString(services);
+ if (ShouldCheckUserTypeBeforeAllowing() &&
+ !LoginDisplayHost::default_host()->IsUserAllowlisted(
+ GetAccountId(email, gaia_id, AccountType::GOOGLE), user_type)) {
+ ShowAllowlistCheckFailedError();
+ return;
+ }
+
const std::string sanitized_email = gaia::SanitizeEmail(email);
LoginDisplayHost::default_host()->SetDisplayEmail(sanitized_email);
@@ -974,16 +990,19 @@ void GaiaScreenHandler::ContinueAuthenticationWhenCookiesAvailable() {
if (!partition)
return;
+ // Validity check that partition did not change during login flow.
+ DCHECK_EQ(signin_partition_manager->GetCurrentStoragePartitionName(),
+ signin_partition_name_);
+
network::mojom::CookieManager* cookie_manager =
partition->GetCookieManagerForBrowserProcess();
- if (!oauth_code_listener_.is_bound()) {
+ if (!oauth_code_waiter_) {
// Set listener before requesting the cookies to avoid race conditions.
- cookie_manager->AddCookieChangeListener(
- GaiaUrls::GetInstance()->gaia_url(), kOAUTHCodeCookie,
- oauth_code_listener_.BindNewPipeAndPassRemote());
- cookie_waiting_timer_ = std::make_unique<base::OneShotTimer>();
- cookie_waiting_timer_->Start(
- FROM_HERE, kCookieDelay,
+ oauth_code_waiter_ = std::make_unique<CookieWaiter>(
+ cookie_manager, kOAUTHCodeCookie,
+ base::BindRepeating(
+ &GaiaScreenHandler::ContinueAuthenticationWhenCookiesAvailable,
+ weak_factory_.GetWeakPtr()),
base::BindOnce(&GaiaScreenHandler::OnCookieWaitTimeout,
weak_factory_.GetWeakPtr()));
}
@@ -1009,15 +1028,14 @@ void GaiaScreenHandler::OnGetCookiesForCompleteAuthentication(
}
if (auth_code.empty()) {
- // Will try again from onCookieChange.
+ // Will try again from oauth_code_waiter callback.
return;
}
DCHECK(pending_user_context_);
UserContext user_context = *pending_user_context_;
pending_user_context_.reset();
- oauth_code_listener_.reset();
- cookie_waiting_timer_.reset();
+ oauth_code_waiter_.reset();
user_context.SetAuthCode(auth_code);
if (!gaps_cookie.empty())
@@ -1029,8 +1047,7 @@ void GaiaScreenHandler::OnGetCookiesForCompleteAuthentication(
void GaiaScreenHandler::OnCookieWaitTimeout() {
DCHECK(pending_user_context_);
pending_user_context_.reset();
- oauth_code_listener_.reset();
- cookie_waiting_timer_.reset();
+ oauth_code_waiter_.reset();
LoadAuthExtension(true /* force */, false /* offline */);
core_oobe_view_->ShowSignInError(
0, l10n_util::GetStringUTF8(IDS_LOGIN_FATAL_ERROR_NO_AUTH_TOKEN),
@@ -1533,7 +1550,13 @@ void GaiaScreenHandler::ShowAllowlistCheckFailedError() {
g_browser_process->platform_part()
->browser_policy_connector_chromeos()
->IsEnterpriseManaged());
- CallJS("login.GaiaSigninScreen.showWhitelistCheckFailedError", true, params);
+
+ bool family_link_allowed = false;
+ CrosSettings::Get()->GetBoolean(kAccountsPrefFamilyLinkAccountsAllowed,
+ &family_link_allowed);
+ params.SetBoolean("familyLinkAllowed", family_link_allowed);
+
+ CallJS("login.GaiaSigninScreen.showAllowlistCheckFailedError", true, params);
}
void GaiaScreenHandler::LoadAuthExtension(bool force, bool offline) {
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 111938b0a5d..4f11ed3ee25 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
@@ -19,18 +19,15 @@
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "chrome/browser/ui/webui/chromeos/login/saml_challenge_key_handler.h"
#include "chromeos/components/security_token_pin/constants.h"
-#include "chromeos/network/portal_detector/network_portal_detector.h"
#include "components/user_manager/user_type.h"
#include "net/base/net_errors.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_access_result.h"
-#include "services/network/public/mojom/cookie_manager.mojom.h"
class AccountId;
namespace base {
class DictionaryValue;
-class OneShotTimer;
} // namespace base
namespace network {
@@ -39,6 +36,7 @@ class NSSTempCertsCacheChromeOS;
namespace chromeos {
+class CookieWaiter;
class Key;
class SamlPasswordAttributes;
class SigninScreenHandler;
@@ -98,7 +96,6 @@ class GaiaView {
class GaiaScreenHandler : public BaseScreenHandler,
public GaiaView,
public NetworkPortalDetector::Observer,
- public network::mojom::CookieChangeListener,
public SecurityTokenPinDialogHost {
public:
using TView = GaiaView;
@@ -215,9 +212,6 @@ class GaiaScreenHandler : public BaseScreenHandler,
const NetworkState* network,
const NetworkPortalDetector::CaptivePortalState& state) override;
- // network::mojom::CookieChangeListener:
- void OnCookieChange(const net::CookieChangeInfo& change) override;
-
// WebUI message handlers.
void HandleWebviewLoadAborted(int error_code);
void HandleCompleteAuthentication(
@@ -412,7 +406,6 @@ class GaiaScreenHandler : public BaseScreenHandler,
NetworkPortalDetector::CaptivePortalStatus captive_portal_status_ =
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE;
- std::unique_ptr<NetworkPortalDetector> network_portal_detector_;
bool disable_restrictive_proxy_check_for_test_ = false;
// Non-owning ptr to SigninScreenHandler instance. Should not be used
@@ -467,15 +460,15 @@ class GaiaScreenHandler : public BaseScreenHandler,
bool hidden_ = true;
+ std::string signin_partition_name_;
+
// Handler for |samlChallengeMachineKey| request.
std::unique_ptr<SamlChallengeKeyHandler> saml_challenge_key_handler_;
std::unique_ptr<SamlChallengeKeyHandler> saml_challenge_key_handler_for_test_;
// Connection to the CookieManager that signals when the GAIA cookies change.
- mojo::Receiver<network::mojom::CookieChangeListener> oauth_code_listener_{
- this};
+ std::unique_ptr<CookieWaiter> oauth_code_waiter_;
std::unique_ptr<UserContext> pending_user_context_;
- std::unique_ptr<base::OneShotTimer> cookie_waiting_timer_;
base::WeakPtrFactory<GaiaScreenHandler> weak_factory_{this};
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 7d9e7ec49e9..49343bf308e 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
@@ -64,11 +64,6 @@ void HIDDetectionScreenHandler::Unbind() {
BaseScreenHandler::SetBaseScreen(nullptr);
}
-void HIDDetectionScreenHandler::CheckIsScreenRequired(
- const base::Callback<void(bool)>& on_check_done) {
- screen_->CheckIsScreenRequired(on_check_done);
-}
-
void HIDDetectionScreenHandler::SetKeyboardState(const std::string& value) {
keyboard_state_ = value;
CallJS("login.HIDDetectionScreen.setKeyboardState", value);
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 7a3d3cddd63..9fdbd0670b8 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
@@ -30,11 +30,6 @@ class HIDDetectionView {
virtual void Hide() = 0;
virtual void Bind(HIDDetectionScreen* screen) = 0;
virtual void Unbind() = 0;
- // Checks if we should show the screen or enough devices already present.
- // Calls corresponding set of actions based on the bool result.
- virtual void CheckIsScreenRequired(
- const base::Callback<void(bool)>& on_check_done) = 0;
-
virtual void SetKeyboardState(const std::string& value) = 0;
virtual void SetMouseState(const std::string& value) = 0;
virtual void SetKeyboardPinCode(const std::string& value) = 0;
@@ -52,7 +47,7 @@ class HIDDetectionScreenHandler
public:
using TView = HIDDetectionView;
- HIDDetectionScreenHandler(JSCallsContainer* js_calls_container);
+ explicit HIDDetectionScreenHandler(JSCallsContainer* js_calls_container);
~HIDDetectionScreenHandler() override;
// HIDDetectionView implementation:
@@ -60,8 +55,6 @@ class HIDDetectionScreenHandler
void Hide() override;
void Bind(HIDDetectionScreen* screen) override;
void Unbind() override;
- void CheckIsScreenRequired(
- const base::Callback<void(bool)>& on_check_done) override;
void SetKeyboardState(const std::string& value) override;
void SetMouseState(const std::string& value) override;
void SetKeyboardPinCode(const std::string& value) override;
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 0a95a8c404b..d84c99d5c26 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
@@ -148,6 +148,53 @@ const char* NetworkStateInformer::StatusString(State state) {
}
}
+// static
+// Returns network name by service path.
+std::string NetworkStateInformer::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();
+}
+
+// static
+bool NetworkStateInformer::IsOnline(State state,
+ NetworkError::ErrorReason reason) {
+ switch (reason) {
+ case NetworkError::ERROR_REASON_PORTAL_DETECTED:
+ case NetworkError::ERROR_REASON_LOADING_TIMEOUT:
+ return false;
+ case NetworkError::ERROR_REASON_PROXY_AUTH_CANCELLED:
+ case NetworkError::ERROR_REASON_PROXY_AUTH_SUPPLIED:
+ case NetworkError::ERROR_REASON_PROXY_CONNECTION_FAILED:
+ case NetworkError::ERROR_REASON_PROXY_CONFIG_CHANGED:
+ case NetworkError::ERROR_REASON_NETWORK_STATE_CHANGED:
+ case NetworkError::ERROR_REASON_UPDATE:
+ case NetworkError::ERROR_REASON_FRAME_ERROR:
+ case NetworkError::ERROR_REASON_NONE:
+ return state == NetworkStateInformer::ONLINE;
+ }
+}
+
+// static
+bool NetworkStateInformer::IsBehindCaptivePortal(
+ State state,
+ NetworkError::ErrorReason reason) {
+ return state == NetworkStateInformer::CAPTIVE_PORTAL ||
+ reason == NetworkError::ERROR_REASON_PORTAL_DETECTED;
+}
+
+// static
+bool NetworkStateInformer::IsProxyError(State state,
+ NetworkError::ErrorReason reason) {
+ return state == NetworkStateInformer::PROXY_AUTH_REQUIRED ||
+ reason == NetworkError::ERROR_REASON_PROXY_AUTH_CANCELLED ||
+ reason == NetworkError::ERROR_REASON_PROXY_CONNECTION_FAILED;
+}
+
bool NetworkStateInformer::UpdateState() {
const NetworkState* default_network =
NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
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 32d79f0dc48..ca207e0a74f 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
@@ -77,6 +77,11 @@ class NetworkStateInformer
std::string network_path() const { return network_path_; }
static const char* StatusString(State state);
+ static std::string GetNetworkName(const std::string& service_path);
+ static bool IsOnline(State state, NetworkError::ErrorReason reason);
+ static bool IsBehindCaptivePortal(State state,
+ NetworkError::ErrorReason reason);
+ static bool IsProxyError(State state, NetworkError::ErrorReason reason);
private:
friend class base::RefCounted<NetworkStateInformer>;
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 29c58fa4b2a..8edea2dd3a7 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
@@ -32,7 +32,7 @@ const uint16_t kDeviceIds[] = {0x0457, 0x266e, 0x222a};
// Returns true if |vendor_id| is a valid vendor id that may be made the primary
// display.
-bool IsWhiteListedVendorId(uint16_t vendor_id) {
+bool IsAllowListedVendorId(uint16_t vendor_id) {
return base::Contains(kDeviceIds, vendor_id);
}
@@ -83,7 +83,7 @@ void OobeDisplayChooser::MoveToTouchDisplay() {
ui::DeviceDataManager::GetInstance();
for (const ui::TouchscreenDevice& device :
device_data_manager->GetTouchscreenDevices()) {
- if (IsWhiteListedVendorId(device.vendor_id) &&
+ if (IsAllowListedVendorId(device.vendor_id) &&
device.target_display_id != display::kInvalidDisplayId) {
auto config_properties = ash::mojom::DisplayConfigProperties::New();
config_properties->set_primary = true;
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 45795d5a757..473bd7311ce 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
@@ -161,10 +161,6 @@ void ResetScreenHandler::SetScreenState(State value) {
CallJS("login.ResetScreen.setScreenState", static_cast<int>(value));
}
-void ResetScreenHandler::SetIsForcedPowerwash(bool value) {
- CallJS("login.ResetScreen.setIsForcedPowerwash", value);
-}
-
ResetView::State ResetScreenHandler::GetScreenState() {
return state_;
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
index edaa9a78e1c..a608bdfd652 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
@@ -43,7 +43,6 @@ class ResetView {
virtual void SetShouldShowConfirmationDialog(bool value) = 0;
virtual void SetConfirmationDialogClosed() = 0;
virtual void SetScreenState(State value) = 0;
- virtual void SetIsForcedPowerwash(bool value) = 0;
virtual State GetScreenState() = 0;
virtual tpm_firmware_update::Mode GetTpmFirmwareUpdateMode() = 0;
@@ -81,7 +80,6 @@ class ResetScreenHandler : public ResetView,
void SetShouldShowConfirmationDialog(bool value) override;
void SetConfirmationDialogClosed() override;
void SetScreenState(State value) override;
- void SetIsForcedPowerwash(bool value) override;
State GetScreenState() override;
tpm_firmware_update::Mode GetTpmFirmwareUpdateMode() override;
bool GetIsRollbackAvailable() override;
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 b3b27e6ce71..3ae971d9eed 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
@@ -1294,6 +1294,13 @@ bool SigninScreenHandler::AllAllowlistedUsersPresent() {
if (!delegate_ || users.size() > kMaxUsers) {
return false;
}
+
+ bool allow_family_link = false;
+ cros_settings->GetBoolean(kAccountsPrefFamilyLinkAccountsAllowed,
+ &allow_family_link);
+ if (allow_family_link)
+ return false;
+
const base::ListValue* allowlist = nullptr;
if (!cros_settings->GetList(kAccountsPrefUsers, &allowlist) || !allowlist)
return false;
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 a7bdc97a447..a378499a04e 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
@@ -138,6 +138,8 @@ void SyncConsentScreenHandler::Show() {
base::DictionaryValue data;
data.SetBoolean("isChildAccount", user_manager->IsLoggedInAsChildUser());
data.SetString("deviceType", ui::GetChromeOSDeviceName());
+ data.SetBoolean("splitSettingsSyncEnabled",
+ chromeos::features::IsSplitSettingsSyncEnabled());
ShowScreenWithData(kScreenId, &data);
}
@@ -160,13 +162,6 @@ void SyncConsentScreenHandler::RegisterMessages() {
&SyncConsentScreenHandler::HandleDeclineAndContinue);
}
-void SyncConsentScreenHandler::GetAdditionalParameters(
- base::DictionaryValue* parameters) {
- parameters->SetBoolean("splitSettingsSyncEnabled",
- chromeos::features::IsSplitSettingsSyncEnabled());
- BaseScreenHandler::GetAdditionalParameters(parameters);
-}
-
void SyncConsentScreenHandler::HandleContinueAndReview(
const login::StringList& consent_description,
const std::string& consent_confirmation) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h
index a11e554f091..475536a4e3c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h
@@ -63,7 +63,6 @@ class SyncConsentScreenHandler : public BaseScreenHandler,
// BaseScreenHandler:
void Initialize() override;
void RegisterMessages() override;
- void GetAdditionalParameters(base::DictionaryValue* parameters) override;
// WebUI message handlers
void HandleContinueAndReview(const ::login::StringList& consent_description,
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 06356a7e419..98ffbb0601e 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
@@ -33,6 +33,11 @@ void UserCreationScreenHandler::DeclareLocalizedValues(
builder->AddF("userCreationTitle", IDS_OOBE_USER_CREATION_TITLE,
ui::GetChromeOSDeviceName());
builder->Add("userCreationSubtitle", IDS_OOBE_USER_CREATION_SUBTITLE);
+ builder->AddF("userCreationAddPersonTitle",
+ IDS_OOBE_USER_CREATION_ADD_PERSON_TITLE,
+ ui::GetChromeOSDeviceName());
+ builder->Add("userCreationAddPersonSubtitle",
+ IDS_OOBE_USER_CREATION_ADD_PERSON_SUBTITLE);
builder->Add("createForSelfLabel", IDS_OOBE_USER_CREATION_SELF_BUTTON_LABEL);
builder->Add("createForSelfDescription",
IDS_OOBE_USER_CREATION_SELF_BUTTON_DESCRIPTION);
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
new file mode 100644
index 00000000000..837677c7b72
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.cc
@@ -0,0 +1,84 @@
+// 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/multidevice_internals/multidevice_internals_logs_handler.h"
+
+#include "base/bind.h"
+#include "base/i18n/time_formatting.h"
+#include "base/values.h"
+#include "chromeos/components/multidevice/logging/logging.h"
+
+namespace chromeos {
+
+namespace multidevice {
+
+namespace {
+
+// Keys in the JSON representation of a log message
+const char kLogMessageTextKey[] = "text";
+const char kLogMessageTimeKey[] = "time";
+const char kLogMessageFileKey[] = "file";
+const char kLogMessageLineKey[] = "line";
+const char kLogMessageSeverityKey[] = "severity";
+
+// Converts |log_message| to a raw dictionary value used as a JSON argument to
+// JavaScript functions.
+base::Value LogMessageToDictionary(
+ const chromeos::multidevice::LogBuffer::LogMessage& log_message) {
+ base::Value dictionary(base::Value::Type::DICTIONARY);
+ dictionary.SetStringKey(kLogMessageTextKey, log_message.text);
+ dictionary.SetStringKey(
+ kLogMessageTimeKey,
+ base::TimeFormatTimeOfDayWithMilliseconds(log_message.time));
+ dictionary.SetStringKey(kLogMessageFileKey, log_message.file);
+ dictionary.SetIntKey(kLogMessageLineKey, log_message.line);
+ dictionary.SetIntKey(kLogMessageSeverityKey, log_message.severity);
+ return dictionary;
+}
+
+} // namespace
+
+MultideviceLogsHandler::MultideviceLogsHandler() : observer_(this) {}
+
+MultideviceLogsHandler::~MultideviceLogsHandler() = default;
+
+void MultideviceLogsHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "getMultideviceLogMessages",
+ base::BindRepeating(&MultideviceLogsHandler::HandleGetLogMessages,
+ base::Unretained(this)));
+}
+
+void MultideviceLogsHandler::OnJavascriptAllowed() {
+ observer_.Add(multidevice::LogBuffer::GetInstance());
+}
+
+void MultideviceLogsHandler::OnJavascriptDisallowed() {
+ observer_.RemoveAll();
+}
+
+void MultideviceLogsHandler::HandleGetLogMessages(const base::ListValue* args) {
+ AllowJavascript();
+ const base::Value& callback_id = args->GetList()[0];
+ base::Value list(base::Value::Type::LIST);
+ for (const auto& log :
+ *chromeos::multidevice::LogBuffer::GetInstance()->logs()) {
+ list.Append(LogMessageToDictionary(log));
+ }
+ ResolveJavascriptCallback(callback_id, list);
+}
+
+void MultideviceLogsHandler::OnLogBufferCleared() {
+ FireWebUIListener("multidevice-log-buffer-cleared");
+}
+
+void MultideviceLogsHandler::OnLogMessageAdded(
+ const chromeos::multidevice::LogBuffer::LogMessage& log_message) {
+ FireWebUIListener("multidevice-log-message-added",
+ LogMessageToDictionary(log_message));
+}
+
+} // namespace multidevice
+
+} // namespace chromeos
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
new file mode 100644
index 00000000000..e8cb0a8caee
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h
@@ -0,0 +1,56 @@
+// 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_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 "chromeos/components/multidevice/logging/log_buffer.h"
+#include "chromeos/components/multidevice/logging/logging.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace base {
+class ListValue;
+} // namespace base
+
+namespace chromeos {
+
+namespace multidevice {
+
+// WebUIMessageHandler for the PA_LOG Macro to pass logging messages to the
+// chrome://multidevice-internals logging tab.
+class MultideviceLogsHandler : public content::WebUIMessageHandler,
+ public multidevice::LogBuffer::Observer {
+ public:
+ MultideviceLogsHandler();
+ MultideviceLogsHandler(const MultideviceLogsHandler&) = delete;
+ MultideviceLogsHandler& operator=(const MultideviceLogsHandler&) = delete;
+ ~MultideviceLogsHandler() override;
+
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ // chromeos::multidevice::LogBuffer::Observer:
+ void OnLogMessageAdded(
+ const multidevice::LogBuffer::LogMessage& log_message) override;
+ void OnLogBufferCleared() override;
+
+ private:
+ // Message handler callback that returns the Log Buffer in dictionary form.
+ void HandleGetLogMessages(const base::ListValue* args);
+
+ // Message handler callback that clears the Log Buffer.
+ void ClearLogBuffer(const base::ListValue* args);
+
+ ScopedObserver<multidevice::LogBuffer, multidevice::LogBuffer::Observer>
+ observer_{this};
+};
+
+} // namespace multidevice
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_LOGS_HANDLER_H_
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
new file mode 100644
index 00000000000..2ebe801e024
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.cc
@@ -0,0 +1,532 @@
+// 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/multidevice_internals/multidevice_internals_phone_hub_handler.h"
+
+#include "ash/public/cpp/system_tray.h"
+#include "base/optional.h"
+#include "base/time/time.h"
+#include "chrome/browser/chromeos/phonehub/phone_hub_manager_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chromeos/components/multidevice/logging/logging.h"
+#include "chromeos/components/phonehub/fake_phone_hub_manager.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/image/image.h"
+
+namespace chromeos {
+namespace multidevice {
+
+namespace {
+
+const int kIconSize = 16;
+const int kContactImageSize = 80;
+const int kSharedImageSize = 400;
+
+// Fake image types used for fields that require gfx::Image().
+enum class ImageType {
+ kPink = 1,
+ kRed = 2,
+ kGreen = 3,
+ kBlue = 4,
+ kYellow = 5,
+};
+
+const SkBitmap ImageTypeToBitmap(ImageType image_type_num, int size) {
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(size, size);
+ switch (image_type_num) {
+ case ImageType::kPink:
+ bitmap.eraseARGB(255, 255, 192, 203);
+ break;
+ case ImageType::kRed:
+ bitmap.eraseARGB(255, 255, 0, 0);
+ break;
+ case ImageType::kGreen:
+ bitmap.eraseARGB(255, 0, 255, 0);
+ break;
+ case ImageType::kBlue:
+ bitmap.eraseARGB(255, 0, 0, 255);
+ break;
+ case ImageType::kYellow:
+ bitmap.eraseARGB(255, 255, 255, 0);
+ break;
+ default:
+ break;
+ }
+ return bitmap;
+}
+
+phonehub::Notification::AppMetadata DictToAppMetadata(
+ const base::DictionaryValue* app_metadata_dict) {
+ base::string16 visible_app_name;
+ CHECK(app_metadata_dict->GetString("visibleAppName", &visible_app_name));
+
+ std::string package_name;
+ CHECK(app_metadata_dict->GetString("packageName", &package_name));
+
+ int icon_image_type_as_int;
+ CHECK(app_metadata_dict->GetInteger("icon", &icon_image_type_as_int));
+
+ auto icon_image_type = static_cast<ImageType>(icon_image_type_as_int);
+ gfx::Image icon = gfx::Image::CreateFrom1xBitmap(
+ ImageTypeToBitmap(icon_image_type, kIconSize));
+ return phonehub::Notification::AppMetadata(visible_app_name, package_name,
+ icon);
+}
+
+void TryAddingMetadata(
+ const std::string& key,
+ const base::DictionaryValue* browser_tab_status_dict,
+ std::vector<phonehub::BrowserTabsModel::BrowserTabMetadata>& metadatas) {
+ const base::DictionaryValue* browser_tab_metadata = nullptr;
+
+ if (!browser_tab_status_dict->GetDictionary(key, &browser_tab_metadata))
+ return;
+
+ std::string url;
+ if (!browser_tab_metadata->GetString("url", &url) || url.empty())
+ return;
+
+ base::string16 title;
+ if (!browser_tab_metadata->GetString("title", &title) || title.empty())
+ return;
+
+ // JavaScript time stamps don't fit in int.
+ double last_accessed_timestamp;
+ if (!browser_tab_metadata->GetDouble("lastAccessedTimeStamp",
+ &last_accessed_timestamp)) {
+ return;
+ }
+
+ int favicon_image_type_as_int;
+ if (!browser_tab_metadata->GetInteger("favicon",
+ &favicon_image_type_as_int) ||
+ !favicon_image_type_as_int) {
+ return;
+ }
+
+ auto favicon_image_type = static_cast<ImageType>(favicon_image_type_as_int);
+ gfx::Image favicon = gfx::Image::CreateFrom1xBitmap(
+ ImageTypeToBitmap(favicon_image_type, kIconSize));
+
+ auto metadata = phonehub::BrowserTabsModel::BrowserTabMetadata(
+ GURL(url), title, base::Time::FromJsTime(last_accessed_timestamp),
+ favicon);
+
+ metadatas.push_back(metadata);
+}
+
+} // namespace
+
+MultidevicePhoneHubHandler::MultidevicePhoneHubHandler() = default;
+
+MultidevicePhoneHubHandler::~MultidevicePhoneHubHandler() {
+ if (fake_phone_hub_manager_)
+ EnableRealPhoneHubManager();
+}
+
+void MultidevicePhoneHubHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "setFakePhoneHubManagerEnabled",
+ base::BindRepeating(
+ &MultidevicePhoneHubHandler::HandleEnableFakePhoneHubManager,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "setFeatureStatus",
+ base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetFeatureStatus,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "setShowOnboardingFlow",
+ base::BindRepeating(
+ &MultidevicePhoneHubHandler::HandleSetShowOnboardingFlow,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "setFakePhoneName",
+ base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetFakePhoneName,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "setFakePhoneStatus",
+ base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetFakePhoneStatus,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "setBrowserTabs",
+ base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetBrowserTabs,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "setNotification",
+ base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetNotification,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "removeNotification",
+ base::BindRepeating(&MultidevicePhoneHubHandler::HandleRemoveNotification,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "enableDnd",
+ base::BindRepeating(&MultidevicePhoneHubHandler::HandleEnableDnd,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "setFindMyDeviceStatus",
+ base::BindRepeating(
+ &MultidevicePhoneHubHandler::HandleSetFindMyDeviceStatus,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
+ "setTetherStatus",
+ base::BindRepeating(&MultidevicePhoneHubHandler::HandleSetTetherStatus,
+ base::Unretained(this)));
+}
+
+void MultidevicePhoneHubHandler::OnJavascriptDisallowed() {
+ RemoveObservers();
+}
+
+void MultidevicePhoneHubHandler::AddObservers() {
+ notification_manager_observer_.Add(
+ fake_phone_hub_manager_->fake_notification_manager());
+ do_not_disturb_controller_observer_.Add(
+ fake_phone_hub_manager_->fake_do_not_disturb_controller());
+ find_my_device_controller_oberserver_.Add(
+ fake_phone_hub_manager_->fake_find_my_device_controller());
+ tether_controller_observer_.Add(
+ fake_phone_hub_manager_->fake_tether_controller());
+}
+
+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);
+ }
+}
+
+void MultidevicePhoneHubHandler::OnNotificationsRemoved(
+ const base::flat_set<int64_t>& notification_ids) {
+ base::ListValue removed_notification_id_js_list;
+ for (const int64_t& id : notification_ids) {
+ removed_notification_id_js_list.Append(static_cast<double>(id));
+ }
+ FireWebUIListener("removed-notification-ids",
+ removed_notification_id_js_list);
+}
+
+void MultidevicePhoneHubHandler::OnDndStateChanged() {
+ bool is_dnd_enabled =
+ fake_phone_hub_manager_->fake_do_not_disturb_controller()->IsDndEnabled();
+ FireWebUIListener("is-dnd-enabled-changed", base::Value(is_dnd_enabled));
+}
+
+void MultidevicePhoneHubHandler::OnPhoneRingingStateChanged() {
+ // TODO(jimmyxgong): Change to casting the enum TBA to int.
+ bool is_ringing = fake_phone_hub_manager_->fake_find_my_device_controller()
+ ->IsPhoneRinging();
+ int status_as_int = is_ringing ? 2 : 1;
+ FireWebUIListener("find-my-device-status-changed",
+ base::Value(status_as_int));
+}
+
+void MultidevicePhoneHubHandler::OnTetherStatusChanged() {
+ int status_as_int = static_cast<int>(
+ fake_phone_hub_manager_->fake_tether_controller()->GetStatus());
+ FireWebUIListener("tether-status-changed", base::Value(status_as_int));
+}
+
+void MultidevicePhoneHubHandler::HandleEnableDnd(const base::ListValue* args) {
+ bool enabled = false;
+ CHECK(args->GetBoolean(0, &enabled));
+ PA_LOG(VERBOSE) << "Setting Do Not Disturb state to " << enabled;
+ fake_phone_hub_manager_->fake_do_not_disturb_controller()
+ ->SetDoNotDisturbStateInternal(enabled);
+}
+
+void MultidevicePhoneHubHandler::HandleSetFindMyDeviceStatus(
+ const base::ListValue* args) {
+ int status_as_int = 0;
+ CHECK(args->GetInteger(0, &status_as_int));
+
+ // TODO(jimmyxgong): Change to casting the enum TBA to int.
+ bool is_ringing = status_as_int == 2;
+ PA_LOG(VERBOSE) << "Setting phone ringing status to " << is_ringing;
+ fake_phone_hub_manager_->fake_find_my_device_controller()
+ ->SetIsPhoneRingingInternal(is_ringing);
+}
+
+void MultidevicePhoneHubHandler::HandleSetTetherStatus(
+ const base::ListValue* args) {
+ int status_as_int = 0;
+ CHECK(args->GetInteger(0, &status_as_int));
+
+ auto status = static_cast<phonehub::TetherController::Status>(status_as_int);
+ PA_LOG(VERBOSE) << "Setting tether status to " << status;
+ fake_phone_hub_manager_->fake_tether_controller()->SetStatus(status);
+}
+
+void MultidevicePhoneHubHandler::EnableRealPhoneHubManager() {
+ // If no FakePhoneHubManager is active, return early. This ensures that we
+ // don't unnecessarily re-initialize the Phone Hub UI.
+ if (!fake_phone_hub_manager_)
+ return;
+
+ PA_LOG(VERBOSE) << "Setting real Phone Hub Manager";
+ Profile* profile = Profile::FromWebUI(web_ui());
+ chromeos::phonehub::PhoneHubManager* phone_hub_manager =
+ chromeos::phonehub::PhoneHubManagerFactory::GetForProfile(profile);
+ ash::SystemTray::Get()->SetPhoneHubManager(phone_hub_manager);
+
+ RemoveObservers();
+ fake_phone_hub_manager_.reset();
+}
+
+void MultidevicePhoneHubHandler::EnableFakePhoneHubManager() {
+ DCHECK(!fake_phone_hub_manager_);
+ PA_LOG(VERBOSE) << "Setting fake Phone Hub Manager";
+ fake_phone_hub_manager_ = std::make_unique<phonehub::FakePhoneHubManager>();
+ ash::SystemTray::Get()->SetPhoneHubManager(fake_phone_hub_manager_.get());
+ AddObservers();
+}
+
+void MultidevicePhoneHubHandler::HandleEnableFakePhoneHubManager(
+ const base::ListValue* args) {
+ AllowJavascript();
+ bool enabled = false;
+ CHECK(args->GetBoolean(0, &enabled));
+ if (enabled) {
+ EnableFakePhoneHubManager();
+ return;
+ }
+ EnableRealPhoneHubManager();
+}
+
+void MultidevicePhoneHubHandler::HandleSetFeatureStatus(
+ const base::ListValue* args) {
+ int feature_as_int = 0;
+ CHECK(args->GetInteger(0, &feature_as_int));
+
+ auto feature = static_cast<phonehub::FeatureStatus>(feature_as_int);
+ PA_LOG(VERBOSE) << "Setting feature status to " << feature;
+ fake_phone_hub_manager_->fake_feature_status_provider()->SetStatus(feature);
+}
+
+void MultidevicePhoneHubHandler::HandleSetShowOnboardingFlow(
+ const base::ListValue* args) {
+ bool show_onboarding_flow = false;
+ CHECK(args->GetBoolean(0, &show_onboarding_flow));
+ PA_LOG(VERBOSE) << "Setting show onboarding flow to " << show_onboarding_flow;
+ fake_phone_hub_manager_->fake_onboarding_ui_tracker()
+ ->SetShouldShowOnboardingUi(show_onboarding_flow);
+}
+
+void MultidevicePhoneHubHandler::HandleSetFakePhoneName(
+ const base::ListValue* args) {
+ base::string16 phone_name;
+ CHECK(args->GetString(0, &phone_name));
+ fake_phone_hub_manager_->mutable_phone_model()->SetPhoneName(phone_name);
+ PA_LOG(VERBOSE) << "Set phone name to " << phone_name;
+}
+
+void MultidevicePhoneHubHandler::HandleSetFakePhoneStatus(
+ const base::ListValue* args) {
+ const base::DictionaryValue* phones_status_dict = nullptr;
+ CHECK(args->GetDictionary(0, &phones_status_dict));
+
+ int mobile_status_as_int;
+ CHECK(phones_status_dict->GetInteger("mobileStatus", &mobile_status_as_int));
+ auto mobile_status = static_cast<phonehub::PhoneStatusModel::MobileStatus>(
+ mobile_status_as_int);
+
+ int signal_strength_as_int;
+ CHECK(phones_status_dict->GetInteger("signalStrength",
+ &signal_strength_as_int));
+ auto signal_strength =
+ static_cast<phonehub::PhoneStatusModel::SignalStrength>(
+ signal_strength_as_int);
+
+ base::string16 mobile_provider;
+ CHECK(phones_status_dict->GetString("mobileProvider", &mobile_provider));
+
+ int charging_state_as_int;
+ CHECK(
+ phones_status_dict->GetInteger("chargingState", &charging_state_as_int));
+ auto charging_state = static_cast<phonehub::PhoneStatusModel::ChargingState>(
+ charging_state_as_int);
+
+ int battery_saver_state_as_int;
+ CHECK(phones_status_dict->GetInteger("batterySaverState",
+ &battery_saver_state_as_int));
+ auto battery_saver_state =
+ static_cast<phonehub::PhoneStatusModel::BatterySaverState>(
+ battery_saver_state_as_int);
+
+ int battery_percentage;
+ CHECK(
+ phones_status_dict->GetInteger("batteryPercentage", &battery_percentage));
+
+ phonehub::PhoneStatusModel::MobileConnectionMetadata connection_metadata = {
+ .signal_strength = signal_strength,
+ .mobile_provider = mobile_provider,
+ };
+ auto phone_status = phonehub::PhoneStatusModel(
+ mobile_status, connection_metadata, charging_state, battery_saver_state,
+ battery_percentage);
+ fake_phone_hub_manager_->mutable_phone_model()->SetPhoneStatusModel(
+ phone_status);
+
+ PA_LOG(VERBOSE) << "Set phone status to -"
+ << "\n mobile status: " << mobile_status
+ << "\n signal strength: " << signal_strength
+ << "\n mobile provider: " << mobile_provider
+ << "\n charging state: " << charging_state
+ << "\n battery saver state: " << battery_saver_state
+ << "\n battery percentage: " << battery_percentage;
+}
+
+void MultidevicePhoneHubHandler::HandleSetBrowserTabs(
+ const base::ListValue* args) {
+ const base::DictionaryValue* browser_tab_status_dict = nullptr;
+ CHECK(args->GetDictionary(0, &browser_tab_status_dict));
+ bool is_tab_sync_enabled;
+ CHECK(browser_tab_status_dict->GetBoolean("isTabSyncEnabled",
+ &is_tab_sync_enabled));
+
+ if (!is_tab_sync_enabled) {
+ fake_phone_hub_manager_->mutable_phone_model()->SetBrowserTabsModel(
+ phonehub::BrowserTabsModel(is_tab_sync_enabled));
+ PA_LOG(VERBOSE) << "Tab sync off; cleared browser tab metadata";
+ return;
+ }
+
+ std::vector<phonehub::BrowserTabsModel::BrowserTabMetadata> metadatas;
+ TryAddingMetadata("browserTabOneMetadata", browser_tab_status_dict,
+ metadatas);
+ TryAddingMetadata("browserTabTwoMetadata", browser_tab_status_dict,
+ metadatas);
+ TryAddingMetadata("browserTabThreeMetadata", browser_tab_status_dict,
+ metadatas);
+ TryAddingMetadata("browserTabFourMetadata", browser_tab_status_dict,
+ metadatas);
+
+ fake_phone_hub_manager_->mutable_phone_model()->SetBrowserTabsModel(
+ phonehub::BrowserTabsModel(is_tab_sync_enabled, metadatas));
+
+ auto browser_tabs_model =
+ fake_phone_hub_manager_->mutable_phone_model()->browser_tabs_model();
+ CHECK(browser_tabs_model.has_value());
+
+ // Log the most recently visited browser tab (at index 0) last.
+ for (int i = metadatas.size() - 1; i > -1; --i) {
+ PA_LOG(VERBOSE) << "Set most recent browser tab number " << i
+ << " to: " << browser_tabs_model->most_recent_tabs()[i];
+ }
+}
+
+void MultidevicePhoneHubHandler::HandleSetNotification(
+ const base::ListValue* args) {
+ const base::DictionaryValue* notification_data_dict = nullptr;
+ CHECK(args->GetDictionary(0, &notification_data_dict));
+
+ int id;
+ CHECK(notification_data_dict->GetInteger("id", &id));
+
+ const base::DictionaryValue* app_metadata_dict = nullptr;
+ CHECK(
+ notification_data_dict->GetDictionary("appMetadata", &app_metadata_dict));
+ phonehub::Notification::AppMetadata app_metadata =
+ DictToAppMetadata(app_metadata_dict);
+
+ // JavaScript time stamps don't fit in int.
+ double js_timestamp;
+ CHECK(notification_data_dict->GetDouble("timestamp", &js_timestamp));
+ auto timestamp = base::Time::FromJsTime(js_timestamp);
+
+ int importance_as_int;
+ CHECK(notification_data_dict->GetInteger("importance", &importance_as_int));
+ auto importance =
+ static_cast<phonehub::Notification::Importance>(importance_as_int);
+
+ int inline_reply_id;
+ CHECK(notification_data_dict->GetInteger("inlineReplyId", &inline_reply_id));
+
+ base::Optional<base::string16> opt_title;
+ base::string16 title;
+ if (notification_data_dict->GetString("title", &title) && !title.empty()) {
+ opt_title = title;
+ }
+
+ base::Optional<base::string16> opt_text_content;
+ base::string16 text_content;
+ if (notification_data_dict->GetString("textContent", &text_content) &&
+ !text_content.empty()) {
+ opt_text_content = text_content;
+ }
+
+ base::Optional<gfx::Image> opt_shared_image;
+ int shared_image_type_as_int;
+ if (notification_data_dict->GetInteger("sharedImage",
+ &shared_image_type_as_int) &&
+ shared_image_type_as_int) {
+ auto shared_image_type = static_cast<ImageType>(shared_image_type_as_int);
+ opt_shared_image = gfx::Image::CreateFrom1xBitmap(
+ ImageTypeToBitmap(shared_image_type, kSharedImageSize));
+ }
+
+ base::Optional<gfx::Image> opt_contact_image;
+ int contact_image_type_as_int;
+ if (notification_data_dict->GetInteger("contactImage",
+ &contact_image_type_as_int) &&
+ contact_image_type_as_int) {
+ auto shared_contact_image_type =
+ static_cast<ImageType>(contact_image_type_as_int);
+ opt_contact_image = gfx::Image::CreateFrom1xBitmap(
+ ImageTypeToBitmap(shared_contact_image_type, kContactImageSize));
+ }
+
+ auto notification = phonehub::Notification(
+ id, app_metadata, timestamp, importance, inline_reply_id, opt_title,
+ opt_text_content, opt_shared_image, opt_contact_image);
+
+ PA_LOG(VERBOSE) << "Set notification" << notification;
+ fake_phone_hub_manager_->fake_notification_manager()->SetNotification(
+ std::move(notification));
+}
+
+void MultidevicePhoneHubHandler::HandleRemoveNotification(
+ const base::ListValue* args) {
+ int notification_id = 0;
+ CHECK(args->GetInteger(0, &notification_id));
+ fake_phone_hub_manager_->fake_notification_manager()->RemoveNotification(
+ notification_id);
+ PA_LOG(VERBOSE) << "Removed notification with id " << notification_id;
+}
+
+} // namespace multidevice
+} // namespace chromeos
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
new file mode 100644
index 00000000000..e4f63bce095
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h
@@ -0,0 +1,91 @@
+// 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_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 "chromeos/components/phonehub/do_not_disturb_controller.h"
+#include "chromeos/components/phonehub/find_my_device_controller.h"
+#include "chromeos/components/phonehub/notification_manager.h"
+#include "chromeos/components/phonehub/tether_controller.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace chromeos {
+
+namespace phonehub {
+class FakePhoneHubManager;
+} // namespace phonehub
+
+namespace multidevice {
+
+// WebUIMessageHandler for chrome://multidevice-internals PhoneHub section.
+class MultidevicePhoneHubHandler
+ : public content::WebUIMessageHandler,
+ public phonehub::NotificationManager::Observer,
+ public phonehub::DoNotDisturbController::Observer,
+ public phonehub::FindMyDeviceController::Observer,
+ public phonehub::TetherController::Observer {
+ public:
+ MultidevicePhoneHubHandler();
+ MultidevicePhoneHubHandler(const MultidevicePhoneHubHandler&) = delete;
+ MultidevicePhoneHubHandler& operator=(const MultidevicePhoneHubHandler&) =
+ delete;
+ ~MultidevicePhoneHubHandler() override;
+
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override {}
+ void OnJavascriptDisallowed() override;
+
+ private:
+ // NotificationManager::Observer
+ void OnNotificationsRemoved(
+ const base::flat_set<int64_t>& notification_ids) override;
+
+ // DoNotDisturbController::Observer
+ void OnDndStateChanged() override;
+
+ // FindMyDeviceController::Observer
+ void OnPhoneRingingStateChanged() override;
+
+ // TetherController::Observer
+ void OnTetherStatusChanged() override;
+
+ void EnableRealPhoneHubManager();
+ void EnableFakePhoneHubManager();
+ void HandleEnableFakePhoneHubManager(const base::ListValue* args);
+ void HandleSetFeatureStatus(const base::ListValue* args);
+ void HandleSetShowOnboardingFlow(const base::ListValue* args);
+ void HandleSetFakePhoneName(const base::ListValue* args);
+ void HandleSetFakePhoneStatus(const base::ListValue* args);
+ void HandleSetBrowserTabs(const base::ListValue* args);
+ void HandleSetNotification(const base::ListValue* args);
+ void HandleRemoveNotification(const base::ListValue* args);
+ void HandleEnableDnd(const base::ListValue* args);
+ void HandleSetFindMyDeviceStatus(const base::ListValue* args);
+ void HandleSetTetherStatus(const base::ListValue* args);
+
+ void AddObservers();
+ 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};
+};
+
+} // namespace multidevice
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_INTERNALS_MULTIDEVICE_INTERNALS_PHONE_HUB_HANDLER_H_
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 0540e89b9eb..a71007911fc 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
@@ -6,10 +6,13 @@
#include "base/containers/span.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_logs_handler.h"
+#include "chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_phone_hub_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#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"
@@ -24,10 +27,10 @@ constexpr char kMultideviceInternalsGeneratedPath[] =
} // namespace
MultideviceInternalsUI::MultideviceInternalsUI(content::WebUI* web_ui)
- : ui::MojoWebUIController(web_ui) {
- Profile* profile = Profile::FromWebUI(web_ui);
+ : ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true) {
content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
chrome::kChromeUIMultiDeviceInternalsHost);
+ html_source->AddBoolean("isPhoneHubEnabled", features::IsPhoneHubEnabled());
webui::SetupWebUIDataSource(
html_source,
@@ -35,7 +38,11 @@ MultideviceInternalsUI::MultideviceInternalsUI(content::WebUI* web_ui)
kMultideviceInternalsResourcesSize),
kMultideviceInternalsGeneratedPath, IDR_MULTIDEVICE_INTERNALS_INDEX_HTML);
- content::WebUIDataSource::Add(profile, html_source);
+ content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
+ web_ui->AddMessageHandler(
+ std::make_unique<multidevice::MultideviceLogsHandler>());
+ web_ui->AddMessageHandler(
+ std::make_unique<multidevice::MultidevicePhoneHubHandler>());
}
MultideviceInternalsUI::~MultideviceInternalsUI() = default;
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 206d9f5794a..53bab12b446 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
@@ -52,6 +52,8 @@ constexpr webui::LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_OFFLINE_DEVICE_OPTION},
{"startSetupPageFeatureMirrorPhoneNotifications",
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MIRROR_PHONE_NOTIFICATIONS},
+ {"startSetupPageFeatureWifiSync",
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_WIFI_SYNC},
{"startSetupPageFeatureListInstallApps",
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_INSTALL_APPS_DESCRIPTION},
{"startSetupPageFeatureListAddFeatures",
@@ -130,6 +132,10 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
"phoneHubEnabled",
base::FeatureList::IsEnabled(chromeos::features::kPhoneHub));
+ html_source->AddBoolean(
+ "wifiSyncEnabled",
+ base::FeatureList::IsEnabled(chromeos::features::kWifiSyncAndroid));
+
for (const auto& entry : GetLocalizedStringsWithPlaceholders())
html_source->AddString(entry.name, entry.localized_string);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
index 9fee438fd85..d0d7e105749 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
@@ -58,6 +58,8 @@ constexpr char kOpenCellularActivationUi[] = "openCellularActivationUi";
constexpr char kShowNetworkDetails[] = "showNetworkDetails";
constexpr char kShowNetworkConfig[] = "showNetworkConfig";
constexpr char kShowAddNewWifiNetworkDialog[] = "showAddNewWifi";
+constexpr char kGetHostname[] = "getHostname";
+constexpr char kSetHostname[] = "setHostname";
bool GetServicePathFromGuid(const std::string& guid,
std::string* service_path) {
@@ -134,6 +136,14 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
kShowAddNewWifiNetworkDialog,
base::BindRepeating(&NetworkConfigMessageHandler::ShowAddNewWifi,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kGetHostname,
+ base::BindRepeating(&NetworkConfigMessageHandler::GetHostname,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kSetHostname,
+ base::BindRepeating(&NetworkConfigMessageHandler::SetHostname,
+ base::Unretained(this)));
}
private:
@@ -240,21 +250,17 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
}
void ShowNetworkDetails(const base::ListValue* arg_list) {
+ CHECK_EQ(1u, arg_list->GetSize());
std::string guid;
- if (!arg_list->GetString(0, &guid)) {
- NOTREACHED();
- return;
- }
+ CHECK(arg_list->GetString(0, &guid));
InternetDetailDialog::ShowDialog(guid);
}
void ShowNetworkConfig(const base::ListValue* arg_list) {
+ CHECK_EQ(1u, arg_list->GetSize());
std::string guid;
- if (!arg_list->GetString(0, &guid)) {
- NOTREACHED();
- return;
- }
+ CHECK(arg_list->GetString(0, &guid));
InternetConfigDialog::ShowDialogForNetworkId(guid);
}
@@ -281,6 +287,23 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
Respond(callback_id, return_arg_list);
}
+ void GetHostname(const base::ListValue* arg_list) {
+ CHECK_EQ(1u, arg_list->GetSize());
+ std::string callback_id;
+ CHECK(arg_list->GetString(0, &callback_id));
+ std::string hostname =
+ NetworkHandler::Get()->network_state_handler()->hostname();
+ Respond(callback_id, base::Value(hostname));
+ }
+
+ void SetHostname(const base::ListValue* arg_list) {
+ CHECK_EQ(1u, arg_list->GetSize());
+ std::string hostname;
+ CHECK(arg_list->GetString(0, &hostname));
+ NET_LOG(USER) << "SET HOSTNAME: " << hostname;
+ NetworkHandler::Get()->network_state_handler()->SetHostname(hostname);
+ }
+
void ErrorCallback(const std::string& callback_id,
const std::string& guid_or_type,
const std::string& function_name,
@@ -388,6 +411,9 @@ void NetworkUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
l10n_util::GetStringUTF16(IDS_NETWORK_UI_FORMAT_SHILL));
localized_strings->SetString(
+ "dhcpHostnameLabel",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_DHCP_HOSTNAME));
+ localized_strings->SetString(
"globalPolicyLabel",
l10n_util::GetStringUTF16(IDS_NETWORK_UI_GLOBAL_POLICY));
localized_strings->SetString(
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 8bd9a19b587..1bdc57642a1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
@@ -8,8 +8,8 @@
#include <memory>
+#include "ash/public/cpp/child_accounts/parent_access_controller.h"
#include "ash/public/cpp/login_screen.h"
-#include "ash/public/cpp/login_types.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/build_time.h"
@@ -125,8 +125,7 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
void DoneClicked(const base::ListValue* args) {
if (!parent_access::ParentAccessService::IsApprovalRequired(
- parent_access::ParentAccessService::SupervisedAction::
- kUpdateClock)) {
+ ash::SupervisedAction::kUpdateClock)) {
OnParentAccessValidation(true);
return;
}
@@ -143,11 +142,11 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
account_id =
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId();
}
- ash::LoginScreen::Get()->ShowParentAccessWidget(
+ ash::ParentAccessController::Get()->ShowWidget(
account_id,
base::BindOnce(&SetTimeMessageHandler::OnParentAccessValidation,
weak_factory_.GetWeakPtr()),
- ash::ParentAccessRequestReason::kChangeTime,
+ ash::SupervisedAction::kUpdateClock,
!is_user_logged_in /* extra_dimmer */,
base::Time::FromDoubleT(seconds));
}
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 234b0c8085c..46e28367e13 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
@@ -20,9 +20,9 @@
#include "components/prefs/pref_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_ui.h"
-#include "content/public/common/web_preferences.h"
#include "content/public/test/browser_test.h"
#include "third_party/blink/public/common/page/page_zoom.h"
+#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "ui/aura/client/aura_constants.h"
#include "url/gurl.h"
@@ -99,7 +99,7 @@ IN_PROC_BROWSER_TEST_F(SystemWebDialogTest, InstanceTest) {
}
IN_PROC_BROWSER_TEST_F(SystemWebDialogTest, FontSize) {
- const content::WebPreferences kDefaultPrefs;
+ const blink::web_pref::WebPreferences kDefaultPrefs;
const int kDefaultFontSize = kDefaultPrefs.default_font_size;
const int kDefaultFixedFontSize = kDefaultPrefs.default_fixed_font_size;
@@ -115,7 +115,7 @@ IN_PROC_BROWSER_TEST_F(SystemWebDialogTest, FontSize) {
dialog->ShowSystemDialog();
// Dialog font sizes are still the default values.
- content::WebPreferences dialog_prefs =
+ blink::web_pref::WebPreferences dialog_prefs =
dialog->GetWebUIForTest()->GetWebContents()->GetOrCreateWebPreferences();
EXPECT_EQ(kDefaultFontSize, dialog_prefs.default_font_size);
EXPECT_EQ(kDefaultFixedFontSize, dialog_prefs.default_fixed_font_size);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.cc b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.cc
index 69d0ad4f5e9..cca6f771d6f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.cc
@@ -102,6 +102,7 @@ gfx::Size SystemWebDialogDelegate::ComputeDialogSizeForInternalScreen(
SystemWebDialogDelegate::SystemWebDialogDelegate(const GURL& gurl,
const base::string16& title)
: gurl_(gurl), title_(title), modal_type_(ui::MODAL_TYPE_NONE) {
+ set_can_resize(false);
switch (session_manager::SessionManager::Get()->session_state()) {
// Normally system dialogs are not modal.
case session_manager::SessionState::UNKNOWN:
@@ -161,10 +162,6 @@ void SystemWebDialogDelegate::GetDialogSize(gfx::Size* size) const {
size->SetSize(kDialogWidth, kDialogHeight);
}
-bool SystemWebDialogDelegate::CanResizeDialog() const {
- return false;
-}
-
std::string SystemWebDialogDelegate::GetDialogArgs() const {
return std::string();
}
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 9f35218c466..865950bd641 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
@@ -73,7 +73,6 @@ class SystemWebDialogDelegate : public ui::WebDialogDelegate {
void GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const override;
void GetDialogSize(gfx::Size* size) const override;
- bool CanResizeDialog() const override;
std::string GetDialogArgs() const override;
void OnDialogShown(content::WebUI* webui) override;
// Note: deletes |this|.
diff --git a/chromium/chrome/browser/ui/webui/commander/commander_handler.cc b/chromium/chrome/browser/ui/webui/commander/commander_handler.cc
new file mode 100644
index 00000000000..6b6173e0360
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/commander/commander_handler.cc
@@ -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.
+
+#include "chrome/browser/ui/webui/commander/commander_handler.h"
+
+#include "base/bind.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ui/commander/commander_view_model.h"
+
+const char CommanderHandler::Delegate::kKey[] =
+ "CommanderHandler::Delegate::kKey";
+CommanderHandler::CommanderHandler() = default;
+CommanderHandler::~CommanderHandler() = default;
+
+void CommanderHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "textChanged", base::BindRepeating(&CommanderHandler::HandleTextChanged,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "optionSelected",
+ base::BindRepeating(&CommanderHandler::HandleOptionSelected,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "dismiss", base::BindRepeating(&CommanderHandler::HandleDismiss,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "heightChanged",
+ base::BindRepeating(&CommanderHandler::HandleHeightChanged,
+ base::Unretained(this)));
+}
+
+void CommanderHandler::OnJavascriptDisallowed() {
+ if (delegate_)
+ delegate_->OnHandlerEnabled(false);
+}
+
+void CommanderHandler::OnJavascriptAllowed() {
+ if (delegate_)
+ delegate_->OnHandlerEnabled(true);
+}
+
+void CommanderHandler::HandleTextChanged(const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(1u, args->GetSize());
+ std::string text = args->GetList()[0].GetString();
+ if (delegate_)
+ delegate_->OnTextChanged(base::UTF8ToUTF16(text));
+}
+
+void CommanderHandler::HandleOptionSelected(const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(2u, args->GetSize());
+ int index = args->GetList()[0].GetInt();
+ int result_set_id = args->GetList()[1].GetInt();
+ if (delegate_)
+ delegate_->OnOptionSelected(index, result_set_id);
+}
+
+void CommanderHandler::HandleDismiss(const base::ListValue* args) {
+ if (delegate_)
+ delegate_->OnDismiss();
+}
+
+void CommanderHandler::HandleHeightChanged(const base::ListValue* args) {
+ CHECK_EQ(1u, args->GetSize());
+ int new_height = args->GetList()[0].GetInt();
+ if (delegate_)
+ delegate_->OnHeightChanged(new_height);
+}
+
+void CommanderHandler::ViewModelUpdated(
+ commander::CommanderViewModel view_model) {
+ if (view_model.action ==
+ commander::CommanderViewModel::Action::kDisplayResults) {
+ base::Value list(base::Value::Type::LIST);
+ for (commander::CommandItemViewModel& item : view_model.items) {
+ // TODO(lgrey): This is temporary, just so we can display something.
+ // We will also need to pass on the result set id, and match ranges for
+ // each item.
+ list.Append(item.title);
+ }
+ FireWebUIListener("view-model-updated", list);
+ } else {
+ DCHECK_EQ(view_model.action,
+ commander::CommanderViewModel::Action::kPrompt);
+ // TODO(lgrey): Handle kPrompt. kDismiss is handled higher up the stack.
+ }
+}
diff --git a/chromium/chrome/browser/ui/webui/commander/commander_handler.h b/chromium/chrome/browser/ui/webui/commander/commander_handler.h
new file mode 100644
index 00000000000..ce89400aea6
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/commander/commander_handler.h
@@ -0,0 +1,73 @@
+// 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_COMMANDER_COMMANDER_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_COMMANDER_COMMANDER_HANDLER_H_
+
+#include "chrome/browser/ui/commander/commander_view_model.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+// Handles serializing and unserializing communication between the commander
+// backend and WebUI interface.
+class CommanderHandler : public content::WebUIMessageHandler {
+ public:
+ // The delegate allows CommanderHandler to send messages up to the
+ // browser-side commander system.
+ class Delegate {
+ public:
+ // The key under which the delegate is expected to be stashed in the
+ // containing web contents.
+ static const char kKey[];
+ // Called when the text is changed in the WebUI interface.
+ virtual void OnTextChanged(const base::string16& text) = 0;
+ // Called when an option is selected (clicked or enter pressed) in the WebUI
+ // interface.
+ virtual void OnOptionSelected(size_t option_index, int result_set_id) = 0;
+ // Called when the WebUI interface wants to dismiss the UI.
+ virtual void OnDismiss() = 0;
+ // Called when the WebUI interface's content height has changed.
+ virtual void OnHeightChanged(int new_height) = 0;
+ // Called when the web interface's availability changes (for example, if
+ // the renderer crashes, this should be called with false).
+ virtual void OnHandlerEnabled(bool is_enabled) = 0;
+ };
+ CommanderHandler();
+ ~CommanderHandler() override;
+
+ // Called when a new view model should be displayed.
+ void ViewModelUpdated(commander::CommanderViewModel view_model);
+
+ void set_delegate(Delegate* delegate) { delegate_ = delegate; }
+
+ // WebUIMessageHandler overrides.
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ private:
+ // WebUI message handlers
+
+ // Handles text changes in the primary textfield. Expects a single string
+ // argument.
+ void HandleTextChanged(const base::ListValue* args);
+
+ // Handles the user selecting one of the available command options.
+ // Expects two numeric argument representing the index of the chosen command,
+ // and the result set id of the active view model (see documentation in
+ // commander::CommanderViewModel).
+ void HandleOptionSelected(const base::ListValue* args);
+
+ // Handles the user pressing "Escape", or otherwise indicating they would
+ // like to dismiss the UI. No arguments expected.
+ void HandleDismiss(const base::ListValue* args);
+
+ // Handles the display height of the UI changing. Expects one numeric argument
+ // representing the new height.
+ void HandleHeightChanged(const base::ListValue* args);
+
+ Delegate* delegate_ = nullptr;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_COMMANDER_COMMANDER_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/commander/commander_ui.cc b/chromium/chrome/browser/ui/webui/commander/commander_ui.cc
new file mode 100644
index 00000000000..f4b5a5ce33c
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/commander/commander_ui.cc
@@ -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.
+
+#include "chrome/browser/ui/webui/commander/commander_ui.h"
+
+#include <memory>
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/commander/commander_handler.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/browser_resources.h"
+#include "content/public/browser/web_ui_data_source.h"
+
+CommanderUI::CommanderUI(content::WebUI* web_ui)
+ : content::WebUIController(web_ui) {
+ auto handler = std::make_unique<CommanderHandler>();
+ handler_ = handler.get();
+ web_ui->AddMessageHandler(std::move(handler));
+
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUICommanderHost);
+ source->AddResourcePath("index.html", IDR_COMMANDER_HTML);
+ source->SetDefaultResource(IDR_COMMANDER_HTML);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, source);
+}
+
+CommanderUI::~CommanderUI() = default;
diff --git a/chromium/chrome/browser/ui/webui/commander/commander_ui.h b/chromium/chrome/browser/ui/webui/commander/commander_ui.h
new file mode 100644
index 00000000000..1a922f76395
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/commander/commander_ui.h
@@ -0,0 +1,28 @@
+// 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_COMMANDER_COMMANDER_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_COMMANDER_COMMANDER_UI_H_
+
+#include "content/public/browser/web_ui_controller.h"
+
+class CommanderHandler;
+
+// Entry point for the Commander WebUI interface.
+class CommanderUI : public content::WebUIController {
+ public:
+ explicit CommanderUI(content::WebUI* web_ui);
+ ~CommanderUI() override;
+
+ // Disallow copy and assign
+ CommanderUI(const CommanderUI& other) = delete;
+ CommanderUI& operator=(const CommanderUI& other) = delete;
+
+ CommanderHandler* handler() { return handler_; }
+
+ private:
+ CommanderHandler* handler_;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_COMMANDER_COMMANDER_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/commander/commander_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/commander/commander_ui_browsertest.cc
new file mode 100644
index 00000000000..79922b9ceb7
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/commander/commander_ui_browsertest.cc
@@ -0,0 +1,137 @@
+// 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/commander/commander_ui.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/commander/commander_view_model.h"
+#include "chrome/browser/ui/webui/commander/commander_handler.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/browser/navigation_controller.h"
+#include "content/public/test/browser_test.h"
+#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/test_web_ui.h"
+
+namespace {
+
+class TestCommanderHandler : public CommanderHandler {
+ public:
+ explicit TestCommanderHandler(content::WebUI* web_ui) { set_web_ui(web_ui); }
+};
+
+} // namespace
+
+// This actually tests the whole WebUI communication layer as a unit:
+// CommanderUI and CommanderHandler.
+class CommanderUITest : public InProcessBrowserTest,
+ public CommanderHandler::Delegate {
+ public:
+ void SetUpOnMainThread() override {
+ contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(browser()->profile()));
+ contents_->GetController().LoadURL(
+ GURL(chrome::kChromeUICommanderURL), content::Referrer(),
+ ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
+ CommanderUI* controller =
+ static_cast<CommanderUI*>(contents_->GetWebUI()->GetController());
+ controller->handler()->set_delegate(this);
+
+ ASSERT_TRUE(content::WaitForLoadStop(contents_.get()));
+ EXPECT_EQ(contents_->GetLastCommittedURL().host(),
+ chrome::kChromeUICommanderHost);
+ }
+ void TearDownOnMainThread() override {
+ contents_.reset();
+ dismiss_invocation_count_ = 0;
+ text_changed_invocations_.clear();
+ option_selected_invocations_.clear();
+ height_changed_invocations_.clear();
+ }
+
+ protected:
+ void ExecuteJS(std::string js) {
+ ASSERT_TRUE(content::ExecuteScript(contents_.get(), js));
+ }
+ // CommanderHandler::Delegate implementation.
+ void OnTextChanged(const base::string16& text) override {
+ text_changed_invocations_.push_back(text);
+ }
+ void OnOptionSelected(size_t option_index, int result_set_id) override {
+ option_selected_invocations_.emplace_back(option_index, result_set_id);
+ }
+
+ void OnDismiss() override { dismiss_invocation_count_++; }
+
+ void OnHeightChanged(int new_height) override {
+ height_changed_invocations_.emplace_back(new_height);
+ }
+ void OnHandlerEnabled(bool enabled) override {}
+
+ const std::vector<base::string16> text_changed_invocations() {
+ return text_changed_invocations_;
+ }
+ const std::vector<std::pair<size_t, int>> option_selected_invocations() {
+ return option_selected_invocations_;
+ }
+ const std::vector<int> height_changed_invocations() {
+ return height_changed_invocations_;
+ }
+
+ size_t dismiss_invocation_count() { return dismiss_invocation_count_; }
+
+ private:
+ std::unique_ptr<content::WebContents> contents_;
+ size_t dismiss_invocation_count_ = 0;
+ std::vector<base::string16> text_changed_invocations_;
+ std::vector<std::pair<size_t, int>> option_selected_invocations_;
+ std::vector<int> height_changed_invocations_;
+};
+
+IN_PROC_BROWSER_TEST_F(CommanderUITest, Dismiss) {
+ EXPECT_EQ(dismiss_invocation_count(), 0u);
+ ExecuteJS("chrome.send('dismiss')");
+ EXPECT_EQ(dismiss_invocation_count(), 1u);
+}
+
+IN_PROC_BROWSER_TEST_F(CommanderUITest, HeightChanged) {
+ EXPECT_EQ(height_changed_invocations().size(), 0u);
+ ExecuteJS("chrome.send('heightChanged', [42])");
+ ASSERT_EQ(height_changed_invocations().size(), 1u);
+ ASSERT_EQ(height_changed_invocations().back(), 42);
+}
+
+IN_PROC_BROWSER_TEST_F(CommanderUITest, TextChanged) {
+ EXPECT_EQ(text_changed_invocations().size(), 0u);
+ ExecuteJS("chrome.send('textChanged', ['orange'])");
+ ASSERT_EQ(text_changed_invocations().size(), 1u);
+ ASSERT_EQ(text_changed_invocations().back(), base::ASCIIToUTF16("orange"));
+}
+
+IN_PROC_BROWSER_TEST_F(CommanderUITest, OptionSelected) {
+ EXPECT_EQ(option_selected_invocations().size(), 0u);
+ ExecuteJS("chrome.send('optionSelected', [13, 586])");
+ ASSERT_EQ(option_selected_invocations().size(), 1u);
+ std::pair<size_t, int> expected({13, 586});
+ ASSERT_EQ(option_selected_invocations().back(), expected);
+}
+
+TEST(CommanderHandlerTest, ViewModelPassed) {
+ content::TestWebUI test_web_ui;
+ auto handler = std::make_unique<TestCommanderHandler>(&test_web_ui);
+ commander::CommanderViewModel vm;
+ vm.action = commander::CommanderViewModel::Action::kDisplayResults;
+ base::string16 item_title = base::ASCIIToUTF16("Test item");
+ std::vector<gfx::Range> item_ranges;
+ vm.items.emplace_back(item_title, item_ranges);
+ handler->AllowJavascriptForTesting();
+ handler->ViewModelUpdated(std::move(vm));
+ const content::TestWebUI::CallData& call_data =
+ *test_web_ui.call_data().back();
+ EXPECT_EQ("cr.webUIListenerCallback", call_data.function_name());
+ EXPECT_EQ("view-model-updated", call_data.arg1()->GetString());
+ EXPECT_EQ("Test item", call_data.arg2()->GetList()[0].GetString());
+}
diff --git a/chromium/chrome/browser/ui/webui/customize_themes/OWNERS b/chromium/chrome/browser/ui/webui/customize_themes/OWNERS
new file mode 100644
index 00000000000..a34c1250dcc
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/customize_themes/OWNERS
@@ -0,0 +1 @@
+file://ui/webui/resources/cr_components/customize_themes/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/customize_themes/README b/chromium/chrome/browser/ui/webui/customize_themes/README
new file mode 100644
index 00000000000..00f45b45b5e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/customize_themes/README
@@ -0,0 +1,6 @@
+This directory contains the native Chrome handler implementation of the
+cr-customize-themes webUI component. The component allows the user to choose a
+color that Chrome will use to generate a new theme.
+
+The handler implements the CustomizeThemesHandler Mojo interface defined in
+//ui/webui/resources/cr_components/customize_themes/customize_themes.mojom
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
new file mode 100644
index 00000000000..d3548c76002
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.cc
@@ -0,0 +1,157 @@
+// 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/customize_themes/chrome_customize_themes_handler.h"
+
+#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search/chrome_colors/chrome_colors_factory.h"
+#include "chrome/browser/search/chrome_colors/chrome_colors_service.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/common/search/generated_colors_info.h"
+#include "chrome/common/themes/autogenerated_theme_util.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_source.h"
+#include "content/public/browser/web_contents.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/common/extension.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/webui/resources/cr_components/customize_themes/customize_themes.mojom.h"
+
+ChromeCustomizeThemesHandler::ChromeCustomizeThemesHandler(
+ mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
+ pending_client,
+ mojo::PendingReceiver<customize_themes::mojom::CustomizeThemesHandler>
+ pending_handler,
+ content::WebContents* web_contents,
+ Profile* profile)
+ : remote_client_(std::move(pending_client)),
+ receiver_(this, std::move(pending_handler)),
+ web_contents_(web_contents),
+ profile_(profile),
+ chrome_colors_service_(
+ chrome_colors::ChromeColorsFactory::GetForProfile(profile_)),
+ theme_service_(ThemeServiceFactory::GetForProfile(profile_)) {
+ CHECK(web_contents_);
+ CHECK(profile_);
+ CHECK(chrome_colors_service_);
+ CHECK(theme_service_);
+ notification_registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
+ content::NotificationService::AllSources());
+}
+
+ChromeCustomizeThemesHandler::~ChromeCustomizeThemesHandler() {
+ // Revert any unconfirmed theme changes.
+ chrome_colors_service_->RevertThemeChangesForTab(web_contents_);
+}
+
+void ChromeCustomizeThemesHandler::ApplyAutogeneratedTheme(
+ const SkColor& frame_color) {
+ chrome_colors_service_->ApplyAutogeneratedTheme(frame_color, web_contents_);
+}
+
+void ChromeCustomizeThemesHandler::ApplyDefaultTheme() {
+ chrome_colors_service_->ApplyDefaultTheme(web_contents_);
+}
+
+void ChromeCustomizeThemesHandler::ApplyChromeTheme(int32_t id) {
+ auto* begin = std::begin(chrome_colors::kGeneratedColorsInfo);
+ auto* end = std::end(chrome_colors::kGeneratedColorsInfo);
+ auto* result = std::find_if(begin, end,
+ [id](const chrome_colors::ColorInfo& color_info) {
+ return color_info.id == id;
+ });
+ if (result == end)
+ return;
+ chrome_colors_service_->ApplyAutogeneratedTheme(result->color, web_contents_);
+}
+
+void ChromeCustomizeThemesHandler::InitializeTheme() {
+ UpdateTheme();
+}
+
+void ChromeCustomizeThemesHandler::GetChromeThemes(
+ GetChromeThemesCallback callback) {
+ std::vector<customize_themes::mojom::ChromeThemePtr> themes;
+ for (const auto& color_info : chrome_colors::kGeneratedColorsInfo) {
+ auto theme_colors = GetAutogeneratedThemeColors(color_info.color);
+ auto theme = customize_themes::mojom::ChromeTheme::New();
+ theme->id = color_info.id;
+ theme->label = l10n_util::GetStringUTF8(color_info.label_id);
+ auto colors = customize_themes::mojom::ThemeColors::New();
+ colors->frame = theme_colors.frame_color;
+ colors->active_tab = theme_colors.active_tab_color;
+ colors->active_tab_text = theme_colors.active_tab_text_color;
+ theme->colors = std::move(colors);
+ themes.push_back(std::move(theme));
+ }
+ std::move(callback).Run(std::move(themes));
+}
+
+void ChromeCustomizeThemesHandler::ConfirmThemeChanges() {
+ chrome_colors_service_->ConfirmThemeChanges();
+}
+
+void ChromeCustomizeThemesHandler::RevertThemeChanges() {
+ chrome_colors_service_->RevertThemeChanges();
+}
+
+void ChromeCustomizeThemesHandler::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED);
+ UpdateTheme();
+}
+
+void ChromeCustomizeThemesHandler::UpdateTheme() {
+ auto theme = customize_themes::mojom::Theme::New();
+
+ const ui::ThemeProvider& theme_provider =
+ ThemeService::GetThemeProviderForProfile(profile_);
+
+ if (theme_service_->UsingDefaultTheme() ||
+ theme_service_->UsingSystemTheme()) {
+ theme->type = customize_themes::mojom::ThemeType::kDefault;
+ theme->info = customize_themes::mojom::ThemeInfo::NewChromeThemeId(-1);
+ } else if (theme_service_->UsingExtensionTheme()) {
+ theme->type = customize_themes::mojom::ThemeType::kThirdParty;
+ auto info = customize_themes::mojom::ThirdPartyThemeInfo::New();
+ const extensions::Extension* theme_extension =
+ extensions::ExtensionRegistry::Get(profile_)
+ ->enabled_extensions()
+ .GetByID(theme_service_->GetThemeID());
+ if (theme_extension) {
+ info->id = theme_extension->id();
+ info->name = theme_extension->name();
+ }
+ theme->info = customize_themes::mojom::ThemeInfo::NewThirdPartyThemeInfo(
+ std::move(info));
+ } else {
+ DCHECK(theme_service_->UsingAutogeneratedTheme());
+ int color_id = chrome_colors::ChromeColorsService::GetColorId(
+ theme_service_->GetAutogeneratedThemeColor());
+ if (color_id > 0) {
+ theme->type = customize_themes::mojom::ThemeType::kChrome;
+ theme->info =
+ customize_themes::mojom::ThemeInfo::NewChromeThemeId(color_id);
+ } else {
+ theme->type = customize_themes::mojom::ThemeType::kAutogenerated;
+ auto theme_colors = customize_themes::mojom::ThemeColors::New();
+ theme_colors->frame =
+ theme_provider.GetColor(ThemeProperties::COLOR_FRAME_ACTIVE);
+ theme_colors->active_tab =
+ theme_provider.GetColor(ThemeProperties::COLOR_NTP_BACKGROUND);
+ theme_colors->active_tab_text =
+ theme_provider.GetColor(ThemeProperties::COLOR_NTP_TEXT);
+ theme->info =
+ customize_themes::mojom::ThemeInfo::NewAutogeneratedThemeColors(
+ std::move(theme_colors));
+ }
+ }
+
+ remote_client_->SetTheme(std::move(theme));
+}
diff --git a/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h b/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h
new file mode 100644
index 00000000000..52ffdc6615f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler.h
@@ -0,0 +1,74 @@
+// 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_CUSTOMIZE_THEMES_CHROME_CUSTOMIZE_THEMES_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CUSTOMIZE_THEMES_CHROME_CUSTOMIZE_THEMES_HANDLER_H_
+
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.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 "ui/webui/resources/cr_components/customize_themes/customize_themes.mojom.h"
+
+namespace chrome_colors {
+class ChromeColorsService;
+}
+
+namespace content {
+class WebContents;
+}
+
+class Profile;
+class ThemeService;
+
+// Implementation of the customize_themes::mojom::CustomizeThemesHandler
+// interface.
+//
+// Supports profile theme changes originating from the CustomizeThemesHandler
+// remote, by utilizing ChromeColorsService. Notifies the CustomizeThemesClient
+// receiver about all theme updates in the current profile.
+class ChromeCustomizeThemesHandler
+ : public customize_themes::mojom::CustomizeThemesHandler,
+ public content::NotificationObserver {
+ public:
+ explicit ChromeCustomizeThemesHandler(
+ mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
+ pending_client,
+ mojo::PendingReceiver<customize_themes::mojom::CustomizeThemesHandler>
+ pending_handler,
+ content::WebContents* web_contents,
+ Profile* profile);
+ ~ChromeCustomizeThemesHandler() override;
+
+ // customize_themes::mojom::CustomizeThemesHandler:
+ void ApplyAutogeneratedTheme(const SkColor& frame_color) override;
+ void ApplyDefaultTheme() override;
+ void ApplyChromeTheme(int32_t id) override;
+ void InitializeTheme() override;
+ void GetChromeThemes(GetChromeThemesCallback callback) override;
+ void ConfirmThemeChanges() override;
+ void RevertThemeChanges() override;
+
+ // content::NotificationObserver:
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+ private:
+ void UpdateTheme();
+
+ mojo::Remote<customize_themes::mojom::CustomizeThemesClient> remote_client_;
+ mojo::Receiver<customize_themes::mojom::CustomizeThemesHandler> receiver_;
+
+ content::WebContents* const web_contents_;
+ Profile* const profile_;
+ chrome_colors::ChromeColorsService* const chrome_colors_service_;
+ ThemeService* const theme_service_;
+
+ content::NotificationRegistrar notification_registrar_;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_CUSTOMIZE_THEMES_CHROME_CUSTOMIZE_THEMES_HANDLER_H_
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
new file mode 100644
index 00000000000..8d79d566233
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/customize_themes/chrome_customize_themes_handler_unittest.cc
@@ -0,0 +1,293 @@
+// 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/customize_themes/chrome_customize_themes_handler.h"
+
+#include <string>
+
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/json/json_reader.h"
+#include "base/optional.h"
+#include "base/path_service.h"
+#include "base/run_loop.h"
+#include "base/test/bind_test_util.h"
+#include "base/values.h"
+#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/extensions/test_extension_environment.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/search/generated_colors_info.h"
+#include "chrome/common/search/selected_colors_info.h"
+#include "chrome/common/themes/autogenerated_theme_util.h"
+#include "chrome/test/base/testing_profile.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_task_environment.h"
+#include "content/public/test/test_utils.h"
+#include "content/public/test/test_web_contents_factory.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/pending_remote.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/webui/resources/cr_components/customize_themes/customize_themes.mojom.h"
+
+using testing::_;
+using testing::NiceMock;
+using testing::Pointwise;
+
+namespace {
+
+constexpr char kThemeExtensionName[] = "minimal";
+// Extension id must have a valid format.
+constexpr char kThemeExtensionId[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+
+class MockCustomizeThemesClient
+ : public customize_themes::mojom::CustomizeThemesClient {
+ public:
+ MockCustomizeThemesClient() = default;
+ ~MockCustomizeThemesClient() override = default;
+
+ mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
+ BindAndGetRemote() {
+ DCHECK(!receiver_.is_bound());
+ return receiver_.BindNewPipeAndPassRemote();
+ }
+
+ MOCK_METHOD(void, SetTheme, (customize_themes::mojom::ThemePtr), (override));
+
+ mojo::Receiver<customize_themes::mojom::CustomizeThemesClient> receiver_{
+ this};
+};
+
+bool VerifyThemeColors(const customize_themes::mojom::ThemeColors& theme_colors,
+ SkColor original_color) {
+ AutogeneratedThemeColors expected_colors =
+ GetAutogeneratedThemeColors(original_color);
+ return theme_colors.frame == expected_colors.frame_color &&
+ theme_colors.active_tab == expected_colors.active_tab_color &&
+ theme_colors.active_tab_text == expected_colors.active_tab_text_color;
+}
+
+SkColor GetChromeThemeColorById(int chrome_theme_id) {
+ for (const auto& color_info : chrome_colors::kGeneratedColorsInfo) {
+ if (color_info.id == chrome_theme_id)
+ return color_info.color;
+ }
+
+ ADD_FAILURE() << "Couldn't find ColorInfo with id=" << chrome_theme_id;
+ return SK_ColorTRANSPARENT;
+}
+
+// Matches a customize_themes::mojom::ThemePtr argument with an autogenerated
+// theme with `color`.
+MATCHER_P(MatchesAutogeneratedTheme, color, "") {
+ return arg->type == customize_themes::mojom::ThemeType::kAutogenerated &&
+ arg->info->is_autogenerated_theme_colors() &&
+ VerifyThemeColors(*arg->info->get_autogenerated_theme_colors(), color);
+}
+
+// Matches a customize_themes::mojom::ThemePtr argument with the default theme.
+MATCHER(MatchesDefaultTheme, "") {
+ return arg->type == customize_themes::mojom::ThemeType::kDefault;
+}
+
+// Matches a customize_themes::mojom::ThemePtr argument with a Chrome theme with
+// `theme_id`.
+MATCHER_P(MatchesChromeTheme, theme_id, "") {
+ return arg->type == customize_themes::mojom::ThemeType::kChrome &&
+ arg->info->is_chrome_theme_id() &&
+ arg->info->get_chrome_theme_id() == theme_id;
+}
+
+// Matches a customize_themes::mojom::ThemePtr argument with a third party theme
+// with `extension_id` and `name`.
+MATCHER_P2(MatchesThirdPartyTheme, extension_id, name, "") {
+ return arg->type == customize_themes::mojom::ThemeType::kThirdParty &&
+ arg->info->is_third_party_theme_info() &&
+ arg->info->get_third_party_theme_info()->id == extension_id &&
+ arg->info->get_third_party_theme_info()->name == name;
+}
+
+// Matches two elements in std::tuple<customize_themes::mojom::ChromeThemePtr,
+// chrome_colors::ColorInfo>.
+// Useful for matching two containers with testing::Pointwise().
+MATCHER(MatchesColorInfo, "") {
+ const customize_themes::mojom::ChromeThemePtr& chrome_theme =
+ std::get<0>(arg);
+ const chrome_colors::ColorInfo& color_info = std::get<1>(arg);
+ return chrome_theme->id == color_info.id &&
+ VerifyThemeColors(*chrome_theme->colors, color_info.color);
+}
+
+} // namespace
+
+class ChromeCustomizeThemesHandlerTest : public testing::Test {
+ public:
+ ChromeCustomizeThemesHandlerTest()
+ : web_contents_(factory_.CreateWebContents(profile())),
+ handler_(std::make_unique<ChromeCustomizeThemesHandler>(
+ mock_client_.BindAndGetRemote(),
+ mojo::PendingReceiver<
+ customize_themes::mojom::CustomizeThemesHandler>(),
+ web_contents_,
+ profile())) {}
+
+ void TearDown() override {
+ if (handler_) {
+ // Confirm all pending changes to not trigger a revert on destruction.
+ handler_->ConfirmThemeChanges();
+ }
+ }
+
+ void ResetHandler() { handler_.reset(); }
+
+ extensions::TestExtensionEnvironment* env() {
+ return &extension_environment_;
+ }
+
+ Profile* profile() { return extension_environment_.profile(); }
+
+ ChromeCustomizeThemesHandler* handler() { return handler_.get(); }
+
+ MockCustomizeThemesClient* mock_client() { return &mock_client_; }
+
+ ThemeService* theme_service() {
+ return ThemeServiceFactory::GetForProfile(profile());
+ }
+
+ private:
+ extensions::TestExtensionEnvironment extension_environment_;
+ NiceMock<MockCustomizeThemesClient> mock_client_;
+ content::TestWebContentsFactory factory_;
+ content::WebContents* web_contents_; // Weak. Owned by factory_.
+ std::unique_ptr<ChromeCustomizeThemesHandler> handler_;
+};
+
+TEST_F(ChromeCustomizeThemesHandlerTest, ApplyAutogeneratedTheme) {
+ constexpr SkColor kAutogeneratedThemeColor = SK_ColorBLUE;
+ EXPECT_CALL(*mock_client(),
+ SetTheme(MatchesAutogeneratedTheme(kAutogeneratedThemeColor)));
+ handler()->ApplyAutogeneratedTheme(kAutogeneratedThemeColor);
+ EXPECT_TRUE(theme_service()->UsingAutogeneratedTheme());
+ EXPECT_EQ(kAutogeneratedThemeColor,
+ theme_service()->GetAutogeneratedThemeColor());
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, ApplyDefaultTheme) {
+ EXPECT_CALL(*mock_client(), SetTheme(MatchesDefaultTheme()));
+ handler()->ApplyDefaultTheme();
+ EXPECT_TRUE(theme_service()->UsingDefaultTheme());
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, ApplyChromeTheme) {
+ constexpr int kChromeThemeId = 4;
+ EXPECT_CALL(*mock_client(), SetTheme(MatchesChromeTheme(kChromeThemeId)));
+ handler()->ApplyChromeTheme(kChromeThemeId);
+ EXPECT_TRUE(theme_service()->UsingAutogeneratedTheme());
+ EXPECT_EQ(GetChromeThemeColorById(kChromeThemeId),
+ theme_service()->GetAutogeneratedThemeColor());
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, InitializeTheme) {
+ EXPECT_CALL(*mock_client(), SetTheme(_));
+ handler()->InitializeTheme();
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, GetChromeThemes) {
+ base::RunLoop run_loop;
+ std::vector<customize_themes::mojom::ChromeThemePtr> chrome_themes;
+
+ handler()->GetChromeThemes(base::BindLambdaForTesting(
+ [&](std::vector<customize_themes::mojom::ChromeThemePtr> themes) {
+ chrome_themes = std::move(themes);
+ run_loop.Quit();
+ }));
+ run_loop.Run();
+
+ std::vector<chrome_colors::ColorInfo> generated_colors_info(
+ std::begin(chrome_colors::kGeneratedColorsInfo),
+ std::end(chrome_colors::kGeneratedColorsInfo));
+ EXPECT_THAT(chrome_themes,
+ Pointwise(MatchesColorInfo(), generated_colors_info));
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, ObserveThemeChanges) {
+ constexpr SkColor kAutogeneratedThemeColor = SK_ColorBLUE;
+ EXPECT_CALL(*mock_client(),
+ SetTheme(MatchesAutogeneratedTheme(kAutogeneratedThemeColor)));
+ theme_service()->BuildAutogeneratedThemeFromColor(kAutogeneratedThemeColor);
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, InstallThirdPartyTheme) {
+ // Read and parse an extension theme manifest from a test file.
+ base::FilePath test_data_dir;
+ ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
+ base::FilePath manifest_path =
+ test_data_dir.AppendASCII("extensions/theme_minimal/manifest.json");
+ std::string config_contents;
+ ASSERT_TRUE(base::ReadFileToString(manifest_path, &config_contents));
+ base::Optional<base::Value> manifest =
+ base::JSONReader::Read(config_contents);
+ ASSERT_TRUE(manifest.has_value());
+
+ content::WindowedNotificationObserver theme_change_observer(
+ chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
+ content::Source<ThemeService>(theme_service()));
+ EXPECT_CALL(*mock_client(), SetTheme(MatchesThirdPartyTheme(
+ kThemeExtensionId, kThemeExtensionName)));
+ env()->MakeExtension(manifest.value(), kThemeExtensionId);
+ theme_change_observer.Wait();
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, RevertThemeChanges) {
+ constexpr SkColor kAutogeneratedThemeColor = SK_ColorBLUE;
+ theme_service()->BuildAutogeneratedThemeFromColor(kAutogeneratedThemeColor);
+
+ handler()->ApplyDefaultTheme();
+ EXPECT_TRUE(theme_service()->UsingDefaultTheme());
+ // Cleans all pending SetTheme() calls.
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_CALL(*mock_client(),
+ SetTheme(MatchesAutogeneratedTheme(kAutogeneratedThemeColor)));
+ handler()->RevertThemeChanges();
+ EXPECT_TRUE(theme_service()->UsingAutogeneratedTheme());
+ EXPECT_EQ(kAutogeneratedThemeColor,
+ theme_service()->GetAutogeneratedThemeColor());
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, ConfirmThemeChanges) {
+ constexpr SkColor kAutogeneratedThemeColor = SK_ColorBLUE;
+ theme_service()->BuildAutogeneratedThemeFromColor(kAutogeneratedThemeColor);
+
+ handler()->ApplyDefaultTheme();
+ EXPECT_TRUE(theme_service()->UsingDefaultTheme());
+ // Cleans all pending SetTheme() calls.
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_CALL(*mock_client(), SetTheme(_)).Times(0);
+ handler()->ConfirmThemeChanges();
+ // Revert should have no effect.
+ handler()->RevertThemeChanges();
+ EXPECT_TRUE(theme_service()->UsingDefaultTheme());
+}
+
+TEST_F(ChromeCustomizeThemesHandlerTest, ResetHandler) {
+ constexpr SkColor kAutogeneratedThemeColor = SK_ColorBLUE;
+ theme_service()->BuildAutogeneratedThemeFromColor(kAutogeneratedThemeColor);
+
+ handler()->ApplyDefaultTheme();
+ EXPECT_TRUE(theme_service()->UsingDefaultTheme());
+ // Cleans all pending SetTheme() calls.
+ base::RunLoop().RunUntilIdle();
+
+ // Handler should revert theme changes when it's destructed.
+ ResetHandler();
+ EXPECT_TRUE(theme_service()->UsingAutogeneratedTheme());
+ EXPECT_EQ(kAutogeneratedThemeColor,
+ theme_service()->GetAutogeneratedThemeColor());
+}
diff --git a/chromium/chrome/browser/ui/webui/device_log_ui.cc b/chromium/chrome/browser/ui/webui/device_log_ui.cc
index fac445e2343..8a9a1a10e6f 100644
--- a/chromium/chrome/browser/ui/webui/device_log_ui.cc
+++ b/chromium/chrome/browser/ui/webui/device_log_ui.cc
@@ -89,6 +89,7 @@ DeviceLogUI::DeviceLogUI(content::WebUI* web_ui)
{"logTypeHidText", IDS_DEVICE_LOG_TYPE_HID},
{"logTypePrinterText", IDS_DEVICE_LOG_TYPE_PRINTER},
{"logTypeFidoText", IDS_DEVICE_LOG_TYPE_FIDO},
+ {"logTypeSerialText", IDS_DEVICE_LOG_TYPE_SERIAL},
{"logEntryFormat", IDS_DEVICE_LOG_ENTRY},
};
AddLocalizedStringsBulk(html, kStrings);
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads.mojom b/chromium/chrome/browser/ui/webui/downloads/downloads.mojom
index dfe2eaea6fd..cc0c64b63d6 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads.mojom
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads.mojom
@@ -4,8 +4,14 @@
module downloads.mojom;
+// This is the information associated with a download used for rendering in the
+// UI.
struct Data {
bool file_externally_removed;
+ bool is_dangerous;
+ bool is_mixed_content;
+ // |otr| stands for off-the-record and is true when a download entry is
+ // created during an incognito or guest profile session.
bool otr;
bool resume;
bool retry;
@@ -23,6 +29,11 @@ struct Data {
string last_reason_text;
string progress_status_text;
string since_string;
+ // |state| indicates the current state of the download. A download data entry
+ // can be dangerous or mixed content which can be expressed as a state to
+ // indicate the download needs confirmation before initiating. After
+ // confirmation, the state will indicate the download is in progress, complete
+ // or cancelled.
string state;
string url;
};
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 c63615e731e..d31d017588b 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_list_tracker.cc
@@ -331,6 +331,8 @@ downloads::mojom::DataPtr DownloadsListTracker::CreateDownloadData(
DCHECK(state);
file_value->danger_type = danger_type;
+ file_value->is_dangerous = download_item->IsDangerous();
+ file_value->is_mixed_content = download_item->IsMixedContent();
file_value->last_reason_text = base::UTF16ToUTF8(last_reason_text);
file_value->percent = percent;
file_value->progress_status_text = base::UTF16ToUTF8(progress_status_text);
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc b/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
index a1ddff80f28..abc1aa5c9e3 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
@@ -167,8 +167,10 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
IDR_DOWNLOADS_IMAGES_INCOGNITO_MARKER_SVG);
source->AddResourcePath("images/no_downloads.svg",
IDR_DOWNLOADS_IMAGES_NO_DOWNLOADS_SVG);
+#if !BUILDFLAG(OPTIMIZE_WEBUI)
source->AddResourcePath("downloads.mojom-lite.js",
IDR_DOWNLOADS_MOJO_LITE_JS);
+#endif
source->AddBoolean(
"allowOpenNow",
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
index e93f7e8c7aa..78a389f94e6 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/extensions/extensions_internals_source.h"
+#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h
index 31e4952fc2d..e6c282bdf78 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h
@@ -5,7 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSIONS_INTERNALS_SOURCE_H_
#define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSIONS_INTERNALS_SOURCE_H_
-#include "base/macros.h"
+#include <string>
+
#include "content/public/browser/url_data_source.h"
class Profile;
@@ -15,6 +16,9 @@ class Profile;
class ExtensionsInternalsSource : public content::URLDataSource {
public:
explicit ExtensionsInternalsSource(Profile* profile);
+ ExtensionsInternalsSource(const ExtensionsInternalsSource&) = delete;
+ ExtensionsInternalsSource& operator=(const ExtensionsInternalsSource&) =
+ delete;
~ExtensionsInternalsSource() override;
// content::URLDataSource:
@@ -31,8 +35,6 @@ class ExtensionsInternalsSource : public content::URLDataSource {
private:
Profile* const profile_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionsInternalsSource);
};
#endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSIONS_INTERNALS_SOURCE_H_
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
index 559e1d5ed99..293d9ea8fa4 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -264,6 +264,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
{"viewIncognito", IDS_EXTENSIONS_VIEW_INCOGNITO},
{"viewInactive", IDS_EXTENSIONS_VIEW_INACTIVE},
{"viewIframe", IDS_EXTENSIONS_VIEW_IFRAME},
+ {"viewServiceWorker", IDS_EXTENSIONS_SERVICE_WORKER_BACKGROUND},
#if defined(OS_CHROMEOS)
{"manageKioskApp", IDS_EXTENSIONS_MANAGE_KIOSK_APP},
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.h b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.h
index 1ed8c8dd6b8..12d266ca149 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.h
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.h
@@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSIONS_UI_H_
#define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSIONS_UI_H_
-#include "base/macros.h"
#include "base/timer/elapsed_timer.h"
#include "chrome/browser/ui/webui/webui_load_timer.h"
#include "components/prefs/pref_member.h"
@@ -27,6 +26,8 @@ class ExtensionsUI : public content::WebContentsObserver,
public content::WebUIController {
public:
explicit ExtensionsUI(content::WebUI* web_ui);
+ ExtensionsUI(const ExtensionsUI&) = delete;
+ ExtensionsUI& operator=(const ExtensionsUI&) = delete;
~ExtensionsUI() override;
static base::RefCountedMemory* GetFaviconResourceBytes(
@@ -48,8 +49,6 @@ class ExtensionsUI : public content::WebContentsObserver,
// Time the chrome://extensions page has been open.
base::Optional<base::ElapsedTimer> timer_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionsUI);
};
} // namespace extensions
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
index cd203793085..3510aafebc3 100644
--- 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
@@ -66,8 +66,7 @@ void FeedInternalsPageHandler::GetGeneralProperties(
GetGeneralPropertiesCallback callback) {
auto properties = feed_internals::mojom::Properties::New();
- properties->is_feed_enabled =
- base::FeatureList::IsEnabled(feed::kInterestFeedContentSuggestions);
+ properties->is_feed_enabled = true;
properties->is_feed_visible =
pref_service_->GetBoolean(feed::prefs::kArticlesListVisible);
properties->is_feed_allowed = IsFeedAllowed();
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 28550b954b3..1783824bfd2 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
@@ -12,14 +12,21 @@
#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"
-#include "chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h"
-#include "chrome/browser/ui/webui/feed_internals/feedv2_internals_page_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/dev_ui_browser_resources.h"
+#include "components/feed/buildflags.h"
#include "components/feed/feed_feature_list.h"
#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
+
FeedInternalsUI::FeedInternalsUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui), profile_(Profile::FromWebUI(web_ui)) {
content::WebUIDataSource* source =
@@ -40,15 +47,20 @@ FeedInternalsUI::~FeedInternalsUI() = default;
void FeedInternalsUI::BindInterface(
mojo::PendingReceiver<feed_internals::mojom::PageHandler> receiver) {
- if (!base::FeatureList::IsEnabled(feed::kInterestFeedV2)) {
+#if BUILDFLAG(ENABLE_FEED_V1)
+ if (feed::IsV1Enabled()) {
page_handler_ = std::make_unique<FeedInternalsPageHandler>(
std::move(receiver),
feed::FeedHostServiceFactory::GetForBrowserContext(profile_),
profile_->GetPrefs());
- } else {
+ }
+#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());
}
+#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 454b67b81d6..7af4ddbe0fc 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
@@ -10,6 +10,7 @@
#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"
@@ -35,10 +36,12 @@ 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/identity_internals_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.cc
index ce1f2aebc85..2e7780cc487 100644
--- a/chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/identity_internals_ui_browsertest.cc
@@ -55,8 +55,13 @@ void IdentityInternalsUIBrowserTest::AddTokenToCache(
extensions::IdentityTokenCacheValue token_cache_value =
extensions::IdentityTokenCacheValue::CreateToken(
token_id, scopes_set, base::TimeDelta::FromSeconds(time_to_live));
- extensions::ExtensionTokenKey key(extension_id, CoreAccountId(account_id),
- scopes_set);
+
+ CoreAccountInfo user_info;
+ user_info.account_id = CoreAccountId(account_id);
+ user_info.gaia = account_id;
+ user_info.email = "user_email_" + account_id;
+
+ extensions::ExtensionTokenKey key(extension_id, user_info, scopes_set);
extensions::IdentityAPI::GetFactoryInstance()
->Get(browser()->profile())
->token_cache()
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 ba94e5d0bf3..6bdd35d52f8 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
@@ -23,6 +23,7 @@ WebAppInternalsPageHandlerImpl::~WebAppInternalsPageHandlerImpl() = default;
void WebAppInternalsPageHandlerImpl::AddPageResources(
content::WebUIDataSource* source) {
+ source->DisableTrustedTypesCSP();
source->AddResourcePath("web_app_internals.mojom-lite.js",
IDR_WEB_APP_INTERNALS_MOJOM_LITE_JS);
source->AddResourcePath("web_app_internals.js", IDR_WEB_APP_INTERNALS_JS);
diff --git a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc
index 4a6ac955491..b7f6f227a9d 100644
--- a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc
+++ b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc
@@ -147,10 +147,6 @@ void LocalDiscoveryUI::RegisterProfilePrefs(
registry->RegisterBooleanPref(prefs::kLocalDiscoveryEnabled, true);
registry->RegisterBooleanPref(
prefs::kLocalDiscoveryNotificationsEnabled,
-#if defined(OS_WIN)
false,
-#else
- true,
-#endif
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
}
diff --git a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
index 66785ec4171..82fbc1dd375 100644
--- a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
@@ -424,7 +424,6 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile,
chrome::kTestUserProfileDir);
#endif
- command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications);
WebUIBrowserTest::SetUpCommandLine(command_line);
}
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler.cc b/chromium/chrome/browser/ui/webui/management_ui_handler.cc
index 518f0baa72c..bb23c5ae734 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/management_ui_handler.cc
@@ -51,6 +51,7 @@
#include "chrome/browser/chromeos/policy/status_collector/status_collector.h"
#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"
@@ -64,6 +65,8 @@
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
#include "ui/chromeos/devicetype_utils.h"
+#else
+#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#endif // defined(OS_CHROMEOS)
#include "chrome/browser/extensions/extension_util.h"
@@ -72,6 +75,7 @@
#include "components/policy/core/common/policy_namespace.h"
#include "components/policy/core/common/policy_service.h"
#include "components/policy/policy_constants.h"
+#include "components/policy/proto/device_management_backend.pb.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
@@ -340,6 +344,29 @@ std::string ManagementUIHandler::GetAccountDomain(Profile* profile) {
: domain;
}
+std::string ManagementUIHandler::GetAccountManager(Profile* profile) {
+ if (!IsProfileManaged(profile))
+ return std::string();
+
+#if defined(OS_CHROMEOS)
+ const policy::UserCloudPolicyManagerChromeOS* user_cloud_policy_manager =
+ profile->GetUserCloudPolicyManagerChromeOS();
+#else
+ const policy::UserCloudPolicyManager* user_cloud_policy_manager =
+ profile->GetUserCloudPolicyManager();
+#endif // defined(OS_CHROMEOS)
+
+ if (user_cloud_policy_manager) {
+ const enterprise_management::PolicyData* policy =
+ user_cloud_policy_manager->core()->store()->policy();
+ if (policy && policy->has_managed_by()) {
+ return policy->managed_by();
+ }
+ }
+
+ return GetAccountDomain(profile);
+}
+
ManagementUIHandler::ManagementUIHandler() {
reporting_extension_ids_ = {kOnPremReportingExtensionStableId,
kOnPremReportingExtensionBetaId,
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler.h b/chromium/chrome/browser/ui/webui/management_ui_handler.h
index ea700bbe668..d45c33d4313 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/management_ui_handler.h
@@ -120,8 +120,17 @@ class ManagementUIHandler : public content::WebUIMessageHandler,
void SetAccountManagedForTesting(bool managed) { account_managed_ = managed; }
void SetDeviceManagedForTesting(bool managed) { device_managed_ = managed; }
+ // This will return the domain (ie foo.com) that manages |profile|. If
+ // unmanaged, an empty string is returned.
static std::string GetAccountDomain(Profile* profile);
+ // This returns the entity that manages this |profile|. For standard dasher
+ // domains, this will be a domain name (ie foo.com). For FlexOrgs, this will
+ // be the email address of the admin of the FlexOrg (ie user@foo.com). If
+ // DMServer does not provide this information, this method defaults to
+ // |GetAccountDomain|. If unmanaged, an empty string is returned.
+ static std::string GetAccountManager(Profile* profile);
+
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc
index fcdbf6ac0a5..a5f0f1bf868 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc
@@ -30,8 +30,10 @@
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
+#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/chromeos/crostini/crostini_features.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/fake_crostini_features.h"
@@ -42,6 +44,7 @@
#include "chrome/browser/chromeos/policy/status_collector/status_collector.h"
#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"
@@ -49,6 +52,7 @@
#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"
@@ -58,10 +62,13 @@
#include "chromeos/network/proxy/ui_proxy_config_service.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "chromeos/tpm/stub_install_attributes.h"
+#include "components/account_id/account_id.h"
#include "components/enterprise/browser/reporting/common_pref_names.h"
#include "components/onc/onc_pref_names.h"
#include "components/policy/core/common/cloud/cloud_external_data_manager.h"
+#include "components/policy/core/common/cloud/mock_cloud_external_data_manager.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
+#include "components/policy/core/common/cloud/mock_cloud_policy_store.h"
#include "components/policy/core/common/cloud/mock_signing_service.h"
#include "components/prefs/testing_pref_service.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
@@ -71,9 +78,16 @@
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
#include "ui/chromeos/devicetype_utils.h"
+#else
+#include "base/threading/thread_task_runner_handle.h"
+#include "components/policy/core/common/cloud/cloud_external_data_manager.h"
+#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)
using testing::_;
+using testing::AnyNumber;
using testing::AssertionFailure;
using testing::AssertionResult;
using testing::AssertionSuccess;
@@ -93,6 +107,15 @@ struct ContextualManagementSourceUpdate {
bool managed;
};
+namespace {
+const char kDomain[] = "domain.com";
+const char kUser[] = "user@domain.com";
+const char kManager[] = "manager@domain.com";
+#if defined(OS_CHROMEOS)
+const char kGaiaId[] = "gaia_id";
+#endif // defined(OS_CHROMEOS)
+} // namespace
+
#if defined(OS_CHROMEOS)
// This class is just to mock the behaviour of the few flags we need for
// simulating the behaviour of the policy::DeviceStatusCollector.
@@ -157,7 +180,7 @@ class TestDeviceCloudPolicyManagerChromeOS
}
~TestDeviceCloudPolicyManagerChromeOS() override = default;
};
-#endif
+#endif // defined(OS_CHROMEOS)
class TestManagementUIHandler : public ManagementUIHandler {
public:
@@ -487,6 +510,48 @@ class ManagementUIHandlerTests : public TestingBaseClass {
TestConfig& GetTestConfig() { return setup_config_; }
+#if defined(OS_CHROMEOS)
+ void OnFatalError() { DCHECK(false); }
+
+ std::unique_ptr<policy::UserCloudPolicyManagerChromeOS>
+ BuildCloudPolicyManager() {
+ auto store = std::make_unique<policy::MockCloudPolicyStore>();
+ EXPECT_CALL(*store, Load()).Times(AnyNumber());
+
+ const AccountId account_id = AccountId::FromUserEmailGaiaId(kUser, kGaiaId);
+
+ TestingProfile::Builder builder_managed_user;
+ builder_managed_user.SetProfileName(kUser);
+ builder_managed_user.OverridePolicyConnectorIsManagedForTesting(true);
+ auto managed_user = builder_managed_user.Build();
+
+ auto data_manager =
+ std::make_unique<policy::MockCloudExternalDataManager>();
+ EXPECT_CALL(*data_manager, Disconnect());
+
+ return std::make_unique<policy::UserCloudPolicyManagerChromeOS>(
+ managed_user.get(), std::move(store), std::move(data_manager),
+ base::FilePath() /* component_policy_cache_path */,
+ policy::UserCloudPolicyManagerChromeOS::PolicyEnforcement::
+ kPolicyRequired,
+ base::TimeDelta::FromMinutes(1) /* policy_refresh_timeout */,
+ base::BindOnce(&ManagementUIHandlerTests::OnFatalError,
+ base::Unretained(this)),
+ account_id, task_runner_);
+ }
+#else
+ std::unique_ptr<policy::UserCloudPolicyManager> BuildCloudPolicyManager() {
+ auto store = std::make_unique<policy::MockUserCloudPolicyStore>();
+ EXPECT_CALL(*store, Load()).Times(AnyNumber());
+
+ return std::make_unique<policy::UserCloudPolicyManager>(
+ std::move(store), base::FilePath(),
+ /*cloud_external_data_manager=*/nullptr,
+ base::ThreadTaskRunnerHandle::Get(),
+ network::TestNetworkConnectionTracker::CreateGetter());
+ }
+#endif // defined(OS_CHROMEOS)
+
protected:
TestConfig setup_config_;
TestManagementUIHandler handler_;
@@ -1204,3 +1269,61 @@ TEST_F(ManagementUIHandlerTests, ThreatReportingInfo) {
EXPECT_EQ(expected_info, *threat_protection_info->FindListKey("info"));
}
+
+TEST_F(ManagementUIHandlerTests, GetAccountDomain) {
+ TestingProfile::Builder builder_unmanaged_user;
+ builder_unmanaged_user.SetProfileName(kUser);
+ builder_unmanaged_user.OverridePolicyConnectorIsManagedForTesting(false);
+ auto unmanaged_user = builder_unmanaged_user.Build();
+ EXPECT_EQ("", handler_.GetAccountDomain(unmanaged_user.get()));
+
+ TestingProfile::Builder builder_managed_user;
+ builder_managed_user.SetProfileName(kUser);
+ builder_managed_user.OverridePolicyConnectorIsManagedForTesting(true);
+ auto managed_user = builder_managed_user.Build();
+ EXPECT_EQ(kDomain, handler_.GetAccountDomain(managed_user.get()));
+}
+
+TEST_F(ManagementUIHandlerTests, GetAccountManager) {
+ TestingProfile::Builder builder_managed_user;
+ builder_managed_user.SetProfileName(kUser);
+ builder_managed_user.OverridePolicyConnectorIsManagedForTesting(true);
+
+#if defined(OS_CHROMEOS)
+ TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr);
+ std::unique_ptr<TestingProfileManager> profile_manager =
+ std::make_unique<TestingProfileManager>(
+ TestingBrowserProcess::GetGlobal());
+ ASSERT_TRUE(profile_manager->SetUp());
+ builder_managed_user.SetUserCloudPolicyManagerChromeOS(
+ BuildCloudPolicyManager());
+#else
+ builder_managed_user.SetUserCloudPolicyManager(BuildCloudPolicyManager());
+#endif
+ auto managed_user = builder_managed_user.Build();
+
+#if defined(OS_CHROMEOS)
+ policy::UserCloudPolicyManagerChromeOS* policy_manager =
+ managed_user->GetUserCloudPolicyManagerChromeOS();
+ policy::MockCloudPolicyStore* mock_store =
+ static_cast<policy::MockCloudPolicyStore*>(
+ policy_manager->core()->store());
+#else
+ policy::UserCloudPolicyManager* policy_manager =
+ managed_user->GetUserCloudPolicyManager();
+ policy::MockUserCloudPolicyStore* mock_store =
+ static_cast<policy::MockUserCloudPolicyStore*>(
+ policy_manager->core()->store());
+#endif
+
+ DCHECK(mock_store);
+ mock_store->policy_ = std::make_unique<enterprise_management::PolicyData>();
+
+ // If no managed_by, then just calculate the domain from the user.
+ EXPECT_FALSE(mock_store->policy_->has_managed_by());
+ EXPECT_EQ(kDomain, handler_.GetAccountManager(managed_user.get()));
+
+ // If managed_by is set, then use that value.
+ mock_store->policy_->set_managed_by(kManager);
+ EXPECT_EQ(kManager, handler_.GetAccountManager(managed_user.get()));
+}
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 04bf2599721..7031f4ef477 100644
--- a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
@@ -25,10 +25,10 @@
#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 "content/public/common/web_preferences.h"
#include "media/base/media_switches.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
+#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#if !defined(OS_ANDROID)
#include "chrome/common/pref_names.h"
@@ -95,11 +95,11 @@ class MediaEngagementScoreDetailsProviderImpl
switch (web_ui_->GetWebContents()
->GetOrCreateWebPreferences()
.autoplay_policy) {
- case content::AutoplayPolicy::kNoUserGestureRequired:
+ case blink::web_pref::AutoplayPolicy::kNoUserGestureRequired:
return "no-user-gesture-required";
- case content::AutoplayPolicy::kUserGestureRequired:
+ case blink::web_pref::AutoplayPolicy::kUserGestureRequired:
return "user-gesture-required";
- case content::AutoplayPolicy::kDocumentUserActivationRequired:
+ case blink::web_pref::AutoplayPolicy::kDocumentUserActivationRequired:
return "document-user-activation-required";
}
}
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_internals_ui.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_internals_ui.cc
index 1bd6fd67aa1..1f87e5256e3 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_internals_ui.cc
@@ -6,12 +6,12 @@
#include <memory>
-#include "chrome/browser/media/router/media_router.h"
-#include "chrome/browser/media/router/media_router_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
+#include "components/media_router/browser/media_router.h"
+#include "components/media_router/browser/media_router_factory.h"
#include "content/public/browser/web_contents.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/media_router/media_router_internals_webui_message_handler.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc
index a45d0eccbbe..5401eaa84b9 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.h"
#include "base/bind.h"
-#include "chrome/browser/media/router/media_router.h"
+#include "components/media_router/browser/media_router.h"
namespace media_router {
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.h b/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.h
index ca321066b2d..c294f093b70 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_internals_webui_message_handler.h
@@ -9,7 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "base/values.h"
-#include "chrome/common/media_router/mojom/media_router.mojom.h"
+#include "components/media_router/common/mojom/media_router.mojom.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace media_router {
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 60fa19f51a0..a1933edafe7 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
@@ -29,43 +29,37 @@ base::Value GetJavascriptTimestamp() {
// Keys in the JSON representation of a contact message
const char kContactMessageTimeKey[] = "time";
-const char kContactMessageContactListChangedKey[] = "contactListChanged";
-const char kContactMessageContactsAddedToAllowedListKey[] =
- "contactsAddedToAllowlist";
-const char kContactMessageContactsRemovedFromAllowedListKey[] =
- "contactsRemovedFromAllowlist";
+const char kContactMessageContactsChangedKey[] = "contactsChanged";
const char kContactMessageAllowedIdsKey[] = "allowedIds";
-const char kContactMessageContactsPassedKey[] = "contactsPassed";
const char kContactMessageContactRecordKey[] = "contactRecords";
// Converts Contact to a raw dictionary value used as a JSON argument to
// JavaScript functions.
+// TODO(nohle): We should probably break up this dictionary into smaller
+// dictionaries corresponding to each contact-manager observer functions. This
+// will require changes at the javascript layer as well.
base::Value ContactMessageToDictionary(
- bool contacts_list_changed,
- bool contacts_added_to_allowlist,
- bool contacts_removed_from_allowlist,
- const std::set<std::string>& allowed_contact_ids,
+ base::Optional<bool> did_contacts_change_since_last_upload,
+ const base::Optional<std::set<std::string>>& allowed_contact_ids,
const base::Optional<std::vector<nearbyshare::proto::ContactRecord>>&
contacts) {
base::Value dictionary(base::Value::Type::DICTIONARY);
dictionary.SetKey(kContactMessageTimeKey, GetJavascriptTimestamp());
- dictionary.SetBoolKey(kContactMessageContactListChangedKey,
- contacts_list_changed);
- dictionary.SetBoolKey(kContactMessageContactsAddedToAllowedListKey,
- contacts_added_to_allowlist);
- dictionary.SetBoolKey(kContactMessageContactsRemovedFromAllowedListKey,
- contacts_removed_from_allowlist);
-
- base::Value::ListStorage allowed_ids_list;
- allowed_ids_list.reserve(allowed_contact_ids.size());
- for (const auto& contact_id : allowed_contact_ids)
- allowed_ids_list.push_back(base::Value(contact_id));
-
- dictionary.SetStringKey(kContactMessageAllowedIdsKey,
- FormatAsJSON(base::Value(std::move(allowed_ids_list))));
-
- dictionary.SetBoolKey(kContactMessageContactsPassedKey, contacts.has_value());
+ if (did_contacts_change_since_last_upload.has_value()) {
+ dictionary.SetBoolKey(kContactMessageContactsChangedKey,
+ *did_contacts_change_since_last_upload);
+ }
+ if (allowed_contact_ids) {
+ base::Value::ListStorage allowed_ids_list;
+ allowed_ids_list.reserve(allowed_contact_ids->size());
+ for (const auto& contact_id : *allowed_contact_ids) {
+ allowed_ids_list.push_back(base::Value(contact_id));
+ }
+ dictionary.SetStringKey(
+ kContactMessageAllowedIdsKey,
+ FormatAsJSON(base::Value(std::move(allowed_ids_list))));
+ }
if (contacts) {
base::Value::ListStorage contact_list;
contact_list.reserve(contacts->size());
@@ -123,24 +117,26 @@ void NearbyInternalsContactHandler::HandleDownloadContacts(
NearbySharingService* service_ =
NearbySharingServiceFactory::GetForBrowserContext(context_);
if (service_) {
- const bool only_download_if_contacts_changed = args->GetList()[0].GetBool();
- service_->GetContactManager()->DownloadContacts(
- only_download_if_contacts_changed);
+ service_->GetContactManager()->DownloadContacts();
} else {
NS_LOG(ERROR) << "No NearbyShareService instance to call.";
}
}
-void NearbyInternalsContactHandler::OnContactsUpdated(
- bool contacts_list_changed,
- bool contacts_added_to_allowlist,
- bool contacts_removed_from_allowlist,
+void NearbyInternalsContactHandler::OnContactsDownloaded(
const std::set<std::string>& allowed_contact_ids,
- const base::Optional<std::vector<nearbyshare::proto::ContactRecord>>&
- contacts) {
+ const std::vector<nearbyshare::proto::ContactRecord>& contacts) {
FireWebUIListener("contacts-updated",
- ContactMessageToDictionary(contacts_list_changed,
- contacts_added_to_allowlist,
- contacts_removed_from_allowlist,
- allowed_contact_ids, contacts));
+ ContactMessageToDictionary(
+ /*did_contacts_change_since_last_upload=*/base::nullopt,
+ allowed_contact_ids, contacts));
+}
+
+void NearbyInternalsContactHandler::OnContactsUploaded(
+ bool did_contacts_change_since_last_upload) {
+ FireWebUIListener(
+ "contacts-updated",
+ ContactMessageToDictionary(did_contacts_change_since_last_upload,
+ /*allowed_contact_ids=*/base::nullopt,
+ /*contacts=*/base::nullopt));
}
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 dc0e0a7d467..a49e64afe89 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
@@ -46,13 +46,10 @@ class NearbyInternalsContactHandler
void InitializeContents(const base::ListValue* args);
// NearbyShareContactManager::Observer:
- void OnContactsUpdated(
- bool contacts_list_changed,
- bool contacts_added_to_allowlist,
- bool contacts_removed_from_allowlist,
+ void OnContactsDownloaded(
const std::set<std::string>& allowed_contact_ids,
- const base::Optional<std::vector<nearbyshare::proto::ContactRecord>>&
- contacts) override;
+ const std::vector<nearbyshare::proto::ContactRecord>& contacts) override;
+ void OnContactsUploaded(bool did_contacts_change_since_last_upload) override;
// Message handler callback that requests a contacts download from the contact
// manager.
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 c2d6bd28c5f..6d0f2427615 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
@@ -24,15 +24,13 @@ namespace {
enum class Rpc {
kCertificate = 0,
kContact = 1,
- kDevice = 2
+ kDevice = 2,
+ kDeviceState = 3
};
// This enum class needs to stay in sync with the Direction definition in
// chrome/browser/resources/nearby_internals/types.js.
-enum class Direction {
- kRequest = 0,
- kResponse = 1
-};
+enum class Direction { kRequest = 0, kResponse = 1 };
std::string FormatAsJSON(const base::Value& value) {
std::string json;
@@ -139,8 +137,7 @@ void NearbyInternalsHttpHandler::ListContactPeople(
NearbySharingService* service_ =
NearbySharingServiceFactory::GetForBrowserContext(context_);
if (service_) {
- service_->GetContactManager()->DownloadContacts(
- /*only_download_if_contacts_changed=*/false);
+ service_->GetContactManager()->DownloadContacts();
} else {
NS_LOG(ERROR) << "No NearbyShareService instance to call.";
}
@@ -195,15 +192,3 @@ void NearbyInternalsHttpHandler::OnListPublicCertificatesResponse(
ListPublicCertificatesResponseToReadableDictionary(response),
Direction::kResponse, Rpc::kCertificate));
}
-
-void NearbyInternalsHttpHandler::OnCheckContactsReachabilityRequest(
- const nearbyshare::proto::CheckContactsReachabilityRequest& request) {
- // No FireWebUIListener() because internal debug page does not support
- // CheckContactsReachabilityRequest.
-}
-
-void NearbyInternalsHttpHandler::OnCheckContactsReachabilityResponse(
- const nearbyshare::proto::CheckContactsReachabilityResponse& response) {
- // No FireWebUIListener() because internal debug page does not support
- // CheckContactsReachabilityResponse.
-}
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 d892a93799d..da37e13c58b 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
@@ -52,12 +52,6 @@ class NearbyInternalsHttpHandler : public content::WebUIMessageHandler,
void OnListPublicCertificatesResponse(
const nearbyshare::proto::ListPublicCertificatesResponse& response)
override;
- void OnCheckContactsReachabilityRequest(
- const nearbyshare::proto::CheckContactsReachabilityRequest& request)
- override;
- void OnCheckContactsReachabilityResponse(
- const nearbyshare::proto::CheckContactsReachabilityResponse& response)
- override;
private:
// Message handler callback that initializes JavaScript.
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 da9a29a0eb2..26215fcf601 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
@@ -4,11 +4,16 @@
#include "chrome/browser/ui/webui/nearby_internals/nearby_internals_ui_trigger_handler.h"
+#include <memory>
+#include <vector>
+
#include "base/bind.h"
#include "base/time/time.h"
+#include "chrome/browser/nearby_sharing/attachment.h"
#include "chrome/browser/nearby_sharing/logging/logging.h"
#include "chrome/browser/nearby_sharing/nearby_sharing_service_factory.h"
-#include "chrome/browser/ui/webui/nearby_share/nearby_share_target_types.mojom.h"
+#include "chrome/browser/nearby_sharing/text_attachment.h"
+#include "chrome/services/sharing/public/mojom/nearby_share_target_types.mojom.h"
namespace {
@@ -371,13 +376,6 @@ void NearbyInternalsUiTriggerHandler::OnShareTargetLost(
ShareTargetMapToList(id_to_share_target_map_));
}
-void NearbyInternalsUiTriggerHandler::OnSendTextCalled(
- NearbySharingService::StatusCodes status_codes) {
- FireWebUIListener(
- "on-status-code-returned",
- StatusCodeToDictionary(status_codes, TriggerEvent::kSendText));
-}
-
void NearbyInternalsUiTriggerHandler::OnAcceptCalled(
NearbySharingService::StatusCodes status_codes) {
FireWebUIListener(
@@ -413,7 +411,7 @@ void NearbyInternalsUiTriggerHandler::SendText(const base::ListValue* args) {
return;
}
- std::string share_target_id = args->GetList()[0].GetString();
+ std::string share_target_id = args->GetList()[1].GetString();
auto it = id_to_share_target_map_.find(share_target_id);
if (it == id_to_share_target_map_.end()) {
NS_LOG(ERROR) << "Invalid ShareTarget ID " << share_target_id
@@ -421,10 +419,16 @@ void NearbyInternalsUiTriggerHandler::SendText(const base::ListValue* args) {
return;
}
- service_->SendText(
- it->second, kPayloadExample,
- base::BindOnce(&NearbyInternalsUiTriggerHandler::OnSendTextCalled,
- weak_ptr_factory_.GetWeakPtr()));
+ std::vector<std::unique_ptr<Attachment>> attachments;
+ attachments.push_back(std::make_unique<TextAttachment>(
+ TextAttachment::Type::kText, kPayloadExample));
+
+ const base::Value& callback_id = args->GetList()[0];
+ ResolveJavascriptCallback(
+ callback_id,
+ StatusCodeToDictionary(
+ service_->SendAttachments(it->second, std::move(attachments)),
+ TriggerEvent::kSendText));
}
void NearbyInternalsUiTriggerHandler::Accept(const base::ListValue* args) {
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 2ddcbc96630..5a82f7bc2f9 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
@@ -51,7 +51,6 @@ class NearbyInternalsUiTriggerHandler : public content::WebUIMessageHandler,
void OnOpenCalled(NearbySharingService::StatusCodes status_codes);
void OnRejectCalled(NearbySharingService::StatusCodes status_codes);
void OnCancelCalled(NearbySharingService::StatusCodes status_codes);
- void OnSendTextCalled(NearbySharingService::StatusCodes status_codes);
// Message handler callback that initializes JavaScript.
void InitializeContents(const base::ListValue* args);
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn b/chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn
index d3d43295e32..087f48462e2 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/nearby_share/BUILD.gn
@@ -4,15 +4,13 @@
import("//mojo/public/tools/bindings/mojom.gni")
-mojom("nearby_share_target_types") {
- sources = [ "nearby_share_target_types.mojom" ]
-}
+assert(is_chromeos, "Nearby Share is CrOS only")
mojom("mojom") {
sources = [ "nearby_share.mojom" ]
public_deps = [
- ":nearby_share_target_types",
+ "//chrome/services/sharing/public/mojom:nearby_share_target_types",
"//mojo/public/mojom/base",
]
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 edff98d46be..a8d75f3816a 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share.mojom
+++ b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share.mojom
@@ -4,7 +4,7 @@
module nearby_share.mojom;
-import "chrome/browser/ui/webui/nearby_share/nearby_share_target_types.mojom";
+import "chrome/services/sharing/public/mojom/nearby_share_target_types.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
// Describes a nearby device that is able to receive data via Nearby Share.
@@ -40,23 +40,83 @@ interface ShareTargetListener {
OnShareTargetLost(ShareTarget share_target);
};
+// Status of the current transfer.
+enum TransferStatus {
+ // The user of the local device needs to accept or reject the transfer. This
+ // involves showing a token on both devices to be compared by the user.
+ kAwaitingLocalConfirmation,
+ // The remote device needs to accept the transfer. We still need to show the
+ // token on this device so the other user can compare it.
+ kAwaitingRemoteAcceptance,
+ // The current transfer is now in progress after both users accepted the
+ // transfer on their devices.
+ kInProgress,
+};
+
+// Interface to be notified about transfer updates. Includes an optional token
+// that needs to be shown to the user to confirm with the remote device. The
+// token verification can be skipped for trusted devices in the contacts list
+// but must be shown when sending to unknown devices. This interface is
+// implemented in UI surfaces and called from the browser process.
+interface TransferUpdateListener {
+ // Called when the status of the current transfer changes.
+ 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 non-file text share (url, phone, address, etc).
+ kText,
+ // 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 un-matched mime type.
+ kUnknownFile,
+};
+
+// 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;
+};
+
// Manager interface for nearby device discovery. Implemented on the browser
-// process and used by UI surfaces.
+// 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().
interface DiscoveryManager {
// Starts discovering nearby devices. The passed |listener| will be called
// with any discovered devices.
StartDiscovery(pending_remote<ShareTargetListener> listener)
=> (bool success);
- // Select a previously discovered |share_target_id| to send data to. If the
- // selected target requires an additional confirmation of a shared connection
- // id by the user it will return a valid ConfirmationManager interface to be
- // used to accept or reject the transfer. |token| will contain the string to
- // show to the user in that case.
+ // Select a previously discovered |share_target_id| to send data to. On
+ // success this will return valid ConfirmationManager and
+ // TransferUpdateListener interfaces to be used to show an additional
+ // confirmation screen to accept or reject the transfer.
SelectShareTarget(mojo_base.mojom.UnguessableToken share_target_id)
=> (SelectShareTargetResult result,
- string? token,
+ 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
+ // share.
+ GetSendPreview() => (SendPreview send_preview);
};
// Manager interface for the Nearby Share confirmation screen. Implemented on
@@ -67,4 +127,53 @@ interface ConfirmationManager {
// Rejects a connection to the current Share Target.
Reject() => (bool success);
+
+ // Cancels a connection to the current Share Target.
+ Cancel() => (bool success);
+};
+
+// Observer interface to receive updates when high visibility has changed
+// and when an incoming share is requested and the user must confirm.
+//
+// This interface is implement in Javascript in the chrome://os-settings WebUI.
+interface ReceiveObserver {
+ // Called when high visibility receive state (foreground receive) has
+ // changed and the new value is provided.
+ OnHighVisibilityChanged(bool in_high_visibility);
+
+ // Called when a share request has arrived and the user must be asked to
+ // accept or reject the call. This will only trigger when the receive manager
+ // is in high visibility, otherwise the notification manager (background
+ // receive surface) will handle the events.
+ OnIncomingShare(ShareTarget share_target, string? connection_token);
+};
+
+// Allows the caller to observe changes to, query, or explicitly enter or exit
+// high visibility. Once in high visibility, the caller may observe incoming
+// shares and accept or reject them.
+//
+// This interface runs in the browser process and is bound by os-settings which
+// hosts the ui surface and implements the |ReceiveObserver|.
+interface ReceiveManager {
+ // Allows the caller to observe ReceiveManager events.
+ AddReceiveObserver(pending_remote<ReceiveObserver> observer);
+
+ // Determine if the user is currently in high visibility.
+ IsInHighVisibility() => (bool in_high_visibility);
+
+ // Attempt to explicitly enter high visibility. If |success| is true the
+ // receive manager is in high visibility state. If |success| is false the
+ // receive manager is not in high visibility state.
+ EnterHighVisibility() => (bool success);
+
+ // Attempt to explicitly exit high visibility. If |success| is true the
+ // receive manager is not in high visibility state. If |success| is false the
+ // receive manager is still in high visibility state.
+ ExitHighVisibility() => (bool success);
+
+ // Accept the incoming share request by the share target id.
+ Accept(mojo_base.mojom.UnguessableToken share_target_id) => (bool success);
+
+ // Reject the incoming share request by the share target id.
+ Reject(mojo_base.mojom.UnguessableToken share_target_id) => (bool success);
};
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 3e063a8efd8..26b65a012ac 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
@@ -6,6 +6,7 @@
#include <string>
+#include "chrome/browser/nearby_sharing/contacts/nearby_share_contact_manager.h"
#include "chrome/browser/nearby_sharing/nearby_per_session_discovery_manager.h"
#include "chrome/browser/nearby_sharing/nearby_share_settings.h"
#include "chrome/browser/nearby_sharing/nearby_sharing_service.h"
@@ -50,21 +51,41 @@ NearbyShareDialogUI::NearbyShareDialogUI(content::WebUI* web_ui)
html_source->AddResourcePath("nearby_share_target_types.mojom-lite.js",
IDR_NEARBY_SHARE_TARGET_TYPES_MOJO_JS);
- RegisterNearbySharedMojoResources(html_source);
+ RegisterNearbySharedResources(html_source);
RegisterNearbySharedStrings(html_source);
html_source->UseStringsJs();
+ web_ui->RegisterMessageCallback(
+ "close", base::BindRepeating(&NearbyShareDialogUI::HandleClose,
+ base::Unretained(this)));
+
content::WebUIDataSource::Add(profile, html_source);
}
NearbyShareDialogUI::~NearbyShareDialogUI() = default;
+void NearbyShareDialogUI::AddObserver(NearbyShareDialogUI::Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void NearbyShareDialogUI::RemoveObserver(
+ NearbyShareDialogUI::Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+void NearbyShareDialogUI::SetAttachments(
+ std::vector<std::unique_ptr<Attachment>> attachments) {
+ attachments_ = std::move(attachments);
+}
+
void NearbyShareDialogUI::BindInterface(
mojo::PendingReceiver<mojom::DiscoveryManager> manager) {
mojo::MakeSelfOwnedReceiver(
- std::make_unique<NearbyPerSessionDiscoveryManager>(nearby_service_),
+ std::make_unique<NearbyPerSessionDiscoveryManager>(
+ nearby_service_, std::move(attachments_)),
std::move(manager));
}
+
void NearbyShareDialogUI::BindInterface(
mojo::PendingReceiver<mojom::NearbyShareSettings> receiver) {
NearbySharingService* nearby_sharing_service =
@@ -73,6 +94,20 @@ void NearbyShareDialogUI::BindInterface(
nearby_sharing_service->GetSettings()->Bind(std::move(receiver));
}
+void NearbyShareDialogUI::BindInterface(
+ mojo::PendingReceiver<nearby_share::mojom::ContactManager> receiver) {
+ NearbySharingService* nearby_sharing_service =
+ NearbySharingServiceFactory::GetForBrowserContext(
+ Profile::FromWebUI(web_ui()));
+ nearby_sharing_service->GetContactManager()->Bind(std::move(receiver));
+}
+
+void NearbyShareDialogUI::HandleClose(const base::ListValue* args) {
+ for (auto& observer : observers_) {
+ observer.OnClose();
+ }
+}
+
WEB_UI_CONTROLLER_TYPE_IMPL(NearbyShareDialogUI)
} // namespace nearby_share
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h
index 3eaf042bd23..570d88d0d3a 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h
+++ b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h
@@ -5,6 +5,12 @@
#ifndef CHROME_BROWSER_UI_WEBUI_NEARBY_SHARE_NEARBY_SHARE_DIALOG_UI_H_
#define CHROME_BROWSER_UI_WEBUI_NEARBY_SHARE_NEARBY_SHARE_DIALOG_UI_H_
+#include <memory>
+#include <vector>
+
+#include "base/observer_list.h"
+#include "base/observer_list_types.h"
+#include "chrome/browser/nearby_sharing/attachment.h"
#include "chrome/browser/ui/webui/nearby_share/nearby_share.mojom.h"
#include "chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@@ -17,19 +23,35 @@ namespace nearby_share {
// The WebUI controller for chrome://nearby.
class NearbyShareDialogUI : public ui::MojoWebUIController {
public:
+ class Observer : public base::CheckedObserver {
+ public:
+ virtual void OnClose() = 0;
+ };
+
explicit NearbyShareDialogUI(content::WebUI* web_ui);
NearbyShareDialogUI(const NearbyShareDialogUI&) = delete;
NearbyShareDialogUI& operator=(const NearbyShareDialogUI&) = delete;
~NearbyShareDialogUI() override;
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+ void SetAttachments(std::vector<std::unique_ptr<Attachment>> attachments);
+
// Instantiates the implementor of the mojom::DiscoveryManager mojo
// interface passing the pending receiver that will be internally bound.
void BindInterface(mojo::PendingReceiver<mojom::DiscoveryManager> manager);
// ui::MojoWebUIController
void BindInterface(
mojo::PendingReceiver<mojom::NearbyShareSettings> receiver);
+ // Binds to the existing contacts manager instance owned by the nearby share
+ // keyed service.
+ void BindInterface(
+ mojo::PendingReceiver<nearby_share::mojom::ContactManager> receiver);
private:
+ void HandleClose(const base::ListValue* args);
+ std::vector<std::unique_ptr<Attachment>> attachments_;
+ base::ObserverList<Observer> observers_;
NearbySharingService* nearby_service_;
WEB_UI_CONTROLLER_TYPE_DECL();
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui_browsertest.cc
index a991a02feb9..c53dd9b8bab 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui_browsertest.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/browser_features.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/webui/nearby_share/nearby_share_dialog_ui.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -16,6 +17,14 @@
namespace {
+class TestObserver : public nearby_share::NearbyShareDialogUI::Observer {
+ public:
+ // nearby_share::NearbyShareDialogUI::Observer:
+ void OnClose() override { close_called = true; }
+
+ bool close_called = false;
+};
+
class NearbyShareDialogUITest : public InProcessBrowserTest {
public:
NearbyShareDialogUITest() {
@@ -23,6 +32,8 @@ class NearbyShareDialogUITest : public InProcessBrowserTest {
}
~NearbyShareDialogUITest() override = default;
+ TestObserver observer_;
+
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
@@ -48,3 +59,31 @@ IN_PROC_BROWSER_TEST_F(NearbyShareDialogUITest, RendersComponent) {
&num_nearby_share_app));
EXPECT_EQ(1, num_nearby_share_app);
}
+
+IN_PROC_BROWSER_TEST_F(NearbyShareDialogUITest, ObserverGetsCalledOnClose) {
+ // First, check that navigation succeeds.
+ GURL kUrl(content::GetWebUIURL(chrome::kChromeUINearbyShareHost));
+ ui_test_utils::NavigateToURL(browser(), kUrl);
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(web_contents);
+ EXPECT_EQ(kUrl, web_contents->GetLastCommittedURL());
+ EXPECT_FALSE(web_contents->IsCrashed());
+
+ auto* webui = web_contents->GetWebUI();
+ ASSERT_TRUE(webui);
+
+ // Add a test observer and verify it gets called when 'close' is sent.
+ auto* nearby_ui =
+ webui->GetController()->GetAs<nearby_share::NearbyShareDialogUI>();
+ ASSERT_TRUE(nearby_ui);
+
+ nearby_ui->AddObserver(&observer_);
+ EXPECT_TRUE(content::ExecuteScript(web_contents, "chrome.send('close');"));
+ EXPECT_TRUE(observer_.close_called);
+
+ nearby_ui->RemoveObserver(&observer_);
+ observer_.close_called = false;
+ EXPECT_TRUE(content::ExecuteScript(web_contents, "chrome.send('close');"));
+ EXPECT_FALSE(observer_.close_called);
+}
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_target_types.mojom b/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_target_types.mojom
deleted file mode 100644
index 64acbb05703..00000000000
--- a/chromium/chrome/browser/ui/webui/nearby_share/nearby_share_target_types.mojom
+++ /dev/null
@@ -1,17 +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.
-
-module nearby_share.mojom;
-
-// Describes the type of device for a share target.
-enum ShareTargetType {
- // Unknown device type.
- kUnknown,
- // A phone.
- kPhone,
- // A tablet.
- kTablet,
- // A laptop.
- kLaptop,
-}; \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/nearby_share/public/mojom/BUILD.gn b/chromium/chrome/browser/ui/webui/nearby_share/public/mojom/BUILD.gn
index 0c7c0ce8170..f57ea358fe8 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/public/mojom/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/nearby_share/public/mojom/BUILD.gn
@@ -7,5 +7,8 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") {
sources = [ "nearby_share_settings.mojom" ]
- public_deps = [ "//mojo/public/mojom/base" ]
+ public_deps = [
+ "//mojo/public/mojom/base",
+ "//url/mojom:url_mojom_gurl",
+ ]
}
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 41c92c86ce4..240a8fe529f 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
@@ -3,6 +3,8 @@
// found in the LICENSE file.
module nearby_share.mojom;
+import "url/mojom/url.mojom";
+
// TODO(crbug.com/1110098): Remove kUnknown.
// Represents the data usage preference when sharing.
enum DataUsage {
@@ -28,6 +30,18 @@ enum Visibility {
kSelectedContacts = 3
};
+// Represents the error result when validating the device name.
+enum DeviceNameValidationResult {
+ // The device name was valid.
+ kValid = 0,
+ // The device name must not be empty.
+ kErrorEmpty = 1,
+ // The device name is too long.
+ kErrorTooLong = 2,
+ // The device name is not valid UTF-8.
+ kErrorNotValidUtf8 = 3
+};
+
// This observer interface allows clients to be notified whenever key Nearby
// Share settings are changed.
interface NearbyShareSettingsObserver {
@@ -58,9 +72,14 @@ interface NearbyShareSettings {
// Get the device name shown to a sender when this device is available as
// a share target. |device_name| is the new device name.
GetDeviceName() => (string device_name);
+ // Validate the device name shown to a sender when this device is available
+ // as a share target. This is a separate function so that we can call it to
+ // validate input as a user types.
+ ValidateDeviceName(string device_name) => (DeviceNameValidationResult result);
// Set the device name shown to a sender when this device is available as
- // a share target.
- SetDeviceName(string device_name);
+ // a share target. Before saving the new name this will validate it and
+ // respond with an error if it is invalid.
+ SetDeviceName(string device_name) => (DeviceNameValidationResult result);
// Get which type of network connectivity Nearby Share can operate on.
GetDataUsage() => (DataUsage data_usage);
@@ -72,6 +91,9 @@ interface NearbyShareSettings {
// Set the visibility of this device with respect to the user's contacts.
SetVisibility(Visibility visibility);
+ // TODO(crbug.com/1128110): This functionality has been moved to
+ // ContactManger and will be removed in a follow up CL.
+ //
// Get all contact ids that this device should be visible to when visibility
// is |kSelectedContacts|.
GetAllowedContacts() => (array<string> allowed_contacts);
@@ -79,3 +101,82 @@ interface NearbyShareSettings {
// is |kSelectedContacts|.
SetAllowedContacts(array<string> allowed_contacts);
};
+
+
+// Translated from the proto file (Contact.Identifier):
+// https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/nearby_sharing/proto/rpc_resources.proto
+// A single contact identifier.
+union ContactIdentifier {
+ string obfuscated_gaia;
+ string phone_number;
+ string account_name;
+};
+
+// Translated from the proto file (ContactRecord):
+// https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/nearby_sharing/proto/rpc_resources.proto
+// A contact record from People backend.
+struct ContactRecord {
+ // The stable id of this contact record.
+ string id;
+ // The contact record's name.
+ string person_name;
+ // The URL of an image displayed to the user when selecting a share
+ // target.
+ url.mojom.Url image_url;
+ array<ContactIdentifier> identifiers;
+};
+
+// Allows a client of |ContactManager| to observe contacts downloading results.
+// These events can be in response to direct requests or due to periodic
+// updates.
+//
+// This interface is implemented in a shared Polymer component that is used in
+// two WebUIs: chrome://nearby and chrome://os-settings.
+interface DownloadContactsObserver {
+ // Notifies the observer that contacts have been downloaded successfully and
+ // gives the most recent allowed contact ids at the same time.
+ //
+ // |allowed_contacts| is a set of contacts ids used when visibility is
+ // |Visibility::kSelectedContacts|. This can be set explicitly with
+ // SetAllowedContacts() on |ContactManager|. This array may be empty if the
+ // user has not selected any contacts yet.
+ // |contacts| is a full set of a user's GAIA contacts from the the people
+ // api. The list is pre-sorted by person_name server side. Any ids present
+ // in allowed_contacts will have a corresponding contact record here. This
+ // array may be empty if the user has no contacts (in which case
+ // |allowed_contacts| will also be empty).
+ OnContactsDownloaded(array<string> allowed_contacts,
+ array<ContactRecord> contacts);
+
+ // Notifies the observer that contacts have failed to download.
+ // NOTE: At the moment we don't provide a specific reason as to why this
+ // failed, it is just a signal for the UI to show a generic error/retry page.
+ OnContactsDownloadFailed();
+};
+
+// The contacts manager allows clients to observe contacts downloading status
+// and results. Contact downloads can happen periodically or on demand with
+// DownloadContacts(). The results are not returned directly on DownloadContacts
+// because multiple queued download requests may result in only a single
+// response and a client is likely interested in getting any contacts download
+// even if they did not explicitly request it (i.e. periodic update).
+//
+// Implemented in the browser process and owned by a keyed service.
+interface ContactManager {
+ // Adds an observer which can listen for the success or failure of contact
+ // downloading.
+ AddDownloadContactsObserver(pending_remote<DownloadContactsObserver>
+ observer);
+
+ // Request a download of contacts from the server. This will queue the call
+ // with the scheduler which may or may not execute right away depending on the
+ // online state of the device.
+ DownloadContacts();
+
+ // Set all contact ids that this device should be visible to when visibility
+ // is |Visibility::kSelectedContacts|. Once set, this will update the device's
+ // private certificates. The latest value of this will be sent on the next
+ // OnContactsDownloaded event on the observer interface, but it will not
+ // trigger an immediate OnContactsDownloaded() event.
+ SetAllowedContacts(array<string> allowed_contacts);
+};
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 8d980947274..ef223625bb6 100644
--- a/chromium/chrome/browser/ui/webui/nearby_share/shared_resources.cc
+++ b/chromium/chrome/browser/ui/webui/nearby_share/shared_resources.cc
@@ -7,36 +7,138 @@
#include <string>
#include "base/containers/span.h"
+#include "base/logging.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/nearby_share_dialog_resources.h"
#include "chrome/grit/nearby_share_dialog_resources_map.h"
+#include "chrome/grit/nearby_shared_resources.h"
+#include "chrome/grit/nearby_shared_resources_map.h"
+#include "chrome/grit/nearby_shared_resources_v3.h"
+#include "chrome/grit/nearby_shared_resources_v3_map.h"
#include "ui/base/webui/web_ui_util.h"
const char kNearbyShareGeneratedPath[] =
"@out_folder@/gen/chrome/browser/resources/nearby_share/";
-void RegisterNearbySharedMojoResources(content::WebUIDataSource* data_source) {
- data_source->AddResourcePath("mojo/nearby_share_settings.mojom-lite.js",
- IDR_NEARBY_SHARE_SETTINGS_MOJOM_LITE_JS);
-}
+namespace {
-void RegisterNearbySharedResources(content::WebUIDataSource* data_source) {
+void RegisterResourcesWithPrefix(
+ content::WebUIDataSource* data_source,
+ const base::span<const GritResourceMap>& resources,
+ std::string prefix) {
std::string generate_path{kNearbyShareGeneratedPath};
- for (const GritResourceMap& resource : base::make_span(
- kNearbyShareDialogResources, kNearbyShareDialogResourcesSize)) {
+ for (const GritResourceMap& resource : resources) {
std::string path = resource.name;
if (path.rfind(generate_path, 0) == 0) {
path = path.substr(generate_path.size());
+ } else {
+ path = prefix + path;
}
data_source->AddResourcePath(path, resource.value);
}
+}
+
+} // namespace
+
+void RegisterNearbySharedMojoResources(content::WebUIDataSource* data_source) {
+ data_source->AddResourcePath("mojo/nearby_share.mojom-lite.js",
+ IDR_NEARBY_SHARE_MOJO_JS);
+ data_source->AddResourcePath("mojo/nearby_share_target_types.mojom-lite.js",
+ IDR_NEARBY_SHARE_TARGET_TYPES_MOJO_JS);
+ data_source->AddResourcePath("mojo/nearby_share_settings.mojom-lite.js",
+ IDR_NEARBY_SHARE_SETTINGS_MOJOM_LITE_JS);
+}
+
+void RegisterNearbySharedResources(content::WebUIDataSource* data_source) {
+ RegisterResourcesWithPrefix(
+ data_source,
+ /*resources=*/
+ base::make_span(kNearbySharedResources, kNearbySharedResourcesSize),
+ /*prefix=*/"shared/");
+ RegisterResourcesWithPrefix(
+ data_source,
+ /*resources=*/
+ base::make_span(kNearbySharedResourcesV3, kNearbySharedResourcesV3Size),
+ /*prefix=*/"shared/");
RegisterNearbySharedMojoResources(data_source);
}
void RegisterNearbySharedStrings(content::WebUIDataSource* data_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"secureConnectionId", IDS_NEARBY_SECURE_CONNECTION_ID},
- };
+ {"nearbyShareAccountRowLabel", IDS_NEARBY_ACCOUNT_ROW_LABEL},
+ {"nearbyShareActionsCancel", IDS_NEARBY_ACTIONS_CANCEL},
+ {"nearbyShareActionsConfirm", IDS_NEARBY_ACTIONS_CONFIRM},
+ {"nearbyShareActionsNext", IDS_NEARBY_ACTIONS_NEXT},
+ {"nearbyShareActionsReject", IDS_NEARBY_ACTIONS_REJECT},
+ {"nearbyShareConfirmationPageAddContactSubtitle",
+ IDS_NEARBY_CONFIRMATION_PAGE_ADD_CONTACT_SUBTITLE},
+ {"nearbyShareConfirmationPageAddContactTitle",
+ IDS_NEARBY_CONFIRMATION_PAGE_ADD_CONTACT_TITLE},
+ {"nearbyShareConfirmationPageTitle", IDS_NEARBY_CONFIRMATION_PAGE_TITLE},
+ {"nearbyShareContactVisibilityAll", IDS_NEARBY_VISIBLITY_ALL_CONTACTS},
+ {"nearbyShareContactVisibilityAllDescription",
+ IDS_NEARBY_VISIBLITY_ALL_CONTACTS_DESCRIPTION},
+ {"nearbyShareContactVisibilityContactsTitle",
+ IDS_NEARBY_CONTACT_VISIBILITY_CONTACTS_TITLE},
+ {"nearbyShareContactVisibilityNearbyShareOpenOthers",
+ IDS_NEARBY_CONTACT_VISIBILITY_NEARBY_SHARE_OPEN_OTHERS},
+ {"nearbyShareContactVisibilityNearbyShareOpenOwn",
+ IDS_NEARBY_CONTACT_VISIBILITY_NEARBY_SHARE_OPEN_OWN},
+ {"nearbyShareContactVisibilityNoContactsSubtitle",
+ IDS_NEARBY_CONTACT_VISIBILITY_NO_CONTACTS_SUBTITLE},
+ {"nearbyShareContactVisibilityNoContactsTitle",
+ IDS_NEARBY_CONTACT_VISIBILITY_NO_CONTACTS_TITLE},
+ {"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},
+ {"nearbyShareDeviceNameTooLongError",
+ IDS_NEARBY_DEVICE_NAME_TOO_LONG_ERROR},
+ {"nearbyShareDeviceNameInvalidCharactersError",
+ IDS_NEARBY_DEVICE_NAME_INVALID_CHARACTERS_ERROR},
+ {"nearbyShareDiscoveryPageInfo", IDS_NEARBY_DISCOVERY_PAGE_INFO},
+ {"nearbyShareDiscoveryPageSubtitle", IDS_NEARBY_DISCOVERY_PAGE_SUBTITLE},
+ {"nearbyShareDiscoveryPageTitle", IDS_NEARBY_DISCOVERY_PAGE_TITLE},
+ {"nearbyShareFeatureName", IDS_NEARBY_SHARE_FEATURE_NAME},
+ {"nearbyShareOnboardingPageDeviceName",
+ IDS_NEARBY_ONBOARDING_PAGE_DEVICE_NAME},
+ {"nearbyShareOnboardingPageSubtitle",
+ IDS_NEARBY_ONBOARDING_PAGE_SUBTITLE},
+ {"nearbyShareOnboardingPageTitle", IDS_NEARBY_ONBOARDING_PAGE_TITLE},
+ {"nearbyShareSecureConnectionId", IDS_NEARBY_SECURE_CONNECTION_ID},
+ {"nearbyShareVisibilityPageManageContacts",
+ IDS_NEARBY_VISIBILITY_PAGE_MANAGE_CONTACTS},
+ {"nearbyShareVisibilityPageSubtitle",
+ IDS_NEARBY_VISIBILITY_PAGE_SUBTITLE},
+ {"nearbyShareVisibilityPageTitle", IDS_NEARBY_VISIBILITY_PAGE_TITLE},
+ {"nearbyShareHighVisibilitySubTitle",
+ IDS_NEARBY_HIGH_VISIBILITY_SUB_TITLE},
+ {"nearbyShareHighVisibilityHelpText",
+ IDS_NEARBY_HIGH_VISIBILITY_HELP_TEXT},
+ {"nearbyShareReceiveConfirmPageTitle",
+ IDS_NEARBY_RECEIVE_CONFIRM_PAGE_TITLE}};
webui::AddLocalizedStringsBulk(data_source, kLocalizedStrings);
}
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 a28efd40faa..eb9e2b68fa1 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,12 +4,13 @@
module new_tab_page.mojom;
+import "chrome/common/search/omnibox.mojom";
+import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/text_direction.mojom";
import "mojo/public/mojom/base/time.mojom";
import "skia/public/mojom/skcolor.mojom";
import "url/mojom/url.mojom";
-import "mojo/public/mojom/base/string16.mojom";
-import "chrome/common/search/omnibox.mojom";
+
struct OneGoogleBarParts {
string bar_html;
@@ -41,13 +42,6 @@ struct MostVisitedInfo {
array<MostVisitedTile> tiles;
};
-struct ThemeColors {
- // The theme's frame color.
- skia.mojom.SkColor frame;
- // The theme's active tab color.
- skia.mojom.SkColor active_tab;
-};
-
// A collection of background images.
struct BackgroundCollection {
// Collection identifier.
@@ -71,40 +65,6 @@ struct CollectionImage {
url.mojom.Url preview_image_url;
};
-// A predefined theme provided by Chrome. Created from data embedded in the
-// Chrome binary.
-struct ChromeTheme {
- // Theme identifier.
- int32 id;
- // Localized string of the theme name.
- string label;
- ThemeColors colors;
-};
-
-enum ThemeType {
- kDefault,
- kAutogenerated,
- kChrome,
- kThirdParty,
-};
-
-// Additional info for third-party themes.
-struct ThirdPartyThemeInfo {
- // ID in the Chrome Web Store.
- string id;
- // Human-readable theme name.
- string name;
-};
-
-union ThemeInfo {
- // Set if the theme is a Chrome theme.
- int32 chrome_theme_id;
- // Set if the theme is autogenerated.
- ThemeColors autogenerated_theme_colors;
- // Set if the theme is a third-party theme.
- ThirdPartyThemeInfo third_party_theme_info;
-};
-
// Theme settings for the NTP realbox.
struct SearchBoxTheme {
skia.mojom.SkColor bg;
@@ -141,8 +101,6 @@ struct BackgroundImage {
// A generic theme.
struct Theme {
- // The theme's type (e.g. default or third-party).
- ThemeType type;
skia.mojom.SkColor background_color;
skia.mojom.SkColor shortcut_background_color;
skia.mojom.SkColor shortcut_text_color;
@@ -150,6 +108,8 @@ struct Theme {
bool shortcut_use_white_add_icon;
// True if the shortcuts titles should be wrapped in a pill.
bool shortcut_use_title_pill;
+ // True if the theme is default.
+ bool is_default;
// True if the theme is dark (e.g. NTP background color is dark).
bool is_dark;
// Color of Google logo. If not set show the logo multi-colored.
@@ -164,11 +124,6 @@ struct Theme {
// URL associated with the background image. Used for href.
url.mojom.Url? background_image_attribution_url;
- // TODO(crbug.com/1040682): Additional info about the theme depending on the
- // type. That should be optional since only some themes require it. However,
- // making this field optional crashes JS.
- ThemeInfo info;
-
// Theme settings for the NTP realbox. Matching those of the Omnibox.
SearchBoxTheme search_box;
};
@@ -251,6 +206,38 @@ enum DoodleShareChannel {
kLinkCopy,
};
+struct PromoImagePart {
+ url.mojom.Url image_url;
+ url.mojom.Url target;
+};
+
+struct PromoLinkPart {
+ string? color;
+ string text;
+ url.mojom.Url url;
+};
+
+struct PromoTextPart {
+ string? color;
+ string text;
+};
+
+union PromoPart {
+ PromoImagePart image;
+ PromoLinkPart link;
+ PromoTextPart text;
+};
+
+// Homepage promo used to display a message with a link on the NTP.
+struct Promo {
+ // A unique identifier for this promo.
+ string? id;
+ // URL to ping to log a promo impression. May be invalid.
+ url.mojom.Url? log_url;
+ // Middle slot promo data.
+ array<PromoPart> middle_slot_parts;
+};
+
// Action the user performed while using the customize dialog. Used for metrics
// logging only. Actions correspond to items in NTPLoggingEventType.
enum CustomizeDialogAction {
@@ -332,18 +319,6 @@ interface PageHandler {
UpdateMostVisitedTile(url.mojom.Url url, url.mojom.Url new_url,
string new_title)
=> (bool success);
- // Returns the pre-defined Chrome themes.
- GetChromeThemes() => (array<ChromeTheme> chromeThemes);
- // Applies the default theme.
- ApplyDefaultTheme();
- // Applies autogenerated theme for the given color.
- ApplyAutogeneratedTheme(skia.mojom.SkColor frame_color);
- // Applies the predefined Chrome theme with the given ID.
- ApplyChromeTheme(int32 id);
- // Confirms changes made to the theme.
- ConfirmThemeChanges();
- // Reverts changes made to the theme.
- RevertThemeChanges();
// Returns the collections of background images.
GetBackgroundCollections() => (array<BackgroundCollection> collections);
// Returns the images of a collection identified by |collection_id|.
@@ -360,6 +335,16 @@ interface PageHandler {
// parameters to the endpoint that serves the OneGoogleBar parts with
// |query_params|.
GetOneGoogleBarParts(string query_params) => (OneGoogleBarParts? parts);
+ // Get the middle slot promo if it exists.
+ GetPromo() => (Promo? promo);
+ // Called when a module the given id is dismissed.
+ OnDismissModule(string module_id);
+ // Called when a module the given id is restored.
+ 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();
// ======= METRICS =======
// Logs that |tiles| were displayed / updated at |time|. The first instance of
@@ -368,8 +353,9 @@ interface PageHandler {
// Logs that the One Google Bar was added to the DOM / loaded in an iframe at
// |time|.
OnOneGoogleBarRendered(double time);
- // Logs that the promo iframe was loaded at |time|.
- OnPromoRendered(double time);
+ // Logs that the promo iframe was loaded at |time| and pings |log_url| for
+ // promo metrics logging.
+ OnPromoRendered(double time, url.mojom.Url? log_url);
// Logs that |tile| at position |index| was triggered to navigate to that
// most visited entry.
OnMostVisitedTileNavigation(MostVisitedTile tile, uint32 index);
@@ -399,6 +385,15 @@ interface PageHandler {
OnVoiceSearchAction(VoiceSearchAction action);
// Logs an error occurred while using voice search.
OnVoiceSearchError(VoiceSearchError error);
+ // 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 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);
// ======= REALBOX =======
// Queries autocomplete matches from the browser.
@@ -446,6 +441,8 @@ interface Page {
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.
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 8c872e06796..12a7b14e8c2 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
@@ -10,6 +10,8 @@
#include "base/files/file_path.h"
#include "base/i18n/rtl.h"
#include "base/json/json_reader.h"
+#include "base/json/json_string_value_serializer.h"
+#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
@@ -22,6 +24,7 @@
#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"
@@ -30,10 +33,9 @@
#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/chrome_colors/chrome_colors_factory.h"
-#include "chrome/browser/search/chrome_colors/chrome_colors_service.h"
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service_factory.h"
+#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"
@@ -41,9 +43,8 @@
#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/common/search/generated_colors_info.h"
#include "chrome/common/search/instant_types.h"
-#include "chrome/common/themes/autogenerated_theme_util.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"
@@ -55,6 +56,7 @@
#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/search_engines/omnibox_focus_type.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_provider_logos/logo_service.h"
@@ -70,34 +72,11 @@ namespace {
const int64_t kMaxDownloadBytes = 1024 * 1024;
+constexpr char kModulesVisiblePrefName[] = "NewTabPage.ModulesVisible";
+
new_tab_page::mojom::ThemePtr MakeTheme(const NtpTheme& ntp_theme) {
auto theme = new_tab_page::mojom::Theme::New();
- if (ntp_theme.using_default_theme) {
- theme->type = new_tab_page::mojom::ThemeType::kDefault;
- // TODO(crbug.com/1040682): This info has no meaning for the default theme
- // and shouldn't be used. We set it here to prevent a crash where mojo is
- // complaing about an unset info. However, we cannot make the field optional
- // as that is crashing JS. Once the JS crash is solved remove this line.
- theme->info = new_tab_page::mojom::ThemeInfo::NewChromeThemeId(-1);
- } else if (ntp_theme.color_id == -1) {
- theme->type = new_tab_page::mojom::ThemeType::kThirdParty;
- auto info = new_tab_page::mojom::ThirdPartyThemeInfo::New();
- info->id = ntp_theme.theme_id;
- info->name = ntp_theme.theme_name;
- theme->info =
- new_tab_page::mojom::ThemeInfo::NewThirdPartyThemeInfo(std::move(info));
- } else if (ntp_theme.color_id == 0) {
- theme->type = new_tab_page::mojom::ThemeType::kAutogenerated;
- auto theme_colors = new_tab_page::mojom::ThemeColors::New();
- theme_colors->frame = ntp_theme.color_dark;
- theme_colors->active_tab = ntp_theme.color_light;
- theme->info = new_tab_page::mojom::ThemeInfo::NewAutogeneratedThemeColors(
- std::move(theme_colors));
- } else {
- theme->type = new_tab_page::mojom::ThemeType::kChrome;
- theme->info =
- new_tab_page::mojom::ThemeInfo::NewChromeThemeId(ntp_theme.color_id);
- }
+ theme->is_default = ntp_theme.using_default_theme;
theme->background_color = ntp_theme.background_color;
theme->shortcut_background_color = ntp_theme.shortcut_color;
theme->shortcut_text_color = ntp_theme.text_color;
@@ -287,8 +266,84 @@ new_tab_page::mojom::ImageDoodlePtr MakeImageDoodle(
return doodle;
}
+new_tab_page::mojom::PromoPtr MakePromo(const PromoData& data) {
+ // |data.middle_slot_json| is safe to be decoded here. The JSON string is part
+ // of a larger JSON initially decoded using the data decoder utility in the
+ // PromoService to base::Value. The middle-slot promo part is then reencoded
+ // from base::Value to a JSON string stored in |data.middle_slot_json|.
+ auto middle_slot = base::JSONReader::Read(data.middle_slot_json);
+ if (!middle_slot.has_value() ||
+ middle_slot.value().FindBoolPath("hidden").value_or(false)) {
+ return nullptr;
+ }
+ auto promo = new_tab_page::mojom::Promo::New();
+ promo->id = data.promo_id;
+ if (middle_slot.has_value()) {
+ auto* parts = middle_slot.value().FindListPath("part");
+ if (parts) {
+ std::vector<new_tab_page::mojom::PromoPartPtr> mojom_parts;
+ for (const base::Value& part : parts->GetList()) {
+ if (part.FindKey("image")) {
+ auto mojom_image = new_tab_page::mojom::PromoImagePart::New();
+ auto* image_url = part.FindStringPath("image.image_url");
+ if (!image_url || image_url->empty()) {
+ continue;
+ }
+ mojom_image->image_url = GURL(*image_url);
+ auto* target = part.FindStringPath("image.target");
+ if (target && !target->empty()) {
+ mojom_image->target = GURL(*target);
+ }
+ mojom_parts.push_back(
+ new_tab_page::mojom::PromoPart::NewImage(std::move(mojom_image)));
+ } else if (part.FindKey("link")) {
+ auto mojom_link = new_tab_page::mojom::PromoLinkPart::New();
+ auto* url = part.FindStringPath("link.url");
+ if (!url || url->empty()) {
+ continue;
+ }
+ mojom_link->url = GURL(*url);
+ auto* text = part.FindStringPath("link.text");
+ if (!text || text->empty()) {
+ continue;
+ }
+ mojom_link->text = *text;
+ auto* color = part.FindStringPath("link.color");
+ if (color && !color->empty()) {
+ mojom_link->color = *color;
+ }
+ mojom_parts.push_back(
+ new_tab_page::mojom::PromoPart::NewLink(std::move(mojom_link)));
+ } else if (part.FindKey("text")) {
+ auto mojom_text = new_tab_page::mojom::PromoTextPart::New();
+ auto* text = part.FindStringPath("text.text");
+ if (!text || text->empty()) {
+ continue;
+ }
+ mojom_text->text = *text;
+ auto* color = part.FindStringPath("text.color");
+ if (color && !color->empty()) {
+ mojom_text->color = *color;
+ }
+ mojom_parts.push_back(
+ new_tab_page::mojom::PromoPart::NewText(std::move(mojom_text)));
+ }
+ }
+ promo->middle_slot_parts = std::move(mojom_parts);
+ }
+ }
+ promo->log_url = data.promo_log_url;
+ return promo;
+}
+
} // namespace
+// static
+const char NewTabPageHandler::kModuleDismissedHistogram[] =
+ "NewTabPage.Modules.Dismissed";
+const char NewTabPageHandler::kModuleRestoredHistogram[] =
+ "NewTabPage.Modules.Restored";
+
NewTabPageHandler::NewTabPageHandler(
mojo::PendingReceiver<new_tab_page::mojom::PageHandler>
pending_page_handler,
@@ -298,9 +353,7 @@ NewTabPageHandler::NewTabPageHandler(
content::WebContents* web_contents,
NTPUserDataLogger* logger,
const base::Time& ntp_navigation_start_time)
- : chrome_colors_service_(
- chrome_colors::ChromeColorsFactory::GetForProfile(profile)),
- instant_service_(instant_service),
+ : instant_service_(instant_service),
ntp_background_service_(
NtpBackgroundServiceFactory::GetForProfile(profile)),
logo_service_(LogoServiceFactory::GetForProfile(profile)),
@@ -318,11 +371,14 @@ NewTabPageHandler::NewTabPageHandler(
web_contents_(web_contents),
ntp_navigation_start_time_(ntp_navigation_start_time),
logger_(logger),
+ promo_service_(PromoServiceFactory::GetForProfile(profile)),
page_{std::move(pending_page)},
receiver_{this, std::move(pending_page_handler)} {
CHECK(instant_service_);
CHECK(ntp_background_service_);
CHECK(logo_service_);
+ CHECK(one_google_bar_service_);
+ CHECK(promo_service_);
CHECK(web_contents_);
CHECK(logger_);
instant_service_->AddObserver(this);
@@ -330,11 +386,10 @@ NewTabPageHandler::NewTabPageHandler(
instant_service_->UpdateNtpTheme();
OmniboxTabHelper::CreateForWebContents(web_contents);
OmniboxTabHelper::FromWebContents(web_contents_)->AddObserver(this);
- // |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_);
- }
+ promo_service_observer_.Add(promo_service_);
+ one_google_bar_service_observer_.Add(one_google_bar_service_);
+ logger_->SetModulesVisible(
+ profile_->GetPrefs()->GetBoolean(kModulesVisiblePrefName));
}
NewTabPageHandler::~NewTabPageHandler() {
@@ -349,6 +404,11 @@ NewTabPageHandler::~NewTabPageHandler() {
}
}
+// static
+void NewTabPageHandler::RegisterProfilePrefs(PrefRegistrySimple* registry) {
+ registry->RegisterBooleanPref(kModulesVisiblePrefName, true);
+}
+
void NewTabPageHandler::AddMostVisitedTile(
const GURL& url,
const std::string& title,
@@ -424,51 +484,6 @@ void NewTabPageHandler::UndoMostVisitedTileAction() {
}
}
-void NewTabPageHandler::GetChromeThemes(GetChromeThemesCallback callback) {
- std::vector<new_tab_page::mojom::ChromeThemePtr> themes;
- for (const auto& color_info : chrome_colors::kGeneratedColorsInfo) {
- auto theme_colors = GetAutogeneratedThemeColors(color_info.color);
- auto theme = new_tab_page::mojom::ChromeTheme::New();
- theme->id = color_info.id;
- theme->label = l10n_util::GetStringUTF8(color_info.label_id);
- auto colors = new_tab_page::mojom::ThemeColors::New();
- colors->frame = theme_colors.frame_color;
- colors->active_tab = theme_colors.active_tab_color;
- theme->colors = std::move(colors);
- themes.push_back(std::move(theme));
- }
- std::move(callback).Run(std::move(themes));
-}
-
-void NewTabPageHandler::ApplyDefaultTheme() {
- chrome_colors_service_->ApplyDefaultTheme(web_contents_);
-}
-
-void NewTabPageHandler::ApplyAutogeneratedTheme(const SkColor& frame_color) {
- chrome_colors_service_->ApplyAutogeneratedTheme(frame_color, web_contents_);
-}
-
-void NewTabPageHandler::ApplyChromeTheme(int32_t id) {
- auto* begin = std::begin(chrome_colors::kGeneratedColorsInfo);
- auto* end = std::end(chrome_colors::kGeneratedColorsInfo);
- auto* result = std::find_if(begin, end,
- [id](const chrome_colors::ColorInfo& color_info) {
- return color_info.id == id;
- });
- if (result == end) {
- return;
- }
- chrome_colors_service_->ApplyAutogeneratedTheme(result->color, web_contents_);
-}
-
-void NewTabPageHandler::ConfirmThemeChanges() {
- chrome_colors_service_->ConfirmThemeChanges();
-}
-
-void NewTabPageHandler::RevertThemeChanges() {
- chrome_colors_service_->RevertThemeChanges();
-}
-
void NewTabPageHandler::SetBackgroundImage(const std::string& attribution_1,
const std::string& attribution_2,
const GURL& attribution_url,
@@ -613,6 +628,101 @@ void NewTabPageHandler::GetOneGoogleBarParts(
one_google_bar_service_->Refresh();
}
+void NewTabPageHandler::GetPromo(GetPromoCallback callback) {
+ // Replace the promo URL with "command:<id>" if such a command ID is set
+ // via the feature params.
+ const std::string command_id = base::GetFieldTrialParamValueByFeature(
+ features::kPromoBrowserCommands, features::kPromoBrowserCommandIdParam);
+ if (!command_id.empty()) {
+ auto promo = new_tab_page::mojom::Promo::New();
+ std::vector<new_tab_page::mojom::PromoPartPtr> parts;
+ auto image = new_tab_page::mojom::PromoImagePart::New();
+ // Warning symbol used as the test image.
+ image->image_url = GURL(
+ "data:image/"
+ "svg+xml;base64,"
+ "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii01IC"
+ "01IDU4IDU4IiBmaWxsPSIjZmRkNjMzIj48cGF0aCBkPSJNMiA0Mmg0NEwyNCA0IDIgNDJ6"
+ "bTI0LTZoLTR2LTRoNHY0em0wLThoLTR2LThoNHY4eiIvPjwvc3ZnPg==");
+ image->target = GURL("command:" + command_id);
+ parts.push_back(new_tab_page::mojom::PromoPart::NewImage(std::move(image)));
+ auto link = new_tab_page::mojom::PromoLinkPart::New();
+ link->url = GURL("command:" + command_id);
+ link->text = "Test command: " + command_id;
+ parts.push_back(new_tab_page::mojom::PromoPart::NewLink(std::move(link)));
+ promo->middle_slot_parts = std::move(parts);
+ std::move(callback).Run(std::move(promo));
+ return;
+ }
+
+ promo_callbacks_.push_back(std::move(callback));
+ if (promo_service_->promo_data().has_value()) {
+ OnPromoDataUpdated();
+ }
+ promo_load_start_time_ = base::TimeTicks::Now();
+ promo_service_->Refresh();
+}
+
+void NewTabPageHandler::OnDismissModule(const std::string& module_id) {
+ const std::string histogram_prefix(kModuleDismissedHistogram);
+ base::UmaHistogramExactLinear(histogram_prefix, 1, 1);
+ base::UmaHistogramExactLinear(histogram_prefix + "." + module_id, 1, 1);
+}
+
+void NewTabPageHandler::OnRestoreModule(const std::string& module_id) {
+ const std::string histogram_prefix(kModuleRestoredHistogram);
+ base::UmaHistogramExactLinear(histogram_prefix, 1, 1);
+ base::UmaHistogramExactLinear(histogram_prefix + "." + module_id, 1, 1);
+}
+
+void NewTabPageHandler::SetModulesVisible(bool visible) {
+ profile_->GetPrefs()->SetBoolean(kModulesVisiblePrefName, visible);
+ UpdateModulesVisible();
+}
+
+void NewTabPageHandler::UpdateModulesVisible() {
+ page_->SetModulesVisible(
+ profile_->GetPrefs()->GetBoolean(kModulesVisiblePrefName));
+}
+
+void NewTabPageHandler::OnPromoDataUpdated() {
+ if (promo_load_start_time_.has_value()) {
+ base::TimeDelta duration = base::TimeTicks::Now() - *promo_load_start_time_;
+ UMA_HISTOGRAM_MEDIUM_TIMES("NewTabPage.Promos.RequestLatency2", duration);
+ if (promo_service_->promo_status() == PromoService::Status::OK_WITH_PROMO) {
+ UMA_HISTOGRAM_MEDIUM_TIMES(
+ "NewTabPage.Promos.RequestLatency2.SuccessWithPromo", duration);
+ } else if (promo_service_->promo_status() ==
+ PromoService::Status::OK_BUT_BLOCKED) {
+ UMA_HISTOGRAM_MEDIUM_TIMES(
+ "NewTabPage.Promos.RequestLatency2.SuccessButBlocked", duration);
+ } else if (promo_service_->promo_status() ==
+ PromoService::Status::OK_WITHOUT_PROMO) {
+ UMA_HISTOGRAM_MEDIUM_TIMES(
+ "NewTabPage.Promos.RequestLatency2.SuccessWithoutPromo", duration);
+ } else {
+ UMA_HISTOGRAM_MEDIUM_TIMES("NewTabPage.Promos.RequestLatency2.Failure",
+ duration);
+ }
+ promo_load_start_time_ = base::nullopt;
+ }
+
+ const auto& data = promo_service_->promo_data();
+ for (auto& callback : promo_callbacks_) {
+ if (data.has_value() && !data->promo_html.empty()) {
+ std::move(callback).Run(MakePromo(data.value()));
+ } else {
+ std::move(callback).Run(nullptr);
+ }
+ }
+ promo_callbacks_.clear();
+}
+
+void NewTabPageHandler::OnPromoServiceShuttingDown() {
+ promo_service_observer_.RemoveAll();
+ promo_service_ = nullptr;
+}
+
void NewTabPageHandler::OnMostVisitedTilesRendered(
std::vector<new_tab_page::mojom::MostVisitedTilePtr> tiles,
double time) {
@@ -630,9 +740,13 @@ void NewTabPageHandler::OnOneGoogleBarRendered(double time) {
base::Time::FromJsTime(time) - ntp_navigation_start_time_);
}
-void NewTabPageHandler::OnPromoRendered(double 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_);
+ if (log_url.has_value() && log_url->is_valid()) {
+ Fetch(*log_url, base::BindOnce([](bool, std::unique_ptr<std::string>) {}));
+ }
}
void NewTabPageHandler::OnMostVisitedTileNavigation(
@@ -846,6 +960,27 @@ void NewTabPageHandler::OnVoiceSearchError(
LogEvent(event);
}
+void NewTabPageHandler::OnModuleImpression(const std::string& module_id,
+ double time) {
+ logger_->LogModuleImpression(
+ module_id, base::Time::FromJsTime(time) - ntp_navigation_start_time_);
+}
+
+void NewTabPageHandler::OnModuleLoaded(const std::string& module_id,
+ double time) {
+ logger_->LogModuleLoaded(
+ module_id, base::Time::FromJsTime(time) - ntp_navigation_start_time_);
+}
+
+void NewTabPageHandler::OnModuleUsage(const std::string& 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_) {
@@ -1117,6 +1252,7 @@ void NewTabPageHandler::OnCollectionImagesAvailable() {
std::vector<new_tab_page::mojom::CollectionImagePtr> images;
if (ntp_background_service_->collection_images().empty()) {
std::move(background_images_callback_).Run(std::move(images));
+ return;
}
auto collection_id =
ntp_background_service_->collection_images()[0].collection_id;
@@ -1342,13 +1478,13 @@ void NewTabPageHandler::Fetch(const GURL& url,
net::DefineNetworkTrafficAnnotation("new_tab_page_handler", R"(
semantics {
sender: "New Tab Page"
- description: "Logs impression and interaction with the doodle."
+ description: "Logs impression and interaction with doodle or promo."
trigger:
- "Showing or clicking on the doodle on the New Tab Page. Desktop "
- "only."
+ "Showing or clicking on the doodle or promo on the New Tab Page. "
+ "Desktop only."
data:
- "String identifiying todays doodle and token identifying a single "
- "doodle interaction session. Data does not contain PII."
+ "String identifiying todays doodle or promo and token identifying "
+ "a single interaction session. Data does not contain PII."
destination: GOOGLE_OWNED_SERVICE
}
policy {
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 21c02580441..17854b75b34 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
@@ -6,9 +6,11 @@
#define CHROME_BROWSER_UI_WEBUI_NEW_TAB_PAGE_NEW_TAB_PAGE_HANDLER_H_
#include <unordered_map>
+#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "base/optional.h"
#include "base/scoped_observer.h"
#include "base/time/time.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"
@@ -16,6 +18,8 @@
#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/webui/new_tab_page/new_tab_page.mojom.h"
#include "chrome/common/search/instant_types.h"
@@ -36,10 +40,6 @@ class NtpBackgroundService;
class Profile;
class NTPUserDataLogger;
-namespace chrome_colors {
-class ChromeColorsService;
-} // namespace chrome_colors
-
namespace content {
class WebContents;
} // namespace content
@@ -54,7 +54,8 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
public OmniboxTabHelper::Observer,
public OneGoogleBarServiceObserver,
public ui::SelectFileDialog::Listener,
- public AutocompleteController::Observer {
+ public AutocompleteController::Observer,
+ public PromoServiceObserver {
public:
NewTabPageHandler(mojo::PendingReceiver<new_tab_page::mojom::PageHandler>
pending_page_handler,
@@ -66,6 +67,12 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
const base::Time& ntp_navigation_start_time);
~NewTabPageHandler() override;
+ // Histograms being recorded when a module is dismissed or restored.
+ static const char kModuleDismissedHistogram[];
+ static const char kModuleRestoredHistogram[];
+
+ static void RegisterProfilePrefs(PrefRegistrySimple* registry);
+
// new_tab_page::mojom::PageHandler:
void AddMostVisitedTile(const GURL& url,
const std::string& title,
@@ -80,12 +87,6 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
const GURL& new_url,
const std::string& new_title,
UpdateMostVisitedTileCallback callback) override;
- void ApplyDefaultTheme() override;
- void ApplyAutogeneratedTheme(const SkColor& frame_color) override;
- void ApplyChromeTheme(int32_t id) override;
- void ConfirmThemeChanges() override;
- void GetChromeThemes(GetChromeThemesCallback callback) override;
- void RevertThemeChanges() override;
void SetBackgroundImage(const std::string& attribution_1,
const std::string& attribution_2,
const GURL& attribution_url,
@@ -103,11 +104,17 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
ChooseLocalCustomBackgroundCallback callback) override;
void GetOneGoogleBarParts(const std::string& ogdeb_value,
GetOneGoogleBarPartsCallback callback) override;
+ void GetPromo(GetPromoCallback callback) override;
+ 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 OnMostVisitedTilesRendered(
std::vector<new_tab_page::mojom::MostVisitedTilePtr> tiles,
double time) override;
void OnOneGoogleBarRendered(double time) override;
- void OnPromoRendered(double time) override;
+ void OnPromoRendered(double time,
+ const base::Optional<GURL>& log_url) override;
void OnMostVisitedTileNavigation(new_tab_page::mojom::MostVisitedTilePtr tile,
uint32_t index) override;
void OnCustomizeDialogAction(
@@ -125,6 +132,10 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
void OnVoiceSearchAction(
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 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;
@@ -161,6 +172,10 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
void OnOneGoogleBarDataUpdated() override;
void OnOneGoogleBarServiceShuttingDown() override;
+ // PromoServiceObserver:
+ void OnPromoDataUpdated() override;
+ void OnPromoServiceShuttingDown() override;
+
// SelectFileDialog::Listener:
void FileSelected(const base::FilePath& path,
int index,
@@ -197,7 +212,6 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
std::unique_ptr<std::string> body);
ChooseLocalCustomBackgroundCallback choose_local_custom_background_callback_;
- chrome_colors::ChromeColorsService* chrome_colors_service_;
InstantService* instant_service_;
NtpBackgroundService* ntp_background_service_;
search_provider_logos::LogoService* logo_service_;
@@ -225,6 +239,11 @@ class NewTabPageHandler : public new_tab_page::mojom::PageHandler,
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::Optional<base::TimeTicks> promo_load_start_time_;
// These are located at the end of the list of member variables to ensure the
// WebUI page is disconnected before other members are destroyed.
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 7624cacbf63..1b7460da19c 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
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#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"
@@ -49,6 +50,7 @@ class MockPage : public new_tab_page::mojom::Page {
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_METHOD1(AutocompleteResultChanged,
void(search::mojom::AutocompleteResultPtr));
MOCK_METHOD3(AutocompleteMatchImageAvailable,
@@ -89,6 +91,7 @@ class NewTabPageHandlerTest : public testing::Test {
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_;
};
@@ -104,3 +107,26 @@ TEST_F(NewTabPageHandlerTest, SetTheme) {
NtpTheme theme;
instant_service_observer_->NtpThemeChanged(theme);
}
+
+TEST_F(NewTabPageHandlerTest, Histograms) {
+ histogram_tester_.ExpectTotalCount(
+ NewTabPageHandler::kModuleDismissedHistogram, 0);
+ histogram_tester_.ExpectTotalCount(
+ NewTabPageHandler::kModuleRestoredHistogram, 0);
+
+ handler_->OnDismissModule("shopping_tasks");
+ histogram_tester_.ExpectTotalCount(
+ NewTabPageHandler::kModuleDismissedHistogram, 1);
+ histogram_tester_.ExpectTotalCount(
+ std::string(NewTabPageHandler::kModuleDismissedHistogram) +
+ ".shopping_tasks",
+ 1);
+
+ handler_->OnRestoreModule("kaleidoscope");
+ histogram_tester_.ExpectTotalCount(
+ NewTabPageHandler::kModuleRestoredHistogram, 1);
+ histogram_tester_.ExpectTotalCount(
+ std::string(NewTabPageHandler::kModuleRestoredHistogram) +
+ ".kaleidoscope",
+ 1);
+}
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 b84f5f45c08..0b7d6fc97ae 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
@@ -15,13 +15,16 @@
#include "chrome/browser/search/instant_service.h"
#include "chrome/browser/search/instant_service_factory.h"
#include "chrome/browser/search/ntp_features.h"
+#include "chrome/browser/search/shopping_tasks/shopping_tasks_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/sanitized_image_source.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/url_constants.h"
@@ -127,12 +130,15 @@ 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},
{"mostVisited", IDS_NTP_CUSTOMIZE_MOST_VISITED_LABEL},
{"myShortcuts", IDS_NTP_CUSTOMIZE_MY_SHORTCUTS_LABEL},
{"noBackground", IDS_NTP_CUSTOMIZE_NO_BACKGROUND_LABEL},
{"refreshDaily", IDS_NTP_CUSTOM_BG_DAILY_REFRESH},
{"shortcutsCurated", IDS_NTP_CUSTOMIZE_MY_SHORTCUTS_DESC},
{"shortcutsMenuItem", IDS_NTP_CUSTOMIZE_MENU_SHORTCUTS_LABEL},
+ {"modulesMenuItem", IDS_NTP_CUSTOMIZE_MENU_MODULES_LABEL},
{"shortcutsOption", IDS_NTP_CUSTOMIZE_MENU_SHORTCUTS_LABEL},
{"shortcutsSuggested", IDS_NTP_CUSTOMIZE_MOST_VISITED_DESC},
{"themesMenuItem", IDS_NTP_CUSTOMIZE_MENU_COLOR_LABEL},
@@ -178,15 +184,28 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{"themeCreatedBy", IDS_NEW_TAB_ATTRIBUTION_INTRO},
// Modules.
- {"modulesDummyName", IDS_NTP_MODULES_DUMMY_NAME},
+ {"dismissModuleToastMessage", IDS_NTP_MODULES_DISMISS_TOAST_MESSAGE},
+ {"moduleInfoButtonTitle", IDS_NTP_MODULES_INFO_BUTTON_TITLE},
+ {"moduleDismissButtonTitle", IDS_NTP_MODULES_DISMISS_BUTTON_TITLE},
{"modulesDummyTitle", IDS_NTP_MODULES_DUMMY_TITLE},
- {"modulesDummy2Name", IDS_NTP_MODULES_DUMMY2_NAME},
{"modulesDummy2Title", IDS_NTP_MODULES_DUMMY2_TITLE},
- {"modulesKaleidoscopeName", IDS_NTP_MODULES_KALEIDOSCOPE_NAME},
{"modulesKaleidoscopeTitle", IDS_NTP_MODULES_KALEIDOSCOPE_TITLE},
+ {"modulesShoppingTasksInfoTitle",
+ IDS_NTP_MODULES_SHOPPING_TASKS_INFO_TITLE},
+ {"modulesShoppingTasksInfoClose",
+ IDS_NTP_MODULES_SHOPPING_TASKS_INFO_CLOSE},
};
AddLocalizedStringsBulk(source, kStrings);
+ source->AddString("modulesShoppingTasksInfo1",
+ l10n_util::GetStringFUTF16(
+ IDS_NTP_MODULES_SHOPPING_TASKS_INFO_1,
+ base::UTF8ToUTF16("https://myactivity.google.com/")));
+ source->AddString("modulesShoppingTasksInfo2",
+ l10n_util::GetStringFUTF16(
+ IDS_NTP_MODULES_SHOPPING_TASKS_INFO_2,
+ base::UTF8ToUTF16("https://policies.google.com/")));
+
// Register images that are purposefully not inlined in the HTML and instead
// are set in Javascript.
static constexpr webui::ResourcePath kImages[] = {
@@ -206,7 +225,8 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
{omnibox::kExtensionAppIconResourceName,
IDR_LOCAL_NTP_ICONS_EXTENSION_APP},
{omnibox::kPageIconResourceName, IDR_LOCAL_NTP_ICONS_PAGE},
- {omnibox::kSearchIconResourceName, IDR_WEBUI_IMAGES_ICON_SEARCH}};
+ {omnibox::kSearchIconResourceName, IDR_WEBUI_IMAGES_ICON_SEARCH},
+ {omnibox::kTrendingUpIconResourceName, IDR_LOCAL_NTP_ICONS_TRENDING_UP}};
webui::AddResourcePathsBulk(source, kImages);
#if BUILDFLAG(ENABLE_KALEIDOSCOPE)
@@ -215,6 +235,9 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
#else
source->AddBoolean("kaleidoscopeModuleEnabled", false);
#endif // BUILDFLAG(ENABLE_KALEIDOSCOPE)
+ source->AddBoolean(
+ "shoppingTasksModuleEnabled",
+ base::FeatureList::IsEnabled(ntp_features::kNtpShoppingTasksModule));
source->AddResourcePath("new_tab_page.mojom-lite.js",
IDR_NEW_TAB_PAGE_MOJO_LITE_JS);
@@ -222,6 +245,9 @@ content::WebUIDataSource* CreateNewTabPageUiHtmlSource(Profile* profile) {
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/shopping_tasks/shopping_tasks.mojom-lite.js",
+ IDR_NEW_TAB_PAGE_MODULES_SHOPPING_TASKS_SHOPPING_TASKS_MOJO_LITE_JS);
#if BUILDFLAG(OPTIMIZE_WEBUI)
source->AddResourcePath("new_tab_page.js", IDR_NEW_TAB_PAGE_NEW_TAB_PAGE_JS);
#endif // BUILDFLAG(OPTIMIZE_WEBUI)
@@ -257,6 +283,7 @@ NewTabPageUI::NewTabPageUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/false),
content::WebContentsObserver(web_ui->GetWebContents()),
page_factory_receiver_(this),
+ customize_themes_factory_receiver_(this),
profile_(Profile::FromWebUI(web_ui)),
instant_service_(InstantServiceFactory::GetForProfile(profile_)),
web_contents_(web_ui->GetWebContents()),
@@ -269,6 +296,8 @@ NewTabPageUI::NewTabPageUI(content::WebUI* web_ui)
instant_service_->IsCustomBackgroundDisabledByPolicy());
content::WebUIDataSource::Add(profile_, source);
+ content::URLDataSource::Add(profile_,
+ std::make_unique<SanitizedImageSource>(profile_));
content::URLDataSource::Add(
profile_, std::make_unique<FaviconSource>(
profile_, chrome::FaviconUrlFormat::kFavicon2));
@@ -319,10 +348,27 @@ void NewTabPageUI::BindInterface(
}
void NewTabPageUI::BindInterface(
+ mojo::PendingReceiver<
+ customize_themes::mojom::CustomizeThemesHandlerFactory>
+ pending_receiver) {
+ if (customize_themes_factory_receiver_.is_bound()) {
+ customize_themes_factory_receiver_.reset();
+ }
+ customize_themes_factory_receiver_.Bind(std::move(pending_receiver));
+}
+
+void NewTabPageUI::BindInterface(
mojo::PendingReceiver<media::mojom::KaleidoscopeDataProvider>
pending_page_handler) {
kaleidoscope_data_provider_ = std::make_unique<KaleidoscopeDataProviderImpl>(
- std::move(pending_page_handler), profile_);
+ std::move(pending_page_handler), profile_, nullptr);
+}
+
+void NewTabPageUI::BindInterface(
+ mojo::PendingReceiver<shopping_tasks::mojom::ShoppingTasksHandler>
+ pending_receiver) {
+ shopping_tasks_handler_ = std::make_unique<ShoppingTasksHandler>(
+ std::move(pending_receiver), profile_);
}
void NewTabPageUI::CreatePageHandler(
@@ -337,6 +383,16 @@ void NewTabPageUI::CreatePageHandler(
navigation_start_time_);
}
+void NewTabPageUI::CreateCustomizeThemesHandler(
+ mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
+ pending_client,
+ mojo::PendingReceiver<customize_themes::mojom::CustomizeThemesHandler>
+ pending_handler) {
+ customize_themes_handler_ = std::make_unique<ChromeCustomizeThemesHandler>(
+ std::move(pending_client), std::move(pending_handler), web_contents_,
+ profile_);
+}
+
void NewTabPageUI::NtpThemeChanged(const NtpTheme& theme) {
// Load time data is cached across page reloads. Update the background color
// here to prevent a white flicker on page reload.
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 e013e169c88..6859ea62f5a 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h
@@ -9,29 +9,36 @@
#include "chrome/browser/media/kaleidoscope/mojom/kaleidoscope.mojom.h"
#include "chrome/browser/promo_browser_command/promo_browser_command.mojom-forward.h"
#include "chrome/browser/search/instant_service_observer.h"
+#include "chrome/browser/search/shopping_tasks/shopping_tasks.mojom.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page.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"
#include "ui/webui/mojo_web_ui_controller.h"
+#include "ui/webui/resources/cr_components/customize_themes/customize_themes.mojom.h"
-class PromoBrowserCommandHandler;
namespace content {
class NavigationHandle;
class WebContents;
class WebUI;
-}
+} // namespace content
+
+class ChromeCustomizeThemesHandler;
class GURL;
class InstantService;
class KaleidoscopeDataProviderImpl;
class NewTabPageHandler;
class Profile;
-
-class NewTabPageUI : public ui::MojoWebUIController,
- public new_tab_page::mojom::PageHandlerFactory,
- public InstantServiceObserver,
- content::WebContentsObserver {
+class PromoBrowserCommandHandler;
+class ShoppingTasksHandler;
+
+class NewTabPageUI
+ : public ui::MojoWebUIController,
+ public new_tab_page::mojom::PageHandlerFactory,
+ public customize_themes::mojom::CustomizeThemesHandlerFactory,
+ public InstantServiceObserver,
+ content::WebContentsObserver {
public:
explicit NewTabPageUI(content::WebUI* web_ui);
~NewTabPageUI() override;
@@ -52,12 +59,26 @@ class NewTabPageUI : public ui::MojoWebUIController,
pending_receiver);
// 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);
+
+ // 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<shopping_tasks::mojom::ShoppingTasksHandler>
+ pending_receiver);
+
private:
// new_tab_page::mojom::PageHandlerFactory:
void CreatePageHandler(
@@ -65,6 +86,13 @@ class NewTabPageUI : public ui::MojoWebUIController,
mojo::PendingReceiver<new_tab_page::mojom::PageHandler>
pending_page_handler) override;
+ // customize_themes::mojom::CustomizeThemesHandlerFactory:
+ void CreateCustomizeThemesHandler(
+ mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
+ pending_client,
+ mojo::PendingReceiver<customize_themes::mojom::CustomizeThemesHandler>
+ pending_handler) override;
+
// InstantServiceObserver:
void NtpThemeChanged(const NtpTheme& theme) override;
void MostVisitedInfoChanged(const InstantMostVisitedInfo& info) override;
@@ -81,6 +109,9 @@ class NewTabPageUI : public ui::MojoWebUIController,
std::unique_ptr<NewTabPageHandler> page_handler_;
mojo::Receiver<new_tab_page::mojom::PageHandlerFactory>
page_factory_receiver_;
+ std::unique_ptr<ChromeCustomizeThemesHandler> customize_themes_handler_;
+ mojo::Receiver<customize_themes::mojom::CustomizeThemesHandlerFactory>
+ customize_themes_factory_receiver_;
std::unique_ptr<PromoBrowserCommandHandler> promo_browser_command_handler_;
Profile* profile_;
InstantService* instant_service_;
@@ -91,6 +122,7 @@ class NewTabPageUI : public ui::MojoWebUIController,
// Mojo implementations for modules:
std::unique_ptr<KaleidoscopeDataProviderImpl> kaleidoscope_data_provider_;
+ std::unique_ptr<ShoppingTasksHandler> shopping_tasks_handler_;
WEB_UI_CONTROLLER_TYPE_DECL();
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.cc b/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.cc
index 57ce137b74e..7e16e7d6631 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.cc
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.cc
@@ -6,6 +6,7 @@
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
+#include "base/metrics/user_metrics.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/command_updater_impl.h"
#include "chrome/browser/profiles/profile.h"
@@ -14,6 +15,9 @@
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/common/webui_url_constants.h"
+#include "components/safe_browsing/content/web_ui/safe_browsing_ui.h"
+#include "components/safe_browsing/core/common/safe_browsing_policy_handler.h"
+#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
@@ -38,6 +42,31 @@ PromoBrowserCommandHandler::PromoBrowserCommandHandler(
PromoBrowserCommandHandler::~PromoBrowserCommandHandler() = default;
+void PromoBrowserCommandHandler::CanShowPromoWithCommand(
+ promo_browser_command::mojom::Command command_id,
+ CanShowPromoWithCommandCallback callback) {
+ bool can_show = false;
+ switch (static_cast<Command>(command_id)) {
+ case Command::kUnknownCommand:
+ // Nothing to do.
+ break;
+ case Command::kOpenSafetyCheck:
+ can_show = true;
+ break;
+ case Command::kOpenSafeBrowsingEnhancedProtectionSettings: {
+ bool managed = safe_browsing::SafeBrowsingPolicyHandler::
+ IsSafeBrowsingProtectionLevelSetByPolicy(profile_->GetPrefs());
+ bool already_enabled =
+ safe_browsing::IsEnhancedProtectionEnabled(*(profile_->GetPrefs()));
+ can_show = !managed && !already_enabled;
+ } break;
+ default:
+ NOTREACHED() << "Unspecified behavior for command " << command_id;
+ break;
+ }
+ std::move(callback).Run(can_show);
+}
+
void PromoBrowserCommandHandler::ExecuteCommand(
Command command_id,
ClickInfoPtr click_info,
@@ -64,6 +93,15 @@ void PromoBrowserCommandHandler::ExecuteCommandWithDisposition(
case Command::kOpenSafetyCheck:
NavigateToURL(GURL(chrome::GetSettingsUrl(chrome::kSafetyCheckSubPage)),
disposition);
+ base::RecordAction(
+ base::UserMetricsAction("NewTabPage_Promos_SafetyCheck"));
+ break;
+ case Command::kOpenSafeBrowsingEnhancedProtectionSettings:
+ NavigateToURL(GURL(chrome::GetSettingsUrl(
+ chrome::kSafeBrowsingEnhancedProtectionSubPage)),
+ disposition);
+ base::RecordAction(
+ base::UserMetricsAction("NewTabPage_Promos_EnhancedProtection"));
break;
default:
NOTREACHED() << "Unspecified behavior for command " << id;
@@ -77,6 +115,9 @@ void PromoBrowserCommandHandler::EnableCommands() {
static_cast<int>(Command::kUnknownCommand), true);
GetCommandUpdater()->UpdateCommandEnabled(
static_cast<int>(Command::kOpenSafetyCheck), true);
+ GetCommandUpdater()->UpdateCommandEnabled(
+ static_cast<int>(Command::kOpenSafeBrowsingEnhancedProtectionSettings),
+ true);
}
CommandUpdater* PromoBrowserCommandHandler::GetCommandUpdater() {
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.h b/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.h
index 7cfde9ee23e..100875c3674 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.h
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.h
@@ -31,6 +31,9 @@ class PromoBrowserCommandHandler
~PromoBrowserCommandHandler() override;
// promo_browser_command::mojom::CommandHandler:
+ void CanShowPromoWithCommand(
+ promo_browser_command::mojom::Command command_id,
+ CanShowPromoWithCommandCallback callback) override;
void ExecuteCommand(promo_browser_command::mojom::Command command_id,
promo_browser_command::mojom::ClickInfoPtr click_info,
ExecuteCommandCallback callback) override;
diff --git a/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler_unittest.cc b/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler_unittest.cc
index 9f11e045a80..5d4c1432991 100644
--- a/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler_unittest.cc
@@ -15,6 +15,8 @@
#include "chrome/browser/ui/webui/new_tab_page/promo_browser_command/promo_browser_command_handler.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -72,6 +74,15 @@ class MockCommandUpdater : public CommandUpdaterImpl {
MOCK_CONST_METHOD1(SupportsCommand, bool(int id));
};
+// Callback used for testing
+// PromoBrowserCommandHandler::CanShowPromoWithCommand().
+void CanShowPromoWithCommandCallback(base::OnceClosure quit_closure,
+ bool* expected_can_show,
+ bool can_show) {
+ *expected_can_show = can_show;
+ std::move(quit_closure).Run();
+}
+
// Callback used for testing PromoBrowserCommandHandler::ExecuteCommand().
void ExecuteCommandCallback(base::OnceClosure quit_closure,
bool* expected_command_executed,
@@ -104,6 +115,16 @@ class PromoBrowserCommandHandlerTest : public testing::Test {
command_handler_->GetCommandUpdater());
}
+ bool CanShowPromoWithCommand(Command command_id) {
+ base::RunLoop run_loop;
+ bool can_show = false;
+ command_handler_->CanShowPromoWithCommand(
+ command_id, base::BindOnce(&CanShowPromoWithCommandCallback,
+ run_loop.QuitClosure(), &can_show));
+ run_loop.Run();
+ return can_show;
+ }
+
bool ExecuteCommand(Command command_id, ClickInfoPtr click_info) {
base::RunLoop run_loop;
bool command_executed = false;
@@ -180,6 +201,10 @@ TEST_F(PromoBrowserCommandHandlerTest, DisableHandlingCommands) {
PromoBrowserCommandHandler::kPromoBrowserCommandHistogramName, 0);
}
+TEST_F(PromoBrowserCommandHandlerTest, CanShowOpenSafetyCheckCommandPromo) {
+ EXPECT_TRUE(CanShowPromoWithCommand(Command::kOpenSafetyCheck));
+}
+
TEST_F(PromoBrowserCommandHandlerTest, OpenSafetyCheckCommand) {
// The OpenSafetyCheck command opens a new settings window with the Safety
// Check, and the correct disposition.
@@ -192,3 +217,84 @@ TEST_F(PromoBrowserCommandHandlerTest, OpenSafetyCheckCommand) {
DispositionFromClick(*info)));
EXPECT_TRUE(ExecuteCommand(Command::kOpenSafetyCheck, std::move(info)));
}
+
+TEST_F(PromoBrowserCommandHandlerTest,
+ CanShowSafeBrowsingEnhancedProtectionCommandPromo_NoPolicies) {
+ EXPECT_TRUE(CanShowPromoWithCommand(
+ Command::kOpenSafeBrowsingEnhancedProtectionSettings));
+}
+
+TEST_F(
+ PromoBrowserCommandHandlerTest,
+ CanShowSafeBrowsingEnhancedProtectionCommandPromo_EnhancedProtectionEnabled) {
+ TestingProfile::Builder builder;
+ std::unique_ptr<TestingProfile> profile = builder.Build();
+ profile->GetTestingPrefService()->SetUserPref(
+ prefs::kSafeBrowsingEnhanced, std::make_unique<base::Value>(true));
+ command_handler_ = std::make_unique<MockCommandHandler>(profile.get());
+
+ EXPECT_FALSE(CanShowPromoWithCommand(
+ Command::kOpenSafeBrowsingEnhancedProtectionSettings));
+}
+
+TEST_F(
+ PromoBrowserCommandHandlerTest,
+ CanShowSafeBrowsingEnhancedProtectionCommandPromo_HasSafeBrowsingManaged_NoProtection) {
+ TestingProfile::Builder builder;
+ std::unique_ptr<TestingProfile> profile = builder.Build();
+ profile->GetTestingPrefService()->SetManagedPref(
+ prefs::kSafeBrowsingEnabled, std::make_unique<base::Value>(false));
+ profile->GetTestingPrefService()->SetManagedPref(
+ prefs::kSafeBrowsingEnhanced, std::make_unique<base::Value>(false));
+ command_handler_ = std::make_unique<MockCommandHandler>(profile.get());
+
+ EXPECT_FALSE(CanShowPromoWithCommand(
+ Command::kOpenSafeBrowsingEnhancedProtectionSettings));
+}
+
+TEST_F(
+ PromoBrowserCommandHandlerTest,
+ CanShowSafeBrowsingEnhancedProtectionCommandPromo_HasSafeBrowsingManaged_StandardProtection) {
+ TestingProfile::Builder builder;
+ std::unique_ptr<TestingProfile> profile = builder.Build();
+ profile->GetTestingPrefService()->SetManagedPref(
+ prefs::kSafeBrowsingEnabled, std::make_unique<base::Value>(true));
+ profile->GetTestingPrefService()->SetManagedPref(
+ prefs::kSafeBrowsingEnhanced, std::make_unique<base::Value>(false));
+ command_handler_ = std::make_unique<MockCommandHandler>(profile.get());
+
+ EXPECT_FALSE(CanShowPromoWithCommand(
+ Command::kOpenSafeBrowsingEnhancedProtectionSettings));
+}
+
+TEST_F(
+ PromoBrowserCommandHandlerTest,
+ CanShowSafeBrowsingEnhancedProtectionCommandPromo_HasSafeBrowsingManaged_EnhancedProtection) {
+ TestingProfile::Builder builder;
+ std::unique_ptr<TestingProfile> profile = builder.Build();
+ profile->GetTestingPrefService()->SetManagedPref(
+ prefs::kSafeBrowsingEnabled, std::make_unique<base::Value>(true));
+ profile->GetTestingPrefService()->SetManagedPref(
+ prefs::kSafeBrowsingEnhanced, std::make_unique<base::Value>(true));
+ command_handler_ = std::make_unique<MockCommandHandler>(profile.get());
+
+ EXPECT_FALSE(CanShowPromoWithCommand(
+ Command::kOpenSafeBrowsingEnhancedProtectionSettings));
+}
+
+TEST_F(PromoBrowserCommandHandlerTest,
+ OpenSafeBrowsingEnhancedProtectionCommand) {
+ // The kOpenSafeBrowsingEnhancedProtectionSettings command opens a new
+ // settings window with the Safe Browsing settings with the Enhanced
+ // Protection section expanded, and the correct disposition.
+ ClickInfoPtr info = ClickInfo::New();
+ info->middle_button = true;
+ info->meta_key = true;
+ EXPECT_CALL(
+ *command_handler_,
+ NavigateToURL(GURL(chrome::GetSettingsUrl(
+ chrome::kSafeBrowsingEnhancedProtectionSubPage)),
+ DispositionFromClick(*info)));
+ EXPECT_TRUE(ExecuteCommand(
+ Command::kOpenSafeBrowsingEnhancedProtectionSettings, std::move(info)));
+}
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 ca3d65682b7..e868748e3e5 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
@@ -12,7 +12,6 @@
#include "base/i18n/rtl.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
-#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/strings/string_piece.h"
@@ -20,13 +19,10 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
-#include "chrome/browser/browser_features.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/ntp_features.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_data.h"
#include "chrome/browser/search/one_google_bar/one_google_bar_service_factory.h"
-#include "chrome/browser/search/promos/promo_data.h"
-#include "chrome/browser/search/promos/promo_service_factory.h"
#include "chrome/browser/ui/search/ntp_user_data_logger.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/new_tab_page_resources.h"
@@ -71,14 +67,7 @@ void ServeBackgroundImageData(content::URLDataSource::GotDataCallback callback,
UntrustedSource::UntrustedSource(Profile* profile)
: one_google_bar_service_(
OneGoogleBarServiceFactory::GetForProfile(profile)),
- profile_(profile),
- promo_service_(PromoServiceFactory::GetForProfile(profile)) {
- // |promo_service_| is null in incognito, or when the feature is
- // disabled.
- if (promo_service_) {
- promo_service_observer_.Add(promo_service_);
- }
-
+ profile_(profile) {
// |one_google_bar_service_| is null in incognito, or when the feature is
// disabled.
if (one_google_bar_service_) {
@@ -90,19 +79,24 @@ UntrustedSource::~UntrustedSource() = default;
std::string UntrustedSource::GetContentSecurityPolicy(
network::mojom::CSPDirectiveName directive) {
- if (directive == network::mojom::CSPDirectiveName::ScriptSrc) {
- return "script-src 'self' 'unsafe-inline' https:;";
- } else if (directive == network::mojom::CSPDirectiveName::ChildSrc) {
- return "child-src https:;";
- } else if (directive == network::mojom::CSPDirectiveName::DefaultSrc) {
- // TODO(https://crbug.com/1085325): Audit and tighten CSP.
- return std::string();
- } else if (directive == network::mojom::CSPDirectiveName::FrameAncestors) {
- return base::StringPrintf("frame-ancestors %s",
- chrome::kChromeUINewTabPageURL);
+ switch (directive) {
+ case network::mojom::CSPDirectiveName::ScriptSrc:
+ return "script-src 'self' 'unsafe-inline' https:;";
+ case network::mojom::CSPDirectiveName::ChildSrc:
+ return "child-src https:;";
+ case network::mojom::CSPDirectiveName::DefaultSrc:
+ // TODO(https://crbug.com/1085325): Audit and tighten CSP.
+ return std::string();
+ case network::mojom::CSPDirectiveName::FrameAncestors:
+ return base::StringPrintf("frame-ancestors %s",
+ chrome::kChromeUINewTabPageURL);
+ case network::mojom::CSPDirectiveName::RequireTrustedTypesFor:
+ return std::string();
+ case network::mojom::CSPDirectiveName::TrustedTypes:
+ return std::string();
+ default:
+ return content::URLDataSource::GetContentSecurityPolicy(directive);
}
-
- return content::URLDataSource::GetContentSecurityPolicy(directive);
}
std::string UntrustedSource::GetSource() {
@@ -142,21 +136,6 @@ void UntrustedSource::StartDataRequest(
bundle.LoadDataResourceBytes(IDR_NEW_TAB_PAGE_ONE_GOOGLE_BAR_API_JS));
return;
}
- if (path == "promo" && promo_service_) {
- promo_callbacks_.push_back(std::move(callback));
- if (promo_service_->promo_data().has_value()) {
- OnPromoDataUpdated();
- }
- promo_load_start_time_ = base::TimeTicks::Now();
- promo_service_->Refresh();
- return;
- }
- if (path == "promo.js") {
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- std::move(callback).Run(
- bundle.LoadDataResourceBytes(IDR_NEW_TAB_PAGE_UNTRUSTED_PROMO_JS));
- return;
- }
if (path == "image" && url_param.is_valid() &&
(url_param.SchemeIs(url::kHttpsScheme) ||
url_param.SchemeIs(content::kChromeUIUntrustedScheme))) {
@@ -250,10 +229,9 @@ bool UntrustedSource::ShouldServiceRequest(
}
const std::string path = url.path().substr(1);
return path == "one-google-bar" || path == "one_google_bar.js" ||
- path == "promo" || path == "promo.js" || path == "image" ||
- path == "background_image" || path == "custom_background_image" ||
- path == "background_image.js" || path == "background.jpg" ||
- path == "one_google_bar_api.js";
+ path == "image" || path == "background_image" ||
+ path == "custom_background_image" || path == "background_image.js" ||
+ path == "background.jpg" || path == "one_google_bar_api.js";
}
void UntrustedSource::OnOneGoogleBarDataUpdated() {
@@ -295,59 +273,6 @@ void UntrustedSource::OnOneGoogleBarServiceShuttingDown() {
one_google_bar_service_ = nullptr;
}
-void UntrustedSource::OnPromoDataUpdated() {
- if (promo_load_start_time_.has_value()) {
- base::TimeDelta duration = base::TimeTicks::Now() - *promo_load_start_time_;
- UMA_HISTOGRAM_MEDIUM_TIMES("NewTabPage.Promos.RequestLatency2", duration);
- if (promo_service_->promo_status() == PromoService::Status::OK_WITH_PROMO) {
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "NewTabPage.Promos.RequestLatency2.SuccessWithPromo", duration);
- } else if (promo_service_->promo_status() ==
- PromoService::Status::OK_BUT_BLOCKED) {
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "NewTabPage.Promos.RequestLatency2.SuccessButBlocked", duration);
- } else if (promo_service_->promo_status() ==
- PromoService::Status::OK_WITHOUT_PROMO) {
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "NewTabPage.Promos.RequestLatency2.SuccessWithoutPromo", duration);
- } else {
- UMA_HISTOGRAM_MEDIUM_TIMES("NewTabPage.Promos.RequestLatency2.Failure",
- duration);
- }
- promo_load_start_time_ = base::nullopt;
- }
-
- const auto& data = promo_service_->promo_data();
- std::string html;
- if (data.has_value() && !data->promo_html.empty()) {
- std::string promo_html = data->promo_html;
-
- // Replace the promo URL with "command:<id>" if such a command ID is set
- // via the feature params.
- const std::string command_id = base::GetFieldTrialParamValueByFeature(
- features::kPromoBrowserCommands, features::kPromoBrowserCommandIdParam);
- if (!command_id.empty()) {
- re2::RE2::GlobalReplace(&promo_html, re2::RE2("href=\"([^\\s]+)\""),
- "href=\"command:" + command_id + "\"");
- }
-
- ui::TemplateReplacements replacements;
- replacements["textdirection"] = base::i18n::IsRTL() ? "rtl" : "ltr";
- replacements["data"] = promo_html;
-
- html = FormatTemplate(IDR_NEW_TAB_PAGE_UNTRUSTED_PROMO_HTML, replacements);
- }
- for (auto& callback : promo_callbacks_) {
- std::move(callback).Run(base::RefCountedString::TakeString(&html));
- }
- promo_callbacks_.clear();
-}
-
-void UntrustedSource::OnPromoServiceShuttingDown() {
- promo_service_observer_.RemoveAll();
- promo_service_ = nullptr;
-}
-
void UntrustedSource::ServeBackgroundImage(
const GURL& url,
const GURL& url_2x,
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 1caf16a43d0..420a55cb7f8 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
@@ -11,8 +11,6 @@
#include "base/scoped_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 "content/public/browser/url_data_source.h"
class Profile;
@@ -41,8 +39,7 @@ class Profile;
// * positionY: (optional) CSS background-position-y property.
// Each of those helpers only accept URLs with HTTPS or chrome-untrusted:.
class UntrustedSource : public content::URLDataSource,
- public OneGoogleBarServiceObserver,
- public PromoServiceObserver {
+ public OneGoogleBarServiceObserver {
public:
explicit UntrustedSource(Profile* profile);
~UntrustedSource() override;
@@ -70,10 +67,6 @@ class UntrustedSource : public content::URLDataSource,
void OnOneGoogleBarDataUpdated() override;
void OnOneGoogleBarServiceShuttingDown() override;
- // PromoServiceObserver:
- void OnPromoDataUpdated() override;
- void OnPromoServiceShuttingDown() override;
-
void ServeBackgroundImage(const GURL& url,
const GURL& url_2x,
const std::string& size,
@@ -90,11 +83,6 @@ class UntrustedSource : public content::URLDataSource,
one_google_bar_service_observer_{this};
base::Optional<base::TimeTicks> one_google_bar_load_start_time_;
Profile* profile_;
- std::vector<content::URLDataSource::GotDataCallback> promo_callbacks_;
- PromoService* promo_service_;
- ScopedObserver<PromoService, PromoServiceObserver> promo_service_observer_{
- this};
- base::Optional<base::TimeTicks> promo_load_start_time_;
};
#endif // CHROME_BROWSER_UI_WEBUI_NEW_TAB_PAGE_UNTRUSTED_SOURCE_H_
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 1e436337d01..b4c2f626ef5 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -8,7 +8,6 @@
#include <string>
#include <utility>
-#include <vector>
#include "base/auto_reset.h"
#include "base/bind.h"
@@ -17,6 +16,7 @@
#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"
@@ -161,14 +161,12 @@ bool DesktopPWAsWithoutExtensions() {
return base::FeatureList::IsEnabled(features::kDesktopPWAsWithoutExtensions);
}
-bool HasMatchingOrGreaterThanIcon(
- std::vector<SquareSizePx> downloaded_icon_sizes,
- int pixels) {
- for (const SquareSizePx icon_size : downloaded_icon_sizes) {
- if (icon_size >= pixels)
- return true;
- }
- return false;
+bool HasMatchingOrGreaterThanIcon(const SortedSizesPx& downloaded_icon_sizes,
+ int pixels) {
+ if (downloaded_icon_sizes.empty())
+ return false;
+ SquareSizePx largest = *downloaded_icon_sizes.rbegin();
+ return largest >= pixels;
}
} // namespace
@@ -205,7 +203,7 @@ void AppLauncherHandler::CreateWebAppInfo(const web_app::AppId& app_id,
base::string16 name = base::UTF8ToUTF16(registrar.GetAppShortName(app_id));
NewTabUI::SetUrlTitleAndDirection(value, name,
- registrar.GetAppLaunchURL(app_id));
+ registrar.GetAppStartUrl(app_id));
NewTabUI::SetFullNameAndDirection(name, value);
GetWebAppBasicInfo(app_id, registrar, value);
@@ -717,7 +715,7 @@ void AppLauncherHandler::HandleLaunchApp(const base::ListValue* args) {
if (registrar.IsInstalled(extension_id) &&
!IsYoutubeExtension(extension_id)) {
type = extensions::Manifest::Type::TYPE_HOSTED_APP;
- full_launch_url = registrar.GetAppLaunchURL(extension_id);
+ full_launch_url = registrar.GetAppStartUrl(extension_id);
launch_container = web_app::ConvertDisplayModeToAppLaunchContainer(
registrar.GetAppEffectiveDisplayMode(extension_id));
} else {
@@ -829,7 +827,7 @@ void AppLauncherHandler::HandleSetLaunchType(const base::ListValue* args) {
}
web_app_provider_->registry_controller().SetAppUserDisplayMode(
- app_id, display_mode);
+ app_id, display_mode, /*is_user_action=*/true);
return;
}
@@ -866,7 +864,6 @@ void AppLauncherHandler::HandleUninstallApp(const base::ListValue* args) {
auto uninstall_success_callback = base::BindOnce(
[](base::WeakPtr<AppLauncherHandler> app_launcher_handler,
bool success) {
- LOCAL_HISTOGRAM_BOOLEAN("Apps.Launcher.UninstallSuccess", success);
if (app_launcher_handler)
app_launcher_handler->CleanupAfterUninstall();
},
@@ -935,7 +932,7 @@ void AppLauncherHandler::HandleCreateAppShortcut(const base::ListValue* args) {
chrome::ShowCreateChromeAppShortcutsDialog(
browser->window()->GetNativeWindow(), browser->profile(), app_id,
base::BindRepeating([](bool success) {
- LOCAL_HISTOGRAM_BOOLEAN(
+ base::UmaHistogramBoolean(
"Apps.AppInfoDialog.CreateWebAppShortcutSuccess", success);
}));
return;
@@ -956,7 +953,7 @@ void AppLauncherHandler::HandleCreateAppShortcut(const base::ListValue* args) {
chrome::ShowCreateChromeAppShortcutsDialog(
browser->window()->GetNativeWindow(), browser->profile(), extension,
base::BindRepeating([](bool success) {
- LOCAL_HISTOGRAM_BOOLEAN(
+ base::UmaHistogramBoolean(
"Apps.AppInfoDialog.CreateExtensionShortcutSuccess", success);
}));
}
@@ -973,10 +970,13 @@ void AppLauncherHandler::HandleInstallAppLocally(const base::ListValue* args) {
web_app_provider_->registry_controller().SetAppInstallTime(app_id,
base::Time::Now());
web_app::InstallOsHooksOptions options;
- options.add_to_applications_menu = true;
options.add_to_desktop = true;
options.add_to_quick_launch_bar = false;
- options.run_on_os_login = false;
+ options.os_hooks[web_app::OsHookType::kShortcuts] = true;
+ options.os_hooks[web_app::OsHookType::kShortcutsMenu] = true;
+ options.os_hooks[web_app::OsHookType::kFileHandlers] = true;
+ options.os_hooks[web_app::OsHookType::kRunOnOsLogin] = false;
+
web_app_provider_->os_integration_manager().InstallOsHooks(
app_id,
base::BindOnce(&AppLauncherHandler::OnOsHooksInstalled,
@@ -998,7 +998,7 @@ void AppLauncherHandler::HandleShowAppInfo(const base::ListValue* args) {
!IsYoutubeExtension(extension_id)) {
chrome::ShowSiteSettings(
chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()),
- web_app_provider_->registrar().GetAppLaunchURL(extension_id));
+ web_app_provider_->registrar().GetAppStartUrl(extension_id));
return;
}
@@ -1116,7 +1116,7 @@ void AppLauncherHandler::HandleGenerateAppForLink(const base::ListValue* args) {
favicon_service->GetFaviconImageForPageURL(
launch_url,
- base::BindOnce(&AppLauncherHandler::OnFaviconForApp,
+ base::BindOnce(&AppLauncherHandler::OnFaviconForAppInstallFromLink,
base::Unretained(this), base::Passed(&install_info)),
&cancelable_task_tracker_);
}
@@ -1130,12 +1130,12 @@ void AppLauncherHandler::HandlePageSelected(const base::ListValue* args) {
prefs->SetInteger(prefs::kNtpShownPage, APPS_PAGE_ID | index);
}
-void AppLauncherHandler::OnFaviconForApp(
+void AppLauncherHandler::OnFaviconForAppInstallFromLink(
std::unique_ptr<AppInstallInfo> install_info,
const favicon_base::FaviconImageResult& image_result) {
auto web_app = std::make_unique<WebApplicationInfo>();
web_app->title = install_info->title;
- web_app->app_url = install_info->app_url;
+ web_app->start_url = install_info->app_url;
if (!image_result.image.IsEmpty()) {
web_app->icon_bitmaps_any[image_result.image.Width()] =
@@ -1149,9 +1149,10 @@ void AppLauncherHandler::OnFaviconForApp(
[](base::WeakPtr<AppLauncherHandler> app_launcher_handler,
const web_app::AppId& app_id,
web_app::InstallResultCode install_result) {
- LOCAL_HISTOGRAM_ENUMERATION(
- "Apps.AppInfoDialog.InstallAppLocallyInstallResult",
- install_result);
+ // Note: this installation path only happens when the user drags a
+ // link to chrome://apps, hence the specific metric name.
+ base::UmaHistogramEnumeration(
+ "Apps.Launcher.InstallAppFromLinkResult", install_result);
if (!app_launcher_handler)
return;
if (install_result !=
@@ -1206,8 +1207,11 @@ void AppLauncherHandler::PromptToEnableApp(const std::string& extension_id) {
void AppLauncherHandler::OnOsHooksInstalled(
const web_app::AppId& app_id,
const web_app::OsHooksResults os_hooks_results) {
- LOCAL_HISTOGRAM_BOOLEAN("Apps.Launcher.InstallLocallyShortcutsCreated",
- os_hooks_results[web_app::OsHookType::kShortcuts]);
+ // TODO(dmurph): Once installation takes the OSHookResults bitfield, then
+ // use that to compare with the results, and record if they all were
+ // successful, instead of just shortcuts.
+ base::UmaHistogramBoolean("Apps.Launcher.InstallLocallyShortcutsCreated",
+ os_hooks_results[web_app::OsHookType::kShortcuts]);
}
void AppLauncherHandler::OnExtensionUninstallDialogClosed(
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 04ec97b9757..08d22a89d19 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
@@ -17,8 +17,8 @@
#include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
#include "chrome/browser/web_applications/components/app_registrar.h"
#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/os_integration_manager.h"
#include "chrome/common/extensions/extension_constants.h"
#include "components/favicon/core/favicon_service.h"
#include "components/prefs/pref_change_registrar.h"
@@ -192,8 +192,9 @@ class AppLauncherHandler
extensions::ExtensionUninstallDialog* CreateExtensionUninstallDialog();
// Continuation for installing a bookmark app after favicon lookup.
- void OnFaviconForApp(std::unique_ptr<AppInstallInfo> install_info,
- const favicon_base::FaviconImageResult& image_result);
+ void OnFaviconForAppInstallFromLink(
+ std::unique_ptr<AppInstallInfo> install_info,
+ const favicon_base::FaviconImageResult& image_result);
// Sends |highlight_app_id_| to the js.
void SetAppToBeHighlighted();
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 8349ba3dd2e..cbf85a634b5 100644
--- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -172,7 +172,6 @@ NTPResourceCache::NTPResourceCache(Profile* profile)
profile_pref_change_registrar_.Add(prefs::kNtpShownPage, callback);
profile_pref_change_registrar_.Add(prefs::kHideWebStoreIcon, callback);
profile_pref_change_registrar_.Add(prefs::kCookieControlsMode, callback);
- profile_pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, callback);
theme_observer_.Add(ui::NativeTheme::GetInstanceForNativeUi());
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom b/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
index e113fded051..2bd08370cd3 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
@@ -43,6 +43,7 @@ struct AutocompleteMatch {
bool starred;
int32 duplicates;
bool from_previous;
+ int32 pedal_id;
array<AutocompleteAdditionalInfo> additional_info;
};
@@ -69,7 +70,7 @@ struct OmniboxResponse {
interface OmniboxPageHandler {
// Registers the webui page.
SetClientPage(pending_remote<OmniboxPage> page);
- // Prompts a autocopmlete controller to process an omnibox query.
+ // Prompts an autocomplete controller to process an omnibox query.
StartOmniboxQuery(string input_string,
bool reset_autocomplete_controller,
int32 cursor_position,
@@ -82,14 +83,14 @@ interface OmniboxPageHandler {
interface OmniboxPage {
// Notifies the page of an omnibox response from a autocomplete
- // controller. |is_page_controller| indicates wether the response
+ // controller. |is_page_controller| indicates whether the response
// originates from a query initiated from the page via
// |StartOmniboxQuery| or from the browser omnibox.
HandleNewAutocompleteResponse(OmniboxResponse response,
bool is_page_controller);
// Notifies the page a new omnibox query has begun.
HandleNewAutocompleteQuery(bool is_page_controller, string input_text);
- // Asyncronously notifies the page of the image data URLs for previous omnibox
- // responses.
+ // Asynchronously notifies the page of the image data URLs for previous
+ // omnibox responses.
HandleAnswerImageData(string image_url, string image_data);
};
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 37d53b407e4..a226e412938 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
@@ -32,6 +32,7 @@
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/autocomplete_provider.h"
#include "components/omnibox/browser/omnibox_controller_emitter.h"
+#include "components/omnibox/browser/omnibox_pedal.h"
#include "components/search_engines/omnibox_focus_type.h"
#include "components/search_engines/template_url.h"
#include "content/public/browser/web_ui.h"
@@ -170,7 +171,8 @@ struct TypeConverter<mojom::AutocompleteMatchPtr, AutocompleteMatch> {
result->keyword = base::UTF16ToUTF8(input.keyword);
result->duplicates = static_cast<int32_t>(input.duplicate_matches.size());
result->from_previous = input.from_previous;
-
+ result->pedal_id =
+ input.pedal ? static_cast<int32_t>(input.pedal->id()) : 0;
result->additional_info =
mojo::ConvertTo<std::vector<mojom::AutocompleteAdditionalInfoPtr>>(
input.additional_info);
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
index cb06efa0c71..bb401e07956 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
@@ -114,7 +114,6 @@
#include "chrome/browser/google/google_update_policy_fetcher_win.h"
#include "chrome/install_static/install_util.h"
-#include "components/update_client/updater_state.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
@@ -450,13 +449,14 @@ class UpdaterStatusProvider : public PolicyStatusProvider {
public:
UpdaterStatusProvider();
~UpdaterStatusProvider() override = default;
+ void SetUpdaterStatus(std::unique_ptr<GoogleUpdateState> status);
void GetStatus(base::DictionaryValue* dict) override;
private:
static std::string FetchActiveDirectoryDomain();
void OnDomainReceived(std::string domain);
- std::string version_;
+ std::unique_ptr<GoogleUpdateState> updater_status_;
std::string domain_;
base::WeakPtrFactory<UpdaterStatusProvider> weak_factory_{this};
};
@@ -739,12 +739,6 @@ void DeviceActiveDirectoryPolicyStatusProvider::GetStatus(
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
UpdaterStatusProvider::UpdaterStatusProvider() {
- auto state =
- update_client::UpdaterState::GetState(install_static::IsSystemInstall());
- const auto& version = state->find("version");
- if (version != state->end())
- version_ = version->second;
-
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(),
@@ -754,11 +748,24 @@ UpdaterStatusProvider::UpdaterStatusProvider() {
weak_factory_.GetWeakPtr()));
}
+void UpdaterStatusProvider::SetUpdaterStatus(
+ std::unique_ptr<GoogleUpdateState> status) {
+ updater_status_ = std::move(status);
+ NotifyStatusChange();
+}
+
void UpdaterStatusProvider::GetStatus(base::DictionaryValue* dict) {
- if (!version_.empty())
- dict->SetString("version", version_);
if (!domain_.empty())
- dict->SetString("domain", domain_);
+ dict->SetStringKey("domain", domain_);
+ if (!updater_status_)
+ return;
+ if (!updater_status_->version.empty())
+ dict->SetStringKey("version", updater_status_->version);
+ if (!updater_status_->last_checked_time.is_null()) {
+ dict->SetStringKey(
+ "timeSinceLastRefresh",
+ GetTimeSinceLastRefreshString(updater_status_->last_checked_time));
+ }
}
// static
@@ -780,7 +787,8 @@ void UpdaterStatusProvider::OnDomainReceived(std::string domain) {
domain_ = std::move(domain);
NotifyStatusChange();
}
-#endif
+
+#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
PolicyUIHandler::PolicyUIHandler() {}
@@ -826,6 +834,7 @@ void PolicyUIHandler::AddCommonLocalizedStringsToSource(
{"unknown", IDS_POLICY_UNKNOWN},
{"unset", IDS_POLICY_UNSET},
{"value", IDS_POLICY_LABEL_VALUE},
+ {"sourceDefault", IDS_POLICY_SOURCE_DEFAULT},
};
AddLocalizedStringsBulk(source, kStrings);
@@ -895,15 +904,7 @@ void PolicyUIHandler::RegisterMessages() {
#endif // defined(OS_CHROMEOS)
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- updater_status_provider_ = std::make_unique<UpdaterStatusProvider>();
- base::PostTaskAndReplyWithResult(
- base::ThreadPool::CreateCOMSTATaskRunner(
- {base::TaskPriority::USER_BLOCKING,
- base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN, base::MayBlock()})
- .get(),
- FROM_HERE, base::BindOnce(&GetGoogleUpdatePolicies),
- base::BindOnce(&PolicyUIHandler::SetUpdaterPolicies,
- weak_factory_.GetWeakPtr()));
+ ReloadUpdaterPoliciesAndState();
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
if (!user_status_provider_.get())
@@ -1185,6 +1186,11 @@ void PolicyUIHandler::HandleReloadPolicies(const base::ListValue* args) {
}
}
#endif
+
+#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
+ ReloadUpdaterPoliciesAndState();
+#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
+
GetPolicyService()->RefreshPolicies(base::BindOnce(
&PolicyUIHandler::OnRefreshPoliciesDone, weak_factory_.GetWeakPtr()));
}
@@ -1289,12 +1295,28 @@ void PolicyUIHandler::SendPolicies() {
}
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
-void PolicyUIHandler::SetUpdaterPolicies(
- std::unique_ptr<policy::PolicyMap> updater_policies) {
- updater_policies_ = std::move(updater_policies);
+void PolicyUIHandler::SetUpdaterPoliciesAndState(
+ std::unique_ptr<GoogleUpdatePoliciesAndState> updater_policies_and_state) {
+ updater_policies_ = std::move(updater_policies_and_state->policies);
+ static_cast<UpdaterStatusProvider*>(updater_status_provider_.get())
+ ->SetUpdaterStatus(std::move(updater_policies_and_state->state));
if (updater_policies_)
SendPolicies();
}
+
+void PolicyUIHandler::ReloadUpdaterPoliciesAndState() {
+ if (!updater_status_provider_)
+ updater_status_provider_ = std::make_unique<UpdaterStatusProvider>();
+ base::PostTaskAndReplyWithResult(
+ base::ThreadPool::CreateCOMSTATaskRunner(
+ {base::TaskPriority::USER_BLOCKING,
+ base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN, base::MayBlock()})
+ .get(),
+ FROM_HERE, base::BindOnce(&GetGoogleUpdatePoliciesAndState),
+ base::BindOnce(&PolicyUIHandler::SetUpdaterPoliciesAndState,
+ weak_factory_.GetWeakPtr()));
+}
+
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
void PolicyUIHandler::OnRefreshPoliciesDone() {
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.h b/chromium/chrome/browser/ui/webui/policy_ui_handler.h
index 58401981694..2b26a9a28f5 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/policy_ui_handler.h
@@ -32,6 +32,7 @@
#endif
class PolicyStatusProvider;
+struct GoogleUpdatePoliciesAndState;
namespace policy {
class PolicyMap;
@@ -97,9 +98,13 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
void SendPolicies();
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
- // Sets |updater_policies_| in this instance and refreshes the UI via
+ // Sets |updater_policies_| in this instance, updates
+ // |updater_status_provider_| with a new state and refreshes the UI via
// SendPolicies.
- void SetUpdaterPolicies(std::unique_ptr<policy::PolicyMap> updater_policies);
+ void SetUpdaterPoliciesAndState(
+ std::unique_ptr<GoogleUpdatePoliciesAndState> updater_policies_and_state);
+
+ void ReloadUpdaterPoliciesAndState();
#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
// Send the status of cloud policy to the UI. For each scope that has cloud
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 c77c732e023..8fcb2a3a579 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
@@ -302,31 +302,33 @@ void LocalPrinterHandlerChromeos::HandlePrinterSetup(
FetchCapabilities(printer, GetNativePrinterPolicies(), std::move(cb));
return;
}
+ case chromeos::PrinterSetupResult::kPrinterUnreachable:
+ case chromeos::PrinterSetupResult::kPrinterSentWrongResponse:
case chromeos::PrinterSetupResult::kPpdNotFound:
- LOG(WARNING) << "Could not find PPD. Check printer configuration.";
- // Prompt user to update configuration.
- // TODO(skau): Fill me in
- break;
case chromeos::PrinterSetupResult::kPpdUnretrievable:
- LOG(WARNING) << "Could not download PPD. Check Internet connection.";
- // Could not download PPD. Connect to Internet.
+ // Prompt user to update configuration or check internet connection.
// TODO(skau): Fill me in
+ LOG(WARNING) << ResultCodeToMessage(result);
break;
- case chromeos::PrinterSetupResult::kPrinterUnreachable:
+ case chromeos::PrinterSetupResult::kFatalError:
case chromeos::PrinterSetupResult::kDbusError:
- case chromeos::PrinterSetupResult::kComponentUnavailable:
+ case chromeos::PrinterSetupResult::kNativePrintersNotAllowed:
case chromeos::PrinterSetupResult::kPpdTooLarge:
case chromeos::PrinterSetupResult::kInvalidPpd:
- case chromeos::PrinterSetupResult::kFatalError:
- case chromeos::PrinterSetupResult::kNativePrintersNotAllowed:
- case chromeos::PrinterSetupResult::kInvalidPrinterUpdate:
+ case chromeos::PrinterSetupResult::kIoError:
+ case chromeos::PrinterSetupResult::kMemoryAllocationError:
+ case chromeos::PrinterSetupResult::kBadUri:
case chromeos::PrinterSetupResult::kDbusNoReply:
case chromeos::PrinterSetupResult::kDbusTimeout:
- case chromeos::PrinterSetupResult::kEditSuccess:
- LOG(ERROR) << "Unexpected error in printer setup. " << result;
+ LOG(ERROR) << ResultCodeToMessage(result);
break;
+ case chromeos::PrinterSetupResult::kInvalidPrinterUpdate:
+ case chromeos::PrinterSetupResult::kEditSuccess:
+ case chromeos::PrinterSetupResult::kPrinterIsNotAutoconfigurable:
+ case chromeos::PrinterSetupResult::kComponentUnavailable:
case chromeos::PrinterSetupResult::kMaxValue:
- NOTREACHED() << "This value is not expected";
+ LOG(ERROR) << "Unexpected error in printer setup: "
+ << ResultCodeToMessage(result);
break;
}
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 d94ff5d701a..bf325ecd6bc 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
@@ -23,7 +23,6 @@
#if defined(OS_MAC)
#include "components/printing/browser/printer_capabilities_mac.h"
-#include "printing/printing_features.h"
#endif
#if defined(OS_WIN)
@@ -80,8 +79,7 @@ base::Value LocalPrinterHandlerDefault::FetchCapabilitiesAsync(
const std::string& locale) {
PrinterSemanticCapsAndDefaults::Papers user_defined_papers;
#if defined(OS_MAC)
- if (base::FeatureList::IsEnabled(features::kEnableCustomMacPaperSizes))
- user_defined_papers = GetMacCustomPaperSizes();
+ user_defined_papers = GetMacCustomPaperSizes();
#endif
#if defined(OS_WIN)
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 bb362bbd321..c48314e52e8 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
@@ -47,7 +47,6 @@
#if defined(OS_MAC)
#include "components/printing/browser/printer_capabilities_mac.h"
-#include "printing/printing_features.h"
#endif
#if defined(OS_CHROMEOS)
@@ -203,21 +202,18 @@ void PdfPrinterHandler::StartGetCapability(const std::string& destination_id,
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
#if defined(OS_MAC)
- if (base::FeatureList::IsEnabled(features::kEnableCustomMacPaperSizes)) {
- // Read the Mac custom paper sizes on a separate thread.
- // 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(&GetMacCustomPaperSizes),
- base::BindOnce(&ConstructCapabilitiesAndCompleteCallback,
- destination_id, std::move(callback)));
- return;
- }
-#endif
-
+ // Read the Mac custom paper sizes on a separate thread.
+ // 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(&GetMacCustomPaperSizes),
+ base::BindOnce(&ConstructCapabilitiesAndCompleteCallback, destination_id,
+ std::move(callback)));
+#else
ConstructCapabilitiesAndCompleteCallback(
destination_id, std::move(callback),
PrinterSemanticCapsAndDefaults::Papers());
+#endif
}
void PdfPrinterHandler::StartPrint(
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 121a103894f..23cc4711f79 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,10 +17,8 @@
#include "url/gurl.h"
#if defined(OS_MAC)
-#include "base/test/scoped_feature_list.h"
#include "components/printing/browser/printer_capabilities_mac.h"
#include "printing/backend/print_backend.h"
-#include "printing/printing_features.h"
#include "ui/gfx/geometry/size.h"
#endif
@@ -275,10 +273,6 @@ TEST_F(PdfPrinterHandlerGetCapabilityTest, GetCapability) {
#if defined(OS_MAC)
TEST_F(PdfPrinterHandlerGetCapabilityTest,
GetMacCustomPaperSizesInCapabilities) {
- base::test::ScopedFeatureList local_feature;
- local_feature.InitAndEnableFeature(
- printing::features::kEnableCustomMacPaperSizes);
-
constexpr char kPaperOptionPath[] = "capabilities.printer.media_size.option";
static const PrinterSemanticCapsAndDefaults::Papers kTestPapers = {
{"printer1", "", gfx::Size(101600, 127000)},
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 ba451b6c854..2cea700c827 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
@@ -196,6 +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)
+// Name of a dictionary field indicating whether the user's Drive directory is
+// mounted.
+const char kIsDriveMounted[] = "isDriveMounted";
+#endif // defined(OS_CHROMEOS)
// Get the print job settings dictionary from |json_str|.
// Returns |base::Value()| on failure.
@@ -456,10 +461,6 @@ void PrintPreviewHandler::RegisterMessages() {
base::BindRepeating(
&PrintPreviewHandler::HandleRequestPrinterStatusUpdate,
base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "isDriveMounted",
- base::BindRepeating(&PrintPreviewHandler::HandleIsDriveMounted,
- base::Unretained(this)));
#endif
}
@@ -1029,6 +1030,16 @@ void PrintPreviewHandler::SendInitialSettings(
GetUserAccountList(&initial_settings);
}
+#if defined(OS_CHROMEOS)
+ if (base::FeatureList::IsEnabled(chromeos::features::kPrintSaveToDrive)) {
+ drive::DriveIntegrationService* drive_service =
+ drive::DriveIntegrationServiceFactory::GetForProfile(
+ Profile::FromWebUI(web_ui()));
+ initial_settings.SetBoolKey(kIsDriveMounted,
+ drive_service && drive_service->IsMounted());
+ }
+#endif // defined(OS_CHROMEOS)
+
ResolveJavascriptCallback(base::Value(callback_id), initial_settings);
}
@@ -1410,18 +1421,6 @@ void PrintPreviewHandler::OnPrinterStatusUpdated(
const base::Value& cups_printer_status) {
ResolveJavascriptCallback(base::Value(callback_id), cups_printer_status);
}
-
-void PrintPreviewHandler::HandleIsDriveMounted(const base::ListValue* args) {
- CHECK_EQ(1U, args->GetSize());
- const std::string& callback_id = args->GetList()[0].GetString();
-
- drive::DriveIntegrationService* drive_service =
- drive::DriveIntegrationServiceFactory::GetForProfile(
- Profile::FromWebUI(web_ui()));
- ResolveJavascriptCallback(
- base::Value(callback_id),
- base::Value(drive_service && drive_service->IsMounted()));
-}
#endif
} // namespace printing
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 ed760a476c7..dfdff9c6553 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
@@ -318,10 +318,6 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// Resolves callback with printer status.
void OnPrinterStatusUpdated(const std::string& callback_id,
const base::Value& cups_printer_status);
-
- // Resolves Javascript callback with true if the user's local Drive folder is
- // mounted.
- void HandleIsDriveMounted(const base::ListValue* args);
#endif
// A count of how many requests received to regenerate preview data.
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 377c9a41e81..d00cef7992d 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
@@ -104,12 +104,12 @@ void ReportPrintSettingsStats(const base::Value& print_settings,
base::Optional<int> color_mode_opt = print_settings.FindIntKey(kSettingColor);
if (color_mode_opt.has_value()) {
+ mojom::ColorModel color_model =
+ ColorModeToColorModel(color_mode_opt.value());
bool unknown_color_model =
- color_mode_opt.value() ==
- static_cast<int>(mojom::ColorModel::kUnknownColorModel);
+ color_model == mojom::ColorModel::kUnknownColorModel;
if (!unknown_color_model) {
- base::Optional<bool> is_color =
- IsColorModelSelected(color_mode_opt.value());
+ base::Optional<bool> is_color = IsColorModelSelected(color_model);
ReportPrintSettingHistogram(is_color.value()
? PrintSettingsBuckets::kColor
: PrintSettingsBuckets::kBlackAndWhite);
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 48dfc6e9586..5999318f362 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
@@ -18,6 +18,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
#include "base/metrics/histogram_functions.h"
+#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
@@ -89,7 +90,7 @@ const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)";
#if !BUILDFLAG(OPTIMIZE_WEBUI)
constexpr char kGeneratedPath[] =
- "@out_folder@/gen/chrome/browser/resources/print_preview/";
+ "@out_folder@/gen/chrome/browser/resources/print_preview/preprocessed/";
#endif
PrintPreviewUI::TestDelegate* g_test_delegate = nullptr;
@@ -420,6 +421,9 @@ void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) {
"showPrinterStatus",
base::FeatureList::IsEnabled(chromeos::features::kPrinterStatus));
source->AddBoolean(
+ "showPrinterStatusInDialog",
+ base::FeatureList::IsEnabled(chromeos::features::kPrinterStatusDialog));
+ source->AddBoolean(
"printSaveToDrive",
base::FeatureList::IsEnabled(chromeos::features::kPrintSaveToDrive));
#endif
@@ -548,6 +552,7 @@ void PrintPreviewUI::ClearPreviewUIId() {
if (!id_)
return;
+ receiver_.reset();
PrintPreviewDataService::GetInstance()->RemoveEntry(*id_);
g_print_preview_request_id_map.Get().Erase(*id_);
g_print_preview_ui_id_map.Get().Remove(*id_);
@@ -607,19 +612,19 @@ void PrintPreviewUI::SetInitiatorTitle(
initiator_title_ = job_title;
}
-bool PrintPreviewUI::LastPageComposited(int page_number) const {
+bool PrintPreviewUI::LastPageComposited(uint32_t page_number) const {
if (pages_to_render_.empty())
return false;
return page_number == pages_to_render_.back();
}
-int PrintPreviewUI::GetPageToNupConvertIndex(int page_number) const {
+uint32_t PrintPreviewUI::GetPageToNupConvertIndex(uint32_t page_number) const {
for (size_t index = 0; index < pages_to_render_.size(); ++index) {
if (page_number == pages_to_render_[index])
return index;
}
- return -1;
+ return kInvalidPageIndex;
}
std::vector<base::ReadOnlySharedMemoryRegion>
@@ -648,7 +653,7 @@ void PrintPreviewUI::SetInitialParams(
}
// static
-bool PrintPreviewUI::ShouldCancelRequest(const PrintHostMsg_PreviewIds& ids) {
+bool PrintPreviewUI::ShouldCancelRequest(const mojom::PreviewIds& ids) {
int current_id = -1;
if (!g_print_preview_request_id_map.Get().Get(ids.ui_id, &current_id))
return true;
@@ -697,7 +702,8 @@ void PrintPreviewUI::OnPrintPreviewRequest(int request_id) {
void PrintPreviewUI::OnDidStartPreview(
const mojom::DidStartPreviewParams& params,
int request_id) {
- DCHECK_GT(params.page_count, 0);
+ DCHECK_GT(params.page_count, 0u);
+ DCHECK_LE(params.page_count, kMaxPageCount);
DCHECK(!params.pages_to_render.empty());
pages_to_render_ = params.pages_to_render;
@@ -708,8 +714,8 @@ void PrintPreviewUI::OnDidStartPreview(
if (g_test_delegate)
g_test_delegate->DidGetPreviewPageCount(params.page_count);
- handler_->SendPageCountReady(params.page_count, params.fit_to_page_scaling,
- request_id);
+ handler_->SendPageCountReady(base::checked_cast<int>(params.page_count),
+ params.fit_to_page_scaling, request_id);
}
void PrintPreviewUI::OnDidGetDefaultPageLayout(
@@ -741,7 +747,7 @@ void PrintPreviewUI::OnDidGetDefaultPageLayout(
handler_->SendPageLayoutReady(layout, has_custom_page_size_style, request_id);
}
-bool PrintPreviewUI::OnPendingPreviewPage(int page_number) {
+bool PrintPreviewUI::OnPendingPreviewPage(uint32_t page_number) {
if (pages_to_render_index_ >= pages_to_render_.size())
return false;
@@ -751,16 +757,18 @@ bool PrintPreviewUI::OnPendingPreviewPage(int page_number) {
}
void PrintPreviewUI::OnDidPreviewPage(
- int page_number,
+ uint32_t page_number,
scoped_refptr<base::RefCountedMemory> data,
int preview_request_id) {
- DCHECK_GE(page_number, 0);
+ DCHECK_NE(page_number, kInvalidPageIndex);
- SetPrintPreviewDataForIndex(page_number, std::move(data));
+ SetPrintPreviewDataForIndex(base::checked_cast<int>(page_number),
+ std::move(data));
if (g_test_delegate)
g_test_delegate->DidRenderPreviewPage(web_ui()->GetWebContents());
- handler_->SendPagePreviewReady(page_number, *id_, preview_request_id);
+ handler_->SendPagePreviewReady(base::checked_cast<int>(page_number), *id_,
+ preview_request_id);
}
void PrintPreviewUI::OnPreviewDataIsAvailable(
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 32bc87ad8a1..d0e9b1fc8b1 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
@@ -25,7 +25,6 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
-struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_RequestPrintPreview_Params;
namespace base {
@@ -91,11 +90,11 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
// Returns true if |page_number| is the last page in |pages_to_render_|.
// |page_number| is a 0-based number.
- bool LastPageComposited(int page_number) const;
+ bool LastPageComposited(uint32_t page_number) const;
// Get the 0-based index of the |page_number| in |pages_to_render_|.
// Same as above, |page_number| is a 0-based number.
- int GetPageToNupConvertIndex(int page_number) const;
+ uint32_t GetPageToNupConvertIndex(uint32_t page_number) const;
std::vector<base::ReadOnlySharedMemoryRegion> TakePagesForNupConvert();
@@ -132,7 +131,7 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
// Determines whether to cancel a print preview request based on the request
// and UI ids in |ids|.
// Can be called from any thread.
- static bool ShouldCancelRequest(const PrintHostMsg_PreviewIds& ids);
+ static bool ShouldCancelRequest(const mojom::PreviewIds& ids);
// Returns an id to uniquely identify this PrintPreviewUI.
base::Optional<int32_t> GetIDForPrintPreviewUI() const;
@@ -154,11 +153,11 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
// 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(int page_number);
+ 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(int page_number,
+ void OnDidPreviewPage(uint32_t page_number,
scoped_refptr<base::RefCountedMemory> data,
int preview_request_id);
@@ -191,7 +190,7 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
// Allows tests to wait until the print preview dialog is loaded.
class TestDelegate {
public:
- virtual void DidGetPreviewPageCount(int page_count) = 0;
+ virtual void DidGetPreviewPageCount(uint32_t page_count) = 0;
virtual void DidRenderPreviewPage(content::WebContents* preview_dialog) = 0;
protected:
@@ -280,7 +279,7 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
base::string16 initiator_title_;
// The list of 0-based page numbers that will be rendered.
- std::vector<int> pages_to_render_;
+ std::vector<uint32_t> pages_to_render_;
// The list of pages to be converted.
std::vector<base::ReadOnlySharedMemoryRegion> pages_for_nup_convert_;
diff --git a/chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc b/chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc
index b191e4ec728..06b152b6e67 100644
--- a/chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc
@@ -154,7 +154,13 @@ IN_PROC_BROWSER_TEST_F(ProfileHelperTest, OpenNewWindowForProfile) {
#endif
}
-IN_PROC_BROWSER_TEST_F(ProfileHelperTest, DeleteSoleProfile) {
+// Test is flaky on Lacros. crbug.com/1130131
+#if defined(OS_LINUX)
+#define MAYBE_DeleteSoleProfile DISABLED_DeleteSoleProfile
+#else
+#define MAYBE_DeleteSoleProfile DeleteSoleProfile
+#endif
+IN_PROC_BROWSER_TEST_F(ProfileHelperTest, MAYBE_DeleteSoleProfile) {
content::TestWebUI web_ui;
Browser* original_browser = browser();
ProfileAttributesStorage& storage =
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 658eb7b6743..ef7780d63da 100644
--- a/chromium/chrome/browser/ui/webui/read_later/read_later.mojom
+++ b/chromium/chrome/browser/ui/webui/read_later/read_later.mojom
@@ -4,7 +4,6 @@
module read_later.mojom;
-import "mojo/public/mojom/base/string16.mojom";
import "url/mojom/url.mojom";
// Read later entries grouped by read/unread status.
@@ -17,9 +16,11 @@ struct ReadLaterEntriesByStatus {
struct ReadLaterEntry {
string title;
url.mojom.Url url;
- mojo_base.mojom.String16 display_url;
+ string display_url;
int64 update_time;
- mojo_base.mojom.String16 display_time_since_update;
+ // Whether the entry has been read.
+ bool read;
+ string display_time_since_update;
};
// Used by the WebUI page to bootstrap bidirectional communication.
@@ -46,4 +47,7 @@ interface PageHandler {
// WebUI-side handler for requests from the browser.
interface Page {
+ // Callback when any item in read later is
+ // changed/removed.
+ ItemsChanged();
};
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 ec052624c1a..601500ce910 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
@@ -6,11 +6,10 @@
#include <algorithm>
#include <memory>
-#include <string>
#include <utility>
#include <vector>
-#include "base/strings/string16.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
@@ -86,10 +85,12 @@ void ReadLaterPageHandler::OpenSavedEntry(const GURL& url) {
void ReadLaterPageHandler::UpdateReadStatus(const GURL& url, bool read) {
reading_list_model_->SetReadStatus(url, read);
+ page_->ItemsChanged();
}
void ReadLaterPageHandler::RemoveEntry(const GURL& url) {
reading_list_model_->RemoveEntryByURL(url);
+ page_->ItemsChanged();
}
read_later::mojom::ReadLaterEntryPtr ReadLaterPageHandler::GetEntryData(
@@ -98,27 +99,29 @@ read_later::mojom::ReadLaterEntryPtr ReadLaterPageHandler::GetEntryData(
entry_data->title = entry->Title();
entry_data->url = entry->URL();
- entry_data->display_url = url_formatter::FormatUrl(
+ entry_data->display_url = base::UTF16ToUTF8(url_formatter::FormatUrl(
entry->URL(),
url_formatter::kFormatUrlOmitDefaults |
url_formatter::kFormatUrlOmitHTTPS |
url_formatter::kFormatUrlOmitTrivialSubdomains |
url_formatter::kFormatUrlTrimAfterHost,
- net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr);
+ net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr));
entry_data->update_time = entry->UpdateTime();
+ entry_data->read = entry->IsRead();
entry_data->display_time_since_update =
GetTimeSinceLastUpdate(entry->UpdateTime());
return entry_data;
}
-base::string16 ReadLaterPageHandler::GetTimeSinceLastUpdate(
+std::string ReadLaterPageHandler::GetTimeSinceLastUpdate(
int64_t last_update_time) {
const int64_t now = TimeToUS(clock_->Now());
if (last_update_time > now)
- return base::string16();
+ return std::string();
const base::TimeDelta elapsed_time =
base::TimeDelta::FromMicroseconds(now - last_update_time);
- return ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED,
- ui::TimeFormat::LENGTH_SHORT, elapsed_time);
+ return base::UTF16ToUTF8(
+ ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED,
+ ui::TimeFormat::LENGTH_SHORT, elapsed_time));
}
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 5bcf496f676..26d32c109e2 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
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_READ_LATER_READ_LATER_PAGE_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_READ_LATER_READ_LATER_PAGE_HANDLER_H_
+#include <string>
+
#include "chrome/browser/ui/webui/read_later/read_later.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
@@ -45,7 +47,7 @@ class ReadLaterPageHandler : public read_later::mojom::PageHandler {
// 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").
- base::string16 GetTimeSinceLastUpdate(int64_t last_update_time);
+ std::string GetTimeSinceLastUpdate(int64_t last_update_time);
mojo::Receiver<read_later::mojom::PageHandler> receiver_;
mojo::Remote<read_later::mojom::Page> page_;
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 e24589d21c5..c209a4344df 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
@@ -42,6 +42,8 @@ class MockPage : public read_later::mojom::Page {
return receiver_.BindNewPipeAndPassRemote();
}
mojo::Receiver<read_later::mojom::Page> receiver_{this};
+
+ MOCK_METHOD0(ItemsChanged, void());
};
void ExpectNewReadLaterEntry(const read_later::mojom::ReadLaterEntry* entry,
@@ -104,8 +106,9 @@ class TestReadLaterPageHandlerTest : public BrowserWithTestWindowTest {
base::ASCIIToUTF16(title));
}
- private:
testing::StrictMock<MockPage> page_;
+
+ private:
std::unique_ptr<TestReadLaterPageHandler> handler_;
ReadingListModel* model_;
};
@@ -156,6 +159,7 @@ TEST_F(TestReadLaterPageHandlerTest, OpenSavedEntry) {
TEST_F(TestReadLaterPageHandlerTest, UpdateReadStatus) {
handler()->UpdateReadStatus(GURL(kTabUrl3), true);
+ EXPECT_CALL(page_, ItemsChanged()).Times(1);
// Get Read later entries.
read_later::mojom::PageHandler::GetReadLaterEntriesCallback callback1 =
@@ -177,6 +181,7 @@ TEST_F(TestReadLaterPageHandlerTest, UpdateReadStatus) {
TEST_F(TestReadLaterPageHandlerTest, RemoveEntry) {
handler()->RemoveEntry(GURL(kTabUrl3));
+ EXPECT_CALL(page_, ItemsChanged()).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 a5a4cc21a2a..5535ada23f0 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
@@ -4,18 +4,55 @@
#include "chrome/browser/ui/webui/read_later/read_later_ui.h"
+#include <string>
#include <utility>
#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/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"
+
+namespace {
+constexpr char kGeneratedPath[] =
+ "@out_folder@/gen/chrome/browser/resources/read_later/";
+
+void AddLocalizedString(content::WebUIDataSource* source,
+ const std::string& message,
+ int id) {
+ base::string16 str = l10n_util::GetStringUTF16(id);
+ base::Erase(str, '&');
+ source->AddString(message, str);
+}
+} // namespace
ReadLaterUI::ReadLaterUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIReadLaterHost);
+ source->AddResourcePath("read_later.mojom-lite.js",
+ IDR_READ_LATER_MOJO_LITE_JS);
+ static constexpr webui::LocalizedString kLocalizedStrings[] = {
+ {"readHeader", IDS_READ_LATER_MENU_READ_HEADER},
+ {"title", IDS_READ_LATER_TITLE},
+ {"tooltipDelete", IDS_DELETE},
+ {"tooltipMarkAsRead", IDS_READ_LATER_MENU_TOOLTIP_MARK_AS_READ},
+ {"tooltipMarkAsUnread", IDS_READ_LATER_MENU_TOOLTIP_MARK_AS_UNREAD},
+ {"unreadHeader", IDS_READ_LATER_MENU_UNREAD_HEADER},
+ };
+ for (const auto& str : kLocalizedStrings)
+ AddLocalizedString(source, str.name, str.id);
+
+ webui::SetupWebUIDataSource(
+ source, base::make_span(kReadLaterResources, kReadLaterResourcesSize),
+ kGeneratedPath, IDR_READ_LATER_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
source);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
index 549152c3ee1..069b8d48d63 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
@@ -22,7 +22,7 @@
#include "base/strings/string_util.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
-#include "base/time/time.h"
+#include "base/time/default_clock.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
@@ -252,7 +252,9 @@ std::string UpdateStatusToString(VersionUpdater::Status status) {
namespace settings {
AboutHandler::AboutHandler(Profile* profile)
- : profile_(profile), apply_changes_from_upgrade_observer_(false) {
+ : profile_(profile),
+ apply_changes_from_upgrade_observer_(false),
+ clock_(base::DefaultClock::GetInstance()) {
UpgradeDetector::GetInstance()->AddObserver(this);
}
@@ -312,10 +314,6 @@ void AboutHandler::RegisterMessages() {
base::BindRepeating(&AboutHandler::HandleGetEndOfLifeInfo,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "getEnabledReleaseNotes",
- base::BindRepeating(&AboutHandler::HandleGetEnabledReleaseNotes,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
"launchReleaseNotes",
base::BindRepeating(&AboutHandler::HandleLaunchReleaseNotes,
base::Unretained(this)));
@@ -421,15 +419,6 @@ void AboutHandler::HandleOpenHelpPage(const base::ListValue* args) {
}
#if defined(OS_CHROMEOS)
-void AboutHandler::HandleGetEnabledReleaseNotes(const base::ListValue* args) {
- CHECK_EQ(1U, args->GetSize());
- std::string callback_id;
- CHECK(args->GetString(0, &callback_id));
- ResolveJavascriptCallback(base::Value(callback_id),
- base::Value(base::FeatureList::IsEnabled(
- chromeos::features::kReleaseNotes)));
-}
-
void AboutHandler::HandleCheckInternetConnection(const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
std::string callback_id;
@@ -630,7 +619,7 @@ void AboutHandler::OnGetEndOfLifeInfo(
chromeos::UpdateEngineClient::EolInfo eol_info) {
base::Value response(base::Value::Type::DICTIONARY);
if (!eol_info.eol_date.is_null()) {
- bool has_eol_passed = eol_info.eol_date <= base::Time::Now();
+ bool has_eol_passed = eol_info.eol_date <= clock_->Now();
response.SetBoolKey("hasEndOfLife", has_eol_passed);
int eol_string_id =
has_eol_passed ? IDS_SETTINGS_ABOUT_PAGE_END_OF_LIFE_MESSAGE_PAST
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.h b/chromium/chrome/browser/ui/webui/settings/about_handler.h
index 9f1fcb630b2..bed6a0ecb10 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.h
@@ -28,6 +28,7 @@ namespace base {
class DictionaryValue;
class FilePath;
class ListValue;
+class Clock;
} // namespace base
class Profile;
@@ -52,6 +53,10 @@ class AboutHandler : public settings::SettingsPageUIHandler,
// Returns the browser version as a string.
static base::string16 BuildBrowserVersionString();
+ protected:
+ // Used to test the EOL string displayed in the About details page.
+ void set_clock(base::Clock* clock) { clock_ = clock; }
+
private:
void OnDeviceAutoUpdatePolicyChanged(const base::Value* previous_policy,
const base::Value* current_policy);
@@ -182,6 +187,9 @@ class AboutHandler : public settings::SettingsPageUIHandler,
// If true changes to UpgradeObserver are applied, if false they are ignored.
bool apply_changes_from_upgrade_observer_;
+ // Override to test the EOL string displayed in the About details page.
+ base::Clock* clock_;
+
// Used for callbacks.
base::WeakPtrFactory<AboutHandler> weak_factory_{this};
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc
index bdfcdf6e8de..6c93c1ff9b0 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/browser/ui/webui/settings/about_handler.h"
+#include "base/test/simple_test_clock.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -22,6 +23,9 @@ class TestAboutHandler : public ::settings::AboutHandler {
~TestAboutHandler() override = default;
// Make public for testing.
+ using AboutHandler::set_clock;
+
+ // Make public for testing.
using AboutHandler::set_web_ui;
};
@@ -42,6 +46,9 @@ class AboutHandlerTest : public testing::Test {
handler_->set_web_ui(&web_ui_);
handler_->RegisterMessages();
handler_->AllowJavascriptForTesting();
+
+ clock_ = std::make_unique<base::SimpleTestClock>();
+ handler_->set_clock(clock_.get());
}
void TearDown() override {
@@ -72,35 +79,38 @@ class AboutHandlerTest : public testing::Test {
return call_data.arg3()->FindKey("aboutPageEndOfLifeMessage")->GetString();
}
+ void SetCurrentTimeToUtc(const char* utc_date_string) {
+ base::Time utc_time;
+ ASSERT_TRUE(base::Time::FromUTCString(utc_date_string, &utc_time));
+ clock_->SetNow(utc_time);
+ }
+
+ void SetEolDateUtc(const char* utc_date_string) {
+ base::Time utc_date;
+ ASSERT_TRUE(base::Time::FromUTCString(utc_date_string, &utc_date));
+ fake_update_engine_client_->set_eol_date(utc_date);
+ }
+
protected:
content::BrowserTaskEnvironment task_environment_;
TestingProfile profile_;
content::TestWebUI web_ui_;
std::unique_ptr<TestAboutHandler> handler_;
FakeUpdateEngineClient* fake_update_engine_client_;
+ std::unique_ptr<base::SimpleTestClock> clock_;
};
-// Deterministic fail on CHROMEOS, crbug.com/1122584.
-#if defined(OS_CHROMEOS)
-#define MAYBE_EndOfLifeMessageInAboutDetailsSubpage \
- DISABLED_EndOfLifeMessageInAboutDetailsSubpage
-#else
-#define MAYBE_EndOfLifeMessageInAboutDetailsSubpage \
- EndOfLifeMessageInAboutDetailsSubpage
-#endif
-TEST_F(AboutHandlerTest, MAYBE_EndOfLifeMessageInAboutDetailsSubpage) {
- const base::Time eol_passed_date =
- base::Time::Now() - base::TimeDelta::FromDays(1000);
- fake_update_engine_client_->set_eol_date(eol_passed_date);
+TEST_F(AboutHandlerTest, EndOfLifeMessageInAboutDetailsSubpage) {
+ SetCurrentTimeToUtc("15 March 2020");
+
+ SetEolDateUtc("15 November 2017");
EXPECT_EQ(
"This device stopped getting automatic software and security "
"updates in November 2017. <a target=\"_blank\" href=\"https:"
"//www.google.com/chromebook/older/\">Learn more</a>",
CallGetEndOfLifeInfoAndReturnString(true /*=has_eol_passed*/));
- const base::Time eol_future_date =
- base::Time::Now() + base::TimeDelta::FromDays(1000);
- fake_update_engine_client_->set_eol_date(eol_future_date);
+ SetEolDateUtc("15 May 2023");
EXPECT_EQ(
"This device will get automatic software and security updates "
"until May 2023. <a target=\"_blank\" href=\"http://support.google"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS b/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
index ff0d48d0403..b89ca31bbd5 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS
@@ -1,5 +1,7 @@
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
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 c32688e2457..c123e9abe31 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.cc
@@ -66,6 +66,12 @@ const std::vector<SearchConcept>& GetAboutSearchConcepts() {
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kChangeChromeChannel}},
+ {IDS_OS_SETTINGS_TAG_ABOUT_CHROME_OS_COPY_DETAILED_BUILD,
+ mojom::kDetailedBuildInfoSubpagePath,
+ mojom::SearchResultIcon::kChrome,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kCopyDetailedBuildInfo}},
{IDS_OS_SETTINGS_TAG_ABOUT_OS_UPDATE,
mojom::kAboutChromeOsDetailsSubpagePath,
mojom::SearchResultIcon::kChrome,
@@ -78,12 +84,6 @@ const std::vector<SearchConcept>& GetAboutSearchConcepts() {
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kGetHelpWithChromeOs}},
- });
- return *tags;
-}
-
-const std::vector<SearchConcept>& GetAboutReleaseNotesSearchConcepts() {
- static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_ABOUT_RELEASE_NOTES,
mojom::kAboutChromeOsDetailsSubpagePath,
mojom::SearchResultIcon::kChrome,
@@ -165,9 +165,6 @@ AboutSection::AboutSection(Profile* profile,
: OsSettingsSection(profile, search_tag_registry) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.AddSearchTags(GetAboutSearchConcepts());
-
- if (base::FeatureList::IsEnabled(features::kReleaseNotes))
- updater.AddSearchTags(GetAboutReleaseNotesSearchConcepts());
}
AboutSection::~AboutSection() = default;
@@ -353,6 +350,11 @@ std::string AboutSection::GetSectionPath() const {
return mojom::kAboutChromeOsSectionPath;
}
+bool AboutSection::LogMetric(mojom::Setting setting, base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void AboutSection::RegisterHierarchy(HierarchyGenerator* generator) const {
// About Chrome OS.
generator->RegisterTopLevelSubpage(
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.h
index 506f0b67d56..ef35563aa3a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/about_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ABOUT_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ABOUT_SECTION_H_
+#include "base/values.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "components/prefs/pref_change_registrar.h"
@@ -37,6 +38,7 @@ class AboutSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
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 587ac2b55a7..c564ce464ca 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.cc
@@ -11,6 +11,8 @@
#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "chrome/browser/accessibility/accessibility_state_utils.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h"
#include "chrome/browser/ui/webui/settings/accessibility_main_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
@@ -23,6 +25,7 @@
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_features.h"
+#include "extensions/browser/extension_system.h"
#include "media/base/media_switches.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/accessibility_switches.h"
@@ -96,12 +99,6 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kCaptions}},
- {IDS_OS_SETTINGS_TAG_A11Y_SPEECH_ENGINES,
- mojom::kTextToSpeechSubpagePath,
- mojom::SearchResultIcon::kA11y,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kTextToSpeechEngines}},
{IDS_OS_SETTINGS_TAG_A11Y_HIGHLIGHT_CURSOR,
mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
@@ -147,7 +144,7 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kSpeakToType}},
+ {.setting = mojom::Setting::kHighlightKeyboardFocus}},
{IDS_OS_SETTINGS_TAG_A11Y_STARTUP_SOUND,
mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
@@ -190,6 +187,18 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kFullscreenMagnifier}},
+ {IDS_OS_SETTINGS_TAG_A11Y_ENABLE_SWITCH_ACCESS,
+ mojom::kManageAccessibilitySubpagePath,
+ mojom::SearchResultIcon::kA11y,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kEnableSwitchAccess}},
+ });
+ return *tags;
+}
+
+const std::vector<SearchConcept>& GetTextToSpeechVoiceSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_A11Y_SPEECH_VOICE_PREVIEW,
mojom::kTextToSpeechSubpagePath,
mojom::SearchResultIcon::kA11y,
@@ -200,14 +209,14 @@ const std::vector<SearchConcept>& GetA11ySearchConcepts() {
return *tags;
}
-const std::vector<SearchConcept>& GetA11ySwitchAccessSearchConcepts() {
+const std::vector<SearchConcept>& GetTextToSpeechEnginesSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_A11Y_ENABLE_SWITCH_ACCESS,
- mojom::kManageAccessibilitySubpagePath,
+ {IDS_OS_SETTINGS_TAG_A11Y_SPEECH_ENGINES,
+ mojom::kTextToSpeechSubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kEnableSwitchAccess}},
+ {.setting = mojom::Setting::kTextToSpeechEngines}},
});
return *tags;
}
@@ -275,7 +284,7 @@ const std::vector<SearchConcept>& GetA11yLabelsSearchConcepts() {
const std::vector<SearchConcept>& GetA11yLiveCaptionSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_A11Y_LIVE_CAPTIONS,
+ {IDS_OS_SETTINGS_TAG_A11Y_LIVE_CAPTION,
mojom::kManageAccessibilitySubpagePath,
mojom::SearchResultIcon::kA11y,
mojom::SearchResultDefaultRank::kMedium,
@@ -310,11 +319,6 @@ bool IsCursorColorAllowed() {
return features::IsAccessibilityCursorColorEnabled();
}
-bool IsSwitchAccessAllowed() {
- return base::CommandLine::ForCurrentProcess()->HasSwitch(
- ::switches::kEnableExperimentalAccessibilitySwitchAccess);
-}
-
bool IsSwitchAccessTextAllowed() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kEnableExperimentalAccessibilitySwitchAccessText);
@@ -348,10 +352,27 @@ AccessibilitySection::AccessibilitySection(
ash::prefs::kAccessibilitySwitchAccessAutoScanEnabled,
base::BindRepeating(&AccessibilitySection::UpdateSearchTags,
base::Unretained(this)));
+
UpdateSearchTags();
+
+ // ExtensionService can be null for tests.
+ extensions::ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
+ if (!extension_service)
+ return;
+ content::TtsController::GetInstance()->AddVoicesChangedDelegate(this);
+ extension_registry_ = extensions::ExtensionRegistry::Get(profile);
+ extension_registry_->AddObserver(this);
+
+ UpdateTextToSpeechVoiceSearchTags();
+ UpdateTextToSpeechEnginesSearchTags();
}
-AccessibilitySection::~AccessibilitySection() = default;
+AccessibilitySection::~AccessibilitySection() {
+ content::TtsController::GetInstance()->RemoveVoicesChangedDelegate(this);
+ if (extension_registry_)
+ extension_registry_->RemoveObserver(this);
+}
void AccessibilitySection::AddLoadTimeData(
content::WebUIDataSource* html_source) {
@@ -548,8 +569,6 @@ void AccessibilitySection::AddLoadTimeData(
html_source->AddString("a11yLearnMoreUrl",
chrome::kChromeAccessibilityHelpURL);
- html_source->AddBoolean("showExperimentalAccessibilitySwitchAccess",
- IsSwitchAccessAllowed());
html_source->AddBoolean(
"showExperimentalAccessibilitySwitchAccessImprovedTextInput",
IsSwitchAccessTextAllowed());
@@ -595,10 +614,17 @@ mojom::SearchResultIcon AccessibilitySection::GetSectionIcon() const {
std::string AccessibilitySection::GetSectionPath() const {
return mojom::kAccessibilitySectionPath;
}
+bool AccessibilitySection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
void AccessibilitySection::RegisterHierarchy(
HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kA11yQuickSettings);
+ generator->RegisterTopLevelSetting(
+ mojom::Setting::kGetImageDescriptionsFromGoogle);
// Manage accessibility.
generator->RegisterTopLevelSubpage(
@@ -615,7 +641,7 @@ void AccessibilitySection::RegisterHierarchy(
mojom::Setting::kStickyKeys,
mojom::Setting::kOnScreenKeyboard,
mojom::Setting::kDictation,
- mojom::Setting::kSpeakToType,
+ mojom::Setting::kHighlightKeyboardFocus,
mojom::Setting::kEnableSwitchAccess,
mojom::Setting::kHighlightTextCaret,
mojom::Setting::kAutoClickWhenCursorStops,
@@ -624,7 +650,6 @@ void AccessibilitySection::RegisterHierarchy(
mojom::Setting::kTabletNavigationButtons,
mojom::Setting::kMonoAudio,
mojom::Setting::kStartupSound,
- mojom::Setting::kGetImageDescriptionsFromGoogle,
mojom::Setting::kLiveCaptions,
mojom::Setting::kEnableCursorColor,
};
@@ -658,13 +683,56 @@ void AccessibilitySection::RegisterHierarchy(
RegisterNestedSettingBulk(mojom::Subpage::kSwitchAccessOptions,
kSwitchAccessSettings, generator);
- // Captions.
+ // Caption preferences.
generator->RegisterTopLevelSubpage(
IDS_SETTINGS_CAPTIONS, mojom::Subpage::kCaptions,
mojom::SearchResultIcon::kA11y, mojom::SearchResultDefaultRank::kMedium,
mojom::kCaptionsSubpagePath);
}
+void AccessibilitySection::OnVoicesChanged() {
+ UpdateTextToSpeechVoiceSearchTags();
+}
+
+void AccessibilitySection::UpdateTextToSpeechVoiceSearchTags() {
+ // Start with no text-to-speech voice search tags.
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetTextToSpeechVoiceSearchConcepts());
+
+ content::TtsController* tts_controller =
+ content::TtsController::GetInstance();
+ std::vector<content::VoiceData> voices;
+ tts_controller->GetVoices(profile(), &voices);
+ if (!voices.empty()) {
+ updater.AddSearchTags(GetTextToSpeechVoiceSearchConcepts());
+ }
+}
+
+void AccessibilitySection::OnExtensionLoaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension) {
+ UpdateTextToSpeechEnginesSearchTags();
+}
+
+void AccessibilitySection::OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionReason reason) {
+ UpdateTextToSpeechEnginesSearchTags();
+}
+
+void AccessibilitySection::UpdateTextToSpeechEnginesSearchTags() {
+ // Start with no text-to-speech engines search tags.
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetTextToSpeechEnginesSearchConcepts());
+
+ const std::set<std::string> extensions =
+ TtsEngineExtensionObserver::GetInstance(profile())->GetTtsExtensions();
+ if (!extensions.empty()) {
+ updater.AddSearchTags(GetTextToSpeechEnginesSearchConcepts());
+ }
+}
+
void AccessibilitySection::UpdateSearchTags() {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
@@ -675,7 +743,6 @@ void AccessibilitySection::UpdateSearchTags() {
updater.RemoveSearchTags(GetA11yLabelsSearchConcepts());
}
- updater.RemoveSearchTags(GetA11ySwitchAccessSearchConcepts());
updater.RemoveSearchTags(GetA11ySwitchAccessOnSearchConcepts());
updater.RemoveSearchTags(GetA11ySwitchAccessKeyboardSearchConcepts());
@@ -691,11 +758,6 @@ void AccessibilitySection::UpdateSearchTags() {
updater.RemoveSearchTags(GetA11yCursorColorSearchConcepts());
}
- if (!IsSwitchAccessAllowed())
- return;
-
- updater.AddSearchTags(GetA11ySwitchAccessSearchConcepts());
-
if (!pref_service_->GetBoolean(
ash::prefs::kAccessibilitySwitchAccessEnabled)) {
return;
@@ -703,7 +765,8 @@ void AccessibilitySection::UpdateSearchTags() {
updater.AddSearchTags(GetA11ySwitchAccessOnSearchConcepts());
- if (pref_service_->GetBoolean(
+ if (IsSwitchAccessTextAllowed() &&
+ pref_service_->GetBoolean(
ash::prefs::kAccessibilitySwitchAccessAutoScanEnabled)) {
updater.AddSearchTags(GetA11ySwitchAccessKeyboardSearchConcepts());
}
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 77f82db40d3..e87764dda08 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_section.h
@@ -5,8 +5,13 @@
#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"
+#include "content/public/browser/tts_controller.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_registry_observer.h"
class PrefService;
@@ -20,7 +25,9 @@ namespace settings {
class SearchTagRegistry;
// Provides UI strings and search tags for Accessibility settings.
-class AccessibilitySection : public OsSettingsSection {
+class AccessibilitySection : public OsSettingsSection,
+ public content::VoicesChangedDelegate,
+ public extensions::ExtensionRegistryObserver {
public:
AccessibilitySection(Profile* profile,
SearchTagRegistry* search_tag_registry,
@@ -35,12 +42,26 @@ class AccessibilitySection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
+ // content::VoicesChangedDelegate:
+ void OnVoicesChanged() override;
+
+ // extensions::ExtensionRegistryObserver:
+ void OnExtensionLoaded(content::BrowserContext* browser_context,
+ const extensions::Extension* extension) override;
+ void OnExtensionUnloaded(content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionReason reason) override;
+
void UpdateSearchTags();
+ void UpdateTextToSpeechVoiceSearchTags();
+ void UpdateTextToSpeechEnginesSearchTags();
PrefService* pref_service_;
PrefChangeRegistrar pref_change_registrar_;
+ extensions::ExtensionRegistry* extension_registry_ = nullptr;
};
} // namespace settings
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 69266feb260..80735842fe4 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
@@ -269,7 +269,10 @@ void AccountManagerUIHandler::OnGetAccounts(
// Check if user is managed.
if (profile_->IsChild()) {
- device_account.SetOrganization(kFamilyLink);
+ std::string organization = kFamilyLink;
+ // Replace space with the non-breaking space.
+ base::ReplaceSubstringsAfterOffset(&organization, 0, " ", "&nbsp;");
+ device_account.SetOrganization(organization);
} else if (user->IsActiveDirectoryUser()) {
device_account.SetOrganization(
GetEnterpriseDomainFromUsername(user->GetDisplayEmail()));
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 af9ff41fcf1..3cd2374a6e0 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
@@ -226,8 +226,9 @@ class AccountManagerUIHandlerTest
std::unique_ptr<TestingAccountManagerUIHandler> handler_;
};
+// TODO(https://crbug.com/1131834): Re-enable flaky test.
IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
- OnGetAccountsNoSecondaryAccounts) {
+ DISABLED_OnGetAccountsNoSecondaryAccounts) {
const std::vector<AccountManager::Account> account_manager_accounts =
GetAccountsFromAccountManager();
// Only Primary account.
@@ -258,12 +259,21 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
ValueOrEmpty(device_account.FindStringKey("email")));
EXPECT_EQ(GetDeviceAccountInfo().id,
ValueOrEmpty(device_account.FindStringKey("id")));
- EXPECT_EQ(GetDeviceAccountInfo().organization,
- ValueOrEmpty(device_account.FindStringKey("organization")));
+ if (GetDeviceAccountInfo().user_type ==
+ user_manager::UserType::USER_TYPE_CHILD) {
+ std::string organization = GetDeviceAccountInfo().organization;
+ base::ReplaceSubstringsAfterOffset(&organization, 0, " ", "&nbsp;");
+ EXPECT_EQ(organization,
+ ValueOrEmpty(device_account.FindStringKey("organization")));
+ } else {
+ EXPECT_EQ(GetDeviceAccountInfo().organization,
+ ValueOrEmpty(device_account.FindStringKey("organization")));
+ }
}
+// TODO(https://crbug.com/1131819): Re-enable flaky test.
IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
- OnGetAccountsWithSecondaryAccounts) {
+ DISABLED_OnGetAccountsWithSecondaryAccounts) {
UpsertAccount("secondary1@example.com");
UpsertAccount("secondary2@example.com");
const std::vector<AccountManager::Account> account_manager_accounts =
@@ -295,8 +305,16 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
ValueOrEmpty(device_account.FindStringKey("email")));
EXPECT_EQ(GetDeviceAccountInfo().id,
ValueOrEmpty(device_account.FindStringKey("id")));
- EXPECT_EQ(GetDeviceAccountInfo().organization,
- ValueOrEmpty(device_account.FindStringKey("organization")));
+ if (GetDeviceAccountInfo().user_type ==
+ user_manager::UserType::USER_TYPE_CHILD) {
+ std::string organization = GetDeviceAccountInfo().organization;
+ base::ReplaceSubstringsAfterOffset(&organization, 0, " ", "&nbsp;");
+ EXPECT_EQ(organization,
+ ValueOrEmpty(device_account.FindStringKey("organization")));
+ } else {
+ EXPECT_EQ(GetDeviceAccountInfo().organization,
+ ValueOrEmpty(device_account.FindStringKey("organization")));
+ }
// Check secondary accounts.
for (const base::Value& account : result) {
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 c1c3fdedf65..3b263bcc04f 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
@@ -15,9 +15,11 @@
#include "base/callback.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/optional.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h"
@@ -43,6 +45,18 @@ constexpr int kBannerHeightPx = 160;
constexpr char kCelsius[] = "celsius";
constexpr char kFahrenheit[] = "fahrenheit";
+constexpr int kMaxRetries = 3;
+
+constexpr net::BackoffEntry::Policy kRetryBackoffPolicy = {
+ 0, // Number of initial errors to ignore.
+ 500, // Initial delay in ms.
+ 2.0, // Factor by which the waiting time will be multiplied.
+ 0.2, // Fuzzing percentage.
+ 60 * 1000, // Maximum delay in ms.
+ -1, // Never discard the entry.
+ true, // Use initial delay.
+};
+
ash::AmbientModeTemperatureUnit ExtractTemperatureUnit(
const base::ListValue* args) {
auto temperature_unit = args->GetList()[0].GetString();
@@ -108,7 +122,9 @@ base::string16 GetAlbumDescription(const ash::PersonalAlbum& album) {
} // namespace
-AmbientModeHandler::AmbientModeHandler() = default;
+AmbientModeHandler::AmbientModeHandler()
+ : fetch_settings_retry_backoff_(&kRetryBackoffPolicy),
+ update_settings_retry_backoff_(&kRetryBackoffPolicy) {}
AmbientModeHandler::~AmbientModeHandler() = default;
@@ -149,10 +165,7 @@ void AmbientModeHandler::HandleRequestSettings(const base::ListValue* args) {
// since the last time requesting the data. Abort any request in progress to
// avoid unnecessary updating invisible subpage.
ui_update_weak_factory_.InvalidateWeakPtrs();
- RequestSettingsAndAlbums(
- base::BindOnce(&AmbientModeHandler::OnSettingsAndAlbumsFetched,
- ui_update_weak_factory_.GetWeakPtr(),
- /*topic_source=*/base::nullopt));
+ RequestSettingsAndAlbums(/*topic_source=*/base::nullopt);
}
void AmbientModeHandler::HandleRequestAlbums(const base::ListValue* args) {
@@ -165,9 +178,7 @@ void AmbientModeHandler::HandleRequestAlbums(const base::ListValue* args) {
// Photos to Art gallery, since the last time requesting the data.
// Abort any request in progress to avoid updating incorrect contents.
ui_update_weak_factory_.InvalidateWeakPtrs();
- RequestSettingsAndAlbums(base::BindOnce(
- &AmbientModeHandler::OnSettingsAndAlbumsFetched,
- ui_update_weak_factory_.GetWeakPtr(), ExtractTopicSource(args)));
+ RequestSettingsAndAlbums(ExtractTopicSource(args));
}
void AmbientModeHandler::HandleSetSelectedTemperatureUnit(
@@ -222,6 +233,9 @@ void AmbientModeHandler::HandleSetSelectedAlbums(const base::ListValue* args) {
});
const bool checked = it != albums->GetList().end();
art_setting.enabled = checked;
+ // A setting must be visible to be enabled.
+ if (art_setting.enabled)
+ CHECK(art_setting.visible);
}
break;
}
@@ -268,6 +282,8 @@ void AmbientModeHandler::SendAlbums(ash::AmbientModeTopicSource topic_source) {
break;
case ash::AmbientModeTopicSource::kArtGallery:
for (const auto& setting : settings_->art_settings) {
+ if (!setting.visible)
+ continue;
base::Value value(base::Value::Type::DICTIONARY);
value.SetKey("albumId", base::Value(setting.album_id));
value.SetKey("checked", base::Value(setting.enabled));
@@ -298,6 +314,14 @@ void AmbientModeHandler::SendAlbumPreview(
}
void AmbientModeHandler::UpdateSettings() {
+ if (is_updating_backend_) {
+ has_pending_updates_for_backend_ = true;
+ return;
+ }
+
+ has_pending_updates_for_backend_ = false;
+ is_updating_backend_ = true;
+
DCHECK(settings_);
ash::AmbientBackendController::Get()->UpdateSettings(
*settings_, base::BindOnce(&AmbientModeHandler::OnUpdateSettings,
@@ -305,31 +329,58 @@ void AmbientModeHandler::UpdateSettings() {
}
void AmbientModeHandler::OnUpdateSettings(bool success) {
- if (success)
- return;
+ is_updating_backend_ = false;
+
+ if (success) {
+ update_settings_retry_backoff_.Reset();
+ } else {
+ update_settings_retry_backoff_.InformOfRequest(/*succeeded=*/false);
+ if (update_settings_retry_backoff_.failure_count() > kMaxRetries)
+ return;
+ }
- // TODO(b/152921891): Retry a small fixed number of times, then only retry
- // when user confirms in the error message dialog.
+ if (has_pending_updates_for_backend_ || !success) {
+ const base::TimeDelta kDelay =
+ update_settings_retry_backoff_.GetTimeUntilRelease();
+ base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE,
+ base::BindOnce(&AmbientModeHandler::UpdateSettings,
+ backend_weak_factory_.GetWeakPtr()),
+ kDelay);
+ }
}
void AmbientModeHandler::RequestSettingsAndAlbums(
- ash::AmbientBackendController::OnSettingsAndAlbumsFetchedCallback
- callback) {
+ base::Optional<ash::AmbientModeTopicSource> topic_source) {
// TODO(b/161044021): Add a helper function to get all the albums. Currently
// only load 100 latest modified albums.
ash::AmbientBackendController::Get()->FetchSettingsAndAlbums(
- kBannerWidthPx, kBannerHeightPx, /*num_albums=*/100, std::move(callback));
+ kBannerWidthPx, kBannerHeightPx, /*num_albums=*/100,
+ base::BindOnce(&AmbientModeHandler::OnSettingsAndAlbumsFetched,
+ ui_update_weak_factory_.GetWeakPtr(), topic_source));
}
void AmbientModeHandler::OnSettingsAndAlbumsFetched(
base::Optional<ash::AmbientModeTopicSource> topic_source,
const base::Optional<ash::AmbientSettings>& settings,
ash::PersonalAlbums personal_albums) {
- // TODO(b/152921891): Retry a small fixed number of times, then only retry
- // when user confirms in the error message dialog.
- if (!settings)
+ // |settings| value implies success.
+ if (!settings) {
+ fetch_settings_retry_backoff_.InformOfRequest(/*succeeded=*/false);
+ if (fetch_settings_retry_backoff_.failure_count() > kMaxRetries)
+ return;
+
+ const base::TimeDelta kDelay =
+ fetch_settings_retry_backoff_.GetTimeUntilRelease();
+ base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE,
+ base::BindOnce(&AmbientModeHandler::RequestSettingsAndAlbums,
+ ui_update_weak_factory_.GetWeakPtr(), topic_source),
+ kDelay);
return;
+ }
+ fetch_settings_retry_backoff_.Reset();
settings_ = settings;
personal_albums_ = std::move(personal_albums);
SyncSettingsAndAlbums();
@@ -337,6 +388,17 @@ void AmbientModeHandler::OnSettingsAndAlbumsFetched(
if (!topic_source) {
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;
+ 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 78232435062..e42d13764f0 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 "net/base/backoff_entry.h"
namespace ash {
struct AmbientSettings;
@@ -80,13 +81,14 @@ class AmbientModeHandler : public ::settings::SettingsPageUIHandler {
// Called when the settings is updated.
void OnUpdateSettings(bool success);
+ // Will be called from ambientMode/photos subpage and ambientMode subpage.
+ // |topic_source| is used to request the albums in that source and identify
+ // the callers:
+ // 1. |kGooglePhotos|: ambientMode/photos?topicSource=0
+ // 2. |kArtGallery|: ambientMode/photos?topicSource=1
+ // 3. base::nullopt: ambientMode/
void RequestSettingsAndAlbums(
- ash::AmbientBackendController::OnSettingsAndAlbumsFetchedCallback
- callback);
-
- // |topic_source| is what the |settings_| and |personal_albums_| were
- // requested for the ambientMode/photos subpage. It is base::nullopt if they
- // were requested by the ambientMode subpage.
+ base::Optional<ash::AmbientModeTopicSource> topic_source);
void OnSettingsAndAlbumsFetched(
base::Optional<ash::AmbientModeTopicSource> topic_source,
const base::Optional<ash::AmbientSettings>& settings,
@@ -115,6 +117,18 @@ class AmbientModeHandler : public ::settings::SettingsPageUIHandler {
ash::PersonalAlbums personal_albums_;
+ // Backoff retries for RequestSettingsAndAlbums().
+ net::BackoffEntry fetch_settings_retry_backoff_;
+
+ // Whether the Settings updating is ongoing.
+ bool is_updating_backend_ = false;
+
+ // Whether there are pending updates.
+ bool has_pending_updates_for_backend_ = false;
+
+ // Backoff retries for UpdateSettings().
+ net::BackoffEntry update_settings_retry_backoff_;
+
base::WeakPtrFactory<AmbientModeHandler> backend_weak_factory_{this};
base::WeakPtrFactory<AmbientModeHandler> ui_update_weak_factory_{this};
};
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 cf0ea9e11c9..5a44dea2532 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
@@ -61,9 +61,54 @@ class AmbientModeHandlerTest : public testing::Test {
handler_->HandleRequestAlbums(&args);
}
+ void FetchSettings() {
+ handler_->RequestSettingsAndAlbums(/*topic_source=*/base::nullopt);
+ }
+
+ void UpdateSettings() {
+ handler_->settings_ = ash::AmbientSettings();
+ handler_->UpdateSettings();
+ }
+
+ bool IsUpdateSettingsPendingAtHandler() const {
+ return handler_->is_updating_backend_;
+ }
+
+ bool HasPendingUpdatesForTesting() const {
+ return handler_->has_pending_updates_for_backend_;
+ }
+
+ base::TimeDelta GetFetchSettingsDelay() {
+ return handler_->fetch_settings_retry_backoff_.GetTimeUntilRelease();
+ }
+
+ base::TimeDelta GetUpdateSettingsDelay() {
+ return handler_->update_settings_retry_backoff_.GetTimeUntilRelease();
+ }
+
+ void FastForwardBy(base::TimeDelta time) {
+ task_environment_.FastForwardBy(time);
+ }
+
+ bool IsFetchSettingsPendingAtBackend() const {
+ return fake_backend_controller_->IsFetchSettingsAndAlbumsPending();
+ }
+
+ void ReplyFetchSettingsAndAlbums(bool success) {
+ fake_backend_controller_->ReplyFetchSettingsAndAlbums(success);
+ }
+
+ bool IsUpdateSettingsPendingAtBackend() const {
+ return fake_backend_controller_->IsUpdateSettingsPending();
+ }
+
+ void ReplyUpdateSettings(bool success) {
+ fake_backend_controller_->ReplyUpdateSettings(success);
+ }
+
std::string BoolToString(bool x) { return x ? "true" : "false"; }
- void VerifySettingsSent(base::RunLoop* run_loop) {
+ void VerifySettingsSent() {
EXPECT_EQ(2U, web_ui_->call_data().size());
// The call is structured such that the function name is the "web callback"
@@ -89,12 +134,9 @@ class AmbientModeHandlerTest : public testing::Test {
temperature_unit_call_data.arg1()->GetString());
// In FakeAmbientBackendControllerImpl, the |temperature_unit| is kCelsius.
EXPECT_EQ("celsius", temperature_unit_call_data.arg2()->GetString());
-
- run_loop->Quit();
}
- void VerifyAlbumsSent(ash::AmbientModeTopicSource topic_source,
- base::RunLoop* run_loop) {
+ void VerifyAlbumsSent(ash::AmbientModeTopicSource topic_source) {
// Art gallery has an extra call to update the topic source to Art gallery.
std::vector<std::unique_ptr<content::TestWebUI::CallData>>::size_type call_size =
topic_source == ash::AmbientModeTopicSource::kGooglePhotos ? 1U : 2U;
@@ -148,51 +190,244 @@ class AmbientModeHandlerTest : public testing::Test {
EXPECT_EQ(false, album1->FindKey("checked")->GetBool());
EXPECT_EQ("art1", album1->FindKey("title")->GetString());
}
- run_loop->Quit();
}
private:
- base::test::TaskEnvironment task_environment_;
+ base::test::TaskEnvironment task_environment_{
+ base::test::TaskEnvironment::TimeSource::MOCK_TIME};
std::unique_ptr<content::TestWebUI> web_ui_;
- std::unique_ptr<ash::AmbientBackendController> fake_backend_controller_;
+ std::unique_ptr<ash::FakeAmbientBackendControllerImpl>
+ fake_backend_controller_;
std::unique_ptr<ash::TestImageDownloader> image_downloader_;
std::unique_ptr<TestAmbientModeHandler> handler_;
};
TEST_F(AmbientModeHandlerTest, TestSendTemperatureUnitAndTopicSource) {
RequestSettings();
-
- base::RunLoop run_loop;
- base::SequencedTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&AmbientModeHandlerTest::VerifySettingsSent,
- base::Unretained(this), &run_loop));
- run_loop.Run();
+ ReplyFetchSettingsAndAlbums(/*success=*/true);
+ VerifySettingsSent();
}
TEST_F(AmbientModeHandlerTest, TestSendAlbumsForGooglePhotos) {
ash::AmbientModeTopicSource topic_source =
ash::AmbientModeTopicSource::kGooglePhotos;
RequestAlbums(topic_source);
-
- base::RunLoop run_loop;
- base::SequencedTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::BindOnce(&AmbientModeHandlerTest::VerifyAlbumsSent,
- base::Unretained(this), topic_source, &run_loop));
- run_loop.Run();
+ ReplyFetchSettingsAndAlbums(/*success=*/true);
+ VerifyAlbumsSent(topic_source);
}
TEST_F(AmbientModeHandlerTest, TestSendAlbumsForArtGallery) {
ash::AmbientModeTopicSource topic_source =
ash::AmbientModeTopicSource::kArtGallery;
RequestAlbums(topic_source);
+ ReplyFetchSettingsAndAlbums(/*success=*/true);
+ VerifyAlbumsSent(topic_source);
+}
+
+TEST_F(AmbientModeHandlerTest, TestFetchSettings) {
+ FetchSettings();
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+
+ ReplyFetchSettingsAndAlbums(/*success=*/true);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+}
+
+TEST_F(AmbientModeHandlerTest, TestFetchSettingsFailedWillRetry) {
+ FetchSettings();
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+
+ ReplyFetchSettingsAndAlbums(/*success=*/false);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+
+ FastForwardBy(GetFetchSettingsDelay() * 1.5);
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+}
+
+TEST_F(AmbientModeHandlerTest, TestFetchSettingsSecondRetryWillBackoff) {
+ FetchSettings();
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+
+ ReplyFetchSettingsAndAlbums(/*success=*/false);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+
+ base::TimeDelta delay1 = GetFetchSettingsDelay();
+ FastForwardBy(delay1 * 1.5);
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+
+ ReplyFetchSettingsAndAlbums(/*success=*/false);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+
+ base::TimeDelta delay2 = GetFetchSettingsDelay();
+ EXPECT_GT(delay2, delay1);
+
+ FastForwardBy(delay2 * 1.5);
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+}
+
+TEST_F(AmbientModeHandlerTest,
+ TestFetchSettingsWillNotRetryMoreThanThreeTimes) {
+ FetchSettings();
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+
+ ReplyFetchSettingsAndAlbums(/*success=*/false);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+
+ // 1st retry.
+ FastForwardBy(GetFetchSettingsDelay() * 1.5);
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+
+ ReplyFetchSettingsAndAlbums(/*success=*/false);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+
+ // 2nd retry.
+ FastForwardBy(GetFetchSettingsDelay() * 1.5);
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+
+ ReplyFetchSettingsAndAlbums(/*success=*/false);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+
+ // 3rd retry.
+ FastForwardBy(GetFetchSettingsDelay() * 1.5);
+ EXPECT_TRUE(IsFetchSettingsPendingAtBackend());
+
+ ReplyFetchSettingsAndAlbums(/*success=*/false);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+
+ // Will not retry.
+ FastForwardBy(GetFetchSettingsDelay() * 1.5);
+ EXPECT_FALSE(IsFetchSettingsPendingAtBackend());
+}
+
+TEST_F(AmbientModeHandlerTest, TestUpdateSettings) {
+ UpdateSettings();
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/true);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+}
+
+TEST_F(AmbientModeHandlerTest, TestUpdateSettingsTwice) {
+ UpdateSettings();
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ UpdateSettings();
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_TRUE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/true);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_TRUE(HasPendingUpdatesForTesting());
+
+ FastForwardBy(GetUpdateSettingsDelay() * 1.5);
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+}
+
+TEST_F(AmbientModeHandlerTest, TestUpdateSettingsFailedWillRetry) {
+ UpdateSettings();
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/false);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ FastForwardBy(GetUpdateSettingsDelay() * 1.5);
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+}
+
+TEST_F(AmbientModeHandlerTest, TestUpdateSettingsSecondRetryWillBackoff) {
+ UpdateSettings();
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/false);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ base::TimeDelta delay1 = GetUpdateSettingsDelay();
+ FastForwardBy(delay1 * 1.5);
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/false);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ base::TimeDelta delay2 = GetUpdateSettingsDelay();
+ EXPECT_GT(delay2, delay1);
+
+ FastForwardBy(delay2 * 1.5);
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+}
- base::RunLoop run_loop;
- base::SequencedTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::BindOnce(&AmbientModeHandlerTest::VerifyAlbumsSent,
- base::Unretained(this), topic_source, &run_loop));
- run_loop.Run();
+TEST_F(AmbientModeHandlerTest,
+ TestUpdateSettingsWillNotRetryMoreThanThreeTimes) {
+ UpdateSettings();
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/false);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ // 1st retry.
+ FastForwardBy(GetUpdateSettingsDelay() * 1.5);
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/false);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ // 2nd retry.
+ FastForwardBy(GetUpdateSettingsDelay() * 1.5);
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/false);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ // 3rd retry.
+ FastForwardBy(GetUpdateSettingsDelay() * 1.5);
+ EXPECT_TRUE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_TRUE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ ReplyUpdateSettings(/*success=*/false);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
+
+ // Will not retry.
+ FastForwardBy(GetUpdateSettingsDelay() * 1.5);
+ EXPECT_FALSE(IsUpdateSettingsPendingAtBackend());
+ EXPECT_FALSE(IsUpdateSettingsPendingAtHandler());
+ EXPECT_FALSE(HasPendingUpdatesForTesting());
}
} // namespace settings
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 ef09fb75b2e..d864124530c 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.cc
@@ -8,6 +8,7 @@
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
+#include "chrome/browser/chromeos/plugin_vm/plugin_vm_features.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_pref_names.h"
#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
@@ -136,7 +137,7 @@ void AddAppManagementStrings(content::WebUIDataSource* html_source) {
bool ShowPluginVm(const Profile* profile, const PrefService& pref_service) {
// Even if not allowed, we still want to show Plugin VM if the VM image is on
// disk, so that users are still able to delete the image at will.
- return plugin_vm::IsPluginVmAllowedForProfile(profile) ||
+ return plugin_vm::PluginVmFeatures::Get()->IsAllowed(profile) ||
pref_service.GetBoolean(plugin_vm::prefs::kPluginVmImageExists);
}
@@ -237,7 +238,14 @@ std::string AppsSection::GetSectionPath() const {
return mojom::kAppsSectionPath;
}
+bool AppsSection::LogMetric(mojom::Setting setting, base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void AppsSection::RegisterHierarchy(HierarchyGenerator* generator) const {
+ generator->RegisterTopLevelSetting(mojom::Setting::kTurnOnPlayStore);
+
// Manage apps.
generator->RegisterTopLevelSubpage(IDS_SETTINGS_APPS_LINK_TEXT,
mojom::Subpage::kAppManagement,
@@ -256,6 +264,12 @@ void AppsSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::SearchResultIcon::kAppsGrid,
mojom::SearchResultDefaultRank::kMedium,
mojom::kPluginVmSharedPathsSubpagePath);
+ generator->RegisterNestedSubpage(
+ IDS_SETTINGS_APPS_PLUGIN_VM_SHARED_USB_DEVICES_LABEL,
+ mojom::Subpage::kPluginVmUsbPreferences, mojom::Subpage::kAppManagement,
+ mojom::SearchResultIcon::kAppsGrid,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kPluginVmUsbPreferencesSubpagePath);
// Google Play Store.
generator->RegisterTopLevelSubpage(IDS_SETTINGS_ANDROID_APPS_LABEL,
@@ -266,10 +280,11 @@ void AppsSection::RegisterHierarchy(HierarchyGenerator* generator) const {
static constexpr mojom::Setting kGooglePlayStoreSettings[] = {
mojom::Setting::kManageAndroidPreferences,
mojom::Setting::kRemovePlayStore,
- mojom::Setting::kTurnOnPlayStore,
};
RegisterNestedSettingBulk(mojom::Subpage::kGooglePlayStore,
kGooglePlayStoreSettings, generator);
+ generator->RegisterTopLevelAltSetting(
+ mojom::Setting::kManageAndroidPreferences);
}
void AppsSection::OnAppRegistered(const std::string& app_id,
@@ -316,8 +331,26 @@ void AppsSection::AddPluginVmLoadTimeData(
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",
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 d5217f6c693..4b36372c1b9 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/apps_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_APPS_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_APPS_SECTION_H_
+#include "base/values.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"
@@ -37,6 +38,7 @@ class AppsSection : public OsSettingsSection, public ArcAppListPrefs::Observer {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
// ArcAppListPrefs::Observer:
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 2de04401ca6..473c21a2106 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc
@@ -207,6 +207,12 @@ std::string BluetoothSection::GetSectionPath() const {
return mojom::kBluetoothSectionPath;
}
+bool BluetoothSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void BluetoothSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSubpage(IDS_SETTINGS_BLUETOOTH,
mojom::Subpage::kBluetoothDevices,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.h
index e187a244e2b..63a9cede5aa 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.h
@@ -7,6 +7,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "device/bluetooth/bluetooth_adapter.h"
@@ -35,6 +36,7 @@ class BluetoothSection : public OsSettingsSection,
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
// device::BluetoothAdapter::Observer:
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 075ce796d0d..eb87c56df57 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
@@ -78,9 +78,6 @@ ui::SelectFileDialog::FileTypeInfo GetUserImageFileTypeInfo() {
return file_type_info;
}
-// Time histogram suffix for profile image download.
-const char kProfileDownloadReason[] = "Preferences";
-
} // namespace
ChangePictureHandler::ChangePictureHandler()
@@ -278,7 +275,7 @@ void ChangePictureHandler::UpdateProfileImage() {
!user_image_manager->DownloadedProfileImage().isNull()) {
SendProfileImage(user_image_manager->DownloadedProfileImage(), false);
}
- user_image_manager->DownloadProfileImage(kProfileDownloadReason);
+ user_image_manager->DownloadProfileImage();
}
void ChangePictureHandler::SendOldImage(std::string&& image_url) {
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 b66f2ae934b..2d64d886bec 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom
@@ -87,6 +87,7 @@ enum Subpage {
kAppDetails = 701,
kGooglePlayStore = 702,
kPluginVmSharedPaths = 703,
+ kPluginVmUsbPreferences = 704,
// Crostini section.
kCrostiniDetails = 800,
@@ -110,6 +111,7 @@ enum Subpage {
kInputMethodOptions = 1203,
kLanguages = 1204,
kInput = 1205,
+ kEditDictionary = 1206,
// Files section.
kNetworkFileShares = 1300,
@@ -192,6 +194,8 @@ const string kAppDetailsSubpagePath = "app-management/detail";
const string kGooglePlayStoreSubpagePath = "androidAppsDetails";
const string kPluginVmSharedPathsSubpagePath =
"app-management/pluginVm/sharedPaths";
+const string kPluginVmUsbPreferencesSubpagePath =
+ "app-management/pluginVm/sharedUsbDevices";
// Crostini section.
const string kCrostiniSectionPath = "crostini";
@@ -217,6 +221,7 @@ const string kSmartInputsSubpagePath = "osLanguages/smartInputs";
const string kInputMethodOptionsSubpagePath = "osLanguages/inputMethodOptions";
const string kLanguagesSubpagePath = "osLanguages/languages";
const string kInputSubpagePath = "osLanguages/input";
+const string kEditDictionarySubpagePath = "osLanguages/editDictionary";
// Files section.
const string kFilesSectionPath = "files";
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 c3a88225b57..dc365343ccf 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
@@ -98,6 +98,7 @@ bool IsOSSettingsSubPage(const std::string& sub_page) {
chromeos::settings::mojom::kInputMethodOptionsSubpagePath,
chromeos::settings::mojom::kLanguagesSubpagePath,
chromeos::settings::mojom::kInputSubpagePath,
+ chromeos::settings::mojom::kEditDictionarySubpagePath,
// Files section.
chromeos::settings::mojom::kFilesSectionPath,
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 d5186c090d1..f08424390dc 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom
@@ -57,6 +57,7 @@ enum Setting {
kPhoneHubNotificationsOnOff = 210,
kPhoneHubNotificationBadgeOnOff = 211,
kPhoneHubTaskContinuationOnOff = 212,
+ kWifiSyncOnOff = 213,
// People section.
kAddAccount = 300,
@@ -169,7 +170,7 @@ enum Setting {
kShowInputOptionsInShelf = 1201,
kShowPersonalInformationSuggestions = 1202,
kShowEmojiSuggestions = 1203,
- kChangeSystemLanguage = 1204,
+ kChangeDeviceLanguage = 1204,
kOfferTranslation = 1205,
kAddInputMethod = 1206,
kSpellCheck = 1207,
@@ -197,7 +198,7 @@ enum Setting {
kStickyKeys = 1511,
kOnScreenKeyboard = 1512,
kDictation = 1513,
- kSpeakToType = 1514,
+ kHighlightKeyboardFocus = 1514,
kHighlightTextCaret = 1515,
kAutoClickWhenCursorStops = 1516,
kLargeCursor = 1517,
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 72c9b26652d..ba9ac8c2a5a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
@@ -74,9 +74,10 @@ void CrostiniHandler::RegisterMessages() {
base::BindRepeating(&CrostiniHandler::HandleRemoveCrostiniSharedPath,
weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
- "getCrostiniSharedUsbDevices",
- base::BindRepeating(&CrostiniHandler::HandleGetCrostiniSharedUsbDevices,
- weak_ptr_factory_.GetWeakPtr()));
+ "notifyCrostiniSharedUsbDevicesPageReady",
+ base::BindRepeating(
+ &CrostiniHandler::HandleNotifyCrostiniSharedUsbDevicesPageReady,
+ weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
"setCrostiniUsbDeviceShared",
base::BindRepeating(&CrostiniHandler::HandleSetCrostiniUsbDeviceShared,
@@ -288,13 +289,14 @@ namespace {
base::ListValue UsbDevicesToListValue(
const std::vector<CrosUsbDeviceInfo> shared_usbs) {
base::ListValue usb_devices_list;
- for (auto device : shared_usbs) {
+ for (auto& device : shared_usbs) {
base::Value device_info(base::Value::Type::DICTIONARY);
- device_info.SetKey("guid", base::Value(device.guid));
- device_info.SetKey("label", base::Value(device.label));
- const bool shared_in_crostini =
- device.vm_sharing_info[crostini::kCrostiniDefaultVmName].shared;
- device_info.SetKey("shared", base::Value(shared_in_crostini));
+ 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;
@@ -326,22 +328,10 @@ base::Value CrostiniDiskInfoToValue(
}
} // namespace
-void CrostiniHandler::HandleGetCrostiniSharedUsbDevices(
+void CrostiniHandler::HandleNotifyCrostiniSharedUsbDevicesPageReady(
const base::ListValue* args) {
AllowJavascript();
- CHECK_EQ(1U, args->GetList().size());
-
- std::string callback_id = args->GetList()[0].GetString();
-
- chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
- if (!detector) {
- ResolveJavascriptCallback(base::Value(callback_id), base::ListValue());
- return;
- }
-
- ResolveJavascriptCallback(
- base::Value(callback_id),
- UsbDevicesToListValue(detector->GetDevicesSharableWithCrostini()));
+ OnUsbDevicesChanged();
}
void CrostiniHandler::HandleSetCrostiniUsbDeviceShared(
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 5867245850c..3839b2fe3f8 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
@@ -58,8 +58,9 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
const std::string& path,
bool result,
const std::string& failure_reason);
- // Returns a list of available USB devices.
- void HandleGetCrostiniSharedUsbDevices(const base::ListValue* args);
+ // 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.
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 84640a580d8..4e05e15ec74 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.cc
@@ -98,8 +98,8 @@ const std::vector<SearchConcept>& GetCrostiniOptedOutSearchConcepts() {
mojom::kCrostiniSectionPath,
mojom::SearchResultIcon::kPenguin,
mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSection,
- {.section = mojom::Section::kCrostini},
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kSetUpCrostini},
{IDS_OS_SETTINGS_TAG_CROSTINI_SETUP_ALT1, SearchConcept::kAltTagEnd}},
});
return *tags;
@@ -270,6 +270,10 @@ void CrostiniSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
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},
@@ -448,6 +452,12 @@ std::string CrostiniSection::GetSectionPath() const {
return mojom::kCrostiniSectionPath;
}
+bool CrostiniSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void CrostiniSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kSetUpCrostini);
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 e7caf6a65ea..98d353d0d27 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CROSTINI_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CROSTINI_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "components/prefs/pref_change_registrar.h"
@@ -35,6 +36,7 @@ class CrostiniSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
bool IsCrostiniAllowed();
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 95fc2fb126a..cedaa49b182 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
@@ -85,12 +85,12 @@ void OnRemovedPrinter(const Printer::PrinterProtocol& protocol, bool success) {
// Log if the IPP attributes request was succesful.
void RecordIppQueryResult(const PrinterQueryResult& result) {
- bool reachable = (result != PrinterQueryResult::UNREACHABLE);
+ bool reachable = (result != PrinterQueryResult::kUnreachable);
UMA_HISTOGRAM_BOOLEAN("Printing.CUPS.IppDeviceReachable", reachable);
if (reachable) {
// Only record whether the query was successful if we reach the printer.
- bool query_success = (result == PrinterQueryResult::SUCCESS);
+ bool query_success = (result == PrinterQueryResult::kSuccess);
UMA_HISTOGRAM_BOOLEAN("Printing.CUPS.IppAttributesSuccess", query_success);
}
}
@@ -147,10 +147,13 @@ std::unique_ptr<chromeos::Printer> DictToPrinter(
}
std::string printer_queue;
- printer_dict.GetString("printerQueue", &printer_queue);
- // Path must start from '/' character.
- if (!printer_queue.empty() && printer_queue.front() != '/')
- printer_queue = "/" + printer_queue;
+ // The protocol "socket" does not allow path.
+ if (printer_protocol != "socket") {
+ printer_dict.GetString("printerQueue", &printer_queue);
+ // Path must start from '/' character.
+ if (!printer_queue.empty() && printer_queue.front() != '/')
+ printer_queue.insert(0, "/");
+ }
auto printer = std::make_unique<chromeos::Printer>(printer_id);
printer->set_display_name(printer_name);
@@ -480,7 +483,7 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::ListValue* args) {
if (uri.GetLastParsingError().status != Uri::ParserStatus::kNoErrors ||
!IsValidPrinterUri(uri)) {
// Run the failure callback.
- OnAutoconfQueried(callback_id, PrinterQueryResult::UNKNOWN_FAILURE,
+ OnAutoconfQueried(callback_id, PrinterQueryResult::kUnknownFailure,
printing::PrinterStatus(), "", "", "", {}, false);
return;
}
@@ -502,7 +505,7 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
bool ipp_everywhere) {
RecordIppQueryResult(result);
- const bool success = result == PrinterQueryResult::SUCCESS;
+ const bool success = result == PrinterQueryResult::kSuccess;
if (success) {
// If we queried a valid make and model, use it. The mDNS record isn't
// guaranteed to have it. However, don't overwrite it if the printer
@@ -548,9 +551,9 @@ void CupsPrintersHandler::OnAutoconfQueried(
const std::vector<std::string>& document_formats,
bool ipp_everywhere) {
RecordIppQueryResult(result);
- const bool success = result == PrinterQueryResult::SUCCESS;
+ const bool success = result == PrinterQueryResult::kSuccess;
- if (result == PrinterQueryResult::UNREACHABLE) {
+ if (result == PrinterQueryResult::kUnreachable) {
PRINTER_LOG(DEBUG) << "Could not reach printer";
RejectJavascriptCallback(
base::Value(callback_id),
@@ -736,8 +739,14 @@ void CupsPrintersHandler::OnAddedOrEditedPrinterCommon(
const Printer& printer,
PrinterSetupResult result_code,
bool is_automatic) {
- UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterSetupResult", result_code,
- PrinterSetupResult::kMaxValue);
+ if (printer.IsZeroconf()) {
+ UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.ZeroconfPrinterSetupResult",
+ result_code, PrinterSetupResult::kMaxValue);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterSetupResult", result_code,
+ PrinterSetupResult::kMaxValue);
+ }
+
switch (result_code) {
case PrinterSetupResult::kSuccess:
UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterAdded",
@@ -752,47 +761,30 @@ void CupsPrintersHandler::OnAddedOrEditedPrinterCommon(
}
return;
case PrinterSetupResult::kEditSuccess:
- PRINTER_LOG(USER) << "Printer updated";
+ PRINTER_LOG(USER) << ResultCodeToMessage(result_code);
printers_manager_->SavePrinter(printer);
return;
- case PrinterSetupResult::kPpdNotFound:
- PRINTER_LOG(ERROR) << "Could not locate requested PPD";
- break;
+ case PrinterSetupResult::kNativePrintersNotAllowed:
+ case PrinterSetupResult::kBadUri:
+ case PrinterSetupResult::kInvalidPrinterUpdate:
+ case PrinterSetupResult::kPrinterUnreachable:
+ case PrinterSetupResult::kPrinterSentWrongResponse:
+ case PrinterSetupResult::kPrinterIsNotAutoconfigurable:
case PrinterSetupResult::kPpdTooLarge:
- PRINTER_LOG(ERROR) << "PPD is too large";
- break;
- case PrinterSetupResult::kPpdUnretrievable:
- PRINTER_LOG(ERROR) << "Could not retrieve PPD from server";
- break;
case PrinterSetupResult::kInvalidPpd:
- PRINTER_LOG(ERROR) << "Provided PPD is invalid.";
- break;
- case PrinterSetupResult::kPrinterUnreachable:
- PRINTER_LOG(ERROR) << "Could not contact printer for configuration";
- break;
- case PrinterSetupResult::kComponentUnavailable:
- LOG(WARNING) << "Could not install component";
- break;
+ case PrinterSetupResult::kPpdNotFound:
+ case PrinterSetupResult::kPpdUnretrievable:
case PrinterSetupResult::kDbusError:
- case PrinterSetupResult::kFatalError:
- PRINTER_LOG(ERROR) << "Unrecoverable error. Reboot required.";
- break;
- case PrinterSetupResult::kNativePrintersNotAllowed:
- PRINTER_LOG(ERROR)
- << "Unable to add or edit printer due to enterprise policy.";
- break;
- case PrinterSetupResult::kInvalidPrinterUpdate:
- PRINTER_LOG(ERROR)
- << "Requested printer changes would make printer unusable";
- break;
case PrinterSetupResult::kDbusNoReply:
- PRINTER_LOG(ERROR) << "Couldn't talk to debugd over D-Bus.";
- break;
case PrinterSetupResult::kDbusTimeout:
- PRINTER_LOG(ERROR) << "Timed out trying to reach debugd over D-Bus.";
+ case PrinterSetupResult::kIoError:
+ case PrinterSetupResult::kMemoryAllocationError:
+ case PrinterSetupResult::kFatalError:
+ PRINTER_LOG(ERROR) << ResultCodeToMessage(result_code);
break;
+ case PrinterSetupResult::kComponentUnavailable:
case PrinterSetupResult::kMaxValue:
- NOTREACHED() << "This is not an expected value";
+ NOTREACHED() << ResultCodeToMessage(result_code);
break;
}
// Log an event that tells us this printer setup failed, so we can get
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 0c1df37cc1e..11f169b0a82 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
@@ -4,8 +4,8 @@
#include "chrome/browser/ui/webui/settings/chromeos/date_time_handler.h"
+#include "ash/public/cpp/child_accounts/parent_access_controller.h"
#include "ash/public/cpp/login_screen.h"
-#include "ash/public/cpp/login_types.h"
#include "base/bind.h"
#include "base/check_op.h"
#include "base/command_line.h"
@@ -145,17 +145,16 @@ void DateTimeHandler::HandleShowParentAccessForTimeZone(
DCHECK(user_manager::UserManager::Get()->GetActiveUser()->IsChild());
if (!parent_access::ParentAccessService::IsApprovalRequired(
- parent_access::ParentAccessService::SupervisedAction::
- kUpdateTimezone)) {
+ ash::SupervisedAction::kUpdateTimezone)) {
OnParentAccessValidation(true);
return;
}
- ash::LoginScreen::Get()->ShowParentAccessWidget(
+ ash::ParentAccessController::Get()->ShowWidget(
user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(),
base::BindOnce(&DateTimeHandler::OnParentAccessValidation,
weak_ptr_factory_.GetWeakPtr()),
- ash::ParentAccessRequestReason::kChangeTimezone, false /* extra_dimmer */,
+ ash::SupervisedAction::kUpdateTimezone, false /* extra_dimmer */,
base::Time::Now());
}
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 8899d28d0e1..e42ba85d228 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
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/webui/settings/chromeos/date_time_section.h"
-#include "base/feature_list.h"
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -13,7 +12,6 @@
#include "chrome/browser/ui/webui/settings/chromeos/date_time_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/webui_util.h"
-#include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/settings/cros_settings_names.h"
@@ -50,12 +48,12 @@ const std::vector<SearchConcept>& GetDateTimeSearchConcepts() {
const std::vector<SearchConcept>& GetFineGrainedTimeZoneSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_DATE_TIME_ZONE_SUBPAGE,
+ {IDS_OS_SETTINGS_TAG_DATE_TIME_ZONE,
mojom::kTimeZoneSubpagePath,
mojom::SearchResultIcon::kClock,
mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kTimeZone}},
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kChangeTimeZone}},
});
return *tags;
}
@@ -130,9 +128,6 @@ void DateTimeSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
html_source->AddString(
"timeZoneID",
system::TimezoneSettings::GetInstance()->GetCurrentTimezoneID());
- html_source->AddBoolean(
- "timeActionsProtectedForChild",
- base::FeatureList::IsEnabled(features::kParentAccessCodeForTimeChange));
bool is_child = user_manager::UserManager::Get()->GetActiveUser()->IsChild();
html_source->AddBoolean("isChild", is_child);
@@ -158,6 +153,12 @@ std::string DateTimeSection::GetSectionPath() const {
return mojom::kDateAndTimeSectionPath;
}
+bool DateTimeSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void DateTimeSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::k24HourClock);
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.h
index 7eef9df9516..ee60a061e9a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DATE_TIME_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_DATE_TIME_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
namespace content {
@@ -30,6 +31,7 @@ class DateTimeSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
};
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc
index c1c5e949eab..a79fa29780d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_pointer_handler.cc
@@ -44,6 +44,10 @@ void PointerHandler::MouseExists(bool exists) {
FireWebUIListener("has-mouse-changed", base::Value(exists));
}
+void PointerHandler::PointingStickExists(bool exists) {
+ FireWebUIListener("has-pointing-stick-changed", base::Value(exists));
+}
+
void PointerHandler::HandleInitialize(const base::ListValue* args) {
AllowJavascript();
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 25f54393c73..adc1b28c301 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
@@ -35,6 +35,7 @@ class PointerHandler
// PointerDeviceObserver implementation.
void TouchpadExists(bool exists) override;
void MouseExists(bool exists) override;
+ void PointingStickExists(bool exists) override;
// Initializes the page with the current pointer information.
void HandleInitialize(const base::ListValue* args);
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 39e32c01bdc..55b7427dc90 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
@@ -271,7 +271,7 @@ void PowerHandler::HandleSetIdleBehavior(const base::ListValue* args) {
prefs_->SetInteger(screen_off_delay_pref, 0);
prefs_->SetInteger(screen_lock_delay_pref, 0);
break;
- case IdleBehavior::OTHER:
+ default:
NOTREACHED() << "Invalid idle behavior " << value;
}
}
@@ -440,15 +440,24 @@ PowerHandler::IdleBehaviorInfo PowerHandler::GetAllowedIdleBehaviors(
IsIdleManaged(power_source));
}
- // If idle action is managed and set to SHUT_DOWN/STOP_SESSION, only
- // possible idle behaviour is other.
+ // If idle action is managed and set to STOP_SESSION, STOP_SESSION is the only
+ // possibility.
+ if (prefs_->IsManagedPreference(idle_pref) &&
+ (prefs_->GetInteger(idle_pref) ==
+ PowerPolicyController::ACTION_STOP_SESSION)) {
+ current_idle_behavior = IdleBehavior::STOP_SESSION;
+ possible_behaviors.insert(IdleBehavior::STOP_SESSION);
+ return IdleBehaviorInfo(possible_behaviors, current_idle_behavior,
+ IsIdleManaged(power_source));
+ }
+
+ // If idle action is managed and set to SHUT_DOWN, SHUT_DOWN is the only
+ // possibility.
if (prefs_->IsManagedPreference(idle_pref) &&
(prefs_->GetInteger(idle_pref) ==
- PowerPolicyController::ACTION_STOP_SESSION ||
- prefs_->GetInteger(idle_pref) ==
- PowerPolicyController::ACTION_SHUT_DOWN)) {
- current_idle_behavior = IdleBehavior::OTHER;
- possible_behaviors.insert(IdleBehavior::OTHER);
+ PowerPolicyController::ACTION_SHUT_DOWN)) {
+ current_idle_behavior = IdleBehavior::SHUT_DOWN;
+ possible_behaviors.insert(IdleBehavior::SHUT_DOWN);
return IdleBehaviorInfo(possible_behaviors, current_idle_behavior,
IsIdleManaged(power_source));
}
@@ -543,8 +552,10 @@ PowerHandler::IdleBehaviorInfo PowerHandler::GetAllowedIdleBehaviors(
? IdleBehavior::DISPLAY_OFF
: IdleBehavior::DISPLAY_ON);
} else {
- current_idle_behavior = IdleBehavior::OTHER;
- possible_behaviors.insert(IdleBehavior::OTHER);
+ NOTREACHED() << "Idle behavior is set to a enterprise-only value, but "
+ << "the setting is not enterprise managed. Defaulting to "
+ << "DISPLAY_OFF_SLEEP behavior.";
+ current_idle_behavior = IdleBehavior::DISPLAY_OFF_SLEEP;
}
return IdleBehaviorInfo(possible_behaviors, current_idle_behavior,
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 1d125b0295a..71db52e8680 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
@@ -39,7 +39,8 @@ class PowerHandler : public ::settings::SettingsPageUIHandler,
DISPLAY_OFF_SLEEP = 0,
DISPLAY_OFF = 1,
DISPLAY_ON = 2,
- OTHER = 3,
+ SHUT_DOWN = 3,
+ STOP_SESSION = 4,
};
// WebUI message name and dictionary keys. Shared with tests.
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 36aee6213e2..0b21a59f441 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
@@ -269,15 +269,6 @@ IN_PROC_BROWSER_TEST_F(PowerHandlerTest, SendIdleSettingForPrefChanges) {
// Current battery idle behavior should be DISPLAY_ON.
settings.current_battery_behavior = PowerHandler::IdleBehavior::DISPLAY_ON;
EXPECT_EQ(ToString(settings), GetLastSettingsChangedMessage());
-
- // Other idle actions should result in an "other" setting.
- GetPrefs()->Set(ash::prefs::kPowerAcIdleAction,
- base::Value(PowerPolicyController::ACTION_STOP_SESSION));
- // Current AC idle behavior should be OTHER.
- settings.current_ac_behavior = PowerHandler::IdleBehavior::OTHER;
- // Possible AC idle behaviors should include OTHER too.
- settings.possible_ac_behaviors.insert(PowerHandler::IdleBehavior::OTHER);
- EXPECT_EQ(ToString(settings), GetLastSettingsChangedMessage());
}
// Verifies that idle-related prefs when managed by enterpise policy are
@@ -298,15 +289,15 @@ IN_PROC_BROWSER_TEST_F(PowerHandlerTest, SendManagedIdleSettingForPrefChanges) {
EXPECT_EQ(ToString(settings), GetLastSettingsChangedMessage());
// Set Enterpise policy that forces battery idle action to Shutdown. Only
- // possible battery idle option visible to the user then should be OTHER and
- // the default should also be set to same.
+ // possible battery idle option visible to the user then should be SHUT_DOWN
+ // and the default should also be set to same.
SetPolicyForPolicyKey(
&policy_map, policy::key::kIdleActionBattery,
base::Value(chromeos::PowerPolicyController::ACTION_SHUT_DOWN));
behaviors.clear();
- behaviors.insert(PowerHandler::IdleBehavior::OTHER);
+ behaviors.insert(PowerHandler::IdleBehavior::SHUT_DOWN);
settings.possible_battery_behaviors = behaviors;
- settings.current_battery_behavior = PowerHandler::IdleBehavior::OTHER;
+ settings.current_battery_behavior = PowerHandler::IdleBehavior::SHUT_DOWN;
settings.battery_idle_managed = true;
EXPECT_EQ(ToString(settings), GetLastSettingsChangedMessage());
// Erase battery idle action.
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 0cd19dec090..6e180aae09d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.cc
@@ -167,12 +167,6 @@ const std::vector<SearchConcept>& GetTouchpadSearchConcepts() {
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kPointers},
{IDS_OS_SETTINGS_TAG_TOUCHPAD_ALT1, SearchConcept::kAltTagEnd}},
- {IDS_OS_SETTINGS_TAG_TOUCHPAD_SCROLL_ACCELERATION,
- mojom::kPointersSubpagePath,
- mojom::SearchResultIcon::kLaptop,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kTouchpadScrollAcceleration}},
{IDS_OS_SETTINGS_TAG_TOUCHPAD_REVERSE_SCROLLING,
mojom::kPointersSubpagePath,
mojom::SearchResultIcon::kLaptop,
@@ -189,6 +183,19 @@ const std::vector<SearchConcept>& GetTouchpadSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>&
+GetTouchpadScrollAccelerationSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_TOUCHPAD_SCROLL_ACCELERATION,
+ mojom::kPointersSubpagePath,
+ mojom::SearchResultIcon::kLaptop,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kTouchpadScrollAcceleration}},
+ });
+ return *tags;
+}
+
const std::vector<SearchConcept>& GetMouseSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_MOUSE_ACCELERATION,
@@ -486,6 +493,7 @@ void AddDeviceKeyboardStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_KEYBOARD_SHOW_SHORTCUT_VIEWER},
{"keyboardShowLanguageAndInput",
IDS_SETTINGS_KEYBOARD_SHOW_LANGUAGE_AND_INPUT},
+ {"keyboardShowInputSettings", IDS_SETTINGS_KEYBOARD_SHOW_INPUT_SETTINGS},
};
AddLocalizedStringsBulk(html_source, keyboard_strings);
@@ -699,7 +707,8 @@ void AddDevicePowerStrings(content::WebUIDataSource* html_source) {
{"powerIdleDisplayOffSleep", IDS_SETTINGS_POWER_IDLE_DISPLAY_OFF_SLEEP},
{"powerIdleDisplayOff", IDS_SETTINGS_POWER_IDLE_DISPLAY_OFF},
{"powerIdleDisplayOn", IDS_SETTINGS_POWER_IDLE_DISPLAY_ON},
- {"powerIdleOther", IDS_SETTINGS_POWER_IDLE_OTHER},
+ {"powerIdleDisplayShutDown", IDS_SETTINGS_POWER_IDLE_SHUT_DOWN},
+ {"powerIdleDisplayStopSession", IDS_SETTINGS_POWER_IDLE_STOP_SESSION},
{"powerLidSleepLabel", IDS_SETTINGS_POWER_LID_CLOSED_SLEEP_LABEL},
{"powerLidSignOutLabel", IDS_SETTINGS_POWER_LID_CLOSED_SIGN_OUT_LABEL},
{"powerLidShutDownLabel", IDS_SETTINGS_POWER_LID_CLOSED_SHUT_DOWN_LABEL},
@@ -779,13 +788,15 @@ DeviceSection::~DeviceSection() {
void DeviceSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kDeviceStrings[] = {
{"devicePageTitle", IDS_SETTINGS_DEVICE_TITLE},
- {"scrollLabel", IDS_SETTINGS_SCROLL_LABEL},
{"touchPadScrollLabel", IDS_OS_SETTINGS_TOUCHPAD_REVERSE_SCROLL_LABEL},
};
AddLocalizedStringsBulk(html_source, kDeviceStrings);
html_source->AddBoolean("isDemoSession",
chromeos::DemoSession::IsDeviceInDemoMode());
+ html_source->AddBoolean("enableLanguageSettingsV2",
+ base::FeatureList::IsEnabled(
+ ::chromeos::features::kLanguageSettingsUpdate));
AddDevicePointersStrings(html_source);
AddDeviceKeyboardStrings(html_source);
@@ -829,6 +840,12 @@ std::string DeviceSection::GetSectionPath() const {
return mojom::kDeviceSectionPath;
}
+bool DeviceSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void DeviceSection::RegisterHierarchy(HierarchyGenerator* generator) const {
// Pointers.
generator->RegisterTopLevelSubpage(
@@ -927,11 +944,14 @@ void DeviceSection::RegisterHierarchy(HierarchyGenerator* generator) const {
void DeviceSection::TouchpadExists(bool exists) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetTouchpadSearchConcepts());
+ updater.RemoveSearchTags(GetTouchpadScrollAccelerationSearchConcepts());
- if (exists)
+ if (exists) {
updater.AddSearchTags(GetTouchpadSearchConcepts());
- else
- updater.RemoveSearchTags(GetTouchpadSearchConcepts());
+ if (base::FeatureList::IsEnabled(chromeos::features::kAllowScrollSettings))
+ updater.AddSearchTags(GetTouchpadScrollAccelerationSearchConcepts());
+ }
}
void DeviceSection::MouseExists(bool exists) {
@@ -943,6 +963,10 @@ void DeviceSection::MouseExists(bool exists) {
updater.RemoveSearchTags(GetMouseSearchConcepts());
}
+void DeviceSection::PointingStickExists(bool exists) {
+ // TODO(crbug.com/1114828): manage search tags when the UI is implemented.
+}
+
void DeviceSection::OnDeviceListsComplete() {
UpdateStylusSearchTags();
}
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 c3e7070b9dd..47bae70bb51 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_section.h
@@ -11,6 +11,7 @@
#include "ash/public/mojom/cros_display_config.mojom.h"
#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/ui/webui/settings/chromeos/os_settings_section.h"
#include "chromeos/dbus/power/power_manager_client.h"
@@ -50,11 +51,13 @@ class DeviceSection : public OsSettingsSection,
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
// system::PointerDeviceObserver::Observer:
void TouchpadExists(bool exists) override;
void MouseExists(bool exists) override;
+ void PointingStickExists(bool exists) override;
// ui::InputDeviceObserver:
void OnDeviceListsComplete() override;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.cc
index 473287ebec0..3791dd8f0d7 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.cc
@@ -32,6 +32,11 @@ std::string FakeOsSettingsSection::GetSectionPath() const {
return std::string();
}
+bool FakeOsSettingsSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ return false;
+}
+
std::string FakeOsSettingsSection::ModifySearchResultUrl(
mojom::SearchResultType type,
OsSettingsIdentifier id,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.h
index 4a58417228a..36b365f4022 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fake_os_settings_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FAKE_OS_SETTINGS_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FAKE_OS_SETTINGS_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
namespace chromeos {
@@ -33,6 +34,7 @@ class FakeOsSettingsSection : public OsSettingsSection {
// These functions return arbitrary dummy values.
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
// Prepends the section name and "::" to the URL in |concept|. For example, if
// the URL is "networkDetails" and the section is mojom::Section::kNetwork,
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 7163b682b59..f9d8293005f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.cc
@@ -119,6 +119,11 @@ std::string FilesSection::GetSectionPath() const {
return mojom::kFilesSectionPath;
}
+bool FilesSection::LogMetric(mojom::Setting setting, base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void FilesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kGoogleDriveConnection);
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.h
index 38b9dc0b236..453176aea25 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/files_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FILES_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FILES_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
namespace content {
@@ -30,6 +31,7 @@ class FilesSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
};
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 80441110d91..94e348e4ccc 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h"
@@ -87,6 +88,18 @@ const std::vector<SearchConcept>& GetEthernetConnectedSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetEthernetNotConnectedSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_ETHERNET,
+ mojom::kNetworkSectionPath,
+ mojom::SearchResultIcon::kEthernet,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSection,
+ {.section = mojom::Section::kNetwork}},
+ });
+ return *tags;
+}
+
const std::vector<SearchConcept>& GetWifiSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_WIFI,
@@ -661,11 +674,15 @@ void InternetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
- chromeos::network_element::AddLocalizedStrings(html_source);
- chromeos::network_element::AddOncLocalizedStrings(html_source);
- chromeos::network_element::AddDetailsLocalizedStrings(html_source);
- chromeos::network_element::AddConfigLocalizedStrings(html_source);
- chromeos::network_element::AddErrorLocalizedStrings(html_source);
+ 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::AddLocalizedStrings(html_source);
+ }
html_source->AddBoolean("showTechnologyBadge",
!ash::features::IsSeparateNetworkIconsEnabled());
@@ -722,6 +739,12 @@ std::string InternetSection::GetSectionPath() const {
return mojom::kNetworkSectionPath;
}
+bool InternetSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void InternetSection::RegisterHierarchy(HierarchyGenerator* generator) const {
// Ethernet details.
generator->RegisterTopLevelSubpage(IDS_SETTINGS_INTERNET_ETHERNET_DETAILS,
@@ -866,6 +889,10 @@ void InternetSection::OnDeviceList(
updater.RemoveSearchTags(GetInstantTetheringOnSearchConcepts());
updater.RemoveSearchTags(GetInstantTetheringOffSearchConcepts());
+ // Keep track of ethernet devices to handle an edge case where Ethernet device
+ // is present but no network is connected.
+ does_ethernet_device_exist_ = false;
+
for (const auto& device : devices) {
switch (device->type) {
case NetworkType::kWiFi:
@@ -894,6 +921,10 @@ void InternetSection::OnDeviceList(
updater.AddSearchTags(GetInstantTetheringOffSearchConcepts());
break;
+ case NetworkType::kEthernet:
+ does_ethernet_device_exist_ = true;
+ break;
+
default:
// Note: Ethernet and VPN only show search tags when connected, and
// categories such as Mobile/Wireless do not have search tags.
@@ -918,6 +949,7 @@ void InternetSection::OnNetworkList(
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetEthernetConnectedSearchConcepts());
+ updater.RemoveSearchTags(GetEthernetNotConnectedSearchConcepts());
updater.RemoveSearchTags(GetWifiConnectedSearchConcepts());
updater.RemoveSearchTags(GetWifiMeteredSearchConcepts());
updater.RemoveSearchTags(GetCellularSearchConcepts());
@@ -985,6 +1017,12 @@ void InternetSection::OnNetworkList(
break;
}
}
+
+ // Edge case where Ethernet device is present but no network is connected,
+ // i.e. on Chromeboxes. http://crbug.com/1096768
+ if (does_ethernet_device_exist_ && !connected_ethernet_guid_.has_value()) {
+ updater.AddSearchTags(GetEthernetNotConnectedSearchConcepts());
+ }
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h
index cbe35474631..0265c105636 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_section.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/optional.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
#include "mojo/public/cpp/bindings/receiver.h"
@@ -40,6 +41,7 @@ class InternetSection
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
std::string ModifySearchResultUrl(
mojom::SearchResultType type,
@@ -75,6 +77,8 @@ class InternetSection
base::Optional<std::string> connected_tether_guid_;
base::Optional<std::string> connected_vpn_guid_;
+ bool does_ethernet_device_exist_ = false;
+
mojo::Receiver<network_config::mojom::CrosNetworkConfigObserver> receiver_{
this};
mojo::Remote<network_config::mojom::CrosNetworkConfig> cros_network_config_;
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 49c7f9129b0..162e26a16e9 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.cc
@@ -17,6 +17,7 @@
#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"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
@@ -65,12 +66,12 @@ const std::vector<SearchConcept>& GetLanguagesPageSearchConceptsV2() {
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSubpage,
{.subpage = mojom::Subpage::kLanguages}},
- {IDS_OS_SETTINGS_TAG_LANGUAGES_CHANGE_SYSTEM_LANGUAGE,
+ {IDS_OS_SETTINGS_TAG_LANGUAGES_CHANGE_DEVICE_LANGUAGE,
mojom::kLanguagesSubpagePath,
mojom::SearchResultIcon::kGlobe,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kChangeSystemLanguage}},
+ {.setting = mojom::Setting::kChangeDeviceLanguage}},
{IDS_OS_SETTINGS_TAG_LANGUAGES_INPUT_ADD_LANGUAGE,
mojom::kLanguagesSubpagePath,
mojom::SearchResultIcon::kGlobe,
@@ -119,6 +120,18 @@ const std::vector<SearchConcept>& GetInputPageSearchConceptsV2() {
return *tags;
}
+const std::vector<SearchConcept>& GetEditDictionarySearchConceptsV2() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_LANGUAGES_EDIT_DICTIONARY,
+ mojom::kEditDictionarySubpagePath,
+ mojom::SearchResultIcon::kGlobe,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSubpage,
+ {.subpage = mojom::Subpage::kEditDictionary}},
+ });
+ return *tags;
+}
+
bool IsLanguageSettingsV2Enabled() {
return base::FeatureList::IsEnabled(
::chromeos::features::kLanguageSettingsUpdate);
@@ -246,21 +259,31 @@ void AddInputMethodOptionsStrings(content::WebUIDataSource* html_source) {
void AddLanguagesPageStringsV2(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
- {"systemLanguageTitle", IDS_OS_SETTINGS_LANGUAGES_SYSTEM_LANGUAGE_TITLE},
- {"systemLanguageDescription",
- IDS_OS_SETTINGS_LANGUAGES_SYSTEM_LANGUAGE_DESCRIPTION},
- {"changeSystemLanguageLabel",
- IDS_OS_SETTINGS_LANGUAGES_CHANGE_SYSTEM_LANGUAGE_BUTTON_LABEL},
- {"changeSystemLanguageButtonDescription",
- IDS_OS_SETTINGS_LANGUAGES_CHANGE_SYSTEM_LANGUAGE_BUTTON_DESCRIPTION},
+ {"deviceLanguageTitle", IDS_OS_SETTINGS_LANGUAGES_DEVICE_LANGUAGE_TITLE},
+ {"changeDeviceLanguageLabel",
+ IDS_OS_SETTINGS_LANGUAGES_CHANGE_DEVICE_LANGUAGE_BUTTON_LABEL},
+ {"changeDeviceLanguageButtonDescription",
+ IDS_OS_SETTINGS_LANGUAGES_CHANGE_DEVICE_LANGUAGE_BUTTON_DESCRIPTION},
{"languagesPreferenceTitle",
IDS_OS_SETTINGS_LANGUAGES_LANGUAGES_PREFERENCE_TITLE},
{"languagesPreferenceDescription",
IDS_OS_SETTINGS_LANGUAGES_LANGUAGES_PREFERENCE_DESCRIPTION},
+ {"translateTargetLabel",
+ IDS_OS_SETTINGS_LANGUAGES_TRANSLATE_TARGET_LABEL},
+ {"offerToTranslateThisLanguage",
+ IDS_OS_SETTINGS_LANGUAGES_OFFER_TO_TRANSLATE_THIS_LANGUAGE},
{"offerTranslationLabel",
IDS_OS_SETTINGS_LANGUAGES_OFFER_TRANSLATION_LABEL},
{"offerTranslationSublabel",
IDS_OS_SETTINGS_LANGUAGES_OFFER_TRANSLATION_SUBLABEL},
+ {"changeDeviceLanguageDialogTitle",
+ IDS_OS_SETTINGS_LANGUAGES_CHANGE_DEVICE_LANGUAGE_DIALOG_TITLE},
+ {"selectedDeviceLanguageInstruction",
+ IDS_OS_SETTINGS_LANGUAGES_SELECTED_DEVICE_LANGUAGE_INSTRUCTION},
+ {"notSelectedDeviceLanguageInstruction",
+ IDS_OS_SETTINGS_LANGUAGES_NOT_SELECTED_DEVICE_LANGUAGE_INSTRUCTION},
+ {"changeDeviceLanguageConfirmButtonLabel",
+ IDS_OS_SETTINGS_LANGUAGES_CHANGE_DEVICE_LANGUAGE_CONFIRM_BUTTON_LABEL},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
@@ -269,6 +292,11 @@ void AddLanguagesPageStringsV2(content::WebUIDataSource* html_source) {
l10n_util::GetStringFUTF16(
IDS_OS_SETTINGS_LANGUAGES_LANGUAGES_PREFERENCE_DESCRIPTION,
base::ASCIIToUTF16(chrome::kLanguageSettingsLearnMoreUrl)));
+ html_source->AddString(
+ "changeDeviceLanguageDialogDescription",
+ l10n_util::GetStringFUTF16(
+ IDS_OS_SETTINGS_LANGUAGES_CHANGE_DEVICE_LANGUAGE_DIALOG_DESCRIPTION,
+ base::ASCIIToUTF16(chrome::kLanguageSettingsLearnMoreUrl)));
}
void AddInputPageStringsV2(content::WebUIDataSource* html_source) {
@@ -277,9 +305,42 @@ void AddInputPageStringsV2(content::WebUIDataSource* html_source) {
IDS_OS_SETTINGS_LANGUAGES_INPUT_METHOD_LIST_TITLE},
{"openOptionsPage", IDS_OS_SETTINGS_LANGUAGES_OPEN_OPTIONS_PAGE_LABEL},
{"addInputMethodLabel", IDS_OS_SETTINGS_LANGUAGES_ADD_INPUT_METHOD_LABEL},
+ {"removeInputMethodTooltip",
+ IDS_OS_SETTINGS_LANGUAGES_REMOVE_INPUT_METHOD_TOOLTIP},
+ {"suggestedInputMethodsLabel",
+ IDS_OS_SETTINGS_LANGUAGES_SUGGESTED_INPUT_METHODS_LABEL},
+ {"allInputMethodsLabel",
+ IDS_OS_SETTINGS_LANGUAGES_ALL_INPUT_METHODS_LABEL},
+ {"searchInputMethodsLabel",
+ IDS_OS_SETTINGS_LANGUAGES_SEARCH_INPUT_METHODS_LABEL},
+ {"inputMethodNotAllowed",
+ IDS_OS_SETTINGS_LANGUAGES_INPUT_METHOD_NOT_ALLOWED},
{"spellCheckTitle", IDS_OS_SETTINGS_LANGUAGES_SPELL_CHECK_TITLE},
- {"spellCheckDisabledReason",
- IDS_OS_SETTINGS_LANGUAGES_SPELL_CHECK_DISABLED_REASON},
+ {"spellCheckEnhancedLabel",
+ IDS_OS_SETTINGS_LANGUAGES_SPELL_CHECK_ENHANCED_LABEL},
+ {"spellCheckLanguagesListTitle",
+ IDS_OS_SETTINGS_LANGUAGES_SPELL_CHECK_LANGUAGES_LIST_TITLE},
+ {"spellCheckLanguagesListDescription",
+ IDS_OS_SETTINGS_LANGUAGES_SPELL_CHECK_LANGUAGES_LIST_DESCRIPTION},
+ {"languagesDictionaryDownloadError",
+ IDS_OS_SETTINGS_LANGUAGES_DICTIONARY_DOWNLOAD_FAILED},
+ {"languagesDictionaryDownloadRetryLabel",
+ IDS_OS_SETTINGS_LANGUAGES_DICTIONARY_DOWNLOAD_RETRY_LABEL},
+ {"languagesDictionaryDownloadRetryDescription",
+ IDS_OS_SETTINGS_LANGUAGES_DICTIONARY_DOWNLOAD_RETRY_DESCRIPTION},
+ {"editDictionaryLabel", IDS_OS_SETTINGS_LANGUAGES_EDIT_DICTIONARY_LABEL},
+ {"editDictionaryDescription",
+ IDS_OS_SETTINGS_LANGUAGES_EDIT_DICTIONARY_DESCRIPTION},
+ {"addDictionaryWordButtonLabel",
+ IDS_OS_SETTINGS_LANGUAGES_ADD_DICTIONARY_WORD_BUTTON_LABEL},
+ {"addDictionaryWordDuplicateError",
+ IDS_OS_SETTINGS_LANGUAGES_ADD_DICTIONARY_WORD_DUPLICATE_ERROR},
+ {"addDictionaryWordLengthError",
+ IDS_OS_SETTINGS_LANGUAGES_ADD_DICTIONARY_WORD_LENGTH_ERROR},
+ {"deleteDictionaryWordTooltip",
+ IDS_OS_SETTINGS_LANGUAGES_DELETE_DICTIONARY_WORD_TOOLTIP},
+ {"noDictionaryWordsLabel",
+ IDS_OS_SETTINGS_LANGUAGES_NO_DICTIONARY_WORDS_LABEL},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
}
@@ -287,12 +348,21 @@ void AddInputPageStringsV2(content::WebUIDataSource* html_source) {
} // namespace
LanguagesSection::LanguagesSection(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();
if (IsLanguageSettingsV2Enabled()) {
+ pref_change_registrar_.Init(pref_service_);
+ pref_change_registrar_.Add(
+ spellcheck::prefs::kSpellCheckEnable,
+ base::BindRepeating(&LanguagesSection::UpdateSpellCheckSearchTags,
+ base::Unretained(this)));
+
updater.AddSearchTags(GetLanguagesPageSearchConceptsV2());
updater.AddSearchTags(GetInputPageSearchConceptsV2());
+ UpdateSpellCheckSearchTags();
} else {
updater.AddSearchTags(GetLanguagesSearchConceptsV1());
}
@@ -380,11 +450,10 @@ std::string LanguagesSection::GetSectionPath() const {
return mojom::kLanguagesAndInputSectionPath;
}
-bool LanguagesSection::IsEmojiSuggestionAllowed() const {
- return base::FeatureList::IsEnabled(
- ::chromeos::features::kEmojiSuggestAddition) &&
- profile()->GetPrefs()->GetBoolean(
- ::chromeos::prefs::kEmojiSuggestionEnterpriseAllowed);
+bool LanguagesSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
}
void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
@@ -394,7 +463,7 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::Subpage::kLanguages, mojom::SearchResultIcon::kGlobe,
mojom::SearchResultDefaultRank::kMedium, mojom::kLanguagesSubpagePath);
static constexpr mojom::Setting kLanguagesPageSettings[] = {
- mojom::Setting::kChangeSystemLanguage,
+ mojom::Setting::kChangeDeviceLanguage,
mojom::Setting::kOfferTranslation,
};
RegisterNestedSettingBulk(mojom::Subpage::kLanguages, kLanguagesPageSettings,
@@ -412,6 +481,13 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
RegisterNestedSettingBulk(mojom::Subpage::kInput, kInputPageSettings,
generator);
+ // Edit dictionary.
+ generator->RegisterNestedSubpage(
+ IDS_OS_SETTINGS_LANGUAGES_EDIT_DICTIONARY_LABEL,
+ mojom::Subpage::kEditDictionary, mojom::Subpage::kInput,
+ mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium,
+ mojom::kEditDictionarySubpagePath);
+
// Languages and input details.
generator->RegisterTopLevelSubpage(
IDS_OS_SETTINGS_LANGUAGES_AND_INPUT_PAGE_TITLE,
@@ -425,6 +501,14 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::Subpage::kLanguages);
generator->RegisterNestedSetting(mojom::Setting::kShowInputOptionsInShelf,
mojom::Subpage::kInput);
+
+ // Input method options.
+ generator->RegisterNestedSubpage(
+ IDS_SETTINGS_LANGUAGES_INPUT_METHOD_OPTIONS_TITLE,
+ mojom::Subpage::kInputMethodOptions, mojom::Subpage::kInput,
+ mojom::SearchResultIcon::kGlobe,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kInputMethodOptionsSubpagePath);
} else {
static constexpr mojom::Setting kLanguagesAndInputDetailsSettings[] = {
mojom::Setting::kAddLanguage,
@@ -432,6 +516,15 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
};
RegisterNestedSettingBulk(mojom::Subpage::kLanguagesAndInputDetails,
kLanguagesAndInputDetailsSettings, generator);
+
+ // Input method options.
+ generator->RegisterNestedSubpage(
+ IDS_SETTINGS_LANGUAGES_INPUT_METHOD_OPTIONS_TITLE,
+ mojom::Subpage::kInputMethodOptions,
+ mojom::Subpage::kLanguagesAndInputDetails,
+ mojom::SearchResultIcon::kGlobe,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::kInputMethodOptionsSubpagePath);
}
// Manage input methods.
@@ -442,14 +535,6 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium,
mojom::kManageInputMethodsSubpagePath);
- // Input method options.
- generator->RegisterNestedSubpage(
- IDS_SETTINGS_LANGUAGES_INPUT_METHOD_OPTIONS_TITLE,
- mojom::Subpage::kInputMethodOptions,
- mojom::Subpage::kLanguagesAndInputDetails,
- mojom::SearchResultIcon::kGlobe, mojom::SearchResultDefaultRank::kMedium,
- mojom::kInputMethodOptionsSubpagePath);
-
// Smart inputs.
generator->RegisterTopLevelSubpage(
IDS_SETTINGS_SUGGESTIONS_TITLE, mojom::Subpage::kSmartInputs,
@@ -463,5 +548,24 @@ void LanguagesSection::RegisterHierarchy(HierarchyGenerator* generator) const {
kSmartInputsFeaturesSettings, generator);
}
+bool LanguagesSection::IsEmojiSuggestionAllowed() const {
+ return base::FeatureList::IsEnabled(
+ ::chromeos::features::kEmojiSuggestAddition) &&
+ pref_service_->GetBoolean(
+ ::chromeos::prefs::kEmojiSuggestionEnterpriseAllowed);
+}
+
+bool LanguagesSection::IsSpellCheckEnabled() const {
+ return pref_service_->GetBoolean(spellcheck::prefs::kSpellCheckEnable);
+}
+
+void LanguagesSection::UpdateSpellCheckSearchTags() {
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetEditDictionarySearchConceptsV2());
+ if (IsSpellCheckEnabled()) {
+ updater.AddSearchTags(GetEditDictionarySearchConceptsV2());
+ }
+}
+
} // namespace settings
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.h
index 9236455754d..6ca34b6b1ac 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/languages_section.h
@@ -5,7 +5,9 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_LANGUAGES_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_LANGUAGES_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
+#include "components/prefs/pref_change_registrar.h"
namespace content {
class WebUIDataSource;
@@ -21,7 +23,9 @@ class SearchTagRegistry;
// the relevant features are enabled.
class LanguagesSection : public OsSettingsSection {
public:
- LanguagesSection(Profile* profile, SearchTagRegistry* search_tag_registry);
+ LanguagesSection(Profile* profile,
+ SearchTagRegistry* search_tag_registry,
+ PrefService* pref_service);
~LanguagesSection() override;
private:
@@ -32,9 +36,15 @@ class LanguagesSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
bool IsEmojiSuggestionAllowed() const;
+ bool IsSpellCheckEnabled() const;
+ void UpdateSpellCheckSearchTags();
+
+ PrefService* pref_service_;
+ PrefChangeRegistrar pref_change_registrar_;
};
} // namespace settings
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 06116213b78..7563a440d9b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/ui/webui/settings/browser_lifetime_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_features_util.h"
#include "chrome/browser/ui/webui/webui_util.h"
-#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -57,9 +56,8 @@ void AddSearchInSettingsStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_SEARCH_NO_RESULTS_HELP,
base::ASCIIToUTF16(chrome::kOsSettingsSearchHelpURL)));
- html_source->AddBoolean(
- "newOsSettingsSearch",
- base::FeatureList::IsEnabled(::chromeos::features::kNewOsSettingsSearch));
+ // TODO(crbug/1080777): Remove this flag and JS codepaths effected.
+ html_source->AddBoolean("newOsSettingsSearch", true);
}
void AddUpdateRequiredEolStrings(content::WebUIDataSource* html_source) {
@@ -174,12 +172,10 @@ void MainSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
chromeos::features::IsDeepLinkingEnabled());
// Add the System Web App resources for Settings.
- if (web_app::SystemWebAppManager::IsEnabled()) {
- html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192);
- html_source->AddResourcePath("pwa.html", IDR_PWA_HTML);
- web_app::SetManifestRequestFilter(html_source, IDR_OS_SETTINGS_MANIFEST,
- IDS_SETTINGS_SETTINGS);
- }
+ html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192);
+ html_source->AddResourcePath("pwa.html", IDR_PWA_HTML);
+ web_app::SetManifestRequestFilter(html_source, IDR_OS_SETTINGS_MANIFEST,
+ IDS_SETTINGS_SETTINGS);
html_source->AddResourcePath("constants/routes.mojom-lite.js",
IDR_OS_SETTINGS_ROUTES_MOJOM_LITE_JS);
@@ -230,6 +226,11 @@ std::string MainSection::GetSectionPath() const {
return std::string();
}
+bool MainSection::LogMetric(mojom::Setting setting, base::Value& value) const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
void MainSection::RegisterHierarchy(HierarchyGenerator* generator) const {
// MainSection is a container for common resources/functionality shared
// between sections and does not have its own subpages/settings.
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 fab6b9bfdc3..569b4827d51 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/main_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_MAIN_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_MAIN_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
namespace content {
@@ -30,6 +31,7 @@ class MainSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
void AddChromeOSUserStrings(content::WebUIDataSource* html_source);
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 b359de47d5e..d5c689cf699 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
@@ -16,7 +16,6 @@
#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/notification_access_manager.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"
@@ -43,7 +42,9 @@ const char kPageContentDataPhoneHubNotificationBadgeStateKey[] =
"phoneHubNotificationBadgeState";
const char kPageContentDataPhoneHubTaskContinuationStateKey[] =
"phoneHubTaskContinuationState";
+const char kPageContentDataWifiSyncStateKey[] = "wifiSyncState";
const char kPageContentDataSmartLockStateKey[] = "smartLockState";
+const char kIsNotificationAccessGranted[] = "isNotificationAccessGranted";
const char kIsAndroidSmsPairingComplete[] = "isAndroidSmsPairingComplete";
constexpr char kAndroidSmsInfoOriginKey[] = "origin";
@@ -73,7 +74,8 @@ MultideviceHandler::MultideviceHandler(
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) {
+ android_sms_app_manager_observer_(this),
+ notification_access_manager_observer_(this) {
pref_change_registrar_.Init(prefs_);
}
@@ -134,6 +136,9 @@ void MultideviceHandler::OnJavascriptAllowed() {
if (multidevice_setup_client_)
multidevice_setup_observer_.Add(multidevice_setup_client_);
+ if (notification_access_manager_)
+ notification_access_manager_observer_.Add(notification_access_manager_);
+
if (android_sms_pairing_state_tracker_) {
android_sms_pairing_state_tracker_observer_.Add(
android_sms_pairing_state_tracker_);
@@ -160,8 +165,10 @@ void MultideviceHandler::OnJavascriptDisallowed() {
if (multidevice_setup_client_)
multidevice_setup_observer_.Remove(multidevice_setup_client_);
- if (notification_access_manager_)
+ if (notification_access_manager_) {
+ notification_access_manager_observer_.Remove(notification_access_manager_);
notification_access_operation_.reset();
+ }
if (android_sms_pairing_state_tracker_) {
android_sms_pairing_state_tracker_observer_.Remove(
@@ -189,6 +196,10 @@ void MultideviceHandler::OnFeatureStatesChanged(
NotifyAndroidSmsInfoChange();
}
+void MultideviceHandler::OnNotificationAccessChanged() {
+ UpdatePageContent();
+}
+
void MultideviceHandler::OnPairingStateChanged() {
UpdatePageContent();
NotifyAndroidSmsInfoChange();
@@ -385,7 +396,7 @@ void MultideviceHandler::HandleCancelNotificationSetup(
void MultideviceHandler::OnStatusChange(
phonehub::NotificationAccessSetupOperation::Status new_status) {
- FireWebUIListener("notification-access-setup-operation-status-changed",
+ FireWebUIListener("settings.onNotificationAccessSetupStatusChanged",
base::Value(static_cast<int32_t>(new_status)));
if (phonehub::NotificationAccessSetupOperation::IsFinalStatus(new_status))
@@ -447,6 +458,10 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
static_cast<int32_t>(
feature_states
[multidevice_setup::mojom::Feature::kPhoneHubTaskContinuation]));
+ page_content_dictionary->SetInteger(
+ kPageContentDataWifiSyncStateKey,
+ static_cast<int32_t>(
+ feature_states[multidevice_setup::mojom::Feature::kWifiSync]));
if (host_status_with_device.second) {
page_content_dictionary->SetString(kPageContentDataHostDeviceNameKey,
@@ -459,6 +474,12 @@ MultideviceHandler::GeneratePageContentDataDictionary() {
? android_sms_pairing_state_tracker_->IsAndroidSmsPairingComplete()
: false);
+ page_content_dictionary->SetBoolean(
+ kIsNotificationAccessGranted,
+ notification_access_manager_
+ ? notification_access_manager_->HasAccessBeenGranted()
+ : false);
+
return page_content_dictionary;
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
index 56fdd03db7e..e4217ae422f 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
@@ -12,6 +12,7 @@
#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/components/multidevice/remote_device_ref.h"
+#include "chromeos/components/phonehub/notification_access_manager.h"
#include "chromeos/components/phonehub/notification_access_setup_operation.h"
#include "chromeos/services/multidevice_setup/public/cpp/multidevice_setup_client.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom-forward.h"
@@ -37,6 +38,7 @@ class MultideviceHandler
public multidevice_setup::MultiDeviceSetupClient::Observer,
public multidevice_setup::AndroidSmsPairingStateTracker::Observer,
public android_sms::AndroidSmsAppManager::Observer,
+ public phonehub::NotificationAccessManager::Observer,
public phonehub::NotificationAccessSetupOperation::Delegate {
public:
MultideviceHandler(
@@ -69,6 +71,9 @@ class MultideviceHandler
void OnStatusChange(
phonehub::NotificationAccessSetupOperation::Status new_status) override;
+ // phonehub::NotificationAccessManager::Observer:
+ void OnNotificationAccessChanged() override;
+
// multidevice_setup::AndroidSmsPairingStateTracker::Observer:
void OnPairingStateChanged() override;
@@ -141,6 +146,9 @@ class MultideviceHandler
ScopedObserver<android_sms::AndroidSmsAppManager,
android_sms::AndroidSmsAppManager::Observer>
android_sms_app_manager_observer_;
+ ScopedObserver<phonehub::NotificationAccessManager,
+ phonehub::NotificationAccessManager::Observer>
+ notification_access_manager_observer_;
// 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 96a3b826a85..fab823c39ad 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc
@@ -66,6 +66,8 @@ GenerateDefaultFeatureStatesMap() {
{multidevice_setup::mojom::Feature::kPhoneHubNotificationBadge,
multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost},
{multidevice_setup::mojom::Feature::kPhoneHubTaskContinuation,
+ multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost},
+ {multidevice_setup::mojom::Feature::kWifiSync,
multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost}};
}
@@ -133,6 +135,11 @@ void VerifyPageContentDict(
multidevice_setup::mojom::Feature::kPhoneHubTaskContinuation);
EXPECT_EQ(static_cast<int>(it->second), phone_hub_task_continuation_state);
+ int wifi_sync_state;
+ EXPECT_TRUE(page_content_dict->GetInteger("wifiSyncState", &wifi_sync_state));
+ it = feature_states_map.find(multidevice_setup::mojom::Feature::kWifiSync);
+ EXPECT_EQ(static_cast<int>(it->second), wifi_sync_state);
+
std::string host_device_name;
if (expected_host_device) {
EXPECT_TRUE(
@@ -229,7 +236,7 @@ class MultideviceHandlerTest : public testing::Test {
}
void CallAttemptNotificationSetup(bool has_access_been_granted) {
- fake_notification_access_manager()->SetHasAccessBeenGranted(
+ fake_notification_access_manager()->SetHasAccessBeenGrantedInternal(
has_access_been_granted);
base::ListValue empty_args;
test_web_ui()->HandleReceivedMessage("attemptNotificationSetup",
@@ -361,12 +368,18 @@ class MultideviceHandlerTest : public testing::Test {
fake_notification_access_manager()->SetNotificationSetupOperationStatus(
status);
+ bool completed_successfully = status ==
+ phonehub::NotificationAccessSetupOperation::
+ Status::kCompletedSuccessfully;
+ if (completed_successfully)
+ call_data_count_before_call++;
+
EXPECT_EQ(call_data_count_before_call + 1u,
test_web_ui()->call_data().size());
const content::TestWebUI::CallData& call_data =
CallDataAtIndex(call_data_count_before_call);
EXPECT_EQ("cr.webUIListenerCallback", call_data.function_name());
- EXPECT_EQ("notification-access-setup-operation-status-changed",
+ EXPECT_EQ("settings.onNotificationAccessSetupStatusChanged",
call_data.arg1()->GetString());
EXPECT_EQ(call_data.arg2()->GetInt(), static_cast<int32_t>(status));
}
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 ad527c32bea..4aac5a9b60b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/chromeos/android_sms/android_sms_service.h"
#include "chrome/browser/nearby_sharing/common/nearby_share_prefs.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"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
#include "chrome/browser/ui/webui/settings/shared_settings_localized_strings_provider.h"
@@ -36,13 +37,7 @@ namespace {
const std::vector<SearchConcept>& GetMultiDeviceOptedInSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags(
- {{IDS_OS_SETTINGS_TAG_MULTIDEVICE_SMART_LOCK_OPTIONS,
- mojom::kSmartLockSubpagePath,
- mojom::SearchResultIcon::kLock,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kSmartLock}},
- {IDS_OS_SETTINGS_TAG_MULTIDEVICE_FORGET,
+ {{IDS_OS_SETTINGS_TAG_MULTIDEVICE_FORGET,
mojom::kMultiDeviceFeaturesSubpagePath,
mojom::SearchResultIcon::kPhone,
mojom::SearchResultDefaultRank::kMedium,
@@ -66,11 +61,22 @@ const std::vector<SearchConcept>& GetMultiDeviceOptedInSearchConcepts() {
{.subpage = mojom::Subpage::kMultiDeviceFeatures},
{IDS_OS_SETTINGS_TAG_MULTIDEVICE_ALT1, SearchConcept::kAltTagEnd}},
{IDS_OS_SETTINGS_TAG_MULTIDEVICE_SMART_LOCK,
- mojom::kMultiDeviceFeaturesSubpagePath,
+ mojom::kSmartLockSubpagePath,
mojom::SearchResultIcon::kLock,
mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kSmartLock}}});
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kSmartLockOnOff}}});
+ return *tags;
+}
+
+const std::vector<SearchConcept>& GetSmartLockOptionsSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags(
+ {{IDS_OS_SETTINGS_TAG_MULTIDEVICE_SMART_LOCK_OPTIONS,
+ mojom::kSmartLockSubpagePath,
+ mojom::SearchResultIcon::kLock,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kSmartLockUnlockOrSignIn}}});
return *tags;
}
@@ -104,6 +110,18 @@ GetMultiDeviceOptedInPhoneHubSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>&
+GetMultiDeviceOptedInWifiSyncSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags(
+ {{IDS_OS_SETTINGS_TAG_MULTIDEVICE_WIFI_SYNC,
+ mojom::kMultiDeviceFeaturesSubpagePath,
+ mojom::SearchResultIcon::kWifi,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kWifiSyncOnOff}}});
+ return *tags;
+}
+
const std::vector<SearchConcept>& GetMultiDeviceOptedOutSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags([] {
// Special-case: The "set up" search tag also includes the names of the
@@ -121,23 +139,31 @@ const std::vector<SearchConcept>& GetMultiDeviceOptedOutSearchConcepts() {
IDS_OS_SETTINGS_TAG_MULTIDEVICE_SMART_LOCK, SearchConcept::kAltTagEnd},
};
- bool is_phone_hub_enabled = features::IsPhoneHubEnabled();
- bool is_instant_tether_enabled =
- base::FeatureList::IsEnabled(features::kInstantTethering);
-
- // If Phone Hub and/or Instant Tethering is available, also include them in
- // the list.
- if (is_phone_hub_enabled) {
- set_up_concept.alt_tag_ids[3] = IDS_OS_SETTINGS_TAG_MULTIDEVICE_PHONE_HUB;
-
- if (is_instant_tether_enabled) {
- set_up_concept.alt_tag_ids[4] = IDS_OS_SETTINGS_TAG_INSTANT_TETHERING;
- } else {
- set_up_concept.alt_tag_ids[4] = SearchConcept::kAltTagEnd;
- }
- } else if (is_instant_tether_enabled) {
- set_up_concept.alt_tag_ids[3] = IDS_OS_SETTINGS_TAG_INSTANT_TETHERING;
- set_up_concept.alt_tag_ids[4] = SearchConcept::kAltTagEnd;
+ // Include the following features in alternate message IDs if they are
+ // enabled and the alt tag limit has not been reached: Phone Hub, Instant
+ // Tethering and Wifi Sync.
+ int alt_tag_index = 3;
+
+ if (features::IsPhoneHubEnabled()) {
+ set_up_concept.alt_tag_ids[alt_tag_index] =
+ IDS_OS_SETTINGS_TAG_MULTIDEVICE_PHONE_HUB;
+ alt_tag_index++;
+ }
+ if (base::FeatureList::IsEnabled(features::kInstantTethering)) {
+ set_up_concept.alt_tag_ids[alt_tag_index] =
+ IDS_OS_SETTINGS_TAG_INSTANT_TETHERING;
+ alt_tag_index++;
+ }
+
+ // TODO(cvandermerwe): Update 5 alt tag limit to 6 and remove condition
+ if (alt_tag_index < 5 && features::IsWifiSyncAndroidEnabled()) {
+ set_up_concept.alt_tag_ids[alt_tag_index] =
+ IDS_OS_SETTINGS_TAG_MULTIDEVICE_WIFI_SYNC;
+ alt_tag_index++;
+ }
+
+ if (alt_tag_index < 5) {
+ set_up_concept.alt_tag_ids[alt_tag_index] = SearchConcept::kAltTagEnd;
}
return std::vector<SearchConcept>{set_up_concept};
@@ -226,6 +252,7 @@ MultiDeviceSection::MultiDeviceSection(
multidevice_setup_client_->AddObserver(this);
OnHostStatusChanged(multidevice_setup_client_->GetHostStatus());
+ OnFeatureStatesChanged(multidevice_setup_client_->GetFeatureStates());
}
MultiDeviceSection::~MultiDeviceSection() {
@@ -252,6 +279,22 @@ void MultiDeviceSection::AddLoadTimeData(
IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_NOTIFICATION_BADGE_SECTION_TITLE},
{"multidevicePhoneHubTaskContinuationItemTitle",
IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_TASK_CONTINUATION_SECTION_TITLE},
+ {"multidevicePhoneHubNotificationBadgeItemSummary",
+ IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_NOTIFICATION_BADGE_SUMMARY},
+ {"multidevicePhoneHubTaskContinuationItemSummary",
+ IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_TASK_CONTINUATION_SUMMARY},
+ {"multideviceWifiSyncItemTitle",
+ IDS_SETTINGS_MULTIDEVICE_WIFI_SYNC_SECTION_TITLE},
+ {"multideviceNotificationAccessSetupAckTitle",
+ IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_ACK_TITLE},
+ {"multideviceNotificationAccessSetupConnectingTitle",
+ IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_CONNECTING_TITLE},
+ {"multideviceNotificationAccessSetupInstructions",
+ IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_INSTRUCTIONS},
+ {"multideviceNotificationAccessSetupCompletedTitle",
+ IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_COMPLETED_TITLE},
+ {"multideviceNotificationAccessSetupCompletedSummary",
+ IDS_SETTINGS_MULTIDEVICE_NOTIFICATION_ACCESS_SETUP_DIALOG_COMPLETED_SUMMARY},
{"multideviceInstantTetheringItemTitle",
IDS_SETTINGS_MULTIDEVICE_INSTANT_TETHERING},
{"multideviceInstantTetheringItemSummary",
@@ -317,9 +360,28 @@ void MultiDeviceSection::AddLoadTimeData(
IDS_SETTINGS_MULTIDEVICE_SMART_LOCK_SUMMARY,
ui::GetChromeOSDeviceName(),
GetHelpUrlWithBoard(chrome::kEasyUnlockLearnMoreUrl)));
+ html_source->AddString(
+ "multidevicePhoneHubItemSummary",
+ l10n_util::GetStringFUTF16(IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_SUMMARY,
+ ui::GetChromeOSDeviceName()));
+ html_source->AddString(
+ "multidevicePhoneHubNotificationsItemSummary",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_MULTIDEVICE_PHONE_HUB_NOTIFICATIONS_SUMMARY,
+ ui::GetChromeOSDeviceName()));
+ html_source->AddString(
+ "multideviceWifiSyncItemSummary",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_MULTIDEVICE_WIFI_SYNC_SUMMARY,
+ // TODO(cvandermerwe) Replace with WifiSyncLearnMoreUrl once created
+ base::UTF8ToUTF16(
+ multidevice_setup::
+ GetBoardSpecificBetterTogetherSuiteLearnMoreUrl()
+ .spec())));
AddEasyUnlockStrings(html_source);
::settings::AddNearbyShareData(html_source);
+ RegisterNearbySharedStrings(html_source);
}
void MultiDeviceSection::AddHandlers(content::WebUI* web_ui) {
@@ -330,8 +392,9 @@ void MultiDeviceSection::AddHandlers(content::WebUI* web_ui) {
web_ui->AddMessageHandler(
std::make_unique<chromeos::settings::MultideviceHandler>(
pref_service_, multidevice_setup_client_,
- phone_hub_manager_ ? phone_hub_manager_->notification_access_manager()
- : nullptr,
+ phone_hub_manager_
+ ? phone_hub_manager_->GetNotificationAccessManager()
+ : nullptr,
android_sms_service_
? android_sms_service_->android_sms_pairing_state_tracker()
: nullptr,
@@ -355,6 +418,12 @@ std::string MultiDeviceSection::GetSectionPath() const {
return mojom::kMultiDeviceSectionPath;
}
+bool MultiDeviceSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void MultiDeviceSection::RegisterHierarchy(
HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kSetUpMultiDevice);
@@ -374,6 +443,7 @@ void MultiDeviceSection::RegisterHierarchy(
mojom::Setting::kPhoneHubNotificationsOnOff,
mojom::Setting::kPhoneHubNotificationBadgeOnOff,
mojom::Setting::kPhoneHubTaskContinuationOnOff,
+ mojom::Setting::kWifiSyncOnOff,
};
RegisterNestedSettingBulk(mojom::Subpage::kMultiDeviceFeatures,
kMultiDeviceFeaturesSettings, generator);
@@ -416,17 +486,32 @@ void MultiDeviceSection::OnHostStatusChanged(
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());
}
}
+void MultiDeviceSection::OnFeatureStatesChanged(
+ const multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap&
+ feature_states_map) {
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetSmartLockOptionsSearchConcepts());
+
+ if (feature_states_map.at(multidevice_setup::mojom::Feature::kSmartLock) ==
+ multidevice_setup::mojom::FeatureState::kEnabledByUser) {
+ updater.AddSearchTags(GetSmartLockOptionsSearchConcepts());
+ }
+}
+
void MultiDeviceSection::OnNearbySharingEnabledChanged() {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
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 866c5ca6673..f420b8a9c22 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_MULTIDEVICE_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_MULTIDEVICE_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "chromeos/services/multidevice_setup/public/cpp/multidevice_setup_client.h"
#include "components/prefs/pref_change_registrar.h"
@@ -53,12 +54,16 @@ class MultiDeviceSection
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
// multidevice_setup::MultiDeviceSetupClient::Observer:
void OnHostStatusChanged(
const multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice&
host_status_with_device) override;
+ void OnFeatureStatesChanged(
+ const multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap&
+ feature_states_map) override;
// Nearby Share enabled pref change observer.
void OnNearbySharingEnabledChanged();
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 2543930d326..47b8ccfb6cc 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
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_sections.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_tag_registry.h"
+#include "chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h"
#include "chromeos/components/local_search_service/local_search_service.h"
#include "chromeos/constants/chromeos_features.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -44,13 +45,14 @@ OsSettingsManager::OsSettingsManager(
identity_manager,
android_sms_service,
printers_manager)),
- hierarchy_(std::make_unique<Hierarchy>(sections_.get())) {
- if (base::FeatureList::IsEnabled(features::kNewOsSettingsSearch)) {
- search_handler_ = std::make_unique<SearchHandler>(
- search_tag_registry_.get(), sections_.get(), hierarchy_.get(),
- local_search_service);
- }
-}
+ settings_user_action_tracker_(
+ std::make_unique<SettingsUserActionTracker>()),
+ hierarchy_(std::make_unique<Hierarchy>(sections_.get())),
+ search_handler_(
+ std::make_unique<SearchHandler>(search_tag_registry_.get(),
+ sections_.get(),
+ hierarchy_.get(),
+ local_search_service)) {}
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 11d5bfc50cb..d54a01a3615 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
@@ -54,6 +54,7 @@ class Hierarchy;
class OsSettingsSections;
class SearchHandler;
class SearchTagRegistry;
+class SettingsUserActionTracker;
// Manager for the Chrome OS settings page. This class is implemented as a
// KeyedService, so one instance of the class is intended to be active for the
@@ -107,9 +108,12 @@ class OsSettingsManager : public KeyedService {
// Adds SettingsPageUIHandlers to an OS settings instance.
void AddHandlers(content::WebUI* web_ui);
- // Note: Returns null when the kNewOsSettingsSearch flag is disabled.
SearchHandler* search_handler() { return search_handler_.get(); }
+ SettingsUserActionTracker* settings_user_action_tracker() {
+ return settings_user_action_tracker_.get();
+ }
+
const Hierarchy* hierarchy() const { return hierarchy_.get(); }
private:
@@ -120,6 +124,7 @@ class OsSettingsManager : public KeyedService {
std::unique_ptr<SearchTagRegistry> search_tag_registry_;
std::unique_ptr<OsSettingsSections> sections_;
+ std::unique_ptr<SettingsUserActionTracker> settings_user_action_tracker_;
std::unique_ptr<Hierarchy> hierarchy_;
std::unique_ptr<SearchHandler> search_handler_;
};
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h
index d2a4dc4dde7..996969b8837 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_section.h
@@ -10,6 +10,7 @@
#include "base/containers/span.h"
#include "base/strings/string16.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/setting.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search.mojom.h"
@@ -118,6 +119,10 @@ class OsSettingsSection {
// Provides the path for this section.
virtual std::string GetSectionPath() const = 0;
+ // Logs metrics for the updated |setting| with optional |value|. Returns
+ // whether the setting change was logged.
+ virtual bool LogMetric(mojom::Setting setting, base::Value& value) const = 0;
+
// Registers the subpages and/or settings which reside in this section.
virtual void RegisterHierarchy(HierarchyGenerator* generator) const = 0;
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 744325a9a6f..0f2b11ba254 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
@@ -103,8 +103,8 @@ OsSettingsSections::OsSettingsSections(
sections_map_[mojom::Section::kPrivacyAndSecurity] = privacy_section.get();
sections_.push_back(std::move(privacy_section));
- auto language_section =
- std::make_unique<LanguagesSection>(profile, search_tag_registry);
+ auto language_section = std::make_unique<LanguagesSection>(
+ profile, search_tag_registry, profile->GetPrefs());
sections_map_[mojom::Section::kLanguagesAndInput] = language_section.get();
sections_.push_back(std::move(language_section));
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 e625820a30d..bbf12d9222e 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
@@ -8,6 +8,8 @@
#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"
+#include "chrome/browser/nearby_sharing/nearby_receive_manager.h"
#include "chrome/browser/nearby_sharing/nearby_share_settings.h"
#include "chrome/browser/nearby_sharing/nearby_sharing_service_factory.h"
#include "chrome/browser/nearby_sharing/nearby_sharing_service_impl.h"
@@ -18,12 +20,13 @@
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_manager_factory.h"
#include "chrome/browser/ui/webui/settings/chromeos/pref_names.h"
#include "chrome/browser/ui/webui/settings/chromeos/search/search_handler.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.h"
+#include "chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/os_settings_resources.h"
#include "chrome/grit/os_settings_resources_map.h"
#include "chromeos/constants/chromeos_features.h"
+#include "chromeos/services/cellular_setup/cellular_setup_impl.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -86,6 +89,10 @@ OSSettingsUI::OSSettingsUI(content::WebUI* web_ui)
IDR_OS_SETTINGS_LAZY_LOAD_VULCANIZED_HTML);
html_source->SetDefaultResource(IDR_OS_SETTINGS_VULCANIZED_HTML);
}
+
+ // We only need to register the mojo resources here because the rest are
+ // bundled in.
+ RegisterNearbySharedMojoResources(html_source);
#else
webui::SetupWebUIDataSource(
html_source,
@@ -94,13 +101,15 @@ OSSettingsUI::OSSettingsUI(content::WebUI* web_ui)
base::FeatureList::IsEnabled(chromeos::features::kOsSettingsPolymer3)
? IDR_OS_SETTINGS_OS_SETTINGS_V3_HTML
: IDR_OS_SETTINGS_SETTINGS_HTML);
-#endif
// Register chrome://nearby resources so they are available at
// chrome://os-settings. This allows the sharing of resources without having
// to put everything in chrome://resources. This is necessary because portions
// of the nearby UI need to be re-used in both places.
+ // This is not nessary when OPTIMIZE_WEBUI is true because the files will be
+ // added to the optimized bundles.
RegisterNearbySharedResources(html_source);
+#endif
ManagedUIHandler::Initialize(web_ui, html_source);
@@ -118,21 +127,25 @@ OSSettingsUI::~OSSettingsUI() {
}
void OSSettingsUI::BindInterface(
+ mojo::PendingReceiver<cellular_setup::mojom::CellularSetup> receiver) {
+ cellular_setup::CellularSetupImpl::CreateAndBindToReciever(
+ std::move(receiver));
+}
+
+void OSSettingsUI::BindInterface(
mojo::PendingReceiver<network_config::mojom::CrosNetworkConfig> receiver) {
ash::GetNetworkConfigService(std::move(receiver));
}
void OSSettingsUI::BindInterface(
mojo::PendingReceiver<mojom::UserActionRecorder> receiver) {
- user_action_recorder_ =
- std::make_unique<SettingsUserActionTracker>(std::move(receiver));
+ OsSettingsManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))
+ ->settings_user_action_tracker()
+ ->BindInterface(std::move(receiver));
}
void OSSettingsUI::BindInterface(
mojo::PendingReceiver<mojom::SearchHandler> receiver) {
- if (!base::FeatureList::IsEnabled(::chromeos::features::kNewOsSettingsSearch))
- return;
-
OsSettingsManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))
->search_handler()
->BindInterface(std::move(receiver));
@@ -156,6 +169,23 @@ void OSSettingsUI::BindInterface(
service->GetSettings()->Bind(std::move(receiver));
}
+void OSSettingsUI::BindInterface(
+ mojo::PendingReceiver<nearby_share::mojom::ReceiveManager> receiver) {
+ NearbySharingService* service =
+ NearbySharingServiceFactory::GetForBrowserContext(
+ Profile::FromWebUI(web_ui()));
+ mojo::MakeSelfOwnedReceiver(std::make_unique<NearbyReceiveManager>(service),
+ std::move(receiver));
+}
+
+void OSSettingsUI::BindInterface(
+ mojo::PendingReceiver<nearby_share::mojom::ContactManager> receiver) {
+ NearbySharingService* service =
+ NearbySharingServiceFactory::GetForBrowserContext(
+ Profile::FromWebUI(web_ui()));
+ service->GetContactManager()->Bind(std::move(receiver));
+}
+
WEB_UI_CONTROLLER_TYPE_IMPL(OSSettingsUI)
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h
index cd8e8062190..fe123adb567 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
@@ -10,12 +10,15 @@
#include "base/macros.h"
#include "base/time/time.h"
#include "chrome/browser/ui/webui/app_management/app_management.mojom-forward.h"
+#include "chrome/browser/ui/webui/nearby_share/nearby_share.mojom.h"
#include "chrome/browser/ui/webui/nearby_share/public/mojom/nearby_share_settings.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/app_management/app_management_page_handler_factory.h"
#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/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"
#include "ui/webui/mojo_web_ui_controller.h"
namespace user_prefs {
@@ -37,6 +40,11 @@ class OSSettingsUI : public ui::MojoWebUIController {
explicit OSSettingsUI(content::WebUI* web_ui);
~OSSettingsUI() override;
+ // Instantiates implementor of the mojom::CellularSetup mojo interface
+ // passing the pending receiver that will be internally bound.
+ void BindInterface(
+ mojo::PendingReceiver<cellular_setup::mojom::CellularSetup> receiver);
+
// Instantiates implementor of the mojom::CrosNetworkConfig mojo interface
// passing the pending receiver that will be internally bound.
void BindInterface(
@@ -61,6 +69,15 @@ class OSSettingsUI : public ui::MojoWebUIController {
void BindInterface(
mojo::PendingReceiver<nearby_share::mojom::NearbyShareSettings> receiver);
+ // Creates and binds a new receive manager.
+ void BindInterface(
+ mojo::PendingReceiver<nearby_share::mojom::ReceiveManager> receiver);
+
+ // Binds to the existing contacts manager instance owned by the nearby share
+ // keyed service.
+ void BindInterface(
+ mojo::PendingReceiver<nearby_share::mojom::ContactManager> receiver);
+
private:
base::TimeTicks time_when_opened_;
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 e40dd48d4ca..f2f4bd2918a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.cc
@@ -15,6 +15,7 @@
#include "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/profiles/profile.h"
#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/ui/ui_features.h"
@@ -44,6 +45,7 @@
#include "components/prefs/pref_service.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h"
+#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -113,12 +115,6 @@ const std::vector<SearchConcept>& GetPeopleSearchConcepts() {
{.setting = mojom::Setting::kLockScreen},
{IDS_OS_SETTINGS_TAG_LOCK_SCREEN_WHEN_WAKING_ALT1,
SearchConcept::kAltTagEnd}},
- {IDS_OS_SETTINGS_TAG_PEOPLE_ACCOUNTS_REMOVE,
- mojom::kMyAccountsSubpagePath,
- mojom::SearchResultIcon::kAvatar,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kRemoveAccount}},
{IDS_OS_SETTINGS_TAG_RESTRICT_SIGN_IN,
mojom::kManageOtherPeopleSubpagePath,
mojom::SearchResultIcon::kAvatar,
@@ -142,6 +138,18 @@ const std::vector<SearchConcept>& GetPeopleSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetRemoveAccountSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_PEOPLE_ACCOUNTS_REMOVE,
+ mojom::kMyAccountsSubpagePath,
+ mojom::SearchResultIcon::kAvatar,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kRemoveAccount}},
+ });
+ return *tags;
+}
+
const std::vector<SearchConcept>& GetNonSplitSyncSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_SYNC_AND_GOOGLE_SERVICES,
@@ -256,12 +264,6 @@ const std::vector<SearchConcept>& GetKerberosSearchConcepts() {
const std::vector<SearchConcept>& GetFingerprintSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
- {IDS_OS_SETTINGS_TAG_FINGERPRINT_REMOVE,
- mojom::kFingerprintSubpagePath,
- mojom::SearchResultIcon::kFingerprint,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kRemoveFingerprint}},
{IDS_OS_SETTINGS_TAG_FINGERPRINT_ADD,
mojom::kFingerprintSubpagePath,
mojom::SearchResultIcon::kFingerprint,
@@ -278,6 +280,18 @@ const std::vector<SearchConcept>& GetFingerprintSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetRemoveFingerprintSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_FINGERPRINT_REMOVE,
+ mojom::kFingerprintSubpagePath,
+ mojom::SearchResultIcon::kFingerprint,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kRemoveFingerprint}},
+ });
+ return *tags;
+}
+
const std::vector<SearchConcept>& GetParentalSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_PARENTAL_CONTROLS,
@@ -602,9 +616,6 @@ void AddSyncControlsStrings(content::WebUIDataSource* html_source) {
chromeos::features::IsSplitSettingsSyncEnabled());
html_source->AddBoolean("useBrowserSyncConsent",
chromeos::features::ShouldUseBrowserSyncConsent());
- html_source->AddBoolean(
- "syncSetupFriendlySettings",
- base::FeatureList::IsEnabled(::features::kSyncSetupFriendlySettings));
html_source->AddString(
"browserSettingsSyncSetupUrl",
base::StrCat({chrome::kChromeUISettingsURL, chrome::kSyncSetupSubPage}));
@@ -672,6 +683,20 @@ void AddParentalControlStrings(content::WebUIDataSource* html_source,
tooltip);
}
+bool IsSameAccount(const AccountManager::AccountKey& account_key,
+ const AccountId& account_id) {
+ switch (account_key.account_type) {
+ case account_manager::AccountType::ACCOUNT_TYPE_GAIA:
+ return account_id.GetAccountType() == AccountType::GOOGLE &&
+ account_id.GetGaiaId() == account_key.id;
+ case account_manager::AccountType::ACCOUNT_TYPE_ACTIVE_DIRECTORY:
+ return account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY &&
+ account_id.GetObjGuid() == account_key.id;
+ case account_manager::AccountType::ACCOUNT_TYPE_UNSPECIFIED:
+ return false;
+ }
+}
+
} // namespace
PeopleSection::PeopleSection(
@@ -695,6 +720,19 @@ PeopleSection::PeopleSection(
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.AddSearchTags(GetPeopleSearchConcepts());
+ // TODO(jamescook): Sort out how account management is split between Chrome
+ // OS and browser settings.
+ if (IsAccountManagerAvailable(profile)) {
+ // Some Account Manager search tags are added/removed dynamically.
+ AccountManagerFactory* factory =
+ g_browser_process->platform_part()->GetAccountManagerFactory();
+ account_manager_ = factory->GetAccountManager(profile->GetPath().value());
+ DCHECK(account_manager_);
+
+ account_manager_->AddObserver(this);
+ FetchAccounts();
+ }
+
if (kerberos_credentials_manager_) {
// Kerberos search tags are added/removed dynamically.
kerberos_credentials_manager_->AddObserver(this);
@@ -718,10 +756,18 @@ PeopleSection::PeopleSection(
if (features::ShouldShowParentalControlSettings(profile))
updater.AddSearchTags(GetParentalSearchConcepts());
- // Fingerprint search tags are added if necessary and do not update
- // dynamically during a user session.
- if (AreFingerprintSettingsAllowed())
+ // Fingerprint search tags are added if necessary. Remove fingerprint search
+ // tags update dynamically during a user session.
+ if (AreFingerprintSettingsAllowed()) {
updater.AddSearchTags(GetFingerprintSearchConcepts());
+
+ fingerprint_pref_change_registrar_.Init(pref_service_);
+ fingerprint_pref_change_registrar_.Add(
+ ::prefs::kQuickUnlockFingerprintRecord,
+ base::BindRepeating(&PeopleSection::UpdateRemoveFingerprintSearchTags,
+ base::Unretained(this)));
+ UpdateRemoveFingerprintSearchTags();
+ }
}
PeopleSection::~PeopleSection() {
@@ -730,6 +776,9 @@ PeopleSection::~PeopleSection() {
if (chromeos::features::IsSplitSettingsSyncEnabled() && sync_service_)
sync_service_->RemoveObserver(this);
+
+ if (account_manager_)
+ account_manager_->RemoveObserver(this);
}
void PeopleSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
@@ -754,7 +803,7 @@ void PeopleSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
// Toggles the Chrome OS Account Manager submenu in the People section.
html_source->AddBoolean("isAccountManagerEnabled",
- chromeos::IsAccountManagerAvailable(profile()));
+ account_manager_ != nullptr);
if (chromeos::features::ShouldUseBrowserSyncConsent()) {
static constexpr webui::LocalizedString kTurnOffStrings[] = {
@@ -822,18 +871,10 @@ void PeopleSection::AddHandlers(content::WebUI* web_ui) {
IDS_OS_SETTINGS_PROFILE_LABEL);
web_ui->AddMessageHandler(std::move(plural_string_handler));
- // TODO(jamescook): Sort out how account management is split between Chrome OS
- // and browser settings.
- if (chromeos::IsAccountManagerAvailable(profile())) {
- chromeos::AccountManagerFactory* factory =
- g_browser_process->platform_part()->GetAccountManagerFactory();
- chromeos::AccountManager* account_manager =
- factory->GetAccountManager(profile()->GetPath().value());
- DCHECK(account_manager);
-
+ if (account_manager_) {
web_ui->AddMessageHandler(
std::make_unique<chromeos::settings::AccountManagerUIHandler>(
- account_manager, identity_manager_));
+ account_manager_, identity_manager_));
}
if (chromeos::features::IsSplitSettingsSyncEnabled())
@@ -877,6 +918,12 @@ std::string PeopleSection::GetSectionPath() const {
return mojom::kPeopleSectionPath;
}
+bool PeopleSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void PeopleSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kSetUpParentalControls);
@@ -976,6 +1023,41 @@ void PeopleSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator);
}
+void PeopleSection::FetchAccounts() {
+ account_manager_->GetAccounts(
+ base::BindOnce(&PeopleSection::UpdateAccountManagerSearchTags,
+ weak_factory_.GetWeakPtr()));
+}
+
+void PeopleSection::OnTokenUpserted(const AccountManager::Account& account) {
+ FetchAccounts();
+}
+
+void PeopleSection::OnAccountRemoved(const AccountManager::Account& account) {
+ FetchAccounts();
+}
+
+void PeopleSection::UpdateAccountManagerSearchTags(
+ const std::vector<AccountManager::Account>& accounts) {
+ DCHECK(IsAccountManagerAvailable(profile()));
+
+ // Start with no Account Manager search tags.
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetRemoveAccountSearchConcepts());
+
+ user_manager::User* user = ProfileHelper::Get()->GetUserByProfile(profile());
+ DCHECK(user);
+
+ for (const AccountManager::Account& account : accounts) {
+ if (IsSameAccount(account.key, user->GetAccountId()))
+ continue;
+
+ // If a non-device account exists, add the "Remove Account" search tag.
+ updater.AddSearchTags(GetRemoveAccountSearchConcepts());
+ return;
+ }
+}
+
void PeopleSection::OnStateChanged(syncer::SyncService* sync_service) {
DCHECK(chromeos::features::IsSplitSettingsSyncEnabled());
DCHECK_EQ(sync_service, sync_service_);
@@ -1053,5 +1135,18 @@ bool PeopleSection::AreFingerprintSettingsAllowed() {
return chromeos::quick_unlock::IsFingerprintEnabled(profile());
}
+void PeopleSection::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
} // namespace chromeos
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 51e8a4b3ea8..de59d7600f8 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/people_section.h
@@ -5,8 +5,12 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PEOPLE_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PEOPLE_SECTION_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/prefs/pref_change_registrar.h"
#include "components/sync/driver/sync_service_observer.h"
class PrefService;
@@ -38,6 +42,7 @@ class SearchTagRegistry;
// they are allowed by policy/flags. Different sets of Sync tags are shown
// depending on whether the feature is enabed or disabled.
class PeopleSection : public OsSettingsSection,
+ public AccountManager::Observer,
public syncer::SyncServiceObserver,
public KerberosCredentialsManager::Observer {
public:
@@ -58,8 +63,13 @@ class PeopleSection : public OsSettingsSection,
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
+ // AccountManager::Observer:
+ void OnTokenUpserted(const AccountManager::Account& account) override;
+ void OnAccountRemoved(const AccountManager::Account& account) override;
+
// syncer::SyncServiceObserver:
void OnStateChanged(syncer::SyncService* sync_service) override;
@@ -69,12 +79,19 @@ class PeopleSection : public OsSettingsSection,
void AddKerberosAccountsPageStrings(
content::WebUIDataSource* html_source) const;
bool AreFingerprintSettingsAllowed();
+ void FetchAccounts();
+ void UpdateAccountManagerSearchTags(
+ const std::vector<AccountManager::Account>& accounts);
+ void UpdateRemoveFingerprintSearchTags();
+ AccountManager* account_manager_ = nullptr;
syncer::SyncService* sync_service_;
SupervisedUserService* supervised_user_service_;
KerberosCredentialsManager* kerberos_credentials_manager_;
signin::IdentityManager* identity_manager_;
PrefService* pref_service_;
+ PrefChangeRegistrar fingerprint_pref_change_registrar_;
+ base::WeakPtrFactory<PeopleSection> weak_factory_{this};
};
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc
index 36b5635a8de..7b9f1684af7 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.cc
@@ -53,8 +53,8 @@ const std::vector<SearchConcept>& GetPersonalizationSearchConcepts() {
mojom::kChangePictureSubpagePath,
mojom::SearchResultIcon::kAvatar,
mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSubpage,
- {.subpage = mojom::Subpage::kChangePicture},
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kChangeDeviceAccountImage},
{IDS_OS_SETTINGS_TAG_CHANGE_DEVICE_ACCOUNT_IMAGE_ALT1,
IDS_OS_SETTINGS_TAG_CHANGE_DEVICE_ACCOUNT_IMAGE_ALT2,
IDS_OS_SETTINGS_TAG_CHANGE_DEVICE_ACCOUNT_IMAGE_ALT3,
@@ -274,6 +274,12 @@ std::string PersonalizationSection::GetSectionPath() const {
return mojom::kPersonalizationSectionPath;
}
+bool PersonalizationSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void PersonalizationSection::RegisterHierarchy(
HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kOpenWallpaper);
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h
index f704a53d971..31e52ce5770 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/personalization_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PERSONALIZATION_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PERSONALIZATION_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
#include "components/prefs/pref_change_registrar.h"
@@ -37,6 +38,7 @@ class PersonalizationSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
// ash::AmbientModeService::Observer:
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 38bf2e61ebc..f4c10eac514 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
@@ -12,10 +12,32 @@
#include "base/bind_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/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) {}
@@ -33,6 +55,15 @@ void PluginVmHandler::RegisterMessages() {
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(
"wouldPermissionChangeRequireRelaunch",
base::BindRepeating(
&PluginVmHandler::HandleWouldPermissionChangeRequireRelaunch,
@@ -47,6 +78,16 @@ 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::HandleGetPluginVmSharedPathsDisplayText(
const base::ListValue* args) {
AllowJavascript();
@@ -63,22 +104,63 @@ void PluginVmHandler::HandleGetPluginVmSharedPathsDisplayText(
void PluginVmHandler::HandleRemovePluginVmSharedPath(
const base::ListValue* args) {
- CHECK_EQ(2U, args->GetSize());
- std::string vm_name = args->GetList()[0].GetString();
- std::string path = args->GetList()[1].GetString();
+ 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(
- [](const std::string& path, bool result,
- const std::string& failure_reason) {
- if (!result) {
- LOG(ERROR) << "Error unsharing " << path << ": "
- << failure_reason;
- }
- },
- path));
+ 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::HandleWouldPermissionChangeRequireRelaunch(
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 e1d77e24424..32f60e6af4b 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,8 +8,10 @@
#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;
@@ -17,23 +19,32 @@ class Profile;
namespace chromeos {
namespace settings {
-class PluginVmHandler : public ::settings::SettingsPageUIHandler {
+class PluginVmHandler : public ::settings::SettingsPageUIHandler,
+ public chromeos::CrosUsbDeviceObserver {
public:
explicit PluginVmHandler(Profile* profile);
~PluginVmHandler() override;
// SettingsPageUIHandler
void RegisterMessages() override;
- void OnJavascriptAllowed() override {}
- void OnJavascriptDisallowed() 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 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 HandleWouldPermissionChangeRequireRelaunch(const base::ListValue* args);
@@ -42,8 +53,17 @@ class PluginVmHandler : public ::settings::SettingsPageUIHandler {
// Relaunches Plugin VM.
void HandleRelaunchPluginVm(const base::ListValue* args);
- Profile* profile_;
+ 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 168efe1d2d6..864d73ad923 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.cc
@@ -13,6 +13,7 @@
#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"
#include "ui/base/webui/web_ui_util.h"
@@ -29,12 +30,6 @@ const std::vector<SearchConcept>& GetPrintingSearchConcepts() {
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kAddPrinter}},
- {IDS_OS_SETTINGS_TAG_PRINTING_SAVED_PRINTERS,
- mojom::kPrintingDetailsSubpagePath,
- mojom::SearchResultIcon::kPrinter,
- mojom::SearchResultDefaultRank::kMedium,
- mojom::SearchResultType::kSetting,
- {.setting = mojom::Setting::kSavedPrinters}},
{IDS_OS_SETTINGS_TAG_PRINTING,
mojom::kPrintingDetailsSubpagePath,
mojom::SearchResultIcon::kPrinter,
@@ -47,6 +42,18 @@ const std::vector<SearchConcept>& GetPrintingSearchConcepts() {
return *tags;
}
+const std::vector<SearchConcept>& GetSavedPrintersSearchConcepts() {
+ static const base::NoDestructor<std::vector<SearchConcept>> tags({
+ {IDS_OS_SETTINGS_TAG_PRINTING_SAVED_PRINTERS,
+ mojom::kPrintingDetailsSubpagePath,
+ mojom::SearchResultIcon::kPrinter,
+ mojom::SearchResultDefaultRank::kMedium,
+ mojom::SearchResultType::kSetting,
+ {.setting = mojom::Setting::kSavedPrinters}},
+ });
+ return *tags;
+}
+
const std::vector<SearchConcept>& GetPrintingManagementSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_PRINT_MANAGEMENT,
@@ -77,9 +84,19 @@ PrintingSection::PrintingSection(Profile* profile,
updater.AddSearchTags(GetPrintingSearchConcepts());
if (IsPrintManagementEnabled())
updater.AddSearchTags(GetPrintingManagementSearchConcepts());
+
+ // Saved Printers search tags are added/removed dynamically.
+ if (printers_manager_) {
+ printers_manager_->AddObserver(this);
+ UpdateSavedPrintersSearchTags();
+ }
}
-PrintingSection::~PrintingSection() = default;
+PrintingSection::~PrintingSection() {
+ if (printers_manager_) {
+ printers_manager_->RemoveObserver(this);
+ }
+}
void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
@@ -233,9 +250,6 @@ void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
html_source->AddString(
"printingCUPSPrintPpdLearnMoreUrl",
GetHelpUrlWithBoard(chrome::kCupsPrintPPDLearnMoreURL));
- html_source->AddBoolean(
- "consumerPrintServerUiEnabled",
- base::FeatureList::IsEnabled(::features::kPrintServerUi));
html_source->AddBoolean("printManagementEnabled", IsPrintManagementEnabled());
}
@@ -260,6 +274,12 @@ std::string PrintingSection::GetSectionPath() const {
return mojom::kPrintingSectionPath;
}
+bool PrintingSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void PrintingSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kPrintJobs);
@@ -277,5 +297,22 @@ void PrintingSection::RegisterHierarchy(HierarchyGenerator* generator) const {
kPrintingDetailsSettings, generator);
}
+void PrintingSection::OnPrintersChanged(PrinterClass printer_class,
+ const std::vector<Printer>& printers) {
+ UpdateSavedPrintersSearchTags();
+}
+
+void PrintingSection::UpdateSavedPrintersSearchTags() {
+ // Start with no saved printers search tags.
+ SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
+ updater.RemoveSearchTags(GetSavedPrintersSearchConcepts());
+
+ std::vector<Printer> saved_printers =
+ printers_manager_->GetPrinters(PrinterClass::kSaved);
+ if (!saved_printers.empty()) {
+ updater.AddSearchTags(GetSavedPrintersSearchConcepts());
+ }
+}
+
} // namespace settings
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.h
index ddef65c546e..fc35a2763d0 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/printing_section.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRINTING_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRINTING_SECTION_H_
+#include "base/values.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
namespace content {
@@ -20,7 +22,8 @@ namespace settings {
class SearchTagRegistry;
// Provides UI strings and search tags for Printing settings.
-class PrintingSection : public OsSettingsSection {
+class PrintingSection : public OsSettingsSection,
+ public CupsPrintersManager::Observer {
public:
PrintingSection(Profile* profile,
SearchTagRegistry* search_tag_registry,
@@ -35,8 +38,15 @@ class PrintingSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
+ // CupsPrintersManager::Observer
+ void OnPrintersChanged(PrinterClass printer_class,
+ const std::vector<Printer>& printers) override;
+
+ void UpdateSavedPrintersSearchTags();
+
CupsPrintersManager* printers_manager_;
};
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 c895cfb5e51..7a740f11a57 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.cc
@@ -115,6 +115,12 @@ std::string PrivacySection::GetSectionPath() const {
return mojom::kPrivacyAndSecuritySectionPath;
}
+bool PrivacySection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void PrivacySection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kVerifiedAccess);
generator->RegisterTopLevelSetting(
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 4acbc9d465c..30478612203 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/privacy_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRIVACY_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_PRIVACY_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
namespace content {
@@ -30,6 +31,7 @@ class PrivacySection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
};
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 1d2a250448f..620983f30e4 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.cc
@@ -107,6 +107,11 @@ std::string ResetSection::GetSectionPath() const {
return mojom::kResetSectionPath;
}
+bool ResetSection::LogMetric(mojom::Setting setting, base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void ResetSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kPowerwash);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.h b/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.h
index 90287737e66..7f6ae4be5cb 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/reset_section.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_RESET_SECTION_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_RESET_SECTION_H_
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
namespace content {
@@ -32,6 +33,7 @@ class ResetSection : public OsSettingsSection {
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
};
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.cc
index 49b774039a7..c0717cf01e8 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.h"
+#include "chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h"
#include "base/metrics/histogram_functions.h"
@@ -35,18 +35,13 @@ void LogDurationMetric(const char* metric_name, base::TimeDelta duration) {
} // namespace
-SettingsUserActionTracker::SettingsUserActionTracker(
- mojo::PendingReceiver<mojom::UserActionRecorder> pending_receiver)
- : SettingsUserActionTracker() {
- receiver_.Bind(std::move(pending_receiver));
-}
-
-SettingsUserActionTracker::SettingsUserActionTracker()
+PerSessionSettingsUserActionTracker::PerSessionSettingsUserActionTracker()
: metric_start_time_(base::TimeTicks::Now()) {}
-SettingsUserActionTracker::~SettingsUserActionTracker() = default;
+PerSessionSettingsUserActionTracker::~PerSessionSettingsUserActionTracker() =
+ default;
-void SettingsUserActionTracker::RecordPageFocus() {
+void PerSessionSettingsUserActionTracker::RecordPageFocus() {
if (last_blur_timestamp_.is_null())
return;
@@ -65,23 +60,23 @@ void SettingsUserActionTracker::RecordPageFocus() {
}
}
-void SettingsUserActionTracker::RecordPageBlur() {
+void PerSessionSettingsUserActionTracker::RecordPageBlur() {
last_blur_timestamp_ = base::TimeTicks::Now();
}
-void SettingsUserActionTracker::RecordClick() {
+void PerSessionSettingsUserActionTracker::RecordClick() {
++num_clicks_since_start_time_;
}
-void SettingsUserActionTracker::RecordNavigation() {
+void PerSessionSettingsUserActionTracker::RecordNavigation() {
++num_navigations_since_start_time_;
}
-void SettingsUserActionTracker::RecordSearch() {
+void PerSessionSettingsUserActionTracker::RecordSearch() {
++num_searches_since_start_time_;
}
-void SettingsUserActionTracker::RecordSettingChange() {
+void PerSessionSettingsUserActionTracker::RecordSettingChange() {
base::TimeTicks now = base::TimeTicks::Now();
if (!last_record_setting_changed_timestamp_.is_null()) {
@@ -120,7 +115,7 @@ void SettingsUserActionTracker::RecordSettingChange() {
last_record_setting_changed_timestamp_ = now;
}
-void SettingsUserActionTracker::ResetMetricsCountersAndTimestamp() {
+void PerSessionSettingsUserActionTracker::ResetMetricsCountersAndTimestamp() {
metric_start_time_ = base::TimeTicks::Now();
num_clicks_since_start_time_ = 0u;
num_navigations_since_start_time_ = 0u;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.h b/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h
index f355bcd524e..da5c370691a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SETTINGS_USER_ACTION_TRACKER_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SETTINGS_USER_ACTION_TRACKER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
#include "base/time/time.h"
-#include "chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
@@ -17,28 +16,24 @@ namespace settings {
// This class is only meant to track actions from an individual settings
// session; if the settings window is closed and reopened again, a new instance
// should be created for that new session.
-class SettingsUserActionTracker : public mojom::UserActionRecorder {
+class PerSessionSettingsUserActionTracker {
public:
- explicit SettingsUserActionTracker(
- mojo::PendingReceiver<mojom::UserActionRecorder> pending_receiver);
- SettingsUserActionTracker(const SettingsUserActionTracker& other) = delete;
- SettingsUserActionTracker& operator=(const SettingsUserActionTracker& other) =
- delete;
- ~SettingsUserActionTracker() override;
+ PerSessionSettingsUserActionTracker();
+ PerSessionSettingsUserActionTracker(
+ const PerSessionSettingsUserActionTracker& other) = delete;
+ PerSessionSettingsUserActionTracker& operator=(
+ const PerSessionSettingsUserActionTracker& other) = delete;
+ ~PerSessionSettingsUserActionTracker();
- // mojom::UserActionRecorder:
- void RecordPageFocus() override;
- void RecordPageBlur() override;
- void RecordClick() override;
- void RecordNavigation() override;
- void RecordSearch() override;
- void RecordSettingChange() override;
+ void RecordPageFocus();
+ void RecordPageBlur();
+ void RecordClick();
+ void RecordNavigation();
+ void RecordSearch();
+ void RecordSettingChange();
private:
- friend class SettingsUserActionTrackerTest;
-
- // For unit tests.
- SettingsUserActionTracker();
+ friend class PerSessionSettingsUserActionTrackerTest;
void ResetMetricsCountersAndTimestamp();
@@ -64,11 +59,9 @@ class SettingsUserActionTracker : public mojom::UserActionRecorder {
// The last time at which a page blur event was received; if no blur events
// have been received, this field is_null().
base::TimeTicks last_blur_timestamp_;
-
- mojo::Receiver<mojom::UserActionRecorder> receiver_{this};
};
} // namespace settings
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SETTINGS_USER_ACTION_TRACKER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_PER_SESSION_SETTINGS_USER_ACTION_TRACKER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker_unittest.cc
index 74a0c9cb0b2..88e13c072e5 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/chromeos/search/settings_user_action_tracker.h"
+#include "chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
@@ -12,18 +12,18 @@
namespace chromeos {
namespace settings {
-class SettingsUserActionTrackerTest : public testing::Test {
+class PerSessionSettingsUserActionTrackerTest : public testing::Test {
protected:
- SettingsUserActionTrackerTest() = default;
- ~SettingsUserActionTrackerTest() override = default;
+ PerSessionSettingsUserActionTrackerTest() = default;
+ ~PerSessionSettingsUserActionTrackerTest() override = default;
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::TimeSource::MOCK_TIME};
base::HistogramTester histogram_tester_;
- SettingsUserActionTracker tracker_;
+ PerSessionSettingsUserActionTracker tracker_;
};
-TEST_F(SettingsUserActionTrackerTest, TestRecordMetrics) {
+TEST_F(PerSessionSettingsUserActionTrackerTest, TestRecordMetrics) {
// Focus the page, perform some tasks, and change a setting.
tracker_.RecordPageFocus();
tracker_.RecordClick();
@@ -117,7 +117,7 @@ TEST_F(SettingsUserActionTrackerTest, TestRecordMetrics) {
/*count=*/2);
}
-TEST_F(SettingsUserActionTrackerTest, TestBlurAndFocus) {
+TEST_F(PerSessionSettingsUserActionTrackerTest, TestBlurAndFocus) {
// Focus the page, click, and change a setting.
tracker_.RecordPageFocus();
tracker_.RecordClick();
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 fb6284e9d9f..1dac5a48067 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
@@ -153,7 +153,7 @@ void SearchHandler::AddParentResults(
// Nested subpage.
if (metadata.parent_subpage) {
- it = AddSubpageResultIfPossible(it, *metadata.parent_subpage,
+ it = AddSubpageResultIfPossible(it, result, *metadata.parent_subpage,
result->relevance_score,
search_results);
break;
@@ -171,7 +171,7 @@ void SearchHandler::AddParentResults(
// Nested setting.
if (metadata.primary.second) {
- it = AddSubpageResultIfPossible(it, *metadata.primary.second,
+ it = AddSubpageResultIfPossible(it, result, *metadata.primary.second,
result->relevance_score,
search_results);
break;
@@ -213,6 +213,7 @@ SearchHandler::AddSectionResultIfPossible(
std::vector<mojom::SearchResultPtr>::iterator
SearchHandler::AddSubpageResultIfPossible(
const std::vector<mojom::SearchResultPtr>::iterator& curr_position,
+ const mojom::SearchResultPtr& child_result,
mojom::Subpage subpage,
double relevance_score,
std::vector<mojom::SearchResultPtr>* results) const {
@@ -220,6 +221,15 @@ SearchHandler::AddSubpageResultIfPossible(
if (ContainsSubpageResult(*results, subpage))
return curr_position;
+ mojom::SearchResultPtr subpage_result =
+ hierarchy_->GetSubpageMetadata(subpage).ToSearchResult(
+ child_result->relevance_score);
+
+ // Don't add a result for a parent subpage if it has the exact same text as
+ // the child result, since this results in a broken-looking UI.
+ if (subpage_result->result_text == child_result->result_text)
+ return curr_position;
+
return results->insert(
curr_position + 1,
hierarchy_->GetSubpageMetadata(subpage).ToSearchResult(relevance_score));
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 90ef05dca83..4f219a5f50b 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
@@ -90,6 +90,7 @@ class SearchHandler : public mojom::SearchHandler,
std::vector<mojom::SearchResultPtr>::iterator AddSubpageResultIfPossible(
const std::vector<mojom::SearchResultPtr>::iterator& position,
+ const mojom::SearchResultPtr& child_result,
mojom::Subpage subpage,
double relevance_score,
std::vector<mojom::SearchResultPtr>* results) const;
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 52c6502053e..ae75a5a3929 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
@@ -6,7 +6,6 @@
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "chrome/browser/ui/webui/settings/chromeos/constants/routes.mojom.h"
#include "chrome/browser/ui/webui/settings/chromeos/fake_hierarchy.h"
@@ -101,8 +100,6 @@ class SearchHandlerTest : public testing::Test {
// testing::Test:
void SetUp() override {
- scoped_feature_list_.InitAndEnableFeature(
- chromeos::features::kNewOsSettingsSearch);
handler_.BindInterface(handler_remote_.BindNewPipeAndPassReceiver());
fake_hierarchy_.AddSubpageMetadata(
@@ -132,7 +129,6 @@ class SearchHandlerTest : public testing::Test {
}
base::test::TaskEnvironment task_environment_;
- base::test::ScopedFeatureList scoped_feature_list_;
local_search_service::LocalSearchService local_search_service_;
SearchTagRegistry search_tag_registry_;
FakeOsSettingsSections fake_sections_;
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 1591a342b6d..035f76f9bc2 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
@@ -121,9 +121,6 @@ SearchTagRegistry::ScopedTagUpdater SearchTagRegistry::StartUpdate() {
void SearchTagRegistry::AddSearchTags(
const std::vector<const SearchConcept*>& search_tags) {
- if (!base::FeatureList::IsEnabled(features::kNewOsSettingsSearch))
- return;
-
index_->AddOrUpdate(ConceptVectorToDataVector(search_tags));
// Add each concept to the map. Note that it is safe to take the address of
@@ -137,9 +134,6 @@ void SearchTagRegistry::AddSearchTags(
void SearchTagRegistry::RemoveSearchTags(
const std::vector<const SearchConcept*>& search_tags) {
- if (!base::FeatureList::IsEnabled(features::kNewOsSettingsSearch))
- return;
-
std::vector<std::string> data_ids;
for (const auto* concept : search_tags) {
std::string result_id = ToResultId(*concept);
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 6f8763df333..d01b1cd1c30 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.cc
@@ -235,10 +235,6 @@ void SearchSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
is_assistant_allowed
? IDS_SETTINGS_SEARCH_AND_ASSISTANT
: IDS_SETTINGS_SEARCH);
- html_source->AddString("searchExplanation",
- l10n_util::GetStringFUTF16(
- IDS_SETTINGS_SEARCH_EXPLANATION,
- base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL)));
html_source->AddString(
"osSearchEngineTooltip",
ui::SubstituteChromeOSDeviceType(IDS_OS_SETTINGS_SEARCH_ENGINE_TOOLTIP));
@@ -270,6 +266,12 @@ std::string SearchSection::GetSectionPath() const {
return mojom::kSearchAndAssistantSectionPath;
}
+bool SearchSection::LogMetric(mojom::Setting setting,
+ base::Value& value) const {
+ // Unimplemented.
+ return false;
+}
+
void SearchSection::RegisterHierarchy(HierarchyGenerator* generator) const {
generator->RegisterTopLevelSetting(mojom::Setting::kPreferredSearchEngine);
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 1de2bc61d26..e493422f84c 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/search_section.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SEARCH_SECTION_H_
#include "ash/public/cpp/assistant/assistant_state_base.h"
+#include "base/values.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_section.h"
namespace content {
@@ -34,6 +35,7 @@ class SearchSection : public OsSettingsSection,
mojom::Section GetSection() const override;
mojom::SearchResultIcon GetSectionIcon() const override;
std::string GetSectionPath() const override;
+ bool LogMetric(mojom::Setting setting, base::Value& value) const override;
void RegisterHierarchy(HierarchyGenerator* generator) const override;
// ash::AssistantStateObserver:
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
new file mode 100644
index 00000000000..77672966743
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.cc
@@ -0,0 +1,68 @@
+// 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/settings_user_action_tracker.h"
+
+#include <memory>
+#include <utility>
+
+#include "base/bind.h"
+
+namespace chromeos {
+namespace settings {
+
+SettingsUserActionTracker::SettingsUserActionTracker() = default;
+
+SettingsUserActionTracker::~SettingsUserActionTracker() = default;
+
+void SettingsUserActionTracker::BindInterface(
+ mojo::PendingReceiver<mojom::UserActionRecorder> pending_receiver) {
+ // Only one user session should be active at a time.
+ EndCurrentSession();
+ receiver_.Bind(std::move(pending_receiver));
+ receiver_.set_disconnect_handler(
+ base::BindOnce(&SettingsUserActionTracker::OnBindingDisconnected,
+ base::Unretained(this)));
+
+ // New session started, so create a new per session tracker.
+ per_session_tracker_ =
+ std::make_unique<PerSessionSettingsUserActionTracker>();
+}
+
+void SettingsUserActionTracker::EndCurrentSession() {
+ // Session ended, so delete the per session tracker.
+ per_session_tracker_.reset();
+ receiver_.reset();
+}
+
+void SettingsUserActionTracker::OnBindingDisconnected() {
+ EndCurrentSession();
+}
+
+void SettingsUserActionTracker::RecordPageFocus() {
+ per_session_tracker_->RecordPageFocus();
+}
+
+void SettingsUserActionTracker::RecordPageBlur() {
+ per_session_tracker_->RecordPageBlur();
+}
+
+void SettingsUserActionTracker::RecordClick() {
+ per_session_tracker_->RecordClick();
+}
+
+void SettingsUserActionTracker::RecordNavigation() {
+ per_session_tracker_->RecordNavigation();
+}
+
+void SettingsUserActionTracker::RecordSearch() {
+ per_session_tracker_->RecordSearch();
+}
+
+void SettingsUserActionTracker::RecordSettingChange() {
+ per_session_tracker_->RecordSettingChange();
+}
+
+} // namespace settings
+} // namespace chromeos
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
new file mode 100644
index 00000000000..73e495c2444
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/settings_user_action_tracker.h
@@ -0,0 +1,52 @@
+// 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_SETTINGS_USER_ACTION_TRACKER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SETTINGS_USER_ACTION_TRACKER_H_
+
+#include <memory>
+
+#include "chrome/browser/ui/webui/settings/chromeos/search/per_session_settings_user_action_tracker.h"
+#include "chrome/browser/ui/webui/settings/chromeos/search/user_action_recorder.mojom.h"
+#include "mojo/public/cpp/bindings/pending_receiver.h"
+#include "mojo/public/cpp/bindings/receiver.h"
+
+namespace chromeos {
+namespace settings {
+
+// Records user actions within Settings. Utilizes a per session tracker that
+// measures the user's effort required to change a setting. Eventually uses
+// a per section tracker to record metrics in each section.
+class SettingsUserActionTracker : public mojom::UserActionRecorder {
+ public:
+ SettingsUserActionTracker();
+ SettingsUserActionTracker(const SettingsUserActionTracker& other) = delete;
+ SettingsUserActionTracker& operator=(const SettingsUserActionTracker& other) =
+ delete;
+ ~SettingsUserActionTracker() override;
+
+ void BindInterface(
+ mojo::PendingReceiver<mojom::UserActionRecorder> pending_receiver);
+
+ private:
+ // mojom::UserActionRecorder:
+ void RecordPageFocus() override;
+ void RecordPageBlur() override;
+ void RecordClick() override;
+ void RecordNavigation() override;
+ void RecordSearch() override;
+ void RecordSettingChange() override;
+
+ void EndCurrentSession();
+ void OnBindingDisconnected();
+
+ std::unique_ptr<PerSessionSettingsUserActionTracker> per_session_tracker_;
+
+ mojo::Receiver<mojom::UserActionRecorder> receiver_{this};
+};
+
+} // namespace settings
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SETTINGS_USER_ACTION_TRACKER_H_
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 7865dd365a5..544bcea97c0 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
@@ -1240,7 +1240,7 @@ TEST(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) {
// Do not be in first run, so that the profiles are not created as "new
// profiles" and automatically migrated to Dice.
first_run::ResetCachedSentinelDataForTesting();
- base::ScopedClosureRunner(
+ base::ScopedClosureRunner scoped_closure_runner(
base::BindOnce(&first_run::ResetCachedSentinelDataForTesting));
base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kNoFirstRun);
ASSERT_FALSE(first_run::IsChromeFirstRun());
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 20aa230a020..3a3d150d1ec 100644
--- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.cc
@@ -230,6 +230,11 @@ void SafetyCheckHandler::PerformSafetyCheck() {
Profile::FromWebUI(web_ui()), true);
}
DCHECK(passwords_delegate_);
+ if (!insecure_credentials_manager_) {
+ insecure_credentials_manager_ =
+ passwords_delegate_->GetInsecureCredentialsManager();
+ }
+ DCHECK(insecure_credentials_manager_);
CheckPasswords();
if (!extension_prefs_) {
@@ -296,12 +301,17 @@ void SafetyCheckHandler::CheckUpdates() {
}
void SafetyCheckHandler::CheckPasswords() {
+ // Reset the tracking for callbacks with compromised passwords.
+ compromised_passwords_exist_ = false;
// Remove |this| as an existing observer for BulkLeakCheck if it is
// 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_);
+ // Start observing the InsecureCredentialsManager.
+ observed_insecure_credentials_manager_.RemoveAll();
+ observed_insecure_credentials_manager_.Add(insecure_credentials_manager_);
passwords_delegate_->StartPasswordCheck(base::BindOnce(
&SafetyCheckHandler::OnStateChanged, weak_ptr_factory_.GetWeakPtr()));
}
@@ -739,6 +749,25 @@ void SafetyCheckHandler::DetermineIfNoPasswordsOrSafe(
Compromised(0), Done(0), Total(0));
}
+void SafetyCheckHandler::UpdatePasswordsResultOnCheckIdle() {
+ size_t num_compromised =
+ passwords_delegate_->GetCompromisedCredentials().size();
+ if (num_compromised == 0) {
+ // 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();
+ }
+ passwords_delegate_->GetSavedPasswordsList(
+ base::BindOnce(&SafetyCheckHandler::DetermineIfNoPasswordsOrSafe,
+ base::Unretained(this)));
+ } else {
+ OnPasswordsCheckResult(PasswordsStatus::kCompromisedExist,
+ Compromised(num_compromised), Done(0), Total(0));
+ }
+}
+
void SafetyCheckHandler::OnVersionUpdaterResult(VersionUpdater::Status status,
int progress,
bool rollback,
@@ -774,17 +803,9 @@ void SafetyCheckHandler::OnStateChanged(
switch (state) {
case BulkLeakCheckService::State::kIdle:
case BulkLeakCheckService::State::kCanceled: {
- size_t num_compromised =
- passwords_delegate_->GetCompromisedCredentials().size();
- if (num_compromised == 0) {
- passwords_delegate_->GetSavedPasswordsList(
- base::BindOnce(&SafetyCheckHandler::DetermineIfNoPasswordsOrSafe,
- base::Unretained(this)));
- } else {
- OnPasswordsCheckResult(PasswordsStatus::kCompromisedExist,
- Compromised(num_compromised), Done(0), Total(0));
- }
- break;
+ UpdatePasswordsResultOnCheckIdle();
+ observed_leak_check_.RemoveAll();
+ return;
}
case BulkLeakCheckService::State::kRunning:
OnPasswordsCheckResult(PasswordsStatus::kChecking, Compromised(0),
@@ -814,14 +835,20 @@ void SafetyCheckHandler::OnStateChanged(
break;
}
- // Stop observing the leak service in all terminal states, if it's still being
- // observed.
+ // Stop observing the leak service and credentials manager in all non-idle
+ // states.
observed_leak_check_.RemoveAll();
+ observed_insecure_credentials_manager_.RemoveAll();
}
void SafetyCheckHandler::OnCredentialDone(
const password_manager::LeakCheckCredential& credential,
password_manager::IsLeaked is_leaked) {
+ // If a leaked credential is discovered, this is guaranteed to not be a safe
+ // state.
+ if (is_leaked) {
+ compromised_passwords_exist_ = true;
+ }
extensions::api::passwords_private::PasswordCheckStatus status =
passwords_delegate_->GetPasswordCheckStatus();
// Send progress updates only if the check is still running.
@@ -834,6 +861,21 @@ void SafetyCheckHandler::OnCredentialDone(
total);
}
}
+
+void SafetyCheckHandler::OnCompromisedCredentialsChanged(
+ password_manager::InsecureCredentialsManager::CredentialsView credentials) {
+ extensions::api::passwords_private::PasswordCheckStatus status =
+ passwords_delegate_->GetPasswordCheckStatus();
+ // Ignore the event, unless the password check is idle with no errors.
+ if (status.state !=
+ extensions::api::passwords_private::PASSWORD_CHECK_STATE_IDLE) {
+ return;
+ }
+ UpdatePasswordsResultOnCheckIdle();
+ // Stop observing the manager to avoid dynamically updating the result.
+ observed_insecure_credentials_manager_.RemoveAll();
+}
+
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
void SafetyCheckHandler::OnIdle(
safe_browsing::ChromeCleanerController::IdleReason idle_reason) {
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 1005025b49e..edaaccde991 100644
--- a/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/safety_check_handler.h
@@ -22,6 +22,7 @@
#include "chrome/browser/ui/webui/help/version_updater.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/password_manager/core/browser/bulk_leak_check_service.h"
+#include "components/password_manager/core/browser/ui/insecure_credentials_manager.h"
#include "components/safety_check/safety_check.h"
#include "components/safety_check/update_check_helper.h"
#include "extensions/browser/extension_prefs.h"
@@ -38,6 +39,7 @@
class SafetyCheckHandler
: public settings::SettingsPageUIHandler,
public password_manager::BulkLeakCheckServiceInterface::Observer,
+ public password_manager::InsecureCredentialsManager::Observer,
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
public safe_browsing::ChromeCleanerController::Observer,
#endif
@@ -210,6 +212,10 @@ class SafetyCheckHandler
const std::vector<extensions::api::passwords_private::PasswordUiEntry>&
passwords);
+ // Gets the compromised passwords count and invokes an appropriate result
+ // method depending on the state.
+ void UpdatePasswordsResultOnCheckIdle();
+
// A callback passed to |VersionUpdater::CheckForUpdate| to receive the update
// state.
void OnVersionUpdaterResult(VersionUpdater::Status status,
@@ -229,6 +235,11 @@ class SafetyCheckHandler
void OnCredentialDone(const password_manager::LeakCheckCredential& credential,
password_manager::IsLeaked is_leaked) override;
+ // InsecureCredentialsManager::Observer implementation.
+ void OnCompromisedCredentialsChanged(
+ password_manager::InsecureCredentialsManager::CredentialsView credentials)
+ override;
+
#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
// safe_browsing::ChromeCleanerController::Observer overrides.
void OnIdle(
@@ -270,18 +281,26 @@ class SafetyCheckHandler
ChromeCleanerStatus chrome_cleaner_status_ = ChromeCleanerStatus::kHidden;
// System time when safety check completed.
base::Time safety_check_completion_time_;
+ // Tracks whether there is at least one |OnCredentialDone| callback with
+ // is_leaked = true.
+ bool compromised_passwords_exist_ = false;
std::unique_ptr<safety_check::SafetyCheck> safety_check_;
std::unique_ptr<safety_check::UpdateCheckHelper> update_helper_;
std::unique_ptr<VersionUpdater> version_updater_;
password_manager::BulkLeakCheckServiceInterface* leak_service_ = nullptr;
+ password_manager::InsecureCredentialsManager* insecure_credentials_manager_ =
+ nullptr;
extensions::PasswordsPrivateDelegate* passwords_delegate_ = nullptr;
extensions::ExtensionPrefs* extension_prefs_ = nullptr;
extensions::ExtensionServiceInterface* extension_service_ = nullptr;
ScopedObserver<password_manager::BulkLeakCheckServiceInterface,
password_manager::BulkLeakCheckServiceInterface::Observer>
observed_leak_check_{this};
+ ScopedObserver<password_manager::InsecureCredentialsManager,
+ password_manager::InsecureCredentialsManager::Observer>
+ observed_insecure_credentials_manager_{this};
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 aba8ab6b18d..99da3f916f4 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
@@ -27,6 +27,7 @@
#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"
+#include "components/password_manager/core/browser/test_password_store.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/safety_check/test_update_check_helper.h"
@@ -104,6 +105,14 @@ bool TestDestructionVersionUpdater::destructor_invoked_ = false;
class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
public:
+ TestPasswordsDelegate() { store_->Init(/*prefs=*/nullptr); }
+
+ void TearDown() {
+ store_->ShutdownOnUIThread();
+ // Needs to be invoked in the test's TearDown() - before the destructor.
+ base::RunLoop().RunUntilIdle();
+ }
+
void SetBulkLeakCheckService(
password_manager::BulkLeakCheckService* leak_service) {
leak_service_ = leak_service;
@@ -123,9 +132,18 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
total_ = total;
}
- std::vector<extensions::api::passwords_private::CompromisedCredential>
+ void InvokeOnCompromisedCredentialsChanged() {
+ // Credentials have to be unique, so the callback is always invoked.
+ store_->AddCompromisedCredentials(
+ {"test.com",
+ base::ASCIIToUTF16("test" +
+ base::NumberToString(test_credential_counter_++))});
+ base::RunLoop().RunUntilIdle();
+ }
+
+ std::vector<extensions::api::passwords_private::InsecureCredential>
GetCompromisedCredentials() override {
- std::vector<extensions::api::passwords_private::CompromisedCredential>
+ std::vector<extensions::api::passwords_private::InsecureCredential>
compromised(compromised_password_count_);
for (int i = 0; i < compromised_password_count_; ++i) {
compromised[i].username = "test" + base::NumberToString(i);
@@ -144,13 +162,24 @@ class TestPasswordsDelegate : public extensions::TestPasswordsPrivateDelegate {
return status;
}
+ password_manager::InsecureCredentialsManager* GetInsecureCredentialsManager()
+ override {
+ return &credentials_manager_;
+ }
+
private:
password_manager::BulkLeakCheckService* leak_service_ = nullptr;
int compromised_password_count_ = 0;
int done_ = 0;
int total_ = 0;
+ int test_credential_counter_ = 0;
extensions::api::passwords_private::PasswordCheckState state_ =
extensions::api::passwords_private::PASSWORD_CHECK_STATE_IDLE;
+ scoped_refptr<password_manager::TestPasswordStore> store_ =
+ base::MakeRefCounted<password_manager::TestPasswordStore>();
+ password_manager::SavedPasswordsPresenter presenter_{store_};
+ password_manager::InsecureCredentialsManager credentials_manager_{&presenter_,
+ store_};
};
class TestSafetyCheckExtensionService : public TestExtensionService {
@@ -201,6 +230,7 @@ class TestChromeCleanerControllerDelegate
class SafetyCheckHandlerTest : public ChromeRenderViewHostTestHarness {
public:
void SetUp() override;
+ void TearDown() override;
// Returns a |base::DictionaryValue| for safety check status update that
// has the specified |component| and |new_state| if it exists; nullptr
@@ -260,6 +290,11 @@ void SafetyCheckHandlerTest::SetUp() {
safety_check_->AllowJavascript();
}
+void SafetyCheckHandlerTest::TearDown() {
+ test_passwords_delegate_.TearDown();
+ ChromeRenderViewHostTestHarness::TearDown();
+}
+
const base::DictionaryValue*
SafetyCheckHandlerTest::GetSafetyCheckStatusChangedWithDataIfExists(
const std::string& component,
@@ -811,6 +846,91 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_Safe) {
SafetyCheckHandler::PasswordsStatus::kSafe, 1);
}
+TEST_F(SafetyCheckHandlerTest, CheckPasswords_StaleSafeThenCompromised) {
+ constexpr int kCompromised = 7;
+ safety_check_->PerformSafetyCheck();
+ // First, a "running" change of state.
+ test_leak_service_->set_state_and_notify(
+ password_manager::BulkLeakCheckService::State::kRunning);
+ test_passwords_delegate_.SetPasswordCheckState(
+ extensions::api::passwords_private::PASSWORD_CHECK_STATE_RUNNING);
+ EXPECT_TRUE(GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)));
+ // Not a "safe" state, so send an |OnCredentialDone| with is_leaked=true.
+ static_cast<password_manager::BulkLeakCheckService::Observer*>(
+ safety_check_.get())
+ ->OnCredentialDone(
+ {base::ASCIIToUTF16("login"), base::ASCIIToUTF16("password")},
+ password_manager::IsLeaked(true));
+ // The service goes idle, but the disk still has a stale "safe" state.
+ test_leak_service_->set_state_and_notify(
+ password_manager::BulkLeakCheckService::State::kIdle);
+ test_passwords_delegate_.SetPasswordCheckState(
+ extensions::api::passwords_private::PASSWORD_CHECK_STATE_IDLE);
+ const base::DictionaryValue* event =
+ GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(SafetyCheckHandler::PasswordsStatus::kSafe));
+ EXPECT_TRUE(event);
+ // An InsecureCredentialsManager callback fires once the compromised passwords
+ // get written to disk.
+ test_passwords_delegate_.SetNumCompromisedCredentials(kCompromised);
+ test_passwords_delegate_.InvokeOnCompromisedCredentialsChanged();
+ const base::DictionaryValue* event2 =
+ GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(
+ SafetyCheckHandler::PasswordsStatus::kCompromisedExist));
+ EXPECT_TRUE(event2);
+ VerifyDisplayString(
+ event2, base::NumberToString(kCompromised) + " compromised passwords");
+}
+
+TEST_F(SafetyCheckHandlerTest, CheckPasswords_SafeStateThenMoreEvents) {
+ safety_check_->PerformSafetyCheck();
+ // Running state.
+ test_leak_service_->set_state_and_notify(
+ password_manager::BulkLeakCheckService::State::kRunning);
+ test_passwords_delegate_.SetPasswordCheckState(
+ extensions::api::passwords_private::PASSWORD_CHECK_STATE_RUNNING);
+ EXPECT_TRUE(GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(SafetyCheckHandler::PasswordsStatus::kChecking)));
+
+ // Previous safe state got loaded.
+ test_passwords_delegate_.SetNumCompromisedCredentials(0);
+ test_passwords_delegate_.InvokeOnCompromisedCredentialsChanged();
+ // The event should get ignored, since the state is still running.
+ const base::DictionaryValue* event =
+ GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(SafetyCheckHandler::PasswordsStatus::kSafe));
+ EXPECT_FALSE(event);
+
+ // The check is completed with another safe state.
+ test_passwords_delegate_.SetPasswordCheckState(
+ extensions::api::passwords_private::PASSWORD_CHECK_STATE_IDLE);
+ test_leak_service_->set_state_and_notify(
+ password_manager::BulkLeakCheckService::State::kIdle);
+ // This time the safe state should be reflected.
+ event = GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords, static_cast<int>(SafetyCheckHandler::PasswordsStatus::kSafe));
+ EXPECT_TRUE(event);
+
+ // After some time, some compromises were discovered (unrelated to SC).
+ constexpr int kCompromised = 7;
+ test_passwords_delegate_.SetNumCompromisedCredentials(kCompromised);
+ test_passwords_delegate_.InvokeOnCompromisedCredentialsChanged();
+ // The new event should get ignored, since the safe state was final.
+ const base::DictionaryValue* event2 =
+ GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(
+ SafetyCheckHandler::PasswordsStatus::kCompromisedExist));
+ EXPECT_FALSE(event2);
+}
+
TEST_F(SafetyCheckHandlerTest, CheckPasswords_CompromisedExist) {
constexpr int kCompromised = 7;
test_passwords_delegate_.SetNumCompromisedCredentials(kCompromised);
@@ -857,6 +977,47 @@ TEST_F(SafetyCheckHandlerTest, CheckPasswords_Error) {
SafetyCheckHandler::PasswordsStatus::kError, 1);
}
+TEST_F(SafetyCheckHandlerTest, CheckPasswords_Error_FutureEventsIgnored) {
+ safety_check_->PerformSafetyCheck();
+ EXPECT_TRUE(test_passwords_delegate_.StartPasswordCheckTriggered());
+ static_cast<password_manager::BulkLeakCheckService::Observer*>(
+ safety_check_.get())
+ ->OnStateChanged(
+ password_manager::BulkLeakCheckService::State::kServiceError);
+ const base::DictionaryValue* event =
+ GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(SafetyCheckHandler::PasswordsStatus::kError));
+ ASSERT_TRUE(event);
+ VerifyDisplayString(event,
+ "Browser can't check your passwords. Try again "
+ "later.");
+ histogram_tester_.ExpectBucketCount(
+ "Settings.SafetyCheck.PasswordsResult",
+ SafetyCheckHandler::PasswordsStatus::kError, 1);
+ // At some point later, the service discovers compromised passwords and goes
+ // idle.
+ constexpr int kCompromised = 7;
+ static_cast<password_manager::BulkLeakCheckService::Observer*>(
+ safety_check_.get())
+ ->OnStateChanged(password_manager::BulkLeakCheckService::State::kRunning);
+ static_cast<password_manager::BulkLeakCheckService::Observer*>(
+ safety_check_.get())
+ ->OnStateChanged(password_manager::BulkLeakCheckService::State::kIdle);
+ // An InsecureCredentialsManager callback fires once the compromised passwords
+ // get written to disk.
+ test_passwords_delegate_.SetNumCompromisedCredentials(kCompromised);
+ test_passwords_delegate_.InvokeOnCompromisedCredentialsChanged();
+ const base::DictionaryValue* event2 =
+ GetSafetyCheckStatusChangedWithDataIfExists(
+ kPasswords,
+ static_cast<int>(
+ SafetyCheckHandler::PasswordsStatus::kCompromisedExist));
+ // The event for compromised passwords should not exist, since the changes
+ // should no longer be observed.
+ EXPECT_FALSE(event2);
+}
+
TEST_F(SafetyCheckHandlerTest, CheckPasswords_FeatureUnavailable) {
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 e7331b97a04..9206266786d 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
@@ -279,6 +279,8 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
break;
case BrowsingDataType::PASSWORDS:
remove_mask |= ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PASSWORDS;
+ remove_mask |=
+ ChromeBrowsingDataRemoverDelegate::DATA_TYPE_ACCOUNT_PASSWORDS;
break;
case BrowsingDataType::FORM_DATA:
remove_mask |= ChromeBrowsingDataRemoverDelegate::DATA_TYPE_FORM_DATA;
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 79f60e280e6..898a006aafe 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
@@ -97,6 +97,7 @@
#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"
@@ -720,6 +721,18 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source,
html_source->AddBoolean(
"isSecondaryUser",
user && user->GetAccountId() != primary_user->GetAccountId());
+
+ html_source->AddString(
+ "openChromeOSLanguagesSettingsLabel",
+ l10n_util::GetStringUTF16(
+ IDS_SETTINGS_LANGUAGES_OPEN_CHROME_OS_SETTINGS_LABEL));
+ html_source->AddString(
+ "chromeOSLanguagesSettingsPath",
+ chromeos::settings::mojom::kLanguagesAndInputSectionPath);
+ html_source->AddBoolean("isChromeOSLanguagesSettingsUpdate",
+ base::FeatureList::IsEnabled(
+ chromeos::features::kLanguageSettingsUpdate));
+
#endif // defined(OS_CHROMEOS)
}
@@ -818,6 +831,7 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
{"compromisedPasswords", IDS_SETTINGS_COMPROMISED_PASSWORDS},
{"compromisedPasswordsDescription",
IDS_SETTINGS_COMPROMISED_PASSWORDS_ADVICE},
+ {"weakPasswords", IDS_SETTINGS_WEAK_PASSWORDS},
{"changePasswordButton", IDS_SETTINGS_CHANGE_PASSWORD_BUTTON},
{"changePasswordInApp", IDS_SETTINGS_CHANGE_PASSWORD_IN_APP_LABEL},
{"leakedPassword", IDS_SETTINGS_COMPROMISED_PASSWORD_REASON_LEAKED},
@@ -910,6 +924,7 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
{"editPasswordTitle", IDS_SETTINGS_PASSWORD_EDIT_TITLE},
{"editPassword", IDS_SETTINGS_PASSWORD_EDIT},
{"editPasswordFootnote", IDS_SETTINGS_PASSWORD_EDIT_FOOTNOTE},
+ {"usernameAlreadyUsed", IDS_SETTINGS_PASSWORD_USERNAME_ALREADY_USED},
{"copyPassword", IDS_SETTINGS_PASSWORD_COPY},
{"passwordStoredOnDevice", IDS_SETTINGS_PASSWORD_STORED_ON_DEVICE},
{"passwordStoredInAccount", IDS_SETTINGS_PASSWORD_STORED_IN_ACCOUNT},
@@ -1023,6 +1038,25 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
autofill::payments::GetManageInstrumentsUrl().spec());
html_source->AddString("paymentMethodsLearnMoreURL",
chrome::kPaymentMethodsLearnMoreURL);
+ html_source->AddString(
+ "weakPasswordsDescription",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_WEAK_PASSWORDS_DESCRIPTION,
+ base::ASCIIToUTF16(chrome::kSeeMoreSecurityTipsURL)));
+ html_source->AddString(
+ "weakPasswordsDescriptionGeneration",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_WEAK_PASSWORDS_DESCRIPTION_GENERATION,
+ base::ASCIIToUTF16(chrome::kPasswordGenerationLearnMoreURL)));
+ html_source->AddString("signedOutUserLabel",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_SIGNED_OUT_USER_LABEL,
+ base::ASCIIToUTF16(chrome::kSyncLearnMoreURL)));
+ html_source->AddString(
+ "signedOutUserHasCompromisedCredentialsLabel",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_SIGNED_OUT_USER_HAS_COMPROMISED_CREDENTIALS_LABEL,
+ base::ASCIIToUTF16(chrome::kSyncLearnMoreURL)));
// The warning message that will be shown if there is a content setting
// pattern with a wildcard in it. The check for wildcards is done on the js
// side.
@@ -1176,6 +1210,12 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
IDS_SETTINGS_SYNC_DISCONNECT_DELETE_PROFILE_WARNING_WITH_COUNTS_PLURAL},
{"deleteProfileWarningWithoutCounts",
IDS_SETTINGS_SYNC_DISCONNECT_DELETE_PROFILE_WARNING_WITHOUT_COUNTS},
+
+ // Color picker strings:
+ {"colorPickerLabel", IDS_NTP_CUSTOMIZE_COLOR_PICKER_LABEL},
+ {"defaultThemeLabel", IDS_NTP_CUSTOMIZE_DEFAULT_LABEL},
+ {"thirdPartyThemeDescription", IDS_NTP_CUSTOMIZE_3PT_THEME_DESC},
+ {"uninstallThirdPartyThemeButton", IDS_NTP_CUSTOMIZE_3PT_THEME_UNINSTALL},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
@@ -1478,14 +1518,12 @@ void AddSearchStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"searchEnginesManage", IDS_SETTINGS_SEARCH_MANAGE_SEARCH_ENGINES},
{"searchPageTitle", IDS_SETTINGS_SEARCH},
-
+ {"searchExplanation", IDS_SETTINGS_SEARCH_EXPLANATION},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
- html_source->AddString("searchExplanation",
- l10n_util::GetStringFUTF16(
- IDS_SETTINGS_SEARCH_EXPLANATION,
- base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL)));
+ html_source->AddString("searchExplanationLearnMoreURL",
+ base::ASCIIToUTF16(chrome::kOmniboxLearnMoreURL));
}
void AddSearchEnginesStrings(content::WebUIDataSource* html_source) {
@@ -1752,8 +1790,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_ALLOW_RECENTLY_CLOSED_SITES},
{"siteSettingsAllowRecentlyClosedSitesRecommended",
IDS_SETTINGS_SITE_SETTINGS_ALLOW_RECENTLY_CLOSED_SITES_RECOMMENDED},
- {"siteSettingsBackgroundSyncBlocked",
- IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC_BLOCKED},
+ {"siteSettingsBackgroundSyncBlock",
+ IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC_BLOCK},
{"siteSettingsHandlersAsk", IDS_SETTINGS_SITE_SETTINGS_HANDLERS_ASK},
{"siteSettingsHandlersAskRecommended",
IDS_SETTINGS_SITE_SETTINGS_HANDLERS_ASK_RECOMMENDED},
@@ -1825,11 +1863,11 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsSourcePolicyBlock",
IDS_PAGE_INFO_PERMISSION_BLOCKED_BY_POLICY},
{"siteSettingsSourcePolicyAsk", IDS_PAGE_INFO_PERMISSION_ASK_BY_POLICY},
- {"siteSettingsAdsBlockNotBlacklistedSingular",
- IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK_NOT_BLACKLISTED_SINGULAR},
+ {"siteSettingsAdsBlockNotBlocklistedSingular",
+ IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK_NOT_BLOCKLISTED_SINGULAR},
{"siteSettingsAllowlisted", IDS_SETTINGS_SITE_SETTINGS_ALLOWLISTED},
- {"siteSettingsAdsBlockBlacklistedSingular",
- IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK_BLACKLISTED_SINGULAR},
+ {"siteSettingsAdsBlockBlocklistedSingular",
+ IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK_BLOCKLISTED_SINGULAR},
{"siteSettingsSourceDrmDisabled",
IDS_SETTINGS_SITE_SETTINGS_SOURCE_DRM_DISABLED},
{"siteSettingsSourceEmbargo",
@@ -1934,6 +1972,125 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"incognitoSiteExceptionDesc",
IDS_SETTINGS_SITE_SETTINGS_INCOGNITO_SITE_EXCEPTION_DESC},
{"noSitesAdded", IDS_SETTINGS_SITE_NO_SITES_ADDED},
+ {"siteSettingsDefaultBehavior",
+ IDS_SETTINGS_SITE_SETTINGS_DEFAULT_BEHAVIOR},
+ {"siteSettingsDefaultBehaviorDescription",
+ IDS_SETTINGS_SITE_SETTINGS_DEFAULT_BEHAVIOR_DESCRIPTION},
+ {"siteSettingsAdsDescription", IDS_SETTINGS_SITE_SETTINGS_ADS_DESCRIPTION},
+ {"siteSettingsAdsAllowed", IDS_SETTINGS_SITE_SETTINGS_ADS_ALLOWED},
+ {"siteSettingsAdsBlocked", IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCKED},
+ {"siteSettingsArDescription", IDS_SETTINGS_SITE_SETTINGS_AR_DESCRIPTION},
+ {"siteSettingsArAllowed", IDS_SETTINGS_SITE_SETTINGS_AR_ALLOWED},
+ {"siteSettingsArBlocked", IDS_SETTINGS_SITE_SETTINGS_AR_BLOCKED},
+ {"siteSettingsAutomaticDownloadsDescription",
+ IDS_SETTINGS_SITE_SETTINGS_AUTOMATIC_DOWNLOADS_DESCRIPTION},
+ {"siteSettingsAutomaticDownloadsAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_AUTOMATIC_DOWNLOADS_ALLOWED},
+ {"siteSettingsAutomaticDownloadsBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_AUTOMATIC_DOWNLOADS_BLOCKED},
+ {"siteSettingsBackgroundSyncDescription",
+ IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC_DESCRIPTION},
+ {"siteSettingsBackgroundSyncAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC_ALLOWED},
+ {"siteSettingsBackgroundSyncBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC_BLOCKED},
+ {"siteSettingsCameraDescription",
+ IDS_SETTINGS_SITE_SETTINGS_CAMERA_DESCRIPTION},
+ {"siteSettingsCameraAllowed", IDS_SETTINGS_SITE_SETTINGS_CAMERA_ALLOWED},
+ {"siteSettingsCameraBlocked", IDS_SETTINGS_SITE_SETTINGS_CAMERA_BLOCKED},
+ {"siteSettingsCameraBlockedSubLabel",
+ IDS_SETTINGS_SITE_SETTINGS_CAMERA_BLOCKED_SUB_LABEL},
+ {"siteSettingsClipboardDescription",
+ IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_DESCRIPTION},
+ {"siteSettingsClipboardAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_ALLOWED},
+ {"siteSettingsClipboardBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_CLIPBOARD_BLOCKED},
+ {"siteSettingsFileSystemWriteDescription",
+ IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_WRITE_DESCRIPTION},
+ {"siteSettingsFileSystemWriteAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_WRITE_ALLOWED},
+ {"siteSettingsFileSystemWriteBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_FILE_SYSTEM_WRITE_BLOCKED},
+ {"siteSettingsLocationDescription",
+ IDS_SETTINGS_SITE_SETTINGS_LOCATION_DESCRIPTION},
+ {"siteSettingsLocationAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_LOCATION_ALLOWED},
+ {"siteSettingsLocationBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_LOCATION_BLOCKED},
+ {"siteSettingsLocationBlockedSubLabel",
+ IDS_SETTINGS_SITE_SETTINGS_LOCATION_BLOCKED_SUB_LABEL},
+ {"siteSettingsImagesDescription",
+ IDS_SETTINGS_SITE_SETTINGS_IMAGES_DESCRIPTION},
+ {"siteSettingsImagesAllowed", IDS_SETTINGS_SITE_SETTINGS_IMAGES_ALLOWED},
+ {"siteSettingsImagesBlocked", IDS_SETTINGS_SITE_SETTINGS_IMAGES_BLOCKED},
+ {"siteSettingsJavascriptDescription",
+ IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_DESCRIPTION},
+ {"siteSettingsJavascriptAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_ALLOWED},
+ {"siteSettingsJavascriptBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_JAVASCRIPT_BLOCKED},
+ {"siteSettingsMicDescription", IDS_SETTINGS_SITE_SETTINGS_MIC_DESCRIPTION},
+ {"siteSettingsMicAllowed", IDS_SETTINGS_SITE_SETTINGS_MIC_ALLOWED},
+ {"siteSettingsMicBlocked", IDS_SETTINGS_SITE_SETTINGS_MIC_BLOCKED},
+ {"siteSettingsMicBlockedSubLabel",
+ IDS_SETTINGS_SITE_SETTINGS_MIC_BLOCKED_SUB_LABEL},
+ {"siteSettingsMidiDescription",
+ IDS_SETTINGS_SITE_SETTINGS_MIDI_DESCRIPTION},
+ {"siteSettingsMidiAllowed", IDS_SETTINGS_SITE_SETTINGS_MIDI_ALLOWED},
+ {"siteSettingsMidiBlocked", IDS_SETTINGS_SITE_SETTINGS_MIDI_BLOCKED},
+ {"siteSettingsPaymentHandlersDescription",
+ IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLERS_DESCRIPTION},
+ {"siteSettingsPaymentHandlersAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLERS_ALLOWED},
+ {"siteSettingsPaymentHandlersBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLERS_BLOCKED},
+ {"siteSettingsFlashDescription",
+ IDS_SETTINGS_SITE_SETTINGS_FLASH_DESCRIPTION},
+ {"siteSettingsFlashAllowed", IDS_SETTINGS_SITE_SETTINGS_FLASH_ALLOWED},
+ {"siteSettingsFlashBlocked", IDS_SETTINGS_SITE_SETTINGS_FLASH_BLOCKED},
+ {"siteSettingsPopupsDescription",
+ IDS_SETTINGS_SITE_SETTINGS_POPUPS_DESCRIPTION},
+ {"siteSettingsPopupsAllowed", IDS_SETTINGS_SITE_SETTINGS_POPUPS_ALLOWED},
+ {"siteSettingsPopupsBlocked", IDS_SETTINGS_SITE_SETTINGS_POPUPS_BLOCKED},
+ {"siteSettingsProtectedContentDescription",
+ IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_DESCRIPTION},
+ {"siteSettingsProtectedContentAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_ALLOWED},
+ {"siteSettingsProtectedContentBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_PROTECTED_CONTENT_BLOCKED},
+ {"siteSettingsMotionSensorsDescription",
+ IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_DESCRIPTION},
+ {"siteSettingsMotionSensorsAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_ALLOWED},
+ {"siteSettingsMotionSensorsBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCKED},
+ {"siteSettingsMotionSensorsBlockedSubLabel",
+ IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCKED_SUB_LABEL},
+ {"siteSettingsSerialPortsDescription",
+ IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_DESCRIPTION},
+ {"siteSettingsSerialPortsAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_ALLOWED},
+ {"siteSettingsSerialPortsBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_BLOCKED},
+ {"siteSettingsSoundDescription",
+ IDS_SETTINGS_SITE_SETTINGS_SOUND_DESCRIPTION},
+ {"siteSettingsSoundAllowed", IDS_SETTINGS_SITE_SETTINGS_SOUND_ALLOWED},
+ {"siteSettingsSoundBlocked", IDS_SETTINGS_SITE_SETTINGS_SOUND_BLOCKED},
+ {"siteSettingsUnsandboxedPluginsDescription",
+ IDS_SETTINGS_SITE_SETTINGS_UNSANDBOXED_PLUGINS_DESCRIPTION},
+ {"siteSettingsUnsandboxedPluginsAllowed",
+ IDS_SETTINGS_SITE_SETTINGS_UNSANDBOXED_PLUGINS_ALLOWED},
+ {"siteSettingsUnsandboxedPluginsBlocked",
+ IDS_SETTINGS_SITE_SETTINGS_UNSANDBOXED_PLUGINS_BLOCKED},
+ {"siteSettingsUsbDescription", IDS_SETTINGS_SITE_SETTINGS_USB_DESCRIPTION},
+ {"siteSettingsUsbAllowed", IDS_SETTINGS_SITE_SETTINGS_USB_ALLOWED},
+ {"siteSettingsUsbBlocked", IDS_SETTINGS_SITE_SETTINGS_USB_BLOCKED},
+ {"siteSettingsVrDescription", IDS_SETTINGS_SITE_SETTINGS_VR_DESCRIPTION},
+ {"siteSettingsVrAllowed", IDS_SETTINGS_SITE_SETTINGS_VR_ALLOWED},
+ {"siteSettingsVrBlocked", IDS_SETTINGS_SITE_SETTINGS_VR_BLOCKED},
+ {"siteSettingsZoomLevelsDescription",
+ IDS_SETTINGS_SITE_SETTINGS_ZOOM_LEVELS_DESCRIPTION},
{"siteSettingsAds", IDS_SETTINGS_SITE_SETTINGS_ADS},
{"siteSettingsAdsBlock", IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK},
{"siteSettingsAdsBlockRecommended",
@@ -1978,6 +2135,11 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsFontAccessAsk", IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_ASK},
{"siteSettingsFontAccessBlock",
IDS_SETTINGS_SITE_SETTINGS_FONT_ACCESS_BLOCK},
+ {"siteSettingsIdleDetection", IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION},
+ {"siteSettingsIdleDetectionAsk",
+ IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION_ASK},
+ {"siteSettingsIdleDetectionBlock",
+ IDS_SETTINGS_SITE_SETTINGS_IDLE_DETECTION_BLOCK},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
@@ -2021,19 +2183,11 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
cmd.HasSwitch(::switches::kEnableExperimentalWebPlatformFeatures));
html_source->AddBoolean(
- "enableFileSystemWriteContentSetting",
- base::FeatureList::IsEnabled(::blink::features::kNativeFileSystemAPI));
-
- html_source->AddBoolean(
"enableRemovingAllThirdPartyCookies",
base::FeatureList::IsEnabled(
browsing_data::features::kEnableRemovingAllThirdPartyCookies));
html_source->AddBoolean(
- "enableInsecureContentContentSetting",
- base::FeatureList::IsEnabled(features::kMixedContentSiteSetting));
-
- html_source->AddBoolean(
"enableStoragePressureUI",
base::FeatureList::IsEnabled(features::kStoragePressureUI));
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 299fdea9e04..4731bc7b3f9 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
@@ -24,6 +24,7 @@
#include "content/public/browser/web_ui.h"
#include "net/dns/public/dns_over_https_server_config.h"
#include "net/dns/public/doh_provider_entry.h"
+#include "net/dns/public/secure_dns_mode.h"
#include "net/dns/public/util.h"
#include "ui/base/l10n/l10n_util.h"
@@ -205,7 +206,7 @@ void SecureDnsHandler::HandleProbeCustomDnsTemplate(
net::DnsConfigOverrides overrides;
overrides.search = std::vector<std::string>();
overrides.attempts = 1;
- overrides.secure_dns_mode = net::DnsConfig::SecureDnsMode::SECURE;
+ overrides.secure_dns_mode = net::SecureDnsMode::kSecure;
secure_dns::ApplyTemplate(&overrides, server_template);
DCHECK(!runner_);
runner_ = std::make_unique<chrome_browser_net::DnsProbeRunner>(
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
index 6f76d852feb..e87212b52e9 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
@@ -118,6 +118,7 @@
#include "ui/base/ui_base_features.h"
#else // !defined(OS_CHROMEOS)
#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/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"
@@ -155,7 +156,13 @@ web_app::AppRegistrar& GetRegistrarForProfile(Profile* profile) {
}
SettingsUI::SettingsUI(content::WebUI* web_ui)
- : content::WebUIController(web_ui),
+ :
+#if !defined(OS_CHROMEOS)
+ ui::MojoWebUIController(web_ui, /*enable_chrome_send=*/true),
+ customize_themes_factory_receiver_(this),
+#else // !defined(OS_CHROMEOS)
+ content::WebUIController(web_ui),
+#endif
webui_load_timer_(web_ui->GetWebContents(),
"Settings.LoadDocumentTime.MD",
"Settings.LoadCompletedTime.MD") {
@@ -264,17 +271,14 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
base::FeatureList::IsEnabled(safe_browsing::kEnhancedProtection));
html_source->AddBoolean(
- "navigateToGooglePasswordManager",
- ShouldManagePasswordsinGooglePasswordManager(profile));
-
- html_source->AddBoolean(
- "enablePasswordCheck",
- base::FeatureList::IsEnabled(password_manager::features::kPasswordCheck));
+ "passwordsWeaknessCheck",
+ base::FeatureList::IsEnabled(
+ password_manager::features::kPasswordsWeaknessCheck));
html_source->AddBoolean(
"editPasswordsInSettings",
base::FeatureList::IsEnabled(
- password_manager::features::kEditPasswordsInDesktopSettings));
+ password_manager::features::kEditPasswordsInSettings));
html_source->AddBoolean("showImportPasswords",
base::FeatureList::IsEnabled(
@@ -286,10 +290,6 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
password_manager::features::kEnablePasswordsAccountStorage));
html_source->AddBoolean(
- "syncSetupFriendlySettings",
- base::FeatureList::IsEnabled(features::kSyncSetupFriendlySettings));
-
- html_source->AddBoolean(
"enableContentSettingsRedesign",
base::FeatureList::IsEnabled(features::kContentSettingsRedesign));
@@ -314,7 +314,11 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
// This is the browser settings page.
html_source->AddBoolean("isOSSettings", false);
-#endif
+#else // defined(OS_CHROMEOS)
+ html_source->AddBoolean(
+ "profileThemeSelectorEnabled",
+ base::FeatureList::IsEnabled(features::kProfilesUIRevamp));
+#endif // !defined(OS_CHROMEOS)
AddSettingsPageUIHandler(std::make_unique<AboutHandler>(profile));
AddSettingsPageUIHandler(std::make_unique<ResetSettingsHandler>(profile));
@@ -323,6 +327,10 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
auto plural_string_handler = std::make_unique<PluralStringHandler>();
plural_string_handler->AddLocalizedString(
"compromisedPasswords", IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT);
+ plural_string_handler->AddLocalizedString(
+ "insecurePasswords", IDS_SETTINGS_INSECURE_PASSWORDS_COUNT);
+ plural_string_handler->AddLocalizedString("weakPasswords",
+ IDS_SETTINGS_WEAK_PASSWORDS_COUNT);
web_ui->AddMessageHandler(std::move(plural_string_handler));
// Add the metrics handler to write uma stats.
@@ -418,8 +426,9 @@ void SettingsUI::InitBrowserSettingsWebUIHandlers() {
profile->GetPrefs(),
chromeos::multidevice_setup::MultiDeviceSetupClientFactory::
GetForProfile(profile),
- phone_hub_manager ? phone_hub_manager->notification_access_manager()
- : nullptr,
+ phone_hub_manager
+ ? phone_hub_manager->GetNotificationAccessManager()
+ : nullptr,
android_sms_service
? android_sms_service->android_sms_pairing_state_tracker()
: nullptr,
@@ -430,7 +439,16 @@ void SettingsUI::InitBrowserSettingsWebUIHandlers() {
web_ui()->AddMessageHandler(
std::make_unique<chromeos::settings::AndroidAppsHandler>(profile));
}
-#endif // defined(OS_CHROMEOS)
+#else // defined(OS_CHROMEOS)
+void SettingsUI::BindInterface(
+ mojo::PendingReceiver<
+ customize_themes::mojom::CustomizeThemesHandlerFactory>
+ pending_receiver) {
+ if (customize_themes_factory_receiver_.is_bound())
+ customize_themes_factory_receiver_.reset();
+ customize_themes_factory_receiver_.Bind(std::move(pending_receiver));
+}
+#endif // !defined(OS_CHROMEOS)
void SettingsUI::AddSettingsPageUIHandler(
std::unique_ptr<content::WebUIMessageHandler> handler) {
@@ -448,4 +466,18 @@ void SettingsUI::TryShowHatsSurveyWithTimeout() {
}
}
+#if !defined(OS_CHROMEOS)
+void SettingsUI::CreateCustomizeThemesHandler(
+ mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
+ pending_client,
+ mojo::PendingReceiver<customize_themes::mojom::CustomizeThemesHandler>
+ pending_handler) {
+ customize_themes_handler_ = std::make_unique<ChromeCustomizeThemesHandler>(
+ std::move(pending_client), std::move(pending_handler),
+ web_ui()->GetWebContents(), Profile::FromWebUI(web_ui()));
+}
+#endif // !defined(OS_CHROMEOS)
+
+WEB_UI_CONTROLLER_TYPE_IMPL(SettingsUI)
+
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_ui.h b/chromium/chrome/browser/ui/webui/settings/settings_ui.h
index ff4a05c608e..6da24f5e2c8 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_ui.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_ui.h
@@ -6,10 +6,19 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_UI_H_
#include "base/macros.h"
+#include "build/build_config.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)
+#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)
+
namespace content {
class WebUIMessageHandler;
} // namespace content
@@ -18,10 +27,23 @@ namespace user_prefs {
class PrefRegistrySyncable;
}
+#if !defined(OS_CHROMEOS)
+class ChromeCustomizeThemesHandler;
+#endif // !defined(OS_CHROMEOS)
+
namespace settings {
// The WebUI handler for chrome://settings.
-class SettingsUI : public content::WebUIController {
+class SettingsUI :
+#if !defined(OS_CHROMEOS)
+ // chrome://settings/manageProfile which only exists on !OS_CHROMEOS
+ // requires mojo bindings.
+ public ui::MojoWebUIController,
+ public customize_themes::mojom::CustomizeThemesHandlerFactory
+#else // !defined(OS_CHROMEOS)
+ public content::WebUIController
+#endif // defined(OS_CHROMEOS)
+{
public:
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
@@ -32,7 +54,14 @@ class SettingsUI : public content::WebUIController {
// Initializes the WebUI message handlers for CrOS-specific settings that are
// still shown in the browser settings UI.
void InitBrowserSettingsWebUIHandlers();
-#endif // defined(OS_CHROMEOS)
+#else // defined(OS_CHROMEOS)
+ // 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)
private:
void AddSettingsPageUIHandler(
@@ -41,8 +70,23 @@ class SettingsUI : public content::WebUIController {
// Makes a request to show a HaTS survey.
void TryShowHatsSurveyWithTimeout();
+#if !defined(OS_CHROMEOS)
+ // customize_themes::mojom::CustomizeThemesHandlerFactory:
+ void CreateCustomizeThemesHandler(
+ mojo::PendingRemote<customize_themes::mojom::CustomizeThemesClient>
+ pending_client,
+ mojo::PendingReceiver<customize_themes::mojom::CustomizeThemesHandler>
+ pending_handler) override;
+
+ std::unique_ptr<ChromeCustomizeThemesHandler> customize_themes_handler_;
+ mojo::Receiver<customize_themes::mojom::CustomizeThemesHandlerFactory>
+ customize_themes_factory_receiver_;
+#endif // !defined(OS_CHROMEOS)
+
WebuiLoadTimer webui_load_timer_;
+ WEB_UI_CONTROLLER_TYPE_DECL();
+
DISALLOW_COPY_AND_ASSIGN(SettingsUI);
};
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 721c9aa404a..ed707ea9cfd 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
@@ -52,6 +52,7 @@ base::string16 GetHelpUrlWithBoard(const std::string& original_url) {
void AddCaptionSubpageStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"captionsTitle", IDS_SETTINGS_CAPTIONS},
+ {"captionsSubtitle", IDS_SETTINGS_CAPTIONS_SUBTITLE},
{"captionsSettings", IDS_SETTINGS_CAPTIONS_SETTINGS},
{"captionsPreview", IDS_SETTINGS_CAPTIONS_PREVIEW},
{"captionsTextSize", IDS_SETTINGS_CAPTIONS_TEXT_SIZE},
@@ -143,16 +144,9 @@ void AddSyncAccountControlStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_PEOPLE_SYNC_PASSWORDS_NOT_WORKING},
{"peopleSignOut", IDS_SETTINGS_PEOPLE_SIGN_OUT},
{"useAnotherAccount", IDS_SETTINGS_PEOPLE_SYNC_ANOTHER_ACCOUNT},
+ {"syncAdvancedPageTitle", IDS_SETTINGS_NEW_SYNC_ADVANCED_PAGE_TITLE},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
- if (base::FeatureList::IsEnabled(features::kSyncSetupFriendlySettings)) {
- html_source->AddLocalizedString("syncAdvancedPageTitle",
- IDS_SETTINGS_NEW_SYNC_ADVANCED_PAGE_TITLE);
-
- } else {
- html_source->AddLocalizedString("syncAdvancedPageTitle",
- IDS_SETTINGS_SYNC_ADVANCED_PAGE_TITLE);
- }
}
#if defined(OS_CHROMEOS)
@@ -201,6 +195,8 @@ void AddSyncPageStrings(content::WebUIDataSource* html_source) {
{"syncSetupCancelDialogBody", IDS_SETTINGS_SYNC_SETUP_CANCEL_DIALOG_BODY},
{"personalizeGoogleServicesTitle",
IDS_SETTINGS_PERSONALIZE_GOOGLE_SERVICES_TITLE},
+ {"manageSyncedDataTitle",
+ IDS_SETTINGS_NEW_MANAGE_SYNCED_DATA_TITLE_UNIFIED_CONSENT},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings);
@@ -234,15 +230,6 @@ void AddSyncPageStrings(content::WebUIDataSource* html_source) {
#else
base::ASCIIToUTF16(chrome::kSyncEncryptionHelpURL)));
#endif
- if (base::FeatureList::IsEnabled(features::kSyncSetupFriendlySettings)) {
- html_source->AddLocalizedString(
- "manageSyncedDataTitle",
- IDS_SETTINGS_NEW_MANAGE_SYNCED_DATA_TITLE_UNIFIED_CONSENT);
- } else {
- html_source->AddLocalizedString(
- "manageSyncedDataTitle",
- IDS_SETTINGS_MANAGE_SYNCED_DATA_TITLE_UNIFIED_CONSENT);
- }
}
void AddNearbyShareData(content::WebUIDataSource* html_source) {
@@ -252,13 +239,12 @@ void AddNearbyShareData(content::WebUIDataSource* html_source) {
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_ROW_TITLE},
{"nearbyShareDeviceNameDialogTitle",
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_DIALOG_TITLE},
- {"nearbyShareDeviceNameDialogInputLabel",
- IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_INPUT_LABEL},
{"nearbyShareEditDeviceName", IDS_SETTINGS_NEARBY_SHARE_EDIT_DEVICE_NAME},
{"nearbyShareDeviceNameAriaDescription",
IDS_SETTINGS_NEARBY_SHARE_DEVICE_NAME_ARIA_DESCRIPTION},
- {"editDataUsage", IDS_SETTINGS_NEARBY_SHARE_EDIT_DATA_USAGE},
- {"updateDataUsage", IDS_SETTINGS_NEARBY_SHARE_UPDATE_DATA_USAGE},
+ {"nearbyShareEditDataUsage", IDS_SETTINGS_NEARBY_SHARE_EDIT_DATA_USAGE},
+ {"nearbyShareUpdateDataUsage",
+ IDS_SETTINGS_NEARBY_SHARE_UPDATE_DATA_USAGE},
{"nearbyShareDataUsageDialogTitle",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_DIALOG_TITLE},
{"nearbyShareDataUsageWifiOnlyLabel",
@@ -278,7 +264,13 @@ void AddNearbyShareData(content::WebUIDataSource* html_source) {
{"nearbyShareDataUsageWifiOnlyEditButtonDescription",
IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_WIFI_ONLY_DESCRIPTION},
{"nearbyShareDataUsageOfflineEditButtonDescription",
- IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_OFFLINE_DESCRIPTION}};
+ IDS_SETTINGS_NEARBY_SHARE_DATA_USAGE_EDIT_BUTTON_OFFLINE_DESCRIPTION},
+ {"nearbyShareContactVisibilityRowTitle",
+ 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);
html_source->AddBoolean(
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 8f9bdf2ebb6..7a66411fe4f 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -60,11 +60,11 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/content_features.h"
-#include "content/public/common/origin_util.h"
#include "content/public/common/url_constants.h"
#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 "third_party/blink/public/common/page/page_zoom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/text/bytes_formatting.h"
@@ -313,7 +313,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) &&
- !content::IsOriginSecure(url)) {
+ !blink::network_utils::IsOriginSecure(url)) {
*out_error = l10n_util::GetStringUTF8(
IDS_SETTINGS_NOT_VALID_WEB_ADDRESS_FOR_CONTENT_TYPE);
return false;
@@ -355,8 +355,6 @@ std::string GetCookieSettingDescription(Profile* profile) {
auto content_setting =
map->GetDefaultContentSetting(ContentSettingsType::COOKIES, nullptr);
- bool block_third_party =
- profile->GetPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies);
auto control_mode = static_cast<content_settings::CookieControlsMode>(
profile->GetPrefs()->GetInteger(prefs::kCookieControlsMode));
@@ -368,20 +366,22 @@ std::string GetCookieSettingDescription(Profile* profile) {
GetNumCookieExceptionsOfTypes(
map, {ContentSetting::CONTENT_SETTING_ALLOW,
ContentSetting::CONTENT_SETTING_SESSION_ONLY}));
- } else if (block_third_party) {
- return l10n_util::GetStringUTF8(
- IDS_SETTINGS_SITE_SETTINGS_COOKIES_BLOCK_THIRD_PARTY);
- } else if (control_mode ==
- content_settings::CookieControlsMode::kIncognitoOnly) {
- return l10n_util::GetStringUTF8(
- IDS_SETTINGS_SITE_SETTINGS_COOKIES_BLOCK_THIRD_PARTY_INCOGNITO);
- } else {
- // We do not make a distinction between allow and clear on exit.
- return l10n_util::GetPluralStringFUTF8(
- IDS_SETTINGS_SITE_SETTINGS_COOKIES_ALLOW,
- GetNumCookieExceptionsOfTypes(map,
- {ContentSetting::CONTENT_SETTING_BLOCK}));
}
+ switch (control_mode) {
+ case content_settings::CookieControlsMode::kBlockThirdParty:
+ return l10n_util::GetStringUTF8(
+ IDS_SETTINGS_SITE_SETTINGS_COOKIES_BLOCK_THIRD_PARTY);
+ case content_settings::CookieControlsMode::kIncognitoOnly:
+ return l10n_util::GetStringUTF8(
+ IDS_SETTINGS_SITE_SETTINGS_COOKIES_BLOCK_THIRD_PARTY_INCOGNITO);
+ case content_settings::CookieControlsMode::kOff:
+ // We do not make a distinction between allow and clear on exit.
+ return l10n_util::GetPluralStringFUTF8(
+ IDS_SETTINGS_SITE_SETTINGS_COOKIES_ALLOW,
+ GetNumCookieExceptionsOfTypes(
+ map, {ContentSetting::CONTENT_SETTING_BLOCK}));
+ }
+ NOTREACHED();
}
} // namespace
@@ -530,10 +530,6 @@ void SiteSettingsHandler::OnJavascriptAllowed() {
// Listen for prefs that impact the effective cookie setting
pref_change_registrar_->Add(
- prefs::kBlockThirdPartyCookies,
- base::Bind(&SiteSettingsHandler::SendCookieSettingDescription,
- base::Unretained(this)));
- pref_change_registrar_->Add(
prefs::kCookieControlsMode,
base::Bind(&SiteSettingsHandler::SendCookieSettingDescription,
base::Unretained(this)));
@@ -551,7 +547,6 @@ void SiteSettingsHandler::OnJavascriptDisallowed() {
chooser_observer_.RemoveAll();
host_zoom_map_subscription_.reset();
pref_change_registrar_->Remove(prefs::kBlockAutoplayEnabled);
- pref_change_registrar_->Remove(prefs::kBlockThirdPartyCookies);
pref_change_registrar_->Remove(prefs::kCookieControlsMode);
#if defined(OS_CHROMEOS)
pref_change_registrar_->Remove(prefs::kEnableDRM);
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 eba93151cc0..3ddf0c9f5ef 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
@@ -42,6 +42,7 @@
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
+#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/history/core/browser/history_service.h"
@@ -112,6 +113,10 @@ class FlashContentSettingsChangeWaiter : public content_settings::Observer {
: profile_(profile) {
HostContentSettingsMapFactory::GetForProfile(profile)->AddObserver(this);
}
+ FlashContentSettingsChangeWaiter(const FlashContentSettingsChangeWaiter&) =
+ delete;
+ FlashContentSettingsChangeWaiter& operator=(
+ const FlashContentSettingsChangeWaiter&) = delete;
~FlashContentSettingsChangeWaiter() override {
HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver(
this);
@@ -134,8 +139,6 @@ class FlashContentSettingsChangeWaiter : public content_settings::Observer {
Profile* profile_;
base::RunLoop run_loop_;
-
- DISALLOW_COPY_AND_ASSIGN(FlashContentSettingsChangeWaiter);
};
#endif
@@ -156,6 +159,9 @@ class ContentSettingSourceSetter {
host_content_settings_map_(
HostContentSettingsMapFactory::GetForProfile(profile)),
content_type_(content_type) {}
+ ContentSettingSourceSetter(const ContentSettingSourceSetter&) = delete;
+ ContentSettingSourceSetter& operator=(const ContentSettingSourceSetter&) =
+ delete;
void SetPolicyDefault(ContentSetting setting) {
prefs_->SetManagedPref(GetPrefNameForDefaultPermissionSetting(),
@@ -177,8 +183,6 @@ class ContentSettingSourceSetter {
sync_preferences::TestingPrefServiceSyncable* prefs_;
HostContentSettingsMap* host_content_settings_map_;
ContentSettingsType content_type_;
-
- DISALLOW_COPY_AND_ASSIGN(ContentSettingSourceSetter);
};
class SiteSettingsHandlerTest : public testing::Test {
@@ -1017,7 +1021,7 @@ TEST_F(SiteSettingsHandlerTest, IncognitoExceptions) {
{
base::ListValue set_args;
set_args.AppendString(kOriginToBlock); // Primary pattern.
- set_args.AppendString(kOriginToBlock); // Secondary pattern.
+ set_args.AppendString(std::string()); // Secondary pattern.
set_args.AppendString(kNotifications);
set_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
@@ -1045,7 +1049,7 @@ TEST_F(SiteSettingsHandlerTest, IncognitoExceptions) {
{
base::ListValue set_args;
set_args.AppendString(kOriginToBlock); // Primary pattern.
- set_args.AppendString(kOriginToBlock); // Secondary pattern.
+ set_args.AppendString(std::string()); // Secondary pattern.
set_args.AppendString(kNotifications);
set_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
@@ -1085,7 +1089,7 @@ TEST_F(SiteSettingsHandlerTest, ResetCategoryPermissionForEmbargoedOrigins) {
{
base::ListValue set_args;
set_args.AppendString(kOriginToBlock); // Primary pattern.
- set_args.AppendString(kOriginToBlock); // Secondary pattern.
+ set_args.AppendString(std::string()); // Secondary pattern.
set_args.AppendString(kNotifications);
set_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
@@ -1127,7 +1131,7 @@ TEST_F(SiteSettingsHandlerTest, ResetCategoryPermissionForEmbargoedOrigins) {
// Reset blocked origin.
base::ListValue reset_args;
reset_args.AppendString(kOriginToBlock);
- reset_args.AppendString(kOriginToBlock);
+ reset_args.AppendString(std::string());
reset_args.AppendString(kNotifications);
reset_args.AppendBoolean(false); // Incognito.
handler()->HandleResetCategoryPermissionForPattern(&reset_args);
@@ -1145,7 +1149,7 @@ TEST_F(SiteSettingsHandlerTest, ResetCategoryPermissionForEmbargoedOrigins) {
// Reset embargoed origin.
base::ListValue reset_args;
reset_args.AppendString(kOriginToEmbargo);
- reset_args.AppendString(kOriginToEmbargo);
+ reset_args.AppendString(std::string());
reset_args.AppendString(kNotifications);
reset_args.AppendBoolean(false); // Incognito.
handler()->HandleResetCategoryPermissionForPattern(&reset_args);
@@ -1168,7 +1172,7 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
// setting Google.com to blocked.
base::ListValue set_args;
set_args.AppendString(google); // Primary pattern.
- set_args.AppendString(google); // Secondary pattern.
+ set_args.AppendString(std::string()); // Secondary pattern.
set_args.AppendString(kNotifications);
set_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
@@ -1187,14 +1191,14 @@ TEST_F(SiteSettingsHandlerTest, Origins) {
get_exception_list_args.AppendString(kCallbackId);
get_exception_list_args.AppendString(kNotifications);
handler()->HandleGetExceptionList(&get_exception_list_args);
- ValidateOrigin(google, google, google, CONTENT_SETTING_BLOCK,
+ ValidateOrigin(google, "", google, CONTENT_SETTING_BLOCK,
site_settings::SiteSettingSource::kPreference, 2U);
{
// Reset things back to how they were.
base::ListValue reset_args;
reset_args.AppendString(google);
- reset_args.AppendString(google);
+ reset_args.AppendString(std::string());
reset_args.AppendString(kNotifications);
reset_args.AppendBoolean(false); // Incognito.
base::HistogramTester histograms;
@@ -1226,7 +1230,7 @@ TEST_F(SiteSettingsHandlerTest, NotificationPermissionRevokeUkm) {
{
base::ListValue set_notification_origin_args;
set_notification_origin_args.AppendString(google);
- set_notification_origin_args.AppendString(google);
+ set_notification_origin_args.AppendString("");
set_notification_origin_args.AppendString(kNotifications);
set_notification_origin_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW));
@@ -1238,7 +1242,7 @@ TEST_F(SiteSettingsHandlerTest, NotificationPermissionRevokeUkm) {
{
base::ListValue set_notification_origin_args;
set_notification_origin_args.AppendString(google);
- set_notification_origin_args.AppendString(google);
+ set_notification_origin_args.AppendString("");
set_notification_origin_args.AppendString(kNotifications);
set_notification_origin_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
@@ -1304,7 +1308,7 @@ TEST_F(SiteSettingsHandlerTest, MAYBE_DefaultSettingSource) {
base::ListValue set_notification_pattern_args;
set_notification_pattern_args.AppendString("[*.]google.com");
- set_notification_pattern_args.AppendString("*");
+ set_notification_pattern_args.AppendString("");
set_notification_pattern_args.AppendString(kNotifications);
set_notification_pattern_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW));
@@ -1318,7 +1322,7 @@ TEST_F(SiteSettingsHandlerTest, MAYBE_DefaultSettingSource) {
base::ListValue set_notification_origin_args;
set_notification_origin_args.AppendString(google);
- set_notification_origin_args.AppendString(google);
+ set_notification_origin_args.AppendString("");
set_notification_origin_args.AppendString(kNotifications);
set_notification_origin_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_BLOCK));
@@ -1476,7 +1480,8 @@ TEST_F(SiteSettingsHandlerTest, ExceptionHelpers) {
ContentSettingsPattern::FromString("[*.]google.com");
std::unique_ptr<base::DictionaryValue> exception =
site_settings::GetExceptionForPage(
- pattern, pattern, pattern.ToString(), CONTENT_SETTING_BLOCK,
+ pattern, ContentSettingsPattern::Wildcard(), pattern.ToString(),
+ CONTENT_SETTING_BLOCK,
site_settings::SiteSettingSourceToString(
site_settings::SiteSettingSource::kPreference),
false);
@@ -1610,7 +1615,10 @@ class SiteSettingsHandlerInfobarTest : public BrowserWithTestWindowTest {
SiteSettingsHandlerInfobarTest()
: kNotifications(site_settings::ContentSettingsTypeToGroupName(
ContentSettingsType::NOTIFICATIONS)) {}
-
+ SiteSettingsHandlerInfobarTest(const SiteSettingsHandlerInfobarTest&) =
+ delete;
+ SiteSettingsHandlerInfobarTest& operator=(
+ const SiteSettingsHandlerInfobarTest&) = delete;
void SetUp() override {
BrowserWithTestWindowTest::SetUp();
handler_ = std::make_unique<SiteSettingsHandler>(profile(), app_registrar_);
@@ -1665,8 +1673,6 @@ class SiteSettingsHandlerInfobarTest : public BrowserWithTestWindowTest {
std::unique_ptr<SiteSettingsHandler> handler_;
std::unique_ptr<BrowserWindow> window2_;
std::unique_ptr<Browser> browser2_;
-
- DISALLOW_COPY_AND_ASSIGN(SiteSettingsHandlerInfobarTest);
};
TEST_F(SiteSettingsHandlerInfobarTest, SettingPermissionsTriggersInfobar) {
@@ -1825,7 +1831,7 @@ TEST_F(SiteSettingsHandlerTest, SessionOnlyException) {
const std::string uma_base("WebsiteSettings.Menu.PermissionChanged");
base::ListValue set_args;
set_args.AppendString(google_with_port); // Primary pattern.
- set_args.AppendString(google_with_port); // Secondary pattern.
+ set_args.AppendString(std::string()); // Secondary pattern.
set_args.AppendString(kCookies);
set_args.AppendString(
content_settings::ContentSettingToString(CONTENT_SETTING_SESSION_ONLY));
@@ -2498,7 +2504,6 @@ TEST_F(SiteSettingsHandlerTest, CookieSettingDescription) {
IDS_SETTINGS_SITE_SETTINGS_COOKIES_BLOCK_THIRD_PARTY_INCOGNITO);
// Enforce expected default profile setting.
- profile()->GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, false);
profile()->GetPrefs()->SetInteger(
prefs::kCookieControlsMode,
static_cast<int>(content_settings::CookieControlsMode::kIncognitoOnly));
@@ -2526,7 +2531,9 @@ TEST_F(SiteSettingsHandlerTest, CookieSettingDescription) {
const int kContentSettingListenerIndex = 2;
// Check updates are working,
- profile()->GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, true);
+ profile()->GetPrefs()->SetInteger(
+ prefs::kCookieControlsMode,
+ static_cast<int>(content_settings::CookieControlsMode::kBlockThirdParty));
expected_call_index += kPrefListenerIndex;
ValidateCookieSettingUpdate(kBlockThirdParty, expected_call_index);
@@ -2536,10 +2543,6 @@ TEST_F(SiteSettingsHandlerTest, CookieSettingDescription) {
ValidateCookieSettingUpdate(kBlocked(0), expected_call_index);
// Check changes which do not affect the effective cookie setting.
- profile()->GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, false);
- expected_call_index += kPrefListenerIndex;
- ValidateCookieSettingUpdate(kBlocked(0), expected_call_index);
-
profile()->GetPrefs()->SetInteger(
prefs::kCookieControlsMode,
static_cast<int>(content_settings::CookieControlsMode::kOff));
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 32c1db01bda..d8c3c135ab3 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_helper.cc
@@ -148,6 +148,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
{ContentSettingsType::STORAGE_ACCESS, nullptr},
{ContentSettingsType::CAMERA_PAN_TILT_ZOOM, nullptr},
{ContentSettingsType::INSECURE_PRIVATE_NETWORK, nullptr},
+ {ContentSettingsType::PERMISSION_AUTOREVOCATION_DATA, nullptr},
};
static_assert(base::size(kContentSettingsTypeGroupNames) ==
// ContentSettingsType starts at -1, so add 1 here.
@@ -285,10 +286,9 @@ bool PatternAppliesToSingleOrigin(const ContentSettingPatternSource& pattern) {
// Default settings and other patterns apply to multiple origins.
if (url::Origin::Create(url).opaque())
return false;
- // Embedded content settings only when |url| is embedded in another origin, so
- // ignore non-wildcard secondary patterns that are different to the primary.
- if (pattern.primary_pattern != pattern.secondary_pattern &&
- pattern.secondary_pattern != ContentSettingsPattern::Wildcard()) {
+ // Embedded content settings only match when |url| is embedded in another
+ // origin, so ignore non-wildcard secondary patterns.
+ if (pattern.secondary_pattern != ContentSettingsPattern::Wildcard()) {
return false;
}
return true;
diff --git a/chromium/chrome/browser/ui/webui/signin/OWNERS b/chromium/chrome/browser/ui/webui/signin/OWNERS
index 74b64b88981..1c786a84ea9 100644
--- a/chromium/chrome/browser/ui/webui/signin/OWNERS
+++ b/chromium/chrome/browser/ui/webui/signin/OWNERS
@@ -1,8 +1,12 @@
+file://components/signin/OWNERS
+
+# For ChromeOS changes
achuith@chromium.org
-msarda@chromium.org
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
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 0de6e4ff302..2ea56f5262d 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
@@ -13,11 +13,13 @@
#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/ui/signin/profile_colors_util.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
+#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"
@@ -36,7 +38,6 @@ DiceWebSigninInterceptHandler::DiceWebSigninInterceptHandler(
base::OnceCallback<void(bool)> callback)
: bubble_parameters_(bubble_parameters), callback_(std::move(callback)) {
DCHECK(callback_);
- DCHECK_NE(intercepted_account().account_id, primary_account().account_id);
}
DiceWebSigninInterceptHandler::~DiceWebSigninInterceptHandler() = default;
@@ -159,6 +160,13 @@ base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
parameters.SetStringKey("bodyText", GetBodyText());
parameters.SetKey("interceptedAccount",
GetAccountInfoValue(intercepted_account()));
+ parameters.SetStringKey("headerBackgroundColor",
+ color_utils::SkColorToRgbaString(
+ bubble_parameters_.profile_highlight_color));
+ parameters.SetStringKey(
+ "headerTextColor",
+ color_utils::SkColorToRgbaString(GetProfileForegroundTextColor(
+ bubble_parameters_.profile_highlight_color)));
return parameters;
}
@@ -186,9 +194,8 @@ std::string DiceWebSigninInterceptHandler::GetBodyTitle() {
return l10n_util::GetStringUTF8(
IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_TITLE);
case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch:
- // This interception bubble is not implemented yet.
- NOTREACHED();
- return "";
+ // TODO: use localized string once it's available.
+ return "Switch profile";
}
}
@@ -215,8 +222,10 @@ std::string DiceWebSigninInterceptHandler::GetBodyText() {
IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC,
base::UTF8ToUTF16(intercepted_account().given_name));
case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch:
- // This interception bubble is not implemented yet.
- NOTREACHED();
- return "";
+ // TODO: use localized string once it's available.
+ return base::StringPrintf(
+ "This account is already signed in in a different profile. Would "
+ "you like to switch to %s's profile?",
+ intercepted_account().given_name.c_str());
}
}
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 f0c5041f83b..43491e922ff 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,7 +7,6 @@
#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/ui/signin/profile_colors_util.h"
#include "chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
@@ -18,7 +17,6 @@
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/webui/web_ui_util.h"
-#include "ui/gfx/color_utils.h"
#include "ui/resources/grit/webui_resources.h"
DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
@@ -34,15 +32,6 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS);
source->AddResourcePath("signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS);
- Profile* profile = Profile::FromWebUI(web_ui);
- SkColor background_color =
- GetThemeColorsForProfile(profile).profile_highlight_color;
- source->AddString("headerBackgroundColor",
- color_utils::SkColorToRgbaString(background_color));
- source->AddString("headerTextColor",
- color_utils::SkColorToRgbaString(
- GetProfileForegroundTextColor(background_color)));
-
// Localized strings.
source->UseStringsJs();
source->EnableReplaceI18nInJS();
@@ -62,7 +51,7 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER);
source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER);
- content::WebUIDataSource::Add(profile, source);
+ content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
DiceWebSigninInterceptUI::~DiceWebSigninInterceptUI() = default;
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 e112feb4238..c41be39bb55 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
@@ -16,6 +16,8 @@
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.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"
@@ -86,7 +88,8 @@ GURL GetInlineLoginUrl(const std::string& email,
source == InlineLoginDialogChromeOS::Source::kArc) {
return GURL(chrome::kChromeUIAccountManagerErrorURL);
}
- return GetUrlWithEmailParam(chrome::kChromeUIEDUCoexistenceLoginURL, email);
+ return GetUrlWithEmailParam(
+ SupervisedUserService::GetEduCoexistenceLoginUrl(), email);
}
} // namespace
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 4d1fdaad6f9..c3314ce1042 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
@@ -26,6 +26,7 @@
#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_service.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/identity_manager.h"
@@ -46,10 +47,6 @@ std::string AnonymizeAccountEmail(const std::string& email) {
return result + "@example.com";
}
-bool GaiaActionButtonsEnabled() {
- return base::FeatureList::IsEnabled(chromeos::features::kGaiaActionButtons);
-}
-
// Returns a base64-encoded hash code of "signin_scoped_device_id:gaia_id".
std::string GetAccountDeviceId(const std::string& signin_scoped_device_id,
const std::string& gaia_id) {
@@ -99,6 +96,7 @@ class SigninHelper : public GaiaAuthConsumer {
: 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) {
@@ -151,6 +149,10 @@ class SigninHelper : public GaiaAuthConsumer {
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_;
@@ -160,6 +162,7 @@ class SigninHelper : public GaiaAuthConsumer {
chromeos::AccountManager::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_;
@@ -207,9 +210,8 @@ class ChildSigninHelper : public SigninHelper {
DCHECK(!secondary_account_consent_logger_);
secondary_account_consent_logger_ =
std::make_unique<SecondaryAccountConsentLogger>(
- identity_manager_, GetAccountManager()->GetUrlLoaderFactory(),
- pref_service_, GetEmail(), parent_obfuscated_gaia_id_,
- re_auth_proof_token_,
+ identity_manager_, GetUrlLoaderFactory(), pref_service_, GetEmail(),
+ parent_obfuscated_gaia_id_, re_auth_proof_token_,
base::BindOnce(&ChildSigninHelper::OnConsentLogged,
weak_ptr_factory_.GetWeakPtr(),
result.refresh_token));
@@ -280,12 +282,15 @@ void InlineLoginHandlerChromeOS::SetExtraInitParams(
const GURL& url = gaia_urls->embedded_setup_chromeos_url(2U);
params.SetKey("gaiaPath", base::Value(url.path().substr(1)));
+ params.SetKey(
+ "platformVersion",
+ base::Value(version_loader::GetVersion(version_loader::VERSION_SHORT)));
params.SetKey("constrained", base::Value("1"));
params.SetKey("flow", base::Value(GetInlineLoginFlowName(
Profile::FromWebUI(web_ui()),
params.FindStringKey("email"))));
params.SetBoolean("dontResizeNonEmbeddedPages", true);
- params.SetBoolean("enableGaiaActionButtons", GaiaActionButtonsEnabled());
+ params.SetBoolean("enableGaiaActionButtons", true);
// For in-session login flows, request Gaia to ignore third party SAML IdP SSO
// redirection policies (and redirect to SAML IdPs by default), otherwise some
@@ -338,8 +343,8 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const std::string& email,
InlineLoginDialogChromeOS::EduCoexistenceFlowResult::kFlowCompleted);
// ChildSigninHelper deletes itself after its work is done.
new ChildSigninHelper(
- account_manager, close_dialog_closure_,
- account_manager->GetUrlLoaderFactory(), gaia_id, email, auth_code,
+ account_manager, close_dialog_closure_, profile->GetURLLoaderFactory(),
+ gaia_id, email, auth_code,
GetAccountDeviceId(GetSigninScopedDeviceIdForProfile(profile), gaia_id),
identity_manager, profile->GetPrefs(), *parentId, *rapt);
return;
@@ -347,8 +352,8 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const std::string& email,
// SigninHelper deletes itself after its work is done.
new SigninHelper(
- account_manager, close_dialog_closure_,
- account_manager->GetUrlLoaderFactory(), gaia_id, email, auth_code,
+ account_manager, close_dialog_closure_, profile->GetURLLoaderFactory(),
+ gaia_id, email, auth_code,
GetAccountDeviceId(GetSigninScopedDeviceIdForProfile(profile), gaia_id));
}
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 2cd1a6274f1..367193bce49 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
@@ -367,7 +367,7 @@ void InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened(
LocalAuth::SetLocalAuthCredentials(profile_, password_);
}
-#if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED)
+#if defined(PASSWORD_REUSE_DETECTION_ENABLED)
if (!password_.empty()) {
scoped_refptr<password_manager::PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile_,
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 33c2b7678d3..210032a7b0d 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
@@ -129,12 +129,22 @@ content::WebUIDataSource* CreateWebUIDataSource() {
{"edu_login_parent_info.js", IDR_EDU_LOGIN_EDU_LOGIN_PARENT_INFO_JS},
{"edu_login_signin.js", IDR_EDU_LOGIN_EDU_LOGIN_SIGNIN_JS},
{"edu_login_error.js", IDR_EDU_LOGIN_EDU_LOGIN_ERROR_JS},
+ // Resources for the server-based edu coexistence flow.
+ {"edu-coexistence", IDR_EDU_COEXISTENCE_EDU_COEXISTENCE_HTML},
+ {"edu_coexistence_app.js", IDR_EDU_COEXISTENCE_EDU_COEXISTENCE_APP_JS},
+ {"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},
+
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
{"googleg.svg", IDR_ACCOUNT_MANAGER_WELCOME_GOOGLE_LOGO_SVG},
#endif
{"family_link_logo.svg", IDR_FAMILY_LINK_LOGO_SVG},
#endif // defined(OS_CHROMEOS)
};
+
webui::AddResourcePathsBulk(source, kResources);
source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE);
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 77f3d7f8f49..99a690256e8 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
@@ -103,10 +103,13 @@ void LoginUIService::DisplayLoginResult(Browser* browser,
last_login_result_ = error_message;
last_login_error_email_ = email;
if (!error_message.empty()) {
- if (browser)
+ if (browser) {
browser->signin_view_controller()->ShowModalSigninErrorDialog();
- else
+ } else if (profile_->GetPath() == UserManager::GetSigninProfilePath()) {
UserManagerProfileDialog::DisplayErrorMessage();
+ } else {
+ LOG(ERROR) << "Unable to show Login error message: " << error_message;
+ }
} else if (browser) {
browser->window()->ShowAvatarBubbleFromAvatarButton(
BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN,
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 abfae488494..c34e2f3add6 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
@@ -47,6 +47,11 @@ void ProfileCreationCustomizeThemesHandler::ApplyChromeTheme(int32_t id) {
remote_client_->SetTheme(std::move(theme));
}
+void ProfileCreationCustomizeThemesHandler::InitializeTheme() {
+ // Do nothing.
+ // The profile picker initializes the theme from JavaScript.
+}
+
void ProfileCreationCustomizeThemesHandler::GetChromeThemes(
GetChromeThemesCallback callback) {
std::vector<customize_themes::mojom::ChromeThemePtr> themes;
diff --git a/chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.h b/chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.h
index d84830c043e..3b5d6cf45a7 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/profile_creation_customize_themes_handler.h
@@ -27,6 +27,7 @@ class ProfileCreationCustomizeThemesHandler
void ApplyAutogeneratedTheme(const SkColor& frame_color) override;
void ApplyDefaultTheme() override;
void ApplyChromeTheme(int32_t id) override;
+ void InitializeTheme() override;
void GetChromeThemes(GetChromeThemesCallback callback) override;
void ConfirmThemeChanges() override;
void RevertThemeChanges() override;
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 44585a46709..c2d3832f7e7 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.cc
@@ -41,7 +41,7 @@
#include "ui/gfx/image/image.h"
namespace {
-const size_t kAvatarIconSize = 74;
+const size_t kProfileCardAvatarSize = 74;
const size_t kProfileCreationAvatarSize = 100;
constexpr int kDefaultThemeColorId = -1;
@@ -98,7 +98,8 @@ base::Value GetAutogeneratedProfileThemeInfoValue(int color_id,
base::Optional<SkColor> color,
SkColor frame_color,
SkColor active_tab_color,
- SkColor frame_text_color) {
+ SkColor frame_text_color,
+ int avatar_icon_size) {
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetIntKey("colorId", color_id);
if (color.has_value())
@@ -111,14 +112,13 @@ base::Value GetAutogeneratedProfileThemeInfoValue(int color_id,
color_utils::SkColorToRgbaString(frame_text_color));
gfx::Image icon = profiles::GetPlaceholderAvatarIconWithColors(
/*fill_color=*/frame_color,
- /*stroke_color=*/GetAvatarStrokeColor(frame_color),
- kProfileCreationAvatarSize);
+ /*stroke_color=*/GetAvatarStrokeColor(frame_color), avatar_icon_size);
dict.SetStringKey("themeGenericAvatar",
webui::GetBitmapDataUrl(icon.AsBitmap()));
return dict;
}
-base::Value CreateDefaultProfileThemeInfo() {
+base::Value CreateDefaultProfileThemeInfo(int avatar_icon_size) {
bool dark_mode =
ui::NativeTheme::GetInstanceForNativeUi()->ShouldUseDarkColors();
SkColor frame_color = ThemeProperties::GetDefaultColor(
@@ -130,16 +130,19 @@ base::Value CreateDefaultProfileThemeInfo() {
/*incognito=*/false, dark_mode);
return GetAutogeneratedProfileThemeInfoValue(
kDefaultThemeColorId, base::nullopt, frame_color, active_tab_color,
- frame_text_color);
+ frame_text_color, avatar_icon_size);
}
-base::Value CreateAutogeneratedProfileThemeInfo(int color_id, SkColor color) {
+base::Value CreateAutogeneratedProfileThemeInfo(int color_id,
+ SkColor color,
+ int avatar_icon_size) {
auto theme_colors = GetAutogeneratedThemeColors(color);
SkColor frame_color = theme_colors.frame_color;
SkColor active_tab_color = theme_colors.active_tab_color;
SkColor frame_text_color = theme_colors.frame_text_color;
return GetAutogeneratedProfileThemeInfoValue(
- color_id, color, frame_color, active_tab_color, frame_text_color);
+ color_id, color, frame_color, active_tab_color, frame_text_color,
+ avatar_icon_size);
}
} // namespace
@@ -150,6 +153,16 @@ ProfilePickerHandler::~ProfilePickerHandler() {
OnJavascriptDisallowed();
}
+void ProfilePickerHandler::EnableStartupMetrics() {
+ DCHECK(creation_time_on_startup_.is_null());
+ content::WebContents* contents = web_ui()->GetWebContents();
+ if (contents->GetVisibility() == content::Visibility::VISIBLE) {
+ // Only record paint event if the window is visible.
+ creation_time_on_startup_ = base::TimeTicks::Now();
+ Observe(web_ui()->GetWebContents());
+ }
+}
+
void ProfilePickerHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"mainViewInitialize",
@@ -212,6 +225,14 @@ void ProfilePickerHandler::OnJavascriptDisallowed() {
void ProfilePickerHandler::HandleMainViewInitialize(
const base::ListValue* args) {
+ if (!creation_time_on_startup_.is_null() && !main_view_initialized_) {
+ // This function can be called multiple times if the page is reloaded. The
+ // histogram is only recorded once.
+ main_view_initialized_ = true;
+ base::UmaHistogramTimes("ProfilePicker.StartupTime.MainViewInitialized",
+ base::TimeTicks::Now() - creation_time_on_startup_);
+ }
+
AllowJavascript();
PushProfilesList();
}
@@ -275,8 +296,10 @@ void ProfilePickerHandler::HandleGetNewProfileSuggestedThemeInfo(
CHECK_EQ(1U, args->GetSize());
const base::Value& callback_id = args->GetList()[0];
chrome_colors::ColorInfo color_info = GenerateNewProfileColor();
- base::Value dict =
- CreateAutogeneratedProfileThemeInfo(color_info.id, color_info.color);
+ int avatar_icon_size =
+ kProfileCreationAvatarSize * web_ui()->GetDeviceScaleFactor();
+ base::Value dict = CreateAutogeneratedProfileThemeInfo(
+ color_info.id, color_info.color, avatar_icon_size);
ResolveJavascriptCallback(callback_id, std::move(dict));
}
@@ -288,17 +311,20 @@ void ProfilePickerHandler::HandleGetProfileThemeInfo(
const base::Value& user_theme_choice = args->GetList()[1];
int color_id = user_theme_choice.FindIntKey("colorId").value();
base::Optional<SkColor> color = user_theme_choice.FindDoubleKey("color");
+ int avatar_icon_size =
+ kProfileCreationAvatarSize * web_ui()->GetDeviceScaleFactor();
base::Value dict;
switch (color_id) {
case kDefaultThemeColorId:
- dict = CreateDefaultProfileThemeInfo();
+ dict = CreateDefaultProfileThemeInfo(avatar_icon_size);
break;
case kManuallyPickedColorId:
- dict = CreateAutogeneratedProfileThemeInfo(color_id, *color);
+ dict = CreateAutogeneratedProfileThemeInfo(color_id, *color,
+ avatar_icon_size);
break;
default:
dict = CreateAutogeneratedProfileThemeInfo(
- color_id, *GetChromeColorColorById(color_id));
+ color_id, *GetChromeColorColorById(color_id), avatar_icon_size);
break;
}
ResolveJavascriptCallback(callback_id, std::move(dict));
@@ -475,7 +501,16 @@ void ProfilePickerHandler::OnProfileStatisticsReceived(
void ProfilePickerHandler::HandleLoadSignInProfileCreationFlow(
const base::ListValue* args) {
- // TODO(crbug.com/1063856): Add implementation.
+ DCHECK(args->GetList()[0].is_int());
+ SkColor profile_color = args->GetList()[0].GetInt();
+ ProfilePicker::SwitchToSignIn(
+ profile_color, base::BindOnce(&ProfilePickerHandler::OnLoadSigninFailed,
+ weak_factory_.GetWeakPtr()));
+}
+
+void ProfilePickerHandler::OnLoadSigninFailed() {
+ if (IsJavascriptAllowed())
+ FireWebUIListener("load-signin-failed", base::Value());
}
void ProfilePickerHandler::OnSwitchToProfileComplete(
@@ -514,6 +549,8 @@ base::Value ProfilePickerHandler::GetProfilesList() {
g_browser_process->profile_manager()
->GetProfileAttributesStorage()
.GetAllProfilesAttributesSortedByName();
+ const int avatar_icon_size =
+ kProfileCardAvatarSize * web_ui()->GetDeviceScaleFactor();
for (const ProfileAttributesEntry* entry : entries) {
auto profile_entry = std::make_unique<base::DictionaryValue>();
profile_entry->SetKey("profilePath",
@@ -528,8 +565,9 @@ base::Value ProfilePickerHandler::GetProfilesList() {
profile_entry->SetString("userName", entry->GetUserName());
profile_entry->SetBoolPath("isManaged",
IsManaged(entry->GetHostedDomain()));
- gfx::Image icon = profiles::GetSizedAvatarIcon(
- entry->GetAvatarIcon(), true, kAvatarIconSize, kAvatarIconSize);
+ gfx::Image icon =
+ profiles::GetSizedAvatarIcon(entry->GetAvatarIcon(avatar_icon_size),
+ true, avatar_icon_size, avatar_icon_size);
std::string icon_url = webui::GetBitmapDataUrl(icon.AsBitmap());
profile_entry->SetString("avatarIcon", icon_url);
profiles_list.Append(std::move(profile_entry));
@@ -563,3 +601,19 @@ void ProfilePickerHandler::OnProfileNameChanged(
const base::string16& old_profile_name) {
PushProfilesList();
}
+
+void ProfilePickerHandler::DidFirstVisuallyNonEmptyPaint() {
+ DCHECK(!creation_time_on_startup_.is_null());
+ base::UmaHistogramTimes("ProfilePicker.StartupTime.FirstPaint",
+ base::TimeTicks::Now() - creation_time_on_startup_);
+ // Stop observing so that the histogram is only recorded once.
+ Observe(nullptr);
+}
+
+void ProfilePickerHandler::OnVisibilityChanged(content::Visibility visibility) {
+ // If the profile picker is hidden, the first paint will be delayed until the
+ // picker is visible again. Stop monitoring the first paint to avoid polluting
+ // the metrics.
+ if (visibility != content::Visibility::VISIBLE)
+ 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 816b2ab0f96..30e541606ad 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_handler.h
@@ -6,19 +6,26 @@
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_PROFILE_PICKER_HANDLER_H_
#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_statistics_common.h"
+#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui_message_handler.h"
// The handler for Javascript messages related to the profile picker main view.
class ProfilePickerHandler : public content::WebUIMessageHandler,
+ public content::WebContentsObserver,
public ProfileAttributesStorage::Observer {
public:
ProfilePickerHandler();
~ProfilePickerHandler() override;
+ // Enables the startup performance metrics. Should only be called when the
+ // profile picker is shown on startup.
+ void EnableStartupMetrics();
+
// content::WebUIMessageHandler:
void RegisterMessages() override;
void OnJavascriptAllowed() override;
@@ -39,6 +46,7 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
void HandleGetProfileThemeInfo(const base::ListValue* args);
void HandleCreateProfile(const base::ListValue* args);
+ void OnLoadSigninFailed();
void GatherProfileStatistics(Profile* profile);
void OnProfileStatisticsReceived(base::FilePath profile_path,
profiles::ProfileCategoryStats result);
@@ -66,6 +74,15 @@ class ProfilePickerHandler : public content::WebUIMessageHandler,
void OnProfileNameChanged(const base::FilePath& profile_path,
const base::string16& old_profile_name) override;
+ // content::WebContentsObserver:
+ void DidFirstVisuallyNonEmptyPaint() override;
+ void OnVisibilityChanged(content::Visibility visibility) override;
+
+ // 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;
+
base::WeakPtrFactory<ProfilePickerHandler> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ProfilePickerHandler);
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 eec87f04aae..c047c18c19a 100644
--- a/chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/profile_picker_ui.cc
@@ -16,15 +16,18 @@
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/browser_resources.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/profile_picker_resources.h"
#include "chrome/grit/profile_picker_resources_map.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/webui/mojo_web_ui_controller.h"
+#include "url/gurl.h"
namespace {
@@ -97,7 +100,7 @@ void AddStrings(content::WebUIDataSource* html_source) {
prefs::kBrowserShowProfilePickerOnStartup));
html_source->AddBoolean(
"signInProfileCreationFlowSupported",
- base::FeatureList::IsEnabled(features::kSignInProfileCreationFlow));
+ base::FeatureList::IsEnabled(features::kProfilesUIRevamp));
html_source->AddString("minimumPickerSize",
base::StringPrintf("%ipx", kMinimumPickerSizePx));
@@ -122,16 +125,52 @@ ProfilePickerUI::ProfilePickerUI(content::WebUI* web_ui)
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(chrome::kChromeUIProfilePickerHost);
- web_ui->AddMessageHandler(std::make_unique<ProfilePickerHandler>());
+ std::unique_ptr<ProfilePickerHandler> handler =
+ std::make_unique<ProfilePickerHandler>();
+ ProfilePickerHandler* raw_handler = handler.get();
+ web_ui->AddMessageHandler(std::move(handler));
+
+ if (web_ui->GetWebContents()->GetURL().query() ==
+ chrome::kChromeUIProfilePickerStartupQuery) {
+ raw_handler->EnableStartupMetrics();
+ }
std::string generated_path =
"@out_folder@/gen/chrome/browser/resources/signin/profile_picker/";
+
+ AddStrings(html_source);
+#if BUILDFLAG(OPTIMIZE_WEBUI)
+ webui::SetupBundledWebUIDataSource(
+ html_source, "profile_picker.js",
+ IDR_PROFILE_PICKER_PROFILE_PICKER_ROLLUP_JS,
+ IDR_PROFILE_PICKER_PROFILE_PICKER_HTML);
+ html_source->AddResourcePath("lazy_load.js",
+ IDR_PROFILE_PICKER_LAZY_LOAD_ROLLUP_JS);
+ html_source->AddResourcePath("shared.rollup.js",
+ IDR_PROFILE_PICKER_SHARED_ROLLUP_JS);
+ html_source->AddResourcePath("images/left_banner_image.svg",
+ IDR_PROFILE_PICKER_IMAGES_LEFT_BANNER_IMAGE);
+ html_source->AddResourcePath("images/right_banner_image.svg",
+ IDR_PROFILE_PICKER_IMAGES_RIGHT_BANNER_IMAGE);
+ html_source->AddResourcePath(
+ "images/dark_mode_left_banner_image.svg",
+ IDR_PROFILE_PICKER_IMAGES_DARK_MODE_LEFT_BANNER_IMAGE);
+ html_source->AddResourcePath(
+ "images/dark_mode_right_banner_image.svg",
+ IDR_PROFILE_PICKER_IMAGES_DARK_MODE_RIGHT_BANNER_IMAGE);
+ html_source->AddResourcePath(
+ "profile_creation_flow/images/banner_light_image.svg",
+ IDR_PROFILE_PICKER_PROFILE_CREATION_FLOW_IMAGES_BANNER_LIGHT_IMAGE);
+ html_source->AddResourcePath(
+ "profile_creation_flow/images/banner_dark_image.svg",
+ IDR_PROFILE_PICKER_PROFILE_CREATION_FLOW_IMAGES_BANNER_DARK_IMAGE);
+#else
+ html_source->AddResourcePath("signin_icons.js", IDR_SIGNIN_ICONS_JS);
webui::SetupWebUIDataSource(
html_source,
base::make_span(kProfilePickerResources, kProfilePickerResourcesSize),
generated_path, IDR_PROFILE_PICKER_PROFILE_PICKER_HTML);
- html_source->AddResourcePath("signin_icons.js", IDR_SIGNIN_ICONS_JS);
- AddStrings(html_source);
+#endif
content::WebUIDataSource::Add(profile, html_source);
}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/BUILD.gn b/chromium/chrome/browser/ui/webui/snippets_internals/BUILD.gn
deleted file mode 100644
index 8981f58301f..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals/BUILD.gn
+++ /dev/null
@@ -1,9 +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.
-
-import("//mojo/public/tools/bindings/mojom.gni")
-
-mojom("mojo_bindings") {
- sources = [ "snippets_internals.mojom" ]
-}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/OWNERS b/chromium/chrome/browser/ui/webui/snippets_internals/OWNERS
deleted file mode 100644
index 30aeea0a736..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-file://components/ntp_snippets/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/snippets_internals/snippets_internals.mojom b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
deleted file mode 100644
index 4f37896e8d9..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
+++ /dev/null
@@ -1,72 +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.
-
-module snippets_internals.mojom;
-
-struct SuggestionCategory {
- int64 categoryId;
- string categoryTitle;
- string status;
-
- array<SuggestionItem> suggestions;
- array<SuggestionItem> dismissedSuggestions;
-};
-
-struct SuggestionItem {
- string suggestionTitle;
- string suggestionId;
- string suggestionIdWithinCategory;
- string url;
- string faviconUrl;
- string snippet;
- string publishDate;
- string publisherName;
- float score;
-};
-
-interface PageHandlerFactory {
- CreatePageHandler(pending_remote<Page> page) =>
- (pending_remote<PageHandler> handler);
-};
-
-// Browser interface.
-interface PageHandler {
- // Populate properties about preferences/flags.
- GetGeneralProperties() => (map<string, string> properties);
-
- // Populate the properties for the user classifier.
- GetUserClassifierProperties() => (map<string, string> properties);
-
- // Clear stored properties for the user classifier.
- ClearUserClassifierProperties();
-
- // Get category ranker tuples (abritrary field/values).
- GetCategoryRankerProperties() => (map<string, string> properties);
-
- // Reload the current suggestions.
- ReloadSuggestions();
-
- // Clear cached suggestions.
- ClearCachedSuggestions();
-
- // Get the remote content suggestions.
- GetRemoteContentSuggestionsProperties() => (map<string, string> properties);
-
- // Fetch suggestions in background after the given delay.
- FetchSuggestionsInBackground(int64 delaySeconds) => ();
-
- // Download the last suggestions in json form.
- GetLastJson() => (string json);
-
- // Get the suggestions by category.
- GetSuggestionsByCategory() => (array<SuggestionCategory> categories);
-
- // Clear the dismissed suggestions.
- ClearDismissedSuggestions(int64 category);
-};
-
-// Frontend interface.
-interface Page {
- OnSuggestionsChanged();
-};
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
deleted file mode 100644
index 948043078e4..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
+++ /dev/null
@@ -1,363 +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/snippets_internals/snippets_internals_page_handler.h"
-
-#include <set>
-#include <string>
-#include <utility>
-
-#include "base/bind.h"
-#include "base/containers/flat_map.h"
-#include "base/feature_list.h"
-#include "base/i18n/time_formatting.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 "chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom.h"
-#include "chrome/common/pref_names.h"
-#include "components/ntp_snippets/category_info.h"
-#include "components/ntp_snippets/features.h"
-#include "components/ntp_snippets/pref_names.h"
-#include "components/ntp_snippets/remote/remote_suggestions_fetcher.h"
-#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
-#include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h"
-#include "components/ntp_snippets/user_classifier.h"
-#include "components/offline_pages/core/offline_page_feature.h"
-#include "components/variations/variations_associated_data.h"
-
-using ntp_snippets::Category;
-using ntp_snippets::CategoryInfo;
-using ntp_snippets::CategoryStatus;
-using ntp_snippets::ContentSuggestion;
-using ntp_snippets::RemoteSuggestionsProvider;
-using ntp_snippets::RemoteSuggestionsFetcher;
-using ntp_snippets::UserClassifier;
-
-namespace {
-/*
- Non-instance helper functions.
-*/
-
-std::set<variations::VariationID> GetSnippetsExperiments() {
- std::set<variations::VariationID> result;
- for (const base::Feature* feature : ntp_snippets::GetAllFeatures()) {
- base::FieldTrial* trial = base::FeatureList::GetFieldTrial(*feature);
- if (!trial || trial->GetGroupNameWithoutActivation().empty())
- continue;
-
- for (variations::IDCollectionKey key :
- {variations::GOOGLE_WEB_PROPERTIES,
- variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN,
- variations::GOOGLE_WEB_PROPERTIES_TRIGGER}) {
- const variations::VariationID id = variations::GetGoogleVariationID(
- key, trial->trial_name(), trial->group_name());
- if (id != variations::EMPTY_ID) {
- result.insert(id);
- }
- }
- }
- return result;
-}
-
-std::string BooleanToString(bool value) {
- return value ? "True" : "False";
-}
-
-std::string GetCategoryStatusName(CategoryStatus status) {
- switch (status) {
- case CategoryStatus::INITIALIZING:
- return "INITIALIZING";
- case CategoryStatus::AVAILABLE:
- return "AVAILABLE";
- case CategoryStatus::AVAILABLE_LOADING:
- return "AVAILABLE_LOADING";
- case CategoryStatus::NOT_PROVIDED:
- return "NOT_PROVIDED";
- case CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED:
- return "ALL_SUGGESTIONS_EXPLICITLY_DISABLED";
- case CategoryStatus::CATEGORY_EXPLICITLY_DISABLED:
- return "CATEGORY_EXPLICITLY_DISABLED";
- case CategoryStatus::LOADING_ERROR:
- return "LOADING_ERROR";
- }
- return std::string();
-}
-
-snippets_internals::mojom::SuggestionItemPtr PrepareContentSuggestionItem(
- const ContentSuggestion& suggestion,
- int index) {
- auto item = snippets_internals::mojom::SuggestionItem::New();
- item->suggestionTitle = base::UTF16ToUTF8(suggestion.title());
- item->suggestionIdWithinCategory = suggestion.id().id_within_category();
- item->suggestionId = "content-suggestion-" + base::NumberToString(index);
- item->url = suggestion.url().spec();
- item->faviconUrl = suggestion.url_with_favicon().spec();
- item->snippet = base::UTF16ToUTF8(suggestion.snippet_text());
- item->publishDate =
- base::UTF16ToUTF8(TimeFormatShortDateAndTime(suggestion.publish_date()));
- item->publisherName = base::UTF16ToUTF8(suggestion.publisher_name());
- item->score = suggestion.score();
-
- return item;
-}
-
-} // namespace
-
-// TODO: Add browser tests.
-SnippetsInternalsPageHandler::SnippetsInternalsPageHandler(
- mojo::PendingReceiver<snippets_internals::mojom::PageHandler> receiver,
- mojo::PendingRemote<snippets_internals::mojom::Page> page,
- ntp_snippets::ContentSuggestionsService* content_suggestions_service,
- PrefService* pref_service)
- : receiver_(this, std::move(receiver)),
- content_suggestions_service_observer_(this),
- content_suggestions_service_(content_suggestions_service),
- remote_suggestions_provider_(
- content_suggestions_service_
- ->remote_suggestions_provider_for_debugging()),
- pref_service_(pref_service),
- page_(std::move(page)) {}
-
-SnippetsInternalsPageHandler::~SnippetsInternalsPageHandler() {}
-
-/*
- Observer methods.
-*/
-
-void SnippetsInternalsPageHandler::OnNewSuggestions(Category category) {
- page_->OnSuggestionsChanged();
-}
-
-void SnippetsInternalsPageHandler::OnCategoryStatusChanged(
- Category category,
- CategoryStatus new_status) {
- page_->OnSuggestionsChanged();
-}
-
-void SnippetsInternalsPageHandler::OnSuggestionInvalidated(
- const ntp_snippets::ContentSuggestion::ID& suggestion_id) {
- page_->OnSuggestionsChanged();
-}
-
-void SnippetsInternalsPageHandler::OnFullRefreshRequired() {
- page_->OnSuggestionsChanged();
-}
-
-void SnippetsInternalsPageHandler::ContentSuggestionsServiceShutdown() {}
-
-/*
- Instance methods.
-*/
-
-void SnippetsInternalsPageHandler::GetGeneralProperties(
- GetGeneralPropertiesCallback callback) {
- auto properties = base::flat_map<std::string, std::string>();
- properties["flag-article-suggestions"] = BooleanToString(
- base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature));
- properties["flag-offlining-recent-pages-feature"] =
- BooleanToString(base::FeatureList::IsEnabled(
- offline_pages::kOffliningRecentPagesFeature));
-
- if (remote_suggestions_provider_) {
- const ntp_snippets::RemoteSuggestionsFetcher* fetcher =
- remote_suggestions_provider_->suggestions_fetcher_for_debugging();
- properties["switch-fetch-url"] = fetcher->GetFetchUrlForDebugging().spec();
- }
-
- std::set<variations::VariationID> ids = GetSnippetsExperiments();
- std::vector<std::string> string_ids;
- std::transform(
- ids.begin(), ids.end(), std::back_inserter(string_ids),
- [](variations::VariationID id) { return base::NumberToString(id); });
-
- properties["experiment-ids"] = base::JoinString(string_ids, ", ");
- std::move(callback).Run(properties);
-}
-
-void SnippetsInternalsPageHandler::GetUserClassifierProperties(
- GetUserClassifierPropertiesCallback callback) {
- auto properties = base::flat_map<std::string, std::string>();
- properties["user-class"] = content_suggestions_service_->user_classifier()
- ->GetUserClassDescriptionForDebugging();
- properties["avg-time-to-open-ntp"] = base::NumberToString(
- content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
- UserClassifier::Metric::NTP_OPENED));
- properties["avg-time-to-show"] = base::NumberToString(
- content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
- UserClassifier::Metric::SUGGESTIONS_SHOWN));
- properties["avg-time-to-use"] = base::NumberToString(
- content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
- UserClassifier::Metric::SUGGESTIONS_USED));
- std::move(callback).Run(properties);
-}
-
-void SnippetsInternalsPageHandler::ClearUserClassifierProperties() {
- content_suggestions_service_->user_classifier()
- ->ClearClassificationForDebugging();
-}
-
-void SnippetsInternalsPageHandler::GetCategoryRankerProperties(
- GetCategoryRankerPropertiesCallback callback) {
- auto properties = base::flat_map<std::string, std::string>();
- std::vector<ntp_snippets::CategoryRanker::DebugDataItem> data =
- content_suggestions_service_->category_ranker()->GetDebugData();
-
- for (const auto& item : data) {
- properties[item.label] = item.content;
- }
-
- std::move(callback).Run(properties);
-}
-
-void SnippetsInternalsPageHandler::ReloadSuggestions() {
- if (remote_suggestions_provider_) {
- remote_suggestions_provider_->ReloadSuggestions();
- }
-}
-
-void SnippetsInternalsPageHandler::ClearCachedSuggestions() {
- content_suggestions_service_->ClearAllCachedSuggestions();
- page_->OnSuggestionsChanged();
-}
-
-void SnippetsInternalsPageHandler::GetRemoteContentSuggestionsProperties(
- GetRemoteContentSuggestionsPropertiesCallback callback) {
- auto properties = base::flat_map<std::string, std::string>();
- if (remote_suggestions_provider_) {
- const std::string& status =
- remote_suggestions_provider_->suggestions_fetcher_for_debugging()
- ->GetLastStatusForDebugging();
- if (!status.empty()) {
- properties["remote-status"] = "Finished: " + status;
- properties["remote-authenticated"] =
- remote_suggestions_provider_->suggestions_fetcher_for_debugging()
- ->WasLastFetchAuthenticatedForDebugging()
- ? "Authenticated"
- : "Non-authenticated";
- }
- }
-
- base::Time time = base::Time::FromInternalValue(pref_service_->GetInt64(
- ntp_snippets::prefs::kLastSuccessfulBackgroundFetchTime));
- properties["last-background-fetch-time"] =
- base::UTF16ToUTF8(base::TimeFormatShortDateAndTime(time));
-
- std::move(callback).Run(properties);
-}
-
-void SnippetsInternalsPageHandler::FetchSuggestionsInBackground(
- int64_t delaySeconds,
- FetchSuggestionsInBackgroundCallback callback) {
- DCHECK(delaySeconds >= 0);
- suggestion_fetch_timer_.Start(
- FROM_HERE, base::TimeDelta::FromSeconds(delaySeconds),
- base::BindOnce(
- &SnippetsInternalsPageHandler::FetchSuggestionsInBackgroundImpl,
- weak_ptr_factory_.GetWeakPtr(), base::Passed(std::move(callback))));
-}
-
-void SnippetsInternalsPageHandler::FetchSuggestionsInBackgroundImpl(
- FetchSuggestionsInBackgroundCallback callback) {
- remote_suggestions_provider_->RefetchInTheBackground(
- RemoteSuggestionsProvider::FetchStatusCallback());
-
- std::move(callback).Run();
-}
-
-void SnippetsInternalsPageHandler::GetLastJson(GetLastJsonCallback callback) {
- std::string json;
- if (remote_suggestions_provider_) {
- const ntp_snippets::RemoteSuggestionsFetcher* fetcher =
- remote_suggestions_provider_->suggestions_fetcher_for_debugging();
- json = fetcher->GetLastJsonForDebugging();
- }
-
- std::move(callback).Run(json);
-}
-
-void SnippetsInternalsPageHandler::GetSuggestionsByCategory(
- GetSuggestionsByCategoryCallback callback) {
- CollectDismissedSuggestions(-1, std::move(callback),
- std::vector<ContentSuggestion>());
-}
-
-void SnippetsInternalsPageHandler::GetSuggestionsByCategoryImpl(
- GetSuggestionsByCategoryCallback callback) {
- std::vector<snippets_internals::mojom::SuggestionCategoryPtr> categories;
-
- int index = 0;
- for (Category category : content_suggestions_service_->GetCategories()) {
- CategoryStatus status =
- content_suggestions_service_->GetCategoryStatus(category);
- base::Optional<CategoryInfo> info =
- content_suggestions_service_->GetCategoryInfo(category);
- DCHECK(info);
- const std::vector<ContentSuggestion>& suggestions =
- content_suggestions_service_->GetSuggestionsForCategory(category);
-
- std::vector<snippets_internals::mojom::SuggestionItemPtr> items;
- for (const ContentSuggestion& suggestion : suggestions) {
- snippets_internals::mojom::SuggestionItemPtr item =
- PrepareContentSuggestionItem(suggestion, index++);
- items.push_back(std::move(item));
- }
-
- std::vector<snippets_internals::mojom::SuggestionItemPtr> dismissed_items;
- for (const ContentSuggestion& suggestion :
- dismissed_suggestions_[category]) {
- snippets_internals::mojom::SuggestionItemPtr item =
- PrepareContentSuggestionItem(suggestion, index++);
- dismissed_items.push_back(std::move(item));
- }
-
- auto suggestion_category =
- snippets_internals::mojom::SuggestionCategory::New();
- suggestion_category->categoryTitle = base::UTF16ToUTF8(info->title());
- suggestion_category->status = GetCategoryStatusName(status);
- suggestion_category->categoryId = category.id();
- suggestion_category->suggestions = std::move(items);
- suggestion_category->dismissedSuggestions = std::move(dismissed_items);
- categories.push_back(std::move(suggestion_category));
- }
-
- std::move(callback).Run(std::move(categories));
-}
-
-void SnippetsInternalsPageHandler::ClearDismissedSuggestions(
- int64_t category_id) {
- Category category = Category::FromIDValue(category_id);
- content_suggestions_service_->ClearDismissedSuggestionsForDebugging(category);
- page_->OnSuggestionsChanged();
-}
-
-void SnippetsInternalsPageHandler::CollectDismissedSuggestions(
- int last_index,
- GetSuggestionsByCategoryCallback callback,
- std::vector<ContentSuggestion> suggestions) {
- std::vector<Category> categories =
- content_suggestions_service_->GetCategories();
-
- // Populate our last category results.
- if (last_index > -1)
- dismissed_suggestions_[categories[last_index]] = std::move(suggestions);
-
- // Find the next category for this.
- for (size_t i = 0; i < categories.size(); i++) {
- // Continue the process in the next method call.
- if (last_index + 1 >= 0 && (size_t)last_index + 1 == i) {
- content_suggestions_service_->GetDismissedSuggestionsForDebugging(
- categories[i],
- base::BindOnce(
- &SnippetsInternalsPageHandler::CollectDismissedSuggestions,
- weak_ptr_factory_.GetWeakPtr(), i,
- base::Passed(std::move(callback))));
- return;
- }
- }
-
- // Call into impl once the dismissed categories have been collected.
- GetSuggestionsByCategoryImpl(std::move(callback));
-}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
deleted file mode 100644
index bf02e04c414..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
+++ /dev/null
@@ -1,103 +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_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_PAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_PAGE_HANDLER_H_
-
-#include <map>
-#include <vector>
-
-#include "base/macros.h"
-#include "base/scoped_observer.h"
-#include "base/timer/timer.h"
-#include "chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom.h"
-#include "components/ntp_snippets/content_suggestions_service.h"
-#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
-#include "components/prefs/pref_service.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"
-
-// TODO: Write tests for this.
-class SnippetsInternalsPageHandler
- : public snippets_internals::mojom::PageHandler,
- public ntp_snippets::ContentSuggestionsService::Observer {
- public:
- explicit SnippetsInternalsPageHandler(
- mojo::PendingReceiver<snippets_internals::mojom::PageHandler> receiver,
- mojo::PendingRemote<snippets_internals::mojom::Page> page,
- ntp_snippets::ContentSuggestionsService* content_suggestions_service,
- PrefService* pref_service);
- ~SnippetsInternalsPageHandler() override;
-
- // snippets_internals::mojom::PageHandler
- void GetGeneralProperties(GetGeneralPropertiesCallback) override;
- void GetUserClassifierProperties(
- GetUserClassifierPropertiesCallback) override;
- void ClearUserClassifierProperties() override;
- void GetCategoryRankerProperties(
- GetCategoryRankerPropertiesCallback) override;
- void ReloadSuggestions() override;
- void ClearCachedSuggestions() override;
- void GetRemoteContentSuggestionsProperties(
- GetRemoteContentSuggestionsPropertiesCallback) override;
- void FetchSuggestionsInBackground(
- int64_t,
- FetchSuggestionsInBackgroundCallback) override;
- void GetLastJson(GetLastJsonCallback) override;
- void GetSuggestionsByCategory(GetSuggestionsByCategoryCallback) override;
- void ClearDismissedSuggestions(int64_t) override;
-
- private:
- // ntp_snippets::ContentSuggestionsService::Observer:
- void OnNewSuggestions(ntp_snippets::Category category) override;
- void OnCategoryStatusChanged(
- ntp_snippets::Category category,
- ntp_snippets::CategoryStatus new_status) override;
- void OnSuggestionInvalidated(
- const ntp_snippets::ContentSuggestion::ID& suggestion_id) override;
- void OnFullRefreshRequired() override;
- void ContentSuggestionsServiceShutdown() override;
-
- void FetchSuggestionsInBackgroundImpl(FetchSuggestionsInBackgroundCallback);
- void GetSuggestionsByCategoryImpl(GetSuggestionsByCategoryCallback);
-
- // Misc. methods.
- void CollectDismissedSuggestions(
- int last_index,
- GetSuggestionsByCategoryCallback callback,
- std::vector<ntp_snippets::ContentSuggestion> suggestions);
-
- // Receiver from the mojo interface to concrete impl.
- mojo::Receiver<snippets_internals::mojom::PageHandler> receiver_;
-
- // Observer to notify frontend of dirty data.
- ScopedObserver<ntp_snippets::ContentSuggestionsService,
- ntp_snippets::ContentSuggestionsService::Observer>
- content_suggestions_service_observer_;
-
- // Services that provide the data & functionality.
- ntp_snippets::ContentSuggestionsService* content_suggestions_service_;
- ntp_snippets::RemoteSuggestionsProvider* remote_suggestions_provider_;
- PrefService* pref_service_;
-
- // Store dismissed suggestions in an instance variable during aggregation
- std::map<ntp_snippets::Category,
- std::vector<ntp_snippets::ContentSuggestion>,
- ntp_snippets::Category::CompareByID>
- dismissed_suggestions_;
-
- // Timers to delay actions.
- base::OneShotTimer suggestion_fetch_timer_;
-
- // Handle back to the page by which we can update.
- mojo::Remote<snippets_internals::mojom::Page> page_;
-
- base::WeakPtrFactory<SnippetsInternalsPageHandler> weak_ptr_factory_{this};
-
- DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsPageHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc
deleted file mode 100644
index f64bcef4886..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc
+++ /dev/null
@@ -1,70 +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/snippets_internals/snippets_internals_ui.h"
-
-#include <memory>
-#include <utility>
-
-#include "base/bind.h"
-#include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom.h"
-#include "chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/dev_ui_browser_resources.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "mojo/public/cpp/bindings/pending_remote.h"
-#include "services/network/public/mojom/content_security_policy.mojom.h"
-
-#if defined(OS_ANDROID)
-#include "chrome/browser/flags/android/chrome_feature_list.h"
-#endif
-
-SnippetsInternalsUI::SnippetsInternalsUI(content::WebUI* web_ui)
- : ui::MojoWebUIController(web_ui) {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUISnippetsInternalsHost);
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::ScriptSrc,
- "script-src chrome://resources 'self' 'unsafe-eval';");
- source->OverrideContentSecurityPolicy(
- network::mojom::CSPDirectiveName::TrustedTypes,
- "trusted-types jstemplate;");
- source->AddResourcePath("snippets_internals.css", IDR_SNIPPETS_INTERNALS_CSS);
- source->AddResourcePath("snippets_internals.js", IDR_SNIPPETS_INTERNALS_JS);
- source->AddResourcePath("snippets_internals.mojom-lite.js",
- IDR_SNIPPETS_INTERNALS_MOJOM_LITE_JS);
- source->SetDefaultResource(IDR_SNIPPETS_INTERNALS_HTML);
-
- Profile* profile = Profile::FromWebUI(web_ui);
- content_suggestions_service_ =
- ContentSuggestionsServiceFactory::GetInstance()->GetForProfile(profile);
- pref_service_ = profile->GetPrefs();
- content::WebUIDataSource::Add(profile, source);
-}
-
-WEB_UI_CONTROLLER_TYPE_IMPL(SnippetsInternalsUI)
-
-SnippetsInternalsUI::~SnippetsInternalsUI() {}
-
-void SnippetsInternalsUI::BindInterface(
- mojo::PendingReceiver<snippets_internals::mojom::PageHandlerFactory>
- receiver) {
- receiver_.reset();
-
- receiver_.Bind(std::move(receiver));
-}
-
-void SnippetsInternalsUI::CreatePageHandler(
- mojo::PendingRemote<snippets_internals::mojom::Page> page,
- CreatePageHandlerCallback callback) {
- DCHECK(page);
- mojo::PendingRemote<snippets_internals::mojom::PageHandler> handler;
- page_handler_ = std::make_unique<SnippetsInternalsPageHandler>(
- handler.InitWithNewPipeAndPassReceiver(), std::move(page),
- content_suggestions_service_, pref_service_);
-
- std::move(callback).Run(std::move(handler));
-}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h
deleted file mode 100644
index 2852762e68b..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h
+++ /dev/null
@@ -1,51 +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_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_UI_H_
-
-#include "base/macros.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom.h"
-#include "components/ntp_snippets/content_suggestions_service.h"
-#include "components/prefs/pref_service.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "mojo/public/cpp/bindings/pending_remote.h"
-#include "mojo/public/cpp/bindings/receiver.h"
-#include "ui/webui/mojo_web_ui_controller.h"
-
-class SnippetsInternalsPageHandler;
-
-// The implementation for the chrome://snippets-internals page.
-class SnippetsInternalsUI
- : public snippets_internals::mojom::PageHandlerFactory,
- public ui::MojoWebUIController {
- public:
- explicit SnippetsInternalsUI(content::WebUI* web_ui);
- ~SnippetsInternalsUI() override;
-
- void CreatePageHandler(
- mojo::PendingRemote<snippets_internals::mojom::Page> page,
- CreatePageHandlerCallback callback) override;
-
- // Instantiates the implementor of the mojom::PageHandlerFactory mojo
- // interface passing the pending receiver that will be internally bound.
- void BindInterface(
- mojo::PendingReceiver<snippets_internals::mojom::PageHandlerFactory>
- receiver);
-
- private:
- std::unique_ptr<SnippetsInternalsPageHandler> page_handler_;
- ntp_snippets::ContentSuggestionsService* content_suggestions_service_;
- PrefService* pref_service_;
-
- // Receiver from the mojo interface to concrete impl.
- mojo::Receiver<snippets_internals::mojom::PageHandlerFactory> receiver_{this};
-
- WEB_UI_CONTROLLER_TYPE_DECL();
-
- DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/tab_search/BUILD.gn b/chromium/chrome/browser/ui/webui/tab_search/BUILD.gn
index 092303f6942..ec9b1c3e16b 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/tab_search/BUILD.gn
@@ -6,4 +6,5 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojo_bindings") {
sources = [ "tab_search.mojom" ]
+ public_deps = [ "//mojo/public/mojom/base" ]
}
diff --git a/chromium/chrome/browser/ui/webui/tab_search/OWNERS b/chromium/chrome/browser/ui/webui/tab_search/OWNERS
index 6716085b93d..bf02bdd162a 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/OWNERS
+++ b/chromium/chrome/browser/ui/webui/tab_search/OWNERS
@@ -1,5 +1,6 @@
robliao@chromium.org
tluk@chromium.org
+yuhengh@chromium.org
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
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 2f5d895d549..07507048cc6 100644
--- a/chromium/chrome/browser/ui/webui/tab_search/tab_search.mojom
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search.mojom
@@ -4,6 +4,8 @@
module tab_search.mojom;
+import "mojo/public/mojom/base/time.mojom";
+
// Collection of WindowTabs of a profile.
struct ProfileTabs {
array<WindowTabs> windows;
@@ -17,16 +19,39 @@ struct WindowTabs {
// Information about an existing open tab.
struct Tab {
+ // Whether the tab is active.
bool active;
+
+ // The index of the tab in the current tab strip.
int32 index;
+
+ // The unique identifier of the tab.
int32 tab_id;
+
+ // The group identifier of the tab.
string? group_id;
+
+ // Whether the tab is pinned.
bool pinned;
+
+ // The title of the tab.
string title;
+
+ // The URL of the tab.
string url;
- string? fav_icon_url;
+
+ // The URL of the favicon in data scheme.
+ // Only used in OTR profile where chrome://favicon2 is not available.
+ string? favicon_url;
+
+ // Whether the favicon is the default one.
bool is_default_favicon;
+
+ // Whether the tab strip should show the icon.
bool show_icon;
+
+ // Time ticks when the tab is last active.
+ mojo_base.mojom.TimeTicks last_active_time_ticks;
};
// Collection of tab groups.
@@ -69,11 +94,21 @@ interface PageHandler {
// Switch to a specific tab.
SwitchToTab(SwitchToTabInfo switch_to_tab_info);
+
+ // Notify the backend that the UI is ready to be shown.
+ ShowUI();
+
+ // Notify the backend that the UI is ready to be closed.
+ CloseUI();
};
// WebUI-side handler for requests from the browser.
interface Page {
// Callback when any tabs in the current profile are
- // added/changed/removed/navigated to new URL
+ // selected/inserted/removed/moved/replaced
TabsChanged();
+
+ // Callback when a tab is updated within the same web contents.
+ // e.g. url, title or favicon changed.
+ TabUpdated(Tab tab);
};
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 6fc31ba5076..b5034185f0c 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
@@ -13,8 +13,10 @@
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
+#include "base/trace_event/trace_event.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/favicon/favicon_utils.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
@@ -31,11 +33,13 @@ constexpr base::TimeDelta kTabsChangeDelay =
TabSearchPageHandler::TabSearchPageHandler(
mojo::PendingReceiver<tab_search::mojom::PageHandler> receiver,
mojo::PendingRemote<tab_search::mojom::Page> page,
- content::WebUI* web_ui)
+ content::WebUI* web_ui,
+ Delegate* delegate)
: receiver_(this, std::move(receiver)),
page_(std::move(page)),
browser_(chrome::FindLastActive()),
web_ui_(web_ui),
+ delegate_(delegate),
debounce_timer_(std::make_unique<base::RetainingOneShotTimer>(
FROM_HERE,
kTabsChangeDelay,
@@ -70,6 +74,7 @@ void TabSearchPageHandler::CloseTab(int32_t tab_id) {
}
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()) {
@@ -149,6 +154,14 @@ void TabSearchPageHandler::SwitchToTab(
details.browser->window()->Activate();
}
+void TabSearchPageHandler::ShowUI() {
+ delegate_->ShowUI();
+}
+
+void TabSearchPageHandler::CloseUI() {
+ delegate_->CloseUI();
+}
+
tab_search::mojom::TabPtr TabSearchPageHandler::GetTabData(
TabStripModel* tab_strip_model,
content::WebContents* contents,
@@ -172,13 +185,15 @@ tab_search::mojom::TabPtr TabSearchPageHandler::GetTabData(
if (tab_renderer_data.favicon.isNull()) {
tab_data->is_default_favicon = true;
} else {
- tab_data->fav_icon_url = webui::EncodePNGAndMakeDataURI(
+ tab_data->favicon_url = webui::EncodePNGAndMakeDataURI(
tab_renderer_data.favicon, web_ui_->GetDeviceScaleFactor());
tab_data->is_default_favicon =
tab_renderer_data.favicon.BackedBySameObjectAs(
favicon::GetDefaultFavicon().AsImageSkia());
}
+
tab_data->show_icon = tab_renderer_data.show_icon;
+ tab_data->last_active_time_ticks = contents->GetLastActiveTime();
return tab_data;
}
@@ -187,7 +202,8 @@ void TabSearchPageHandler::OnTabStripModelChanged(
TabStripModel* tab_strip_model,
const TabStripModelChange& change,
const TabStripSelectionChange& selection) {
- ScheduleDebounce();
+ if (!browser_tab_strip_tracker_.is_processing_initial_browsers())
+ ScheduleDebounce();
}
void TabSearchPageHandler::TabChangedAt(content::WebContents* contents,
@@ -195,8 +211,13 @@ void TabSearchPageHandler::TabChangedAt(content::WebContents* contents,
TabChangeType change_type) {
// TODO(crbug.com/1112496): Support more values for TabChangeType and filter
// out the changes we are not interested in.
- if (change_type == TabChangeType::kAll)
- ScheduleDebounce();
+ if (change_type != TabChangeType::kAll)
+ return;
+ Browser* browser = chrome::FindBrowserWithWebContents(contents);
+ if (!browser)
+ return;
+ TRACE_EVENT0("browser", "TabSearchPageHandler::TabChangedAt");
+ page_->TabUpdated(GetTabData(browser->tab_strip_model(), contents, index));
}
void TabSearchPageHandler::ScheduleDebounce() {
@@ -205,8 +226,7 @@ void TabSearchPageHandler::ScheduleDebounce() {
}
void TabSearchPageHandler::NotifyTabsChanged() {
- if (!browser_tab_strip_tracker_.is_processing_initial_browsers())
- page_->TabsChanged();
+ page_->TabsChanged();
debounce_timer_->Stop();
}
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 2f025c31f04..05b13ada3b5 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
@@ -33,10 +33,17 @@ class TabSearchPageHandler : public tab_search::mojom::PageHandler,
public TabStripModelObserver,
public BrowserTabStripTrackerDelegate {
public:
+ class Delegate {
+ public:
+ virtual void ShowUI() = 0;
+ virtual void CloseUI() = 0;
+ };
+
TabSearchPageHandler(
mojo::PendingReceiver<tab_search::mojom::PageHandler> receiver,
mojo::PendingRemote<tab_search::mojom::Page> page,
- content::WebUI* web_ui);
+ content::WebUI* web_ui,
+ Delegate* delegate);
TabSearchPageHandler(const TabSearchPageHandler&) = delete;
TabSearchPageHandler& operator=(const TabSearchPageHandler&) = delete;
~TabSearchPageHandler() override;
@@ -48,6 +55,8 @@ class TabSearchPageHandler : public tab_search::mojom::PageHandler,
void ShowFeedbackPage() override;
void SwitchToTab(
tab_search::mojom::SwitchToTabInfoPtr switch_to_tab_info) override;
+ void ShowUI() override;
+ void CloseUI() override;
// TabStripModelObserver:
void OnTabStripModelChanged(
@@ -92,6 +101,7 @@ class TabSearchPageHandler : public tab_search::mojom::PageHandler,
mojo::Remote<tab_search::mojom::Page> page_;
Browser* const browser_;
content::WebUI* const web_ui_;
+ Delegate* const delegate_;
BrowserTabStripTracker browser_tab_strip_tracker_{this, this};
std::unique_ptr<base::RetainingOneShotTimer> debounce_timer_;
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 e4b20669d85..8d335a68bb9 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
@@ -7,6 +7,7 @@
#include "base/test/bind_test_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/timer/mock_timer.h"
+#include "build/build_config.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
@@ -18,6 +19,9 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/color_utils.h"
+using testing::_;
+using testing::Truly;
+
namespace {
constexpr char kTabUrl1[] = "http://foo/1";
@@ -44,6 +48,7 @@ class MockPage : public tab_search::mojom::Page {
mojo::Receiver<tab_search::mojom::Page> receiver_{this};
MOCK_METHOD0(TabsChanged, void());
+ MOCK_METHOD1(TabUpdated, void(tab_search::mojom::TabPtr));
};
void ExpectNewTab(const tab_search::mojom::Tab* tab,
@@ -56,9 +61,10 @@ void ExpectNewTab(const tab_search::mojom::Tab* tab,
EXPECT_FALSE(tab->pinned);
EXPECT_EQ(title, tab->title);
EXPECT_EQ(url, tab->url);
- EXPECT_TRUE(tab->fav_icon_url.has_value());
+ EXPECT_TRUE(tab->favicon_url.has_value());
EXPECT_TRUE(tab->is_default_favicon);
EXPECT_TRUE(tab->show_icon);
+ EXPECT_GT(tab->last_active_time_ticks, base::TimeTicks());
}
void ExpectProfileTabs(tab_search::mojom::ProfileTabs* profile_tabs) {
@@ -75,11 +81,13 @@ void ExpectProfileTabs(tab_search::mojom::ProfileTabs* profile_tabs) {
class TestTabSearchPageHandler : public TabSearchPageHandler {
public:
TestTabSearchPageHandler(mojo::PendingRemote<tab_search::mojom::Page> page,
- content::WebUI* web_ui)
+ content::WebUI* web_ui,
+ TabSearchPageHandler::Delegate* delegate)
: TabSearchPageHandler(
mojo::PendingReceiver<tab_search::mojom::PageHandler>(),
std::move(page),
- web_ui) {
+ web_ui,
+ delegate) {
mock_debounce_timer_ = new base::MockRetainingOneShotTimer();
SetTimerForTesting(base::WrapUnique(mock_debounce_timer_));
}
@@ -91,6 +99,15 @@ class TestTabSearchPageHandler : public TabSearchPageHandler {
base::MockRetainingOneShotTimer* mock_debounce_timer_;
};
+class MockTabSearchPageHandlerDelegate : public TabSearchPageHandler::Delegate {
+ public:
+ MockTabSearchPageHandlerDelegate() = default;
+ virtual ~MockTabSearchPageHandlerDelegate() = default;
+
+ MOCK_METHOD(void, ShowUI, (), (override));
+ MOCK_METHOD(void, CloseUI, (), (override));
+};
+
class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
public:
void SetUp() override {
@@ -103,8 +120,9 @@ class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
CreateTestBrowser(browser()->profile()->GetPrimaryOTRProfile(), false);
browser4_ = CreateTestBrowser(profile2(), false);
BrowserList::SetLastActive(browser1());
+ handler_delegate_ = std::make_unique<MockTabSearchPageHandlerDelegate>();
handler_ = std::make_unique<TestTabSearchPageHandler>(
- page_.BindAndGetRemote(), web_ui());
+ page_.BindAndGetRemote(), web_ui(), handler_delegate_.get());
}
void TearDown() override {
@@ -135,6 +153,9 @@ class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
Browser* browser4() { return browser4_.get(); }
TestTabSearchPageHandler* handler() { return handler_.get(); }
+ MockTabSearchPageHandlerDelegate* handler_delegate() {
+ return handler_delegate_.get();
+ }
void FireTimer() { handler_->mock_debounce_timer()->Fire(); }
bool IsTimerRunning() { return handler_->mock_debounce_timer()->IsRunning(); }
@@ -167,6 +188,7 @@ class TabSearchPageHandlerTest : public BrowserWithTestWindowTest {
std::unique_ptr<Browser> browser3_;
std::unique_ptr<Browser> browser4_;
std::unique_ptr<TestTabSearchPageHandler> handler_;
+ std::unique_ptr<MockTabSearchPageHandlerDelegate> handler_delegate_;
};
TEST_F(TabSearchPageHandlerTest, GetTabs) {
@@ -179,6 +201,7 @@ TEST_F(TabSearchPageHandlerTest, GetTabs) {
AddTabWithTitle(browser1(), GURL(kTabUrl1), kTabName1);
EXPECT_CALL(page_, TabsChanged()).Times(1);
+ EXPECT_CALL(page_, TabUpdated(_)).Times(2);
handler()->mock_debounce_timer()->Fire();
int32_t tab_id2 = 0;
@@ -246,6 +269,7 @@ TEST_F(TabSearchPageHandlerTest, GetTabs) {
// timer fires.
TEST_F(TabSearchPageHandlerTest, TabsChanged) {
EXPECT_CALL(page_, TabsChanged()).Times(4);
+ EXPECT_CALL(page_, TabUpdated(_)).Times(1);
FireTimer(); // Will call TabsChanged().
// Add 2 tabs in browser1.
@@ -276,6 +300,7 @@ TEST_F(TabSearchPageHandlerTest, TabsChanged) {
// will not call TabsChanged().
TEST_F(TabSearchPageHandlerTest, TabsNotChanged) {
EXPECT_CALL(page_, TabsChanged()).Times(1);
+ EXPECT_CALL(page_, TabUpdated(_)).Times(0);
FireTimer(); // Will call TabsChanged().
ASSERT_FALSE(IsTimerRunning());
AddTabWithTitle(browser3(), GURL(kTabUrl1),
@@ -286,6 +311,22 @@ TEST_F(TabSearchPageHandlerTest, TabsNotChanged) {
ASSERT_FALSE(IsTimerRunning());
}
+bool VerifyTabUpdated(const tab_search::mojom::TabPtr& tab) {
+ ExpectNewTab(tab.get(), kTabUrl1, kTabName1, 1);
+ return true;
+}
+
+// Verify tab update event is called correctly with data
+TEST_F(TabSearchPageHandlerTest, TabUpdated) {
+ EXPECT_CALL(page_, TabsChanged()).Times(1);
+ EXPECT_CALL(page_, TabUpdated(Truly(VerifyTabUpdated))).Times(1);
+ AddTabWithTitle(browser1(), GURL(kTabUrl1), kTabName1);
+ // Adding the following tab will trigger TabUpdated() to the first tab
+ // since the tab index will change from 0 to 1
+ AddTabWithTitle(browser1(), GURL(kTabUrl2), kTabName2);
+ FireTimer();
+}
+
TEST_F(TabSearchPageHandlerTest, CloseTab) {
AddTabWithTitle(browser1(), GURL(kTabUrl1), kTabName1);
AddTabWithTitle(browser2(), GURL(kTabUrl2), kTabName2);
@@ -296,15 +337,34 @@ 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);
handler()->CloseTab(tab_id);
ASSERT_EQ(1, browser1()->tab_strip_model()->count());
ASSERT_EQ(1, browser2()->tab_strip_model()->count());
}
-TEST_F(TabSearchPageHandlerTest, ShowFeedbackPage) {
+// TODO(crbug.com/1128855): Fix the test for Lacros build.
+#if BUILDFLAG(IS_LACROS)
+#define MAYBE_ShowFeedbackPage DISABLED_ShowFeedbackPage
+#else
+#define MAYBE_ShowFeedbackPage ShowFeedbackPage
+#endif
+TEST_F(TabSearchPageHandlerTest, MAYBE_ShowFeedbackPage) {
base::HistogramTester histogram_tester;
handler()->ShowFeedbackPage();
histogram_tester.ExpectTotalCount("Feedback.RequestSource", 1);
}
+// Make sure the delegate receives the ShowUI() call.
+TEST_F(TabSearchPageHandlerTest, ShowUITest) {
+ EXPECT_CALL(*handler_delegate(), ShowUI()).Times(1);
+ handler()->ShowUI();
+}
+
+// Make sure the delegate receives the closeUI() call.
+TEST_F(TabSearchPageHandlerTest, CloseUITest) {
+ EXPECT_CALL(*handler_delegate(), CloseUI()).Times(1);
+ handler()->CloseUI();
+}
+
} // namespace
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 2390be7af1e..e20cca6a190 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
@@ -4,15 +4,20 @@
#include "chrome/browser/ui/webui/tab_search/tab_search_ui.h"
+#include "base/numerics/ranges.h"
#include "build/branding_buildflags.h"
-#include "chrome/browser/ui/webui/tab_search/tab_search_page_handler.h"
+#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/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.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/webui/web_ui_util.h"
#if BUILDFLAG(ENABLE_TAB_SEARCH)
#include "chrome/grit/tab_search_resources.h"
@@ -35,14 +40,51 @@ TabSearchUI::TabSearchUI(content::WebUI* web_ui)
#if BUILDFLAG(ENABLE_TAB_SEARCH)
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUITabSearchHost);
+ static constexpr webui::LocalizedString kStrings[] = {
+ {"clearSearch", IDS_CLEAR_SEARCH},
+ {"searchTabs", IDS_TAB_SEARCH_SEARCH_TABS},
+ {"noResultsFound", IDS_TAB_SEARCH_NO_RESULTS_FOUND},
+ {"closeTab", IDS_TAB_SEARCH_CLOSE_TAB},
+ {"submitFeedback", IDS_TAB_SEARCH_SUBMIT_FEEDBACK},
+ {"a11yTabClosed", IDS_TAB_SEARCH_A11Y_TAB_CLOSED},
+ {"a11yFoundTab", IDS_TAB_SEARCH_A11Y_FOUND_TAB},
+ {"a11yFoundTabs", IDS_TAB_SEARCH_A11Y_FOUND_TABS},
+ {"a11yFoundTabFor", IDS_TAB_SEARCH_A11Y_FOUND_TAB_FOR},
+ {"a11yFoundTabsFor", IDS_TAB_SEARCH_A11Y_FOUND_TABS_FOR},
+ };
+ AddLocalizedStringsBulk(source, kStrings);
+
+ source->AddBoolean(
+ "submitFeedbackEnabled",
+ base::FeatureList::IsEnabled(features::kTabSearchFeedback));
+
+ // Add the configuration parameters for fuzzy search.
+ source->AddBoolean("searchIgnoreLocation",
+ features::kTabSearchSearchIgnoreLocation.Get());
+ source->AddInteger("searchDistance",
+ features::kTabSearchSearchDistance.Get());
+ source->AddDouble(
+ "searchThreshold",
+ base::ClampToRange<double>(features::kTabSearchSearchThreshold.Get(),
+ features::kTabSearchSearchThresholdMin,
+ features::kTabSearchSearchThresholdMax));
+ source->AddDouble("searchTitleToHostnameWeightRatio",
+ features::kTabSearchTitleToHostnameWeightRatio.Get());
+
source->AddLocalizedString("close", IDS_CLOSE);
source->AddResourcePath("tab_search.mojom-lite.js",
IDR_TAB_SEARCH_MOJO_LITE_JS);
+ source->AddResourcePath("fuse.js", IDR_FUSE_JS);
webui::SetupWebUIDataSource(
source, base::make_span(kTabSearchResources, kTabSearchResourcesSize),
kGeneratedPath, IDR_TAB_SEARCH_PAGE_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
source);
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::URLDataSource::Add(
+ profile, std::make_unique<FaviconSource>(
+ profile, chrome::FaviconUrlFormat::kFavicon2));
#endif // BUILDFLAG(ENABLE_TAB_SEARCH)
}
@@ -56,10 +98,26 @@ void TabSearchUI::BindInterface(
page_factory_receiver_.Bind(std::move(receiver));
}
+void TabSearchUI::SetEmbedder(TabSearchUIEmbedder* embedder) {
+ // Setting the embedder must be done before the page handler is created.
+ DCHECK(!embedder || !page_handler_);
+ embedder_ = embedder;
+}
+
+void TabSearchUI::ShowUI() {
+ if (embedder_)
+ embedder_->ShowBubble();
+}
+
+void TabSearchUI::CloseUI() {
+ if (embedder_)
+ embedder_->CloseBubble();
+}
+
void TabSearchUI::CreatePageHandler(
mojo::PendingRemote<tab_search::mojom::Page> page,
mojo::PendingReceiver<tab_search::mojom::PageHandler> receiver) {
DCHECK(page);
page_handler_ = std::make_unique<TabSearchPageHandler>(
- std::move(receiver), std::move(page), web_ui());
+ std::move(receiver), std::move(page), web_ui(), this);
}
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 3b678f61d46..d4415c9310e 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
@@ -7,34 +7,35 @@
#include <memory>
+#include "base/callback_forward.h"
#include "base/macros.h"
#include "chrome/browser/ui/webui/tab_search/tab_search.mojom.h"
+#include "chrome/browser/ui/webui/tab_search/tab_search_page_handler.h"
+#include "chrome/browser/ui/webui/tab_search/tab_search_ui_embedder.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"
#include "ui/webui/mojo_web_ui_controller.h"
-class Browser;
-class TabSearchUIEmbedder;
-class TabSearchPageHandler;
-
class TabSearchUI : public ui::MojoWebUIController,
- public tab_search::mojom::PageHandlerFactory {
+ public tab_search::mojom::PageHandlerFactory,
+ public TabSearchPageHandler::Delegate {
public:
explicit TabSearchUI(content::WebUI* web_ui);
TabSearchUI(const TabSearchUI&) = delete;
TabSearchUI& operator=(const TabSearchUI&) = delete;
~TabSearchUI() override;
- // Initialize TabSearchUI by passing in the current browser and the
- // current embedder, the WebUI won't work until this is called.
- void Initialize(Browser* browser, TabSearchUIEmbedder* embedder);
-
// Instantiates the implementor of the mojom::PageHandlerFactory mojo
// interface passing the pending receiver that will be internally bound.
void BindInterface(
mojo::PendingReceiver<tab_search::mojom::PageHandlerFactory> receiver);
+ void SetEmbedder(TabSearchUIEmbedder* embedder);
+
+ // TabSearchPageHandler::Delegate:
+ void ShowUI() override;
+ void CloseUI() override;
private:
// tab_search::mojom::PageHandlerFactory
@@ -49,6 +50,8 @@ class TabSearchUI : public ui::MojoWebUIController,
WebuiLoadTimer webui_load_timer_;
+ TabSearchUIEmbedder* embedder_ = nullptr;
+
WEB_UI_CONTROLLER_TYPE_DECL();
};
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
new file mode 100644
index 00000000000..5afbfa5eb4d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_browsertest.cc
@@ -0,0 +1,116 @@
+// 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 <string>
+
+#include "base/test/scoped_feature_list.h"
+#include "chrome/browser/extensions/extension_tab_util.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/ui_features.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"
+
+class TabSearchUIBrowserTest : public InProcessBrowserTest {
+ public:
+ void SetUp() override {
+ feature_list_.InitAndEnableFeature(features::kTabSearch);
+ InProcessBrowserTest::SetUp();
+ }
+
+ void SetUpOnMainThread() override {
+ AppendTab(chrome::kChromeUISettingsURL);
+ AppendTab(chrome::kChromeUIHistoryURL);
+ AppendTab(chrome::kChromeUIBookmarksURL);
+
+ webui_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(browser()->profile()));
+
+ webui_contents_->GetController().LoadURLWithParams(
+ content::NavigationController::LoadURLParams(
+ GURL(chrome::kChromeUITabSearchURL)));
+
+ // Finish loading after initializing.
+ ASSERT_TRUE(content::WaitForLoadStop(webui_contents_.get()));
+ }
+
+ void TearDownOnMainThread() override { webui_contents_.reset(); }
+
+ void AppendTab(std::string url) {
+ chrome::AddTabAt(browser(), GURL(url), -1, true);
+ }
+
+ content::WebContents* GetActiveTab() {
+ return browser()->tab_strip_model()->GetActiveWebContents();
+ }
+
+ protected:
+ std::unique_ptr<content::WebContents> webui_contents_;
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
+};
+
+// TODO(romanarora): Investigate a way to call WebUI custom methods and refactor
+// JS code below.
+
+IN_PROC_BROWSER_TEST_F(TabSearchUIBrowserTest, InitialTabItemsListed) {
+ const std::string tab_items_js =
+ "const tabItems = document.querySelector('tab-search-app').shadowRoot"
+ " .querySelectorAll('tab-search-item');";
+ int tab_item_count =
+ content::EvalJs(webui_contents_.get(), tab_items_js + "tabItems.length",
+ content::EXECUTE_SCRIPT_DEFAULT_OPTIONS,
+ ISOLATED_WORLD_ID_CHROME_INTERNAL)
+ .ExtractInt();
+ ASSERT_EQ(4, tab_item_count);
+}
+
+IN_PROC_BROWSER_TEST_F(TabSearchUIBrowserTest, SwitchToTabAction) {
+ int tab_count = browser()->tab_strip_model()->GetTabCount();
+ int tab_id = extensions::ExtensionTabUtil::GetTabId(
+ browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1));
+ ASSERT_EQ(tab_id, extensions::ExtensionTabUtil::GetTabId(GetActiveTab()));
+
+ tab_id = extensions::ExtensionTabUtil::GetTabId(
+ browser()->tab_strip_model()->GetWebContentsAt(0));
+
+ const std::string tab_item_js = base::StringPrintf(
+ "document.querySelector('tab-search-app').shadowRoot"
+ " .getElementById('%s')",
+ base::NumberToString(tab_id).c_str());
+ ASSERT_TRUE(content::ExecJs(webui_contents_.get(), tab_item_js + ".click()",
+ content::EXECUTE_SCRIPT_DEFAULT_OPTIONS,
+ ISOLATED_WORLD_ID_CHROME_INTERNAL));
+ ASSERT_EQ(tab_id, extensions::ExtensionTabUtil::GetTabId(GetActiveTab()));
+}
+
+IN_PROC_BROWSER_TEST_F(TabSearchUIBrowserTest, CloseTabAction) {
+ ASSERT_EQ(4, browser()->tab_strip_model()->GetTabCount());
+
+ int tab_id = extensions::ExtensionTabUtil::GetTabId(
+ browser()->tab_strip_model()->GetWebContentsAt(0));
+
+ const std::string tab_item_button_js = base::StringPrintf(
+ "document.querySelector('tab-search-app').shadowRoot.getElementById('%s')"
+ " .shadowRoot.getElementById('closeButton')",
+ base::NumberToString(tab_id).c_str());
+ ASSERT_TRUE(content::ExecJs(webui_contents_.get(),
+ tab_item_button_js + ".click()",
+ content::EXECUTE_SCRIPT_DEFAULT_OPTIONS,
+ ISOLATED_WORLD_ID_CHROME_INTERNAL));
+ int tab_count = browser()->tab_strip_model()->GetTabCount();
+ ASSERT_EQ(3, 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(
+ browser()->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_search/tab_search_ui_embedder.h b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_embedder.h
new file mode 100644
index 00000000000..878e313fb6f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/tab_search/tab_search_ui_embedder.h
@@ -0,0 +1,19 @@
+// 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_TAB_SEARCH_TAB_SEARCH_UI_EMBEDDER_H_
+#define CHROME_BROWSER_UI_WEBUI_TAB_SEARCH_TAB_SEARCH_UI_EMBEDDER_H_
+
+// Interface to be implemented by the embedder. Provides native UI
+// functionality such as showing and closing a bubble view.
+class TabSearchUIEmbedder {
+ public:
+ TabSearchUIEmbedder() = default;
+ virtual ~TabSearchUIEmbedder() = default;
+
+ virtual void ShowBubble() = 0;
+ virtual void CloseBubble() = 0;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_TAB_SEARCH_TAB_SEARCH_UI_EMBEDDER_H_
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 cbfb3884f90..6f76ac6f688 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
@@ -7,7 +7,7 @@
#include "chrome/common/webui_url_constants.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/common/web_preferences.h"
+#include "third_party/blink/public/common/web_preferences/web_preferences.h"
ChromeContentBrowserClientTabStripPart::
ChromeContentBrowserClientTabStripPart() = default;
@@ -16,7 +16,7 @@ ChromeContentBrowserClientTabStripPart::
void ChromeContentBrowserClientTabStripPart::OverrideWebkitPrefs(
content::RenderViewHost* rvh,
- content::WebPreferences* web_prefs) {
+ blink::web_pref::WebPreferences* web_prefs) {
content::WebContents* contents =
content::WebContents::FromRenderViewHost(rvh);
@@ -30,7 +30,7 @@ void ChromeContentBrowserClientTabStripPart::OverrideWebkitPrefs(
return;
}
- content::WebPreferences default_prefs;
+ blink::web_pref::WebPreferences default_prefs;
web_prefs->default_font_size = default_prefs.default_font_size;
web_prefs->default_fixed_font_size = default_prefs.default_fixed_font_size;
web_prefs->minimum_font_size = default_prefs.minimum_font_size;
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 63af9321d82..2edc7d30c13 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
@@ -8,7 +8,7 @@
#include "base/macros.h"
#include "chrome/browser/chrome_content_browser_client_parts.h"
#include "content/public/browser/render_view_host.h"
-#include "content/public/common/web_preferences.h"
+#include "third_party/blink/public/common/web_preferences/web_preferences.h"
class ChromeContentBrowserClientTabStripPart
: public ChromeContentBrowserClientParts {
@@ -18,7 +18,7 @@ class ChromeContentBrowserClientTabStripPart
// ChromeContentBrowserClientParts:
void OverrideWebkitPrefs(content::RenderViewHost* rvh,
- content::WebPreferences* web_prefs) override;
+ blink::web_pref::WebPreferences* web_prefs) override;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClientTabStripPart);
diff --git a/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part_browsertest.cc b/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part_browsertest.cc
index 77673808c03..c3dadeabc6e 100644
--- a/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/tab_strip/chrome_content_browser_client_tab_strip_part_browsertest.cc
@@ -12,8 +12,8 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/render_view_host.h"
-#include "content/public/common/web_preferences.h"
#include "content/public/test/browser_test.h"
+#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "ui/base/ui_base_switches.h"
class ChromeContentBrowserClientTabStripPartTest : public InProcessBrowserTest {
@@ -34,14 +34,14 @@ class ChromeContentBrowserClientTabStripPartTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientTabStripPartTest,
TabStripHasDefaultFontSizes) {
- const content::WebPreferences default_prefs;
+ const blink::web_pref::WebPreferences default_prefs;
const int kDefaultFontSize = default_prefs.default_font_size;
const int kDefaultFixedFontSize = default_prefs.default_fixed_font_size;
const int kDefaultMinimumFontSize = default_prefs.minimum_font_size;
const int kDefaultMinimumLogicalFontSize =
default_prefs.minimum_logical_font_size;
- content::WebPreferences preexisting_tab_strip_prefs =
+ blink::web_pref::WebPreferences preexisting_tab_strip_prefs =
CreateTabStripWebContents()->GetOrCreateWebPreferences();
Profile* profile = browser()->profile();
@@ -63,7 +63,7 @@ IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientTabStripPartTest,
EXPECT_EQ(kDefaultMinimumLogicalFontSize,
preexisting_tab_strip_prefs.minimum_logical_font_size);
- content::WebPreferences new_tab_strip_prefs =
+ blink::web_pref::WebPreferences new_tab_strip_prefs =
CreateTabStripWebContents()->GetOrCreateWebPreferences();
EXPECT_EQ(kDefaultFontSize, new_tab_strip_prefs.default_font_size);
EXPECT_EQ(kDefaultFixedFontSize, new_tab_strip_prefs.default_fixed_font_size);
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 083d2850613..1b7f85054c2 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,7 +110,10 @@ IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest, ActivatingTabClosesEmbedder) {
ISOLATED_WORLD_ID_CHROME_INTERNAL));
}
-IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest, InvokesEditDialogForGroups) {
+// Flaky.
+// TODO(https://crbug.com/1132300): Re-enable.
+IN_PROC_BROWSER_TEST_F(TabStripUIBrowserTest,
+ DISABLED_InvokesEditDialogForGroups) {
using ::testing::_;
tab_groups::TabGroupId group_id =
diff --git a/chromium/chrome/browser/ui/webui/version_ui.cc b/chromium/chrome/browser/ui/webui/version_ui.cc
index a12c19f812f..96c6549203f 100644
--- a/chromium/chrome/browser/ui/webui/version_ui.cc
+++ b/chromium/chrome/browser/ui/webui/version_ui.cc
@@ -123,7 +123,7 @@ int VersionUI::VersionProcessorVariation() {
#if defined(OS_ANDROID)
// When building for Android, "unused" strings are removed. However, binaries
// of both bitnesses are stripped of strings based on string analysis of one
- // bitness. Search the code for "generate_resource_whitelist" for more
+ // bitness. Search the code for "generate_resource_allowlist" for more
// information. Therefore, make sure both the IDS_VERSION_UI_32BIT and
// IDS_VERSION_UI_64BIT strings are marked as always used so that they’re
// never stripped. https://crbug.com/1119479
diff --git a/chromium/chrome/browser/ui/webui/video_tutorials/OWNERS b/chromium/chrome/browser/ui/webui/video_tutorials/OWNERS
new file mode 100644
index 00000000000..4ed34726dac
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/video_tutorials/OWNERS
@@ -0,0 +1,4 @@
+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.cc b/chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.cc
new file mode 100644
index 00000000000..aac47cf20f3
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.cc
@@ -0,0 +1,36 @@
+// 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/video_tutorials/video_player_source.h"
+
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/browser_resources.h"
+#include "services/network/public/mojom/content_security_policy.mojom.h"
+
+namespace video_tutorials {
+
+// static
+content::WebUIDataSource* CreateVideoPlayerUntrustedDataSource() {
+ content::WebUIDataSource* source = content::WebUIDataSource::Create(
+ chrome::kChromeUIUntrustedVideoPlayerUrl);
+ source->AddResourcePath("", IDR_VIDEO_PLAYER_HTML);
+ source->AddResourcePath("video_player.css", IDR_VIDEO_PLAYER_CSS);
+ source->AddResourcePath("video_player.js", IDR_VIDEO_PLAYER_JS);
+
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::ConnectSrc, "connect-src https:;");
+ source->OverrideContentSecurityPolicy(
+ network::mojom::CSPDirectiveName::ImgSrc, "img-src https:;");
+ source->OverrideContentSecurityPolicy(
+ 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;
+}
+
+} // namespace video_tutorials
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
new file mode 100644
index 00000000000..219e14db26d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/video_tutorials/video_player_source.h
@@ -0,0 +1,17 @@
+// 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/webui_webview_browsertest.cc b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
index 9e6115be104..9e422f3fc21 100644
--- a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
@@ -366,10 +366,10 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, DISABLED_DragAndDropToInput) {
guest_dest_rect.y() + guest_dest_rect.height() / 2.0 + webview_rect.y());
gfx::Rect container_bounds = embedder_web_contents->GetContainerBounds();
const gfx::PointF screen_pt(container_bounds.x(), container_bounds.y());
- const blink::WebDragOperationsMask drag_operation_mask =
- static_cast<blink::WebDragOperationsMask>(blink::kWebDragOperationCopy |
- blink::kWebDragOperationLink |
- blink::kWebDragOperationMove);
+ const blink::DragOperationsMask drag_operation_mask =
+ static_cast<blink::DragOperationsMask>(blink::kDragOperationCopy |
+ blink::kDragOperationLink |
+ blink::kDragOperationMove);
content::DropData dropdata;
dropdata.did_originate_from_renderer = true;
dropdata.url = GURL(url::kAboutBlankURL);
diff --git a/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
index 12cb92c2c64..8b9c61852ec 100644
--- a/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
@@ -82,6 +82,7 @@ void AddStrings(content::WebUIDataSource* html_source) {
{"next", IDS_WELCOME_NEXT},
{"noThanks", IDS_NO_THANKS},
{"skip", IDS_WELCOME_SKIP},
+ {"stepsLabel", IDS_WELCOME_STEPS},
// Sign-in view strings.
{"signInHeader", IDS_WELCOME_SIGNIN_VIEW_HEADER},