summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/ui/webui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-24 11:30:15 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-30 12:56:19 +0000
commit6036726eb981b6c4b42047513b9d3f4ac865daac (patch)
tree673593e70678e7789766d1f732eb51f613a2703b /chromium/chrome/browser/ui/webui
parent466052c4e7c052268fd931888cd58961da94c586 (diff)
BASELINE: Update Chromium to 70.0.3538.78
Change-Id: Ie634710bf039e26c1957f4ae45e101bd4c434ae7 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui/webui')
-rw-r--r--chromium/chrome/browser/ui/webui/DEPS12
-rw-r--r--chromium/chrome/browser/ui/webui/about_ui.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/browsing_history_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/certificates_handler.cc167
-rw-r--r--chromium/chrome/browser/ui/webui/certificates_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/DEPS5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc251
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc225
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h85
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.h39
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc198
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/DEPS7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc76
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/image_source.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc64
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc363
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h110
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc82
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.cc104
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h58
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager_observer.h25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.cc77
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h32
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.cc63
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h32
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.cc63
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h32
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc38
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc179
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h71
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc63
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc114
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.h53
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc308
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h31
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc160
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h24
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc144
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h14
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc79
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc69
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h35
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/power_ui.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h4
-rw-r--r--chromium/chrome/browser/ui/webui/components_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc233
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/discards/discards.mojom4
-rw-r--r--chromium/chrome/browser/ui/webui/discards/discards_ui.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_internals_browsertest.cc53
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc156
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h38
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_basic.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_win.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/inspect_ui.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h15
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc39
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h6
-rw-r--r--chromium/chrome/browser/ui/webui/invalidations_message_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc190
-rw-r--r--chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h12
-rw-r--r--chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/md_history_ui.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc53
-rw-r--r--chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc324
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui.h7
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui_service.cc71
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui_service.h61
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory.cc64
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory.h51
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory_unittest.cc103
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/memory_internals_ui.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/nacl_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/DEPS2
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/policy_ui_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h1
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/policy_settings.h28
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc189
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h21
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc53
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc58
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h29
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc40
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/sticky_settings.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/profile_helper.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/quota_internals/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc65
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h9
-rw-r--r--chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/change_password_handler.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc62
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc47
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc117
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc192
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h57
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc330
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/settings/downloads_handler.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/settings/downloads_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc210
-rw-r--r--chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc54
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.cc169
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.h19
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc406
-rw-r--r--chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc31
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc85
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc198
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.h35
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc185
-rw-r--r--chromium/chrome/browser/ui/webui/settings/tts_handler.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/settings/tts_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/settings_utils_linux.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/settings_utils_win.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler.h20
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h10
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h10
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service.h2
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc56
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/DEPS3
-rw-r--r--chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_browsertest.js34
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_message_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/task_scheduler_internals/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/theme_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/ukm/ukm_internals_ui.cc100
-rw-r--r--chromium/chrome/browser/ui/webui/ukm/ukm_internals_ui.h20
-rw-r--r--chromium/chrome/browser/ui/webui/version_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/version_handler_chromeos.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/version_ui.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/welcome_ui.cc61
-rw-r--r--chromium/chrome/browser/ui/webui/welcome_win10_handler.cc8
246 files changed, 7125 insertions, 2716 deletions
diff --git a/chromium/chrome/browser/ui/webui/DEPS b/chromium/chrome/browser/ui/webui/DEPS
index ab5553d0edf..1c49a311295 100644
--- a/chromium/chrome/browser/ui/webui/DEPS
+++ b/chromium/chrome/browser/ui/webui/DEPS
@@ -1,14 +1,6 @@
include_rules = [
# TODO(mash): Remove. http://crbug.com/628715
"+ash/strings",
- "+components/about_ui",
- "+components/invalidation",
- "+components/onc",
- "+components/proximity_auth",
- "+components/sync/engine/events",
- "+components/sync/sessions",
- "+components/sync/base/weak_handle.h",
- "+components/sync/js",
"+device/bluetooth",
"+extensions/strings/grit/extensions_strings.h",
@@ -19,8 +11,4 @@ include_rules = [
"+third_party/angle", # For ANGLE version.
"+third_party/brotli", # For compressed resources.
"+third_party/zlib/zlib.h", # For compression level constants.
-
- # DOM Distiller.
- "+components/dom_distiller/core",
- "+components/dom_distiller/webui",
]
diff --git a/chromium/chrome/browser/ui/webui/about_ui.cc b/chromium/chrome/browser/ui/webui/about_ui.cc
index 6153c0f51c9..f17784247a4 100644
--- a/chromium/chrome/browser/ui/webui/about_ui.cc
+++ b/chromium/chrome/browser/ui/webui/about_ui.cc
@@ -31,9 +31,9 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
+#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread.h"
-#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/about_flags.h"
@@ -136,7 +136,8 @@ class ChromeOSTermsHandler
}
void LoadOemEulaFileAsync() {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(
+ base::BlockingType::MAY_BLOCK);
const chromeos::StartupCustomizationDocument* customization =
chromeos::StartupCustomizationDocument::GetInstance();
@@ -153,7 +154,8 @@ class ChromeOSTermsHandler
}
void LoadEulaFileAsync() {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(
+ base::BlockingType::MAY_BLOCK);
std::string file_path =
base::StringPrintf(chrome::kEULAPathFormat, locale_.c_str());
@@ -223,7 +225,7 @@ class ChromeOSCreditsHandler
}
// Load local Chrome OS credits from the disk.
base::PostTaskWithTraitsAndReply(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&ChromeOSCreditsHandler::LoadCreditsFileAsync, this),
base::Bind(&ChromeOSCreditsHandler::ResponseOnUIThread, this));
}
diff --git a/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc b/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc
index d804302e241..3bb63dbd340 100644
--- a/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc
+++ b/chromium/chrome/browser/ui/webui/app_launcher_page_ui.cc
@@ -55,9 +55,9 @@ AppLauncherPageUI::AppLauncherPageUI(content::WebUI* web_ui)
// earlier.
web_ui->AddMessageHandler(std::make_unique<ThemeHandler>());
- std::unique_ptr<HTMLSource> html_source(
- new HTMLSource(GetProfile()->GetOriginalProfile()));
- content::URLDataSource::Add(GetProfile(), html_source.release());
+ content::URLDataSource::Add(
+ GetProfile(),
+ std::make_unique<HTMLSource>(GetProfile()->GetOriginalProfile()));
}
AppLauncherPageUI::~AppLauncherPageUI() {
diff --git a/chromium/chrome/browser/ui/webui/browsing_history_handler.cc b/chromium/chrome/browser/ui/webui/browsing_history_handler.cc
index 4b542481235..73a0891dcac 100644
--- a/chromium/chrome/browser/ui/webui/browsing_history_handler.cc
+++ b/chromium/chrome/browser/ui/webui/browsing_history_handler.cc
@@ -245,7 +245,8 @@ void BrowsingHistoryHandler::RegisterMessages() {
this, local_history, sync_service);
// Create our favicon data source.
- content::URLDataSource::Add(profile, new FaviconSource(profile));
+ content::URLDataSource::Add(profile,
+ std::make_unique<FaviconSource>(profile));
web_ui()->RegisterMessageCallback(
"queryHistory",
diff --git a/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc b/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc
index d789c144fe7..e73ade2e2e0 100644
--- a/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc
@@ -61,21 +61,25 @@ class TestSyncService : public browser_sync::TestProfileSyncService {
explicit TestSyncService(Profile* profile)
: browser_sync::TestProfileSyncService(
CreateProfileSyncServiceParamsForTest(profile)),
- state_(State::ACTIVE) {}
+ state_(TransportState::ACTIVE) {}
- State GetState() const override { return state_; }
+ TransportState GetTransportState() const override { return state_; }
+
+ int GetDisableReasons() const override { return DISABLE_REASON_NONE; }
+
+ bool IsFirstSetupComplete() const override { return true; }
syncer::ModelTypeSet GetActiveDataTypes() const override {
return syncer::ModelTypeSet::All();
}
- void SetState(State state) {
+ void SetTransportState(TransportState state) {
state_ = state;
NotifyObservers();
}
private:
- State state_;
+ TransportState state_;
DISALLOW_COPY_AND_ASSIGN(TestSyncService);
};
@@ -169,7 +173,8 @@ TEST_F(BrowsingHistoryHandlerTest, ObservingWebHistoryDeletions) {
// BrowsingHistoryHandler is informed about WebHistoryService history
// deletions.
{
- sync_service()->SetState(syncer::SyncService::State::ACTIVE);
+ sync_service()->SetTransportState(
+ syncer::SyncService::TransportState::ACTIVE);
BrowsingHistoryHandlerWithWebUIForTesting handler(web_ui());
handler.RegisterMessages();
@@ -184,10 +189,12 @@ TEST_F(BrowsingHistoryHandlerTest, ObservingWebHistoryDeletions) {
// BrowsingHistoryHandler will be informed about WebHistoryService deletions
// even if history sync is activated later.
{
- sync_service()->SetState(syncer::SyncService::State::INITIALIZING);
+ sync_service()->SetTransportState(
+ syncer::SyncService::TransportState::INITIALIZING);
BrowsingHistoryHandlerWithWebUIForTesting handler(web_ui());
handler.RegisterMessages();
- sync_service()->SetState(syncer::SyncService::State::ACTIVE);
+ sync_service()->SetTransportState(
+ syncer::SyncService::TransportState::ACTIVE);
web_history_service()->ExpireHistoryBetween(
std::set<GURL>(), base::Time(), base::Time::Max(), callback,
@@ -200,7 +207,8 @@ TEST_F(BrowsingHistoryHandlerTest, ObservingWebHistoryDeletions) {
// BrowsingHistoryHandler does not fire historyDeleted while a web history
// delete request is happening.
{
- sync_service()->SetState(syncer::SyncService::State::ACTIVE);
+ sync_service()->SetTransportState(
+ syncer::SyncService::TransportState::ACTIVE);
BrowsingHistoryHandlerWithWebUIForTesting handler(web_ui());
handler.RegisterMessages();
@@ -222,7 +230,8 @@ TEST_F(BrowsingHistoryHandlerTest, ObservingWebHistoryDeletions) {
// deletions. The WebHistoryService object still exists (because it's a
// BrowserContextKeyedService), but is not visible to BrowsingHistoryHandler.
{
- sync_service()->SetState(syncer::SyncService::State::INITIALIZING);
+ sync_service()->SetTransportState(
+ syncer::SyncService::TransportState::INITIALIZING);
BrowsingHistoryHandlerWithWebUIForTesting handler(web_ui());
handler.RegisterMessages();
diff --git a/chromium/chrome/browser/ui/webui/certificates_handler.cc b/chromium/chrome/browser/ui/webui/certificates_handler.cc
index 71beb63980b..57ccbca195b 100644
--- a/chromium/chrome/browser/ui/webui/certificates_handler.cc
+++ b/chromium/chrome/browser/ui/webui/certificates_handler.cc
@@ -21,8 +21,8 @@
#include "base/posix/safe_strerror.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/task_scheduler/task_traits.h"
+#include "base/task/post_task.h"
+#include "base/task/task_traits.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
@@ -42,11 +42,6 @@
#include "net/der/parser.h"
#include "ui/base/l10n/l10n_util.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/policy/user_network_configuration_updater.h"
-#include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
-#endif
-
using base::UTF8ToUTF16;
namespace {
@@ -57,10 +52,13 @@ static const char kCertificatesHandlerExtractableField[] = "extractable";
static const char kCertificatesHandlerKeyField[] = "id";
static const char kCertificatesHandlerNameField[] = "name";
static const char kCertificatesHandlerObjSignField[] = "objSign";
-static const char kCertificatesHandlerPolicyField[] = "policy";
+static const char kCertificatesHandlerPolicyInstalledField[] = "policy";
+static const char kCertificatesHandlerWebTrustAnchorField[] = "webTrustAnchor";
static const char kCertificatesHandlerReadonlyField[] = "readonly";
static const char kCertificatesHandlerSslField[] = "ssl";
static const char kCertificatesHandlerSubnodesField[] = "subnodes";
+static const char kCertificatesHandlerContainsPolicyCertsField[] =
+ "containsPolicyCerts";
static const char kCertificatesHandlerUntrustedField[] = "untrusted";
// Field names for communicating erros to JS.
@@ -70,7 +68,7 @@ static const char kCertificatesHandlerErrorField[] = "error";
static const char kCertificatesHandlerErrorTitle[] = "title";
// Enumeration of different callers of SelectFile. (Start counting at 1 so
-// if SelectFile is accidentally called with params=NULL it won't match any.)
+// if SelectFile is accidentally called with params=nullptr it won't match any.)
enum {
EXPORT_PERSONAL_FILE_SELECTED = 1,
IMPORT_PERSONAL_FILE_SELECTED,
@@ -99,7 +97,7 @@ struct DictionaryIdComparator {
base::string16 b_str;
a_dict->GetString(kCertificatesHandlerNameField, &a_str);
b_dict->GetString(kCertificatesHandlerNameField, &b_str);
- if (collator_ == NULL)
+ if (collator_ == nullptr)
return a_str < b_str;
return base::i18n::CompareString16WithCollator(*collator_, a_str, b_str) ==
UCOL_LESS;
@@ -132,13 +130,6 @@ struct CertEquals {
CERTCertificate* cert_;
};
-// Determine whether a certificate was stored with web trust by a policy.
-bool IsPolicyInstalledWithWebTrust(const net::CertificateList& web_trust_certs,
- CERTCertificate* cert) {
- return std::find_if(web_trust_certs.begin(), web_trust_certs.end(),
- CertEquals(cert)) != web_trust_certs.end();
-}
-
// Determine if |data| could be a PFX Protocol Data Unit.
// This only does the minimum parsing necessary to distinguish a PFX file from a
// DER encoded Certificate.
@@ -226,12 +217,12 @@ CERTCertificate* CertIdMap::IdToCert(const std::string& id) {
CERTCertificate* CertIdMap::CallbackArgsToCert(const base::ListValue* args) {
std::string node_id;
if (!args->GetString(0, &node_id))
- return NULL;
+ return nullptr;
CERTCertificate* cert = IdToCert(node_id);
if (!cert) {
NOTREACHED();
- return NULL;
+ return nullptr;
}
return cert;
@@ -287,7 +278,7 @@ base::CancelableTaskTracker::TaskId FileAccessProvider::StartRead(
// Post task to a background sequence to read file.
auto task_runner = base::CreateTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::BACKGROUND});
+ {base::MayBlock(), base::TaskPriority::BEST_EFFORT});
return tracker->PostTaskAndReply(
task_runner.get(), FROM_HERE,
base::BindOnce(&FileAccessProvider::DoRead, this, path, saved_errno,
@@ -306,7 +297,7 @@ base::CancelableTaskTracker::TaskId FileAccessProvider::StartWrite(
// This task blocks shutdown because it saves critical user data.
auto task_runner = base::CreateTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::BACKGROUND,
+ {base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
return tracker->PostTaskAndReply(
task_runner.get(), FROM_HERE,
@@ -414,18 +405,10 @@ void CertificatesHandler::RegisterMessages() {
}
void CertificatesHandler::CertificatesRefreshed() {
- net::CertificateList web_trusted_certs;
-#if defined(OS_CHROMEOS)
- policy::UserNetworkConfigurationUpdater* service =
- policy::UserNetworkConfigurationUpdaterFactory::GetForProfile(
- Profile::FromWebUI(web_ui()));
- if (service)
- service->GetWebTrustedCertificates(&web_trusted_certs);
-#endif
- PopulateTree("personalCerts", net::USER_CERT, web_trusted_certs);
- PopulateTree("serverCerts", net::SERVER_CERT, web_trusted_certs);
- PopulateTree("caCerts", net::CA_CERT, web_trusted_certs);
- PopulateTree("otherCerts", net::OTHER_CERT, web_trusted_certs);
+ PopulateTree("personalCerts", net::USER_CERT);
+ PopulateTree("serverCerts", net::SERVER_CERT);
+ PopulateTree("caCerts", net::CA_CERT);
+ PopulateTree("otherCerts", net::OTHER_CERT);
}
void CertificatesHandler::FileSelected(const base::FilePath& path,
@@ -785,7 +768,7 @@ void CertificatesHandler::ImportExportCleanup() {
// away so they don't try and call back to us.
if (select_file_dialog_.get())
select_file_dialog_->ListenerDestroyed();
- select_file_dialog_ = NULL;
+ select_file_dialog_ = nullptr;
}
void CertificatesHandler::HandleImportServer(const base::ListValue* args) {
@@ -1023,74 +1006,72 @@ void CertificatesHandler::HandleRefreshCertificates(
// to do anything.
}
-void CertificatesHandler::PopulateTree(
- const std::string& tab_name,
- net::CertType type,
- const net::CertificateList& web_trust_certs) {
+void CertificatesHandler::PopulateTree(const std::string& tab_name,
+ net::CertType type) {
std::unique_ptr<icu::Collator> collator;
UErrorCode error = U_ZERO_ERROR;
collator.reset(icu::Collator::createInstance(
icu::Locale(g_browser_process->GetApplicationLocale().c_str()), error));
if (U_FAILURE(error))
- collator.reset(NULL);
+ collator.reset();
DictionaryIdComparator comparator(collator.get());
- CertificateManagerModel::OrgGroupingMap map;
-
- certificate_manager_model_->FilterAndBuildOrgGroupingMap(type, &map);
-
- {
- std::unique_ptr<base::ListValue> nodes =
- std::make_unique<base::ListValue>();
- for (CertificateManagerModel::OrgGroupingMap::iterator i = map.begin();
- i != map.end(); ++i) {
- // Populate first level (org name).
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
- dict->SetString(kCertificatesHandlerKeyField, OrgNameToId(i->first));
- dict->SetString(kCertificatesHandlerNameField, i->first);
-
- // Populate second level (certs).
- auto subnodes = std::make_unique<base::ListValue>();
- for (net::ScopedCERTCertificateList::const_iterator org_cert_it =
- i->second.begin();
- org_cert_it != i->second.end(); ++org_cert_it) {
- std::unique_ptr<base::DictionaryValue> cert_dict(
- new base::DictionaryValue);
- CERTCertificate* cert = org_cert_it->get();
- cert_dict->SetString(kCertificatesHandlerKeyField,
- cert_id_map_->CertToId(cert));
- cert_dict->SetString(
- kCertificatesHandlerNameField,
- certificate_manager_model_->GetColumnText(
- cert, CertificateManagerModel::COL_SUBJECT_NAME));
- cert_dict->SetBoolean(
- kCertificatesHandlerReadonlyField,
- certificate_manager_model_->cert_db()->IsReadOnly(cert));
- // Policy-installed certificates with web trust are trusted.
- bool policy_trusted =
- IsPolicyInstalledWithWebTrust(web_trust_certs, cert);
- cert_dict->SetBoolean(
- kCertificatesHandlerUntrustedField,
- !policy_trusted &&
- certificate_manager_model_->cert_db()->IsUntrusted(cert));
- cert_dict->SetBoolean(kCertificatesHandlerPolicyField, policy_trusted);
- // TODO(hshi): This should be determined by testing for PKCS #11
- // CKA_EXTRACTABLE attribute. We may need to use the NSS function
- // PK11_ReadRawAttribute to do that.
- cert_dict->SetBoolean(
- kCertificatesHandlerExtractableField,
- !certificate_manager_model_->IsHardwareBacked(cert));
- // TODO(mattm): Other columns.
- subnodes->Append(std::move(cert_dict));
- }
- std::sort(subnodes->begin(), subnodes->end(), comparator);
-
- dict->Set(kCertificatesHandlerSubnodesField, std::move(subnodes));
- nodes->Append(std::move(dict));
+ CertificateManagerModel::OrgGroupingMap org_grouping_map;
+
+ certificate_manager_model_->FilterAndBuildOrgGroupingMap(type,
+ &org_grouping_map);
+
+ base::ListValue nodes;
+ for (const auto& org_grouping_map_entry : org_grouping_map) {
+ // Populate first level (org name).
+ base::DictionaryValue org_dict;
+ org_dict.SetKey(kCertificatesHandlerKeyField,
+ base::Value(OrgNameToId(org_grouping_map_entry.first)));
+ org_dict.SetKey(kCertificatesHandlerNameField,
+ base::Value(org_grouping_map_entry.first));
+
+ // Populate second level (certs).
+ base::ListValue subnodes;
+ bool contains_policy_certs = false;
+ for (const auto& org_cert : org_grouping_map_entry.second) {
+ base::DictionaryValue cert_dict;
+ CERTCertificate* cert = org_cert->cert();
+ cert_dict.SetKey(kCertificatesHandlerKeyField,
+ base::Value(cert_id_map_->CertToId(cert)));
+ cert_dict.SetKey(kCertificatesHandlerNameField,
+ base::Value(org_cert->name()));
+ cert_dict.SetKey(kCertificatesHandlerReadonlyField,
+ base::Value(org_cert->read_only()));
+ cert_dict.SetKey(kCertificatesHandlerUntrustedField,
+ base::Value(org_cert->untrusted()));
+ cert_dict.SetKey(
+ kCertificatesHandlerPolicyInstalledField,
+ base::Value(org_cert->source() ==
+ CertificateManagerModel::CertInfo::Source::kPolicy));
+ cert_dict.SetKey(kCertificatesHandlerWebTrustAnchorField,
+ base::Value(org_cert->web_trust_anchor()));
+ // TODO(hshi): This should be determined by testing for PKCS #11
+ // CKA_EXTRACTABLE attribute. We may need to use the NSS function
+ // PK11_ReadRawAttribute to do that.
+ cert_dict.SetKey(kCertificatesHandlerExtractableField,
+ base::Value(!org_cert->hardware_backed()));
+ // TODO(mattm): Other columns.
+ subnodes.GetList().push_back(std::move(cert_dict));
+
+ contains_policy_certs |=
+ org_cert->source() ==
+ CertificateManagerModel::CertInfo::Source::kPolicy;
}
- std::sort(nodes->begin(), nodes->end(), comparator);
+ std::sort(subnodes.GetList().begin(), subnodes.GetList().end(), comparator);
- FireWebUIListener("certificates-changed", base::Value(tab_name), *nodes);
+ org_dict.SetKey(kCertificatesHandlerContainsPolicyCertsField,
+ base::Value(contains_policy_certs));
+ org_dict.SetKey(kCertificatesHandlerSubnodesField, std::move(subnodes));
+ nodes.GetList().push_back(std::move(org_dict));
}
+ std::sort(nodes.GetList().begin(), nodes.GetList().end(), comparator);
+
+ FireWebUIListener("certificates-changed", base::Value(tab_name),
+ std::move(nodes));
}
void CertificatesHandler::ResolveCallback(const base::Value& response) {
diff --git a/chromium/chrome/browser/ui/webui/certificates_handler.h b/chromium/chrome/browser/ui/webui/certificates_handler.h
index fa6047677ec..3e69636d8a7 100644
--- a/chromium/chrome/browser/ui/webui/certificates_handler.h
+++ b/chromium/chrome/browser/ui/webui/certificates_handler.h
@@ -136,14 +136,7 @@ class CertificatesHandler : public content::WebUIMessageHandler,
void HandleRefreshCertificates(const base::ListValue* args);
// Populate the given tab's tree.
- void PopulateTree(const std::string& tab_name,
- net::CertType type,
- const net::CertificateList& web_trust_certs);
-
- // Populate the tree after retrieving the list of policy-installed
- // web-trusted certificates.
- void OnPolicyWebTrustCertsRetrieved(
- const net::CertificateList& web_trust_certs);
+ void PopulateTree(const std::string& tab_name, net::CertType type);
void ResolveCallback(const base::Value& response);
void RejectCallback(const base::Value& response);
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 3940cb02397..ce230a0a720 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
@@ -15,6 +15,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/about_flags.h"
+#include "chrome/browser/accessibility/accessibility_ui.h"
#include "chrome/browser/devtools/devtools_ui_bindings.h"
#include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
#include "chrome/browser/engagement/site_engagement_service.h"
@@ -59,6 +60,7 @@
#include "chrome/browser/ui/webui/sync_internals_ui.h"
#include "chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.h"
#include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h"
+#include "chrome/browser/ui/webui/ukm/ukm_internals_ui.h"
#include "chrome/browser/ui/webui/usb_internals/usb_internals_ui.h"
#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
#include "chrome/browser/ui/webui/version_ui.h"
@@ -349,6 +351,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
// All platform builds of Chrome will need to have a cloud printing
// dialog as backup. It's just that on Chrome OS, it's the only
// print dialog.
+ if (url.host_piece() == chrome::kChromeUIAccessibilityHost)
+ return &NewWebUI<AccessibilityUI>;
if (url.host_piece() == chrome::kChromeUIBluetoothInternalsHost)
return &NewWebUI<BluetoothInternalsUI>;
if (url.host_piece() == chrome::kChromeUIComponentsHost)
@@ -409,6 +413,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<TaskSchedulerInternalsUI>;
if (url.host_piece() == chrome::kChromeUITranslateInternalsHost)
return &NewWebUI<TranslateInternalsUI>;
+ if (url.host_piece() == chrome::kChromeUIUkmHost)
+ return &NewWebUI<UkmInternalsUI>;
if (url.host_piece() == chrome::kChromeUIUsbInternalsHost)
return &NewWebUI<UsbInternalsUI>;
if (url.host_piece() == chrome::kChromeUIUserActionsHost)
@@ -482,7 +488,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chrome::kChromeUIKeyboardOverlayHost)
return &NewWebUI<KeyboardOverlayUI>;
if (url.host_piece() == chrome::kChromeUIMobileSetupHost)
- return &NewWebUI<MobileSetupUI>;
+ return &NewWebUI<chromeos::MobileSetupUI>;
if (url.host_piece() == chrome::kChromeUIMultiDeviceSetupHost)
return &NewWebUI<chromeos::multidevice_setup::MultiDeviceSetupDialogUI>;
if (url.host_piece() == chrome::kChromeUINetworkHost)
diff --git a/chromium/chrome/browser/ui/webui/chromeos/DEPS b/chromium/chrome/browser/ui/webui/chromeos/DEPS
index 3a2bdd04a8d..ef0d6e148d1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/DEPS
+++ b/chromium/chrome/browser/ui/webui/chromeos/DEPS
@@ -1,14 +1,9 @@
include_rules = [
- "+components/login",
- "+components/user_manager",
"+media/audio/sounds",
"+services/device/public/mojom",
]
specific_include_rules = {
- "drive_internals_ui\.cc": [
- "+components/drive"
- ],
"keyboard_overlay_ui\.cc": [
# TODO(mash): Remove. http://crbug.com/770866
"+ash/shell.h",
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc
index 8ad3c438e86..c550b13ee46 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc
@@ -4,202 +4,20 @@
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/grit/browser_resources.h"
-#include "chrome/grit/generated_resources.h"
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chromeos/services/assistant/public/mojom/constants.mojom.h"
#include "chromeos/services/assistant/public/proto/settings_ui.pb.h"
#include "components/arc/arc_prefs.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "services/service_manager/public/cpp/connector.h"
-#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
namespace {
-constexpr char kJsScreenPath[] = "assistantOptin";
-
-// Construct SettingsUiSelector for the ConsentFlow UI.
-assistant::SettingsUiSelector GetSettingsUiSelector() {
- assistant::SettingsUiSelector selector;
- assistant::ConsentFlowUiSelector* consent_flow_ui =
- selector.mutable_consent_flow_ui_selector();
- consent_flow_ui->set_flow_id(assistant::ActivityControlSettingsUiSelector::
- ASSISTANT_SUW_ONBOARDING_ON_CHROME_OS);
- selector.set_email_opt_in(true);
- return selector;
-}
-
-// Construct SettingsUiUpdate for user opt-in.
-assistant::SettingsUiUpdate GetSettingsUiUpdate(
- const std::string& consent_token) {
- assistant::SettingsUiUpdate update;
- assistant::ConsentFlowUiUpdate* consent_flow_update =
- update.mutable_consent_flow_ui_update();
- consent_flow_update->set_flow_id(
- assistant::ActivityControlSettingsUiSelector::
- ASSISTANT_SUW_ONBOARDING_ON_CHROME_OS);
- consent_flow_update->set_consent_token(consent_token);
-
- return update;
-}
-
-// Construct SettingsUiUpdate for email opt-in.
-assistant::SettingsUiUpdate GetEmailOptInUpdate(bool opted_in) {
- assistant::SettingsUiUpdate update;
- assistant::EmailOptInUpdate* email_optin_update =
- update.mutable_email_opt_in_update();
- email_optin_update->set_email_opt_in_update_state(
- opted_in ? assistant::EmailOptInUpdate::OPT_IN
- : assistant::EmailOptInUpdate::OPT_OUT);
-
- return update;
-}
-
-using SettingZippyList = google::protobuf::RepeatedPtrField<
- assistant::ClassicActivityControlUiTexts::SettingZippy>;
-// Helper method to create zippy data.
-base::ListValue CreateZippyData(const SettingZippyList& zippy_list) {
- base::ListValue zippy_data;
- for (auto& setting_zippy : zippy_list) {
- base::DictionaryValue data;
- data.SetString("title", setting_zippy.title());
- if (setting_zippy.description_paragraph_size()) {
- data.SetString("description", setting_zippy.description_paragraph(0));
- }
- if (setting_zippy.additional_info_paragraph_size()) {
- data.SetString("additionalInfo",
- setting_zippy.additional_info_paragraph(0));
- }
- data.SetString("iconUri", setting_zippy.icon_uri());
- zippy_data.GetList().push_back(std::move(data));
- }
- return zippy_data;
-}
-
-// Helper method to create disclosure data.
-base::ListValue CreateDisclosureData(const SettingZippyList& disclosure_list) {
- base::ListValue disclosure_data;
- for (auto& disclosure : disclosure_list) {
- base::DictionaryValue data;
- data.SetString("title", disclosure.title());
- if (disclosure.description_paragraph_size()) {
- data.SetString("description", disclosure.description_paragraph(0));
- }
- if (disclosure.additional_info_paragraph_size()) {
- data.SetString("additionalInfo", disclosure.additional_info_paragraph(0));
- }
- data.SetString("iconUri", disclosure.icon_uri());
- disclosure_data.GetList().push_back(std::move(data));
- }
- return disclosure_data;
-}
-
-// Helper method to create get more screen data.
-base::ListValue CreateGetMoreData(
- bool email_optin_needed,
- const assistant::EmailOptInUi& email_optin_ui) {
- base::ListValue get_more_data;
-
- // Process screen context data.
- base::DictionaryValue context_data;
- context_data.SetString(
- "title", l10n_util::GetStringUTF16(IDS_ASSISTANT_SCREEN_CONTEXT_TITLE));
- context_data.SetString("description", l10n_util::GetStringUTF16(
- IDS_ASSISTANT_SCREEN_CONTEXT_DESC));
- context_data.SetBoolean("defaultEnabled", true);
- context_data.SetString("iconUri",
- "https://www.gstatic.com/images/icons/material/system/"
- "2x/laptop_chromebook_grey600_24dp.png");
- get_more_data.GetList().push_back(std::move(context_data));
-
- // Process email optin data.
- if (email_optin_needed) {
- base::DictionaryValue data;
- data.SetString("title", email_optin_ui.title());
- data.SetString("description", email_optin_ui.description());
- data.SetBoolean("defaultEnabled", email_optin_ui.default_enabled());
- data.SetString("iconUri", email_optin_ui.icon_uri());
- get_more_data.GetList().push_back(std::move(data));
- }
-
- return get_more_data;
-}
-
-// Get string constants for settings ui.
-base::DictionaryValue GetSettingsUiStrings(
- const assistant::SettingsUi& settings_ui,
- bool activity_control_needed) {
- auto consent_ui = settings_ui.consent_flow_ui().consent_ui();
- auto confirm_reject_ui = consent_ui.activity_control_confirm_reject_ui();
- auto activity_control_ui = consent_ui.activity_control_ui();
- auto third_party_disclosure_ui = consent_ui.third_party_disclosure_ui();
- base::DictionaryValue dictionary;
-
- // Add activity controll string constants.
- if (activity_control_needed) {
- dictionary.SetString("valuePropIdentity", activity_control_ui.identity());
- if (activity_control_ui.intro_text_paragraph_size()) {
- dictionary.SetString("valuePropIntro",
- activity_control_ui.intro_text_paragraph(0));
- }
- if (activity_control_ui.footer_paragraph_size()) {
- dictionary.SetString("valuePropFooter",
- activity_control_ui.footer_paragraph(0));
- }
- dictionary.SetString("valuePropNextButton",
- consent_ui.accept_button_text());
- dictionary.SetString("valuePropSkipButton",
- consent_ui.reject_button_text());
- }
-
- // Add confirm reject screen string constants.
- // TODO(updowndota) Use remote strings after server bug fixed.
- dictionary.SetString(
- "confirmRejectTitle",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_CONFIRM_SCREEN_TITLE));
- dictionary.SetString(
- "confirmRejectAcceptTitle",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_CONFIRM_SCREEN_ACCEPT_TITLE));
- dictionary.SetString(
- "confirmRejectAcceptMessage",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_CONFIRM_SCREEN_ACCEPT_MESSAGE));
- dictionary.SetString(
- "confirmRejectAcceptMessageExpanded",
- l10n_util::GetStringUTF16(
- IDS_ASSISTANT_CONFIRM_SCREEN_ACCEPT_MESSAGE_EXPANDED));
- dictionary.SetString(
- "confirmRejectRejectTitle",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_CONFIRM_SCREEN_REJECT_TITLE));
- dictionary.SetString(
- "confirmRejectRejectMessage",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_CONFIRM_SCREEN_REJECT_MESSAGE));
- dictionary.SetString(
- "confirmRejectContinueButton",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_CONTINUE_BUTTON));
-
- // Add third party string constants.
- dictionary.SetString(
- "thirdPartyTitle",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_THIRD_PARTY_SCREEN_TITLE));
- dictionary.SetString(
- "thirdPartyContinueButton",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_CONTINUE_BUTTON));
- dictionary.SetString("thirdPartyFooter", consent_ui.tos_pp_links());
-
- // Add get more screen string constants.
- dictionary.SetString(
- "getMoreTitle",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_GET_MORE_SCREEN_TITLE));
- dictionary.SetString(
- "getMoreContinueButton",
- l10n_util::GetStringUTF16(IDS_ASSISTANT_CONTINUE_BUTTON));
-
- return dictionary;
-}
+constexpr char kJsScreenPath[] = "assistantOptInFlow";
} // namespace
@@ -211,19 +29,25 @@ AssistantOptInHandler::AssistantOptInHandler(
}
AssistantOptInHandler::~AssistantOptInHandler() {
- arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this);
+ if (arc::VoiceInteractionControllerClient::Get()) {
+ arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this);
+ }
}
void AssistantOptInHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {}
void AssistantOptInHandler::RegisterMessages() {
- AddCallback("initialized", &AssistantOptInHandler::HandleInitialized);
+ AddPrefixedCallback("initialized", &AssistantOptInHandler::HandleInitialized);
+ AddPrefixedCallback("hotwordResult",
+ &AssistantOptInHandler::HandleHotwordResult);
+ AddPrefixedCallback("flowFinished",
+ &AssistantOptInHandler::HandleFlowFinished);
}
void AssistantOptInHandler::Initialize() {
- if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() !=
- ash::mojom::VoiceInteractionState::RUNNING) {
+ if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() ==
+ ash::mojom::VoiceInteractionState::NOT_READY) {
arc::VoiceInteractionControllerClient::Get()->AddObserver(this);
} else {
BindAssistantSettingsManager();
@@ -235,19 +59,21 @@ void AssistantOptInHandler::ShowNextScreen() {
}
void AssistantOptInHandler::OnActivityControlOptInResult(bool opted_in) {
+ Profile* profile = Profile::FromWebUI(web_ui());
if (opted_in) {
+ RecordAssistantOptInStatus(ACTIVITY_CONTROL_ACCEPTED);
settings_manager_->UpdateSettings(
GetSettingsUiUpdate(consent_token_).SerializeAsString(),
base::BindOnce(&AssistantOptInHandler::OnUpdateSettingsResponse,
weak_factory_.GetWeakPtr()));
} else {
- PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
- prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
- false);
- prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true);
- prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, true);
+ RecordAssistantOptInStatus(ACTIVITY_CONTROL_SKIPPED);
+ profile->GetPrefs()->SetBoolean(
+ arc::prefs::kVoiceInteractionActivityControlAccepted, false);
CallJSOrDefer("closeDialog");
}
+
+ RecordActivityControlConsent(profile, ui_audit_key_, opted_in);
}
void AssistantOptInHandler::OnEmailOptInResult(bool opted_in) {
@@ -257,6 +83,7 @@ void AssistantOptInHandler::OnEmailOptInResult(bool opted_in) {
return;
}
+ RecordAssistantOptInStatus(opted_in ? EMAIL_OPTED_IN : EMAIL_OPTED_OUT);
settings_manager_->UpdateSettings(
GetEmailOptInUpdate(opted_in).SerializeAsString(),
base::BindOnce(&AssistantOptInHandler::OnUpdateSettingsResponse,
@@ -265,8 +92,10 @@ void AssistantOptInHandler::OnEmailOptInResult(bool opted_in) {
void AssistantOptInHandler::OnStateChanged(
ash::mojom::VoiceInteractionState state) {
- if (state == ash::mojom::VoiceInteractionState::RUNNING)
+ if (state != ash::mojom::VoiceInteractionState::NOT_READY) {
BindAssistantSettingsManager();
+ arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this);
+ }
}
void AssistantOptInHandler::BindAssistantSettingsManager() {
@@ -290,12 +119,12 @@ void AssistantOptInHandler::SendGetSettingsRequest() {
weak_factory_.GetWeakPtr()));
}
-void AssistantOptInHandler::ReloadContent(const base::DictionaryValue& dict) {
+void AssistantOptInHandler::ReloadContent(const base::Value& dict) {
CallJSOrDefer("reloadContent", dict);
}
void AssistantOptInHandler::AddSettingZippy(const std::string& type,
- const base::ListValue& data) {
+ const base::Value& data) {
CallJSOrDefer("addSettingZippy", type, data);
}
@@ -304,12 +133,14 @@ void AssistantOptInHandler::OnGetSettingsResponse(const std::string& settings) {
settings_ui.ParseFromString(settings);
DCHECK(settings_ui.has_consent_flow_ui());
+
+ RecordAssistantOptInStatus(FLOW_STARTED);
auto consent_ui = settings_ui.consent_flow_ui().consent_ui();
auto activity_control_ui = consent_ui.activity_control_ui();
- auto confirm_reject_ui = consent_ui.activity_control_confirm_reject_ui();
auto third_party_disclosure_ui = consent_ui.third_party_disclosure_ui();
consent_token_ = activity_control_ui.consent_token();
+ ui_audit_key_ = activity_control_ui.ui_audit_key();
// Process activity control data.
if (!activity_control_ui.setting_zippy().size()) {
@@ -318,8 +149,6 @@ void AssistantOptInHandler::OnGetSettingsResponse(const std::string& settings) {
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
true);
- prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true);
- prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, true);
ShowNextScreen();
} else {
AddSettingZippy("settings",
@@ -355,8 +184,6 @@ void AssistantOptInHandler::OnUpdateSettingsResponse(
PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
true);
- prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true);
- prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, true);
}
}
@@ -366,6 +193,12 @@ void AssistantOptInHandler::OnUpdateSettingsResponse(
// TODO(updowndta): Handle email optin update failure.
LOG(ERROR) << "Email OptIn udpate error.";
}
+ // Update hotword will cause Assistant restart. In order to make sure email
+ // optin request is successfully sent to server, update the hotword after
+ // email optin result has been received.
+ PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled,
+ enable_hotword_);
}
ShowNextScreen();
@@ -375,4 +208,20 @@ void AssistantOptInHandler::HandleInitialized() {
ExecuteDeferredJSCalls();
}
+void AssistantOptInHandler::HandleHotwordResult(bool enable_hotword) {
+ enable_hotword_ = enable_hotword;
+
+ if (!email_optin_needed_) {
+ // No need to send email optin result. Safe to update hotword pref and
+ // restart Assistant here.
+ PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled,
+ enable_hotword);
+ }
+}
+
+void AssistantOptInHandler::HandleFlowFinished() {
+ CallJSOrDefer("closeDialog");
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h
index 5f3dd0e5187..833d94ccf03 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h
@@ -46,8 +46,8 @@ class AssistantOptInHandler
void SendGetSettingsRequest();
// Send message and consent data to the page.
- void ReloadContent(const base::DictionaryValue& dict);
- void AddSettingZippy(const std::string& type, const base::ListValue& data);
+ void ReloadContent(const base::Value& dict);
+ void AddSettingZippy(const std::string& type, const base::Value& data);
// Handle response from the settings manager.
void OnGetSettingsResponse(const std::string& settings);
@@ -55,16 +55,24 @@ class AssistantOptInHandler
// Handler for JS WebUI message.
void HandleInitialized();
+ void HandleHotwordResult(bool enable_hotword);
+ void HandleFlowFinished();
// Consent token used to complete the opt-in.
std::string consent_token_;
+ // An opaque token for audit record.
+ std::string ui_audit_key_;
+
// Whether activity control is needed for user.
bool activity_control_needed_ = true;
// Whether email optin is needed for user.
bool email_optin_needed_ = false;
+ // Whether user chose to enable hotword.
+ bool enable_hotword_ = true;
+
assistant::mojom::AssistantSettingsManagerPtr settings_manager_;
base::WeakPtrFactory<AssistantOptInHandler> weak_factory_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h
deleted file mode 100644
index 40986386f49..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_SCREEN_EXIT_CODE_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_SCREEN_EXIT_CODE_H_
-
-#include <string>
-
-#include "base/callback.h"
-
-namespace chromeos {
-
-enum class AssistantOptInScreenExitCode {
- VALUE_PROP_SKIPPED = 0,
- VALUE_PROP_ACCEPTED = 1,
- THIRD_PARTY_CONTINUED = 2,
- EMAIL_OPTED_IN = 3,
- EMAIL_OPTED_OUT = 4,
- CONFIRM_ACCEPTED = 5,
- CONFIRM_REJECTED = 6,
- EXIT_CODES_COUNT
-};
-
-using OnAssistantOptInScreenExitCallback =
- base::OnceCallback<void(AssistantOptInScreenExitCode exit_code)>;
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_SCREEN_EXIT_CODE_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
index 754e9533c04..16f3211e37d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
@@ -6,11 +6,12 @@
#include <memory>
+#include "ash/public/cpp/shell_window_ids.h"
#include "base/bind.h"
#include "base/macros.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.h"
+#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h"
@@ -29,8 +30,8 @@ namespace {
bool is_active = false;
-constexpr int kAssistantOptInDialogWidth = 576;
-constexpr int kAssistantOptInDialogHeight = 480;
+constexpr int kAssistantOptInDialogWidth = 768;
+constexpr int kAssistantOptInDialogHeight = 640;
} // namespace
@@ -50,13 +51,12 @@ AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui)
AddScreenHandler(std::make_unique<ValuePropScreenHandler>(
base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr())));
- AddScreenHandler(std::make_unique<ConfirmRejectScreenHandler>(
- base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr())));
AddScreenHandler(std::make_unique<ThirdPartyScreenHandler>(
base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr())));
AddScreenHandler(std::make_unique<GetMoreScreenHandler>(
base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr())));
- AddScreenHandler(std::make_unique<ReadyScreenHandler>());
+ AddScreenHandler(std::make_unique<ReadyScreenHandler>(
+ base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr())));
base::DictionaryValue localized_strings;
for (auto* handler : screen_handlers_)
@@ -68,6 +68,10 @@ AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui)
source->AddResourcePath("assistant_logo.png", IDR_ASSISTANT_LOGO_PNG);
source->SetDefaultResource(IDR_ASSISTANT_OPTIN_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
+
+ // Make sure enable Assistant service since we need it during the flow.
+ PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true);
}
AssistantOptInUI::~AssistantOptInUI() = default;
@@ -81,17 +85,11 @@ void AssistantOptInUI::AddScreenHandler(
void AssistantOptInUI::OnExit(AssistantOptInScreenExitCode exit_code) {
switch (exit_code) {
case AssistantOptInScreenExitCode::VALUE_PROP_SKIPPED:
- assistant_handler_->ShowNextScreen();
+ assistant_handler_->OnActivityControlOptInResult(false);
break;
case AssistantOptInScreenExitCode::VALUE_PROP_ACCEPTED:
assistant_handler_->OnActivityControlOptInResult(true);
break;
- case AssistantOptInScreenExitCode::CONFIRM_ACCEPTED:
- assistant_handler_->OnActivityControlOptInResult(true);
- break;
- case AssistantOptInScreenExitCode::CONFIRM_REJECTED:
- assistant_handler_->OnActivityControlOptInResult(false);
- break;
case AssistantOptInScreenExitCode::THIRD_PARTY_CONTINUED:
assistant_handler_->ShowNextScreen();
break;
@@ -101,6 +99,9 @@ void AssistantOptInUI::OnExit(AssistantOptInScreenExitCode exit_code) {
case AssistantOptInScreenExitCode::EMAIL_OPTED_OUT:
assistant_handler_->OnEmailOptInResult(false);
break;
+ case AssistantOptInScreenExitCode::READY_SCREEN_CONTINUED:
+ CloseDialog(nullptr);
+ break;
default:
NOTREACHED();
}
@@ -113,7 +114,12 @@ void AssistantOptInDialog::Show(
ash::mojom::AssistantSetup::StartAssistantOptInFlowCallback callback) {
DCHECK(!is_active);
AssistantOptInDialog* dialog = new AssistantOptInDialog(std::move(callback));
- dialog->ShowSystemDialog(true);
+
+ int container_id = dialog->GetDialogModalType() == ui::MODAL_TYPE_NONE
+ ? ash::kShellWindowId_DefaultContainer
+ : ash::kShellWindowId_LockSystemModalContainer;
+ chrome::ShowWebDialogInContainer(
+ container_id, ProfileManager::GetActiveUserProfile(), dialog, true);
}
// static
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h
index 4174b738e37..062cf1b49be 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h
@@ -11,7 +11,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h"
-#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h"
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
#include "content/public/browser/web_ui_controller.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc
new file mode 100644
index 00000000000..fbce386db70
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc
@@ -0,0 +1,225 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
+
+#include "base/metrics/histogram_macros.h"
+#include "chrome/browser/consent_auditor/consent_auditor_factory.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
+#include "chrome/grit/browser_resources.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/arc/arc_prefs.h"
+#include "components/consent_auditor/consent_auditor.h"
+#include "components/signin/core/browser/signin_manager_base.h"
+#include "components/user_manager/user_manager.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/webui/web_ui_util.h"
+
+namespace chromeos {
+
+void RecordAssistantOptInStatus(AssistantOptInFlowStatus status) {
+ UMA_HISTOGRAM_ENUMERATION("Assistant.OptInFlowStatus", status, kMaxValue + 1);
+}
+
+// Construct SettingsUiSelector for the ConsentFlow UI.
+assistant::SettingsUiSelector GetSettingsUiSelector() {
+ assistant::SettingsUiSelector selector;
+ assistant::ConsentFlowUiSelector* consent_flow_ui =
+ selector.mutable_consent_flow_ui_selector();
+ consent_flow_ui->set_flow_id(assistant::ActivityControlSettingsUiSelector::
+ ASSISTANT_SUW_ONBOARDING_ON_CHROME_OS);
+ selector.set_email_opt_in(true);
+ return selector;
+}
+
+// Construct SettingsUiUpdate for user opt-in.
+assistant::SettingsUiUpdate GetSettingsUiUpdate(
+ const std::string& consent_token) {
+ assistant::SettingsUiUpdate update;
+ assistant::ConsentFlowUiUpdate* consent_flow_update =
+ update.mutable_consent_flow_ui_update();
+ consent_flow_update->set_flow_id(
+ assistant::ActivityControlSettingsUiSelector::
+ ASSISTANT_SUW_ONBOARDING_ON_CHROME_OS);
+ consent_flow_update->set_consent_token(consent_token);
+
+ return update;
+}
+
+// Construct SettingsUiUpdate for email opt-in.
+assistant::SettingsUiUpdate GetEmailOptInUpdate(bool opted_in) {
+ assistant::SettingsUiUpdate update;
+ assistant::EmailOptInUpdate* email_optin_update =
+ update.mutable_email_opt_in_update();
+ email_optin_update->set_email_opt_in_update_state(
+ opted_in ? assistant::EmailOptInUpdate::OPT_IN
+ : assistant::EmailOptInUpdate::OPT_OUT);
+
+ return update;
+}
+
+// Helper method to create zippy data.
+base::Value CreateZippyData(const SettingZippyList& zippy_list) {
+ base::Value zippy_data(base::Value::Type::LIST);
+ for (auto& setting_zippy : zippy_list) {
+ base::Value data(base::Value::Type::DICTIONARY);
+ data.SetKey("title", base::Value(setting_zippy.title()));
+ if (setting_zippy.description_paragraph_size()) {
+ data.SetKey("description",
+ base::Value(setting_zippy.description_paragraph(0)));
+ }
+ if (setting_zippy.additional_info_paragraph_size()) {
+ data.SetKey("additionalInfo",
+ base::Value(setting_zippy.additional_info_paragraph(0)));
+ }
+ data.SetKey("iconUri", base::Value(setting_zippy.icon_uri()));
+ data.SetKey("popupLink", base::Value(l10n_util::GetStringUTF16(
+ IDS_ASSISTANT_ACTIVITY_CONTROL_POPUP_LINK)));
+ zippy_data.GetList().push_back(std::move(data));
+ }
+ return zippy_data;
+}
+
+// Helper method to create disclosure data.
+base::Value CreateDisclosureData(const SettingZippyList& disclosure_list) {
+ base::Value disclosure_data(base::Value::Type::LIST);
+ for (auto& disclosure : disclosure_list) {
+ base::Value data(base::Value::Type::DICTIONARY);
+ data.SetKey("title", base::Value(disclosure.title()));
+ if (disclosure.description_paragraph_size()) {
+ data.SetKey("description",
+ base::Value(disclosure.description_paragraph(0)));
+ }
+ if (disclosure.additional_info_paragraph_size()) {
+ data.SetKey("additionalInfo",
+ base::Value(disclosure.additional_info_paragraph(0)));
+ }
+ data.SetKey("iconUri", base::Value(disclosure.icon_uri()));
+ disclosure_data.GetList().push_back(std::move(data));
+ }
+ return disclosure_data;
+}
+
+// Helper method to create get more screen data.
+base::Value CreateGetMoreData(bool email_optin_needed,
+ const assistant::EmailOptInUi& email_optin_ui) {
+ base::Value get_more_data(base::Value::Type::LIST);
+
+ // Process hotword data.
+ base::Value hotword_data(base::Value::Type::DICTIONARY);
+ hotword_data.SetKey(
+ "title",
+ base::Value(l10n_util::GetStringUTF16(IDS_ASSISTANT_HOTWORD_TITLE)));
+ hotword_data.SetKey(
+ "description",
+ base::Value(l10n_util::GetStringUTF16(IDS_ASSISTANT_HOTWORD_DESC)));
+ hotword_data.SetKey("defaultEnabled", base::Value(true));
+ hotword_data.SetKey(
+ "iconUri",
+ base::Value("https://www.gstatic.com/images/icons/material/system/"
+ "2x/mic_none_grey600_48dp.png"));
+ get_more_data.GetList().push_back(std::move(hotword_data));
+
+ // Process screen context data.
+ base::Value context_data(base::Value::Type::DICTIONARY);
+ context_data.SetKey("title", base::Value(l10n_util::GetStringUTF16(
+ IDS_ASSISTANT_SCREEN_CONTEXT_TITLE)));
+ context_data.SetKey("description", base::Value(l10n_util::GetStringUTF16(
+ IDS_ASSISTANT_SCREEN_CONTEXT_DESC)));
+ context_data.SetKey("defaultEnabled", base::Value(true));
+ context_data.SetKey(
+ "iconUri",
+ base::Value("https://www.gstatic.com/images/icons/material/system/"
+ "2x/laptop_chromebook_grey600_24dp.png"));
+ get_more_data.GetList().push_back(std::move(context_data));
+
+ // Process email optin data.
+ if (email_optin_needed) {
+ base::Value data(base::Value::Type::DICTIONARY);
+ data.SetKey("title", base::Value(email_optin_ui.title()));
+ data.SetKey("description", base::Value(email_optin_ui.description()));
+ data.SetKey("defaultEnabled",
+ base::Value(email_optin_ui.default_enabled()));
+ data.SetKey("iconUri", base::Value(email_optin_ui.icon_uri()));
+ data.SetKey("legalText", base::Value(email_optin_ui.legal_text()));
+ get_more_data.GetList().push_back(std::move(data));
+ }
+
+ return get_more_data;
+}
+
+// Get string constants for settings ui.
+base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui,
+ bool activity_control_needed) {
+ auto consent_ui = settings_ui.consent_flow_ui().consent_ui();
+ auto activity_control_ui = consent_ui.activity_control_ui();
+ auto third_party_disclosure_ui = consent_ui.third_party_disclosure_ui();
+ base::Value dictionary(base::Value::Type::DICTIONARY);
+
+ // Add activity controll string constants.
+ if (activity_control_needed) {
+ scoped_refptr<base::RefCountedMemory> image =
+ chromeos::UserImageSource::GetUserImage(
+ user_manager::UserManager::Get()->GetActiveUser()->GetAccountId());
+ std::string icon_url = webui::GetPngDataUrl(image->front(), image->size());
+ dictionary.SetKey("valuePropUserImage", base::Value(icon_url));
+
+ dictionary.SetKey("valuePropIdentity",
+ base::Value(activity_control_ui.identity()));
+ dictionary.SetKey("valuePropTitle",
+ base::Value(activity_control_ui.title()));
+ if (activity_control_ui.intro_text_paragraph_size()) {
+ dictionary.SetKey(
+ "valuePropIntro",
+ base::Value(activity_control_ui.intro_text_paragraph(0)));
+ }
+ if (activity_control_ui.footer_paragraph_size()) {
+ dictionary.SetKey("valuePropFooter",
+ base::Value(activity_control_ui.footer_paragraph(0)));
+ }
+ dictionary.SetKey("valuePropNextButton",
+ base::Value(consent_ui.accept_button_text()));
+ dictionary.SetKey("valuePropSkipButton",
+ base::Value(consent_ui.reject_button_text()));
+ }
+
+ // Add third party string constants.
+ dictionary.SetKey("thirdPartyTitle",
+ base::Value(third_party_disclosure_ui.title()));
+ dictionary.SetKey("thirdPartyContinueButton",
+ base::Value(third_party_disclosure_ui.button_continue()));
+ dictionary.SetKey("thirdPartyFooter", base::Value(consent_ui.tos_pp_links()));
+
+ // Add get more screen string constants.
+ dictionary.SetKey("getMoreTitle", base::Value(l10n_util::GetStringUTF16(
+ IDS_ASSISTANT_GET_MORE_SCREEN_TITLE)));
+ dictionary.SetKey("getMoreIntro", base::Value(l10n_util::GetStringUTF16(
+ IDS_ASSISTANT_GET_MORE_SCREEN_INTRO)));
+ dictionary.SetKey(
+ "getMoreContinueButton",
+ base::Value(l10n_util::GetStringUTF16(IDS_ASSISTANT_CONTINUE_BUTTON)));
+
+ return dictionary;
+}
+
+using sync_pb::UserConsentTypes;
+void RecordActivityControlConsent(Profile* profile,
+ std::string ui_audit_key,
+ bool opted_in) {
+ SigninManagerBase* signin_manager =
+ SigninManagerFactory::GetForProfile(profile);
+ DCHECK(signin_manager->IsAuthenticated());
+ std::string account_id = signin_manager->GetAuthenticatedAccountId();
+
+ UserConsentTypes::AssistantActivityControlConsent consent;
+ consent.set_ui_audit_key(ui_audit_key);
+ consent.set_status(opted_in ? UserConsentTypes::GIVEN
+ : UserConsentTypes::NOT_GIVEN);
+
+ ConsentAuditorFactory::GetForProfile(profile)
+ ->RecordAssistantActivityControlConsent(account_id, consent);
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h
new file mode 100644
index 00000000000..b1d35c07ce5
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h
@@ -0,0 +1,85 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_UTILS_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_UTILS_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chromeos/services/assistant/public/mojom/constants.mojom.h"
+#include "chromeos/services/assistant/public/proto/settings_ui.pb.h"
+#include "components/prefs/pref_service.h"
+#include "services/service_manager/public/cpp/connector.h"
+
+namespace chromeos {
+
+enum class AssistantOptInScreenExitCode {
+ VALUE_PROP_SKIPPED = 0,
+ VALUE_PROP_ACCEPTED = 1,
+ THIRD_PARTY_CONTINUED = 2,
+ EMAIL_OPTED_IN = 3,
+ EMAIL_OPTED_OUT = 4,
+ READY_SCREEN_CONTINUED = 5,
+ EXIT_CODES_COUNT
+};
+
+// Type of Assistant opt-in flow status. This enum is used to back an UMA
+// histogram and should be treated as append-only.
+enum AssistantOptInFlowStatus {
+ FLOW_STARTED = 0,
+ ACTIVITY_CONTROL_SHOWN,
+ ACTIVITY_CONTROL_ACCEPTED,
+ ACTIVITY_CONTROL_SKIPPED,
+ THIRD_PARTY_SHOWN,
+ THIRD_PARTY_CONTINUED,
+ GET_MORE_SHOWN,
+ EMAIL_OPTED_IN,
+ EMAIL_OPTED_OUT,
+ GET_MORE_CONTINUED,
+ READY_SCREEN_SHOWN,
+ READY_SCREEN_CONTINUED,
+ // Magic constant used by the histogram macros.
+ kMaxValue = READY_SCREEN_CONTINUED
+};
+
+using OnAssistantOptInScreenExitCallback =
+ base::OnceCallback<void(AssistantOptInScreenExitCode exit_code)>;
+
+void RecordAssistantOptInStatus(AssistantOptInFlowStatus);
+
+// Construct SettingsUiSelector for the ConsentFlow UI.
+assistant::SettingsUiSelector GetSettingsUiSelector();
+
+// Construct SettingsUiUpdate for user opt-in.
+assistant::SettingsUiUpdate GetSettingsUiUpdate(
+ const std::string& consent_token);
+
+// Construct SettingsUiUpdate for email opt-in.
+assistant::SettingsUiUpdate GetEmailOptInUpdate(bool opted_in);
+
+using SettingZippyList = google::protobuf::RepeatedPtrField<
+ assistant::ClassicActivityControlUiTexts::SettingZippy>;
+// Helper method to create zippy data.
+base::Value CreateZippyData(const SettingZippyList& zippy_list);
+
+// Helper method to create disclosure data.
+base::Value CreateDisclosureData(const SettingZippyList& disclosure_list);
+
+// Helper method to create get more screen data.
+base::Value CreateGetMoreData(bool email_optin_needed,
+ const assistant::EmailOptInUi& email_optin_ui);
+
+// Get string constants for settings ui.
+base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui,
+ bool activity_control_needed);
+
+void RecordActivityControlConsent(Profile* profile,
+ std::string ui_audit_key,
+ bool opted_in);
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_UTILS_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.cc
deleted file mode 100644
index 821e080e85c..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.h"
-
-#include "chrome/browser/browser_process.h"
-#include "chrome/grit/generated_resources.h"
-#include "components/login/localized_values_builder.h"
-
-namespace {
-
-constexpr char kJsScreenPath[] = "AssistantConfirmRejectScreen";
-
-} // namespace
-
-namespace chromeos {
-
-ConfirmRejectScreenHandler::ConfirmRejectScreenHandler(
- OnAssistantOptInScreenExitCallback callback)
- : BaseWebUIHandler(), exit_callback_(std::move(callback)) {
- set_call_js_prefix(kJsScreenPath);
-}
-
-ConfirmRejectScreenHandler::~ConfirmRejectScreenHandler() = default;
-
-void ConfirmRejectScreenHandler::DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) {}
-
-void ConfirmRejectScreenHandler::RegisterMessages() {
- AddPrefixedCallback("userActed",
- &ConfirmRejectScreenHandler::HandleUserAction);
-}
-
-void ConfirmRejectScreenHandler::Initialize() {}
-
-void ConfirmRejectScreenHandler::HandleUserAction(bool confirm_result) {
- DCHECK(exit_callback_);
- if (confirm_result) {
- std::move(exit_callback_)
- .Run(AssistantOptInScreenExitCode::CONFIRM_ACCEPTED);
- } else {
- std::move(exit_callback_)
- .Run(AssistantOptInScreenExitCode::CONFIRM_REJECTED);
- }
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.h
deleted file mode 100644
index b1022678261..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/confirm_reject_screen_handler.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_CONFIRM_REJECT_SCREEN_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_CONFIRM_REJECT_SCREEN_HANDLER_H_
-
-#include <memory>
-#include <string>
-
-#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h"
-#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
-
-namespace chromeos {
-
-class ConfirmRejectScreenHandler : public BaseWebUIHandler {
- public:
- explicit ConfirmRejectScreenHandler(
- OnAssistantOptInScreenExitCallback callback);
- ~ConfirmRejectScreenHandler() override;
-
- // BaseWebUIHandler:
- void DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) override;
- void RegisterMessages() override;
- void Initialize() override;
-
- private:
- void HandleUserAction(bool confirm_result);
-
- OnAssistantOptInScreenExitCallback exit_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(ConfirmRejectScreenHandler);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_CONFIRM_REJECT_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.cc
index d9864c4668f..2bfb15b9fe0 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.cc
@@ -13,7 +13,7 @@
namespace {
-constexpr char kJsScreenPath[] = "AssistantGetMoreScreen";
+constexpr char kJsScreenPath[] = "assistant.GetMoreScreen";
} // namespace
@@ -32,6 +32,7 @@ void GetMoreScreenHandler::DeclareLocalizedValues(
void GetMoreScreenHandler::RegisterMessages() {
AddPrefixedCallback("userActed", &GetMoreScreenHandler::HandleUserAction);
+ AddPrefixedCallback("screenShown", &GetMoreScreenHandler::HandleScreenShown);
}
void GetMoreScreenHandler::Initialize() {}
@@ -42,6 +43,7 @@ void GetMoreScreenHandler::HandleUserAction(const bool screen_context,
prefs->SetBoolean(arc::prefs::kVoiceInteractionContextEnabled,
screen_context);
+ RecordAssistantOptInStatus(GET_MORE_CONTINUED);
DCHECK(exit_callback_);
if (email_opted_in) {
std::move(exit_callback_).Run(AssistantOptInScreenExitCode::EMAIL_OPTED_IN);
@@ -51,4 +53,8 @@ void GetMoreScreenHandler::HandleUserAction(const bool screen_context,
}
}
+void GetMoreScreenHandler::HandleScreenShown() {
+ RecordAssistantOptInStatus(GET_MORE_SHOWN);
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h
index 5ee693ac156..4429fc55184 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h"
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
namespace chromeos {
@@ -27,6 +27,7 @@ class GetMoreScreenHandler : public BaseWebUIHandler {
private:
void HandleUserAction(const bool screen_context, const bool email_opted_in);
+ void HandleScreenShown();
OnAssistantOptInScreenExitCallback exit_callback_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.cc
index 268ce349dd3..1a1f4487bdc 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.cc
@@ -8,9 +8,21 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
+namespace {
+
+constexpr char kJsScreenPath[] = "assistant.ReadyScreen";
+
+constexpr char kUserActionNextPressed[] = "next-pressed";
+
+} // namespace
+
namespace chromeos {
-ReadyScreenHandler::ReadyScreenHandler() : BaseWebUIHandler() {}
+ReadyScreenHandler::ReadyScreenHandler(
+ OnAssistantOptInScreenExitCallback callback)
+ : BaseWebUIHandler(), exit_callback_(std::move(callback)) {
+ set_call_js_prefix(kJsScreenPath);
+}
ReadyScreenHandler::~ReadyScreenHandler() = default;
@@ -21,6 +33,24 @@ void ReadyScreenHandler::DeclareLocalizedValues(
builder->Add("assistantReadyButton", IDS_ASSISTANT_DONE_BUTTON);
}
+void ReadyScreenHandler::RegisterMessages() {
+ AddPrefixedCallback("userActed", &ReadyScreenHandler::HandleUserAction);
+ AddPrefixedCallback("screenShown", &ReadyScreenHandler::HandleScreenShown);
+}
+
void ReadyScreenHandler::Initialize() {}
+void ReadyScreenHandler::HandleUserAction(const std::string& action) {
+ DCHECK(exit_callback_);
+ if (action == kUserActionNextPressed) {
+ RecordAssistantOptInStatus(READY_SCREEN_CONTINUED);
+ std::move(exit_callback_)
+ .Run(AssistantOptInScreenExitCode::READY_SCREEN_CONTINUED);
+ }
+}
+
+void ReadyScreenHandler::HandleScreenShown() {
+ RecordAssistantOptInStatus(READY_SCREEN_SHOWN);
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h
index 0975ce8032d..6e71856a97d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h
@@ -9,22 +9,28 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h"
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
namespace chromeos {
class ReadyScreenHandler : public BaseWebUIHandler {
public:
- ReadyScreenHandler();
+ explicit ReadyScreenHandler(OnAssistantOptInScreenExitCallback callback);
~ReadyScreenHandler() override;
// BaseWebUIHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
+ void RegisterMessages() override;
void Initialize() override;
private:
+ void HandleUserAction(const std::string& action);
+ void HandleScreenShown();
+
+ OnAssistantOptInScreenExitCallback exit_callback_;
+
DISALLOW_COPY_AND_ASSIGN(ReadyScreenHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.cc
index 6489db3a11f..cdaed48da8d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.cc
@@ -10,7 +10,7 @@
namespace {
-constexpr char kJsScreenPath[] = "AssistantThirdPartyScreen";
+constexpr char kJsScreenPath[] = "assistant.ThirdPartyScreen";
constexpr char kUserActionNextPressed[] = "next-pressed";
@@ -31,6 +31,8 @@ void ThirdPartyScreenHandler::DeclareLocalizedValues(
void ThirdPartyScreenHandler::RegisterMessages() {
AddPrefixedCallback("userActed", &ThirdPartyScreenHandler::HandleUserAction);
+ AddPrefixedCallback("screenShown",
+ &ThirdPartyScreenHandler::HandleScreenShown);
}
void ThirdPartyScreenHandler::Initialize() {}
@@ -38,9 +40,14 @@ void ThirdPartyScreenHandler::Initialize() {}
void ThirdPartyScreenHandler::HandleUserAction(const std::string& action) {
DCHECK(exit_callback_);
if (action == kUserActionNextPressed) {
+ RecordAssistantOptInStatus(THIRD_PARTY_CONTINUED);
std::move(exit_callback_)
.Run(AssistantOptInScreenExitCode::THIRD_PARTY_CONTINUED);
}
}
+void ThirdPartyScreenHandler::HandleScreenShown() {
+ RecordAssistantOptInStatus(THIRD_PARTY_SHOWN);
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h
index 97228314c42..558b448709e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h"
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
namespace chromeos {
@@ -27,6 +27,7 @@ class ThirdPartyScreenHandler : public BaseWebUIHandler {
private:
void HandleUserAction(const std::string& action);
+ void HandleScreenShown();
OnAssistantOptInScreenExitCallback exit_callback_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc
index 095484482a4..5f05a52abc7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc
@@ -10,7 +10,7 @@
namespace {
-constexpr char kJsScreenPath[] = "AssistantValuePropScreen";
+constexpr char kJsScreenPath[] = "assistant.ValuePropScreen";
constexpr char kUserActionSkipPressed[] = "skip-pressed";
constexpr char kUserActionNextPressed[] = "next-pressed";
@@ -38,16 +38,19 @@ void ValuePropScreenHandler::DeclareLocalizedValues(
IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_TITLE);
builder->Add("assistantOptinLoadErrorMessage",
IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_MESSAGE);
+ builder->Add("assistantOptinSkipButton",
+ IDS_VOICE_INTERACTION_VALUE_PROP_SKIP_BUTTON);
builder->Add("assistantOptinRetryButton",
IDS_VOICE_INTERACTION_VALUE_PROP_RETRY_BUTTON);
- builder->Add("assistantOptinMoreButton",
- IDS_VOICE_INTERACTION_VALUE_PROP_MORE_BUTTION);
+ builder->Add("assistantOptinOKButton", IDS_OOBE_OK_BUTTON_TEXT);
builder->Add("back", IDS_EULA_BACK_BUTTON);
builder->Add("next", IDS_EULA_NEXT_BUTTON);
}
void ValuePropScreenHandler::RegisterMessages() {
AddPrefixedCallback("userActed", &ValuePropScreenHandler::HandleUserAction);
+ AddPrefixedCallback("screenShown",
+ &ValuePropScreenHandler::HandleScreenShown);
}
void ValuePropScreenHandler::Initialize() {}
@@ -62,4 +65,8 @@ void ValuePropScreenHandler::HandleUserAction(const std::string& action) {
.Run(AssistantOptInScreenExitCode::VALUE_PROP_ACCEPTED);
}
+void ValuePropScreenHandler::HandleScreenShown() {
+ RecordAssistantOptInStatus(ACTIVITY_CONTROL_SHOWN);
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h
index ec8e0324871..65e13af43c6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h"
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
namespace chromeos {
@@ -27,6 +27,7 @@ class ValuePropScreenHandler : public BaseWebUIHandler {
private:
void HandleUserAction(const std::string& action);
+ void HandleScreenShown();
OnAssistantOptInScreenExitCallback exit_callback_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
index 2a0a1b3bdf6..72498815027 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
@@ -13,6 +13,8 @@
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_features.h"
+#include "device/bluetooth/bluetooth_device.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
@@ -41,8 +43,14 @@ BluetoothPairingDialog* BluetoothPairingDialog::ShowDialog(
const base::string16& name_for_display,
bool paired,
bool connected) {
- BluetoothPairingDialog* dialog =
- new BluetoothPairingDialog(address, name_for_display, paired, connected);
+ std::string cannonical_address =
+ device::BluetoothDevice::CanonicalizeAddress(address);
+ if (cannonical_address.empty()) {
+ LOG(ERROR) << "BluetoothPairingDialog: Invalid address: " << address;
+ return nullptr;
+ }
+ BluetoothPairingDialog* dialog = new BluetoothPairingDialog(
+ cannonical_address, name_for_display, paired, connected);
dialog->ShowSystemDialog();
return dialog;
}
@@ -86,7 +94,10 @@ BluetoothPairingDialogUI::BluetoothPairingDialogUI(content::WebUI* web_ui)
source->SetJsonPath("strings.js");
#if BUILDFLAG(OPTIMIZE_WEBUI)
source->UseGzip();
- source->SetDefaultResource(IDR_BLUETOOTH_PAIRING_DIALOG_VULCANIZED_HTML);
+ source->SetDefaultResource(
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2) ?
+ IDR_BLUETOOTH_PAIRING_DIALOG_VULCANIZED_P2_HTML :
+ IDR_BLUETOOTH_PAIRING_DIALOG_VULCANIZED_HTML);
source->AddResourcePath("crisper.js",
IDR_BLUETOOTH_PAIRING_DIALOG_CRISPER_JS);
#else
diff --git a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
index af67afa5562..13c32f05652 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <fstream>
#include <memory>
#include <utility>
@@ -17,9 +18,11 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
+#include "base/strings/pattern.h"
+#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "chrome/browser/chromeos/drive/debug_info_collector.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
@@ -52,6 +55,32 @@ namespace chromeos {
namespace {
+constexpr char kKey[] = "key";
+constexpr char kValue[] = "value";
+constexpr char kClass[] = "class";
+
+constexpr const char* const kLogLevelName[] = {"info", "warning", "error"};
+
+size_t SeverityToLogLevelNameIndex(logging::LogSeverity severity) {
+ if (severity <= logging::LOG_INFO)
+ return 0;
+ if (severity == logging::LOG_WARNING)
+ return 1;
+ return 2;
+}
+
+size_t LogMarkToLogLevelNameIndex(char mark) {
+ switch (mark) {
+ case 'I':
+ case 'V':
+ return 0;
+ case 'W':
+ return 1;
+ default:
+ return 2;
+ }
+}
+
// Gets metadata of all files and directories in |root_path|
// recursively. Stores the result as a list of dictionaries like:
//
@@ -189,27 +218,73 @@ std::string FormatEntry(const base::FilePath& path,
return out;
}
-std::string SeverityToString(logging::LogSeverity severity) {
- switch (severity) {
- case logging::LOG_INFO:
- return "info";
- case logging::LOG_WARNING:
- return "warning";
- case logging::LOG_ERROR:
- return "error";
- default: // Treat all other higher severities as ERROR.
- return "error";
- }
-}
-
-// Appends {'key': key, 'value': value} dictionary to the |list|.
+// Appends {'key': key, 'value': value, 'class': clazz} dictionary to the
+// |list|.
void AppendKeyValue(base::ListValue* list,
- const std::string& key,
- const std::string& value) {
+ std::string key,
+ std::string value,
+ std::string clazz = std::string()) {
auto dict = std::make_unique<base::DictionaryValue>();
- dict->SetString("key", key);
- dict->SetString("value", value);
- list->Append(std::move(dict));
+ dict->SetPath({kKey}, base::Value(std::move(key)));
+ dict->SetPath({kValue}, base::Value(std::move(value)));
+ if (!clazz.empty())
+ dict->SetPath({kClass}, base::Value(std::move(clazz)));
+ list->GetList().push_back(std::move(*dict));
+}
+
+ino_t GetInodeValue(const base::FilePath& path) {
+ struct stat file_stats;
+ if (stat(path.value().c_str(), &file_stats) != 0)
+ return 0;
+ return file_stats.st_ino;
+}
+
+std::pair<ino_t, base::ListValue> GetServiceLogContents(
+ const base::FilePath& log_path,
+ ino_t inode,
+ int from_line_number) {
+ base::ListValue result;
+
+ std::ifstream log(log_path.value());
+ if (log.good()) {
+ ino_t new_inode = GetInodeValue(log_path);
+ if (new_inode != inode) {
+ // Apparently log was recreated. Re-read the log.
+ from_line_number = 0;
+ inode = new_inode;
+ }
+
+ base::Time time;
+ constexpr char kTimestampPattern[] = R"(????-??-??T??:??:??.???Z? )";
+ const size_t pattern_length = strlen(kTimestampPattern);
+
+ std::string line;
+ int line_number = 0;
+ while (log.good()) {
+ std::getline(log, line);
+ if (line.empty() || ++line_number <= from_line_number) {
+ continue;
+ }
+
+ base::StringPiece log_line = line;
+ size_t severity_index = 0;
+ if (base::MatchPattern(log_line.substr(0, pattern_length),
+ kTimestampPattern) &&
+ google_apis::util::GetTimeFromString(
+ log_line.substr(0, pattern_length - 2), &time)) {
+ severity_index = LogMarkToLogLevelNameIndex(line[pattern_length - 2]);
+ line = line.substr(pattern_length);
+ }
+ const char* const severity = kLogLevelName[severity_index];
+
+ AppendKeyValue(&result,
+ google_apis::util::FormatTimeAsStringLocaltime(time),
+ base::StrCat({"[", severity, "] ", line}),
+ base::StrCat({"log-", severity}));
+ }
+ }
+
+ return {inode, std::move(result)};
}
// Class to handle messages from chrome://drive-internals.
@@ -255,6 +330,7 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
void UpdateCacheContentsSection(
drive::DebugInfoCollector* debug_info_collector);
void UpdateEventLogSection();
+ void UpdateServiceLogSection();
void UpdatePathConfigurationsSection();
// Called when GetGCacheContents() is complete.
@@ -306,9 +382,21 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
// Called after file system reset for ResetDriveFileSystem is done.
void ResetFinished(bool success);
+ // Called when service logs are read.
+ void OnServiceLogRead(std::pair<ino_t, base::ListValue>);
+
// The last event sent to the JavaScript side.
int last_sent_event_id_;
+ // The last line of service log sent to the JS side.
+ int last_sent_line_number_;
+
+ // The inode of the log file.
+ ino_t service_log_file_inode_;
+
+ // Service log file is being parsed.
+ bool service_log_file_is_processing_ = false;
+
base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler);
};
@@ -461,6 +549,9 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
// and resent whole the logs to the page.
last_sent_event_id_ = -1;
UpdateEventLogSection();
+ last_sent_line_number_ = 0;
+ service_log_file_inode_ = 0;
+ UpdateServiceLogSection();
}
void DriveInternalsWebUIHandler::UpdateDriveRelatedPreferencesSection() {
@@ -680,7 +771,8 @@ void DriveInternalsWebUIHandler::UpdateGCacheContentsSection() {
// Start updating the GCache contents section.
Profile* profile = Profile::FromWebUI(web_ui());
- const base::FilePath root_path = drive::util::GetCacheRootPath(profile);
+ const base::FilePath root_path =
+ drive::util::GetCacheRootPath(profile).DirName();
base::ListValue* gcache_contents = new base::ListValue;
base::DictionaryValue* gcache_summary = new base::DictionaryValue;
base::PostTaskWithTraitsAndReply(
@@ -705,9 +797,8 @@ void DriveInternalsWebUIHandler::UpdateFileSystemContentsSection() {
debug_info_collector->GetResourceEntry(
root_path,
- base::Bind(&DriveInternalsWebUIHandler::OnGetResourceEntryByPath,
- weak_ptr_factory_.GetWeakPtr(),
- root_path));
+ base::BindOnce(&DriveInternalsWebUIHandler::OnGetResourceEntryByPath,
+ weak_ptr_factory_.GetWeakPtr(), root_path));
debug_info_collector->ReadDirectory(
root_path,
@@ -762,20 +853,54 @@ void DriveInternalsWebUIHandler::UpdateEventLogSection() {
if (log[i].id <= last_sent_event_id_)
continue;
- std::string severity = SeverityToString(log[i].severity);
-
- auto dict = std::make_unique<base::DictionaryValue>();
- dict->SetString("key",
- google_apis::util::FormatTimeAsStringLocaltime(log[i].when));
- dict->SetString("value", "[" + severity + "] " + log[i].what);
- dict->SetString("class", "log-" + severity);
- list.Append(std::move(dict));
+ const char* const severity =
+ kLogLevelName[SeverityToLogLevelNameIndex(log[i].severity)];
+ AppendKeyValue(&list,
+ google_apis::util::FormatTimeAsStringLocaltime(log[i].when),
+ base::StrCat({"[", severity, "] ", log[i].what}),
+ base::StrCat({"log-", severity}));
last_sent_event_id_ = log[i].id;
}
if (!list.empty())
web_ui()->CallJavascriptFunctionUnsafe("updateEventLog", list);
}
+void DriveInternalsWebUIHandler::UpdateServiceLogSection() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (service_log_file_is_processing_)
+ return;
+ service_log_file_is_processing_ = true;
+
+ drive::DriveIntegrationService* integration_service = GetIntegrationService();
+ if (!integration_service)
+ return;
+ base::FilePath log_path = integration_service->GetDriveFsLogPath();
+ if (log_path.empty())
+ return;
+
+ base::PostTaskWithTraitsAndReplyWithResult(
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
+ base::BindOnce(&GetServiceLogContents, log_path, service_log_file_inode_,
+ last_sent_line_number_),
+ base::BindOnce(&DriveInternalsWebUIHandler::OnServiceLogRead,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void DriveInternalsWebUIHandler::OnServiceLogRead(
+ std::pair<ino_t, base::ListValue> response) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (service_log_file_inode_ != response.first) {
+ service_log_file_inode_ = response.first;
+ last_sent_line_number_ = 0;
+ }
+ if (!response.second.empty()) {
+ web_ui()->CallJavascriptFunctionUnsafe("updateServiceLog", response.second);
+ last_sent_line_number_ += response.second.GetList().size();
+ }
+ service_log_file_is_processing_ = false;
+}
+
void DriveInternalsWebUIHandler::UpdatePathConfigurationsSection() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -786,9 +911,11 @@ void DriveInternalsWebUIHandler::UpdatePathConfigurationsSection() {
AppendKeyValue(
&paths, "Downloads",
file_manager::util::GetDownloadsFolderForProfile(profile).AsUTF8Unsafe());
- AppendKeyValue(
- &paths, "Drive",
- drive::util::GetDriveMountPointPath(profile).AsUTF8Unsafe());
+ const auto* integration_service = GetIntegrationService();
+ if (integration_service && integration_service->IsMounted()) {
+ AppendKeyValue(&paths, "Drive",
+ integration_service->GetMountPointPath().AsUTF8Unsafe());
+ }
const char* kPathPreferences[] = {
prefs::kSelectFileLastDirectory,
@@ -898,6 +1025,7 @@ void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) {
return;
UpdateEventLogSection();
+ UpdateServiceLogSection();
drive::JobListInterface* job_list = integration_service->job_list();
if (job_list) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emulator/DEPS b/chromium/chrome/browser/ui/webui/chromeos/emulator/DEPS
deleted file mode 100644
index e9d9de6def2..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/emulator/DEPS
+++ /dev/null
@@ -1,7 +0,0 @@
-specific_include_rules = {
- "device_emulator_message_handler\.cc": [
- # TODO(mash): Remove. http://crbug.com/756094
- "+ash/shell.h",
- "+ash/system/bluetooth/tray_bluetooth_helper.h",
- ],
-}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc
index 8aa100ecda3..c88d7153051 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
@@ -7,18 +7,19 @@
#include <stdint.h>
#include <utility>
-#include "ash/shell.h"
-#include "ash/system/bluetooth/tray_bluetooth_helper.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "chrome/browser/chromeos/system/fake_input_device_settings.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
+#include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_cras_audio_client.h"
#include "chromeos/dbus/fake_power_manager_client.h"
#include "content/public/browser/web_ui.h"
+#include "device/bluetooth/bluetooth_adapter_factory.h"
+#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
#include "device/bluetooth/dbus/fake_bluetooth_device_client.h"
@@ -119,8 +120,8 @@ void DeviceEmulatorMessageHandler::BluetoothObserver::DeviceAdded(
}
void DeviceEmulatorMessageHandler::BluetoothObserver::DevicePropertyChanged(
- const dbus::ObjectPath& object_path,
- const std::string& property_name) {
+ const dbus::ObjectPath& object_path,
+ const std::string& property_name) {
if (property_name == kPairedPropertyName) {
owner_->web_ui()->CallJavascriptFunctionUnsafe(
kDevicePairedFromTrayJSCallback, base::Value(object_path.value()));
@@ -161,8 +162,7 @@ void DeviceEmulatorMessageHandler::CrasAudioObserver::NodesChanged() {
class DeviceEmulatorMessageHandler::PowerObserver
: public PowerManagerClient::Observer {
public:
- explicit PowerObserver(DeviceEmulatorMessageHandler* owner)
- : owner_(owner) {
+ explicit PowerObserver(DeviceEmulatorMessageHandler* owner) : owner_(owner) {
owner_->fake_power_manager_client_->AddObserver(this);
}
@@ -170,13 +170,12 @@ class DeviceEmulatorMessageHandler::PowerObserver
owner_->fake_power_manager_client_->RemoveObserver(this);
}
- void PowerChanged(
- const power_manager::PowerSupplyProperties& proto) override;
+ void PowerChanged(const power_manager::PowerSupplyProperties& proto) override;
private:
- DeviceEmulatorMessageHandler* owner_;
+ DeviceEmulatorMessageHandler* owner_;
- DISALLOW_COPY_AND_ASSIGN(PowerObserver);
+ DISALLOW_COPY_AND_ASSIGN(PowerObserver);
};
void DeviceEmulatorMessageHandler::PowerObserver::PowerChanged(
@@ -200,23 +199,32 @@ void DeviceEmulatorMessageHandler::PowerObserver::PowerChanged(
DeviceEmulatorMessageHandler::DeviceEmulatorMessageHandler()
: fake_bluetooth_device_client_(
static_cast<bluez::FakeBluetoothDeviceClient*>(
- bluez::BluezDBusManager::Get()
- ->GetBluetoothDeviceClient())),
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient())),
fake_cras_audio_client_(static_cast<chromeos::FakeCrasAudioClient*>(
- chromeos::DBusThreadManager::Get()
- ->GetCrasAudioClient())),
+ chromeos::DBusThreadManager::Get()->GetCrasAudioClient())),
fake_power_manager_client_(static_cast<chromeos::FakePowerManagerClient*>(
- chromeos::DBusThreadManager::Get()
- ->GetPowerManagerClient())),
- weak_ptr_factory_(this) {}
-
-DeviceEmulatorMessageHandler::~DeviceEmulatorMessageHandler() {
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient())),
+ weak_ptr_factory_(this) {
+ device::BluetoothAdapterFactory::GetAdapter(
+ base::Bind(&DeviceEmulatorMessageHandler::BluetoothDeviceAdapterReady,
+ weak_ptr_factory_.GetWeakPtr()));
}
+DeviceEmulatorMessageHandler::~DeviceEmulatorMessageHandler() {}
+
void DeviceEmulatorMessageHandler::Init(const base::ListValue* args) {
AllowJavascript();
}
+void DeviceEmulatorMessageHandler::BluetoothDeviceAdapterReady(
+ scoped_refptr<device::BluetoothAdapter> adapter) {
+ if (!adapter) {
+ LOG(ERROR) << "Bluetooth adapter not available";
+ return;
+ }
+ bluetooth_adapter_ = adapter;
+}
+
void DeviceEmulatorMessageHandler::RequestPowerInfo(
const base::ListValue* args) {
fake_power_manager_client_->RequestStatusUpdate();
@@ -287,8 +295,7 @@ void DeviceEmulatorMessageHandler::HandleRequestBluetoothPair(
// Try to pair the device with the main adapter. The device is identified
// by its device ID, which, in this case is the same as its address.
- ash::Shell::Get()->tray_bluetooth_helper()->ConnectToBluetoothDevice(
- props->address.value());
+ ConnectToBluetoothDevice(props->address.value());
if (!props->paired.value()) {
web_ui()->CallJavascriptFunctionUnsafe(kPairFailedJSCallback,
base::Value(path));
@@ -445,8 +452,8 @@ void DeviceEmulatorMessageHandler::UpdatePowerSources(
port));
std::string power_level;
CHECK(dict->GetString("power", &power_level));
- source->set_max_power(
- power_level == "high" ? kPowerLevelHigh : kPowerLevelLow);
+ source->set_max_power(power_level == "high" ? kPowerLevelHigh
+ : kPowerLevelLow);
if (id == selected_id)
selected_source = source;
}
@@ -630,6 +637,29 @@ DeviceEmulatorMessageHandler::GetDeviceInfo(
return device;
}
+void DeviceEmulatorMessageHandler::ConnectToBluetoothDevice(
+ const std::string& address) {
+ if (!bluetooth_adapter_) {
+ LOG(ERROR) << "Bluetooth adapter not ready";
+ return;
+ }
+ device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address);
+ if (!device || device->IsConnecting() ||
+ (device->IsPaired() &&
+ (device->IsConnected() || !device->IsConnectable()))) {
+ return;
+ }
+ if (!device->IsPaired() && device->IsPairable()) {
+ // Show pairing dialog for the unpaired device.
+ chromeos::BluetoothPairingDialog::ShowDialog(
+ device->GetAddress(), device->GetNameForDisplay(), device->IsPaired(),
+ device->IsConnected());
+ } else {
+ // Attempt to connect to the device.
+ device->Connect(nullptr, base::DoNothing(), base::DoNothing());
+ }
+}
+
void DeviceEmulatorMessageHandler::TouchpadExists(bool exists) {
if (!IsJavascriptAllowed())
return;
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 9b5099d0082..9c6690616ff 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
@@ -8,10 +8,12 @@
#include <memory>
#include "base/macros.h"
+#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/system/pointer_device_observer.h"
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "device/bluetooth/bluetooth_adapter.h"
namespace base {
class DictionaryValue;
@@ -107,6 +109,9 @@ class DeviceEmulatorMessageHandler :
class CrasAudioObserver;
class PowerObserver;
+ void BluetoothDeviceAdapterReady(
+ scoped_refptr<device::BluetoothAdapter> adapter);
+
// Creates a bluetooth device with the properties given in |args|. |args|
// should contain a dictionary so that each dictionary value can be mapped
// to its respective property upon creating the device. Returns the device
@@ -118,6 +123,8 @@ class DeviceEmulatorMessageHandler :
std::unique_ptr<base::DictionaryValue> GetDeviceInfo(
const dbus::ObjectPath& object_path);
+ void ConnectToBluetoothDevice(const std::string& address);
+
// system::PointerDeviceObserver::Observer:
void TouchpadExists(bool exists) override;
void MouseExists(bool exists) override;
@@ -131,6 +138,8 @@ class DeviceEmulatorMessageHandler :
FakePowerManagerClient* fake_power_manager_client_;
std::unique_ptr<PowerObserver> power_observer_;
+ scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
+
base::WeakPtrFactory<DeviceEmulatorMessageHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DeviceEmulatorMessageHandler);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc
index 5b5c071700f..97562f89390 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h"
+#include "ash/public/cpp/ash_features.h"
#include "base/bind.h"
#include "base/values.h"
#include "chromeos/chromeos_switches.h"
@@ -50,6 +51,8 @@ void FirstRunHandler::ShowStepPositioned(const std::string& name,
step_params.SetKey(
"voiceInteractionEnabled",
base::Value(chromeos::switches::IsVoiceInteractionEnabled()));
+ step_params.SetKey("unifiedSystemTrayEnabled",
+ base::Value(ash::features::IsSystemTrayUnifiedEnabled()));
web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.showStep", step_params);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/image_source.cc b/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
index 67ea4411f91..9145713af6c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
@@ -15,8 +15,8 @@
#include "base/memory/ref_counted_memory.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/task_scheduler/task_scheduler.h"
+#include "base/task/post_task.h"
+#include "base/task/task_scheduler/task_scheduler.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chromeos/login/users/avatar/user_image_loader.h"
#include "chrome/common/url_constants.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc
index 0591f3b24f6..514fa719425 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/internet_config_dialog.cc
@@ -17,6 +17,7 @@
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_features.h"
namespace chromeos {
@@ -115,7 +116,10 @@ InternetConfigDialogUI::InternetConfigDialogUI(content::WebUI* web_ui)
source->SetJsonPath("strings.js");
#if BUILDFLAG(OPTIMIZE_WEBUI)
source->UseGzip();
- source->SetDefaultResource(IDR_INTERNET_CONFIG_DIALOG_VULCANIZED_HTML);
+ source->SetDefaultResource(
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2) ?
+ IDR_INTERNET_CONFIG_DIALOG_VULCANIZED_P2_HTML :
+ IDR_INTERNET_CONFIG_DIALOG_VULCANIZED_HTML);
source->AddResourcePath("crisper.js", IDR_INTERNET_CONFIG_DIALOG_CRISPER_JS);
#else
source->SetDefaultResource(IDR_INTERNET_CONFIG_DIALOG_HTML);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc
index a05bb03c5dc..91daeef0759 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/internet_detail_dialog.cc
@@ -18,6 +18,7 @@
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_features.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
@@ -131,7 +132,10 @@ InternetDetailDialogUI::InternetDetailDialogUI(content::WebUI* web_ui)
source->SetJsonPath("strings.js");
#if BUILDFLAG(OPTIMIZE_WEBUI)
source->UseGzip();
- source->SetDefaultResource(IDR_INTERNET_DETAIL_DIALOG_VULCANIZED_HTML);
+ source->SetDefaultResource(
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2) ?
+ IDR_INTERNET_DETAIL_DIALOG_VULCANIZED_P2_HTML :
+ IDR_INTERNET_DETAIL_DIALOG_VULCANIZED_HTML);
source->AddResourcePath("crisper.js", IDR_INTERNET_DETAIL_DIALOG_CRISPER_JS);
#else
source->SetDefaultResource(IDR_INTERNET_DETAIL_DIALOG_HTML);
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 bc31372f2a9..a20c7a94568 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
@@ -5,13 +5,26 @@
#include "chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h"
#include "chrome/browser/chromeos/login/screens/app_downloading_screen.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/grit/generated_resources.h"
+#include "components/arc/arc_prefs.h"
#include "components/login/localized_values_builder.h"
+#include "components/prefs/pref_service.h"
+#include "ui/base/resource/resource_bundle.h"
namespace {
const char kJsScreenPath[] = "login.AppDownloadingScreen";
+int GetNumberOfUserSelectedApps() {
+ const Profile* profile = ProfileManager::GetActiveUserProfile();
+ const PrefService* pref_service = profile->GetPrefs();
+ return static_cast<int>(
+ pref_service->Get(arc::prefs::kArcFastAppReinstallPackages)
+ ->GetList()
+ .size());
+}
+
} // namespace
namespace chromeos {
@@ -25,8 +38,10 @@ AppDownloadingScreenHandler::~AppDownloadingScreenHandler() {}
void AppDownloadingScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->Add("appDownloadingScreenTitle",
- IDS_LOGIN_APP_DOWNLOADING_SCREEN_TITLE);
+ builder->Add("appDownloadingScreenTitleSingular",
+ IDS_LOGIN_APP_DOWNLOADING_SCREEN_TITLE_SINGULAR);
+ builder->Add("appDownloadingScreenTitlePlural",
+ IDS_LOGIN_APP_DOWNLOADING_SCREEN_TITLE_PLURAL);
builder->Add("appDownloadingScreenDescription",
IDS_LOGIN_APP_DOWNLOADING_SCREEN_DESCRIPTION);
builder->Add("appDownloadingContinueSetup",
@@ -44,6 +59,8 @@ void AppDownloadingScreenHandler::Bind(AppDownloadingScreen* screen) {
void AppDownloadingScreenHandler::Show() {
ShowScreen(kScreenId);
+ CallJS("updateNumberOfSelectedApps",
+ base::Value(GetNumberOfUserSelectedApps()));
}
void AppDownloadingScreenHandler::Hide() {}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc
index 763a78625a8..8b3d420b688 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/i18n/timezone.h"
+#include "base/sha1.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler.h"
@@ -32,6 +33,15 @@
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
+using ArcBackupAndRestoreConsent =
+ sync_pb::UserConsentTypes::ArcBackupAndRestoreConsent;
+using ArcGoogleLocationServiceConsent =
+ sync_pb::UserConsentTypes::ArcGoogleLocationServiceConsent;
+using ArcPlayTermsOfServiceConsent =
+ sync_pb::UserConsentTypes::ArcPlayTermsOfServiceConsent;
+
+using sync_pb::UserConsentTypes;
+
namespace {
const char kJsScreenPath[] = "login.ArcTermsOfServiceScreen";
@@ -296,32 +306,44 @@ void ArcTermsOfServiceScreenHandler::RecordConsents(
DCHECK(signin_manager->IsAuthenticated());
const std::string account_id = signin_manager->GetAuthenticatedAccountId();
- // TODO(jhorwich): Replace this approach when passing |is_managed| boolean is
- // supported by the underlying consent protos.
- const std::vector<int> consent_ids = ArcSupportHost::ComputePlayToSConsentIds(
- record_tos_content ? tos_content : "");
-
- consent_auditor->RecordGaiaConsent(
- account_id, consent_auditor::Feature::PLAY_STORE, consent_ids,
- IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT,
- tos_accepted ? consent_auditor::ConsentStatus::GIVEN
- : consent_auditor::ConsentStatus::NOT_GIVEN);
+ ArcPlayTermsOfServiceConsent play_consent;
+ play_consent.set_status(tos_accepted ? UserConsentTypes::GIVEN
+ : UserConsentTypes::NOT_GIVEN);
+ play_consent.set_confirmation_grd_id(IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT);
+ play_consent.set_consent_flow(ArcPlayTermsOfServiceConsent::SETUP);
+ if (record_tos_content) {
+ play_consent.set_play_terms_of_service_text_length(tos_content.length());
+ play_consent.set_play_terms_of_service_hash(
+ base::SHA1HashString(tos_content));
+ }
+ consent_auditor->RecordArcPlayConsent(account_id, play_consent);
if (record_backup_consent) {
- consent_auditor->RecordGaiaConsent(
- account_id, consent_auditor::Feature::BACKUP_AND_RESTORE,
- {IDS_ARC_OPT_IN_DIALOG_BACKUP_RESTORE},
- IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT,
- backup_accepted ? consent_auditor::ConsentStatus::GIVEN
- : consent_auditor::ConsentStatus::NOT_GIVEN);
+ ArcBackupAndRestoreConsent backup_and_restore_consent;
+ backup_and_restore_consent.set_confirmation_grd_id(
+ IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT);
+ backup_and_restore_consent.add_description_grd_ids(
+ IDS_ARC_OPT_IN_DIALOG_BACKUP_RESTORE);
+ backup_and_restore_consent.set_status(backup_accepted
+ ? UserConsentTypes::GIVEN
+ : UserConsentTypes::NOT_GIVEN);
+
+ consent_auditor->RecordArcBackupAndRestoreConsent(
+ account_id, backup_and_restore_consent);
}
if (record_location_consent) {
- consent_auditor->RecordGaiaConsent(
- account_id, consent_auditor::Feature::GOOGLE_LOCATION_SERVICE,
- {IDS_ARC_OPT_IN_LOCATION_SETTING}, IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT,
- location_accepted ? consent_auditor::ConsentStatus::GIVEN
- : consent_auditor::ConsentStatus::NOT_GIVEN);
+ ArcGoogleLocationServiceConsent location_service_consent;
+ location_service_consent.set_confirmation_grd_id(
+ IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT);
+ location_service_consent.add_description_grd_ids(
+ IDS_ARC_OPT_IN_LOCATION_SETTING);
+ location_service_consent.set_status(location_accepted
+ ? UserConsentTypes::GIVEN
+ : UserConsentTypes::NOT_GIVEN);
+
+ consent_auditor->RecordArcGoogleLocationServiceConsent(
+ account_id, location_service_consent);
}
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
index 5bc0eafabf8..e63def59f34 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
@@ -101,7 +101,8 @@ class ArcTermsOfServiceScreenHandler
void OnBackupAndRestoreModeChanged(bool enabled, bool managed) override;
void OnLocationServicesModeChanged(bool enabled, bool managed) override;
- base::ObserverList<ArcTermsOfServiceScreenViewObserver, true> observer_list_;
+ base::ObserverList<ArcTermsOfServiceScreenViewObserver, true>::Unchecked
+ observer_list_;
// Whether the screen should be shown right after initialization.
bool show_on_init_ = false;
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
new file mode 100644
index 00000000000..50203401165
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
@@ -0,0 +1,363 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h"
+
+#include "chrome/browser/chromeos/login/oobe_screen.h"
+#include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
+#include "chrome/grit/browser_resources.h"
+#include "chrome/grit/generated_resources.h"
+#include "chromeos/services/assistant/public/mojom/constants.mojom.h"
+#include "chromeos/services/assistant/public/proto/settings_ui.pb.h"
+#include "components/arc/arc_prefs.h"
+#include "components/login/localized_values_builder.h"
+#include "components/prefs/pref_service.h"
+#include "services/service_manager/public/cpp/connector.h"
+
+namespace chromeos {
+
+namespace {
+
+constexpr char kJsScreenPath[] = "login.AssistantOptInFlowScreen";
+constexpr char kSkipPressed[] = "skip-pressed";
+constexpr char kNextPressed[] = "next-pressed";
+constexpr char kFlowFinished[] = "flow-finished";
+
+} // namespace
+
+AssistantOptInFlowScreenHandler::AssistantOptInFlowScreenHandler()
+ : BaseScreenHandler(kScreenId), weak_factory_(this) {
+ set_call_js_prefix(kJsScreenPath);
+}
+
+AssistantOptInFlowScreenHandler::~AssistantOptInFlowScreenHandler() {
+ if (arc::VoiceInteractionControllerClient::Get()) {
+ arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this);
+ }
+ if (screen_) {
+ screen_->OnViewDestroyed(this);
+ }
+}
+
+void AssistantOptInFlowScreenHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("assistantOptinLoading",
+ IDS_VOICE_INTERACTION_VALUE_PROP_LOADING);
+ builder->Add("assistantOptinLoadErrorTitle",
+ IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_TITLE);
+ builder->Add("assistantOptinLoadErrorMessage",
+ IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_MESSAGE);
+ builder->Add("assistantOptinSkipButton",
+ IDS_VOICE_INTERACTION_VALUE_PROP_SKIP_BUTTON);
+ builder->Add("assistantOptinRetryButton",
+ IDS_VOICE_INTERACTION_VALUE_PROP_RETRY_BUTTON);
+ builder->Add("assistantOptinOKButton", IDS_OOBE_OK_BUTTON_TEXT);
+ builder->Add("assistantReadyTitle", IDS_ASSISTANT_READY_SCREEN_TITLE);
+ builder->Add("assistantReadyMessage", IDS_ASSISTANT_READY_SCREEN_MESSAGE);
+ builder->Add("assistantReadyButton", IDS_ASSISTANT_DONE_BUTTON);
+}
+
+void AssistantOptInFlowScreenHandler::RegisterMessages() {
+ AddCallback(
+ "assistant.ValuePropScreen.userActed",
+ &AssistantOptInFlowScreenHandler::HandleValuePropScreenUserAction);
+ AddCallback(
+ "assistant.ThirdPartyScreen.userActed",
+ &AssistantOptInFlowScreenHandler::HandleThirdPartyScreenUserAction);
+ AddCallback("assistant.GetMoreScreen.userActed",
+ &AssistantOptInFlowScreenHandler::HandleGetMoreScreenUserAction);
+ AddCallback("assistant.ReadyScreen.userActed",
+ &AssistantOptInFlowScreenHandler::HandleReadyScreenUserAction);
+ AddCallback("assistant.ValuePropScreen.screenShown",
+ &AssistantOptInFlowScreenHandler::HandleValuePropScreenShown);
+ AddCallback("assistant.ThirdPartyScreen.screenShown",
+ &AssistantOptInFlowScreenHandler::HandleThirdPartyScreenShown);
+ AddCallback("assistant.GetMoreScreen.screenShown",
+ &AssistantOptInFlowScreenHandler::HandleGetMoreScreenShown);
+ AddCallback("assistant.ReadyScreen.screenShown",
+ &AssistantOptInFlowScreenHandler::HandleReadyScreenShown);
+ AddCallback("assistantOptInFlow.hotwordResult",
+ &AssistantOptInFlowScreenHandler::HandleHotwordResult);
+ AddCallback("assistantOptInFlow.flowFinished",
+ &AssistantOptInFlowScreenHandler::HandleFlowFinished);
+ AddCallback("assistantOptInFlow.initialized",
+ &AssistantOptInFlowScreenHandler::HandleFlowInitialized);
+}
+
+void AssistantOptInFlowScreenHandler::Bind(AssistantOptInFlowScreen* screen) {
+ BaseScreenHandler::SetBaseScreen(screen);
+ screen_ = screen;
+ if (page_is_ready())
+ Initialize();
+}
+
+void AssistantOptInFlowScreenHandler::Unbind() {
+ screen_ = nullptr;
+ BaseScreenHandler::SetBaseScreen(nullptr);
+}
+
+void AssistantOptInFlowScreenHandler::Show() {
+ // Make sure enable Assistant service since we need it during the flow.
+ PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true);
+
+ if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() ==
+ ash::mojom::VoiceInteractionState::NOT_READY) {
+ arc::VoiceInteractionControllerClient::Get()->AddObserver(this);
+ } else {
+ BindAssistantSettingsManager();
+ }
+
+ if (!page_is_ready() || !screen_) {
+ show_on_init_ = true;
+ return;
+ }
+
+ ShowScreen(kScreenId);
+}
+
+void AssistantOptInFlowScreenHandler::Hide() {}
+
+void AssistantOptInFlowScreenHandler::Initialize() {
+ if (!screen_ || !show_on_init_)
+ return;
+
+ Show();
+ show_on_init_ = false;
+}
+
+void AssistantOptInFlowScreenHandler::ShowNextScreen() {
+ CallJS("showNextScreen");
+}
+
+void AssistantOptInFlowScreenHandler::OnActivityControlOptInResult(
+ bool opted_in) {
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ if (opted_in) {
+ RecordAssistantOptInStatus(ACTIVITY_CONTROL_ACCEPTED);
+ settings_manager_->UpdateSettings(
+ GetSettingsUiUpdate(consent_token_).SerializeAsString(),
+ base::BindOnce(
+ &AssistantOptInFlowScreenHandler::OnUpdateSettingsResponse,
+ weak_factory_.GetWeakPtr()));
+ } else {
+ RecordAssistantOptInStatus(ACTIVITY_CONTROL_SKIPPED);
+ profile->GetPrefs()->SetBoolean(
+ arc::prefs::kVoiceInteractionActivityControlAccepted, false);
+ screen_->OnUserAction(kFlowFinished);
+ }
+
+ RecordActivityControlConsent(profile, ui_audit_key_, opted_in);
+}
+
+void AssistantOptInFlowScreenHandler::OnEmailOptInResult(bool opted_in) {
+ if (!email_optin_needed_) {
+ DCHECK(!opted_in);
+ ShowNextScreen();
+ return;
+ }
+
+ RecordAssistantOptInStatus(opted_in ? EMAIL_OPTED_IN : EMAIL_OPTED_OUT);
+ settings_manager_->UpdateSettings(
+ GetEmailOptInUpdate(opted_in).SerializeAsString(),
+ base::BindOnce(&AssistantOptInFlowScreenHandler::OnUpdateSettingsResponse,
+ weak_factory_.GetWeakPtr()));
+}
+
+void AssistantOptInFlowScreenHandler::OnStateChanged(
+ ash::mojom::VoiceInteractionState state) {
+ if (state != ash::mojom::VoiceInteractionState::NOT_READY) {
+ BindAssistantSettingsManager();
+ arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this);
+ }
+}
+
+void AssistantOptInFlowScreenHandler::BindAssistantSettingsManager() {
+ if (settings_manager_.is_bound())
+ return;
+
+ // Set up settings mojom.
+ service_manager::Connector* connector =
+ content::BrowserContext::GetConnectorFor(
+ ProfileManager::GetActiveUserProfile());
+ connector->BindInterface(assistant::mojom::kServiceName,
+ mojo::MakeRequest(&settings_manager_));
+
+ SendGetSettingsRequest();
+}
+
+void AssistantOptInFlowScreenHandler::SendGetSettingsRequest() {
+ assistant::SettingsUiSelector selector = GetSettingsUiSelector();
+ settings_manager_->GetSettings(
+ selector.SerializeAsString(),
+ base::BindOnce(&AssistantOptInFlowScreenHandler::OnGetSettingsResponse,
+ weak_factory_.GetWeakPtr()));
+}
+
+void AssistantOptInFlowScreenHandler::ReloadContent(const base::Value& dict) {
+ CallJS("reloadContent", dict);
+}
+
+void AssistantOptInFlowScreenHandler::AddSettingZippy(const std::string& type,
+ const base::Value& data) {
+ CallJS("addSettingZippy", type, data);
+}
+
+void AssistantOptInFlowScreenHandler::OnGetSettingsResponse(
+ const std::string& settings) {
+ assistant::SettingsUi settings_ui;
+ settings_ui.ParseFromString(settings);
+
+ DCHECK(settings_ui.has_consent_flow_ui());
+
+ RecordAssistantOptInStatus(FLOW_STARTED);
+ auto consent_ui = settings_ui.consent_flow_ui().consent_ui();
+ auto activity_control_ui = consent_ui.activity_control_ui();
+ auto third_party_disclosure_ui = consent_ui.third_party_disclosure_ui();
+
+ consent_token_ = activity_control_ui.consent_token();
+ ui_audit_key_ = activity_control_ui.ui_audit_key();
+
+ // Process activity control data.
+ if (!activity_control_ui.setting_zippy().size()) {
+ // No need to consent. Move to the next screen.
+ activity_control_needed_ = false;
+ PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
+ true);
+ ShowNextScreen();
+ } else {
+ AddSettingZippy("settings",
+ CreateZippyData(activity_control_ui.setting_zippy()));
+ }
+
+ // Process third party disclosure data.
+ AddSettingZippy("disclosure", CreateDisclosureData(
+ third_party_disclosure_ui.disclosures()));
+
+ // Process get more data.
+ email_optin_needed_ = settings_ui.has_email_opt_in_ui() &&
+ settings_ui.email_opt_in_ui().has_title();
+ AddSettingZippy("get-more", CreateGetMoreData(email_optin_needed_,
+ settings_ui.email_opt_in_ui()));
+
+ // Pass string constants dictionary.
+ ReloadContent(GetSettingsUiStrings(settings_ui, activity_control_needed_));
+}
+
+void AssistantOptInFlowScreenHandler::OnUpdateSettingsResponse(
+ const std::string& result) {
+ assistant::SettingsUiUpdateResult ui_result;
+ ui_result.ParseFromString(result);
+
+ if (ui_result.has_consent_flow_update_result()) {
+ if (ui_result.consent_flow_update_result().update_status() !=
+ assistant::ConsentFlowUiUpdateResult::SUCCESS) {
+ // TODO(updowndta): Handle consent update failure.
+ LOG(ERROR) << "Consent udpate error.";
+ } else if (activity_control_needed_) {
+ activity_control_needed_ = false;
+ PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted,
+ true);
+ }
+ }
+
+ if (ui_result.has_email_opt_in_update_result()) {
+ if (ui_result.email_opt_in_update_result().update_status() !=
+ assistant::EmailOptInUpdateResult::SUCCESS) {
+ // TODO(updowndta): Handle email optin update failure.
+ LOG(ERROR) << "Email OptIn udpate error.";
+ }
+ // Update hotword will cause Assistant restart. In order to make sure email
+ // optin request is successfully sent to server, update the hotword after
+ // email optin result has been received.
+ PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled,
+ enable_hotword_);
+ }
+
+ ShowNextScreen();
+}
+
+void AssistantOptInFlowScreenHandler::HandleHotwordResult(bool enable_hotword) {
+ enable_hotword_ = enable_hotword;
+
+ if (!email_optin_needed_) {
+ // No need to send email optin result. Safe to update hotword pref and
+ // restart Assistant here.
+ PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled,
+ enable_hotword);
+ }
+}
+
+void AssistantOptInFlowScreenHandler::HandleLoadingScreenUserAction(
+ const std::string& action) {
+ if (action == kSkipPressed) {
+ screen_->OnUserAction(kFlowFinished);
+ }
+}
+
+void AssistantOptInFlowScreenHandler::HandleValuePropScreenUserAction(
+ const std::string& action) {
+ if (action == kSkipPressed) {
+ OnActivityControlOptInResult(false);
+ } else if (action == kNextPressed) {
+ OnActivityControlOptInResult(true);
+ }
+}
+
+void AssistantOptInFlowScreenHandler::HandleThirdPartyScreenUserAction(
+ const std::string& action) {
+ if (action == kNextPressed) {
+ RecordAssistantOptInStatus(THIRD_PARTY_CONTINUED);
+ ShowNextScreen();
+ }
+}
+
+void AssistantOptInFlowScreenHandler::HandleGetMoreScreenUserAction(
+ const bool screen_context,
+ const bool email_opted_in) {
+ RecordAssistantOptInStatus(GET_MORE_CONTINUED);
+ PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionContextEnabled,
+ screen_context);
+ OnEmailOptInResult(email_opted_in);
+}
+
+void AssistantOptInFlowScreenHandler::HandleReadyScreenUserAction(
+ const std::string& action) {
+ if (action == kNextPressed) {
+ RecordAssistantOptInStatus(READY_SCREEN_CONTINUED);
+ screen_->OnUserAction(kFlowFinished);
+ }
+}
+
+void AssistantOptInFlowScreenHandler::HandleValuePropScreenShown() {
+ RecordAssistantOptInStatus(ACTIVITY_CONTROL_SHOWN);
+}
+
+void AssistantOptInFlowScreenHandler::HandleThirdPartyScreenShown() {
+ RecordAssistantOptInStatus(THIRD_PARTY_SHOWN);
+}
+
+void AssistantOptInFlowScreenHandler::HandleGetMoreScreenShown() {
+ RecordAssistantOptInStatus(GET_MORE_SHOWN);
+}
+
+void AssistantOptInFlowScreenHandler::HandleReadyScreenShown() {
+ RecordAssistantOptInStatus(READY_SCREEN_SHOWN);
+}
+
+void AssistantOptInFlowScreenHandler::HandleFlowFinished() {
+ screen_->OnUserAction(kFlowFinished);
+}
+
+void AssistantOptInFlowScreenHandler::HandleFlowInitialized() {}
+
+} // 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
new file mode 100644
index 00000000000..bcd0ff69667
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h
@@ -0,0 +1,110 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ASSISTANT_OPTIN_FLOW_SCREEN_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ASSISTANT_OPTIN_FLOW_SCREEN_HANDLER_H_
+
+#include <memory>
+#include <string>
+
+#include "base/macros.h"
+#include "chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h"
+#include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen_view.h"
+#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
+#include "chromeos/services/assistant/public/mojom/settings.mojom.h"
+
+namespace chromeos {
+
+// TODO(updowndota): Refactor to reuse AssistantOptInHandler methods.
+class AssistantOptInFlowScreenHandler
+ : public BaseScreenHandler,
+ public AssistantOptInFlowScreenView,
+ public arc::VoiceInteractionControllerClient::Observer {
+ public:
+ AssistantOptInFlowScreenHandler();
+ ~AssistantOptInFlowScreenHandler() override;
+
+ // BaseScreenHandler:
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void RegisterMessages() override;
+
+ // AssistantOptInFlowScreenView:
+ void Bind(AssistantOptInFlowScreen* screen) override;
+ void Unbind() override;
+ void Show() override;
+ void Hide() override;
+
+ // Send messages to the page.
+ void ShowNextScreen();
+
+ // Handle user opt-in result.
+ void OnActivityControlOptInResult(bool opted_in);
+ void OnEmailOptInResult(bool opted_in);
+
+ private:
+ // BaseScreenHandler:
+ void Initialize() override;
+
+ // arc::VoiceInteractionControllerClient::Observer overrides
+ void OnStateChanged(ash::mojom::VoiceInteractionState state) override;
+
+ // Connect to assistant settings manager.
+ void BindAssistantSettingsManager();
+
+ // Send GetSettings request for the opt-in UI.
+ void SendGetSettingsRequest();
+
+ // Send message and consent data to the page.
+ void ReloadContent(const base::Value& dict);
+ void AddSettingZippy(const std::string& type, const base::Value& data);
+
+ // Handle response from the settings manager.
+ void OnGetSettingsResponse(const std::string& settings);
+ void OnUpdateSettingsResponse(const std::string& settings);
+
+ // Handler for JS WebUI message.
+ void HandleLoadingScreenUserAction(const std::string& action);
+ void HandleValuePropScreenUserAction(const std::string& action);
+ void HandleThirdPartyScreenUserAction(const std::string& action);
+ void HandleGetMoreScreenUserAction(const bool screen_context,
+ const bool email_opted_in);
+ void HandleReadyScreenUserAction(const std::string& action);
+ void HandleValuePropScreenShown();
+ void HandleThirdPartyScreenShown();
+ void HandleGetMoreScreenShown();
+ void HandleReadyScreenShown();
+ void HandleHotwordResult(bool enable_hotword);
+ void HandleFlowFinished();
+ void HandleFlowInitialized();
+
+ AssistantOptInFlowScreen* screen_ = nullptr;
+
+ // Whether the screen should be shown right after initialization.
+ bool show_on_init_ = false;
+
+ // Consent token used to complete the opt-in.
+ std::string consent_token_;
+
+ // An opaque token for audit record.
+ std::string ui_audit_key_;
+
+ // Whether activity control is needed for user.
+ bool activity_control_needed_ = true;
+
+ // Whether email optin is needed for user.
+ bool email_optin_needed_ = false;
+
+ // Whether user chose to enable hotword.
+ bool enable_hotword_ = true;
+
+ assistant::mojom::AssistantSettingsManagerPtr settings_manager_;
+ base::WeakPtrFactory<AssistantOptInFlowScreenHandler> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(AssistantOptInFlowScreenHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ASSISTANT_OPTIN_FLOW_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
index 919aa82003b..6137e9ad4e4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
@@ -10,11 +10,13 @@
#include "ash/public/interfaces/event_rewriter_controller.mojom.h"
#include "ash/shell.h"
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
+#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
#include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
@@ -92,15 +94,11 @@ CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui,
weak_ptr_factory_(this) {
DCHECK(js_calls_container);
set_call_js_prefix(kJsScreenPath);
- if (features::IsAshInBrowserProcess()) {
- AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
- CHECK(accessibility_manager);
- accessibility_subscription_ = accessibility_manager->RegisterCallback(
- base::Bind(&CoreOobeHandler::OnAccessibilityStatusChanged,
- base::Unretained(this)));
- } else {
- NOTIMPLEMENTED();
- }
+ AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
+ CHECK(accessibility_manager);
+ accessibility_subscription_ = accessibility_manager->RegisterCallback(
+ base::Bind(&CoreOobeHandler::OnAccessibilityStatusChanged,
+ base::Unretained(this)));
TabletModeClient* tablet_mode_client = TabletModeClient::Get();
tablet_mode_client->AddObserver(this);
@@ -129,9 +127,11 @@ void CoreOobeHandler::DeclareLocalizedValues(
// OOBE accessibility options menu strings shown on each screen.
builder->Add("accessibilityLink", IDS_OOBE_ACCESSIBILITY_LINK);
builder->Add("spokenFeedbackOption", IDS_OOBE_SPOKEN_FEEDBACK_OPTION);
+ builder->Add("selectToSpeakOption", IDS_OOBE_SELECT_TO_SPEAK_OPTION);
builder->Add("largeCursorOption", IDS_OOBE_LARGE_CURSOR_OPTION);
builder->Add("highContrastOption", IDS_OOBE_HIGH_CONTRAST_MODE_OPTION);
builder->Add("screenMagnifierOption", IDS_OOBE_SCREEN_MAGNIFIER_OPTION);
+ builder->Add("dockedMagnifierOption", IDS_OOBE_DOCKED_MAGNIFIER_OPTION);
builder->Add("virtualKeyboardOption", IDS_OOBE_VIRTUAL_KEYBOARD_OPTION);
builder->Add("closeAccessibilityMenu", IDS_OOBE_CLOSE_ACCESSIBILITY_MENU);
@@ -183,6 +183,8 @@ void CoreOobeHandler::Initialize() {
void CoreOobeHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
dict->SetKey("isInTabletMode",
base::Value(TabletModeClient::Get()->tablet_mode_enabled()));
+ dict->SetKey("isDemoModeEnabled",
+ base::Value(DemoSetupController::IsDemoModeAllowed()));
}
void CoreOobeHandler::RegisterMessages() {
@@ -199,6 +201,10 @@ void CoreOobeHandler::RegisterMessages() {
&CoreOobeHandler::HandleEnableScreenMagnifier);
AddCallback("enableSpokenFeedback",
&CoreOobeHandler::HandleEnableSpokenFeedback);
+ AddCallback("enableSelectToSpeak",
+ &CoreOobeHandler::HandleEnableSelectToSpeak);
+ AddCallback("enableDockedMagnifier",
+ &CoreOobeHandler::HandleEnableDockedMagnifier);
AddCallback("setDeviceRequisition",
&CoreOobeHandler::HandleSetDeviceRequisition);
AddCallback("screenAssetsLoaded", &CoreOobeHandler::HandleScreenAssetsLoaded);
@@ -348,7 +354,6 @@ void CoreOobeHandler::HandleEnableVirtualKeyboard(bool enabled) {
}
void CoreOobeHandler::HandleEnableScreenMagnifier(bool enabled) {
- // TODO(nkostylev): Add support for partial screen magnifier.
DCHECK(MagnificationManager::Get());
MagnificationManager::Get()->SetMagnifierEnabled(enabled);
}
@@ -356,8 +361,22 @@ void CoreOobeHandler::HandleEnableScreenMagnifier(bool enabled) {
void CoreOobeHandler::HandleEnableSpokenFeedback(bool /* enabled */) {
// Checkbox is initialized on page init and updates when spoken feedback
// setting is changed so just toggle spoken feedback here.
- AccessibilityManager* manager = AccessibilityManager::Get();
- manager->EnableSpokenFeedback(!manager->IsSpokenFeedbackEnabled());
+ AccessibilityManager::Get()->EnableSpokenFeedback(
+ !AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
+}
+
+void CoreOobeHandler::HandleEnableSelectToSpeak(bool /* enabled */) {
+ // Checkbox is initialized on page init and updates when Select to Speak
+ // setting is changed so just toggle Select to Speak here.
+ AccessibilityManager::Get()->SetSelectToSpeakEnabled(
+ !AccessibilityManager::Get()->IsSelectToSpeakEnabled());
+}
+
+void CoreOobeHandler::HandleEnableDockedMagnifier(bool enabled) {
+ // Checkbox is initialized on page init and updates when the docked magnifier
+ // setting is changed so just toggle Select to Speak here.
+ DCHECK(MagnificationManager::Get());
+ MagnificationManager::Get()->SetDockedMagnifierEnabled(enabled);
}
void CoreOobeHandler::HandleSetDeviceRequisition(
@@ -417,12 +436,17 @@ void CoreOobeHandler::HandleToggleResetScreen() {
// purpose of installing a TPM firmware update.
tpm_firmware_update::GetAvailableUpdateModes(
base::BindOnce([](const std::set<tpm_firmware_update::Mode>& modes) {
- if (modes.count(tpm_firmware_update::Mode::kPowerwash) > 0) {
+ using tpm_firmware_update::Mode;
+ for (Mode mode : {Mode::kPowerwash, Mode::kCleanup}) {
+ if (modes.count(mode) == 0)
+ continue;
+
// Force the TPM firmware update option to be enabled.
g_browser_process->local_state()->SetInteger(
prefs::kFactoryResetTPMFirmwareUpdateMode,
- static_cast<int>(tpm_firmware_update::Mode::kPowerwash));
+ static_cast<int>(mode));
LaunchResetScreen();
+ return;
}
}),
base::TimeDelta());
@@ -469,12 +493,6 @@ void CoreOobeHandler::ForwardAccelerator(std::string accelerator_name) {
}
void CoreOobeHandler::UpdateA11yState() {
- if (!features::IsAshInBrowserProcess()) {
- NOTIMPLEMENTED();
- return;
- }
- // TODO(dpolukhin): crbug.com/412891
- DCHECK(MagnificationManager::Get());
base::DictionaryValue a11y_info;
a11y_info.SetBoolean("highContrastEnabled",
AccessibilityManager::Get()->IsHighContrastEnabled());
@@ -482,8 +500,24 @@ void CoreOobeHandler::UpdateA11yState() {
AccessibilityManager::Get()->IsLargeCursorEnabled());
a11y_info.SetBoolean("spokenFeedbackEnabled",
AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
- a11y_info.SetBoolean("screenMagnifierEnabled",
- MagnificationManager::Get()->IsMagnifierEnabled());
+ a11y_info.SetBoolean("selectToSpeakEnabled",
+ AccessibilityManager::Get()->IsSelectToSpeakEnabled());
+ a11y_info.SetBoolean(
+ "enableExperimentalA11yFeatures",
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableExperimentalAccessibilityFeatures));
+ if (!features::IsMultiProcessMash()) {
+ DCHECK(MagnificationManager::Get());
+ a11y_info.SetBoolean("screenMagnifierEnabled",
+ MagnificationManager::Get()->IsMagnifierEnabled());
+ a11y_info.SetBoolean(
+ "dockedMagnifierEnabled",
+ MagnificationManager::Get()->IsDockedMagnifierEnabled());
+ } else {
+ // TODO: get MagnificationManager working with mash.
+ // https://crbug.com/817157
+ NOTIMPLEMENTED_LOG_ONCE();
+ }
a11y_info.SetBoolean("virtualKeyboardEnabled",
AccessibilityManager::Get()->IsVirtualKeyboardEnabled());
CallJSOrDefer("refreshA11yInfo", a11y_info);
@@ -545,9 +579,9 @@ void CoreOobeHandler::UpdateDeviceRequisition() {
}
void CoreOobeHandler::UpdateKeyboardState() {
- // TODO(mash): Support virtual keyboard under MASH. There is no
+ // TODO(crbug.com/646565): Support virtual keyboard under MASH. There is no
// KeyboardController in the browser process under MASH.
- if (features::IsAshInBrowserProcess()) {
+ if (!features::IsUsingWindowService()) {
auto* keyboard_controller = keyboard::KeyboardController::Get();
if (keyboard_controller->enabled()) {
const bool is_keyboard_shown = keyboard_controller->IsKeyboardVisible();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
index 95ff28854a8..933dd72f91f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
@@ -130,6 +130,8 @@ class CoreOobeHandler : public BaseWebUIHandler,
void HandleEnableVirtualKeyboard(bool enabled);
void HandleEnableScreenMagnifier(bool enabled);
void HandleEnableSpokenFeedback(bool /* enabled */);
+ void HandleEnableSelectToSpeak(bool /* enabled */);
+ void HandleEnableDockedMagnifier(bool /* enabled */);
void HandleInitialized();
void HandleSkipUpdateEnrollAfterEula();
void HandleUpdateCurrentScreen(const std::string& screen);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc
index dfd1bba9c94..c5b5f83824d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc
@@ -4,13 +4,9 @@
#include "chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h"
-#include "base/command_line.h"
-#include "base/values.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/demo_setup_screen.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/chromeos_switches.h"
#include "components/login/localized_values_builder.h"
namespace {
@@ -61,12 +57,4 @@ void DemoSetupScreenHandler::DeclareLocalizedValues(
IDS_OOBE_DEMO_SETUP_ERROR_SCREEN_RETRY_BUTTON_LABEL);
}
-void DemoSetupScreenHandler::GetAdditionalParameters(
- base::DictionaryValue* dict) {
- const bool is_offline_demo_mode_enabled =
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableOfflineDemoMode);
- dict->SetBoolean("offlineDemoModeEnabled", is_offline_demo_mode_enabled);
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h
index 2acc8e02609..46c6c14e3f0 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h
@@ -30,7 +30,6 @@ class DemoSetupScreenHandler : public BaseScreenHandler,
void Initialize() override;
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
- void GetAdditionalParameters(base::DictionaryValue* dict) override;
private:
DemoSetupScreen* screen_ = nullptr;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc
index 966871e92e0..0a205aa2534 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc
@@ -8,6 +8,9 @@
#include "base/logging.h"
#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h"
+#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h"
+#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h"
#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.h"
namespace chromeos {
@@ -27,6 +30,12 @@ bool DiscoverManager::IsCompleted() const {
}
void DiscoverManager::CreateModules() {
+ modules_[DiscoverModuleLaunchHelpApp::kModuleName] =
+ std::make_unique<DiscoverModuleLaunchHelpApp>();
+ modules_[DiscoverModuleRedeemOffers::kModuleName] =
+ std::make_unique<DiscoverModuleRedeemOffers>();
+ modules_[DiscoverModuleSyncFiles::kModuleName] =
+ std::make_unique<DiscoverModuleSyncFiles>();
modules_[DiscoverModuleWelcome::kModuleName] =
std::make_unique<DiscoverModuleWelcome>();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.cc
new file mode 100644
index 00000000000..8f8fcbf6a6b
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.cc
@@ -0,0 +1,104 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_navigator.h"
+#include "chrome/browser/ui/browser_navigator_params.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager_observer.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/generated_resources.h"
+#include "content/public/browser/web_contents.h"
+#include "ui/gfx/geometry/rect.h"
+#include "url/gurl.h"
+
+namespace chromeos {
+
+// static
+DiscoverWindowManager* DiscoverWindowManager::GetInstance() {
+ static base::NoDestructor<DiscoverWindowManager> window_manager;
+ return window_manager.get();
+}
+
+void DiscoverWindowManager::AddObserver(
+ DiscoverWindowManagerObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void DiscoverWindowManager::RemoveObserver(
+ const DiscoverWindowManagerObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+void DiscoverWindowManager::ShowChromeDiscoverPageForProfile(Profile* profile) {
+ const GURL gurl(chrome::kChromeUIDiscoverURL);
+
+ // Use the original (non off-the-record) profile for discover unless
+ // this is a guest session.
+ if (!profile->IsGuestSession() && profile->IsOffTheRecord())
+ profile = profile->GetOriginalProfile();
+
+ // Look for an existing browser window.
+ Browser* browser = FindBrowserForProfile(profile);
+ if (browser) {
+ DCHECK(browser->profile() == profile);
+ const content::WebContents* web_contents =
+ browser->tab_strip_model()->GetWebContentsAt(0);
+ if (web_contents && web_contents->GetURL() == gurl) {
+ browser->window()->Show();
+ return;
+ }
+ NavigateParams params(browser, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK);
+ params.window_action = NavigateParams::SHOW_WINDOW;
+ params.user_gesture = true;
+ Navigate(&params);
+ return;
+ }
+
+ // No existing browser window, create one.
+ NavigateParams params(profile, gurl, ui::PAGE_TRANSITION_AUTO_BOOKMARK);
+ params.disposition = WindowOpenDisposition::NEW_POPUP;
+ params.trusted_source = true;
+ params.window_action = NavigateParams::SHOW_WINDOW;
+ params.user_gesture = true;
+ params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE;
+ // Adjust window size by the title bar size.
+ // TODO(https://crbug.com/864686): remove this.
+ params.window_bounds = gfx::Rect(768, 640 + 32 /* FIXMEalemate) */);
+
+ Navigate(&params);
+
+ // operator[] not used because SessionID has no default constructor.
+ discover_session_map_.emplace(profile, SessionID::InvalidValue())
+ .first->second = params.browser->session_id();
+ DCHECK(params.browser->is_trusted_source());
+
+ for (DiscoverWindowManagerObserver& observer : observers_)
+ observer.OnNewDiscoverWindow(params.browser);
+}
+
+Browser* DiscoverWindowManager::FindBrowserForProfile(Profile* profile) {
+ ProfileSessionMap::iterator iter = discover_session_map_.find(profile);
+ if (iter != discover_session_map_.end())
+ return chrome::FindBrowserWithID(iter->second);
+ return nullptr;
+}
+
+bool DiscoverWindowManager::IsDiscoverBrowser(Browser* browser) const {
+ ProfileSessionMap::const_iterator iter =
+ discover_session_map_.find(browser->profile());
+ return (iter != discover_session_map_.end() &&
+ iter->second == browser->session_id());
+}
+
+DiscoverWindowManager::DiscoverWindowManager() = default;
+
+DiscoverWindowManager::~DiscoverWindowManager() = default;
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h
new file mode 100644
index 00000000000..2d8958ffaa2
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h
@@ -0,0 +1,58 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_H_
+
+#include <map>
+
+#include "base/macros.h"
+#include "base/no_destructor.h"
+#include "base/observer_list.h"
+#include "components/sessions/core/session_id.h"
+
+class Browser;
+class Profile;
+
+namespace chromeos {
+
+class DiscoverWindowManagerObserver;
+
+// Manages Discover windows for CrOS. Each Profile is associated with a single
+// Browser window for Discover UI that will be created when the separate
+// Discover App is first opened.
+class DiscoverWindowManager {
+ public:
+ static DiscoverWindowManager* GetInstance();
+
+ void AddObserver(DiscoverWindowManagerObserver* observer);
+ void RemoveObserver(const DiscoverWindowManagerObserver* observer);
+
+ // Shows a chrome://oobe/discover/ page in an an existing system
+ // Browser window for |profile| or creates a new one.
+ void ShowChromeDiscoverPageForProfile(Profile* profile);
+
+ // If a Browser Discover app window for |profile| has already been created,
+ // returns it, otherwise returns NULL.
+ Browser* FindBrowserForProfile(Profile* profile);
+
+ // Returns true if |browser| is a Discover app window.
+ bool IsDiscoverBrowser(Browser* browser) const;
+
+ private:
+ friend class base::NoDestructor<DiscoverWindowManager>;
+ using ProfileSessionMap = std::map<Profile*, SessionID>;
+
+ DiscoverWindowManager();
+ ~DiscoverWindowManager();
+
+ base::ObserverList<DiscoverWindowManagerObserver> observers_;
+ ProfileSessionMap discover_session_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(DiscoverWindowManager);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager_observer.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager_observer.h
new file mode 100644
index 00000000000..30a9c062214
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager_observer.h
@@ -0,0 +1,25 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_OBSERVER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_OBSERVER_H_
+
+#include "base/observer_list_types.h"
+
+class Browser;
+
+namespace chromeos {
+
+class DiscoverWindowManagerObserver : public base::CheckedObserver {
+ public:
+ // Called when a new Discover App browser window is created.
+ virtual void OnNewDiscoverWindow(Browser* discover_browser) = 0;
+
+ protected:
+ ~DiscoverWindowManagerObserver() override = default;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_DISCOVER_WINDOW_MANAGER_OBSERVER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.cc
new file mode 100644
index 00000000000..cd3e89c41f8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.cc
@@ -0,0 +1,77 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
+#include "content/public/browser/web_ui.h"
+#include "ui/chromeos/devicetype_utils.h"
+
+namespace chromeos {
+
+namespace {
+
+class DiscoverModuleLaunchHelpAppHandler : public DiscoverHandler {
+ public:
+ DiscoverModuleLaunchHelpAppHandler();
+ ~DiscoverModuleLaunchHelpAppHandler() override = default;
+
+ private:
+ // BaseWebUIHandler: implementation
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void Initialize() override;
+ void RegisterMessages() override;
+
+ // Message handlers.
+ void HandleLaunchHelpApp();
+
+ DISALLOW_COPY_AND_ASSIGN(DiscoverModuleLaunchHelpAppHandler);
+};
+
+DiscoverModuleLaunchHelpAppHandler::DiscoverModuleLaunchHelpAppHandler()
+ : DiscoverHandler(DiscoverModuleLaunchHelpApp::kModuleName) {}
+
+void DiscoverModuleLaunchHelpAppHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("discoverGetHelp", IDS_DISCOVER_GET_HELP);
+}
+
+void DiscoverModuleLaunchHelpAppHandler::Initialize() {}
+
+void DiscoverModuleLaunchHelpAppHandler::RegisterMessages() {
+ AddPrefixedCallback("handleLaunchHelpApp",
+ &DiscoverModuleLaunchHelpAppHandler::HandleLaunchHelpApp);
+}
+
+void DiscoverModuleLaunchHelpAppHandler::HandleLaunchHelpApp() {
+ chrome::ShowHelpForProfile(Profile::FromWebUI(web_ui()),
+ chrome::HelpSource::HELP_SOURCE_WEBUI);
+}
+
+} // anonymous namespace
+
+/* ***************************************************************** */
+/* Discover LaunchHelpApp module implementation below. */
+
+const char DiscoverModuleLaunchHelpApp::kModuleName[] = "launch-help-app";
+
+DiscoverModuleLaunchHelpApp::DiscoverModuleLaunchHelpApp() = default;
+
+DiscoverModuleLaunchHelpApp::~DiscoverModuleLaunchHelpApp() = default;
+
+bool DiscoverModuleLaunchHelpApp::IsCompleted() const {
+ return false;
+}
+
+std::unique_ptr<DiscoverHandler>
+DiscoverModuleLaunchHelpApp::CreateWebUIHandler() const {
+ return std::make_unique<DiscoverModuleLaunchHelpAppHandler>();
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h
new file mode 100644
index 00000000000..7a386aba397
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h
@@ -0,0 +1,32 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_LAUNCH_HELP_APP_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_LAUNCH_HELP_APP_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "chrome/browser/ui/webui/chromeos/login/discover/discover_module.h"
+
+namespace chromeos {
+
+class DiscoverModuleLaunchHelpApp : public DiscoverModule {
+ public:
+ DiscoverModuleLaunchHelpApp();
+ ~DiscoverModuleLaunchHelpApp() override;
+
+ // DiscoverModule:
+ bool IsCompleted() const override;
+ std::unique_ptr<DiscoverHandler> CreateWebUIHandler() const override;
+
+ // Module name.
+ static const char kModuleName[];
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DiscoverModuleLaunchHelpApp);
+};
+
+} // namespace chromeos
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_LAUNCH_HELP_APP_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.cc
new file mode 100644
index 00000000000..300586ee25d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.cc
@@ -0,0 +1,63 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h"
+
+#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
+#include "ui/chromeos/devicetype_utils.h"
+
+namespace chromeos {
+
+namespace {
+
+class DiscoverModuleRedeemOffersHandler : public DiscoverHandler {
+ public:
+ DiscoverModuleRedeemOffersHandler();
+ ~DiscoverModuleRedeemOffersHandler() override = default;
+
+ private:
+ // BaseWebUIHandler: implementation
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void Initialize() override;
+ void RegisterMessages() override;
+
+ DISALLOW_COPY_AND_ASSIGN(DiscoverModuleRedeemOffersHandler);
+};
+
+DiscoverModuleRedeemOffersHandler::DiscoverModuleRedeemOffersHandler()
+ : DiscoverHandler(DiscoverModuleRedeemOffers::kModuleName) {}
+
+void DiscoverModuleRedeemOffersHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("discoverRedeemYourOffers", IDS_DISCOVER_REDEEM_YOUR_OFFERS);
+}
+
+void DiscoverModuleRedeemOffersHandler::Initialize() {}
+
+void DiscoverModuleRedeemOffersHandler::RegisterMessages() {}
+
+} // anonymous namespace
+
+/* ***************************************************************** */
+/* Discover RedeemOffers module implementation below. */
+
+const char DiscoverModuleRedeemOffers::kModuleName[] = "redeem-offers";
+
+DiscoverModuleRedeemOffers::DiscoverModuleRedeemOffers() = default;
+
+DiscoverModuleRedeemOffers::~DiscoverModuleRedeemOffers() = default;
+
+bool DiscoverModuleRedeemOffers::IsCompleted() const {
+ return false;
+}
+
+std::unique_ptr<DiscoverHandler>
+DiscoverModuleRedeemOffers::CreateWebUIHandler() const {
+ return std::make_unique<DiscoverModuleRedeemOffersHandler>();
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h
new file mode 100644
index 00000000000..ac4d91b82fb
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h
@@ -0,0 +1,32 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_REDEEM_OFFERS_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_REDEEM_OFFERS_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "chrome/browser/ui/webui/chromeos/login/discover/discover_module.h"
+
+namespace chromeos {
+
+class DiscoverModuleRedeemOffers : public DiscoverModule {
+ public:
+ DiscoverModuleRedeemOffers();
+ ~DiscoverModuleRedeemOffers() override;
+
+ // DiscoverModule:
+ bool IsCompleted() const override;
+ std::unique_ptr<DiscoverHandler> CreateWebUIHandler() const override;
+
+ // Module name.
+ static const char kModuleName[];
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DiscoverModuleRedeemOffers);
+};
+
+} // namespace chromeos
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_REDEEM_OFFERS_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.cc
new file mode 100644
index 00000000000..cb910b79fc2
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.cc
@@ -0,0 +1,63 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h"
+
+#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
+#include "ui/chromeos/devicetype_utils.h"
+
+namespace chromeos {
+
+namespace {
+
+class DiscoverModuleSyncFilesHandler : public DiscoverHandler {
+ public:
+ DiscoverModuleSyncFilesHandler();
+ ~DiscoverModuleSyncFilesHandler() override = default;
+
+ private:
+ // BaseWebUIHandler: implementation
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void Initialize() override;
+ void RegisterMessages() override;
+
+ DISALLOW_COPY_AND_ASSIGN(DiscoverModuleSyncFilesHandler);
+};
+
+DiscoverModuleSyncFilesHandler::DiscoverModuleSyncFilesHandler()
+ : DiscoverHandler(DiscoverModuleSyncFiles::kModuleName) {}
+
+void DiscoverModuleSyncFilesHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("discoverSyncMyFiles", IDS_DISCOVER_SYNC_MY_FILES);
+}
+
+void DiscoverModuleSyncFilesHandler::Initialize() {}
+
+void DiscoverModuleSyncFilesHandler::RegisterMessages() {}
+
+} // anonymous namespace
+
+/* ***************************************************************** */
+/* Discover SyncFiles module implementation below. */
+
+const char DiscoverModuleSyncFiles::kModuleName[] = "sync-files";
+
+DiscoverModuleSyncFiles::DiscoverModuleSyncFiles() = default;
+
+DiscoverModuleSyncFiles::~DiscoverModuleSyncFiles() = default;
+
+bool DiscoverModuleSyncFiles::IsCompleted() const {
+ return false;
+}
+
+std::unique_ptr<DiscoverHandler> DiscoverModuleSyncFiles::CreateWebUIHandler()
+ const {
+ return std::make_unique<DiscoverModuleSyncFilesHandler>();
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h
new file mode 100644
index 00000000000..2eccb231799
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h
@@ -0,0 +1,32 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_SYNC_FILES_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_SYNC_FILES_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "chrome/browser/ui/webui/chromeos/login/discover/discover_module.h"
+
+namespace chromeos {
+
+class DiscoverModuleSyncFiles : public DiscoverModule {
+ public:
+ DiscoverModuleSyncFiles();
+ ~DiscoverModuleSyncFiles() override;
+
+ // DiscoverModule:
+ bool IsCompleted() const override;
+ std::unique_ptr<DiscoverHandler> CreateWebUIHandler() const override;
+
+ // Module name.
+ static const char kModuleName[];
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DiscoverModuleSyncFiles);
+};
+
+} // namespace chromeos
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_SYNC_FILES_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.cc
index ff9c37f20c6..c5c8cb6ec14 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.cc
@@ -33,8 +33,6 @@ DiscoverModuleWelcomeHandler::DiscoverModuleWelcomeHandler()
void DiscoverModuleWelcomeHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->Add("discoverWelcomeGetStarted", IDS_DISCOVER_WELCOME_GET_STARTED);
- builder->Add("discoverWelcomeLater", IDS_DISCOVER_WELCOME_LATER);
builder->AddF("discoverWelcomeTitle", IDS_DISCOVER_WELCOME_TITLE,
ui::GetChromeOSDeviceName());
builder->AddF("discoverWelcomeSubTitle", IDS_DISCOVER_WELCOME_SUBTITLE,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
index a03537115f1..f7de7178211 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
@@ -14,7 +14,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
@@ -574,8 +574,9 @@ void EncryptionMigrationScreenHandler::StartMigration() {
auth_request = CreateAuthorizationRequest();
}
DBusThreadManager::Get()->GetCryptohomeClient()->MountEx(
- cryptohome::Identification(user_context_.GetAccountId()), auth_request,
- mount,
+ cryptohome::CreateAccountIdentifierFromAccountId(
+ user_context_.GetAccountId()),
+ auth_request, mount,
base::BindOnce(&EncryptionMigrationScreenHandler::OnMountExistingVault,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -601,7 +602,9 @@ void EncryptionMigrationScreenHandler::OnMountExistingVault(
request.set_minimal_migration(IsMinimalMigration());
DBusThreadManager::Get()->GetCryptohomeClient()->AddObserver(this);
DBusThreadManager::Get()->GetCryptohomeClient()->MigrateToDircrypto(
- cryptohome::Identification(user_context_.GetAccountId()), request,
+ cryptohome::CreateAccountIdentifierFromAccountId(
+ user_context_.GetAccountId()),
+ request,
base::Bind(&EncryptionMigrationScreenHandler::OnMigrationRequested,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -639,23 +642,30 @@ void EncryptionMigrationScreenHandler::RemoveCryptohome() {
user_manager::UserManager::Get()->SaveUserOAuthStatus(
user_context_.GetAccountId(),
user_manager::User::OAUTH2_TOKEN_STATUS_INVALID);
- cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove(
- cryptohome::Identification(user_context_.GetAccountId()),
- base::Bind(&EncryptionMigrationScreenHandler::OnRemoveCryptohome,
- weak_ptr_factory_.GetWeakPtr()));
+
+ const cryptohome::Identification cryptohome_id(user_context_.GetAccountId());
+
+ cryptohome::AccountIdentifier account_id_proto;
+ account_id_proto.set_account_id(cryptohome_id.id());
+
+ DBusThreadManager::Get()->GetCryptohomeClient()->RemoveEx(
+ account_id_proto,
+ base::BindOnce(&EncryptionMigrationScreenHandler::OnRemoveCryptohome,
+ weak_ptr_factory_.GetWeakPtr()));
}
void EncryptionMigrationScreenHandler::OnRemoveCryptohome(
- bool success,
- cryptohome::MountError return_code) {
- LOG_IF(ERROR, !success) << "Removing cryptohome failed. return code: "
- << return_code;
- if (success)
+ base::Optional<cryptohome::BaseReply> reply) {
+ cryptohome::MountError error = BaseReplyToMountError(reply);
+ if (error == cryptohome::MOUNT_ERROR_NONE) {
RecordRemoveCryptohomeResultSuccess(IsResumingIncompleteMigration(),
IsArcKiosk());
- else
+ } else {
+ LOG(ERROR) << "Removing cryptohome failed. return code: "
+ << reply.value().error();
RecordRemoveCryptohomeResultFailure(IsResumingIncompleteMigration(),
IsArcKiosk());
+ }
UpdateUIState(UIState::MIGRATION_FAILED);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h
index f13f58d641d..74affe81713 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h
@@ -108,7 +108,7 @@ class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView,
void OnMountExistingVault(base::Optional<cryptohome::BaseReply> reply);
// Removes cryptohome and shows the error screen after the removal finishes.
void RemoveCryptohome();
- void OnRemoveCryptohome(bool success, cryptohome::MountError return_code);
+ void OnRemoveCryptohome(base::Optional<cryptohome::BaseReply> reply);
// Creates authorization request for MountEx method using |user_context_|.
cryptohome::AuthorizationRequest CreateAuthorizationRequest();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc
index 567d7be991b..537629dca63 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc
@@ -19,6 +19,7 @@
#include "chromeos/dbus/fake_cryptohome_client.h"
#include "chromeos/dbus/fake_power_manager_client.h"
#include "chromeos/dbus/power_policy_controller.h"
+#include "chromeos/dbus/util/account_identifier_operators.h"
#include "chromeos/login/auth/key.h"
#include "chromeos/login/auth/user_context.h"
#include "components/account_id/account_id.h"
@@ -230,7 +231,8 @@ TEST_F(EncryptionMigrationScreenHandlerTest, MinimalMigration) {
encryption_migration_screen_handler_->fake_wake_lock()->HasWakeLock());
EXPECT_TRUE(fake_cryptohome_client_->to_migrate_from_ecryptfs());
EXPECT_TRUE(fake_cryptohome_client_->minimal_migration());
- EXPECT_EQ(cryptohome::Identification(user_context_.GetAccountId()),
+ EXPECT_EQ(cryptohome::CreateAccountIdentifierFromAccountId(
+ user_context_.GetAccountId()),
fake_cryptohome_client_->get_id_for_disk_migrated_to_dircrypto());
EXPECT_EQ(
user_context_.GetKey()->GetSecret(),
@@ -254,7 +256,8 @@ TEST_F(EncryptionMigrationScreenHandlerTest, ResumeMinimalMigration) {
EXPECT_TRUE(continue_login_callback_called_);
EXPECT_TRUE(fake_cryptohome_client_->to_migrate_from_ecryptfs());
EXPECT_TRUE(fake_cryptohome_client_->minimal_migration());
- EXPECT_EQ(cryptohome::Identification(user_context_.GetAccountId()),
+ EXPECT_EQ(cryptohome::CreateAccountIdentifierFromAccountId(
+ user_context_.GetAccountId()),
fake_cryptohome_client_->get_id_for_disk_migrated_to_dircrypto());
EXPECT_EQ(
user_context_.GetKey()->GetSecret(),
@@ -280,7 +283,8 @@ TEST_F(EncryptionMigrationScreenHandlerTest, MinimalMigrationSlow) {
EXPECT_TRUE(restart_login_callback_called_);
EXPECT_TRUE(fake_cryptohome_client_->to_migrate_from_ecryptfs());
EXPECT_TRUE(fake_cryptohome_client_->minimal_migration());
- EXPECT_EQ(cryptohome::Identification(user_context_.GetAccountId()),
+ EXPECT_EQ(cryptohome::CreateAccountIdentifierFromAccountId(
+ user_context_.GetAccountId()),
fake_cryptohome_client_->get_id_for_disk_migrated_to_dircrypto());
EXPECT_EQ(
user_context_.GetKey()->GetSecret(),
@@ -295,10 +299,6 @@ TEST_F(EncryptionMigrationScreenHandlerTest, MinimalMigrationFails) {
scoped_task_environment_.RunUntilIdle();
- EXPECT_CALL(
- *mock_async_method_caller_,
- AsyncRemove(cryptohome::Identification(user_context_.GetAccountId()),
- _ /* callback */));
encryption_migration_screen_handler_->testing_tick_clock()->Advance(
base::TimeDelta::FromMinutes(1));
fake_cryptohome_client_->NotifyDircryptoMigrationProgress(
@@ -308,7 +308,8 @@ TEST_F(EncryptionMigrationScreenHandlerTest, MinimalMigrationFails) {
Mock::VerifyAndClearExpectations(mock_async_method_caller_);
EXPECT_TRUE(fake_cryptohome_client_->to_migrate_from_ecryptfs());
EXPECT_TRUE(fake_cryptohome_client_->minimal_migration());
- EXPECT_EQ(cryptohome::Identification(user_context_.GetAccountId()),
+ EXPECT_EQ(cryptohome::CreateAccountIdentifierFromAccountId(
+ user_context_.GetAccountId()),
fake_cryptohome_client_->get_id_for_disk_migrated_to_dircrypto());
EXPECT_EQ(
user_context_.GetKey()->GetSecret(),
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 2f4c2f8318c..50ea95bae58 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
@@ -419,6 +419,11 @@ void EnrollmentScreenHandler::ShowEnrollmentStatus(
case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH:
ShowError(IDS_ENTERPRISE_ENROLLMENT_DOMAIN_MISMATCH_ERROR, true);
break;
+ case policy::DM_STATUS_SERVICE_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE:
+ ShowError(
+ IDS_ENTERPRISE_ENROLLMENT_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE,
+ true);
+ break;
default:
ShowErrorMessage(
l10n_util::GetStringFUTF8(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
index 22f1eba88cd..bac09e27de8 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
@@ -103,10 +103,11 @@ void ErrorScreenHandler::DeclareLocalizedValues(
builder->Add("rebootButton", IDS_RELAUNCH_BUTTON);
builder->Add("diagnoseButton", IDS_DIAGNOSE_BUTTON);
builder->Add("configureCertsButton", IDS_MANAGE_CERTIFICATES);
- builder->Add("continueButton", IDS_NETWORK_SELECTION_CONTINUE_BUTTON);
+ builder->Add("continueButton", IDS_WELCOME_SELECTION_CONTINUE_BUTTON);
builder->Add("okButton", IDS_APP_OK);
- builder->Add("proxySettingsMenuName", IDS_PROXY_SETTINGS_MENU_NAME);
- builder->Add("addWiFiNetworkMenuName", IDS_ADD_WI_FI_NETWORK_MENU_NAME);
+ builder->Add("proxySettingsMenuName",
+ IDS_NETWORK_PROXY_SETTINGS_LIST_ITEM_NAME);
+ builder->Add("addWiFiNetworkMenuName", IDS_NETWORK_ADD_WI_FI_LIST_ITEM_NAME);
network_element::AddLocalizedValuesToBuilder(builder);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc
new file mode 100644
index 00000000000..6b1a1887c5e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc
@@ -0,0 +1,179 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h"
+
+#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/chromeos/login/screens/fingerprint_setup_screen.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/common/service_manager_connection.h"
+#include "services/device/public/mojom/constants.mojom.h"
+#include "services/service_manager/public/cpp/connector.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+const char kJsScreenPath[] = "login.FingerprintSetupScreen";
+
+// The max number of fingerprints that can be stored.
+constexpr int kMaxAllowedFingerprints = 3;
+
+// Determines what the newly added fingerprint's name should be.
+std::string GetDefaultFingerprintName(int enrolled_finger_count) {
+ DCHECK(enrolled_finger_count < kMaxAllowedFingerprints);
+ switch (enrolled_finger_count) {
+ case 0:
+ return l10n_util::GetStringUTF8(
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME_1);
+ case 1:
+ return l10n_util::GetStringUTF8(
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME_2);
+ case 2:
+ return l10n_util::GetStringUTF8(
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME_3);
+ default:
+ NOTREACHED();
+ }
+ return std::string();
+}
+
+} // namespace
+
+namespace chromeos {
+
+FingerprintSetupScreenHandler::FingerprintSetupScreenHandler()
+ : BaseScreenHandler(kScreenId) {
+ set_call_js_prefix(kJsScreenPath);
+
+ service_manager::Connector* connector =
+ content::ServiceManagerConnection::GetForProcess()->GetConnector();
+ connector->BindInterface(device::mojom::kServiceName, &fp_service_);
+ device::mojom::FingerprintObserverPtr observer;
+ binding_.Bind(mojo::MakeRequest(&observer));
+ fp_service_->AddFingerprintObserver(std::move(observer));
+}
+
+FingerprintSetupScreenHandler::~FingerprintSetupScreenHandler() = default;
+
+void FingerprintSetupScreenHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("setupFingerprintScreenTitle",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_TITLE);
+ builder->Add("setupFingerprintScreenDescription",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_SENSOR_DESCRIPTION);
+ builder->Add("skipFingerprintSetup",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_BUTTON_SKIP);
+ builder->Add("fingerprintSetupLater",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_BUTTON_LATER);
+ builder->Add("fingerprintSetupNext",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_BUTTON_NEXT);
+ builder->Add("fingerprintSetupDone",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_BUTTON_DONE);
+ builder->Add("fingerprintSetupAddAnother",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_BUTTON_ADD_ANOTHER);
+ builder->Add("placeFingerScreenTitle",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_SENSOR_LOCATION_TITLE);
+ builder->Add("enrollmentProgressScreenTitle",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_ENROLLMENT_PROGRESS_TITLE);
+ builder->Add("fingerprintSetupAddFingerprint",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_BUTTON_ADD_FINGERPRINT);
+ builder->Add("setupFingerprintEnrollmentSuccessTitle",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_ENROLLMENT_SUCCESS_TITLE);
+ builder->Add("setupFingerprintEnrollmentSuccessDescription",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_ENROLLMENT_SUCCESS_DESCRIPTION);
+ builder->Add("setupFingerprintScanMoveFinger",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_INSTRUCTION_MOVE_FINGER);
+ builder->Add("setupFingerprintScanTryAgain",
+ IDS_OOBE_FINGERPINT_SETUP_SCREEN_INSTRUCTION_TRY_AGAIN);
+}
+
+void FingerprintSetupScreenHandler::RegisterMessages() {
+ BaseScreenHandler::RegisterMessages();
+ web_ui()->RegisterMessageCallback(
+ "startEnroll",
+ base::BindRepeating(&FingerprintSetupScreenHandler::HandleStartEnroll,
+ base::Unretained(this)));
+}
+
+void FingerprintSetupScreenHandler::Bind(FingerprintSetupScreen* screen) {
+ screen_ = screen;
+ BaseScreenHandler::SetBaseScreen(screen);
+}
+
+void FingerprintSetupScreenHandler::Show() {
+ ShowScreen(kScreenId);
+}
+
+void FingerprintSetupScreenHandler::Hide() {
+ // Clean up existing fingerprint enroll session.
+ if (enroll_session_started_) {
+ fp_service_->CancelCurrentEnrollSession(base::BindOnce(
+ &FingerprintSetupScreenHandler::OnCancelCurrentEnrollSession,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
+}
+
+void FingerprintSetupScreenHandler::Initialize() {}
+
+void FingerprintSetupScreenHandler::OnRestarted() {
+ VLOG(1) << "Fingerprint session restarted.";
+}
+
+void FingerprintSetupScreenHandler::OnEnrollScanDone(
+ uint32_t scan_result,
+ bool enroll_session_complete,
+ int percent_complete) {
+ VLOG(1) << "Receive fingerprint enroll scan result. scan_result="
+ << scan_result
+ << ", enroll_session_complete=" << enroll_session_complete
+ << ", percent_complete=" << percent_complete;
+ CallJS("onEnrollScanDone", static_cast<int>(scan_result),
+ enroll_session_complete, percent_complete);
+
+ if (enroll_session_complete) {
+ enroll_session_started_ = false;
+
+ ++enrolled_finger_count_;
+ CallJS("enableAddAnotherFinger",
+ enrolled_finger_count_ < kMaxAllowedFingerprints);
+
+ // Update the number of registered fingers, it's fine to override because
+ // this is the first time user log in and have no finger registered.
+ ProfileManager::GetActiveUserProfile()->GetPrefs()->SetInteger(
+ prefs::kQuickUnlockFingerprintRecord, enrolled_finger_count_);
+ }
+}
+
+void FingerprintSetupScreenHandler::OnAuthScanDone(
+ uint32_t scan_result,
+ const base::flat_map<std::string, std::vector<std::string>>& matches) {}
+
+void FingerprintSetupScreenHandler::OnSessionFailed() {
+ // TODO(xiaoyinh): Add more user visible information when available.
+ LOG(ERROR) << "Fingerprint session failed.";
+}
+
+void FingerprintSetupScreenHandler::HandleStartEnroll(
+ const base::ListValue* args) {
+ DCHECK(enrolled_finger_count_ < kMaxAllowedFingerprints);
+
+ enroll_session_started_ = true;
+ fp_service_->StartEnrollSession(
+ ProfileHelper::Get()->GetUserIdHashFromProfile(
+ ProfileManager::GetActiveUserProfile()),
+ GetDefaultFingerprintName(enrolled_finger_count_));
+}
+
+void FingerprintSetupScreenHandler::OnCancelCurrentEnrollSession(bool success) {
+ if (!success)
+ LOG(ERROR) << "Failed to cancel current fingerprint enroll session.";
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h
new file mode 100644
index 00000000000..40def90688f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h
@@ -0,0 +1,71 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_FINGERPRINT_SETUP_SCREEN_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_FINGERPRINT_SETUP_SCREEN_HANDLER_H_
+
+#include "base/macros.h"
+#include "chrome/browser/chromeos/login/screens/fingerprint_setup_screen_view.h"
+#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "services/device/public/mojom/fingerprint.mojom.h"
+
+namespace chromeos {
+
+class FingerprintSetupScreen;
+
+// The sole implementation of the FingerprintSetupScreenView, using WebUI.
+class FingerprintSetupScreenHandler
+ : public BaseScreenHandler,
+ public FingerprintSetupScreenView,
+ public device::mojom::FingerprintObserver {
+ public:
+ FingerprintSetupScreenHandler();
+ ~FingerprintSetupScreenHandler() override;
+
+ // BaseScreenHandler:
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void RegisterMessages() override;
+
+ // FingerprintSetupScreenView:
+ void Bind(FingerprintSetupScreen* screen) override;
+ void Show() override;
+ void Hide() override;
+
+ // BaseScreenHandler:
+ void Initialize() override;
+
+ // device::mojom::FingerprintObserver:
+ void OnRestarted() override;
+ void OnEnrollScanDone(uint32_t scan_result,
+ bool enroll_session_complete,
+ int percent_complete) override;
+ void OnAuthScanDone(
+ uint32_t scan_result,
+ const base::flat_map<std::string, std::vector<std::string>>& matches)
+ override;
+ void OnSessionFailed() override;
+
+ private:
+ // JS callbacks.
+ void HandleStartEnroll(const base::ListValue* args);
+
+ void OnCancelCurrentEnrollSession(bool success);
+
+ FingerprintSetupScreen* screen_ = nullptr;
+
+ device::mojom::FingerprintPtr fp_service_;
+ mojo::Binding<device::mojom::FingerprintObserver> binding_{this};
+ int enrolled_finger_count_ = 0;
+ bool enroll_session_started_ = false;
+
+ base::WeakPtrFactory<FingerprintSetupScreenHandler> weak_ptr_factory_{this};
+
+ DISALLOW_COPY_AND_ASSIGN(FingerprintSetupScreenHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_FINGERPRINT_SETUP_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
index 0d06906c4be..e3c2649b0a2 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
@@ -19,7 +19,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/language_preferences.h"
@@ -34,12 +34,14 @@
#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/policy/temp_certs_cache_nss.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/ash/login_screen_client.h"
#include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
@@ -579,6 +581,10 @@ void GaiaScreenHandler::RegisterMessages() {
AddCallback("updateOobeDialogSize",
&GaiaScreenHandler::HandleUpdateOobeDialogSize);
AddCallback("hideOobeDialog", &GaiaScreenHandler::HandleHideOobeDialog);
+ AddCallback("updateSigninUIState",
+ &GaiaScreenHandler::HandleUpdateSigninUIState);
+ AddCallback("showGuestForGaia",
+ &GaiaScreenHandler::HandleShowGuestForGaiaScreen);
// Allow UMA metrics collection from JS.
web_ui()->AddMessageHandler(std::make_unique<MetricsHandler>());
@@ -852,6 +858,22 @@ void GaiaScreenHandler::HandleGetIsSamlUserPasswordless(
base::Value(false) /* isSamlUserPasswordless */);
}
+void GaiaScreenHandler::HandleUpdateSigninUIState(int state) {
+ if (LoginDisplayHost::default_host()) {
+ auto dialog_state = static_cast<ash::mojom::OobeDialogState>(state);
+ DCHECK(ash::mojom::IsKnownEnumValue(dialog_state));
+ LoginDisplayHost::default_host()->UpdateOobeDialogState(dialog_state);
+ }
+}
+
+void GaiaScreenHandler::HandleShowGuestForGaiaScreen(bool allow_guest_login,
+ bool can_show_for_gaia) {
+ LoginScreenClient::Get()->login_screen()->SetAllowLoginAsGuest(
+ allow_guest_login);
+ LoginScreenClient::Get()->login_screen()->SetShowGuestButtonForGaiaScreen(
+ can_show_for_gaia);
+}
+
void GaiaScreenHandler::OnShowAddUser() {
signin_screen_handler_->is_account_picker_showing_first_time_ = false;
lock_screen_utils::EnforcePolicyInputMethods(std::string());
@@ -1107,8 +1129,10 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
// out of scope and the certificates will not be held in memory anymore.
untrusted_authority_certs_cache_ =
std::make_unique<policy::TempCertsCacheNSS>(
- policy::TempCertsCacheNSS::
- GetUntrustedAuthoritiesFromDeviceOncPolicy());
+ g_browser_process->platform_part()
+ ->browser_policy_connector_chromeos()
+ ->GetDeviceNetworkConfigurationUpdater()
+ ->GetAllAuthorityCertificates());
}
LoadAuthExtension(!gaia_silent_load_ /* force */, false /* 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 84306fde47f..f2da30938a3 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
@@ -137,6 +137,10 @@ class GaiaScreenHandler : public BaseScreenHandler,
void HandleGetIsSamlUserPasswordless(const std::string& callback_id,
const std::string& typed_email,
const std::string& gaia_id);
+ void HandleUpdateSigninUIState(int state);
+ void HandleShowGuestForGaiaScreen(bool allow_guest_login,
+ bool can_show_for_gaia);
+
void OnShowAddUser();
// Really handles the complete login message.
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc
index 39ff5fe96d7..3d0d0be07c1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc
@@ -168,6 +168,9 @@ std::string HostPairingScreenHandler::GetErrorStringFromEnrollmentError(
case policy::DM_STATUS_SERVICE_DOMAIN_MISMATCH:
return l10n_util::GetStringUTF8(
IDS_ENTERPRISE_ENROLLMENT_DOMAIN_MISMATCH_ERROR);
+ case policy::DM_STATUS_SERVICE_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE:
+ return l10n_util::GetStringUTF8(
+ IDS_ENTERPRISE_ENROLLMENT_CONSUMER_ACCOUNT_WITH_PACKAGED_LICENSE);
default:
return l10n_util::GetStringFUTF8(
IDS_ENTERPRISE_ENROLLMENT_STATUS_REGISTRATION_FAILED,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
index 6859c60e1f1..9761fa5a543 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
@@ -22,8 +22,8 @@
#include "base/strings/string16.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/task/post_task.h"
#include "base/task_runner_util.h"
-#include "base/task_scheduler/post_task.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc
new file mode 100644
index 00000000000..4d1c61677e8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc
@@ -0,0 +1,63 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h"
+
+#include "chrome/browser/chromeos/login/screens/marketing_opt_in_screen.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
+
+namespace {
+
+const char kJsScreenPath[] = "login.MarketingOptInScreen";
+
+} // namespace
+
+namespace chromeos {
+
+MarketingOptInScreenHandler::MarketingOptInScreenHandler()
+ : BaseScreenHandler(kScreenId) {
+ set_call_js_prefix(kJsScreenPath);
+}
+
+MarketingOptInScreenHandler::~MarketingOptInScreenHandler() {}
+
+void MarketingOptInScreenHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("marketingOptInScreenTitle",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_TITLE);
+ builder->Add("marketingOptInScreenSubtitle",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_SUBTITLE);
+ builder->Add("marketingOptInGetPlayUpdates",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_GET_PLAY_UPDATES);
+ builder->Add("marketingOptInGetChromebookUpdates",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_GET_CHROMEBOOK_UPDATES);
+ builder->Add("marketingOptInScreenAllSet",
+ IDS_LOGIN_MARKETING_OPT_IN_SCREEN_ALL_SET);
+}
+
+void MarketingOptInScreenHandler::Bind(MarketingOptInScreen* screen) {
+ screen_ = screen;
+ BaseScreenHandler::SetBaseScreen(screen);
+}
+
+void MarketingOptInScreenHandler::Show() {
+ ShowScreen(kScreenId);
+}
+
+void MarketingOptInScreenHandler::Hide() {}
+
+void MarketingOptInScreenHandler::Initialize() {}
+
+void MarketingOptInScreenHandler::RegisterMessages() {
+ AddPrefixedCallback("allSet", &MarketingOptInScreenHandler::HandleAllSet);
+}
+
+void MarketingOptInScreenHandler::HandleAllSet(
+ bool play_communications_opt_in,
+ bool tips_communications_opt_in) {
+ screen_->OnAllSet(play_communications_opt_in, tips_communications_opt_in);
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h
new file mode 100644
index 00000000000..2225b7af041
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h
@@ -0,0 +1,48 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MARKETING_OPT_IN_SCREEN_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MARKETING_OPT_IN_SCREEN_HANDLER_H_
+
+#include "base/macros.h"
+#include "chrome/browser/chromeos/login/screens/marketing_opt_in_screen_view.h"
+#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
+
+namespace chromeos {
+
+class MarketingOptInScreen;
+
+// The sole implementation of the MarketingOptInScreenView, using WebUI.
+class MarketingOptInScreenHandler : public BaseScreenHandler,
+ public MarketingOptInScreenView {
+ public:
+ MarketingOptInScreenHandler();
+ ~MarketingOptInScreenHandler() override;
+
+ // BaseScreenHandler:
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+
+ // MarketingOptInScreenView:
+ void Bind(MarketingOptInScreen* screen) override;
+ void Show() override;
+ void Hide() override;
+
+ private:
+ // BaseScreenHandler:
+ void Initialize() override;
+ void RegisterMessages() override;
+
+ // WebUI event handler.
+ void HandleAllSet(bool play_communications_opt_in,
+ bool tips_communications_opt_in);
+
+ MarketingOptInScreen* screen_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(MarketingOptInScreenHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MARKETING_OPT_IN_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
new file mode 100644
index 00000000000..aadf70c5866
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
@@ -0,0 +1,114 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
+
+#include <stddef.h>
+
+#include "base/values.h"
+#include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h"
+#include "chrome/browser/chromeos/login/screens/core_oobe_view.h"
+#include "chrome/browser/chromeos/login/screens/network_screen.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
+#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
+#include "chrome/grit/generated_resources.h"
+#include "chromeos/network/network_handler.h"
+#include "chromeos/network/network_state_handler.h"
+#include "components/login/localized_values_builder.h"
+
+namespace {
+
+const char kJsScreenPath[] = "login.NetworkScreen";
+
+} // namespace
+
+namespace chromeos {
+
+NetworkScreenHandler::NetworkScreenHandler(CoreOobeView* core_oobe_view)
+ : BaseScreenHandler(kScreenId), core_oobe_view_(core_oobe_view) {
+ set_call_js_prefix(kJsScreenPath);
+ DCHECK(core_oobe_view_);
+}
+
+NetworkScreenHandler::~NetworkScreenHandler() {
+ if (screen_)
+ screen_->OnViewDestroyed(this);
+}
+
+void NetworkScreenHandler::Show() {
+ if (!page_is_ready()) {
+ show_on_init_ = true;
+ return;
+ }
+
+ // In OOBE all physical network technologies should be enabled, so the user is
+ // able to select any of the available networks on the device. Enabled
+ // technologies should not be changed if network screen is shown outside of
+ // OOBE.
+ // If OOBE is not completed, we assume that the only instance of this object
+ // could be OOBE itself.
+ if (!StartupUtils::IsOobeCompleted()) {
+ NetworkStateHandler* handler =
+ NetworkHandler::Get()->network_state_handler();
+ handler->SetTechnologyEnabled(NetworkTypePattern::Physical(), true,
+ chromeos::network_handler::ErrorCallback());
+ }
+
+ base::DictionaryValue data;
+ data.SetBoolean("isDemoModeSetup",
+ DemoSetupController::IsOobeDemoSetupFlowInProgress());
+ ShowScreenWithData(kScreenId, &data);
+}
+
+void NetworkScreenHandler::Hide() {}
+
+void NetworkScreenHandler::Bind(NetworkScreen* screen) {
+ screen_ = screen;
+ BaseScreenHandler::SetBaseScreen(screen_);
+}
+
+void NetworkScreenHandler::Unbind() {
+ screen_ = nullptr;
+ BaseScreenHandler::SetBaseScreen(nullptr);
+}
+
+void NetworkScreenHandler::ShowError(const base::string16& message) {
+ CallJS("showError", message);
+}
+
+void NetworkScreenHandler::ClearErrors() {
+ if (page_is_ready())
+ core_oobe_view_->ClearErrors();
+}
+
+void NetworkScreenHandler::ShowConnectingStatus(
+ bool connecting,
+ const base::string16& network_id) {}
+
+void NetworkScreenHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("networkSectionTitle", IDS_NETWORK_SELECTION_TITLE);
+ builder->Add("networkSectionHint", IDS_NETWORK_SELECTION_HINT);
+ builder->Add("proxySettingsListItemName",
+ IDS_NETWORK_PROXY_SETTINGS_LIST_ITEM_NAME);
+ builder->Add("addWiFiListItemName", IDS_NETWORK_ADD_WI_FI_LIST_ITEM_NAME);
+ builder->Add("offlineDemoSetupListItemName",
+ IDS_NETWORK_OFFLINE_DEMO_SETUP_LIST_ITEM_NAME);
+ network_element::AddLocalizedValuesToBuilder(builder);
+}
+
+void NetworkScreenHandler::GetAdditionalParameters(
+ base::DictionaryValue* dict) {
+ dict->SetBoolean("offlineDemoModeEnabled",
+ DemoSetupController::IsOfflineDemoModeAllowed());
+}
+
+void NetworkScreenHandler::Initialize() {
+ if (show_on_init_) {
+ show_on_init_ = false;
+ Show();
+ }
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.h
new file mode 100644
index 00000000000..1c88cdda1a2
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.h
@@ -0,0 +1,53 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_
+
+#include "base/macros.h"
+#include "base/strings/string16.h"
+#include "chrome/browser/chromeos/login/screens/network_screen_view.h"
+#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
+
+namespace chromeos {
+
+class CoreOobeView;
+
+// WebUI implementation of NetworkScreenView. It is used to interact with
+// the OOBE network selection screen.
+class NetworkScreenHandler : public NetworkScreenView,
+ public BaseScreenHandler {
+ public:
+ explicit NetworkScreenHandler(CoreOobeView* core_oobe_view);
+ ~NetworkScreenHandler() override;
+
+ private:
+ // NetworkScreenView:
+ void Show() override;
+ void Hide() override;
+ void Bind(NetworkScreen* screen) override;
+ void Unbind() override;
+ void ShowError(const base::string16& message) override;
+ void ClearErrors() override;
+ void ShowConnectingStatus(bool connecting,
+ const base::string16& network_id) override;
+
+ // BaseScreenHandler:
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void GetAdditionalParameters(base::DictionaryValue* dict) override;
+ void Initialize() override;
+
+ CoreOobeView* core_oobe_view_ = nullptr;
+ NetworkScreen* screen_ = nullptr;
+
+ // Keeps whether screen should be shown right after initialization.
+ bool show_on_init_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkScreenHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_NETWORK_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc b/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
index 476a23950bf..564cfbe0f74 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
@@ -193,13 +193,13 @@ bool NetworkStateInformer::UpdateState() {
bool NetworkStateInformer::UpdateProxyConfig() {
const NetworkState* default_network =
NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
- if (!default_network)
+ if (!default_network || !default_network->proxy_config())
return false;
- if (proxy_config_ && *proxy_config_ == default_network->proxy_config())
+ if (proxy_config_ && *proxy_config_ == *default_network->proxy_config())
return false;
proxy_config_ =
- std::make_unique<base::Value>(default_network->proxy_config().Clone());
+ std::make_unique<base::Value>(default_network->proxy_config()->Clone());
return true;
}
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 70816148b9a..df2306eb8ec 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
@@ -101,7 +101,7 @@ class NetworkStateInformer
std::string network_path_;
std::unique_ptr<base::Value> proxy_config_;
- base::ObserverList<NetworkStateInformerObserver> observers_;
+ base::ObserverList<NetworkStateInformerObserver>::Unchecked observers_;
content::NotificationRegistrar registrar_;
base::WeakPtrFactory<NetworkStateInformer> weak_ptr_factory_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
index 641f57d2c23..eb08cdc2e10 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
@@ -13,7 +13,7 @@
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "mojo/public/cpp/bindings/binding.h"
-#include "services/ui/public/cpp/input_devices/input_device_client_test_api.h"
+#include "services/ws/public/cpp/input_devices/input_device_client_test_api.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display.h"
#include "ui/display/display_observer.h"
@@ -90,7 +90,7 @@ class OobeDisplayChooserTest : public ash::AshTestBase {
display_chooser_->set_cros_display_config_ptr_for_test(
cros_display_config_->CreateInterfacePtrAndBind());
- ui::InputDeviceClientTestApi().OnDeviceListsComplete();
+ ws::InputDeviceClientTestApi().OnDeviceListsComplete();
}
OobeDisplayChooser* display_chooser() { return display_chooser_.get(); }
@@ -124,7 +124,7 @@ TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) {
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
"Touchscreen", gfx::Size(800, 600), 1);
touchscreen.vendor_id = kWhitelistedId;
- ui::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen});
+ ws::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen});
base::RunLoop().RunUntilIdle();
// Associate touchscreen device with display
@@ -137,10 +137,10 @@ TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) {
// For mus we have to explicitly tell the InputDeviceClient the
// TouchscreenDevices. Normally InputDeviceClient is told of the
// TouchscreenDevices by way of implementing
- // ui::mojom::InputDeviceObserverMojo. In unit tests InputDeviceClient is not
+ // ws::mojom::InputDeviceObserverMojo. In unit tests InputDeviceClient is not
// wired to the window server (the window server isn't running).
touchscreen.target_display_id = display_info[1].id();
- ui::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen}, true);
+ ws::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen}, true);
EXPECT_EQ(1, GetPrimaryDisplay());
display_chooser()->TryToPlaceUiOnTouchDisplay();
@@ -167,7 +167,7 @@ TEST_F(OobeDisplayChooserTest, DontSwitchFromTouch) {
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
"Touchscreen", gfx::Size(800, 600), 1);
touchscreen.vendor_id = kWhitelistedId;
- ui::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen});
+ ws::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen});
base::RunLoop().RunUntilIdle();
// Associate touchscreen device with display
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
index 4a80138f5a7..b3a45be6728 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
@@ -13,6 +13,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -22,6 +23,7 @@
#include "chrome/browser/chromeos/login/screens/demo_preferences_screen_view.h"
#include "chrome/browser/chromeos/login/screens/demo_setup_screen_view.h"
#include "chrome/browser/chromeos/login/screens/error_screen.h"
+#include "chrome/browser/chromeos/login/screens/fingerprint_setup_screen_view.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -36,6 +38,7 @@
#include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/controller_pairing_screen_handler.h"
@@ -48,13 +51,16 @@
#include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h"
#include "chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h"
@@ -99,89 +105,70 @@ namespace chromeos {
namespace {
-const char* kKnownDisplayTypes[] = {OobeUI::kOobeDisplay,
- OobeUI::kLoginDisplay,
- OobeUI::kLockDisplay,
- OobeUI::kUserAddingDisplay,
- OobeUI::kAppLaunchSplashDisplay,
+const char* kKnownDisplayTypes[] = {OobeUI::kAppLaunchSplashDisplay,
OobeUI::kArcKioskSplashDisplay,
- OobeUI::kGaiaSigninDisplay};
-
-const char kStringsJSPath[] = "strings.js";
-const char kLockJSPath[] = "lock.js";
-const char kLoginJSPath[] = "login.js";
-const char kOobeJSPath[] = "oobe.js";
-const char kKeyboardUtilsJSPath[] = "keyboard_utils.js";
-const char kCustomElementsHTMLPath[] = "custom_elements.html";
-const char kCustomElementsJSPath[] = "custom_elements.js";
-const char kCustomElementsUserPodHTMLPath[] = "custom_elements_user_pod.html";
-
-// Paths for deferred resource loading.
-const char kEnrollmentHTMLPath[] = "enrollment.html";
-const char kEnrollmentCSSPath[] = "enrollment.css";
-const char kEnrollmentJSPath[] = "enrollment.js";
-const char kArcAssistantLogoPath[] = "assistant_logo.png";
-const char kArcPlaystoreCSSPath[] = "playstore.css";
-const char kArcOverlayCSSPath[] = "overlay.css";
-const char kArcPlaystoreJSPath[] = "playstore.js";
-const char kArcPlaystoreLogoPath[] = "playstore.svg";
-const char kProductLogoPath[] = "product-logo.png";
-
-const char kRecommendAppListViewJSPath[] = "recommend_app_list_view.js";
-const char kRecommendAppListViewHTMLPath[] = "recommend_app_list_view.html";
+ OobeUI::kDiscoverDisplay,
+ OobeUI::kGaiaSigninDisplay,
+ OobeUI::kLockDisplay,
+ OobeUI::kLoginDisplay,
+ OobeUI::kOobeDisplay,
+ OobeUI::kUserAddingDisplay};
+
+// Sorted
+constexpr char kArcAssistantLogoPath[] = "assistant_logo.png";
+constexpr char kArcOverlayCSSPath[] = "overlay.css";
+constexpr char kArcPlaystoreCSSPath[] = "playstore.css";
+constexpr char kArcPlaystoreJSPath[] = "playstore.js";
+constexpr char kArcPlaystoreLogoPath[] = "playstore.svg";
+constexpr char kCustomElementsHTMLPath[] = "custom_elements.html";
+constexpr char kCustomElementsJSPath[] = "custom_elements.js";
+constexpr char kCustomElementsUserPodHTMLPath[] =
+ "custom_elements_user_pod.html";
+constexpr char kDiscoverJSPath[] = "discover_app.js";
+constexpr char kKeyboardUtilsJSPath[] = "keyboard_utils.js";
+constexpr char kLockJSPath[] = "lock.js";
+constexpr char kLoginJSPath[] = "login.js";
+constexpr char kOobeJSPath[] = "oobe.js";
+constexpr char kProductLogoPath[] = "product-logo.png";
+constexpr char kRecommendAppListViewHTMLPath[] = "recommend_app_list_view.html";
+constexpr char kRecommendAppListViewJSPath[] = "recommend_app_list_view.js";
+constexpr char kStringsJSPath[] = "strings.js";
#if defined(GOOGLE_CHROME_BUILD)
-const char kLogo24PX1XSvgPath[] = "logo_24px-1x.svg";
-const char kLogo24PX2XSvgPath[] = "logo_24px-2x.svg";
-const char kSyncConsentIcons[] = "sync-consent-icons.html";
+constexpr char kLogo24PX1XSvgPath[] = "logo_24px-1x.svg";
+constexpr char kLogo24PX2XSvgPath[] = "logo_24px-2x.svg";
+constexpr char kSyncConsentIcons[] = "sync-consent-icons.html";
#endif
-// Creates a WebUIDataSource for chrome://oobe
-content::WebUIDataSource* CreateOobeUIDataSource(
- const base::DictionaryValue& localized_strings,
- const std::string& display_type) {
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+// Paths for deferred resource loading.
+constexpr char kEnrollmentCSSPath[] = "enrollment.css";
+constexpr char kEnrollmentHTMLPath[] = "enrollment.html";
+constexpr char kEnrollmentJSPath[] = "enrollment.js";
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIOobeHost);
- source->AddLocalizedStrings(localized_strings);
- source->SetJsonPath(kStringsJSPath);
+// Adds various product logo resources.
+void AddProductLogoResources(content::WebUIDataSource* source) {
+ // Required for Assistant OOBE.
+ source->AddResourcePath(kArcAssistantLogoPath, IDR_ASSISTANT_LOGO_PNG);
- if (display_type == OobeUI::kOobeDisplay) {
- source->SetDefaultResource(IDR_OOBE_HTML);
- source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS);
- source->AddResourcePath(kCustomElementsHTMLPath,
- IDR_CUSTOM_ELEMENTS_OOBE_HTML);
- source->AddResourcePath(kCustomElementsJSPath, IDR_CUSTOM_ELEMENTS_OOBE_JS);
- } else if (display_type == OobeUI::kLockDisplay) {
- // TODO(crbug.com/810170): Remove the resource files associated with
- // kShowNonMdLogin switch (IDR_LOCK_HTML/JS and IDR_LOGIN_HTML/JS and the
- // files those use).
- source->SetDefaultResource(IDR_MD_LOCK_HTML);
- source->AddResourcePath(kLockJSPath, IDR_MD_LOCK_JS);
- source->AddResourcePath(kCustomElementsHTMLPath,
- IDR_CUSTOM_ELEMENTS_LOCK_HTML);
- source->AddResourcePath(kCustomElementsJSPath, IDR_CUSTOM_ELEMENTS_LOCK_JS);
- source->AddResourcePath(kCustomElementsUserPodHTMLPath,
- IDR_CUSTOM_ELEMENTS_USER_POD_HTML);
- } else {
- source->SetDefaultResource(IDR_MD_LOGIN_HTML);
- source->AddResourcePath(kLoginJSPath, IDR_MD_LOGIN_JS);
- source->AddResourcePath(kCustomElementsHTMLPath,
- IDR_CUSTOM_ELEMENTS_LOGIN_HTML);
- source->AddResourcePath(kCustomElementsJSPath,
- IDR_CUSTOM_ELEMENTS_LOGIN_JS);
- source->AddResourcePath(kCustomElementsUserPodHTMLPath,
- IDR_CUSTOM_ELEMENTS_USER_POD_HTML);
- }
#if defined(GOOGLE_CHROME_BUILD)
source->AddResourcePath(kLogo24PX1XSvgPath, IDR_PRODUCT_LOGO_24PX_1X);
source->AddResourcePath(kLogo24PX2XSvgPath, IDR_PRODUCT_LOGO_24PX_2X);
+#endif
+
+ // Required in encryption migration screen.
+ source->AddResourcePath(kProductLogoPath, IDR_PRODUCT_LOGO_64);
+}
+
+void AddSyncConsentResources(content::WebUIDataSource* source) {
+#if defined(GOOGLE_CHROME_BUILD)
source->AddResourcePath(kSyncConsentIcons,
IDR_PRODUCT_CHROMEOS_SYNC_CONSENT_SCREEN_ICONS);
// No #else section here as Sync Settings screen is Chrome-specific.
#endif
+}
+// Adds resources for ARC-dependent screens (PlayStore ToS, Assistant, etc...)
+void AddArcScreensResources(content::WebUIDataSource* source) {
// Required for postprocessing of Goolge PlayStore Terms and Overlay help.
source->AddResourcePath(kArcOverlayCSSPath, IDR_ARC_SUPPORT_OVERLAY_CSS);
source->AddResourcePath(kArcPlaystoreCSSPath, IDR_ARC_SUPPORT_PLAYSTORE_CSS);
@@ -193,12 +180,92 @@ content::WebUIDataSource* CreateOobeUIDataSource(
IDR_ARC_SUPPORT_RECOMMEND_APP_LIST_VIEW_JS);
source->AddResourcePath(kRecommendAppListViewHTMLPath,
IDR_ARC_SUPPORT_RECOMMEND_APP_LIST_VIEW_HTML);
+}
- // Required for Assistant OOBE.
- source->AddResourcePath(kArcAssistantLogoPath, IDR_ASSISTANT_LOGO_PNG);
+// Adds Enterprise Enrollment resources.
+void AddEnterpriseEnrollmentResources(content::WebUIDataSource* source) {
+ // Deferred resources.
+ source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML);
+ source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS);
+ source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS);
+}
- // Required in encryption migration screen.
- source->AddResourcePath(kProductLogoPath, IDR_PRODUCT_LOGO_64);
+// Default and non-shared resource definition for kOobeDisplay display type.
+// chrome://oobe/oobe
+void AddOobeDisplayTypeDefaultResources(content::WebUIDataSource* source) {
+ source->SetDefaultResource(IDR_OOBE_HTML);
+ source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS);
+ source->AddResourcePath(kCustomElementsHTMLPath,
+ IDR_CUSTOM_ELEMENTS_OOBE_HTML);
+ source->AddResourcePath(kCustomElementsJSPath, IDR_CUSTOM_ELEMENTS_OOBE_JS);
+}
+
+// Default and non-shared resource definition for kLockDisplay display type.
+// chrome://oobe/lock
+void AddLockDisplayTypeDefaultResources(content::WebUIDataSource* source) {
+ // TODO(crbug.com/810170): Remove the resource files associated with
+ // kShowNonMdLogin switch (IDR_LOCK_HTML/JS and IDR_LOGIN_HTML/JS and the
+ // files those use).
+ source->SetDefaultResource(IDR_MD_LOCK_HTML);
+ source->AddResourcePath(kLockJSPath, IDR_MD_LOCK_JS);
+ source->AddResourcePath(kCustomElementsHTMLPath,
+ IDR_CUSTOM_ELEMENTS_LOCK_HTML);
+ source->AddResourcePath(kCustomElementsJSPath, IDR_CUSTOM_ELEMENTS_LOCK_JS);
+}
+
+// Default and non-shared resource definition for kDiscoverDisplay display type.
+// chrome://oobe/discover
+void AddDiscoverDisplayTypeDefaultResources(content::WebUIDataSource* source) {
+ source->SetDefaultResource(IDR_CHROMEOS_DISCOVER_APP_HTML);
+ source->AddResourcePath(kDiscoverJSPath, IDR_CHROMEOS_DISCOVER_APP_JS);
+}
+
+// Default and non-shared resource definition for kLoginDisplay display type.
+// chrome://oobe/login
+void AddLoginDisplayTypeDefaultResources(content::WebUIDataSource* source) {
+ source->SetDefaultResource(IDR_MD_LOGIN_HTML);
+ source->AddResourcePath(kLoginJSPath, IDR_MD_LOGIN_JS);
+ source->AddResourcePath(kCustomElementsHTMLPath,
+ IDR_CUSTOM_ELEMENTS_LOGIN_HTML);
+ source->AddResourcePath(kCustomElementsJSPath, IDR_CUSTOM_ELEMENTS_LOGIN_JS);
+}
+
+// Creates a WebUIDataSource for chrome://oobe
+content::WebUIDataSource* CreateOobeUIDataSource(
+ const base::DictionaryValue& localized_strings,
+ const std::string& display_type) {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIOobeHost);
+ source->AddLocalizedStrings(localized_strings);
+ source->SetJsonPath(kStringsJSPath);
+
+ // First, configure default and non-shared resources for the current display
+ // type.
+ if (display_type == OobeUI::kOobeDisplay) {
+ AddOobeDisplayTypeDefaultResources(source);
+ } else if (display_type == OobeUI::kLockDisplay) {
+ AddLockDisplayTypeDefaultResources(source);
+ } else if (display_type == OobeUI::kDiscoverDisplay) {
+ AddDiscoverDisplayTypeDefaultResources(source);
+ } else {
+ AddLoginDisplayTypeDefaultResources(source);
+ }
+
+ // Configure shared resources
+ AddProductLogoResources(source);
+
+ if (display_type != OobeUI::kLockDisplay) {
+ AddSyncConsentResources(source);
+ AddArcScreensResources(source);
+ AddEnterpriseEnrollmentResources(source);
+ }
+ if (display_type == OobeUI::kLockDisplay ||
+ display_type == OobeUI::kLoginDisplay) {
+ source->AddResourcePath(kCustomElementsUserPodHTMLPath,
+ IDR_CUSTOM_ELEMENTS_USER_POD_HTML);
+ }
source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS);
source->OverrideContentSecurityPolicyChildSrc(base::StringPrintf(
@@ -206,11 +273,6 @@ content::WebUIDataSource* CreateOobeUIDataSource(
source->OverrideContentSecurityPolicyObjectSrc(
"object-src chrome:;");
- // Serve deferred resources.
- source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML);
- source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS);
- source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS);
-
// Only add a filter when runing as test.
const bool is_running_test = command_line->HasSwitch(::switches::kTestName) ||
command_line->HasSwitch(::switches::kTestType);
@@ -222,9 +284,8 @@ content::WebUIDataSource* CreateOobeUIDataSource(
std::string GetDisplayType(const GURL& url) {
std::string path = url.path().size() ? url.path().substr(1) : "";
- if (std::find(kKnownDisplayTypes,
- kKnownDisplayTypes + arraysize(kKnownDisplayTypes),
- path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) {
+
+ if (!base::ContainsValue(kKnownDisplayTypes, path)) {
LOG(ERROR) << "Unknown display type '" << path << "'. Setting default.";
return OobeUI::kLoginDisplay;
}
@@ -242,28 +303,19 @@ bool IsRemoraRequisitioned() {
} // namespace
// static
-const char OobeUI::kOobeDisplay[] = "oobe";
-const char OobeUI::kLoginDisplay[] = "login";
-const char OobeUI::kLockDisplay[] = "lock";
-const char OobeUI::kUserAddingDisplay[] = "user-adding";
const char OobeUI::kAppLaunchSplashDisplay[] = "app-launch-splash";
const char OobeUI::kArcKioskSplashDisplay[] = "arc-kiosk-splash";
+const char OobeUI::kDiscoverDisplay[] = "discover";
const char OobeUI::kGaiaSigninDisplay[] = "gaia-signin";
+const char OobeUI::kLockDisplay[] = "lock";
+const char OobeUI::kLoginDisplay[] = "login";
+const char OobeUI::kOobeDisplay[] = "oobe";
+const char OobeUI::kUserAddingDisplay[] = "user-adding";
-OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
- : WebUIController(web_ui) {
- display_type_ = GetDisplayType(url);
-
+void OobeUI::ConfigureOobeDisplay() {
network_state_informer_ = new NetworkStateInformer();
network_state_informer_->Init();
- js_calls_container = std::make_unique<JSCallsContainer>();
-
- auto core_handler =
- std::make_unique<CoreOobeHandler>(this, js_calls_container.get());
- core_handler_ = core_handler.get();
- AddWebUIHandler(std::move(core_handler));
-
AddWebUIHandler(std::make_unique<NetworkDropdownHandler>());
AddScreenHandler(std::make_unique<UpdateScreenHandler>());
@@ -271,6 +323,8 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
if (display_type_ == kOobeDisplay)
AddScreenHandler(std::make_unique<WelcomeScreenHandler>(core_handler_));
+ AddScreenHandler(std::make_unique<NetworkScreenHandler>(core_handler_));
+
AddScreenHandler(std::make_unique<EnableDebuggingScreenHandler>());
AddScreenHandler(std::make_unique<EulaScreenHandler>(core_handler_));
@@ -320,7 +374,9 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
AddScreenHandler(std::make_unique<DemoPreferencesScreenHandler>());
- AddScreenHandler(std::make_unique<DiscoverScreenHandler>());
+ AddScreenHandler(std::make_unique<FingerprintSetupScreenHandler>());
+
+ AddScreenHandler(std::make_unique<MarketingOptInScreenHandler>());
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -368,16 +424,15 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
AddScreenHandler(std::make_unique<UpdateRequiredScreenHandler>());
+ AddScreenHandler(std::make_unique<AssistantOptInFlowScreenHandler>());
+
// Initialize KioskAppMenuHandler. Note that it is NOT a screen handler.
auto kiosk_app_menu_handler =
std::make_unique<KioskAppMenuHandler>(network_state_informer_);
kiosk_app_menu_handler_ = kiosk_app_menu_handler.get();
- web_ui->AddMessageHandler(std::move(kiosk_app_menu_handler));
+ web_ui()->AddMessageHandler(std::move(kiosk_app_menu_handler));
- base::DictionaryValue localized_strings;
- GetLocalizedStrings(&localized_strings);
-
- Profile* profile = Profile::FromWebUI(web_ui);
+ Profile* profile = Profile::FromWebUI(web_ui());
// Set up the chrome://theme/ source, for Chrome logo.
ThemeSource* theme = new ThemeSource(profile);
content::URLDataSource::Add(profile, theme);
@@ -387,23 +442,46 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
new AboutUIHTMLSource(chrome::kChromeUITermsHost, profile);
content::URLDataSource::Add(profile, about_source);
- // Set up the chrome://oobe/ source.
- content::WebUIDataSource* html_source =
- CreateOobeUIDataSource(localized_strings, display_type_);
- content::WebUIDataSource::Add(profile, html_source);
-
// Set up the chrome://userimage/ source.
UserImageSource* user_image_source = new UserImageSource();
content::URLDataSource::Add(profile, user_image_source);
// TabHelper is required for OOBE webui to make webview working on it.
- content::WebContents* contents = web_ui->GetWebContents();
+ content::WebContents* contents = web_ui()->GetWebContents();
extensions::TabHelper::CreateForWebContents(contents);
if (IsRemoraRequisitioned())
oobe_display_chooser_ = std::make_unique<OobeDisplayChooser>();
}
+OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
+ : WebUIController(web_ui) {
+ display_type_ = GetDisplayType(url);
+
+ js_calls_container = std::make_unique<JSCallsContainer>();
+
+ auto core_handler =
+ std::make_unique<CoreOobeHandler>(this, js_calls_container.get());
+ core_handler_ = core_handler.get();
+
+ AddWebUIHandler(std::move(core_handler));
+
+ if (display_type_ != OobeUI::kDiscoverDisplay)
+ ConfigureOobeDisplay();
+
+ if (display_type_ != OobeUI::kLockDisplay) {
+ AddScreenHandler(std::make_unique<DiscoverScreenHandler>());
+ }
+
+ base::DictionaryValue localized_strings;
+ GetLocalizedStrings(&localized_strings);
+
+ // Set up the chrome://oobe/ source.
+ content::WebUIDataSource* html_source =
+ CreateOobeUIDataSource(localized_strings, display_type_);
+ content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
+}
+
OobeUI::~OobeUI() {
}
@@ -443,6 +521,10 @@ DemoPreferencesScreenView* OobeUI::GetDemoPreferencesScreenView() {
return GetView<DemoPreferencesScreenHandler>();
}
+FingerprintSetupScreenView* OobeUI::GetFingerprintSetupScreenView() {
+ return GetView<FingerprintSetupScreenHandler>();
+}
+
KioskAutolaunchScreenView* OobeUI::GetKioskAutolaunchScreenView() {
return GetView<KioskAutolaunchScreenHandler>();
}
@@ -459,6 +541,10 @@ SyncConsentScreenView* OobeUI::GetSyncConsentScreenView() {
return GetView<SyncConsentScreenHandler>();
}
+MarketingOptInScreenView* OobeUI::GetMarketingOptInScreenView() {
+ return GetView<MarketingOptInScreenHandler>();
+}
+
ArcTermsOfServiceScreenView* OobeUI::GetArcTermsOfServiceScreenView() {
return GetView<ArcTermsOfServiceScreenHandler>();
}
@@ -512,6 +598,10 @@ UpdateRequiredView* OobeUI::GetUpdateRequiredScreenView() {
return GetView<UpdateRequiredScreenHandler>();
}
+AssistantOptInFlowScreenView* OobeUI::GetAssistantOptInFlowScreenView() {
+ return GetView<AssistantOptInFlowScreenHandler>();
+}
+
UserImageView* OobeUI::GetUserImageView() {
return GetView<UserImageScreenHandler>();
}
@@ -533,6 +623,10 @@ UserBoardView* OobeUI::GetUserBoardView() {
return GetView<UserBoardScreenHandler>();
}
+NetworkScreenView* OobeUI::GetNetworkScreenView() {
+ return GetView<NetworkScreenHandler>();
+}
+
void OobeUI::OnShutdownPolicyChanged(bool reboot_on_shutdown) {
core_handler_->UpdateShutdownAndRebootVisibility(reboot_on_shutdown);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
index 65a907ecbf2..d40fbf186a4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
@@ -29,10 +29,13 @@ class AppDownloadingScreenView;
class AppLaunchSplashScreenView;
class ArcKioskSplashScreenView;
class ArcTermsOfServiceScreenView;
+class AssistantOptInFlowScreenView;
class AutoEnrollmentCheckScreenView;
class BaseScreenHandler;
class ControllerPairingScreenView;
class CoreOobeView;
+class DemoPreferencesScreenView;
+class DemoSetupScreenView;
class DeviceDisabledScreenView;
class EnableDebuggingScreenView;
class EncryptionMigrationScreenView;
@@ -40,6 +43,7 @@ class EnrollmentScreenView;
class EulaView;
class ErrorScreen;
class DiscoverScreenView;
+class FingerprintSetupScreenView;
class GaiaView;
class HIDDetectionView;
class HostPairingScreenView;
@@ -47,17 +51,16 @@ class KioskAppMenuHandler;
class KioskAutolaunchScreenView;
class KioskEnableScreenView;
class LoginScreenContext;
+class MarketingOptInScreenView;
class NativeWindowDelegate;
+class NetworkScreenView;
class NetworkStateInformer;
-class WelcomeView;
class OobeDisplayChooser;
class RecommendAppsScreenView;
+class ResetView;
class SigninScreenHandler;
class SigninScreenHandlerDelegate;
class SupervisedUserCreationScreenHandler;
-class ResetView;
-class DemoSetupScreenView;
-class DemoPreferencesScreenView;
class SyncConsentScreenView;
class TermsOfServiceScreenView;
class UserBoardView;
@@ -66,6 +69,7 @@ class UpdateView;
class UpdateRequiredView;
class VoiceInteractionValuePropScreenView;
class WaitForContainerReadyScreenView;
+class WelcomeView;
class WrongHWIDScreenView;
// A custom WebUI that defines datasource for out-of-box-experience (OOBE) UI:
@@ -77,13 +81,14 @@ class OobeUI : public content::WebUIController,
public:
// List of known types of OobeUI. Type added as path in chrome://oobe url, for
// example chrome://oobe/user-adding.
- static const char kOobeDisplay[];
- static const char kLoginDisplay[];
- static const char kLockDisplay[];
- static const char kUserAddingDisplay[];
static const char kAppLaunchSplashDisplay[];
static const char kArcKioskSplashDisplay[];
+ static const char kDiscoverDisplay[];
static const char kGaiaSigninDisplay[];
+ static const char kLockDisplay[];
+ static const char kLoginDisplay[];
+ static const char kOobeDisplay[];
+ static const char kUserAddingDisplay[];
class Observer {
public:
@@ -110,6 +115,7 @@ class OobeUI : public content::WebUIController,
ResetView* GetResetView();
DemoSetupScreenView* GetDemoSetupScreenView();
DemoPreferencesScreenView* GetDemoPreferencesScreenView();
+ FingerprintSetupScreenView* GetFingerprintSetupScreenView();
KioskAutolaunchScreenView* GetKioskAutolaunchScreenView();
KioskEnableScreenView* GetKioskEnableScreenView();
TermsOfServiceScreenView* GetTermsOfServiceScreenView();
@@ -132,9 +138,12 @@ class OobeUI : public content::WebUIController,
VoiceInteractionValuePropScreenView* GetVoiceInteractionValuePropScreenView();
WaitForContainerReadyScreenView* GetWaitForContainerReadyScreenView();
UpdateRequiredView* GetUpdateRequiredScreenView();
+ AssistantOptInFlowScreenView* GetAssistantOptInFlowScreenView();
GaiaView* GetGaiaScreenView();
UserBoardView* GetUserBoardView();
DiscoverScreenView* GetDiscoverScreenView();
+ NetworkScreenView* GetNetworkScreenView();
+ MarketingOptInScreenView* GetMarketingOptInScreenView();
// ShutdownPolicyHandler::Delegate
void OnShutdownPolicyChanged(bool reboot_on_shutdown) override;
@@ -215,6 +224,10 @@ class OobeUI : public content::WebUIController,
void AddWebUIHandler(std::unique_ptr<BaseWebUIHandler> handler);
void AddScreenHandler(std::unique_ptr<BaseScreenHandler> handler);
+ // Configures all the relevant screen shandlers and resources for OOBE/Login
+ // display type.
+ void ConfigureOobeDisplay();
+
// Type of UI.
std::string display_type_;
@@ -254,7 +267,7 @@ class OobeUI : public content::WebUIController,
std::vector<base::Closure> ready_callbacks_;
// List of registered observers.
- base::ObserverList<Observer> observer_list_;
+ base::ObserverList<Observer>::Unchecked observer_list_;
// Observer of CrosSettings watching the kRebootOnShutdown policy.
std::unique_ptr<ShutdownPolicyHandler> shutdown_policy_handler_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc
index b55e82564a8..75924f17d03 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc
@@ -105,6 +105,10 @@ void RecommendAppsScreenHandler::OnLoadSuccess(const base::Value& app_list) {
LoadAppListInUI(app_list);
}
+void RecommendAppsScreenHandler::OnParseResponseError() {
+ HandleSkip();
+}
+
void RecommendAppsScreenHandler::HandleSkip() {
for (auto& observer : observer_list_)
observer.OnSkip();
@@ -116,6 +120,13 @@ void RecommendAppsScreenHandler::HandleRetry() {
}
void RecommendAppsScreenHandler::HandleInstall(const base::ListValue* args) {
+ // If the user does not select any apps, we should skip the app downloading
+ // screen.
+ if (args->GetList().empty()) {
+ HandleSkip();
+ return;
+ }
+
pref_service_->Set(arc::prefs::kArcFastAppReinstallPackages, *args);
arc::ArcFastAppReinstallStarter* fast_app_reinstall_starter =
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h
index c813764aeb6..723c44bfc42 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h
@@ -41,6 +41,7 @@ class RecommendAppsScreenHandler : public BaseScreenHandler,
// RecommendAppsScreenView:
void OnLoadError() override;
void OnLoadSuccess(const base::Value& app_list) override;
+ void OnParseResponseError() override;
// Call the JS function to load the list of apps in the WebView.
void LoadAppListInUI(const base::Value& app_list);
@@ -53,7 +54,8 @@ class RecommendAppsScreenHandler : public BaseScreenHandler,
PrefService* pref_service_;
- base::ObserverList<RecommendAppsScreenViewObserver, true> observer_list_;
+ base::ObserverList<RecommendAppsScreenViewObserver, true>::Unchecked
+ observer_list_;
DISALLOW_COPY_AND_ASSIGN(RecommendAppsScreenHandler);
};
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 fe182a0e43d..3ba24b7fc48 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
@@ -39,6 +39,7 @@
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/lock_screen_apps/state_controller.h"
+#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h"
#include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h"
@@ -315,7 +316,7 @@ SigninScreenHandler::SigninScreenHandler(
WallpaperControllerClient::Get()->AddObserver(std::move(ptr_info));
// TODO(tbarzic): This is needed for login UI - remove it when login switches
// to views implementation (or otherwise, make it work under mash).
- if (features::IsAshInBrowserProcess())
+ if (!features::IsMultiProcessMash())
detachable_base_observer_.Add(ash::Shell::Get()->detachable_base_handler());
}
@@ -543,6 +544,7 @@ void SigninScreenHandler::RegisterMessages() {
&SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts);
AddCallback("getTabletModeState",
&SigninScreenHandler::HandleGetTabletModeState);
+ AddCallback("getDemoModeState", &SigninScreenHandler::HandleGetDemoModeState);
AddCallback("logRemoveUserWarningShown",
&SigninScreenHandler::HandleLogRemoveUserWarningShown);
AddCallback("firstIncorrectPasswordAttempt",
@@ -839,7 +841,7 @@ void SigninScreenHandler::SetupAndShowOfflineMessage(
// error screen (offline, proxy).
if (IsGaiaVisible() ||
(error_screen_->GetErrorState() != NetworkError::ERROR_STATE_PORTAL)) {
- error_screen_->FixCaptivePortal();
+ LoginDisplayHost::default_host()->HandleDisplayCaptivePortal();
}
const std::string network_name = GetNetworkName(network_path);
error_screen_->SetErrorState(NetworkError::ERROR_STATE_PORTAL,
@@ -1602,6 +1604,11 @@ void SigninScreenHandler::HandleGetTabletModeState() {
TabletModeClient::Get()->tablet_mode_enabled());
}
+void SigninScreenHandler::HandleGetDemoModeState() {
+ CallJS("login.AccountPickerScreen.setDemoModeState",
+ DemoSession::IsDeviceInDemoMode());
+}
+
void SigninScreenHandler::HandleLogRemoveUserWarningShown() {
ProfileMetrics::LogProfileDeleteUser(
ProfileMetrics::DELETE_PROFILE_USER_MANAGER_SHOW_WARNING);
@@ -1765,7 +1772,7 @@ void SigninScreenHandler::OnDetachableBaseRequiresUpdateChanged(
bool requires_update) {}
void SigninScreenHandler::UpdateDetachableBaseChangedError() {
- if (!features::IsAshInBrowserProcess())
+ if (features::IsMultiProcessMash())
return;
auto pairing_status =
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
index 847fbad247d..9c3a788ca45 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
@@ -401,6 +401,7 @@ class SigninScreenHandler
void HandleGetPublicSessionKeyboardLayouts(const AccountId& account_id,
const std::string& locale);
void HandleGetTabletModeState();
+ void HandleGetDemoModeState();
void HandleLogRemoveUserWarningShown();
void HandleFirstIncorrectPasswordAttempt(const AccountId& account_id);
void HandleMaxIncorrectPasswordAttempts(const AccountId& account_id);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
index 230adcacf7c..825a45b5fc8 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
@@ -12,8 +12,7 @@
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller_delegate.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/chromeos/settings/device_settings_service.h"
+#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
@@ -64,9 +63,6 @@ class SigninPrepareUserListTest : public ash::AshTestBase,
fake_user_manager_->AddUser(AccountId::FromUserEmail(kUsers[i]));
fake_user_manager_->set_owner_id(AccountId::FromUserEmail(kOwner));
-
- chromeos::DeviceSettingsService::Initialize();
- chromeos::CrosSettings::Initialize();
}
void TearDown() override {
@@ -78,6 +74,7 @@ class SigninPrepareUserListTest : public ash::AshTestBase,
// MultiProfileUserControllerDelegate overrides:
void OnUserNotAllowed(const std::string& user_email) override {}
+ ScopedCrosSettingsTestHelper cros_settings_test_helper_;
FakeChromeUserManager* fake_user_manager_;
user_manager::ScopedUserManager user_manager_enabler_;
std::unique_ptr<TestingProfileManager> profile_manager_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc
index 1b3047e9864..b5b0c3fa9fd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc
@@ -11,38 +11,28 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
-#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
-#include "chrome/browser/chromeos/customization/customization_document.h"
-#include "chrome/browser/chromeos/idle_detector.h"
#include "chrome/browser/chromeos/login/screens/core_oobe_view.h"
#include "chrome/browser/chromeos/login/screens/welcome_screen.h"
#include "chrome/browser/chromeos/login/ui/input_events_blocker.h"
-#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
-#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/chromeos/system/timezone_util.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
-#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/chromeos_switches.h"
-#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state_handler.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
+#include "ui/base/ime/chromeos/component_extension_ime_manager.h"
#include "ui/base/ime/chromeos/extension_ime_util.h"
-#include "ui/gfx/geometry/rect.h"
-#include "ui/views/layout/fill_layout.h"
-#include "ui/views/widget/widget.h"
+#include "ui/base/ime/chromeos/input_method_manager.h"
namespace {
@@ -86,12 +76,6 @@ void WelcomeScreenHandler::Show() {
return;
}
- // Make sure all physical network technologies are enabled. On OOBE, the user
- // should be able to select any of the available networks on the device.
- NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
- handler->SetTechnologyEnabled(NetworkTypePattern::Physical(), true,
- chromeos::network_handler::ErrorCallback());
-
base::DictionaryValue welcome_screen_params;
welcome_screen_params.SetBoolean(
"isDeveloperMode", base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -112,23 +96,10 @@ void WelcomeScreenHandler::Unbind() {
BaseScreenHandler::SetBaseScreen(nullptr);
}
-void WelcomeScreenHandler::ShowError(const base::string16& message) {
- CallJS("showError", message);
-}
-
-void WelcomeScreenHandler::ClearErrors() {
- if (page_is_ready())
- core_oobe_view_->ClearErrors();
-}
-
void WelcomeScreenHandler::StopDemoModeDetection() {
core_oobe_view_->StopDemoModeDetection();
}
-void WelcomeScreenHandler::ShowConnectingStatus(
- bool connecting,
- const base::string16& network_id) {}
-
void WelcomeScreenHandler::ReloadLocalizedContent() {
base::DictionaryValue localized_strings;
GetOobeUI()->GetLocalizedStrings(&localized_strings);
@@ -140,15 +111,14 @@ void WelcomeScreenHandler::ReloadLocalizedContent() {
void WelcomeScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation())
- builder->Add("networkScreenGreeting", IDS_REMORA_CONFIRM_MESSAGE);
+ builder->Add("welcomeScreenGreeting", IDS_REMORA_CONFIRM_MESSAGE);
else
- builder->Add("networkScreenGreeting", IDS_WELCOME_SCREEN_GREETING);
+ builder->Add("welcomeScreenGreeting", IDS_WELCOME_SCREEN_GREETING);
- builder->Add("networkScreenTitle", IDS_WELCOME_SCREEN_TITLE);
- builder->Add("continueButton", IDS_NETWORK_SELECTION_CONTINUE_BUTTON);
+ builder->Add("welcomeScreenTitle", IDS_WELCOME_SCREEN_TITLE);
// MD-OOBE (oobe-welcome-md)
- builder->Add("debuggingFeaturesLink", IDS_NETWORK_ENABLE_DEV_FEATURES_LINK);
+ builder->Add("debuggingFeaturesLink", IDS_WELCOME_ENABLE_DEV_FEATURES_LINK);
builder->Add("timezoneDropdownLabel", IDS_TIMEZONE_DROPDOWN_LABEL);
builder->Add("oobeOKButtonText", IDS_OOBE_OK_BUTTON_TEXT);
builder->Add("welcomeNextButtonText", IDS_OOBE_WELCOME_NEXT_BUTTON_TEXT);
@@ -157,8 +127,6 @@ void WelcomeScreenHandler::DeclareLocalizedValues(
builder->Add("accessibilitySectionTitle", IDS_ACCESSIBILITY_SECTION_TITLE);
builder->Add("accessibilitySectionHint", IDS_ACCESSIBILITY_SECTION_HINT);
builder->Add("timezoneSectionTitle", IDS_TIMEZONE_SECTION_TITLE);
- builder->Add("networkSectionTitle", IDS_NETWORK_SECTION_TITLE);
- builder->Add("networkSectionHint", IDS_NETWORK_SECTION_HINT);
builder->Add("advancedOptionsSectionTitle",
IDS_OOBE_ADVANCED_OPTIONS_SCREEN_TITLE);
builder->Add("advancedOptionsEEBootstrappingTitle",
@@ -178,8 +146,6 @@ void WelcomeScreenHandler::DeclareLocalizedValues(
builder->Add("languageDropdownLabel", IDS_LANGUAGE_DROPDOWN_LABEL);
builder->Add("keyboardDropdownTitle", IDS_KEYBOARD_DROPDOWN_TITLE);
builder->Add("keyboardDropdownLabel", IDS_KEYBOARD_DROPDOWN_LABEL);
- builder->Add("proxySettingsMenuName", IDS_PROXY_SETTINGS_MENU_NAME);
- builder->Add("addWiFiNetworkMenuName", IDS_ADD_WI_FI_NETWORK_MENU_NAME);
builder->Add("highContrastOptionOff", IDS_HIGH_CONTRAST_OPTION_OFF);
builder->Add("highContrastOptionOn", IDS_HIGH_CONTRAST_OPTION_ON);
@@ -189,12 +155,13 @@ void WelcomeScreenHandler::DeclareLocalizedValues(
builder->Add("screenMagnifierOptionOn", IDS_SCREEN_MAGNIFIER_OPTION_ON);
builder->Add("spokenFeedbackOptionOff", IDS_SPOKEN_FEEDBACK_OPTION_OFF);
builder->Add("spokenFeedbackOptionOn", IDS_SPOKEN_FEEDBACK_OPTION_ON);
+ builder->Add("selectToSpeakOptionOff", IDS_SELECT_TO_SPEAK_OPTION_OFF);
+ builder->Add("selectToSpeakOptionOn", IDS_SELECT_TO_SPEAK_OPTION_ON);
builder->Add("virtualKeyboardOptionOff", IDS_VIRTUAL_KEYBOARD_OPTION_OFF);
builder->Add("virtualKeyboardOptionOn", IDS_VIRTUAL_KEYBOARD_OPTION_ON);
builder->Add("timezoneDropdownTitle", IDS_TIMEZONE_DROPDOWN_TITLE);
builder->Add("timezoneButtonText", IDS_TIMEZONE_BUTTON_TEXT);
- network_element::AddLocalizedValuesToBuilder(builder);
}
void WelcomeScreenHandler::GetAdditionalParameters(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h
index 73157f50225..61e87a538a4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h
@@ -6,16 +6,10 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_WELCOME_SCREEN_HANDLER_H_
#include <memory>
-#include <string>
-#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "chrome/browser/chromeos/base/locale_util.h"
#include "chrome/browser/chromeos/login/screens/welcome_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-#include "ui/base/ime/chromeos/component_extension_ime_manager.h"
-#include "ui/base/ime/chromeos/input_method_manager.h"
-#include "ui/gfx/geometry/point.h"
namespace base {
class ListValue;
@@ -38,11 +32,7 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler {
void Hide() override;
void Bind(WelcomeScreen* screen) override;
void Unbind() override;
- void ShowError(const base::string16& message) override;
- void ClearErrors() override;
void StopDemoModeDetection() override;
- void ShowConnectingStatus(bool connecting,
- const base::string16& network_id) override;
void ReloadLocalizedContent() override;
// BaseScreenHandler implementation:
@@ -60,9 +50,6 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler {
// Keeps whether screen should be shown right after initialization.
bool show_on_init_ = false;
- // Position of the network control.
- gfx::Point network_control_pos_;
-
DISALLOW_COPY_AND_ASSIGN(WelcomeScreenHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc
index b8ed44130df..76ff0738b50 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc
@@ -4,164 +4,94 @@
#include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
-#include "base/bind.h"
-#include "base/macros.h"
-#include "base/memory/singleton.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chromeos/login/ui/login_display_host.h"
-#include "chrome/browser/chromeos/login/ui/webui_login_view.h"
#include "chrome/browser/chromeos/mobile/mobile_activator.h"
#include "chrome/browser/lifetime/browser_shutdown.h"
-#include "chrome/browser/platform_util.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
-#include "content/public/browser/browser_thread.h"
+#include "components/device_event_log/device_event_log.h"
+#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/widget/widget.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
-using chromeos::MobileActivator;
-using content::BrowserThread;
-using content::WebContents;
-using content::WebUIMessageHandler;
-using ui::WebDialogDelegate;
-
-class MobileSetupDialogDelegate : public WebDialogDelegate {
- public:
- static MobileSetupDialogDelegate* GetInstance();
- void ShowDialog(const std::string& service_path);
-
- protected:
- friend struct base::DefaultSingletonTraits<MobileSetupDialogDelegate>;
-
- MobileSetupDialogDelegate();
- ~MobileSetupDialogDelegate() override;
-
- void OnCloseDialog();
-
- // WebDialogDelegate overrides.
- ui::ModalType GetDialogModalType() const override;
- base::string16 GetDialogTitle() const override;
- GURL GetDialogContentURL() const override;
- void GetWebUIMessageHandlers(
- std::vector<WebUIMessageHandler*>* handlers) const override;
- void GetDialogSize(gfx::Size* size) const override;
- std::string GetDialogArgs() const override;
- void OnDialogClosed(const std::string& json_retval) override;
- void OnCloseContents(WebContents* source, bool* out_close_dialog) override;
- bool ShouldShowDialogTitle() const override;
- bool HandleContextMenu(const content::ContextMenuParams& params) override;
-
- private:
- gfx::NativeWindow dialog_window_;
- // Cellular network service path.
- std::string service_path_;
- DISALLOW_COPY_AND_ASSIGN(MobileSetupDialogDelegate);
-};
+namespace chromeos {
+
+namespace {
+
+constexpr int kMobileSetupDialogWidth = 850;
+constexpr int kMobileSetupDialogHeight = 650;
+
+GURL GetURL(const NetworkState& network) {
+ std::string url(chrome::kChromeUIMobileSetupURL);
+ // TODO(stevenjb): Use GUID instead.
+ url.append(network.path());
+ return GURL(url);
+}
+
+MobileSetupDialog* dialog_instance = nullptr;
+
+} // namespace
// static
void MobileSetupDialog::ShowByNetworkId(const std::string& network_id) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ if (dialog_instance) {
+ NET_LOG(EVENT) << "Only one active MobileSetupDialog instance supported.";
+ dialog_instance->dialog_window()->Focus();
+ return;
+ }
const chromeos::NetworkState* network =
chromeos::NetworkHandler::Get()
->network_state_handler()
->GetNetworkStateFromGuid(network_id);
if (!network) {
- LOG(ERROR) << "MobileSetupDialog: Network ID not found: " << network_id;
+ NET_LOG(ERROR) << "MobileSetupDialog: Network ID not found: " << network_id;
return;
}
- MobileSetupDialogDelegate::GetInstance()->ShowDialog(network->path());
-}
-
-// static
-MobileSetupDialogDelegate* MobileSetupDialogDelegate::GetInstance() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return base::Singleton<MobileSetupDialogDelegate>::get();
-}
-
-MobileSetupDialogDelegate::MobileSetupDialogDelegate()
- : dialog_window_(nullptr) {}
-
-MobileSetupDialogDelegate::~MobileSetupDialogDelegate() {
-}
-
-void MobileSetupDialogDelegate::ShowDialog(const std::string& service_path) {
- service_path_ = service_path;
-
- gfx::NativeWindow parent = nullptr;
- // If we're on the login screen.
- if (chromeos::LoginDisplayHost::default_host()) {
- chromeos::WebUILoginView* login_view =
- chromeos::LoginDisplayHost::default_host()->GetWebUILoginView();
- if (login_view)
- parent = login_view->GetNativeWindow();
- }
- // Only the primary user can change this.
- dialog_window_ = chrome::ShowWebDialog(
- parent,
- ProfileManager::GetPrimaryUserProfile(),
- this);
-}
-
-ui::ModalType MobileSetupDialogDelegate::GetDialogModalType() const {
- return ui::MODAL_TYPE_SYSTEM;
-}
-
-base::string16 MobileSetupDialogDelegate::GetDialogTitle() const {
- return l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE);
+ NET_LOG(EVENT) << "Opening MobileSetupDialog, ID: " << network_id;
+ dialog_instance = new MobileSetupDialog(*network);
+ dialog_instance->ShowSystemDialog();
}
-GURL MobileSetupDialogDelegate::GetDialogContentURL() const {
- std::string url(chrome::kChromeUIMobileSetupURL);
- url.append(service_path_);
- return GURL(url);
-}
+MobileSetupDialog::MobileSetupDialog(const NetworkState& network)
+ : SystemWebDialogDelegate(
+ GetURL(network),
+ l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE)) {}
-void MobileSetupDialogDelegate::GetWebUIMessageHandlers(
- std::vector<WebUIMessageHandler*>* handlers) const {
+MobileSetupDialog::~MobileSetupDialog() {
+ dialog_instance = nullptr;
}
-void MobileSetupDialogDelegate::GetDialogSize(gfx::Size* size) const {
- size->SetSize(850, 650);
+void MobileSetupDialog::GetDialogSize(gfx::Size* size) const {
+ size->SetSize(kMobileSetupDialogWidth, kMobileSetupDialogHeight);
}
-std::string MobileSetupDialogDelegate::GetDialogArgs() const {
+std::string MobileSetupDialog::GetDialogArgs() const {
return std::string();
}
-void MobileSetupDialogDelegate::OnDialogClosed(const std::string& json_retval) {
- dialog_window_ = nullptr;
-}
-
-void MobileSetupDialogDelegate::OnCloseContents(WebContents* source,
- bool* out_close_dialog) {
+void MobileSetupDialog::OnCloseContents(content::WebContents* source,
+ bool* out_close_dialog) {
// If we're exiting, popping up the confirmation dialog can cause a
// crash. Note: IsTryingToQuit can be cancelled on other platforms by the
// onbeforeunload handler, except on ChromeOS. So IsTryingToQuit is the
// appropriate check to use here.
- if (!dialog_window_ ||
- !MobileActivator::GetInstance()->RunningActivation() ||
+ bool running_activation = MobileActivator::GetInstance()->RunningActivation();
+ NET_LOG(EVENT) << "Closing MobileSetupDialog. Activation running = "
+ << running_activation;
+ if (!dialog_window() || !running_activation ||
browser_shutdown::IsTryingToQuit()) {
*out_close_dialog = true;
return;
}
*out_close_dialog = chrome::ShowQuestionMessageBox(
- dialog_window_, l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE),
+ dialog_window(), l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE),
l10n_util::GetStringUTF16(IDS_MOBILE_CANCEL_ACTIVATION));
}
-bool MobileSetupDialogDelegate::ShouldShowDialogTitle() const {
- return true;
-}
-
-bool MobileSetupDialogDelegate::HandleContextMenu(
- const content::ContextMenuParams& params) {
- return true;
-}
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h
index 14dcab048d7..e15ad870e3d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h
@@ -5,18 +5,30 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_DIALOG_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_DIALOG_H_
-#include <vector>
-
#include "base/macros.h"
-#include "base/memory/singleton.h"
-#include "ui/web_dialogs/web_dialog_ui.h"
+#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+
+namespace chromeos {
+
+class NetworkState;
-class MobileSetupDialog {
+class MobileSetupDialog : public SystemWebDialogDelegate {
public:
static void ShowByNetworkId(const std::string& network_id);
- private:
+ protected:
+ explicit MobileSetupDialog(const NetworkState& network);
+ ~MobileSetupDialog() override;
+
+ // ui::WebDialogDelegate
+ void GetDialogSize(gfx::Size* size) const override;
+ std::string GetDialogArgs() const override;
+ void OnCloseContents(content::WebContents* source,
+ bool* out_close_dialog) override;
+
DISALLOW_COPY_AND_ASSIGN(MobileSetupDialog);
};
+} // namespace chromeos
+
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_DIALOG_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
index 48df3c8a814..1307ed94223 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
@@ -33,10 +33,10 @@
#include "chrome/grit/generated_resources.h"
#include "chromeos/network/device_state.h"
#include "chromeos/network/network_configuration_handler.h"
-#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_state_handler_observer.h"
+#include "components/device_event_log/device_event_log.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
@@ -52,13 +52,7 @@
#include "ui/base/webui/web_ui_util.h"
#include "url/gurl.h"
-using chromeos::MobileActivator;
-using chromeos::NetworkHandler;
-using chromeos::NetworkState;
-using content::BrowserThread;
-using content::RenderViewHost;
-using content::WebContents;
-using content::WebUIMessageHandler;
+namespace chromeos {
namespace {
@@ -83,31 +77,54 @@ const char kJsConnectivityChangedCallback[] =
void DataRequestFailed(
const std::string& service_path,
const content::URLDataSource::GotDataCallback& callback) {
- NET_LOG_ERROR("Data Request Failed for Mobile Setup", service_path);
+ NET_LOG(ERROR) << "Data Request Failed for Mobile Setup: " << service_path;
scoped_refptr<base::RefCountedBytes> html_bytes(new base::RefCountedBytes);
callback.Run(html_bytes.get());
}
+bool HasStringProperty(const base::Value& properties,
+ const char* key,
+ std::string* result) {
+ const base::Value* value =
+ properties.FindKeyOfType(key, base::Value::Type::STRING);
+ if (!value) {
+ NET_LOG(ERROR) << "Missing Mobile Setup property: " << key;
+ return false;
+ }
+ *result = value->GetString();
+ return true;
+}
+
+bool HasDictionaryProperty(const base::Value& properties,
+ const char* key,
+ const base::Value** result) {
+ *result = properties.FindKeyOfType(key, base::Value::Type::DICTIONARY);
+ if (!result)
+ NET_LOG(ERROR) << "Missing Mobile Setup property: " << key;
+ return !!result;
+}
+
// Converts the network properties into a JS object.
void GetDeviceInfo(const base::DictionaryValue& properties,
base::DictionaryValue* value) {
std::string name;
properties.GetStringWithoutPathExpansion(shill::kNameProperty, &name);
std::string activation_type;
- properties.GetStringWithoutPathExpansion(
- shill::kActivationTypeProperty,
- &activation_type);
+ properties.GetStringWithoutPathExpansion(shill::kActivationTypeProperty,
+ &activation_type);
const base::DictionaryValue* payment_dict;
std::string payment_url, post_method, post_data;
if (properties.GetDictionaryWithoutPathExpansion(
shill::kPaymentPortalProperty, &payment_dict)) {
- payment_dict->GetStringWithoutPathExpansion(
- shill::kPaymentPortalURL, &payment_url);
- payment_dict->GetStringWithoutPathExpansion(
- shill::kPaymentPortalMethod, &post_method);
- payment_dict->GetStringWithoutPathExpansion(
- shill::kPaymentPortalPostData, &post_data);
+ payment_dict->GetStringWithoutPathExpansion(shill::kPaymentPortalURL,
+ &payment_url);
+ payment_dict->GetStringWithoutPathExpansion(shill::kPaymentPortalMethod,
+ &post_method);
+ payment_dict->GetStringWithoutPathExpansion(shill::kPaymentPortalPostData,
+ &post_data);
}
+ NET_LOG(EVENT) << "MobileSetupUI: Payment URL = " << payment_url
+ << " Post Data = " << post_data;
value->SetString("activation_type", activation_type);
value->SetString("carrier", name);
@@ -117,12 +134,12 @@ void GetDeviceInfo(const base::DictionaryValue& properties,
// Use the cached DeviceState properties.
std::string device_path;
- if (!properties.GetStringWithoutPathExpansion(
- shill::kDeviceProperty, &device_path) ||
+ if (!properties.GetStringWithoutPathExpansion(shill::kDeviceProperty,
+ &device_path) ||
device_path.empty()) {
return;
}
- const chromeos::DeviceState* device =
+ const DeviceState* device =
NetworkHandler::Get()->network_state_handler()->GetDeviceState(
device_path);
if (!device)
@@ -182,11 +199,9 @@ class MobileSetupUIHTMLSource : public content::URLDataSource {
};
// The handler for Javascript messages related to the "register" view.
-class MobileSetupHandler
- : public WebUIMessageHandler,
- public MobileActivator::Observer,
- public chromeos::NetworkStateHandlerObserver,
- public base::SupportsWeakPtr<MobileSetupHandler> {
+class MobileSetupHandler : public content::WebUIMessageHandler,
+ public MobileActivator::Observer,
+ public NetworkStateHandlerObserver {
public:
MobileSetupHandler();
~MobileSetupHandler() override;
@@ -262,9 +277,7 @@ class MobileSetupHandler
//
////////////////////////////////////////////////////////////////////////////////
-MobileSetupUIHTMLSource::MobileSetupUIHTMLSource()
- : weak_ptr_factory_(this) {
-}
+MobileSetupUIHTMLSource::MobileSetupUIHTMLSource() : weak_ptr_factory_(this) {}
std::string MobileSetupUIHTMLSource::GetSource() const {
return chrome::kChromeUIMobileSetupHost;
@@ -286,29 +299,26 @@ void MobileSetupUIHTMLSource::GetPropertiesAndStartDataRequest(
const content::URLDataSource::GotDataCallback& callback,
const std::string& service_path,
const base::DictionaryValue& properties) {
- const base::DictionaryValue* payment_dict;
- std::string name, usage_url, activation_state, payment_url;
- if (!properties.GetStringWithoutPathExpansion(
- shill::kNameProperty, &name) ||
- !properties.GetStringWithoutPathExpansion(
- shill::kUsageURLProperty, &usage_url) ||
- !properties.GetStringWithoutPathExpansion(
- shill::kActivationStateProperty, &activation_state) ||
- !properties.GetDictionaryWithoutPathExpansion(
- shill::kPaymentPortalProperty, &payment_dict) ||
- !payment_dict->GetStringWithoutPathExpansion(
- shill::kPaymentPortalURL, &payment_url)) {
+ const base::Value* payment_dict;
+ std::string name, activation_state, payment_url;
+ if (!HasStringProperty(properties, shill::kNameProperty, &name) ||
+ !HasStringProperty(properties, shill::kActivationStateProperty,
+ &activation_state) ||
+ !HasDictionaryProperty(properties, shill::kPaymentPortalProperty,
+ &payment_dict) ||
+ !HasStringProperty(*payment_dict, shill::kPaymentPortalURL,
+ &payment_url)) {
DataRequestFailed(service_path, callback);
return;
}
- if (payment_url.empty() && usage_url.empty() &&
+ if (payment_url.empty() &&
activation_state != shill::kActivationStateActivated) {
DataRequestFailed(service_path, callback);
return;
}
- NET_LOG_EVENT("Starting mobile setup", service_path);
+ NET_LOG(EVENT) << "Starting mobile setup: " << service_path;
base::DictionaryValue strings;
strings.SetString("connecting_header",
@@ -326,15 +336,13 @@ void MobileSetupUIHTMLSource::GetPropertiesAndStartDataRequest(
l10n_util::GetStringUTF16(IDS_MOBILE_COMPLETED_TEXT));
strings.SetString("portal_unreachable_header",
l10n_util::GetStringUTF16(IDS_MOBILE_NO_CONNECTION_HEADER));
- strings.SetString("invalid_device_info_header",
+ strings.SetString(
+ "invalid_device_info_header",
l10n_util::GetStringUTF16(IDS_MOBILE_INVALID_DEVICE_INFO_HEADER));
strings.SetString("title", l10n_util::GetStringUTF16(IDS_MOBILE_SETUP_TITLE));
- strings.SetString("close_button",
- l10n_util::GetStringUTF16(IDS_CLOSE));
- strings.SetString("cancel_button",
- l10n_util::GetStringUTF16(IDS_CANCEL));
- strings.SetString("ok_button",
- l10n_util::GetStringUTF16(IDS_OK));
+ strings.SetString("close_button", l10n_util::GetStringUTF16(IDS_CLOSE));
+ strings.SetString("cancel_button", l10n_util::GetStringUTF16(IDS_CANCEL));
+ strings.SetString("ok_button", l10n_util::GetStringUTF16(IDS_OK));
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &strings);
@@ -374,8 +382,7 @@ void MobileSetupUIHTMLSource::GetPropertiesFailure(
MobileSetupHandler::MobileSetupHandler()
: type_(TYPE_UNDETERMINED),
lte_portal_reachable_(true),
- weak_ptr_factory_(this) {
-}
+ weak_ptr_factory_(this) {}
MobileSetupHandler::~MobileSetupHandler() {
if (type_ == TYPE_ACTIVATION) {
@@ -453,7 +460,7 @@ void MobileSetupHandler::HandleStartActivation(const base::ListValue* args) {
if (path.empty())
return;
- LOG(WARNING) << "Starting activation for service " << path;
+ NET_LOG(EVENT) << "Starting activation for service: " << path;
type_ = TYPE_ACTIVATION;
MobileActivator::GetInstance()->AddObserver(this);
@@ -504,8 +511,7 @@ void MobileSetupHandler::HandleGetDeviceInfo(const base::ListValue* args) {
if (path.empty())
return;
- chromeos::NetworkStateHandler* nsh =
- NetworkHandler::Get()->network_state_handler();
+ NetworkStateHandler* nsh = NetworkHandler::Get()->network_state_handler();
// TODO: Figure out why the path has an extra '/' in the front. (e.g. It is
// '//service/5' instead of '/service/5'.
const NetworkState* network = nsh->GetNetworkState(path.substr(1));
@@ -524,8 +530,7 @@ void MobileSetupHandler::HandleGetDeviceInfo(const base::ListValue* args) {
nsh->AddObserver(this, FROM_HERE);
// Update the network status and notify the webui. This is the initial
// network state so the webui should be notified no matter what.
- UpdatePortalReachability(network,
- true /* force notification */);
+ UpdatePortalReachability(network, true /* force notification */);
} else {
type_ = TYPE_PORTAL;
// For non-LTE networks network state is ignored, so report the portal is
@@ -557,8 +562,7 @@ void MobileSetupHandler::GetPropertiesFailure(
const std::string& callback_name,
const std::string& error_name,
std::unique_ptr<base::DictionaryValue> error_data) {
- NET_LOG_ERROR("MobileActivator GetProperties Failed: " + error_name,
- service_path);
+ NET_LOG(ERROR) << "MobileActivator GetProperties Failed: " << error_name;
// Invoke |callback_name| with an empty dictionary.
base::DictionaryValue device_dict;
web_ui()->CallJavascriptFunctionUnsafe(callback_name, device_dict);
@@ -576,7 +580,7 @@ void MobileSetupHandler::DefaultNetworkChanged(
const NetworkState* network =
NetworkHandler::Get()->network_state_handler()->GetNetworkState(path);
if (!network) {
- LOG(ERROR) << "Service path lost";
+ NET_LOG(ERROR) << "Service for activation lost: " << path;
web_ui()->GetWebContents()->Close();
return;
}
@@ -596,15 +600,13 @@ void MobileSetupHandler::NetworkConnectionStateChanged(
UpdatePortalReachability(network, false /* do not force notification */);
}
-void MobileSetupHandler::UpdatePortalReachability(
- const NetworkState* network,
- bool force_notification) {
+void MobileSetupHandler::UpdatePortalReachability(const NetworkState* network,
+ bool force_notification) {
DCHECK(web_ui());
DCHECK_EQ(type_, TYPE_PORTAL_LTE);
- chromeos::NetworkStateHandler* nsh =
- NetworkHandler::Get()->network_state_handler();
+ NetworkStateHandler* nsh = NetworkHandler::Get()->network_state_handler();
bool portal_reachable =
(network->IsConnectedState() ||
(nsh->DefaultNetwork() &&
@@ -624,8 +626,7 @@ void MobileSetupHandler::UpdatePortalReachability(
//
////////////////////////////////////////////////////////////////////////////////
-MobileSetupUI::MobileSetupUI(content::WebUI* web_ui)
- : WebUIController(web_ui) {
+MobileSetupUI::MobileSetupUI(content::WebUI* web_ui) : ui::WebDialogUI(web_ui) {
web_ui->AddMessageHandler(std::make_unique<MobileSetupHandler>());
MobileSetupUIHTMLSource* html_source = new MobileSetupUIHTMLSource();
@@ -636,8 +637,13 @@ MobileSetupUI::MobileSetupUI(content::WebUI* web_ui)
content::WebContentsObserver::Observe(web_ui->GetWebContents());
}
+MobileSetupUI::~MobileSetupUI() = default;
+
void MobileSetupUI::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
+ NET_LOG(EVENT) << "MobileSetupUI: DidFinishNavigation. Committed: "
+ << navigation_handle->HasCommitted() << " Frame: "
+ << navigation_handle->GetRenderFrameHost()->GetFrameName();
if (!navigation_handle->HasCommitted() ||
navigation_handle->GetRenderFrameHost()->GetFrameName() !=
"paymentForm") {
@@ -645,6 +651,8 @@ void MobileSetupUI::DidFinishNavigation(
}
if (navigation_handle->IsErrorPage()) {
+ NET_LOG(ERROR) << "MobileSetupUI: Error: "
+ << navigation_handle->GetNetErrorCode();
base::Value result_value(-navigation_handle->GetNetErrorCode());
web_ui()->CallJavascriptFunctionUnsafe(kJsPortalFrameLoadFailedCallback,
result_value);
@@ -653,3 +661,5 @@ void MobileSetupUI::DidFinishNavigation(
web_ui()->CallJavascriptFunctionUnsafe(kJsPortalFrameLoadCompletedCallback);
}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h
index 0fd9d74190e..a98f2935ff4 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h
@@ -6,17 +6,17 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_UI_H_
#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_ui_controller.h"
+#include "ui/web_dialogs/web_dialog_ui.h"
+
+namespace chromeos {
// A custom WebUI that defines datasource for mobile setup registration page
// that is used in Chrome OS activate modem and perform plan subscription tasks.
-class MobileSetupUI : public content::WebUIController,
- public content::WebContentsObserver,
- public base::SupportsWeakPtr<MobileSetupUI> {
+class MobileSetupUI : public ui::WebDialogUI,
+ public content::WebContentsObserver {
public:
explicit MobileSetupUI(content::WebUI* web_ui);
+ ~MobileSetupUI() override;
private:
// content::WebContentsObserver overrides.
@@ -26,4 +26,6 @@ class MobileSetupUI : public content::WebUIController,
DISALLOW_COPY_AND_ASSIGN(MobileSetupUI);
};
+} // namespace chromeos
+
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc
index 5ed83ce27d5..3f43b8aa4c7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc
@@ -4,14 +4,22 @@
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/sys_info.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h"
+#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/multidevice_setup_resources.h"
#include "chrome/grit/multidevice_setup_resources_map.h"
+#include "chromeos/grit/chromeos_resources.h"
+#include "chromeos/services/multidevice_setup/public/cpp/url_provider.h"
+#include "chromeos/services/multidevice_setup/public/mojom/constants.mojom.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
@@ -20,23 +28,37 @@ namespace multidevice_setup {
namespace {
+// TODO(khorimoto): Localize footnote marker if necessary.
+const char kFootnoteMarker[] = "*";
+
constexpr int kDialogHeightPx = 640;
constexpr int kDialogWidthPx = 768;
void AddMultiDeviceSetupStrings(content::WebUIDataSource* html_source) {
- // TODO(jordynass): Translate the newly added strings from
- // //chrome/app/chromeos_strings.grdp.
static constexpr struct {
const char* name;
int id;
- } kLocalizedStrings[] = {
+ } kLocalizedStringsWithoutPlaceholders[] = {
{"accept", IDS_MULTIDEVICE_SETUP_ACCEPT_LABEL},
{"cancel", IDS_CANCEL},
{"done", IDS_DONE},
+ {"passwordPageHeader", IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_HEADER},
+ {"enterPassword",
+ IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_ENTER_PASSWORD_LABEL},
+ {"wrongPassword",
+ IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_WRONG_PASSWORD_LABEL},
{"startSetupPageMultipleDeviceHeader",
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MULTIPLE_DEVICE_HEADER},
{"startSetupPageSingleDeviceHeader",
IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_SINGLE_DEVICE_HEADER},
+ {"startSetupPageFeatureListHeader",
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_FEATURE_LIST_HEADER},
+ {"startSetupPageFeatureListAwm",
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_AWM_DESCRIPTION},
+ {"startSetupPageFeatureListInstallApps",
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_INSTALL_APPS_DESCRIPTION},
+ {"startSetupPageFeatureListAddFeatures",
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_ADD_FEATURES},
{"setupFailedPageHeader", IDS_MULTIDEVICE_SETUP_SETUP_FAILED_PAGE_HEADER},
{"setupFailedPageMessage",
IDS_MULTIDEVICE_SETUP_SETUP_FAILED_PAGE_MESSAGE},
@@ -45,16 +67,26 @@ void AddMultiDeviceSetupStrings(content::WebUIDataSource* html_source) {
{"setupSucceededPageMessage",
IDS_MULTIDEVICE_SETUP_SETUP_SUCCEEDED_PAGE_MESSAGE},
{"startSetupPageHeader", IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_HEADER},
- {"startSetupPageMessagePart1",
- IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MESSAGE_PART_1},
- {"startSetupPageMessagePart2",
- IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MESSAGE_PART_2},
{"title", IDS_MULTIDEVICE_SETUP_DIALOG_TITLE},
{"tryAgain", IDS_MULTIDEVICE_SETUP_TRY_AGAIN_LABEL},
};
- for (const auto& entry : kLocalizedStrings)
+ for (const auto& entry : kLocalizedStringsWithoutPlaceholders)
html_source->AddLocalizedString(entry.name, entry.id);
+
+ html_source->AddString(
+ "startSetupPageMessage",
+ l10n_util::GetStringFUTF16(
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MESSAGE,
+ base::ASCIIToUTF16(kFootnoteMarker),
+ base::UTF8ToUTF16(
+ chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl()
+ .spec())));
+ html_source->AddString(
+ "startSetupPageFootnote",
+ l10n_util::GetStringFUTF16(
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_FOOTNOTE,
+ base::ASCIIToUTF16(kFootnoteMarker)));
}
} // namespace
@@ -93,7 +125,7 @@ void MultiDeviceSetupDialog::OnDialogClosed(const std::string& json_retval) {
}
MultiDeviceSetupDialogUI::MultiDeviceSetupDialogUI(content::WebUI* web_ui)
- : ui::WebDialogUI(web_ui) {
+ : ui::MojoWebDialogUI(web_ui) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIMultiDeviceSetupHost);
@@ -101,6 +133,19 @@ MultiDeviceSetupDialogUI::MultiDeviceSetupDialogUI(content::WebUI* web_ui)
source->SetJsonPath("strings.js");
source->SetDefaultResource(
IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_DIALOG_HTML);
+ source->AddResourcePath("mojo/public/mojom/base/time.mojom.js",
+ IDR_TIME_MOJOM_JS);
+ source->AddResourcePath(
+ "chromeos/services/device_sync/public/mojom/device_sync.mojom.js",
+ IDR_DEVICE_SYNC_MOJOM_JS);
+ source->AddResourcePath(
+ "chromeos/services/multidevice_setup/public/mojom/"
+ "multidevice_setup.mojom.js",
+ IDR_MULTIDEVICE_SETUP_MOJOM_JS);
+ source->AddResourcePath(
+ "chromeos/services/multidevice_setup/public/mojom/"
+ "multidevice_setup_constants.mojom.js",
+ IDR_MULTIDEVICE_SETUP_CONSTANTS_MOJOM_JS);
// Note: The |kMultiDeviceSetupResourcesSize| and |kMultideviceSetupResources|
// fields are defined in the generated file
@@ -110,11 +155,27 @@ MultiDeviceSetupDialogUI::MultiDeviceSetupDialogUI(content::WebUI* web_ui)
kMultideviceSetupResources[i].value);
}
+ web_ui->AddMessageHandler(std::make_unique<MultideviceSetupHandler>());
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
+
+ // Add Mojo bindings to this WebUI so that Mojo calls can occur in JavaScript.
+ AddHandlerToRegistry(base::BindRepeating(
+ &MultiDeviceSetupDialogUI::BindMultiDeviceSetup, base::Unretained(this)));
}
MultiDeviceSetupDialogUI::~MultiDeviceSetupDialogUI() = default;
+void MultiDeviceSetupDialogUI::BindMultiDeviceSetup(
+ chromeos::multidevice_setup::mojom::MultiDeviceSetupRequest request) {
+ service_manager::Connector* connector =
+ content::BrowserContext::GetConnectorFor(
+ web_ui()->GetWebContents()->GetBrowserContext());
+ DCHECK(connector);
+
+ connector->BindInterface(chromeos::multidevice_setup::mojom::kServiceName,
+ std::move(request));
+}
+
} // namespace multidevice_setup
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h
index 66433f09942..cd79039b1f2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "ui/web_dialogs/web_dialog_ui.h"
namespace chromeos {
@@ -38,12 +39,15 @@ class MultiDeviceSetupDialog : public SystemWebDialogDelegate {
DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupDialog);
};
-class MultiDeviceSetupDialogUI : public ui::WebDialogUI {
+class MultiDeviceSetupDialogUI : public ui::MojoWebDialogUI {
public:
explicit MultiDeviceSetupDialogUI(content::WebUI* web_ui);
~MultiDeviceSetupDialogUI() override;
private:
+ void BindMultiDeviceSetup(
+ chromeos::multidevice_setup::mojom::MultiDeviceSetupRequest request);
+
DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupDialogUI);
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc
new file mode 100644
index 00000000000..29d6bbc74f8
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc
@@ -0,0 +1,69 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
+#include "chrome/common/webui_url_constants.h"
+#include "components/user_manager/user.h"
+#include "ui/base/webui/web_ui_util.h"
+
+namespace chromeos {
+
+namespace multidevice_setup {
+
+MultideviceSetupHandler::MultideviceSetupHandler() = default;
+
+MultideviceSetupHandler::~MultideviceSetupHandler() = default;
+
+void MultideviceSetupHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "getProfileInfo",
+ base::BindRepeating(&MultideviceSetupHandler::HandleGetProfileInfo,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "openMultiDeviceSettings",
+ base::BindRepeating(
+ &MultideviceSetupHandler::HandleOpenMultiDeviceSettings,
+ base::Unretained(this)));
+}
+
+void MultideviceSetupHandler::HandleGetProfileInfo(
+ const base::ListValue* args) {
+ AllowJavascript();
+
+ std::string callback_id;
+ bool result = args->GetString(0, &callback_id);
+ DCHECK(result);
+
+ const user_manager::User* user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(
+ Profile::FromWebUI(web_ui()));
+
+ base::DictionaryValue response;
+ response.SetString("email", user->GetDisplayEmail());
+
+ scoped_refptr<base::RefCountedMemory> image =
+ chromeos::UserImageSource::GetUserImage(user->GetAccountId());
+ response.SetString("profilePhotoUrl",
+ webui::GetPngDataUrl(image->front(), image->size()));
+
+ ResolveJavascriptCallback(base::Value(callback_id), response);
+}
+
+void MultideviceSetupHandler::HandleOpenMultiDeviceSettings(
+ const base::ListValue* args) {
+ DCHECK(args->empty());
+ chrome::ShowSettingsSubPageForProfile(Profile::FromWebUI(web_ui()),
+ chrome::kConnectedDevicesSubPage);
+}
+
+} // namespace multidevice_setup
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h
new file mode 100644
index 00000000000..093d0fb03bc
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h
@@ -0,0 +1,35 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_HANDLER_H_
+
+#include "base/macros.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace chromeos {
+
+namespace multidevice_setup {
+
+// Chrome MultiDevice setup flow WebUI handler.
+class MultideviceSetupHandler : public content::WebUIMessageHandler {
+ public:
+ MultideviceSetupHandler();
+ ~MultideviceSetupHandler() override;
+
+ private:
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
+
+ void HandleGetProfileInfo(const base::ListValue* args);
+ void HandleOpenMultiDeviceSettings(const base::ListValue* args);
+
+ DISALLOW_COPY_AND_ASSIGN(MultideviceSetupHandler);
+};
+
+} // namespace multidevice_setup
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
index 21d6578d905..656de5b6d66 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/power_ui.cc
@@ -7,7 +7,9 @@
#include <stddef.h>
#include <memory>
+#include <string>
#include <utility>
+#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -17,6 +19,7 @@
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/chromeos/power/power_data_collector.h"
+#include "chrome/browser/chromeos/power/process_data_collector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -43,6 +46,8 @@ const char kRequestCpuFreqDataCallback[] = "requestCpuFreqData";
const char kOnRequestCpuFreqDataFunction[] =
"powerUI.showCpuFreqData";
+const char kRequestProcessUsageDataCallback[] = "requestProcessUsageData";
+
class PowerMessageHandler : public content::WebUIMessageHandler {
public:
PowerMessageHandler();
@@ -55,6 +60,7 @@ class PowerMessageHandler : public content::WebUIMessageHandler {
void OnGetBatteryChargeData(const base::ListValue* value);
void OnGetCpuIdleData(const base::ListValue* value);
void OnGetCpuFreqData(const base::ListValue* value);
+ void OnGetProcessUsageData(const base::ListValue* value);
void GetJsStateOccupancyData(
const std::vector<CpuDataCollector::StateOccupancySampleDeque>& data,
const std::vector<std::string>& state_names,
@@ -81,6 +87,10 @@ void PowerMessageHandler::RegisterMessages() {
kRequestCpuFreqDataCallback,
base::BindRepeating(&PowerMessageHandler::OnGetCpuFreqData,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kRequestProcessUsageDataCallback,
+ base::BindRepeating(&PowerMessageHandler::OnGetProcessUsageData,
+ base::Unretained(this)));
}
void PowerMessageHandler::OnGetBatteryChargeData(const base::ListValue* value) {
@@ -142,6 +152,32 @@ void PowerMessageHandler::OnGetCpuFreqData(const base::ListValue* value) {
js_freq_data, js_system_resumed_data);
}
+void PowerMessageHandler::OnGetProcessUsageData(const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(1U, args->GetSize());
+
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+
+ const std::vector<ProcessDataCollector::ProcessUsageData>& process_list =
+ ProcessDataCollector::Get()->GetProcessUsages();
+
+ base::ListValue js_process_usages;
+ for (const auto& process_info : process_list) {
+ std::unique_ptr<base::DictionaryValue> element =
+ std::make_unique<base::DictionaryValue>();
+ element->SetInteger("pid", process_info.process_data.pid);
+ element->SetString("name", process_info.process_data.name);
+ element->SetString("cmdline", process_info.process_data.cmdline);
+ element->SetInteger("type",
+ static_cast<int>(process_info.process_data.type));
+ element->SetDouble("powerUsageFraction", process_info.power_usage_fraction);
+ js_process_usages.Append(std::move(element));
+ }
+
+ ResolveJavascriptCallback(*callback_id, js_process_usages);
+}
+
void PowerMessageHandler::GetJsSystemResumedData(base::ListValue *data) {
DCHECK(data);
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 95008b5f536..7a48123bd79 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
@@ -101,8 +101,7 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
return;
}
- Profile* profile = Profile::FromBrowserContext(
- web_ui()->GetWebContents()->GetBrowserContext());
+ Profile* profile = Profile::FromWebUI(web_ui());
DCHECK(profile);
system::SetTimezoneFromUI(profile, timezone_id);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h b/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h
index f2d2bfedf91..4a21bbabe73 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_message_handler.h
@@ -9,7 +9,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/values.h"
#include "content/public/browser/web_ui_message_handler.h"
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 aa7400cb37d..165ee5e13b2 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
@@ -70,8 +70,8 @@ void SystemWebDialogDelegate::ShowSystemDialog(bool is_minimal_style) {
int container_id = GetDialogModalType() == ui::MODAL_TYPE_NONE
? ash::kShellWindowId_AlwaysOnTopContainer
: ash::kShellWindowId_LockSystemModalContainer;
- chrome::ShowWebDialogInContainer(container_id, browser_context, this,
- is_minimal_style);
+ dialog_window_ = chrome::ShowWebDialogInContainer(
+ container_id, browser_context, this, is_minimal_style);
}
} // namespace chromeos
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 6c248bb8cce..7e50ee2b283 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
@@ -51,11 +51,15 @@ class SystemWebDialogDelegate : public ui::WebDialogDelegate {
static constexpr int kDialogWidth = 512;
static constexpr int kDialogHeight = 480;
+ protected:
+ gfx::NativeWindow dialog_window() const { return dialog_window_; }
+
private:
GURL gurl_;
base::string16 title_;
content::WebUI* webui_ = nullptr;
ui::ModalType modal_type_;
+ gfx::NativeWindow dialog_window_;
DISALLOW_COPY_AND_ASSIGN(SystemWebDialogDelegate);
};
diff --git a/chromium/chrome/browser/ui/webui/components_ui.cc b/chromium/chrome/browser/ui/webui/components_ui.cc
index a3a4fe9b9b3..be13e830fc0 100644
--- a/chromium/chrome/browser/ui/webui/components_ui.cc
+++ b/chromium/chrome/browser/ui/webui/components_ui.cc
@@ -183,12 +183,14 @@ std::unique_ptr<base::ListValue> ComponentsUI::LoadComponents() {
for (size_t j = 0; j < component_ids.size(); ++j) {
update_client::CrxUpdateItem item;
if (cus->GetComponentDetails(component_ids[j], &item)) {
- std::unique_ptr<base::DictionaryValue> component_entry(
- new base::DictionaryValue());
+ auto component_entry = std::make_unique<base::DictionaryValue>();
component_entry->SetString("id", component_ids[j]);
- component_entry->SetString("name", item.component.name);
- component_entry->SetString("version", item.component.version.GetString());
component_entry->SetString("status", ServiceStatusToString(item.state));
+ if (item.component) {
+ component_entry->SetString("name", item.component->name);
+ component_entry->SetString("version",
+ item.component->version.GetString());
+ }
component_list->Append(std::move(component_entry));
}
}
@@ -266,8 +268,8 @@ void ComponentsUI::OnEvent(Events event, const std::string& id) {
if (event == Events::COMPONENT_UPDATED) {
auto* component_updater = g_browser_process->component_updater();
update_client::CrxUpdateItem item;
- if (component_updater->GetComponentDetails(id, &item))
- parameters.SetString("version", item.component.version.GetString());
+ if (component_updater->GetComponentDetails(id, &item) && item.component)
+ parameters.SetString("version", item.component->version.GetString());
}
parameters.SetString("id", id);
}
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
index ab34217d8cc..5d2afa81386 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
@@ -11,6 +11,7 @@
#include "base/feature_list.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_piece.h"
#include "base/values.h"
#include "base/win/windows_version.h"
#include "chrome/browser/conflicts/module_database_win.h"
@@ -21,6 +22,7 @@
#include "ui/base/l10n/l10n_util.h"
#if defined(GOOGLE_CHROME_BUILD)
+#include "base/win/win_util.h"
#include "chrome/browser/conflicts/incompatible_applications_updater_win.h"
#include "chrome/browser/conflicts/module_blacklist_cache_updater_win.h"
#endif
@@ -28,93 +30,165 @@
namespace {
#if defined(GOOGLE_CHROME_BUILD)
+
+// Strings used twice.
+constexpr char kNotLoaded[] = "Not loaded";
+constexpr char kAllowedInputMethodEditor[] = "Allowed - Input method editor";
+constexpr char kAllowedMatchingCertificate[] = "Allowed - Matching certificate";
+constexpr char kAllowedMicrosoftModule[] = "Allowed - Microsoft module";
+constexpr char kAllowedWhitelisted[] = "Allowed - Whitelisted";
+constexpr char kAllowedSameDirectory[] =
+#if defined(OFFICIAL_BUILD)
+ // In official builds, modules in the Chrome directory are blocked but they
+ // won't cause a warning because the warning would blame Chrome itself.
+ "Tolerated - In executable directory";
+#else // !defined(OFFICIAL_BUILD)
+ // In developer builds, DLLs that are part of Chrome are not signed and thus
+ // the easy way to identify them is to check that they are in the same
+ // directory (or child folder) as the main exe.
+ "Allowed - In executable directory (dev builds only)";
+#endif
+
+void AppendString(base::StringPiece input, std::string* output) {
+ if (!output->empty())
+ *output += ", ";
+ input.AppendToString(output);
+}
+
+// Returns a string describing the current module blocking status: loaded or
+// not, blocked or not, was in blacklist cache or not, bypassed blocking or not.
+std::string GetBlockingStatusString(
+ const ModuleBlacklistCacheUpdater::ModuleBlockingState& blocking_state) {
+ std::string status;
+
+ // Output status regarding the blacklist cache, current blocking, and
+ // load status.
+ if (blocking_state.was_blocked)
+ status = "Blocked";
+ if (!blocking_state.was_loaded)
+ AppendString(kNotLoaded, &status);
+ else if (blocking_state.was_in_blacklist_cache)
+ AppendString("Bypassed blocking", &status);
+ if (blocking_state.was_in_blacklist_cache)
+ AppendString("In blacklist cache", &status);
+
+ return status;
+}
+
+// Returns a string describing the blocking decision related to a module. This
+// returns the empty string to indicate that the warning decision description
+// should be used instead.
+std::string GetBlockingDecisionString(
+ const ModuleBlacklistCacheUpdater::ModuleBlockingState& blocking_state,
+ IncompatibleApplicationsUpdater* incompatible_applications_updater) {
+ using BlockingDecision = ModuleBlacklistCacheUpdater::ModuleBlockingDecision;
+
+ // Append status regarding the logic that will be applied during the next
+ // startup.
+ switch (blocking_state.blocking_decision) {
+ case BlockingDecision::kUnknown:
+ NOTREACHED();
+ break;
+ case BlockingDecision::kAllowedIME:
+ return kAllowedInputMethodEditor;
+ case BlockingDecision::kAllowedSameCertificate:
+ return kAllowedMatchingCertificate;
+ case BlockingDecision::kAllowedSameDirectory:
+ return kAllowedSameDirectory;
+ case BlockingDecision::kAllowedMicrosoft:
+ return kAllowedMicrosoftModule;
+ case BlockingDecision::kAllowedWhitelisted:
+ return kAllowedWhitelisted;
+ case BlockingDecision::kTolerated:
+ // This is a module explicitly allowed to load by the Module List
+ // component. But it is still valid for a potential warning, and so the
+ // warning status is used instead.
+ if (incompatible_applications_updater)
+ break;
+ return "Tolerated - Will be blocked in the future";
+ case BlockingDecision::kDisallowedExplicit:
+ return "Disallowed - Explicitly blacklisted";
+ case BlockingDecision::kDisallowedImplicit:
+ return "Disallowed - Implicitly blacklisted";
+ }
+
+ // Returning an empty string indicates that the warning status should be used.
+ return std::string();
+}
+
+// Returns a string describing the warning decision that was made regarding a
+// module.
+std::string GetModuleWarningDecisionString(
+ const ModuleInfoKey& module_key,
+ IncompatibleApplicationsUpdater* incompatible_applications_updater) {
+ using WarningDecision =
+ IncompatibleApplicationsUpdater::ModuleWarningDecision;
+
+ WarningDecision warning_decision =
+ incompatible_applications_updater->GetModuleWarningDecision(module_key);
+
+ switch (warning_decision) {
+ case WarningDecision::kNotLoaded:
+ return kNotLoaded;
+ case WarningDecision::kAllowedIME:
+ return kAllowedInputMethodEditor;
+ case WarningDecision::kAllowedShellExtension:
+ return "Tolerated - Shell extension";
+ case WarningDecision::kAllowedSameCertificate:
+ return kAllowedMatchingCertificate;
+ case WarningDecision::kAllowedSameDirectory:
+ return kAllowedSameDirectory;
+ case WarningDecision::kAllowedMicrosoft:
+ return kAllowedMicrosoftModule;
+ case WarningDecision::kAllowedWhitelisted:
+ return kAllowedWhitelisted;
+ case WarningDecision::kNoTiedApplication:
+ return "Tolerated - Could not tie to an installed application";
+ case WarningDecision::kIncompatible:
+ return "Incompatible";
+ case WarningDecision::kAddedToBlacklist:
+ case WarningDecision::kUnknown:
+ NOTREACHED();
+ break;
+ }
+
+ return std::string();
+}
+
std::string GetModuleStatusString(
const ModuleInfoKey& module_key,
IncompatibleApplicationsUpdater* incompatible_applications_updater,
ModuleBlacklistCacheUpdater* module_blacklist_cache_updater) {
- DCHECK(incompatible_applications_updater || module_blacklist_cache_updater);
+ if (!incompatible_applications_updater && !module_blacklist_cache_updater)
+ return std::string();
- // Strings used twice.
- constexpr char kNotLoaded[] = "Not loaded";
- constexpr char kAllowedInputMethodEditor[] = "Allowed - Input method editor";
- constexpr char kAllowedMatchingCertificate[] =
- "Allowed - Matching certificate";
- constexpr char kAllowedSameDirectory[] = "Allowed - In executable directory";
- constexpr char kAllowedMicrosoftModule[] = "Allowed - Microsoft module";
- constexpr char kAllowedWhitelisted[] = "Allowed - Whitelisted";
+ std::string status;
// The blocking status is shown over the warning status.
if (module_blacklist_cache_updater) {
- using BlockingDecision =
- ModuleBlacklistCacheUpdater::ModuleBlockingDecision;
-
- BlockingDecision blocking_decision =
- module_blacklist_cache_updater->GetModuleBlockingDecision(module_key);
-
- switch (blocking_decision) {
- case BlockingDecision::kNotLoaded:
- return kNotLoaded;
- case BlockingDecision::kAllowedIME:
- return kAllowedInputMethodEditor;
- case BlockingDecision::kAllowedSameCertificate:
- return kAllowedMatchingCertificate;
- case BlockingDecision::kAllowedSameDirectory:
- return kAllowedSameDirectory;
- case BlockingDecision::kAllowedMicrosoft:
- return kAllowedMicrosoftModule;
- case BlockingDecision::kAllowedWhitelisted:
- return kAllowedWhitelisted;
- case BlockingDecision::kTolerated:
- // This is a module explicitely allowed to load by the Module List
- // component. But it is still valid for a potential warning, and so the
- // warning status is used instead.
- if (incompatible_applications_updater)
- break;
- return "Tolerated - Will be blocked in the future";
- case BlockingDecision::kBlacklisted:
- return "Disallowed - Added to the blacklist";
- case BlockingDecision::kBlocked:
- return "Disallowed - Blocked";
- case BlockingDecision::kUnknown:
- NOTREACHED();
- break;
+ const ModuleBlacklistCacheUpdater::ModuleBlockingState& blocking_state =
+ module_blacklist_cache_updater->GetModuleBlockingState(module_key);
+
+ status = GetBlockingStatusString(blocking_state);
+
+ std::string blocking_string = GetBlockingDecisionString(
+ blocking_state, incompatible_applications_updater);
+ if (!blocking_string.empty()) {
+ AppendString(blocking_string, &status);
+ return status;
}
+
+ // An empty |blocking_string| indicates that a warning decision string
+ // should be used instead.
}
if (incompatible_applications_updater) {
- using WarningDecision =
- IncompatibleApplicationsUpdater::ModuleWarningDecision;
-
- WarningDecision warning_decision =
- incompatible_applications_updater->GetModuleWarningDecision(module_key);
-
- switch (warning_decision) {
- case WarningDecision::kNotLoaded:
- return kNotLoaded;
- case WarningDecision::kAllowedIME:
- return kAllowedInputMethodEditor;
- case WarningDecision::kAllowedShellExtension:
- return "Tolerated - Shell extension";
- case WarningDecision::kAllowedSameCertificate:
- return kAllowedMatchingCertificate;
- case WarningDecision::kAllowedSameDirectory:
- return kAllowedSameDirectory;
- case WarningDecision::kAllowedMicrosoft:
- return kAllowedMicrosoftModule;
- case WarningDecision::kAllowedWhitelisted:
- return kAllowedWhitelisted;
- case WarningDecision::kNoTiedApplication:
- return "Tolerated - Could not tie to an installed application";
- case WarningDecision::kIncompatible:
- return "Incompatible";
- case WarningDecision::kAddedToBlacklist:
- case WarningDecision::kUnknown:
- NOTREACHED();
- break;
- }
+ AppendString(GetModuleWarningDecisionString(
+ module_key, incompatible_applications_updater),
+ &status);
}
- return std::string();
+ return status;
}
#endif // defined(GOOGLE_CHROME_BUILD)
@@ -162,11 +236,6 @@ void ConflictsHandler::OnNewModuleFound(const ModuleInfoKey& module_key,
std::string type_string;
if (module_data.module_properties & ModuleInfoData::kPropertyShellExtension)
type_string = "Shell extension";
- if (module_data.module_properties & ModuleInfoData::kPropertyBlocked) {
- if (!type_string.empty())
- type_string += ", ";
- type_string += "blocked";
- }
data->SetString("type_description", type_string);
const auto& inspection_result = *module_data.inspection_result;
@@ -234,7 +303,10 @@ void ConflictsHandler::HandleRequestModuleList(const base::ListValue* args) {
third_party_features_status_ = kFeatureDisabled;
}
- // The above 2 cases are the only possible reasons why the manager wouldn't
+ if (base::win::IsEnterpriseManaged())
+ third_party_features_status_ = kEnterpriseManaged;
+
+ // The above 3 cases are the only possible reasons why the manager wouldn't
// exist.
DCHECK(third_party_features_status_.has_value());
#else // defined(GOOGLE_CHROME_BUILD)
@@ -298,6 +370,9 @@ std::string ConflictsHandler::GetThirdPartyFeaturesStatusString(
case ThirdPartyFeaturesStatus::kNonGoogleChromeBuild:
return "The third-party features are not available in non-Google Chrome "
"builds.";
+ case ThirdPartyFeaturesStatus::kEnterpriseManaged:
+ return "The third-party features are temporarily disabled for clients on "
+ "domain-joined machines.";
case ThirdPartyFeaturesStatus::kPolicyDisabled:
return "The ThirdPartyBlockingEnabled group policy is disabled.";
case ThirdPartyFeaturesStatus::kFeatureDisabled:
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
index 51f0630e035..99ff0e656e4 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
@@ -33,6 +33,12 @@ class ConflictsHandler : public content::WebUIMessageHandler,
enum ThirdPartyFeaturesStatus {
// The third-party features are not available in non-Google Chrome builds.
kNonGoogleChromeBuild,
+ // The third-party features are temporarily disabled on domain-joined
+ // machines because of a known issue with third-party blocking and the
+ // IAttachmentExecute::Save() API (https://crbug.com/870998).
+ // TODO(pmonette): Move IAttachmentExecute::Save() to a utility process and
+ // remove this.
+ kEnterpriseManaged,
// The ThirdPartyBlockingEnabled group policy is disabled.
kPolicyDisabled,
// Both the IncompatibleApplicationsWarning and the
diff --git a/chromium/chrome/browser/ui/webui/discards/discards.mojom b/chromium/chrome/browser/ui/webui/discards/discards.mojom
index 64f0d0eb1c4..b9c02585a7d 100644
--- a/chromium/chrome/browser/ui/webui/discards/discards.mojom
+++ b/chromium/chrome/browser/ui/webui/discards/discards.mojom
@@ -37,6 +37,8 @@ struct TabDiscardsInfo {
// The number of times this tab has been discarded in the current browser
// session.
int32 discard_count;
+ // If the tab is currently discarded, the discard reason.
+ LifecycleUnitDiscardReason discard_reason;
// The rank of the tab in the "importance to user" list. The tab with 1 is the
// most important, the tab with N is the least important.
int32 utility_rank;
@@ -56,6 +58,8 @@ struct TabDiscardsInfo {
double reactivation_score;
// Site engagement score.
double site_engagement_score;
+ // Whether or not the tab has input focus.
+ bool has_focus;
};
// Interface for providing information about discards. Lives in the browser
diff --git a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
index 5aaf01c15d1..8c321454cac 100644
--- a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
+++ b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/resource_coordinator/discard_reason.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h"
#include "chrome/browser/resource_coordinator/tab_activity_watcher.h"
@@ -34,9 +33,9 @@
namespace {
-resource_coordinator::DiscardReason GetDiscardReason(bool urgent) {
- return urgent ? resource_coordinator::DiscardReason::kUrgent
- : resource_coordinator::DiscardReason::kProactive;
+mojom::LifecycleUnitDiscardReason GetDiscardReason(bool urgent) {
+ return urgent ? mojom::LifecycleUnitDiscardReason::URGENT
+ : mojom::LifecycleUnitDiscardReason::PROACTIVE;
}
mojom::LifecycleUnitVisibility GetLifecycleUnitVisibility(
@@ -78,10 +77,7 @@ double GetSiteEngagementScore(content::WebContents* contents) {
auto* engagement_svc = SiteEngagementService::Get(
Profile::FromBrowserContext(contents->GetBrowserContext()));
- double engagement =
- engagement_svc->GetDetails(nav_entry->GetURL()).total_score;
-
- return engagement;
+ return engagement_svc->GetDetails(nav_entry->GetURL()).total_score;
}
class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider {
@@ -127,9 +123,12 @@ class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider {
info->cannot_freeze_reasons = freeze_details.GetFailureReasonStrings();
resource_coordinator::DecisionDetails discard_details;
info->can_discard = lifecycle_unit->CanDiscard(
- resource_coordinator::DiscardReason::kProactive, &discard_details);
+ mojom::LifecycleUnitDiscardReason::PROACTIVE, &discard_details);
info->cannot_discard_reasons = discard_details.GetFailureReasonStrings();
- info->discard_count = tab_lifecycle_unit_external->GetDiscardCount();
+ info->discard_count = lifecycle_unit->GetDiscardCount();
+ // This is only valid if the state is PENDING_DISCARD or DISCARD, but the
+ // javascript code takes care of that.
+ info->discard_reason = lifecycle_unit->GetDiscardReason();
info->utility_rank = rank++;
const base::TimeTicks last_focused_time =
lifecycle_unit->GetLastFocusedTime();
@@ -148,6 +147,11 @@ class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider {
if (info->has_reactivation_score)
info->reactivation_score = reactivation_score.value();
info->site_engagement_score = GetSiteEngagementScore(contents);
+ // TODO(crbug.com/876340): The focus is used to compute the page lifecycle
+ // state. This should be replaced with the actual page lifecycle state
+ // information from Blink, but this depends on implementing the passive
+ // state and plumbing it to the browser.
+ info->has_focus = lifecycle_unit->GetLastFocusedTime().is_max();
infos.push_back(std::move(info));
}
diff --git a/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc
index 8d533f08310..771a37085e2 100644
--- a/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc
@@ -21,11 +21,10 @@ using contextual_suggestions::ContextualSuggestionsResult;
namespace {
bool AreChromeFlagsSetup() {
- return (base::FeatureList::IsEnabled(
- contextual_suggestions::kContextualSuggestionsBottomSheet) ||
- base::FeatureList::IsEnabled(
- contextual_suggestions::kContextualSuggestionsButton)) &&
- base::FeatureList::IsEnabled(chrome::android::kChromeModernDesign);
+ return base::FeatureList::IsEnabled(
+ contextual_suggestions::kContextualSuggestionsBottomSheet) ||
+ base::FeatureList::IsEnabled(
+ contextual_suggestions::kContextualSuggestionsButton);
}
std::string GetAreChromeFlagsSetupString() {
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_browsertest.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_browsertest.cc
new file mode 100644
index 00000000000..43bcec32608
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_browsertest.cc
@@ -0,0 +1,53 @@
+// 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 "base/files/file_path.h"
+#include "base/path_service.h"
+#include "base/strings/stringprintf.h"
+#include "chrome/browser/extensions/chrome_test_extension_loader.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
+#include "url/gurl.h"
+
+using ExtensionsInternalsTest = extensions::ExtensionBrowserTest;
+
+IN_PROC_BROWSER_TEST_F(ExtensionsInternalsTest,
+ TestExtensionsInternalsAreServed) {
+ // Install an extension that we can check for.
+ base::FilePath test_data_dir;
+ ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
+ test_data_dir = test_data_dir.AppendASCII("extensions");
+ extensions::ChromeTestExtensionLoader loader(browser()->profile());
+ const extensions::Extension* extension =
+ loader.LoadExtension(test_data_dir.AppendASCII("good.crx")).get();
+ ASSERT_TRUE(extension);
+
+ // First, check that navigation succeeds.
+ GURL navigation_url("chrome://extensions-internals");
+ ui_test_utils::NavigateToURL(browser(), navigation_url);
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ ASSERT_TRUE(web_contents);
+ EXPECT_EQ(navigation_url, web_contents->GetLastCommittedURL());
+ EXPECT_FALSE(web_contents->IsCrashed());
+ EXPECT_FALSE(web_contents->GetInterstitialPage());
+
+ // Look for a bit of JSON that has the extension's unique ID.
+ bool has_text = false;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ web_contents,
+ base::StringPrintf("window.domAutomationController.send("
+ "document.body.textContent && "
+ "document.body.textContent.indexOf("
+ "'\"id\": \"%s\"') >= 0);",
+ extension->id().c_str()),
+ &has_text));
+ EXPECT_TRUE(has_text);
+}
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
new file mode 100644
index 00000000000..669c2553a84
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc
@@ -0,0 +1,156 @@
+// 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/extensions/extensions_internals_source.h"
+
+#include <string>
+#include <utility>
+
+#include "base/json/json_writer.h"
+#include "base/logging.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/webui_url_constants.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/browser/browser_thread.h"
+#include "extensions/browser/activity.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/process_manager.h"
+
+namespace {
+
+const char* TypeToString(extensions::Manifest::Type type) {
+ switch (type) {
+ case extensions::Manifest::TYPE_UNKNOWN:
+ return "TYPE_UNKNOWN";
+ case extensions::Manifest::TYPE_EXTENSION:
+ return "TYPE_EXTENSION";
+ case extensions::Manifest::TYPE_THEME:
+ return "TYPE_THEME";
+ case extensions::Manifest::TYPE_USER_SCRIPT:
+ return "TYPE_USER_SCRIPT";
+ case extensions::Manifest::TYPE_HOSTED_APP:
+ return "TYPE_HOSTED_APP";
+ case extensions::Manifest::TYPE_LEGACY_PACKAGED_APP:
+ return "TYPE_LEGACY_PACKAGED_APP";
+ case extensions::Manifest::TYPE_PLATFORM_APP:
+ return "TYPE_PLATFORM_APP";
+ case extensions::Manifest::TYPE_SHARED_MODULE:
+ return "TYPE_SHARED_MODULE";
+ case extensions::Manifest::NUM_LOAD_TYPES:
+ break;
+ }
+ NOTREACHED();
+ return "";
+}
+
+const char* LocationToString(extensions::Manifest::Location loc) {
+ switch (loc) {
+ case extensions::Manifest::INVALID_LOCATION:
+ return "INVALID_LOCATION";
+ case extensions::Manifest::INTERNAL:
+ return "INTERNAL";
+ case extensions::Manifest::EXTERNAL_PREF:
+ return "EXTERNAL_PREF";
+ case extensions::Manifest::EXTERNAL_REGISTRY:
+ return "EXTERNAL_REGISTRY";
+ case extensions::Manifest::UNPACKED:
+ return "UNPACKED";
+ case extensions::Manifest::COMPONENT:
+ return "COMPONENT";
+ case extensions::Manifest::EXTERNAL_PREF_DOWNLOAD:
+ return "EXTERNAL_PREF_DOWNLOAD";
+ case extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD:
+ return "EXTERNAL_POLICY_DOWNLOAD";
+ case extensions::Manifest::COMMAND_LINE:
+ return "COMMAND_LINE";
+ case extensions::Manifest::EXTERNAL_POLICY:
+ return "EXTERNAL_POLICY";
+ case extensions::Manifest::EXTERNAL_COMPONENT:
+ return "EXTERNAL_COMPONENT";
+ case extensions::Manifest::NUM_LOCATIONS:
+ break;
+ }
+ NOTREACHED();
+ return "";
+}
+
+base::Value FormatKeepaliveData(extensions::ProcessManager* process_manager,
+ const extensions::Extension* extension) {
+ base::Value keepalive_data(base::Value::Type::DICTIONARY);
+ keepalive_data.SetKey(
+ "count", base::Value(process_manager->GetLazyKeepaliveCount(extension)));
+ const extensions::ProcessManager::ActivitiesMultiset activities =
+ process_manager->GetLazyKeepaliveActivities(extension);
+ base::Value activities_data(base::Value::Type::LIST);
+ activities_data.GetList().reserve(activities.size());
+ for (const auto& activity : activities) {
+ base::Value activities_entry(base::Value::Type::DICTIONARY);
+ activities_entry.SetKey(
+ "type", base::Value(extensions::Activity::ToString(activity.first)));
+ activities_entry.SetKey("extra_data", base::Value(activity.second));
+ activities_data.GetList().push_back(std::move(activities_entry));
+ }
+ keepalive_data.SetKey("activites", std::move(activities_data));
+ return keepalive_data;
+}
+
+} // namespace
+
+ExtensionsInternalsSource::ExtensionsInternalsSource(Profile* profile)
+ : profile_(profile) {}
+
+ExtensionsInternalsSource::~ExtensionsInternalsSource() = default;
+
+std::string ExtensionsInternalsSource::GetSource() const {
+ return chrome::kChromeUIExtensionsInternalsHost;
+}
+
+std::string ExtensionsInternalsSource::GetMimeType(
+ const std::string& path) const {
+ return "text/plain";
+}
+
+void ExtensionsInternalsSource::StartDataRequest(
+ const std::string& path,
+ const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
+ const content::URLDataSource::GotDataCallback& callback) {
+ std::string json = WriteToString();
+ callback.Run(base::RefCountedString::TakeString(&json));
+}
+
+std::string ExtensionsInternalsSource::WriteToString() const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ std::unique_ptr<extensions::ExtensionSet> extensions =
+ extensions::ExtensionRegistry::Get(profile_)
+ ->GenerateInstalledExtensionsSet();
+ extensions::ProcessManager* process_manager =
+ extensions::ProcessManager::Get(profile_);
+ base::Value data(base::Value::Type::LIST);
+ for (const auto& extension : *extensions) {
+ base::Value extension_data(base::Value::Type::DICTIONARY);
+ extension_data.SetKey("id", base::Value(extension->id()));
+ extension_data.SetKey(
+ "keepalive", FormatKeepaliveData(process_manager, extension.get()));
+ extension_data.SetKey("location",
+ base::Value(LocationToString(extension->location())));
+ extension_data.SetKey("manifest_version",
+ base::Value(extension->manifest_version()));
+ extension_data.SetKey("name", base::Value(extension->name()));
+ extension_data.SetKey("path",
+ base::Value(extension->path().LossyDisplayName()));
+ extension_data.SetKey("type",
+ base::Value(TypeToString(extension->GetType())));
+ extension_data.SetKey("version",
+ base::Value(extension->GetVersionForDisplay()));
+ data.GetList().push_back(std::move(extension_data));
+ }
+
+ std::string json;
+ base::JSONWriter::WriteWithOptions(
+ data, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
+
+ return json;
+}
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h
new file mode 100644
index 00000000000..c848a0a5041
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.h
@@ -0,0 +1,38 @@
+// 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_EXTENSIONS_EXTENSIONS_INTERNALS_SOURCE_H_
+#define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSIONS_INTERNALS_SOURCE_H_
+
+#include "base/macros.h"
+#include "content/public/browser/url_data_source.h"
+
+class Profile;
+
+// A simple data source that returns information about installed
+// extensions for the associated profile.
+class ExtensionsInternalsSource : public content::URLDataSource {
+ public:
+ explicit ExtensionsInternalsSource(Profile* profile);
+ ~ExtensionsInternalsSource() override;
+
+ // content::URLDataSource:
+ std::string GetSource() const override;
+ std::string GetMimeType(const std::string& path) const override;
+ void StartDataRequest(
+ const std::string& path,
+ const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
+ const content::URLDataSource::GotDataCallback& callback) override;
+
+ // Simpler interface to generate string output, without needing to
+ // call StartDataRequest.
+ std::string WriteToString() const;
+
+ 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 77af9957f7b..393653d6692 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -13,6 +13,7 @@
#include "base/timer/elapsed_timer.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/chrome_extension_browser_constants.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/common/pref_names.h"
@@ -23,7 +24,7 @@
#include "chrome/grit/extensions_resources_map.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
-#include "components/google/core/browser/google_util.h"
+#include "components/google/core/common/google_util.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
@@ -32,6 +33,7 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_features.h"
#include "extensions/common/extension_urls.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -128,8 +130,12 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
{"learnMore", IDS_LEARN_MORE},
{"noSearchResults", IDS_SEARCH_NO_RESULTS},
{"ok", IDS_OK},
+ {"save", IDS_SAVE},
{"searchResults", IDS_SEARCH_RESULTS},
+ // Multi-use strings defined in md_extensions_strings.grdp.
+ {"remove", IDS_MD_EXTENSIONS_REMOVE},
+
// Add extension-specific strings.
{"title", IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE},
{"toolbarTitle", IDS_MD_EXTENSIONS_TOOLBAR_TITLE},
@@ -158,13 +164,13 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
{"openChromeWebStore", IDS_MD_EXTENSIONS_SIDEBAR_OPEN_CHROME_WEB_STORE},
{"keyboardShortcuts", IDS_MD_EXTENSIONS_SIDEBAR_KEYBOARD_SHORTCUTS},
{"incognitoInfoWarning", IDS_EXTENSIONS_INCOGNITO_WARNING},
- {"itemHostPermissionsHeading",
- IDS_MD_EXTENSIONS_ITEM_HOST_PERMISSIONS_HEADING},
- {"itemHostAccessOnClick", IDS_MD_EXTENSIONS_HOST_ACCESS_ON_CLICK},
- {"itemHostAccessOnSpecificSites",
+ {"hostPermissionsEdit", IDS_MD_EXTENSIONS_HOST_PERMISSIONS_EDIT},
+ {"hostPermissionsHeading", IDS_MD_EXTENSIONS_ITEM_HOST_PERMISSIONS_HEADING},
+ {"hostAccessOnClick", IDS_MD_EXTENSIONS_HOST_ACCESS_ON_CLICK},
+ {"hostAccessOnSpecificSites",
IDS_MD_EXTENSIONS_HOST_ACCESS_ON_SPECIFIC_SITES},
- {"itemHostAccessOnAllSites", IDS_MD_EXTENSIONS_HOST_ACCESS_ON_ALL_SITES},
- {"itemAllowedHosts", IDS_EXTENSIONS_ITEM_ALLOWED_HOSTS},
+ {"hostAccessOnAllSites", IDS_MD_EXTENSIONS_HOST_ACCESS_ON_ALL_SITES},
+ {"hostAllowedHosts", IDS_EXTENSIONS_ITEM_ALLOWED_HOSTS},
{"itemId", IDS_MD_EXTENSIONS_ITEM_ID},
{"itemInspectViews", IDS_MD_EXTENSIONS_ITEM_INSPECT_VIEWS},
// NOTE: This text reads "<n> more". It's possible that it should be using
@@ -195,7 +201,6 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
{"itemOptions", IDS_MD_EXTENSIONS_ITEM_OPTIONS},
{"itemPermissions", IDS_MD_EXTENSIONS_ITEM_PERMISSIONS},
{"itemPermissionsEmpty", IDS_MD_EXTENSIONS_ITEM_PERMISSIONS_EMPTY},
- {"itemRemove", IDS_MD_EXTENSIONS_ITEM_REMOVE},
{"itemRemoveExtension", IDS_MD_EXTENSIONS_ITEM_REMOVE_EXTENSION},
{"itemSource", IDS_MD_EXTENSIONS_ITEM_SOURCE},
{"itemSourcePolicy", IDS_MD_EXTENSIONS_ITEM_SOURCE_POLICY},
@@ -218,6 +223,11 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
{"loadErrorErrorLabel", IDS_MD_EXTENSIONS_LOAD_ERROR_ERROR_LABEL},
{"loadErrorRetry", IDS_MD_EXTENSIONS_LOAD_ERROR_RETRY},
{"noErrorsToShow", IDS_EXTENSIONS_ERROR_NO_ERRORS_CODE_MESSAGE},
+ {"runtimeHostsDialogInputError",
+ IDS_MD_EXTENSIONS_RUNTIME_HOSTS_DIALOG_INPUT_ERROR},
+ {"runtimeHostsDialogInputLabel",
+ IDS_MD_EXTENSIONS_RUNTIME_HOSTS_DIALOG_INPUT_LABEL},
+ {"runtimeHostsDialogTitle", IDS_MD_EXTENSIONS_RUNTIME_HOSTS_DIALOG_TITLE},
{"packDialogTitle", IDS_MD_EXTENSIONS_PACK_DIALOG_TITLE},
{"packDialogWarningTitle", IDS_MD_EXTENSIONS_PACK_DIALOG_WARNING_TITLE},
{"packDialogErrorTitle", IDS_MD_EXTENSIONS_PACK_DIALOG_ERROR_TITLE},
@@ -298,13 +308,22 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
GURL(extension_urls::GetWebstoreExtensionsCategoryURL()),
g_browser_process->GetApplicationLocale())
.spec()));
+ source->AddString(
+ "hostPermissionsLearnMoreLink",
+ l10n_util::GetStringFUTF16(
+ IDS_MD_EXTENSIONS_HOST_PERMISSIONS_LEARN_MORE,
+ base::ASCIIToUTF16(
+ chrome_extension_constants::kRuntimeHostPermissionsHelpURL)));
source->AddBoolean(kInDevModeKey, in_dev_mode);
source->AddString(kLoadTimeClassesKey, GetLoadTimeClasses(in_dev_mode));
#if BUILDFLAG(OPTIMIZE_WEBUI)
source->AddResourcePath("crisper.js", IDR_MD_EXTENSIONS_CRISPER_JS);
- source->SetDefaultResource(IDR_MD_EXTENSIONS_VULCANIZED_HTML);
+ source->SetDefaultResource(
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2) ?
+ IDR_MD_EXTENSIONS_VULCANIZED_P2_HTML :
+ IDR_MD_EXTENSIONS_VULCANIZED_HTML);
source->UseGzip();
#else
// Add all MD Extensions resources.
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_basic.cc b/chromium/chrome/browser/ui/webui/help/version_updater_basic.cc
index 796d0a5a9f4..93e3f41a76d 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_basic.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_basic.cc
@@ -5,16 +5,15 @@
#include "chrome/browser/ui/webui/help/version_updater_basic.h"
#include "base/strings/string16.h"
-#include "chrome/browser/upgrade_detector.h"
+#include "chrome/browser/upgrade_detector/upgrade_detector.h"
void VersionUpdaterBasic::CheckForUpdate(
const StatusCallback& status_callback,
const PromoteCallback&) {
- if (UpgradeDetector::GetInstance()->notify_upgrade())
- status_callback.Run(NEARLY_UPDATED, 0, false, std::string(), 0,
- base::string16());
- else
- status_callback.Run(DISABLED, 0, false, std::string(), 0, base::string16());
+ const Status status = UpgradeDetector::GetInstance()->notify_upgrade()
+ ? NEARLY_UPDATED
+ : DISABLED;
+ status_callback.Run(status, 0, false, std::string(), 0, base::string16());
}
VersionUpdater* VersionUpdater::Create(content::WebContents* web_contents) {
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
index 587ec32394c..4127290b805 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc
@@ -12,8 +12,7 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
-#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/chromeos/settings/device_settings_service.h"
+#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/fake_update_engine_client.h"
#include "chromeos/dbus/shill_service_client.h"
@@ -61,9 +60,6 @@ class VersionUpdaterCrosTest : public ::testing::Test {
.WillRepeatedly(Return(false));
EXPECT_CALL(*mock_user_manager_, Shutdown()).Times(AtLeast(0));
- DeviceSettingsService::Initialize();
- CrosSettings::Initialize();
-
NetworkHandler::Initialize();
base::RunLoop().RunUntilIdle();
}
@@ -92,9 +88,6 @@ class VersionUpdaterCrosTest : public ::testing::Test {
void TearDown() override {
NetworkHandler::Shutdown();
-
- CrosSettings::Shutdown();
- DeviceSettingsService::Shutdown();
}
content::TestBrowserThreadBundle thread_bundle_;
@@ -103,6 +96,7 @@ class VersionUpdaterCrosTest : public ::testing::Test {
MockUserManager* mock_user_manager_; // Not owned.
user_manager::ScopedUserManager user_manager_enabler_;
+ ScopedCrosSettingsTestHelper cros_settings_test_helper_;
DISALLOW_COPY_AND_ASSIGN(VersionUpdaterCrosTest);
};
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_win.cc b/chromium/chrome/browser/ui/webui/help/version_updater_win.cc
index a09e5751176..f094833c346 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_win.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_win.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/help/version_updater_win.h"
#include "base/memory/weak_ptr.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/win/win_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run/upgrade_util.h"
diff --git a/chromium/chrome/browser/ui/webui/inspect_ui.cc b/chromium/chrome/browser/ui/webui/inspect_ui.cc
index e777221fc77..151d8f14559 100644
--- a/chromium/chrome/browser/ui/webui/inspect_ui.cc
+++ b/chromium/chrome/browser/ui/webui/inspect_ui.cc
@@ -67,7 +67,8 @@ const char kInspectUiNameField[] = "name";
const char kInspectUiUrlField[] = "url";
const char kInspectUiIsAdditionalField[] = "isAdditional";
-void GetUiDevToolsTargets(base::ListValue& targets) {
+base::ListValue GetUiDevToolsTargets() {
+ base::ListValue targets;
for (const auto& client_pair :
ui_devtools::UiDevToolsServer::GetClientNamesAndUrls()) {
auto target_data = std::make_unique<base::DictionaryValue>();
@@ -76,6 +77,7 @@ void GetUiDevToolsTargets(base::ListValue& targets) {
target_data->SetBoolean(kInspectUiIsAdditionalField, true);
targets.Append(std::move(target_data));
}
+ return targets;
}
// InspectMessageHandler --------------------------------------------
@@ -105,7 +107,7 @@ class InspectMessageHandler : public WebUIMessageHandler {
void HandleTCPDiscoveryConfigCommand(const base::ListValue* args);
void HandleOpenNodeFrontendCommand(const base::ListValue* args);
- InspectUI* inspect_ui_;
+ InspectUI* const inspect_ui_;
DISALLOW_COPY_AND_ASSIGN(InspectMessageHandler);
};
@@ -383,8 +385,7 @@ void InspectUI::Inspect(const std::string& source_id,
const std::string& target_id) {
scoped_refptr<DevToolsAgentHost> target = FindTarget(source_id, target_id);
if (target) {
- Profile* profile = Profile::FromBrowserContext(
- web_ui()->GetWebContents()->GetBrowserContext());
+ Profile* profile = Profile::FromWebUI(web_ui());
DevToolsWindow::OpenDevToolsWindow(target, profile);
}
}
@@ -393,8 +394,7 @@ void InspectUI::InspectFallback(const std::string& source_id,
const std::string& target_id) {
scoped_refptr<DevToolsAgentHost> target = FindTarget(source_id, target_id);
if (target) {
- Profile* profile = Profile::FromBrowserContext(
- web_ui()->GetWebContents()->GetBrowserContext());
+ Profile* profile = Profile::FromWebUI(web_ui());
DevToolsWindow::OpenDevToolsWindowWithBundledFrontend(target, profile);
}
}
@@ -490,8 +490,7 @@ void InspectUI::StartListeningNotifications() {
DevToolsTargetsUIHandler::Callback callback =
base::Bind(&InspectUI::PopulateTargets, base::Unretained(this));
- base::ListValue additional_targets;
- GetUiDevToolsTargets(additional_targets);
+ base::ListValue additional_targets = GetUiDevToolsTargets();
PopulateAdditionalTargets(additional_targets);
AddTargetUIHandler(
diff --git a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
index 5fbf984c00f..f539aa124a9 100644
--- a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
+++ b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
@@ -271,15 +271,18 @@ safe_browsing::SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage(
if (net::GetValueForKeyInQuery(web_contents->GetURL(),
"type",
&type_param)) {
- // TODO(mattm): add param for SB_THREAT_TYPE_URL_UNWANTED.
if (type_param == "malware") {
threat_type = safe_browsing::SB_THREAT_TYPE_URL_MALWARE;
} else if (type_param == "phishing") {
threat_type = safe_browsing::SB_THREAT_TYPE_URL_PHISHING;
+ } else if (type_param == "unwanted") {
+ threat_type = safe_browsing::SB_THREAT_TYPE_URL_UNWANTED;
} else if (type_param == "clientside_malware") {
threat_type = safe_browsing::SB_THREAT_TYPE_URL_CLIENT_SIDE_MALWARE;
} else if (type_param == "clientside_phishing") {
threat_type = safe_browsing::SB_THREAT_TYPE_URL_CLIENT_SIDE_PHISHING;
+ } else if (type_param == "billing") {
+ threat_type = safe_browsing::SB_THREAT_TYPE_BILLING;
}
}
safe_browsing::SafeBrowsingBlockingPage::UnsafeResource resource;
@@ -325,6 +328,8 @@ TestSafeBrowsingBlockingPageQuiet* CreateSafeBrowsingQuietBlockingPage(
threat_type = safe_browsing::SB_THREAT_TYPE_URL_MALWARE;
} else if (type_param == "phishing") {
threat_type = safe_browsing::SB_THREAT_TYPE_URL_PHISHING;
+ } else if (type_param == "unwanted") {
+ threat_type = safe_browsing::SB_THREAT_TYPE_URL_UNWANTED;
} else if (type_param == "giant") {
threat_type = safe_browsing::SB_THREAT_TYPE_URL_MALWARE;
is_giant_webview = true;
@@ -403,7 +408,8 @@ CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage(
InterstitialUI::InterstitialUI(content::WebUI* web_ui)
: WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
- content::URLDataSource::Add(profile, new InterstitialHTMLSource());
+ content::URLDataSource::Add(profile,
+ std::make_unique<InterstitialHTMLSource>());
}
InterstitialUI::~InterstitialUI() {
diff --git a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc
index cfda3105c3b..22fdd471443 100644
--- a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc
@@ -101,6 +101,11 @@ IN_PROC_BROWSER_TEST_F(InterstitialUITest, PhishingInterstitial) {
"Security error");
}
+IN_PROC_BROWSER_TEST_F(InterstitialUITest, UnwantedSoftwareInterstitial) {
+ TestInterstitial(GURL("chrome://interstitials/safebrowsing?type=unwanted"),
+ "Security error");
+}
+
IN_PROC_BROWSER_TEST_F(InterstitialUITest, MalwareInterstitialQuiet) {
TestInterstitial(
GURL("chrome://interstitials/quietsafebrowsing?type=malware"),
@@ -113,6 +118,12 @@ IN_PROC_BROWSER_TEST_F(InterstitialUITest, PhishingInterstitialQuiet) {
"Security error");
}
+IN_PROC_BROWSER_TEST_F(InterstitialUITest, UnwantedSoftwareInterstitialQuiet) {
+ TestInterstitial(
+ GURL("chrome://interstitials/quietsafebrowsing?type=unwanted"),
+ "Security error");
+}
+
IN_PROC_BROWSER_TEST_F(InterstitialUITest, ClientsideMalwareInterstitial) {
TestInterstitial(
GURL("chrome://interstitials/safebrowsing?type=clientside_malware"),
@@ -125,6 +136,11 @@ IN_PROC_BROWSER_TEST_F(InterstitialUITest, ClientsidePhishingInterstitial) {
"Security error");
}
+IN_PROC_BROWSER_TEST_F(InterstitialUITest, BillingInterstitial) {
+ TestInterstitial(GURL("chrome://interstitials/safebrowsing?type=billing"),
+ "Security error");
+}
+
IN_PROC_BROWSER_TEST_F(InterstitialUITest, CaptivePortalInterstitial) {
TestInterstitial(GURL("chrome://interstitials/captiveportal"),
"Connect to network");
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/OWNERS b/chromium/chrome/browser/ui/webui/interventions_internals/OWNERS
index 6340a5dc2a9..ecb8556d61d 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/interventions_internals/OWNERS
@@ -4,4 +4,4 @@ tbansal@chromium.org
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-# COMPONENT: UI>Browser>Previews
+# COMPONENT: Blink>Previews
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc
index 7acc8d01890..ae7afceea0e 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc
@@ -12,12 +12,13 @@
#include "base/metrics/field_trial_params.h"
#include "base/time/time.h"
#include "build/build_config.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/flag_descriptions.h"
-#include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h"
#include "chrome/common/chrome_switches.h"
#include "components/previews/core/previews_experiments.h"
#include "components/previews/core/previews_switches.h"
#include "net/nqe/network_quality_estimator_params.h"
+#include "services/network/public/cpp/network_quality_tracker.h"
#include "services/network/public/cpp/network_switches.h"
namespace {
@@ -99,11 +100,9 @@ std::string GetEnabledStateForSwitch(const std::string& switch_name) {
InterventionsInternalsPageHandler::InterventionsInternalsPageHandler(
mojom::InterventionsInternalsPageHandlerRequest request,
- previews::PreviewsUIService* previews_ui_service,
- UINetworkQualityEstimatorService* ui_nqe_service)
+ previews::PreviewsUIService* previews_ui_service)
: binding_(this, std::move(request)),
previews_ui_service_(previews_ui_service),
- ui_nqe_service_(ui_nqe_service),
current_estimated_ect_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN) {
logger_ = previews_ui_service_->previews_logger();
DCHECK(logger_);
@@ -112,7 +111,8 @@ InterventionsInternalsPageHandler::InterventionsInternalsPageHandler(
InterventionsInternalsPageHandler::~InterventionsInternalsPageHandler() {
DCHECK(logger_);
logger_->RemoveObserver(this);
- ui_nqe_service_->RemoveEffectiveConnectionTypeObserver(this);
+ g_browser_process->network_quality_tracker()
+ ->RemoveEffectiveConnectionTypeObserver(this);
}
void InterventionsInternalsPageHandler::SetClientPage(
@@ -120,7 +120,8 @@ void InterventionsInternalsPageHandler::SetClientPage(
page_ = std::move(page);
DCHECK(page_);
logger_->AddAndNotifyObserver(this);
- ui_nqe_service_->AddEffectiveConnectionTypeObserver(this);
+ g_browser_process->network_quality_tracker()
+ ->AddEffectiveConnectionTypeObserver(this);
}
void InterventionsInternalsPageHandler::OnEffectiveConnectionTypeChanged(
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h
index 55c20dcd9a1..49a50b659d5 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.h
@@ -15,19 +15,16 @@
#include "components/previews/core/previews_logger_observer.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "net/nqe/effective_connection_type.h"
-#include "net/nqe/effective_connection_type_observer.h"
-
-class UINetworkQualityEstimatorService;
+#include "services/network/public/cpp/network_quality_tracker.h"
class InterventionsInternalsPageHandler
: public previews::PreviewsLoggerObserver,
- public net::EffectiveConnectionTypeObserver,
+ public network::NetworkQualityTracker::EffectiveConnectionTypeObserver,
public mojom::InterventionsInternalsPageHandler {
public:
InterventionsInternalsPageHandler(
mojom::InterventionsInternalsPageHandlerRequest request,
- previews::PreviewsUIService* previews_ui_service,
- UINetworkQualityEstimatorService* ui_nqe_service);
+ previews::PreviewsUIService* previews_ui_service);
~InterventionsInternalsPageHandler() override;
// mojom::InterventionsInternalsPageHandler:
@@ -47,7 +44,7 @@ class InterventionsInternalsPageHandler
void OnLastObserverRemove() override;
private:
- // net::EffectiveConnectionTypeObserver:
+ // network::NetworkQualityTracker::EffectiveConnectionTypeObserver:
void OnEffectiveConnectionTypeChanged(
net::EffectiveConnectionType type) override;
@@ -61,10 +58,6 @@ class InterventionsInternalsPageHandler
// guaranteed to outlive |this|.
previews::PreviewsUIService* previews_ui_service_;
- // A pointer to the UINetworkQualityEsitmatorService, guaranteed to outlive
- // |this|.
- UINetworkQualityEstimatorService* ui_nqe_service_;
-
// The current estimated effective connection type.
net::EffectiveConnectionType current_estimated_ect_;
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc
index a1312af72e2..46c92a66784 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc
@@ -22,7 +22,6 @@
#include "base/time/default_clock.h"
#include "build/build_config.h"
#include "chrome/browser/flag_descriptions.h"
-#include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/interventions_internals/interventions_internals.mojom.h"
#include "chrome/common/chrome_constants.h"
@@ -191,27 +190,6 @@ class TestPreviewsLogger : public previews::PreviewsLogger {
bool remove_is_called_;
};
-// Mock class to test interaction between PageHandler and the
-// UINetworkQualityEstimatorService.
-class TestUINetworkQualityEstimatorService
- : public UINetworkQualityEstimatorService {
- public:
- explicit TestUINetworkQualityEstimatorService(Profile* profile)
- : UINetworkQualityEstimatorService(profile), remove_is_called_(false) {}
-
- // UINetworkQualityEstimatorService:
- void RemoveEffectiveConnectionTypeObserver(
- net::EffectiveConnectionTypeObserver* observer) override {
- remove_is_called_ = true;
- }
-
- bool RemovedObserverIsCalled() const { return remove_is_called_; }
-
- private:
- // Check if the observer removed itself from the observer list.
- bool remove_is_called_;
-};
-
// A dummy class to setup PreviewsUIService.
class TestPreviewsDeciderImpl : public previews::PreviewsDeciderImpl {
public:
@@ -276,16 +254,11 @@ class InterventionsInternalsPageHandlerTest : public testing::Test {
std::make_unique<TestPreviewsUIService>(&io_data, std::move(logger));
ASSERT_TRUE(profile_manager_.SetUp());
- TestingProfile* test_profile =
- profile_manager_.CreateTestingProfile(chrome::kInitialProfile);
- ui_nqe_service_ =
- std::make_unique<TestUINetworkQualityEstimatorService>(test_profile);
mojom::InterventionsInternalsPageHandlerPtr page_handler_ptr;
handler_request_ = mojo::MakeRequest(&page_handler_ptr);
page_handler_ = std::make_unique<InterventionsInternalsPageHandler>(
- std::move(handler_request_), previews_ui_service_.get(),
- ui_nqe_service_.get());
+ std::move(handler_request_), previews_ui_service_.get());
mojom::InterventionsInternalsPagePtr page_ptr;
page_request_ = mojo::MakeRequest(&page_ptr);
@@ -306,7 +279,6 @@ class InterventionsInternalsPageHandlerTest : public testing::Test {
TestPreviewsLogger* logger_;
std::unique_ptr<TestPreviewsUIService> previews_ui_service_;
- std::unique_ptr<TestUINetworkQualityEstimatorService> ui_nqe_service_;
// InterventionsInternalPageHandler's variables.
mojom::InterventionsInternalsPageHandlerRequest handler_request_;
@@ -650,6 +622,13 @@ TEST_F(InterventionsInternalsPageHandlerTest, OnNewMessageLogAddedPostToPage) {
base::RunLoop().RunUntilIdle();
mojom::MessageLogPtr* actual = page_->message();
+ // Discard any messages generated by network quality tracker.
+ while ((*actual)->type == "ECT Changed") {
+ page_handler_->OnNewMessageLogAdded(message);
+ base::RunLoop().RunUntilIdle();
+
+ actual = page_->message();
+ }
EXPECT_EQ(message.event_type, (*actual)->type);
EXPECT_EQ(message.event_description, (*actual)->description);
EXPECT_EQ(message.url, (*actual)->url);
@@ -661,10 +640,8 @@ TEST_F(InterventionsInternalsPageHandlerTest, OnNewMessageLogAddedPostToPage) {
TEST_F(InterventionsInternalsPageHandlerTest, ObserverIsRemovedWhenDestroyed) {
EXPECT_FALSE(logger_->RemovedObserverIsCalled());
- EXPECT_FALSE(ui_nqe_service_->RemovedObserverIsCalled());
page_handler_.reset();
EXPECT_TRUE(logger_->RemovedObserverIsCalled());
- EXPECT_TRUE(ui_nqe_service_->RemovedObserverIsCalled());
}
TEST_F(InterventionsInternalsPageHandlerTest, OnNewBlacklistedHostPostToPage) {
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc
index 434ebf833c3..70172891639 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc
@@ -8,8 +8,6 @@
#include <utility>
#include <vector>
-#include "chrome/browser/net/nqe/ui_network_quality_estimator_service.h"
-#include "chrome/browser/net/nqe/ui_network_quality_estimator_service_factory.h"
#include "chrome/browser/previews/previews_service.h"
#include "chrome/browser/previews/previews_service_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -58,8 +56,6 @@ InterventionsInternalsUI::InterventionsInternalsUI(content::WebUI* web_ui)
}
content::WebUIDataSource::Add(profile, GetSource());
previews_ui_service_ = previews_service->previews_ui_service();
- ui_nqe_service_ =
- UINetworkQualityEstimatorServiceFactory::GetForProfile(profile);
AddHandlerToRegistry(base::BindRepeating(
&InterventionsInternalsUI::BindInterventionsInternalsPageHandler,
base::Unretained(this)));
@@ -70,7 +66,6 @@ InterventionsInternalsUI::~InterventionsInternalsUI() {}
void InterventionsInternalsUI::BindInterventionsInternalsPageHandler(
mojom::InterventionsInternalsPageHandlerRequest request) {
DCHECK(previews_ui_service_);
- DCHECK(ui_nqe_service_);
page_handler_.reset(new InterventionsInternalsPageHandler(
- std::move(request), previews_ui_service_, ui_nqe_service_));
+ std::move(request), previews_ui_service_));
}
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h
index 28a0150d12e..b284a9d8131 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h
@@ -14,8 +14,6 @@ namespace previews {
class PreviewsUIService;
} // namespace previews
-class UINetworkQualityEstimatorService;
-
// The WebUI for chrome://interventions-internals.
class InterventionsInternalsUI : public ui::MojoWebUIController {
public:
@@ -29,10 +27,6 @@ class InterventionsInternalsUI : public ui::MojoWebUIController {
// The PreviewsUIService associated with this UI.
previews::PreviewsUIService* previews_ui_service_;
- // The network quality estimator service for getting the estimate effective
- // conntection type.
- UINetworkQualityEstimatorService* ui_nqe_service_;
-
std::unique_ptr<InterventionsInternalsPageHandler> page_handler_;
DISALLOW_COPY_AND_ASSIGN(InterventionsInternalsUI);
diff --git a/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc b/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc
index 388d20b037c..ef2380b3429 100644
--- a/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc
@@ -7,7 +7,7 @@
#include <utility>
#include "base/bind.h"
-#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
+#include "chrome/browser/invalidation/deprecated_profile_invalidation_provider_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/invalidation/impl/invalidation_logger.h"
#include "components/invalidation/impl/profile_invalidation_provider.h"
@@ -44,7 +44,7 @@ void InvalidationsMessageHandler::RegisterMessages() {
void InvalidationsMessageHandler::UIReady(const base::ListValue* args) {
invalidation::ProfileInvalidationProvider* invalidation_provider =
- invalidation::ProfileInvalidationProviderFactory::GetForProfile(
+ invalidation::DeprecatedProfileInvalidationProviderFactory::GetForProfile(
Profile::FromWebUI(web_ui()));
if (invalidation_provider) {
logger_ = invalidation_provider->GetInvalidationService()->
@@ -58,7 +58,7 @@ void InvalidationsMessageHandler::UIReady(const base::ListValue* args) {
void InvalidationsMessageHandler::HandleRequestDetailedStatus(
const base::ListValue* args) {
invalidation::ProfileInvalidationProvider* invalidation_provider =
- invalidation::ProfileInvalidationProviderFactory::GetForProfile(
+ invalidation::DeprecatedProfileInvalidationProviderFactory::GetForProfile(
Profile::FromWebUI(web_ui()));
if (invalidation_provider) {
invalidation_provider->GetInvalidationService()->RequestDetailedStatus(
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 2488a4195d1..5d79f75d4cb 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
@@ -15,6 +15,7 @@
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
+#include "base/test/bind_test_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/local_discovery/test_service_discovery_client.h"
@@ -35,9 +36,6 @@
#include "chrome/test/base/web_ui_browser_test.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/http/http_status_code.h"
-#include "net/url_request/test_url_fetcher_factory.h"
-#include "net/url_request/url_request_status.h"
-#include "net/url_request/url_request_test_util.h"
#include "services/identity/public/cpp/identity_test_utils.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
@@ -49,18 +47,14 @@
#include "components/prefs/pref_service.h"
#endif
-using testing::InvokeWithoutArgs;
-using testing::Return;
+using testing::AnyNumber;
using testing::AtLeast;
-using testing::DoDefault;
using testing::DoAll;
+using testing::DoDefault;
using testing::InSequence;
-using testing::StrictMock;
-using testing::AnyNumber;
-
using testing::InvokeWithoutArgs;
using testing::Return;
-using testing::AtLeast;
+using testing::StrictMock;
namespace local_discovery {
@@ -324,43 +318,15 @@ class TestMessageLoopCondition {
DISALLOW_COPY_AND_ASSIGN(TestMessageLoopCondition);
};
-class MockableFakeURLFetcherCreator {
- public:
- MockableFakeURLFetcherCreator() {
- }
-
- ~MockableFakeURLFetcherCreator() {
- }
-
- MOCK_METHOD1(OnCreateFakeURLFetcher, void(const std::string& url));
-
- std::unique_ptr<net::FakeURLFetcher> CreateFakeURLFetcher(
- const GURL& url,
- net::URLFetcherDelegate* delegate,
- const std::string& response_data,
- net::HttpStatusCode response_code,
- net::URLRequestStatus::Status status) {
- OnCreateFakeURLFetcher(url.spec());
- return std::unique_ptr<net::FakeURLFetcher>(new net::FakeURLFetcher(
- url, delegate, response_data, response_code, status));
- }
-
- net::FakeURLFetcherFactory::FakeURLFetcherCreator callback() {
- return base::Bind(&MockableFakeURLFetcherCreator::CreateFakeURLFetcher,
- base::Unretained(this));
- }
-};
-
class LocalDiscoveryUITest : public WebUIBrowserTest {
public:
LocalDiscoveryUITest()
: test_shared_loader_factory_(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&test_url_loader_factory_)),
- fake_fetcher_factory_(&fetcher_impl_factory_,
- fake_url_fetcher_creator_.callback()) {}
- ~LocalDiscoveryUITest() override {
- }
+ set_url_loader_factory_(test_shared_loader_factory_) {}
+
+ ~LocalDiscoveryUITest() override { test_shared_loader_factory_->Detach(); }
void SetUp() override {
// We need to stub out DualMediaSinkService here, because the profile setup
@@ -389,56 +355,16 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
GaiaUrls::GetInstance()->oauth2_token_url().spec(), kResponseGaiaToken);
test_url_loader_factory_.AddResponse(
GaiaUrls::GetInstance()->oauth_user_info_url().spec(), kResponseGaiaId);
+ test_url_loader_factory_.AddResponse(kURLInfo, kResponseInfo);
+ test_url_loader_factory_.AddResponse(kURLRegisterStart,
+ kResponseRegisterStart);
+ test_url_loader_factory_.AddResponse(kURLRegisterClaimToken,
+ kResponseRegisterClaimTokenNoConfirm);
+ test_url_loader_factory_.AddResponse(kURLCloudPrintConfirm,
+ kResponseCloudPrintConfirm);
+ test_url_loader_factory_.AddResponse(kURLRegisterComplete,
+ kResponseRegisterComplete);
- fake_fetcher_factory().SetFakeResponse(
- GURL(kURLInfo),
- kResponseInfo,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- fake_fetcher_factory().SetFakeResponse(
- GURL(kURLRegisterStart),
- kResponseRegisterStart,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- fake_fetcher_factory().SetFakeResponse(
- GURL(kURLRegisterClaimToken),
- kResponseRegisterClaimTokenNoConfirm,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- fake_fetcher_factory().SetFakeResponse(
- GURL(kURLCloudPrintConfirm),
- kResponseCloudPrintConfirm,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- fake_fetcher_factory().SetFakeResponse(
- GURL(kURLRegisterComplete),
- kResponseRegisterComplete,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- fake_fetcher_factory().SetFakeResponse(
- GaiaUrls::GetInstance()->oauth2_token_url(),
- kResponseGaiaToken,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
- GaiaUrls::GetInstance()->oauth2_token_url().spec()))
- .Times(AnyNumber());
-
- fake_fetcher_factory().SetFakeResponse(
- GaiaUrls::GetInstance()->oauth_user_info_url(),
- kResponseGaiaId,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
- GaiaUrls::GetInstance()->oauth_user_info_url().spec()))
- .Times(AnyNumber());
identity::MakePrimaryAccountAvailable(
SigninManagerFactory::GetForProfile(browser()->profile()),
ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()),
@@ -490,25 +416,18 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
return condition_devices_listed_;
}
- net::FakeURLFetcherFactory& fake_fetcher_factory() {
- return fake_fetcher_factory_;
- }
-
- MockableFakeURLFetcherCreator& fake_url_fetcher_creator() {
- return fake_url_fetcher_creator_;
+ network::TestURLLoaderFactory* test_url_loader_factory() {
+ return &test_url_loader_factory_;
}
private:
scoped_refptr<TestServiceDiscoveryClient> test_service_discovery_client_;
TestMessageLoopCondition condition_devices_listed_;
-
network::TestURLLoaderFactory test_url_loader_factory_;
scoped_refptr<network::WeakWrapperSharedURLLoaderFactory>
test_shared_loader_factory_;
-
- net::URLFetcherImplFactory fetcher_impl_factory_;
- StrictMock<MockableFakeURLFetcherCreator> fake_url_fetcher_creator_;
- net::FakeURLFetcherFactory fake_fetcher_factory_;
+ local_discovery::LocalDiscoveryUIHandler::SetURLLoaderFactoryForTesting
+ set_url_loader_factory_;
DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUITest);
};
@@ -540,10 +459,7 @@ IN_PROC_BROWSER_TEST_F(LocalDiscoveryUITest, AddRowTest) {
EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("checkNoDevices"));
}
-// Flaky: http://crbug.com/660669.
IN_PROC_BROWSER_TEST_F(LocalDiscoveryUITest, RegisterTest) {
- TestMessageLoopCondition condition_token_claimed;
-
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDevicesURL));
condition_devices_listed().Wait();
@@ -557,49 +473,45 @@ IN_PROC_BROWSER_TEST_F(LocalDiscoveryUITest, RegisterTest) {
EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("registerShowOverlay"));
{
- InSequence s;
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(kURLInfo));
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
- kURLRegisterStart));
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
- kURLRegisterClaimToken))
- .WillOnce(InvokeWithoutArgs(&condition_token_claimed,
- &TestMessageLoopCondition::Signal));
+ base::RunLoop run_loop;
+ std::set<GURL> served_urls;
+ test_url_loader_factory()->SetInterceptor(base::BindLambdaForTesting(
+ [&](const network::ResourceRequest& resource) {
+ served_urls.insert(resource.url);
+ if (resource.url == GURL(kURLRegisterClaimToken))
+ run_loop.Quit();
+ }));
+ EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("registerBegin"));
+ run_loop.Run();
+ EXPECT_TRUE(base::ContainsKey(served_urls, GURL(kURLInfo)));
+ EXPECT_TRUE(base::ContainsKey(served_urls, GURL(kURLRegisterStart)));
+ EXPECT_TRUE(base::ContainsKey(served_urls, GURL(kURLRegisterClaimToken)));
+ test_url_loader_factory()->SetInterceptor(base::NullCallback());
}
- EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("registerBegin"));
-
- condition_token_claimed.Wait();
-
EXPECT_TRUE(WebUIBrowserTest::RunJavascriptTest("expectPageAdding1"));
- fake_fetcher_factory().SetFakeResponse(
- GURL(kURLRegisterClaimToken),
- kResponseRegisterClaimTokenConfirm,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
-
- fake_fetcher_factory().SetFakeResponse(
- GURL(kURLInfo),
- kResponseInfoWithID,
- net::HTTP_OK,
- net::URLRequestStatus::SUCCESS);
+ test_url_loader_factory()->AddResponse(kURLRegisterClaimToken,
+ kResponseRegisterClaimTokenConfirm);
+ test_url_loader_factory()->AddResponse(kURLInfo, kResponseInfoWithID);
{
- InSequence s;
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
- kURLRegisterClaimToken));
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
- kURLCloudPrintConfirm));
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
- kURLRegisterComplete));
- EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(kURLInfo))
- .WillOnce(InvokeWithoutArgs(&condition_token_claimed,
- &TestMessageLoopCondition::Signal));
+ base::RunLoop run_loop;
+ std::set<GURL> served_urls;
+ test_url_loader_factory()->SetInterceptor(base::BindLambdaForTesting(
+ [&](const network::ResourceRequest& resource) {
+ served_urls.insert(resource.url);
+ if (resource.url == GURL(kURLInfo))
+ run_loop.Quit();
+ }));
+ run_loop.Run();
+ EXPECT_TRUE(base::ContainsKey(served_urls, GURL(kURLRegisterClaimToken)));
+ EXPECT_TRUE(base::ContainsKey(served_urls, GURL(kURLCloudPrintConfirm)));
+ EXPECT_TRUE(base::ContainsKey(served_urls, GURL(kURLRegisterComplete)));
+ EXPECT_TRUE(base::ContainsKey(served_urls, GURL(kURLInfo)));
+ test_url_loader_factory()->SetInterceptor(base::NullCallback());
}
- condition_token_claimed.Wait();
-
test_service_discovery_client()->SimulateReceive(
kAnnouncePacketRegistered, sizeof(kAnnouncePacketRegistered));
diff --git a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc
index 1ad7ece153e..1fa7b8a58cb 100644
--- a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/metrics/user_metrics.h"
+#include "base/no_destructor.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -30,6 +31,7 @@
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
#include "printing/buildflags/buildflags.h"
+#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
@@ -92,8 +94,27 @@ void ReadDevicesList(const CloudPrintPrinterList::DeviceList& devices,
}
}
+scoped_refptr<network::SharedURLLoaderFactory>&
+GetURLLoaderFactoryForTesting() {
+ static base::NoDestructor<scoped_refptr<network::SharedURLLoaderFactory>>
+ instance;
+ return *instance;
+}
+
} // namespace
+LocalDiscoveryUIHandler::SetURLLoaderFactoryForTesting::
+ SetURLLoaderFactoryForTesting(
+ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {
+ DCHECK(!GetURLLoaderFactoryForTesting());
+ GetURLLoaderFactoryForTesting() = url_loader_factory;
+}
+
+LocalDiscoveryUIHandler::SetURLLoaderFactoryForTesting::
+ ~SetURLLoaderFactoryForTesting() {
+ GetURLLoaderFactoryForTesting() = nullptr;
+}
+
LocalDiscoveryUIHandler::LocalDiscoveryUIHandler()
: is_visible_(false),
failed_list_count_(0),
@@ -168,9 +189,15 @@ void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) {
privet_lister_.reset(
new cloud_print::PrivetDeviceListerImpl(service_discovery_client_.get(),
this));
+
+ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory =
+ GetURLLoaderFactoryForTesting();
+ if (!url_loader_factory)
+ url_loader_factory = profile->GetURLLoaderFactory();
+
privet_http_factory_ =
cloud_print::PrivetHTTPAsynchronousFactory::CreateInstance(
- profile->GetRequestContext());
+ url_loader_factory);
identity::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile);
@@ -516,7 +543,12 @@ std::unique_ptr<GCDApiFlow> LocalDiscoveryUIHandler::CreateApiFlow() {
if (!(identity_manager && identity_manager->HasPrimaryAccount()))
return std::unique_ptr<GCDApiFlow>();
- return GCDApiFlow::Create(profile->GetRequestContext(), identity_manager);
+ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory =
+ GetURLLoaderFactoryForTesting();
+ if (!url_loader_factory)
+ url_loader_factory = profile->GetURLLoaderFactory();
+
+ return GCDApiFlow::Create(url_loader_factory, identity_manager);
}
bool LocalDiscoveryUIHandler::IsUserSupervisedOrOffTheRecord() {
diff --git a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
index cca4463919c..440c6465cce 100644
--- a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
@@ -45,6 +46,17 @@ class LocalDiscoveryUIHandler
public cloud_print::CloudPrintPrinterList::Delegate,
public identity::IdentityManager::Observer {
public:
+ // Class used to set a URLLoaderFactory that should be used when making
+ // network requests. Create one instance of this object with the
+ // URLLoaderFactory to use. It's automatically unregistered when the object is
+ // destroyed.
+ class SetURLLoaderFactoryForTesting final {
+ public:
+ explicit SetURLLoaderFactoryForTesting(
+ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
+ ~SetURLLoaderFactoryForTesting();
+ };
+
LocalDiscoveryUIHandler();
~LocalDiscoveryUIHandler() override;
diff --git a/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc b/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc
index 06195fc97ab..403a5f4ac3c 100644
--- a/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc
+++ b/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc
@@ -22,6 +22,7 @@
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_features.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -135,7 +136,10 @@ content::WebUIDataSource* CreateMdBookmarksUIHTMLSource(Profile* profile) {
IDR_MD_BOOKMARKS_IMAGES_FOLDER_SVG);
#if BUILDFLAG(OPTIMIZE_WEBUI)
source->AddResourcePath("crisper.js", IDR_MD_BOOKMARKS_CRISPER_JS);
- source->SetDefaultResource(IDR_MD_BOOKMARKS_VULCANIZED_HTML);
+ source->SetDefaultResource(
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2)
+ ? IDR_MD_BOOKMARKS_VULCANIZED_P2_HTML
+ : IDR_MD_BOOKMARKS_VULCANIZED_HTML);
source->UseGzip({"images/folder_open.svg", "images/folder.svg"});
#else
source->AddResourcePath("actions.html", IDR_MD_BOOKMARKS_ACTIONS_HTML);
diff --git a/chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc b/chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc
index f7464ef1f8b..7d7ddfca942 100644
--- a/chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc
+++ b/chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc
@@ -210,7 +210,7 @@ DownloadsListTracker::CreateDownloadItemValue(
file_value->SetString("id", base::NumberToString(download_item->GetId()));
base::FilePath download_path(download_item->GetTargetFilePath());
- file_value->Set("file_path", base::CreateFilePathValue(download_path));
+ file_value->SetKey("file_path", base::CreateFilePathValue(download_path));
file_value->SetString("file_url",
net::FilePathToFileURL(download_path).spec());
@@ -227,12 +227,12 @@ DownloadsListTracker::CreateDownloadItemValue(
// language. This won't work if the extension was uninstalled, so the name
// might be the wrong language.
bool include_disabled = true;
+ auto* profile = Profile::FromBrowserContext(
+ content::DownloadItemUtils::GetBrowserContext(download_item));
+ auto* service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
const extensions::Extension* extension =
- extensions::ExtensionSystem::Get(
- Profile::FromBrowserContext(
- content::DownloadItemUtils::GetBrowserContext(download_item)))
- ->extension_service()
- ->GetExtensionById(by_ext->id(), include_disabled);
+ service->GetExtensionById(by_ext->id(), include_disabled);
if (extension)
by_ext_name = extension->name();
}
diff --git a/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc b/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc
index e3938ed4ed6..878c3ca58db 100644
--- a/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc
+++ b/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc
@@ -30,6 +30,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_features.h"
#include "ui/base/resource/resource_bundle.h"
using content::BrowserContext;
@@ -53,7 +54,6 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
source->AddLocalizedString("moreActions", IDS_DOWNLOAD_MORE_ACTIONS);
source->AddLocalizedString("search", IDS_MD_DOWNLOAD_SEARCH);
-
// No results message that shows instead of the downloads list.
source->AddLocalizedString("noDownloads", IDS_MD_DOWNLOAD_NO_DOWNLOADS);
source->AddLocalizedString("noSearchResults", IDS_SEARCH_NO_RESULTS);
@@ -81,16 +81,14 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
source->AddLocalizedString("controlShowInFolder", IDS_DOWNLOAD_LINK_SHOW);
source->AddLocalizedString("controlCancel", IDS_DOWNLOAD_LINK_CANCEL);
source->AddLocalizedString("controlResume", IDS_DOWNLOAD_LINK_RESUME);
- source->AddLocalizedString("controlRemoveFromList",
- IDS_DOWNLOAD_LINK_REMOVE);
+ source->AddLocalizedString("controlRemoveFromList", IDS_DOWNLOAD_LINK_REMOVE);
source->AddLocalizedString("controlRetry", IDS_MD_DOWNLOAD_LINK_RETRY);
- source->AddLocalizedString("controlledByUrl",
- IDS_DOWNLOAD_BY_EXTENSION_URL);
+ source->AddLocalizedString("controlledByUrl", IDS_DOWNLOAD_BY_EXTENSION_URL);
PrefService* prefs = profile->GetPrefs();
source->AddBoolean("allowDeletingHistory",
prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory) &&
- !profile->IsSupervised());
+ !profile->IsSupervised());
source->AddLocalizedString("inIncognito", IDS_DOWNLOAD_IN_INCOGNITO);
@@ -108,7 +106,10 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
"2x/incognito_marker.png", "2x/no_downloads.png"});
source->AddResourcePath("crisper.js", IDR_MD_DOWNLOADS_CRISPER_JS);
- source->SetDefaultResource(IDR_MD_DOWNLOADS_VULCANIZED_HTML);
+ source->SetDefaultResource(
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2)
+ ? IDR_MD_DOWNLOADS_VULCANIZED_P2_HTML
+ : IDR_MD_DOWNLOADS_VULCANIZED_HTML);
#else
source->AddResourcePath("browser_proxy.html",
IDR_MD_DOWNLOADS_BROWSER_PROXY_HTML);
@@ -156,8 +157,7 @@ MdDownloadsUI::MdDownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
// Set up the chrome://downloads/ source.
content::WebUIDataSource* source = CreateDownloadsUIHTMLSource(profile);
content::WebUIDataSource::Add(profile, source);
- ThemeSource* theme = new ThemeSource(profile);
- content::URLDataSource::Add(profile, theme);
+ content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
}
// static
diff --git a/chromium/chrome/browser/ui/webui/md_history_ui.cc b/chromium/chrome/browser/ui/webui/md_history_ui.cc
index de8af30aaad..46df9d42ef5 100644
--- a/chromium/chrome/browser/ui/webui/md_history_ui.cc
+++ b/chromium/chrome/browser/ui/webui/md_history_ui.cc
@@ -30,6 +30,7 @@
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_features.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "ui/base/l10n/l10n_util.h"
@@ -174,12 +175,16 @@ content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile,
source->UseGzip(exclude_from_gzip);
#if BUILDFLAG(OPTIMIZE_WEBUI)
+ const bool use_polymer_2 =
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2);
source->AddResourcePath("app.html",
- IDR_MD_HISTORY_APP_VULCANIZED_HTML);
- source->AddResourcePath("app.crisper.js",
- IDR_MD_HISTORY_APP_CRISPER_JS);
+ use_polymer_2 ? IDR_MD_HISTORY_APP_VULCANIZED_P2_HTML
+ : IDR_MD_HISTORY_APP_VULCANIZED_HTML);
+ source->AddResourcePath("app.crisper.js", IDR_MD_HISTORY_APP_CRISPER_JS);
source->AddResourcePath("lazy_load.html",
- IDR_MD_HISTORY_LAZY_LOAD_VULCANIZED_HTML);
+ use_polymer_2
+ ? IDR_MD_HISTORY_LAZY_LOAD_VULCANIZED_P2_HTML
+ : IDR_MD_HISTORY_LAZY_LOAD_VULCANIZED_HTML);
source->AddResourcePath("lazy_load.crisper.js",
IDR_MD_HISTORY_LAZY_LOAD_CRISPER_JS);
#endif
@@ -217,7 +222,8 @@ MdHistoryUI::~MdHistoryUI() {}
void MdHistoryUI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
- registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false,
+ registry->RegisterBooleanPref(
+ prefs::kMdHistoryMenuPromoShown, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
}
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 00d7e9860e0..16bf36021df 100644
--- a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/macros.h"
+#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/media_engagement_score.h"
#include "chrome/browser/media/media_engagement_service.h"
@@ -16,12 +17,20 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "components/component_updater/component_updater_service.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/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/binding.h"
+#if !defined(OS_ANDROID)
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_service.h"
+#endif
+
namespace {
namespace {
@@ -37,10 +46,13 @@ class MediaEngagementScoreDetailsProviderImpl
: public media::mojom::MediaEngagementScoreDetailsProvider {
public:
MediaEngagementScoreDetailsProviderImpl(
- Profile* profile,
+ content::WebUI* web_ui,
mojo::InterfaceRequest<media::mojom::MediaEngagementScoreDetailsProvider>
request)
- : profile_(profile), binding_(this, std::move(request)) {
+ : web_ui_(web_ui),
+ profile_(Profile::FromWebUI(web_ui)),
+ binding_(this, std::move(request)) {
+ DCHECK(web_ui_);
DCHECK(profile_);
service_ = MediaEngagementService::Get(profile_);
}
@@ -65,12 +77,30 @@ class MediaEngagementScoreDetailsProviderImpl
base::FeatureList::IsEnabled(
media::kMediaEngagementBypassAutoplayPolicies),
base::FeatureList::IsEnabled(media::kPreloadMediaEngagementData),
- media::GetEffectiveAutoplayPolicy(
- *base::CommandLine::ForCurrentProcess()),
- GetPreloadVersion()));
+ base::FeatureList::IsEnabled(media::kAutoplaySoundSettings),
+ GetBlockAutoplayPref(),
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAutoplayPolicy),
+ GetAppliedAutoplayPolicy(), GetPreloadVersion()));
}
private:
+ const std::string GetAppliedAutoplayPolicy() {
+ switch (web_ui_->GetWebContents()
+ ->GetRenderViewHost()
+ ->GetWebkitPreferences()
+ .autoplay_policy) {
+ case content::AutoplayPolicy::kNoUserGestureRequired:
+ return "no-user-gesture-required";
+ case content::AutoplayPolicy::kUserGestureRequired:
+ return "user-gesture-required";
+ case content::AutoplayPolicy::kUserGestureRequiredForCrossOrigin:
+ return "user-gesture-required-for-cross-origin";
+ case content::AutoplayPolicy::kDocumentUserActivationRequired:
+ return "document-user-activation-required";
+ }
+ }
+
const std::string GetPreloadVersion() {
component_updater::ComponentUpdateService* cus =
g_browser_process->component_updater();
@@ -84,6 +114,17 @@ class MediaEngagementScoreDetailsProviderImpl
return std::string();
}
+ // Pref is not available on Android.
+ bool GetBlockAutoplayPref() {
+#if defined(OS_ANDROID)
+ return false;
+#else
+ return profile_->GetPrefs()->GetBoolean(prefs::kBlockAutoplayEnabled);
+#endif
+ }
+
+ content::WebUI* web_ui_;
+
Profile* profile_;
MediaEngagementService* service_;
@@ -118,5 +159,5 @@ MediaEngagementUI::~MediaEngagementUI() = default;
void MediaEngagementUI::BindMediaEngagementScoreDetailsProvider(
media::mojom::MediaEngagementScoreDetailsProviderRequest request) {
ui_handler_ = std::make_unique<MediaEngagementScoreDetailsProviderImpl>(
- Profile::FromWebUI(web_ui()), std::move(request));
+ web_ui(), std::move(request));
}
diff --git a/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc b/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
index 69df161dfeb..bea416db65b 100644
--- a/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
@@ -20,6 +20,7 @@
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/media/webrtc/webrtc_event_log_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -27,7 +28,8 @@
#include "components/prefs/pref_service.h"
#include "components/upload_list/upload_list.h"
#include "components/version_info/version_info.h"
-#include "components/webrtc_logging/browser/log_list.h"
+#include "components/webrtc_logging/browser/text_log_list.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -47,8 +49,10 @@ content::WebUIDataSource* CreateWebRtcLogsUIHTMLSource() {
content::WebUIDataSource::Create(chrome::kChromeUIWebRtcLogsHost);
source->AddLocalizedString("webrtcLogsTitle", IDS_WEBRTC_LOGS_TITLE);
- source->AddLocalizedString("webrtcLogCountFormat",
- IDS_WEBRTC_LOGS_LOG_COUNT_BANNER_FORMAT);
+ source->AddLocalizedString("webrtcTextLogCountFormat",
+ IDS_WEBRTC_TEXT_LOGS_LOG_COUNT_BANNER_FORMAT);
+ source->AddLocalizedString("webrtcEventLogCountFormat",
+ IDS_WEBRTC_EVENT_LOGS_LOG_COUNT_BANNER_FORMAT);
source->AddLocalizedString("webrtcLogHeaderFormat",
IDS_WEBRTC_LOGS_LOG_HEADER_FORMAT);
source->AddLocalizedString("webrtcLogLocalFileLabelFormat",
@@ -57,13 +61,23 @@ content::WebUIDataSource* CreateWebRtcLogsUIHTMLSource() {
IDS_WEBRTC_LOGS_NO_LOCAL_LOG_FILE_MESSAGE);
source->AddLocalizedString("webrtcLogUploadTimeFormat",
IDS_WEBRTC_LOGS_LOG_UPLOAD_TIME_FORMAT);
+ source->AddLocalizedString("webrtcLogFailedUploadTimeFormat",
+ IDS_WEBRTC_LOGS_LOG_FAILED_UPLOAD_TIME_FORMAT);
source->AddLocalizedString("webrtcLogReportIdFormat",
IDS_WEBRTC_LOGS_LOG_REPORT_ID_FORMAT);
+ source->AddLocalizedString("webrtcEventLogLocalLogIdFormat",
+ IDS_WEBRTC_LOGS_EVENT_LOG_LOCAL_LOG_ID);
source->AddLocalizedString("bugLinkText", IDS_WEBRTC_LOGS_BUG_LINK_LABEL);
source->AddLocalizedString("webrtcLogNotUploadedMessage",
IDS_WEBRTC_LOGS_LOG_NOT_UPLOADED_MESSAGE);
- source->AddLocalizedString("noLogsMessage",
- IDS_WEBRTC_LOGS_NO_LOGS_MESSAGE);
+ source->AddLocalizedString("webrtcLogPendingMessage",
+ IDS_WEBRTC_LOGS_LOG_PENDING_MESSAGE);
+ source->AddLocalizedString("webrtcLogActivelyUploadedMessage",
+ IDS_WEBRTC_LOGS_LOG_ACTIVELY_UPLOADED_MESSAGE);
+ source->AddLocalizedString("noTextLogsMessage",
+ IDS_WEBRTC_LOGS_NO_TEXT_LOGS_MESSAGE);
+ source->AddLocalizedString("noEventLogsMessage",
+ IDS_WEBRTC_LOGS_NO_EVENT_LOGS_MESSAGE);
source->SetJsonPath("strings.js");
source->AddResourcePath("webrtc_logs.js", IDR_WEBRTC_LOGS_JS);
source->SetDefaultResource(IDR_WEBRTC_LOGS_HTML);
@@ -86,17 +100,67 @@ class WebRtcLogsDOMHandler final : public WebUIMessageHandler {
void RegisterMessages() override;
private:
+ using WebRtcEventLogManager = webrtc_event_logging::WebRtcEventLogManager;
+
// Asynchronously fetches the list of upload WebRTC logs. Called from JS.
void HandleRequestWebRtcLogs(const base::ListValue* args);
- // Sends the recently uploaded logs list JS.
- void UpdateUI();
+ // Asynchronously load WebRTC text logs.
+ void LoadWebRtcTextLogs();
+
+ // Callback for when WebRTC text logs have been asynchronously loaded.
+ void OnWebRtcTextLogsLoaded();
- // Loads, parses and stores the list of uploaded WebRTC logs.
- scoped_refptr<UploadList> upload_list_;
+ // Asynchronously load WebRTC event logs.
+ void LoadWebRtcEventLogs();
- // The directory where the logs are stored.
- base::FilePath log_dir_;
+ // Callback for when WebRTC event logs have been asynchronously loaded.
+ void OnWebRtcEventLogsLoaded(
+ const std::vector<UploadList::UploadInfo>& event_logs);
+
+ // Update the chrome://webrtc-logs/ page.
+ void UpdateUI();
+
+ // Update the text/event logs part of the forementioned page.
+ void UpdateUIWithTextLogs(base::ListValue* text_logs_list) const;
+ void UpdateUIWithEventLogs(base::ListValue* event_logs_list) const;
+
+ // Convert a history entry about a captured WebRTC event log into a
+ // DictionaryValue of the type expected by updateWebRtcLogsList().
+ std::unique_ptr<base::DictionaryValue> EventLogUploadInfoToDictionaryValue(
+ const UploadList::UploadInfo& info) const;
+
+ // Helpers for EventLogUploadInfoToDictionaryValue().
+ std::unique_ptr<base::DictionaryValue> FromPendingLog(
+ const UploadList::UploadInfo& info) const;
+ std::unique_ptr<base::DictionaryValue> FromActivelyUploadedLog(
+ const UploadList::UploadInfo& info) const;
+ std::unique_ptr<base::DictionaryValue> FromNotUploadedLog(
+ const UploadList::UploadInfo& info) const;
+ std::unique_ptr<base::DictionaryValue> FromUploadUnsuccessfulLog(
+ const UploadList::UploadInfo& info) const;
+ std::unique_ptr<base::DictionaryValue> FromUploadSuccessfulLog(
+ const UploadList::UploadInfo& info) const;
+
+ bool SanityCheckOnUploadInfo(const UploadList::UploadInfo& info) const;
+
+ // The directories where the (text/event) logs are stored.
+ const base::FilePath text_log_dir_;
+ const base::FilePath event_log_dir_;
+
+ // Identifies to WebRtcEventLogManager the profile with which |this| is
+ // associated. Technically, we should be able to just keep Profile*,
+ // but avoiding it makes less lifetime assumptions.
+ // Note that the profile->GetOriginalProfile() is used, to make sure that
+ // for incognito profiles, the parent profile's event logs are shown,
+ // as is the behavior for text logs.
+ const WebRtcEventLogManager::BrowserContextId original_browser_context_id_;
+
+ // Loads, parses and stores the list of uploaded text WebRTC logs.
+ scoped_refptr<UploadList> text_log_upload_list_;
+
+ // List of WebRTC logs captured and possibly uploaded to Crash.
+ std::vector<UploadList::UploadInfo> event_logs_;
// Factory for creating weak references to instances of this class.
base::WeakPtrFactory<WebRtcLogsDOMHandler> weak_ptr_factory_;
@@ -105,20 +169,26 @@ class WebRtcLogsDOMHandler final : public WebUIMessageHandler {
};
WebRtcLogsDOMHandler::WebRtcLogsDOMHandler(Profile* profile)
- : log_dir_(
- webrtc_logging::LogList::GetWebRtcLogDirectoryForBrowserContextPath(
- profile->GetPath())),
+ : text_log_dir_(
+ webrtc_logging::TextLogList::
+ GetWebRtcLogDirectoryForBrowserContextPath(profile->GetPath())),
+ event_log_dir_(
+ WebRtcEventLogManager::GetRemoteBoundWebRtcEventLogsDir(profile)),
+ original_browser_context_id_(webrtc_event_logging::GetBrowserContextId(
+ profile->GetOriginalProfile())),
+ text_log_upload_list_(
+ webrtc_logging::TextLogList::CreateWebRtcLogList(profile)),
weak_ptr_factory_(this) {
- upload_list_ = webrtc_logging::LogList::CreateWebRtcLogList(profile);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
}
WebRtcLogsDOMHandler::~WebRtcLogsDOMHandler() {
- upload_list_->CancelCallback();
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ text_log_upload_list_->CancelCallback();
}
void WebRtcLogsDOMHandler::RegisterMessages() {
- upload_list_->Load(base::BindOnce(&WebRtcLogsDOMHandler::UpdateUI,
- weak_ptr_factory_.GetWeakPtr()));
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
web_ui()->RegisterMessageCallback(
"requestWebRtcLogsList",
@@ -128,15 +198,67 @@ void WebRtcLogsDOMHandler::RegisterMessages() {
void WebRtcLogsDOMHandler::HandleRequestWebRtcLogs(
const base::ListValue* args) {
- upload_list_->Load(base::BindOnce(&WebRtcLogsDOMHandler::UpdateUI,
- weak_ptr_factory_.GetWeakPtr()));
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ LoadWebRtcTextLogs();
+}
+
+void WebRtcLogsDOMHandler::LoadWebRtcTextLogs() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ text_log_upload_list_->Load(
+ base::BindOnce(&WebRtcLogsDOMHandler::OnWebRtcTextLogsLoaded,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void WebRtcLogsDOMHandler::OnWebRtcTextLogsLoaded() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ LoadWebRtcEventLogs(); // Text logs loaded; on to the event logs.
+}
+
+void WebRtcLogsDOMHandler::LoadWebRtcEventLogs() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ WebRtcEventLogManager* manager = WebRtcEventLogManager::GetInstance();
+ if (manager) {
+ manager->GetHistory(
+ original_browser_context_id_,
+ base::BindOnce(&WebRtcLogsDOMHandler::OnWebRtcEventLogsLoaded,
+ weak_ptr_factory_.GetWeakPtr()));
+ } else {
+ OnWebRtcEventLogsLoaded(std::vector<UploadList::UploadInfo>());
+ }
+}
+
+void WebRtcLogsDOMHandler::OnWebRtcEventLogsLoaded(
+ const std::vector<UploadList::UploadInfo>& event_logs) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ event_logs_ = event_logs;
+
+ UpdateUI(); // All log histories loaded asynchronously; time to display.
}
void WebRtcLogsDOMHandler::UpdateUI() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ base::ListValue text_logs_list;
+ UpdateUIWithTextLogs(&text_logs_list);
+
+ base::ListValue event_logs_list;
+ UpdateUIWithEventLogs(&event_logs_list);
+
+ base::Value version(version_info::GetVersionNumber());
+
+ web_ui()->CallJavascriptFunctionUnsafe("updateWebRtcLogsList", text_logs_list,
+ event_logs_list, version);
+}
+
+void WebRtcLogsDOMHandler::UpdateUIWithTextLogs(
+ base::ListValue* upload_list) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
std::vector<UploadList::UploadInfo> uploads;
- upload_list_->GetUploads(50, &uploads);
+ text_log_upload_list_->GetUploads(50, &uploads);
- base::ListValue upload_list;
for (std::vector<UploadList::UploadInfo>::iterator i = uploads.begin();
i != uploads.end();
++i) {
@@ -150,8 +272,9 @@ void WebRtcLogsDOMHandler::UpdateUI() {
base::FilePath::StringType value;
if (!i->local_id.empty())
- value = log_dir_.AppendASCII(i->local_id)
- .AddExtension(FILE_PATH_LITERAL(".gz")).value();
+ value = text_log_dir_.AppendASCII(i->local_id)
+ .AddExtension(FILE_PATH_LITERAL(".gz"))
+ .value();
upload->SetString("local_file", value);
// In october 2015, capture time was added to the log list, previously the
@@ -186,13 +309,158 @@ void WebRtcLogsDOMHandler::UpdateUI() {
value_w = base::string16(base::ASCIIToUTF16("(unknown time)"));
upload->SetString("capture_time", value_w);
- upload_list.Append(std::move(upload));
+ upload_list->Append(std::move(upload));
}
+}
- base::Value version(version_info::GetVersionNumber());
+void WebRtcLogsDOMHandler::UpdateUIWithEventLogs(
+ base::ListValue* event_logs_list) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ for (auto it = event_logs_.crbegin(); it != event_logs_.crend(); ++it) {
+ event_logs_list->Append(EventLogUploadInfoToDictionaryValue(*it));
+ }
+}
+
+std::unique_ptr<base::DictionaryValue>
+WebRtcLogsDOMHandler::EventLogUploadInfoToDictionaryValue(
+ const UploadList::UploadInfo& info) const {
+ switch (info.state) {
+ case UploadList::UploadInfo::State::Pending:
+ // TODO(crbug.com/775415): Display actively-written logs differently
+ // than fully captured pending logs.
+ return info.upload_time.is_null() ? FromPendingLog(info)
+ : FromActivelyUploadedLog(info);
+ case UploadList::UploadInfo::State::NotUploaded:
+ return info.upload_time.is_null() ? FromNotUploadedLog(info)
+ : FromUploadUnsuccessfulLog(info);
+ case UploadList::UploadInfo::State::Uploaded:
+ return FromUploadSuccessfulLog(info);
+ case UploadList::UploadInfo::State::Pending_UserRequested:
+ NOTREACHED();
+ }
+
+ LOG(ERROR) << "Unrecognized state (" << static_cast<int>(info.state) << ").";
+ return nullptr;
+}
+
+std::unique_ptr<base::DictionaryValue> WebRtcLogsDOMHandler::FromPendingLog(
+ const UploadList::UploadInfo& info) const {
+ DCHECK_EQ(info.state, UploadList::UploadInfo::State::Pending);
+ DCHECK(info.upload_time.is_null());
+
+ if (!SanityCheckOnUploadInfo(info)) {
+ return nullptr;
+ }
+
+ std::unique_ptr<base::DictionaryValue> log(new base::DictionaryValue());
+ log->SetString("state", "pending");
+ log->SetString("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log->SetString("local_file",
+ event_log_dir_.AppendASCII(info.local_id).value());
+ return log;
+}
+
+std::unique_ptr<base::DictionaryValue>
+WebRtcLogsDOMHandler::FromActivelyUploadedLog(
+ const UploadList::UploadInfo& info) const {
+ DCHECK_EQ(info.state, UploadList::UploadInfo::State::Pending);
+ DCHECK(!info.upload_time.is_null());
+
+ if (!SanityCheckOnUploadInfo(info)) {
+ return nullptr;
+ }
+
+ std::unique_ptr<base::DictionaryValue> log(new base::DictionaryValue());
+ log->SetString("state", "actively_uploaded");
+ log->SetString("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log->SetString("local_file",
+ event_log_dir_.AppendASCII(info.local_id).value());
+ return log;
+}
+
+std::unique_ptr<base::DictionaryValue> WebRtcLogsDOMHandler::FromNotUploadedLog(
+ const UploadList::UploadInfo& info) const {
+ DCHECK_EQ(info.state, UploadList::UploadInfo::State::NotUploaded);
+ DCHECK(info.upload_time.is_null());
+
+ if (!SanityCheckOnUploadInfo(info)) {
+ return nullptr;
+ }
+
+ std::unique_ptr<base::DictionaryValue> log(new base::DictionaryValue());
+ log->SetString("state", "not_uploaded");
+ log->SetString("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log->SetString("local_id", info.local_id);
+ return log;
+}
+
+std::unique_ptr<base::DictionaryValue>
+WebRtcLogsDOMHandler::FromUploadUnsuccessfulLog(
+ const UploadList::UploadInfo& info) const {
+ DCHECK_EQ(info.state, UploadList::UploadInfo::State::NotUploaded);
+ DCHECK(!info.upload_time.is_null());
+
+ if (!SanityCheckOnUploadInfo(info)) {
+ return nullptr;
+ }
+
+ if (!info.upload_id.empty()) {
+ LOG(ERROR) << "Unexpected upload ID.";
+ return nullptr;
+ }
+
+ std::unique_ptr<base::DictionaryValue> log(new base::DictionaryValue());
+ log->SetString("state", "upload_unsuccessful");
+ log->SetString("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log->SetString("local_id", info.local_id);
+ log->SetString("upload_time",
+ base::TimeFormatFriendlyDateAndTime(info.upload_time));
+ return log;
+}
+
+std::unique_ptr<base::DictionaryValue>
+WebRtcLogsDOMHandler::FromUploadSuccessfulLog(
+ const UploadList::UploadInfo& info) const {
+ DCHECK_EQ(info.state, UploadList::UploadInfo::State::Uploaded);
+ DCHECK(!info.upload_time.is_null());
+
+ if (!SanityCheckOnUploadInfo(info)) {
+ return nullptr;
+ }
+
+ if (info.upload_id.empty()) {
+ LOG(ERROR) << "Unknown upload ID.";
+ return nullptr;
+ }
+
+ std::unique_ptr<base::DictionaryValue> log(new base::DictionaryValue());
+ log->SetString("state", "upload_successful");
+ log->SetString("capture_time",
+ base::TimeFormatFriendlyDateAndTime(info.capture_time));
+ log->SetString("local_id", info.local_id);
+ log->SetString("upload_id", info.upload_id);
+ log->SetString("upload_time",
+ base::TimeFormatFriendlyDateAndTime(info.upload_time));
+ return log;
+}
+
+bool WebRtcLogsDOMHandler::SanityCheckOnUploadInfo(
+ const UploadList::UploadInfo& info) const {
+ if (info.capture_time.is_null()) {
+ LOG(ERROR) << "Unknown capture time.";
+ return false;
+ }
+
+ if (info.local_id.empty()) {
+ LOG(ERROR) << "Unknown local ID.";
+ return false;
+ }
- web_ui()->CallJavascriptFunctionUnsafe("updateWebRtcLogsList", upload_list,
- version);
+ return true;
}
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl.cc
index 438bde5b358..ff37610b926 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl.cc
@@ -31,9 +31,6 @@
#include "ui/web_dialogs/web_dialog_web_contents_delegate.h"
#include "url/gurl.h"
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(
- media_router::MediaRouterDialogControllerWebUIImpl);
-
using content::LoadCommittedDetails;
using content::NavigationController;
using content::WebContents;
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc
index ea35a42225c..78c74cad0f1 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc
@@ -8,11 +8,11 @@
#include "chrome/browser/media/router/test/test_helper.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/media_router/media_router_ui_service.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/mock_media_router_action_controller.h"
#include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl.h"
#include "chrome/browser/ui/webui/media_router/media_router_ui.h"
-#include "chrome/browser/ui/webui/media_router/media_router_ui_service.h"
#include "chrome/browser/ui/webui/media_router/media_router_web_ui_test.h"
#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -29,8 +29,10 @@ class MediaRouterDialogControllerWebUIImplTest : public MediaRouterWebUITest {
void OpenMediaRouterDialog();
- MOCK_METHOD2(PresentationSuccessCallback,
- void(const blink::mojom::PresentationInfo&, const MediaRoute&));
+ MOCK_METHOD3(PresentationSuccessCallback,
+ void(const blink::mojom::PresentationInfo&,
+ mojom::RoutePresentationConnectionPtr,
+ const MediaRoute&));
MOCK_METHOD1(PresentationErrorCallback,
void(const blink::mojom::PresentationError& error));
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc
index d49923de6a1..4aba966ad9f 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc
@@ -115,8 +115,10 @@ bool MediaRouterUI::ConnectRoute(const MediaSink::Id& sink_id,
GetIssueManager()->ClearNonBlockingIssues();
GetMediaRouter()->ConnectRouteByRouteId(
params->source_id, route_id, params->origin, initiator(),
- std::move(params->route_response_callbacks), params->timeout,
- params->incognito);
+ base::BindOnce(&MediaRouterUIBase::RunRouteResponseCallbacks,
+ std::move(params->presentation_callback),
+ std::move(params->route_result_callbacks)),
+ params->timeout, params->incognito);
return true;
}
@@ -324,11 +326,6 @@ void MediaRouterUI::OnRouteResponseReceived(
SendIssueForRouteTimeout(cast_mode, presentation_request_source_name);
}
-void MediaRouterUI::HandleCreateSessionRequestRouteResponse(
- const RouteRequestResult&) {
- Close();
-}
-
void MediaRouterUI::OnSearchSinkResponseReceived(
MediaCastMode cast_mode,
const MediaSink::Id& found_sink_id) {
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui.h b/chromium/chrome/browser/ui/webui/media_router/media_router_ui.h
index acf5fe70e64..bc1b0bbf1e1 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui.h
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_ui.h
@@ -27,8 +27,8 @@ class MediaRouterUI : public MediaRouterUIBase, public ConstrainedWebDialogUI {
explicit MediaRouterUI(content::WebUI* web_ui);
~MediaRouterUI() override;
- // Closes the media router UI.
- void Close();
+ // MediaRouterUIBase:
+ void Close() override;
// Notifies this instance that the UI has been initialized.
virtual void OnUIInitialized();
@@ -160,9 +160,6 @@ class MediaRouterUI : public MediaRouterUIBase, public ConstrainedWebDialogUI {
const base::string16& presentation_request_source_name,
const RouteRequestResult& result) override;
- void HandleCreateSessionRequestRouteResponse(
- const RouteRequestResult&) override;
-
// Callback passed to MediaRouter to receive the sink ID of the sink found by
// SearchSinksAndCreateRoute().
void OnSearchSinkResponseReceived(MediaCastMode cast_mode,
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service.cc
deleted file mode 100644
index 1726d12f796..00000000000
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service.cc
+++ /dev/null
@@ -1,71 +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/media_router/media_router_ui_service.h"
-
-#include "chrome/browser/media/router/media_router_feature.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/media_router/media_router_ui_service_factory.h"
-#include "chrome/common/pref_names.h"
-#include "components/prefs/pref_change_registrar.h"
-#include "components/user_prefs/user_prefs.h"
-
-namespace media_router {
-
-MediaRouterUIService::MediaRouterUIService(Profile* profile)
- : MediaRouterUIService(profile, nullptr) {}
-
-MediaRouterUIService::MediaRouterUIService(
- Profile* profile,
- std::unique_ptr<MediaRouterActionController> action_controller)
- : profile_(profile),
- action_controller_(std::move(action_controller)),
- profile_pref_registrar_(std::make_unique<PrefChangeRegistrar>()) {
- profile_pref_registrar_->Init(profile->GetPrefs());
- profile_pref_registrar_->Add(
- ::prefs::kEnableMediaRouter,
- base::BindRepeating(&MediaRouterUIService::ConfigureService,
- base::Unretained(this)));
- ConfigureService();
-}
-
-MediaRouterUIService::~MediaRouterUIService() {}
-
-void MediaRouterUIService::Shutdown() {
- DisableService();
-}
-
-// static
-MediaRouterUIService* MediaRouterUIService::Get(Profile* profile) {
- return MediaRouterUIServiceFactory::GetForBrowserContext(profile);
-}
-
-MediaRouterActionController* MediaRouterUIService::action_controller() {
- return action_controller_.get();
-}
-
-void MediaRouterUIService::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void MediaRouterUIService::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
-void MediaRouterUIService::ConfigureService() {
- if (!MediaRouterEnabled(profile_)) {
- DisableService();
- } else if (!action_controller_ && MediaRouterEnabled(profile_)) {
- action_controller_ =
- std::make_unique<MediaRouterActionController>(profile_);
- }
-}
-
-void MediaRouterUIService::DisableService() {
- for (auto& observer : observers_)
- observer.OnServiceDisabled();
- action_controller_.reset();
-}
-
-} // namespace media_router
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service.h b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service.h
deleted file mode 100644
index 313be0e33f6..00000000000
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service.h
+++ /dev/null
@@ -1,61 +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_MEDIA_ROUTER_MEDIA_ROUTER_UI_SERVICE_H_
-#define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_SERVICE_H_
-
-#include <memory>
-
-#include "base/observer_list.h"
-#include "chrome/browser/ui/toolbar/media_router_action_controller.h"
-#include "components/keyed_service/core/keyed_service.h"
-
-class PrefChangeRegistrar;
-class Profile;
-
-namespace media_router {
-
-// Service that owns per-profile Media Router UI objects, such as the controller
-// for the Media Router toolbar action.
-class MediaRouterUIService : public KeyedService {
- public:
- class Observer {
- public:
- virtual void OnServiceDisabled() = 0;
- };
-
- explicit MediaRouterUIService(Profile* profile);
- // Used by tests to inject an action controller.
- MediaRouterUIService(
- Profile* profile,
- std::unique_ptr<MediaRouterActionController> action_controller);
- ~MediaRouterUIService() override;
-
- // KeyedService:
- void Shutdown() override;
-
- static MediaRouterUIService* Get(Profile* profile);
-
- virtual MediaRouterActionController* action_controller();
-
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
-
- private:
- friend class MediaRouterUIBrowserTest;
-
- void ConfigureService();
- void DisableService();
-
- Profile* profile_;
- std::unique_ptr<MediaRouterActionController> action_controller_;
- std::unique_ptr<PrefChangeRegistrar> profile_pref_registrar_;
-
- base::ObserverList<Observer> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(MediaRouterUIService);
-};
-
-} // namespace media_router
-
-#endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_SERVICE_H_
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory.cc
deleted file mode 100644
index 98c0f0eeb07..00000000000
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory.cc
+++ /dev/null
@@ -1,64 +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/media_router/media_router_ui_service_factory.h"
-
-#include "chrome/browser/media/router/media_router_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/toolbar/toolbar_actions_model_factory.h"
-#include "chrome/browser/ui/webui/media_router/media_router_ui_service.h"
-#include "components/keyed_service/content/browser_context_dependency_manager.h"
-
-using content::BrowserContext;
-
-namespace media_router {
-
-// static
-MediaRouterUIService* MediaRouterUIServiceFactory::GetForBrowserContext(
- BrowserContext* context) {
- DCHECK(context);
- return static_cast<MediaRouterUIService*>(
- GetInstance()->GetServiceForBrowserContext(context, true));
-}
-
-// static
-MediaRouterUIServiceFactory* MediaRouterUIServiceFactory::GetInstance() {
- return base::Singleton<MediaRouterUIServiceFactory>::get();
-}
-
-MediaRouterUIServiceFactory::MediaRouterUIServiceFactory()
- : BrowserContextKeyedServiceFactory(
- "MediaRouterUIService",
- BrowserContextDependencyManager::GetInstance()) {
- DependsOn(MediaRouterFactory::GetInstance());
- // MediaRouterUIService owns a MediaRouterActionController that depends on
- // ToolbarActionsModel.
- DependsOn(ToolbarActionsModelFactory::GetInstance());
-}
-
-MediaRouterUIServiceFactory::~MediaRouterUIServiceFactory() {}
-
-BrowserContext* MediaRouterUIServiceFactory::GetBrowserContextToUse(
- BrowserContext* context) const {
- return context;
-}
-
-KeyedService* MediaRouterUIServiceFactory::BuildServiceInstanceFor(
- BrowserContext* context) const {
- return new MediaRouterUIService(Profile::FromBrowserContext(context));
-}
-
-bool MediaRouterUIServiceFactory::ServiceIsCreatedWithBrowserContext() const {
-#if !defined(OS_ANDROID)
- return true;
-#else
- return false;
-#endif
-}
-
-bool MediaRouterUIServiceFactory::ServiceIsNULLWhileTesting() const {
- return true;
-}
-
-} // namespace media_router
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory.h b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory.h
deleted file mode 100644
index 10d57611301..00000000000
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory.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_MEDIA_ROUTER_MEDIA_ROUTER_UI_SERVICE_FACTORY_H_
-#define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_SERVICE_FACTORY_H_
-
-#include "base/gtest_prod_util.h"
-#include "base/memory/singleton.h"
-#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
-
-namespace content {
-class BrowserContext;
-}
-
-namespace media_router {
-
-class MediaRouterUIService;
-
-class MediaRouterUIServiceFactory : public BrowserContextKeyedServiceFactory {
- public:
- static MediaRouterUIService* GetForBrowserContext(
- content::BrowserContext* context);
-
- static MediaRouterUIServiceFactory* GetInstance();
-
- private:
- friend struct base::DefaultSingletonTraits<MediaRouterUIServiceFactory>;
- FRIEND_TEST_ALL_PREFIXES(MediaRouterUIServiceFactoryUnitTest, CreateService);
- FRIEND_TEST_ALL_PREFIXES(MediaRouterUIServiceFactoryUnitTest,
- DoNotCreateActionControllerWhenDisabled);
- FRIEND_TEST_ALL_PREFIXES(MediaRouterUIServiceFactoryUnitTest,
- DisablingMediaRouting);
-
- MediaRouterUIServiceFactory();
- ~MediaRouterUIServiceFactory() override;
-
- // BrowserContextKeyedServiceFactory interface.
- content::BrowserContext* GetBrowserContextToUse(
- content::BrowserContext* context) const override;
- KeyedService* BuildServiceInstanceFor(
- content::BrowserContext* context) const override;
- bool ServiceIsCreatedWithBrowserContext() const override;
- bool ServiceIsNULLWhileTesting() const override;
-
- DISALLOW_COPY_AND_ASSIGN(MediaRouterUIServiceFactory);
-};
-
-} // namespace media_router
-
-#endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_SERVICE_FACTORY_H_
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory_unittest.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory_unittest.cc
deleted file mode 100644
index 22005542e82..00000000000
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_service_factory_unittest.cc
+++ /dev/null
@@ -1,103 +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 <memory>
-
-#include "base/values.h"
-#include "chrome/browser/media/router/media_router_factory.h"
-#include "chrome/browser/media/router/test/mock_media_router.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
-#include "chrome/browser/ui/toolbar/toolbar_actions_model_factory.h"
-#include "chrome/browser/ui/webui/media_router/media_router_ui_service.h"
-#include "chrome/browser/ui/webui/media_router/media_router_ui_service_factory.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/test/base/testing_profile.h"
-#include "components/sync_preferences/testing_pref_service_syncable.h"
-#include "content/public/test/test_browser_thread_bundle.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class MockMediaRouterUIServiceObserver
- : public media_router::MediaRouterUIService::Observer {
- public:
- MOCK_METHOD0(OnServiceDisabled, void());
-};
-
-} // namespace
-
-namespace media_router {
-
-class MediaRouterUIServiceFactoryUnitTest : public testing::Test {
- public:
- MediaRouterUIServiceFactoryUnitTest() {}
- ~MediaRouterUIServiceFactoryUnitTest() override {}
-
- void SetUp() override {
- TestingProfile::Builder builder;
- // MediaRouterUIService instantiates MediaRouterActionController, which
- // requires ToolbarActionsModel.
- builder.AddTestingFactory(ToolbarActionsModelFactory::GetInstance(),
- BuildFakeToolBarActionsModel);
- builder.AddTestingFactory(MediaRouterFactory::GetInstance(),
- MockMediaRouter::Create);
- profile_ = builder.Build();
- }
-
- static std::unique_ptr<KeyedService> BuildFakeToolBarActionsModel(
- content::BrowserContext* context) {
- return std::unique_ptr<ToolbarActionsModel>(
- new ToolbarActionsModel(static_cast<Profile*>(context), nullptr));
- }
-
- protected:
- content::TestBrowserThreadBundle thread_bundle_;
- std::unique_ptr<TestingProfile> profile_;
-};
-
-TEST_F(MediaRouterUIServiceFactoryUnitTest, CreateService) {
- // We call BuildServiceInstanceFor() directly because
- // MediaRouterUIServiceFactory::GetForBrowserContext() is set to return a
- // nullptr for a test profile.
- std::unique_ptr<MediaRouterUIService> service(
- static_cast<MediaRouterUIService*>(
- MediaRouterUIServiceFactory::GetInstance()->BuildServiceInstanceFor(
- profile_.get())));
- ASSERT_TRUE(service);
- ASSERT_TRUE(service->action_controller());
-}
-
-TEST_F(MediaRouterUIServiceFactoryUnitTest,
- DoNotCreateActionControllerWhenDisabled) {
- profile_->GetTestingPrefService()->SetManagedPref(
- prefs::kEnableMediaRouter, std::make_unique<base::Value>(false));
- std::unique_ptr<MediaRouterUIService> service(
- static_cast<MediaRouterUIService*>(
- MediaRouterUIServiceFactory::GetInstance()->BuildServiceInstanceFor(
- profile_.get())));
- ASSERT_TRUE(service);
- EXPECT_EQ(nullptr, service->action_controller());
-}
-
-TEST_F(MediaRouterUIServiceFactoryUnitTest, DisablingMediaRouting) {
- std::unique_ptr<MediaRouterUIService> service(
- static_cast<MediaRouterUIService*>(
- MediaRouterUIServiceFactory::GetInstance()->BuildServiceInstanceFor(
- profile_.get())));
- ASSERT_TRUE(service);
- ASSERT_TRUE(service->action_controller());
-
- MockMediaRouterUIServiceObserver mock_observer;
- service->AddObserver(&mock_observer);
- EXPECT_CALL(mock_observer, OnServiceDisabled).Times(testing::Exactly(1));
-
- profile_->GetTestingPrefService()->SetManagedPref(
- prefs::kEnableMediaRouter, std::make_unique<base::Value>(false));
- EXPECT_EQ(nullptr, service->action_controller());
- service->RemoveObserver(&mock_observer);
-}
-
-} // namespace media_router
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc
index cc65de51976..6847cd75354 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/ui/webui/media_router/media_router_webui_message_handler.h"
#include "chrome/common/media_router/media_route.h"
#include "chrome/common/media_router/media_source_helper.h"
+#include "chrome/common/media_router/mojo/media_router.mojom.h"
#include "chrome/common/media_router/route_request_result.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
@@ -107,7 +108,9 @@ class PresentationRequestCallbacks {
const blink::mojom::PresentationError& expected_error)
: expected_error_(expected_error) {}
- void Success(const blink::mojom::PresentationInfo&, const MediaRoute&) {}
+ void Success(const blink::mojom::PresentationInfo&,
+ mojom::RoutePresentationConnectionPtr,
+ const MediaRoute&) {}
void Error(const blink::mojom::PresentationError& error) {
EXPECT_EQ(expected_error_.error_type, error.error_type);
@@ -244,11 +247,11 @@ class MediaRouterUIIncognitoTest : public MediaRouterUITest {
TEST_F(MediaRouterUITest, RouteCreationTimeoutForTab) {
CreateMediaRouterUI(profile());
- std::vector<MediaRouteResponseCallback> callbacks;
+ MediaRouteResponseCallback callback;
EXPECT_CALL(mock_router_,
CreateRouteInternal(_, _, _, _, _,
base::TimeDelta::FromSeconds(60), false))
- .WillOnce(SaveArgWithMove<4>(&callbacks));
+ .WillOnce(SaveArgWithMove<4>(&callback));
media_router_ui_->CreateRoute(CreateSinkCompatibleWithAllSources().id(),
MediaCastMode::TAB_MIRROR);
@@ -257,17 +260,16 @@ TEST_F(MediaRouterUITest, RouteCreationTimeoutForTab) {
EXPECT_CALL(*message_handler_, UpdateIssue(IssueTitleEquals(expected_title)));
std::unique_ptr<RouteRequestResult> result =
RouteRequestResult::FromError("Timed out", RouteRequestResult::TIMED_OUT);
- for (auto& callback : callbacks)
- std::move(callback).Run(*result);
+ std::move(callback).Run(nullptr, *result);
}
TEST_F(MediaRouterUITest, RouteCreationTimeoutForDesktop) {
CreateMediaRouterUI(profile());
- std::vector<MediaRouteResponseCallback> callbacks;
+ MediaRouteResponseCallback callback;
EXPECT_CALL(mock_router_,
CreateRouteInternal(_, _, _, _, _,
base::TimeDelta::FromSeconds(120), false))
- .WillOnce(SaveArgWithMove<4>(&callbacks));
+ .WillOnce(SaveArgWithMove<4>(&callback));
media_router_ui_->CreateRoute(CreateSinkCompatibleWithAllSources().id(),
MediaCastMode::DESKTOP_MIRROR);
@@ -276,8 +278,7 @@ TEST_F(MediaRouterUITest, RouteCreationTimeoutForDesktop) {
EXPECT_CALL(*message_handler_, UpdateIssue(IssueTitleEquals(expected_title)));
std::unique_ptr<RouteRequestResult> result =
RouteRequestResult::FromError("Timed out", RouteRequestResult::TIMED_OUT);
- for (auto& callback : callbacks)
- std::move(callback).Run(*result);
+ std::move(callback).Run(nullptr, *result);
}
TEST_F(MediaRouterUITest, RouteCreationTimeoutForPresentation) {
@@ -286,11 +287,11 @@ TEST_F(MediaRouterUITest, RouteCreationTimeoutForPresentation) {
{0, 0}, {GURL("https://presentationurl.com")},
url::Origin::Create(GURL("https://frameurl.fakeurl")));
media_router_ui_->OnDefaultPresentationChanged(presentation_request);
- std::vector<MediaRouteResponseCallback> callbacks;
+ MediaRouteResponseCallback callback;
EXPECT_CALL(mock_router_,
CreateRouteInternal(_, _, _, _, _,
base::TimeDelta::FromSeconds(20), false))
- .WillOnce(SaveArgWithMove<4>(&callbacks));
+ .WillOnce(SaveArgWithMove<4>(&callback));
media_router_ui_->CreateRoute(CreateSinkCompatibleWithAllSources().id(),
MediaCastMode::PRESENTATION);
@@ -300,8 +301,7 @@ TEST_F(MediaRouterUITest, RouteCreationTimeoutForPresentation) {
EXPECT_CALL(*message_handler_, UpdateIssue(IssueTitleEquals(expected_title)));
std::unique_ptr<RouteRequestResult> result =
RouteRequestResult::FromError("Timed out", RouteRequestResult::TIMED_OUT);
- for (auto& callback : callbacks)
- std::move(callback).Run(*result);
+ std::move(callback).Run(nullptr, *result);
}
// Tests that if a local file CreateRoute call is made from a new tab, the
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.cc
index 0b0a38ed222..b15b9927ece 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.cc
@@ -6,11 +6,11 @@
#include "chrome/browser/media/router/media_router_factory.h"
#include "chrome/browser/media/router/test/mock_media_router.h"
+#include "chrome/browser/ui/media_router/media_router_ui_service.h"
+#include "chrome/browser/ui/media_router/media_router_ui_service_factory.h"
#include "chrome/browser/ui/toolbar/mock_media_router_action_controller.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
#include "chrome/browser/ui/toolbar/toolbar_actions_model_factory.h"
-#include "chrome/browser/ui/webui/media_router/media_router_ui_service.h"
-#include "chrome/browser/ui/webui/media_router/media_router_ui_service_factory.h"
#include "chrome/test/base/dialog_test_browser_window.h"
class MockMediaRouterUIService : public media_router::MediaRouterUIService {
diff --git a/chromium/chrome/browser/ui/webui/memory_internals_ui.cc b/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
index 2ab3d76daed..17636bd8c31 100644
--- a/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
@@ -74,8 +74,14 @@ std::string GetMessageString() {
case Mode::kRendererSampling:
return std::string(
- "Memory logging is enabled for an automatic sample of renderer "
- "processes. This UI is disabled.");
+ "Memory logging is enabled for at most one renderer process. Each "
+ "renderer process has a fixed probability of being sampled at "
+ "startup.");
+
+ case Mode::kUtilitySampling:
+ return std::string(
+ "Each utility process has a fixed probability of being profiled at "
+ "startup.");
case Mode::kNone:
case Mode::kManual:
@@ -272,14 +278,15 @@ void MemoryInternalsDOMHandler::GetChildProcessesOnIOThread(
base::WeakPtr<MemoryInternalsDOMHandler> dom_handler) {
std::vector<base::Value> result;
- // The only non-renderer child process that currently supports out-of-process
- // heap profiling is GPU.
+ // The only non-renderer child processes that currently support out-of-process
+ // heap profiling are GPU and UTILITY.
for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
// Note that ChildProcessData.id is a child ID and not an OS PID.
const content::ChildProcessData& data = iter.GetData();
- if (data.process_type == content::PROCESS_TYPE_GPU) {
- result.push_back(MakeProcessInfo(base::GetProcId(data.handle),
+ if (data.process_type == content::PROCESS_TYPE_GPU ||
+ data.process_type == content::PROCESS_TYPE_UTILITY) {
+ result.push_back(MakeProcessInfo(base::GetProcId(data.GetHandle()),
GetChildDescription(data)));
}
}
diff --git a/chromium/chrome/browser/ui/webui/nacl_ui.cc b/chromium/chrome/browser/ui/webui/nacl_ui.cc
index 49b29dfe600..c4f9b9d6532 100644
--- a/chromium/chrome/browser/ui/webui/nacl_ui.cc
+++ b/chromium/chrome/browser/ui/webui/nacl_ui.cc
@@ -23,7 +23,7 @@
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/plugins/plugin_prefs.h"
@@ -355,7 +355,7 @@ void NaClDomHandler::MaybeRespondToPage() {
if (!pnacl_path_validated_) {
std::string* version_string = new std::string;
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&CheckPathAndVersion, version_string),
base::Bind(&NaClDomHandler::DidCheckPathAndVersion,
weak_ptr_factory_.GetWeakPtr(),
diff --git a/chromium/chrome/browser/ui/webui/net_internals/DEPS b/chromium/chrome/browser/ui/webui/net_internals/DEPS
index 060df380685..12e5f1c9cbe 100644
--- a/chromium/chrome/browser/ui/webui/net_internals/DEPS
+++ b/chromium/chrome/browser/ui/webui/net_internals/DEPS
@@ -1,5 +1,3 @@
include_rules = [
- "+components/onc",
- "+components/user_manager",
"+services/network/expect_ct_reporter.h",
]
diff --git a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
index 34960e3e654..76652731b92 100644
--- a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
@@ -211,10 +211,8 @@ class NetInternalsMessageHandler
// Called back by the CertificateImporter when a certificate import finished.
// |previous_error| contains earlier errors during this import.
- void OnCertificatesImported(
- const std::string& previous_error,
- bool success,
- net::ScopedCERTCertificateList onc_trusted_certificates);
+ void OnCertificatesImported(const std::string& previous_error,
+ bool cert_import_success);
#endif
private:
@@ -981,19 +979,21 @@ void NetInternalsMessageHandler::ImportONCFileToNSSDB(
chromeos::onc::CertificateImporterImpl cert_importer(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), nssdb);
- cert_importer.ImportCertificates(
- std::make_unique<chromeos::onc::OncParsedCertificates>(certificates),
- onc_source,
+ auto certs =
+ std::make_unique<chromeos::onc::OncParsedCertificates>(certificates);
+ if (certs->has_error())
+ error += "Some certificates couldn't be parsed. ";
+ cert_importer.ImportAllCertificatesUserInitiated(
+ certs->server_or_authority_certificates(), certs->client_certificates(),
base::Bind(&NetInternalsMessageHandler::OnCertificatesImported,
- AsWeakPtr(), error));
+ AsWeakPtr(), error /* previous_error */));
}
void NetInternalsMessageHandler::OnCertificatesImported(
const std::string& previous_error,
- bool success,
- net::ScopedCERTCertificateList /* unused onc_trusted_certificates */) {
+ bool cert_import_success) {
std::string error = previous_error;
- if (!success)
+ if (!cert_import_success)
error += "Some certificates couldn't be imported. ";
SendJavascriptCommand("receivedONCFileParse",
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 d9cac60b0b5..ff6cec6de2f 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -20,11 +20,13 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_ui_util.h"
+#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -41,6 +43,7 @@
#include "chrome/browser/ui/webui/extensions/extension_basic_info.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
+#include "chrome/browser/web_applications/extensions/bookmark_app_util.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -150,6 +153,22 @@ void AppLauncherHandler::CreateAppInfo(const Extension* extension,
service->profile())->management_policy()->UserMayModifySettings(
extension, NULL));
+ bool is_locally_installed =
+ !extension->is_hosted_app() ||
+ BookmarkAppIsLocallyInstalled(service->profile(), extension);
+ value->SetBoolean("mayChangeLaunchType",
+ !extension->is_platform_app() && is_locally_installed);
+
+#if defined(OS_MACOSX)
+ // On Mac, only packaged apps can have shortcuts created.
+ value->SetBoolean("mayCreateShortcuts", extension->is_platform_app());
+#else
+ // On other platforms, any locally installed app can have shortcuts created.
+ value->SetBoolean("mayCreateShortcuts", is_locally_installed);
+#endif
+
+ value->SetBoolean("isLocallyInstalled", is_locally_installed);
+
auto icon_size = extension_misc::EXTENSION_ICON_LARGE;
auto match_type = ExtensionIconSet::MATCH_BIGGER;
bool has_non_default_large_icon =
diff --git a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
index d59de5f9b1b..e2881420a45 100644
--- a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -58,8 +58,8 @@ NewTabUI::NewTabUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
web_ui->AddMessageHandler(std::make_unique<ThemeHandler>());
// content::URLDataSource assumes the ownership of the html source.
- content::URLDataSource::Add(
- profile, new NewTabHTMLSource(profile->GetOriginalProfile()));
+ content::URLDataSource::Add(profile, std::make_unique<NewTabHTMLSource>(
+ profile->GetOriginalProfile()));
pref_change_registrar_.Init(profile->GetPrefs());
pref_change_registrar_.Add(bookmarks::prefs::kShowBookmarkBar,
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 3c2af7b1a72..fdc50989ef1 100644
--- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -32,7 +32,7 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
-#include "components/google/core/browser/google_util.h"
+#include "components/google/core/common/google_util.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_thread.h"
diff --git a/chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc
index 29c17795b7b..62bced52475 100644
--- a/chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc
@@ -8,6 +8,10 @@
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui_data_source.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
+#endif
+
namespace policy_indicator {
struct LocalizedString {
@@ -16,8 +20,13 @@ struct LocalizedString {
};
void AddLocalizedStrings(content::WebUIDataSource* html_source) {
+ int controlled_setting_policy_id = IDS_CONTROLLED_SETTING_POLICY;
+#if defined(OS_CHROMEOS)
+ if (chromeos::DemoSession::IsDeviceInDemoMode())
+ controlled_setting_policy_id = IDS_CONTROLLED_SETTING_DEMO_SESSION;
+#endif
LocalizedString localized_strings[] = {
- {"controlledSettingPolicy", IDS_CONTROLLED_SETTING_POLICY},
+ {"controlledSettingPolicy", controlled_setting_policy_id},
{"controlledSettingRecommendedMatches", IDS_CONTROLLED_SETTING_RECOMMENDED},
{"controlledSettingRecommendedDiffers",
IDS_CONTROLLED_SETTING_HAS_RECOMMENDATION},
diff --git a/chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc
index 48ee22746b2..24cbd0bc9b0 100644
--- a/chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc
@@ -8,8 +8,8 @@
#include "base/path_service.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/task_scheduler/task_traits.h"
+#include "base/task/post_task.h"
+#include "base/task/task_traits.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
diff --git a/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc
index b7ee3b356cb..c1f1a36df59 100644
--- a/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc
@@ -9,7 +9,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/policy/schema_registry_service.h"
@@ -404,7 +404,7 @@ void PolicyToolUIHandler::HandleUpdateSession(const base::ListValue* args) {
std::string converted_values;
base::JSONWriter::Write(*policy_values, &converted_values);
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&PolicyToolUIHandler::DoUpdateSession,
base::Unretained(this), converted_values),
base::BindOnce(&PolicyToolUIHandler::OnSessionUpdated,
@@ -415,7 +415,7 @@ void PolicyToolUIHandler::HandleUpdateSession(const base::ListValue* args) {
void PolicyToolUIHandler::HandleResetSession(const base::ListValue* args) {
DCHECK_EQ(0U, args->GetSize());
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&PolicyToolUIHandler::DoUpdateSession,
base::Unretained(this), "{}"),
base::BindOnce(&PolicyToolUIHandler::OnSessionUpdated,
@@ -472,7 +472,7 @@ void PolicyToolUIHandler::WriteSessionPolicyToFile(
const std::string data = session_dict_for_exporting_;
base::PostTaskWithTraits(
FROM_HERE,
- {base::MayBlock(), base::TaskPriority::BACKGROUND,
+ {base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN},
base::BindOnce(&DoWriteSessionPolicyToFile, path, data));
}
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
index cd3a8df1cd2..db5f1afedda 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
@@ -18,8 +18,8 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/task_scheduler/task_traits.h"
+#include "base/task/post_task.h"
+#include "base/task/task_traits.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
@@ -811,7 +811,7 @@ void PolicyUIHandler::WritePoliciesToJSONFile(
base::PostTaskWithTraits(
FROM_HERE,
- {base::MayBlock(), base::TaskPriority::BACKGROUND,
+ {base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN},
base::BindOnce(&DoWritePoliciesToJSONFile, path, json_policies));
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
index 78b67d27f48..3cdb186891c 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
@@ -13,7 +13,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string_split.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "chrome/browser/printing/pwg_raster_converter.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc
index b753712af06..40f83cbaa42 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
@@ -11,7 +11,7 @@
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/values.h"
#include "chrome/browser/chromeos/printing/cups_print_job_manager.h"
#include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h"
@@ -21,6 +21,7 @@
#include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
+#include "chrome/common/pref_names.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon_client.h"
#include "chromeos/printing/ppd_provider.h"
@@ -28,6 +29,7 @@
#include "components/printing/common/printer_capabilities.h"
#include "content/public/browser/browser_thread.h"
#include "printing/backend/print_backend_consts.h"
+#include "printing/backend/printing_restrictions.h"
namespace {
@@ -59,17 +61,26 @@ void AddPrintersToList(const std::vector<chromeos::Printer>& printers,
}
}
+void CapabilitiesFetched(base::DictionaryValue policies,
+ LocalPrinterHandlerChromeos::GetCapabilityCallback cb,
+ std::unique_ptr<base::DictionaryValue> printer_info) {
+ printer_info->FindKey(printing::kPrinter)
+ ->SetKey(printing::kSettingPolicies, std::move(policies));
+ std::move(cb).Run(std::move(printer_info));
+}
+
void FetchCapabilities(std::unique_ptr<chromeos::Printer> printer,
+ base::DictionaryValue policies,
LocalPrinterHandlerChromeos::GetCapabilityCallback cb) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
printing::PrinterBasicInfo basic_info = ToBasicInfo(*printer);
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&printing::GetSettingsOnBlockingPool, printer->id(),
basic_info, nullptr),
- std::move(cb));
+ base::BindOnce(&CapabilitiesFetched, std::move(policies), std::move(cb)));
}
} // namespace
@@ -77,7 +88,8 @@ void FetchCapabilities(std::unique_ptr<chromeos::Printer> printer,
LocalPrinterHandlerChromeos::LocalPrinterHandlerChromeos(
Profile* profile,
content::WebContents* preview_web_contents)
- : preview_web_contents_(preview_web_contents),
+ : profile_(profile),
+ preview_web_contents_(preview_web_contents),
printers_manager_(
CupsPrintersManagerFactory::GetForBrowserContext(profile)),
printer_configurer_(chromeos::PrinterConfigurer::Create(profile)),
@@ -153,7 +165,7 @@ void LocalPrinterHandlerChromeos::StartGetCapability(
printer_configurer_->SetUpPrinter(
printer_ref,
base::BindOnce(&LocalPrinterHandlerChromeos::HandlePrinterSetup,
- weak_factory_.GetWeakPtr(), base::Passed(&printer),
+ weak_factory_.GetWeakPtr(), std::move(printer),
std::move(cb)));
}
@@ -164,14 +176,20 @@ void LocalPrinterHandlerChromeos::HandlePrinterSetup(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
switch (result) {
- case chromeos::PrinterSetupResult::kSuccess:
+ case chromeos::PrinterSetupResult::kSuccess: {
VLOG(1) << "Printer setup successful for " << printer->id()
<< " fetching properties";
- printers_manager_->PrinterInstalled(*printer);
+ printers_manager_->PrinterInstalled(*printer, true /*is_automatic*/);
+ // populate |policies| with policies for native printers.
+ base::DictionaryValue policies;
+ policies.SetInteger(
+ printing::kAllowedColorModes,
+ profile_->GetPrefs()->GetInteger(prefs::kPrintingAllowedColorModes));
// fetch settings on the blocking pool and invoke callback.
- FetchCapabilities(std::move(printer), std::move(cb));
+ FetchCapabilities(std::move(printer), std::move(policies), std::move(cb));
return;
+ }
case chromeos::PrinterSetupResult::kPpdNotFound:
LOG(WARNING) << "Could not find PPD. Check printer configuration.";
// Prompt user to update configuration.
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
index a846e6ffefd..07ec8698ccf 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
@@ -49,6 +49,7 @@ class LocalPrinterHandlerChromeos : public PrinterHandler {
GetCapabilityCallback cb,
chromeos::PrinterSetupResult result);
+ Profile* const profile_;
content::WebContents* const preview_web_contents_;
chromeos::CupsPrintersManager* printers_manager_;
scoped_refptr<chromeos::PpdProvider> ppd_provider_;
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 794a8d53a6c..45be6a05e11 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
@@ -9,8 +9,8 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/threading/thread_restrictions.h"
+#include "base/task/post_task.h"
+#include "base/threading/scoped_blocking_call.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
#include "components/printing/common/printer_capabilities.h"
#include "content/public/browser/browser_thread.h"
@@ -19,7 +19,7 @@
namespace {
printing::PrinterList EnumeratePrintersAsync() {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
scoped_refptr<printing::PrintBackend> print_backend(
printing::PrintBackend::CreateInstance(nullptr));
@@ -30,7 +30,7 @@ printing::PrinterList EnumeratePrintersAsync() {
std::unique_ptr<base::DictionaryValue> FetchCapabilitiesAsync(
const std::string& device_name) {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
scoped_refptr<printing::PrintBackend> print_backend(
printing::PrintBackend::CreateInstance(nullptr));
@@ -51,7 +51,7 @@ std::unique_ptr<base::DictionaryValue> FetchCapabilitiesAsync(
}
std::string GetDefaultPrinterAsync() {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
scoped_refptr<printing::PrintBackend> print_backend(
printing::PrintBackend::CreateInstance(nullptr));
@@ -74,7 +74,7 @@ void LocalPrinterHandlerDefault::GetDefaultPrinter(DefaultPrinterCallback cb) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&GetDefaultPrinterAsync), std::move(cb));
}
@@ -85,7 +85,7 @@ void LocalPrinterHandlerDefault::StartGetPrinters(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&EnumeratePrintersAsync),
base::BindOnce(&printing::ConvertPrinterListForCallback, callback,
std::move(done_callback)));
@@ -97,7 +97,7 @@ void LocalPrinterHandlerDefault::StartGetCapability(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&FetchCapabilitiesAsync, device_name), std::move(cb));
}
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 97f9d542885..ba142e10ef0 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
@@ -11,9 +11,10 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/i18n/file_util_icu.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
@@ -93,8 +94,7 @@ std::unique_ptr<base::DictionaryValue> GetPdfCapabilities(
Media default_media("", "", default_media_size.width(),
default_media_size.height());
if (!default_media.MatchBySize() ||
- std::find(kPdfMedia, kPdfMedia + arraysize(kPdfMedia),
- default_media.type) == kPdfMedia + arraysize(kPdfMedia)) {
+ !base::ContainsValue(kPdfMedia, default_media.type)) {
default_media = Media(locale == "en-US" ? NA_LETTER : ISO_A4);
}
MediaCapability media;
@@ -325,7 +325,7 @@ void PdfPrinterHandler::SelectFile(const base::FilePath& default_filename,
// returns and eventually FileSelected() gets called.
if (!prompt_user) {
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&GetUniquePath, path.Append(default_filename)),
base::Bind(&PdfPrinterHandler::OnGotUniqueFileName,
weak_ptr_factory_.GetWeakPtr()));
@@ -343,7 +343,7 @@ void PdfPrinterHandler::SelectFile(const base::FilePath& default_filename,
// save directory does not exist.
base::FilePath default_path = download_prefs->DownloadPath();
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&SelectSaveDirectory, path, default_path),
base::BindOnce(&PdfPrinterHandler::OnDirectorySelected,
weak_ptr_factory_.GetWeakPtr(), default_filename));
@@ -351,7 +351,7 @@ void PdfPrinterHandler::SelectFile(const base::FilePath& default_filename,
void PdfPrinterHandler::PostPrintToPdfTask() {
base::PostTaskWithTraits(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&PrintToPdfCallback, print_data_, print_to_pdf_path_,
pdf_file_saved_closure_));
print_to_pdf_path_.clear();
diff --git a/chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc b/chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc
new file mode 100644
index 00000000000..5177d8d0ed2
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/print_preview/policy_settings.cc
@@ -0,0 +1,18 @@
+// 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/print_preview/policy_settings.h"
+
+#include "chrome/common/pref_names.h"
+#include "components/pref_registry/pref_registry_syncable.h"
+
+namespace printing {
+
+// static
+void PolicySettings::RegisterProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(prefs::kPrintHeaderFooter, true);
+}
+
+} // namespace printing
diff --git a/chromium/chrome/browser/ui/webui/print_preview/policy_settings.h b/chromium/chrome/browser/ui/webui/print_preview/policy_settings.h
new file mode 100644
index 00000000000..a77d0782632
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/print_preview/policy_settings.h
@@ -0,0 +1,28 @@
+// 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_PRINT_PREVIEW_POLICY_SETTINGS_H_
+#define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_POLICY_SETTINGS_H_
+
+#include "base/macros.h"
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+namespace printing {
+
+// Registers the enterprise policy prefs that should be enforced in print
+// preview. These settings override other settings, and cannot be controlled by
+// the user.
+class PolicySettings {
+ public:
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(PolicySettings);
+};
+
+} // namespace printing
+
+#endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_POLICY_SETTINGS_H_
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 7ce766e59dd..8e8a5ed48ba 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
@@ -45,6 +45,7 @@
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/webui/print_preview/pdf_printer_handler.h"
+#include "chrome/browser/ui/webui/print_preview/policy_settings.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
#include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
@@ -61,6 +62,7 @@
#include "components/prefs/pref_service.h"
#include "components/printing/common/cloud_print_cdd_conversion.h"
#include "components/printing/common/print_messages.h"
+#include "components/printing/common/printer_capabilities.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "components/signin/core/browser/profile_management_switches.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
@@ -128,7 +130,7 @@ enum PrintSettingsBuckets {
HEADERS_AND_FOOTERS,
CSS_BACKGROUND,
SELECTION_ONLY,
- EXTERNAL_PDF_PREVIEW,
+ EXTERNAL_PDF_PREVIEW_UNUSED,
PAGE_RANGE,
DEFAULT_MEDIA,
NON_DEFAULT_MEDIA,
@@ -138,6 +140,9 @@ enum PrintSettingsBuckets {
SCALING,
PRINT_AS_IMAGE,
PAGES_PER_SHEET,
+ FIT_TO_PAGE,
+ DEFAULT_DPI,
+ NON_DEFAULT_DPI,
PRINT_SETTINGS_BUCKET_BOUNDARY
};
@@ -262,6 +267,12 @@ const char kAppState[] = "serializedAppStateStr";
// Name of a dictionary field holding the default destination selection rules.
const char kDefaultDestinationSelectionRules[] =
"serializedDefaultDestinationSelectionRulesStr";
+// Name of a dictionary pref holding the default value for the header/footer
+// checkbox. If set, takes priority over sticky settings.
+const char kHeaderFooter[] = "headerFooter";
+// Name of a dictionary field telling us whether the kPrintHeaderFooter pref is
+// managed by an enterprise policy.
+const char kIsHeaderFooterManaged[] = "isHeaderFooterManaged";
// Get the print job settings dictionary from |json_str|. Returns NULL on
// failure.
@@ -287,17 +298,30 @@ std::unique_ptr<base::DictionaryValue> GetSettingsDictionary(
}
// Track the popularity of print settings and report the stats.
-void ReportPrintSettingsStats(const base::DictionaryValue& settings) {
+void ReportPrintSettingsStats(const base::DictionaryValue& print_settings,
+ const base::DictionaryValue& preview_settings,
+ bool is_pdf) {
ReportPrintSettingHistogram(TOTAL);
+ // Print settings can be categorized into 2 groups: settings that are applied
+ // via preview generation (page range, selection, headers/footers, background
+ // graphics, scaling, layout, page size, pages per sheet, fit to page,
+ // margins, rasterize), and settings that are applied at the printer (color,
+ // duplex, copies, collate, dpi). The former should be captured from the most
+ // recent preview request, as some of them are set to dummy values in the
+ // print ticket. Similarly, settings applied at the printer should be pulled
+ // from the print ticket, as they may have dummy values in the preview
+ // request.
const base::ListValue* page_range_array = NULL;
- if (settings.GetList(printing::kSettingPageRange, &page_range_array) &&
+ if (preview_settings.GetList(printing::kSettingPageRange,
+ &page_range_array) &&
!page_range_array->empty()) {
ReportPrintSettingHistogram(PAGE_RANGE);
}
const base::DictionaryValue* media_size_value = NULL;
- if (settings.GetDictionary(printing::kSettingMediaSize, &media_size_value) &&
+ if (preview_settings.GetDictionary(printing::kSettingMediaSize,
+ &media_size_value) &&
!media_size_value->empty()) {
bool is_default = false;
if (media_size_value->GetBoolean(printing::kSettingMediaSizeIsDefault,
@@ -310,74 +334,94 @@ void ReportPrintSettingsStats(const base::DictionaryValue& settings) {
}
bool landscape = false;
- if (settings.GetBoolean(printing::kSettingLandscape, &landscape))
+ if (preview_settings.GetBoolean(printing::kSettingLandscape, &landscape))
ReportPrintSettingHistogram(landscape ? LANDSCAPE : PORTRAIT);
int copies = 1;
- if (settings.GetInteger(printing::kSettingCopies, &copies) && copies > 1)
+ if (print_settings.GetInteger(printing::kSettingCopies, &copies) &&
+ copies > 1) {
ReportPrintSettingHistogram(COPIES);
+ }
int scaling = 100;
- if (settings.GetInteger(printing::kSettingScaleFactor, &scaling) &&
+ if (preview_settings.GetInteger(printing::kSettingScaleFactor, &scaling) &&
scaling != 100) {
ReportPrintSettingHistogram(SCALING);
}
int pages_per_sheet = 1;
- if (settings.GetInteger(printing::kSettingPagesPerSheet, &pages_per_sheet) &&
+ if (preview_settings.GetInteger(printing::kSettingPagesPerSheet,
+ &pages_per_sheet) &&
pages_per_sheet != 1) {
ReportPrintSettingHistogram(PAGES_PER_SHEET);
}
bool collate = false;
- if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate)
+ if (print_settings.GetBoolean(printing::kSettingCollate, &collate) && collate)
ReportPrintSettingHistogram(COLLATE);
int duplex_mode = 0;
- if (settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode))
+ if (print_settings.GetInteger(printing::kSettingDuplexMode, &duplex_mode))
ReportPrintSettingHistogram(duplex_mode ? DUPLEX : SIMPLEX);
int color_mode = 0;
- if (settings.GetInteger(printing::kSettingColor, &color_mode)) {
+ if (print_settings.GetInteger(printing::kSettingColor, &color_mode)) {
ReportPrintSettingHistogram(
printing::IsColorModelSelected(color_mode) ? COLOR : BLACK_AND_WHITE);
}
int margins_type = 0;
- if (settings.GetInteger(printing::kSettingMarginsType, &margins_type) &&
+ if (preview_settings.GetInteger(printing::kSettingMarginsType,
+ &margins_type) &&
margins_type != 0) {
ReportPrintSettingHistogram(NON_DEFAULT_MARGINS);
}
bool headers = false;
- if (settings.GetBoolean(printing::kSettingHeaderFooterEnabled, &headers) &&
+ if (preview_settings.GetBoolean(printing::kSettingHeaderFooterEnabled,
+ &headers) &&
headers) {
ReportPrintSettingHistogram(HEADERS_AND_FOOTERS);
}
bool css_background = false;
- if (settings.GetBoolean(printing::kSettingShouldPrintBackgrounds,
- &css_background) && css_background) {
+ if (preview_settings.GetBoolean(printing::kSettingShouldPrintBackgrounds,
+ &css_background) &&
+ css_background) {
ReportPrintSettingHistogram(CSS_BACKGROUND);
}
bool selection_only = false;
- if (settings.GetBoolean(printing::kSettingShouldPrintSelectionOnly,
- &selection_only) && selection_only) {
+ if (preview_settings.GetBoolean(printing::kSettingShouldPrintSelectionOnly,
+ &selection_only) &&
+ selection_only) {
ReportPrintSettingHistogram(SELECTION_ONLY);
}
- bool external_preview = false;
- if (settings.GetBoolean(printing::kSettingOpenPDFInPreview,
- &external_preview) && external_preview) {
- ReportPrintSettingHistogram(EXTERNAL_PDF_PREVIEW);
- }
-
bool rasterize = false;
- if (settings.GetBoolean(printing::kSettingRasterizePdf,
- &rasterize) && rasterize) {
+ if (preview_settings.GetBoolean(printing::kSettingRasterizePdf, &rasterize) &&
+ rasterize) {
ReportPrintSettingHistogram(PRINT_AS_IMAGE);
}
+
+ bool fit_to_page = false;
+ if (is_pdf &&
+ preview_settings.GetBoolean(printing::kSettingFitToPageEnabled,
+ &fit_to_page) &&
+ fit_to_page) {
+ ReportPrintSettingHistogram(FIT_TO_PAGE);
+ }
+
+ int dpi_horizontal = 0;
+ int dpi_vertical = 0;
+ if (print_settings.GetInteger(printing::kSettingDpiHorizontal,
+ &dpi_horizontal) &&
+ print_settings.GetInteger(printing::kSettingDpiVertical, &dpi_vertical) &&
+ dpi_horizontal > 0 && dpi_vertical > 0) {
+ bool is_default = false;
+ if (print_settings.GetBoolean(printing::kSettingDpiDefault, &is_default))
+ ReportPrintSettingHistogram(is_default ? DEFAULT_DPI : NON_DEFAULT_DPI);
+ }
}
UserActionBuckets DetermineUserAction(const base::DictionaryValue& settings) {
@@ -461,10 +505,10 @@ class PrintPreviewHandler::AccessTokenService
requests_[type].callback_id = callback_id;
}
- void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
- const std::string& access_token,
- const base::Time& expiration_time) override {
- OnServiceResponse(request, access_token);
+ void OnGetTokenSuccess(
+ const OAuth2TokenService::Request* request,
+ const OAuth2AccessTokenConsumer::TokenResponse& token_response) override {
+ OnServiceResponse(request, token_response.access_token);
}
void OnGetTokenFailure(const OAuth2TokenService::Request* request,
@@ -592,6 +636,7 @@ void PrintPreviewHandler::OnJavascriptDisallowed() {
// this is necessary for refresh or navigation from the chrome://print page.
weak_factory_.InvalidateWeakPtrs();
preview_callbacks_.clear();
+ preview_failures_.clear();
UnregisterForGaiaCookieChanges();
}
@@ -599,6 +644,12 @@ WebContents* PrintPreviewHandler::preview_web_contents() const {
return web_ui()->GetWebContents();
}
+PrefService* PrintPreviewHandler::GetPrefs() const {
+ auto* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
+ DCHECK(prefs);
+ return prefs;
+}
+
PrintPreviewUI* PrintPreviewHandler::print_preview_ui() const {
return static_cast<PrintPreviewUI*>(web_ui()->GetController());
}
@@ -718,8 +769,7 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
preview_callbacks_[request_id] = callback_id;
print_preview_ui()->OnPrintPreviewRequest(request_id);
// Add an additional key in order to identify |print_preview_ui| later on
- // when calling PrintPreviewUI::GetCurrentPrintPreviewStatus() on the IO
- // thread.
+ // when calling PrintPreviewUI::ShouldCancelRequest() on the IO thread.
settings->SetInteger(printing::kPreviewUIID,
print_preview_ui()->GetIDForPrintPreviewUI());
@@ -758,6 +808,7 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
VLOG(1) << "Print preview request start";
rfh->Send(new PrintMsg_PrintPreview(rfh->GetRoutingID(), *settings));
+ last_preview_settings_ = std::move(settings);
}
void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
@@ -820,11 +871,11 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
}
// After validating |settings|, record metrics.
- ReportPrintSettingsStats(*settings);
+ bool is_pdf = !print_preview_ui()->source_is_modifiable();
+ if (last_preview_settings_)
+ ReportPrintSettingsStats(*settings, *last_preview_settings_, is_pdf);
{
- PrintDocumentTypeBuckets doc_type =
- print_preview_ui()->source_is_modifiable() ? HTML_DOCUMENT
- : PDF_DOCUMENT;
+ PrintDocumentTypeBuckets doc_type = is_pdf ? PDF_DOCUMENT : HTML_DOCUMENT;
size_t average_page_size_in_kb = data->size() / page_count;
average_page_size_in_kb /= 1024;
ReportPrintDocumentTypeAndSizeHistograms(doc_type, average_page_size_in_kb);
@@ -869,8 +920,7 @@ void PrintPreviewHandler::HandleSaveAppState(const base::ListValue* args) {
printing::StickySettings* sticky_settings = GetStickySettings();
if (args->GetString(0, &data_to_save) && !data_to_save.empty())
sticky_settings->StoreAppState(data_to_save);
- sticky_settings->SaveInPrefs(Profile::FromBrowserContext(
- preview_web_contents()->GetBrowserContext())->GetPrefs());
+ sticky_settings->SaveInPrefs(GetPrefs());
}
// |args| is expected to contain a string with representing the callback id
@@ -903,9 +953,7 @@ void PrintPreviewHandler::HandleSignin(const base::ListValue* args) {
CHECK(!callback_id.empty());
CHECK(args->GetBoolean(1, &add_account));
- Profile* profile = Profile::FromBrowserContext(
- preview_web_contents()->GetBrowserContext());
- chrome::ScopedTabbedBrowserDisplayer displayer(profile);
+ chrome::ScopedTabbedBrowserDisplayer displayer(Profile::FromWebUI(web_ui()));
print_dialog_cloud::CreateCloudPrintSigninTab(
displayer.browser(), add_account,
base::Bind(&PrintPreviewHandler::OnSigninComplete,
@@ -1025,8 +1073,7 @@ void PrintPreviewHandler::SendInitialSettings(
print_preview_ui()->source_has_selection());
initial_settings.SetBoolean(printing::kSettingShouldPrintSelectionOnly,
print_preview_ui()->print_selection_only());
- PrefService* prefs = Profile::FromBrowserContext(
- preview_web_contents()->GetBrowserContext())->GetPrefs();
+ PrefService* prefs = GetPrefs();
printing::StickySettings* sticky_settings = GetStickySettings();
sticky_settings->RestoreFromPrefs(prefs);
if (sticky_settings->printer_app_state()) {
@@ -1036,22 +1083,27 @@ void PrintPreviewHandler::SendInitialSettings(
initial_settings.SetKey(kAppState, base::Value());
}
+ if (prefs->HasPrefPath(prefs::kPrintHeaderFooter)) {
+ // Don't override sticky settings, unless kPrintHeaderFooter is actually
+ // customized.
+ initial_settings.SetBoolean(kHeaderFooter,
+ prefs->GetBoolean(prefs::kPrintHeaderFooter));
+ }
+ initial_settings.SetBoolean(
+ kIsHeaderFooterManaged,
+ prefs->IsManagedPreference(prefs::kPrintHeaderFooter));
+
base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
initial_settings.SetBoolean(kIsInKioskAutoPrintMode,
cmdline->HasSwitch(switches::kKioskModePrinting));
initial_settings.SetBoolean(kIsInAppKioskMode,
chrome::IsRunningInForcedAppMode());
- bool set_rules = false;
- if (prefs) {
- const std::string rules_str =
- prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules);
- if (!rules_str.empty()) {
- initial_settings.SetString(kDefaultDestinationSelectionRules, rules_str);
- set_rules = true;
- }
- }
- if (!set_rules) {
+ const std::string rules_str =
+ prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules);
+ if (rules_str.empty()) {
initial_settings.SetKey(kDefaultDestinationSelectionRules, base::Value());
+ } else {
+ initial_settings.SetString(kDefaultDestinationSelectionRules, rules_str);
}
GetNumberFormatAndMeasurementSystem(&initial_settings);
@@ -1097,6 +1149,14 @@ void PrintPreviewHandler::SendPrinterSetup(
destination_info->Remove(printing::kSettingCapabilities, &caps_value) &&
caps_value->is_dict()) {
caps = base::DictionaryValue::From(std::move(caps_value));
+ base::Value* printer = destination_info->FindKeyOfType(
+ printing::kPrinter, base::Value::Type::DICTIONARY);
+ if (printer) {
+ base::Value* policies_value = printer->FindKeyOfType(
+ printing::kSettingPolicies, base::Value::Type::DICTIONARY);
+ if (policies_value)
+ response->SetKey("policies", std::move(*policies_value));
+ }
} else {
LOG(WARNING) << "Printer setup failed";
success = false;
@@ -1110,9 +1170,7 @@ void PrintPreviewHandler::SendPrinterSetup(
}
void PrintPreviewHandler::SendCloudPrintEnabled() {
- Profile* profile = Profile::FromBrowserContext(
- preview_web_contents()->GetBrowserContext());
- PrefService* prefs = profile->GetPrefs();
+ PrefService* prefs = GetPrefs();
if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled) &&
!base::FeatureList::IsEnabled(features::kCloudPrinterHandler)) {
FireWebUIListener(
@@ -1169,6 +1227,10 @@ void PrintPreviewHandler::OnPrintPreviewFailed(int request_id) {
reported_failed_preview_ = true;
ReportUserActionHistogram(PREVIEW_FAILED);
}
+
+ // Keep track of failures.
+ bool inserted = preview_failures_.insert(request_id).second;
+ DCHECK(inserted);
RejectJavascriptCallback(base::Value(callback_id),
base::Value("PREVIEW_FAILED"));
}
@@ -1194,8 +1256,8 @@ void PrintPreviewHandler::SendPrintPresetOptions(bool disable_scaling,
}
void PrintPreviewHandler::SendPageCountReady(int page_count,
- int request_id,
- int fit_to_page_scaling) {
+ int fit_to_page_scaling,
+ int request_id) {
if (!ShouldReceiveRendererMessage(request_id))
return;
@@ -1216,12 +1278,19 @@ void PrintPreviewHandler::SendPageLayoutReady(
void PrintPreviewHandler::SendPagePreviewReady(int page_index,
int preview_uid,
- int preview_response_id) {
- if (!ShouldReceiveRendererMessage(preview_response_id))
+ int preview_request_id) {
+ // With print compositing, by the time compositing finishes and this method
+ // gets called, the print preview may have failed. Since the failure message
+ // may have arrived first, check for this case and bail out instead of
+ // thinking this may be a bad IPC message.
+ if (base::ContainsKey(preview_failures_, preview_request_id))
+ return;
+
+ if (!ShouldReceiveRendererMessage(preview_request_id))
return;
FireWebUIListener("page-preview-ready", base::Value(page_index),
- base::Value(preview_uid), base::Value(preview_response_id));
+ base::Value(preview_uid), base::Value(preview_request_id));
}
void PrintPreviewHandler::OnPrintPreviewCancelled(int request_id) {
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 a6b34ca8b66..88a08b47aaf 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
@@ -7,6 +7,7 @@
#include <map>
#include <memory>
+#include <set>
#include <string>
#include "base/files/file_path.h"
@@ -92,8 +93,8 @@ class PrintPreviewHandler
// Send the print preview page count and fit to page scaling
void SendPageCountReady(int page_count,
- int request_id,
- int fit_to_page_scaling);
+ int fit_to_page_scaling,
+ int request_id);
// Send the default page layout
void SendPageLayoutReady(const base::DictionaryValue& layout,
@@ -103,7 +104,7 @@ class PrintPreviewHandler
// Notify the WebUI that the page preview is ready.
void SendPagePreviewReady(int page_index,
int preview_uid,
- int preview_response_id);
+ int preview_request_id);
int regenerate_preview_request_count() const {
return regenerate_preview_request_count_;
@@ -144,7 +145,11 @@ class PrintPreviewHandler
FRIEND_TEST_ALL_PREFIXES(PrintPreviewPdfGeneratedBrowserTest,
MANUAL_DummyTest);
friend class PrintPreviewHandlerTest;
- FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, InitialSettings);
+ FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, InitialSettingsSimple);
+ FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest,
+ InitialSettingsEnableHeaderFooter);
+ FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest,
+ InitialSettingsDisableHeaderFooter);
FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, GetPrinters);
FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, GetPrinterCapabilities);
FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, Print);
@@ -156,6 +161,8 @@ class PrintPreviewHandler
PrintPreviewUI* print_preview_ui() const;
+ PrefService* GetPrefs() const;
+
// Whether the the handler should be receiving messages from the renderer to
// forward to the Print Preview JS in response to preview request with id
// |request_id|. Kills the renderer if the handler should not be receiving
@@ -317,6 +324,9 @@ class PrintPreviewHandler
// Whether we have already logged the number of printers this session.
bool has_logged_printers_count_;
+ // The settings used for the most recent preview request.
+ std::unique_ptr<base::DictionaryValue> last_preview_settings_;
+
// Holds token service to get OAuth2 access tokens.
std::unique_ptr<AccessTokenService> token_service_;
@@ -347,6 +357,9 @@ class PrintPreviewHandler
// Maps preview request ids to callbacks.
std::map<int, std::string> preview_callbacks_;
+ // Set of preview request ids for failed previews.
+ std::set<int> preview_failures_;
+
base::WeakPtrFactory<PrintPreviewHandler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler);
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
index 7e4bffcd685..bc7888c8133 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
@@ -10,18 +10,24 @@
#include "base/base64.h"
#include "base/containers/flat_set.h"
+#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/optional.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/icu_test_util.h"
#include "base/values.h"
#include "chrome/browser/printing/print_test_utils.h"
#include "chrome/browser/printing/print_view_manager.h"
+#include "chrome/browser/ui/webui/print_preview/policy_settings.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/prefs/pref_service.h"
#include "components/printing/common/print_messages.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_controller.h"
@@ -318,14 +324,16 @@ class PrintPreviewHandlerTest : public testing::Test {
// Validates the initial settings structure in the response matches the
// print_preview.NativeInitialSettings type in
- // chrome/browser/resources/print_preview/native_layer.js. Checks that
- // |default_printer_name| is the printer name returned and that
- // |initiator_title| is the initiator title returned and validates that
- // delimeters are correct for "en" locale (set in Initialize()). Assumes
- // "test-callback-id-0" was used as the callback id.
+ // chrome/browser/resources/print_preview/native_layer.js. Checks that:
+ // - |default_printer_name| is the printer name returned
+ // - |initiator_title| is the initiator title returned
+ // - |expected_header_footer| is the header/footer state returned, if any
+ // Also validates that delimeters are correct for "en" locale (set in
+ // Initialize()). Assumes "test-callback-id-0" was used as the callback id.
void ValidateInitialSettings(const content::TestWebUI::CallData& data,
const std::string& default_printer_name,
- const std::string& initiator_title) {
+ const std::string& initiator_title,
+ base::Optional<bool> expected_header_footer) {
CheckWebUIResponse(data, "test-callback-id-0", true);
const base::Value* settings = data.arg3();
ASSERT_TRUE(settings->FindKeyOfType("isInKioskAutoPrintMode",
@@ -358,6 +366,12 @@ class PrintPreviewHandlerTest : public testing::Test {
settings->FindKeyOfType("printerName", base::Value::Type::STRING);
ASSERT_TRUE(printer);
EXPECT_EQ(default_printer_name, printer->GetString());
+
+ const base::Value* header_footer =
+ settings->FindKeyOfType("headerFooter", base::Value::Type::BOOLEAN);
+ EXPECT_EQ(bool(expected_header_footer), bool(header_footer));
+ if (expected_header_footer)
+ EXPECT_EQ(*expected_header_footer, header_footer->GetBool());
}
IPC::TestSink& initiator_sink() {
@@ -385,6 +399,7 @@ class PrintPreviewHandlerTest : public testing::Test {
}
const Profile* profile() { return profile_.get(); }
+ PrefService* prefs() { return profile_->GetPrefs(); }
content::TestWebUI* web_ui() { return web_ui_.get(); }
printing::TestPrintPreviewHandler* handler() { return handler_; }
printing::TestPrinterHandler* printer_handler() { return printer_handler_; }
@@ -404,18 +419,36 @@ class PrintPreviewHandlerTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandlerTest);
};
-TEST_F(PrintPreviewHandlerTest, InitialSettings) {
+TEST_F(PrintPreviewHandlerTest, InitialSettingsSimple) {
Initialize();
// Verify initial settings were sent.
ValidateInitialSettings(*web_ui()->call_data().back(),
printing::kDummyPrinterName,
- printing::kDummyInitiatorName);
+ printing::kDummyInitiatorName, base::nullopt);
// Check that the use-cloud-print event got sent
AssertWebUIEventFired(*web_ui()->call_data().front(), "use-cloud-print");
}
+TEST_F(PrintPreviewHandlerTest, InitialSettingsEnableHeaderFooter) {
+ // Set a pref that should take priority over StickySettings.
+ prefs()->SetBoolean(prefs::kPrintHeaderFooter, true);
+ Initialize();
+ ValidateInitialSettings(
+ *web_ui()->call_data().back(), printing::kDummyPrinterName,
+ printing::kDummyInitiatorName, base::Optional<bool>(true));
+}
+
+TEST_F(PrintPreviewHandlerTest, InitialSettingsDisableHeaderFooter) {
+ // Set a pref that should take priority over StickySettings.
+ prefs()->SetBoolean(prefs::kPrintHeaderFooter, false);
+ Initialize();
+ ValidateInitialSettings(
+ *web_ui()->call_data().back(), printing::kDummyPrinterName,
+ printing::kDummyInitiatorName, base::Optional<bool>(false));
+}
+
TEST_F(PrintPreviewHandlerTest, GetPrinters) {
Initialize();
@@ -636,7 +669,7 @@ TEST_F(PrintPreviewHandlerTest, SendPreviewUpdates) {
AssertWebUIEventFired(*web_ui()->call_data().back(), "page-layout-ready");
// 1 page document. Modifiable so send default 100 scaling.
- handler()->SendPageCountReady(1, preview_request_id, 100);
+ handler()->SendPageCountReady(1, 100, preview_request_id);
AssertWebUIEventFired(*web_ui()->call_data().back(), "page-count-ready");
// Page at index 0 is ready.
@@ -656,7 +689,7 @@ TEST_F(PrintPreviewHandlerTest, SendPreviewUpdates) {
handler()->SendPageLayoutReady(base::DictionaryValue(), false,
preview_request_id);
EXPECT_EQ(message_count, web_ui()->call_data().size());
- handler()->SendPageCountReady(1, 0, -1);
+ handler()->SendPageCountReady(1, -1, 0);
EXPECT_EQ(message_count, web_ui()->call_data().size());
handler()->OnPrintPreviewReady(0, 0);
EXPECT_EQ(message_count, web_ui()->call_data().size());
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 4d571af9601..8ecdea6626f 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
@@ -46,8 +46,8 @@
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/common/content_features.h"
#include "extensions/common/constants.h"
-#include "printing/buildflags/buildflags.h"
#include "printing/page_size_margins.h"
#include "printing/print_job_constants.h"
#include "ui/base/l10n/l10n_util.h"
@@ -431,7 +431,7 @@ void SetupPrintPreviewPlugin(content::WebUIDataSource* source) {
source->AddResourcePath("pdf/index.html", IDR_PDF_INDEX_HTML);
source->AddResourcePath("pdf/index.css", IDR_PDF_INDEX_CSS);
source->AddResourcePath("pdf/main.js", IDR_PDF_MAIN_JS);
- source->AddResourcePath("pdf/pdf.js", IDR_PDF_PDF_JS);
+ source->AddResourcePath("pdf/pdf_viewer.js", IDR_PDF_PDF_VIEWER_JS);
source->AddResourcePath("pdf/toolbar_manager.js", IDR_PDF_UI_MANAGER_JS);
source->AddResourcePath("pdf/pdf_fitting_type.js",
IDR_PDF_PDF_FITTING_TYPE_JS);
@@ -528,6 +528,10 @@ content::WebUIDataSource* CreateNewPrintPreviewUISource(Profile* profile) {
#if BUILDFLAG(OPTIMIZE_WEBUI)
source->AddResourcePath("crisper.js", IDR_PRINT_PREVIEW_CRISPER_JS);
source->SetDefaultResource(IDR_PRINT_PREVIEW_VULCANIZED_HTML);
+ source->SetDefaultResource(
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2) ?
+ IDR_PRINT_PREVIEW_VULCANIZED_P2_HTML :
+ IDR_PRINT_PREVIEW_VULCANIZED_HTML);
#else
for (size_t i = 0; i < kPrintPreviewResourcesSize; ++i) {
source->AddResourcePath(kPrintPreviewResources[i].name,
@@ -553,6 +557,14 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) {
return source;
}
+PrintPreviewHandler* CreatePrintPreviewHandlers(content::WebUI* web_ui) {
+ auto handler = std::make_unique<PrintPreviewHandler>();
+ PrintPreviewHandler* handler_ptr = handler.get();
+ web_ui->AddMessageHandler(std::move(handler));
+ web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
+ return handler_ptr;
+}
+
} // namespace
PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui,
@@ -560,12 +572,7 @@ PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui,
: ConstrainedWebDialogUI(web_ui),
initial_preview_start_time_(base::TimeTicks::Now()),
id_(g_print_preview_ui_id_map.Get().Add(this)),
- handler_(nullptr),
- source_is_modifiable_(true),
- source_has_selection_(false),
- print_selection_only_(false),
- dialog_closed_(false) {
- handler_ = handler.get();
+ handler_(handler.get()) {
web_ui->AddMessageHandler(std::move(handler));
g_print_preview_request_id_map.Get().Set(id_, -1);
@@ -575,11 +582,7 @@ PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui)
: ConstrainedWebDialogUI(web_ui),
initial_preview_start_time_(base::TimeTicks::Now()),
id_(g_print_preview_ui_id_map.Get().Add(this)),
- handler_(nullptr),
- source_is_modifiable_(true),
- source_has_selection_(false),
- print_selection_only_(false),
- dialog_closed_(false) {
+ handler_(CreatePrintPreviewHandlers(web_ui)) {
// Set up the chrome://print/ data source.
Profile* profile = Profile::FromWebUI(web_ui);
@@ -594,12 +597,7 @@ PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui)
}
// Set up the chrome://theme/ source.
- content::URLDataSource::Add(profile, new ThemeSource(profile));
-
- auto handler = std::make_unique<PrintPreviewHandler>();
- handler_ = handler.get();
- web_ui->AddMessageHandler(std::move(handler));
- web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
+ content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
g_print_preview_request_id_map.Get().Set(id_, -1);
}
@@ -646,15 +644,11 @@ void PrintPreviewUI::SetInitialParams(
}
// static
-void PrintPreviewUI::GetCurrentPrintPreviewStatus(
- const PrintHostMsg_PreviewIds& ids,
- bool* cancel) {
+bool PrintPreviewUI::ShouldCancelRequest(const PrintHostMsg_PreviewIds& ids) {
int current_id = -1;
- if (!g_print_preview_request_id_map.Get().Get(ids.ui_id, &current_id)) {
- *cancel = true;
- return;
- }
- *cancel = (ids.request_id != current_id);
+ if (!g_print_preview_request_id_map.Get().Get(ids.ui_id, &current_id))
+ return true;
+ return ids.request_id != current_id;
}
int32_t PrintPreviewUI::GetIDForPrintPreviewUI() const {
@@ -699,14 +693,14 @@ void PrintPreviewUI::OnPrintPreviewRequest(int request_id) {
g_print_preview_request_id_map.Get().Set(id_, request_id);
}
-void PrintPreviewUI::OnDidGetPreviewPageCount(
- const PrintHostMsg_DidGetPreviewPageCount_Params& params,
+void PrintPreviewUI::OnDidStartPreview(
+ const PrintHostMsg_DidStartPreview_Params& params,
int request_id) {
DCHECK_GT(params.page_count, 0);
if (g_testing_delegate)
g_testing_delegate->DidGetPreviewPageCount(params.page_count);
- handler_->SendPageCountReady(params.page_count, request_id,
- params.fit_to_page_scaling);
+ handler_->SendPageCountReady(params.page_count, params.fit_to_page_scaling,
+ request_id);
}
void PrintPreviewUI::OnDidGetDefaultPageLayout(
@@ -818,7 +812,7 @@ void PrintPreviewUI::SetDelegateForTesting(TestingDelegate* delegate) {
}
void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) {
- handler_->FileSelectedForTesting(path, 0, NULL);
+ handler_->FileSelectedForTesting(path, 0, nullptr);
}
void PrintPreviewUI::SetPdfSavedClosureForTesting(
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 336b9b82b34..6fc3581f8a8 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
@@ -15,10 +15,9 @@
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
-#include "printing/buildflags/buildflags.h"
class PrintPreviewHandler;
-struct PrintHostMsg_DidGetPreviewPageCount_Params;
+struct PrintHostMsg_DidStartPreview_Params;
struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_RequestPrintPreview_Params;
struct PrintHostMsg_SetOptionsFromDocument_Params;
@@ -76,10 +75,9 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
const PrintHostMsg_RequestPrintPreview_Params& params);
// Determines whether to cancel a print preview request based on the request
- // and ui ids in |ids|.
+ // and UI ids in |ids|.
// Can be called from any thread.
- static void GetCurrentPrintPreviewStatus(const PrintHostMsg_PreviewIds& ids,
- bool* cancel);
+ static bool ShouldCancelRequest(const PrintHostMsg_PreviewIds& ids);
// Returns an id to uniquely identify this PrintPreviewUI.
int32_t GetIDForPrintPreviewUI() const;
@@ -87,10 +85,9 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
// Notifies the Web UI of a print preview request with |request_id|.
virtual void OnPrintPreviewRequest(int request_id);
- // Notifies the Web UI about the page count of the request preview.
- void OnDidGetPreviewPageCount(
- const PrintHostMsg_DidGetPreviewPageCount_Params& params,
- int request_id);
+ // Notifies the Web UI about the properties of the request preview.
+ void OnDidStartPreview(const PrintHostMsg_DidStartPreview_Params& params,
+ int request_id);
// Notifies the Web UI of the default page layout according to the currently
// selected printer and page size.
@@ -184,24 +181,24 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
const int32_t id_;
// Weak pointer to the WebUI handler.
- PrintPreviewHandler* handler_;
+ PrintPreviewHandler* const handler_;
// Indicates whether the source document can be modified.
- bool source_is_modifiable_;
+ bool source_is_modifiable_ = true;
// Indicates whether the source document has selection.
- bool source_has_selection_;
+ bool source_has_selection_ = false;
// Indicates whether only the selection should be printed.
- bool print_selection_only_;
+ bool print_selection_only_ = false;
+
+ // Keeps track of whether OnClosePrintPreviewDialog() has been called or not.
+ bool dialog_closed_ = false;
// Store the initiator title, used for populating the print preview dialog
// title.
base::string16 initiator_title_;
- // Keeps track of whether OnClosePrintPreviewDialog() has been called or not.
- bool dialog_closed_;
-
DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI);
};
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
index 4f8c3977135..b06ab2b7aa0 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
@@ -31,7 +31,7 @@ namespace {
scoped_refptr<base::RefCountedBytes> CreateTestData() {
const unsigned char blob1[] =
- "12346102356120394751634516591348710478123649165419234519234512349134";
+ "%PDF-1.4123461023561203947516345165913487104781236491654192345192345";
std::vector<unsigned char> preview_data(blob1, blob1 + sizeof(blob1));
return base::MakeRefCounted<base::RefCountedBytes>(preview_data);
}
@@ -105,11 +105,6 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewData) {
EXPECT_EQ(dummy_data->size(), data->size());
EXPECT_EQ(dummy_data.get(), data.get());
- // This should not cause any memory leaks.
- dummy_data = base::MakeRefCounted<base::RefCountedBytes>();
- preview_ui->SetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX,
- dummy_data.get());
-
// Clear the preview data.
preview_ui->ClearAllPreviewData();
@@ -180,7 +175,7 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewDraftPages) {
}
// Test the browser-side print preview cancellation functionality.
-TEST_F(PrintPreviewUIUnitTest, GetCurrentPrintPreviewStatus) {
+TEST_F(PrintPreviewUIUnitTest, ShouldCancelRequest) {
WebContents* initiator = browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(initiator);
@@ -201,38 +196,21 @@ TEST_F(PrintPreviewUIUnitTest, GetCurrentPrintPreviewStatus) {
preview_dialog->GetWebUI()->GetController());
ASSERT_TRUE(preview_ui);
- // Test with invalid |preview_ui_addr|.
- bool cancel = false;
+ // Test with invalid UI ID.
const int32_t kInvalidId = -5;
- preview_ui->GetCurrentPrintPreviewStatus(
- PrintHostMsg_PreviewIds(0, kInvalidId), &cancel);
- EXPECT_TRUE(cancel);
+ EXPECT_TRUE(preview_ui->ShouldCancelRequest({0, kInvalidId}));
const int kFirstRequestId = 1000;
const int kSecondRequestId = 1001;
- const int32_t preview_ui_addr = preview_ui->GetIDForPrintPreviewUI();
+ const int32_t preview_id = preview_ui->GetIDForPrintPreviewUI();
// Test with kFirstRequestId.
preview_ui->OnPrintPreviewRequest(kFirstRequestId);
- cancel = true;
- preview_ui->GetCurrentPrintPreviewStatus(
- PrintHostMsg_PreviewIds(kFirstRequestId, preview_ui_addr), &cancel);
- EXPECT_FALSE(cancel);
-
- cancel = false;
- preview_ui->GetCurrentPrintPreviewStatus(
- PrintHostMsg_PreviewIds(kSecondRequestId, preview_ui_addr), &cancel);
- EXPECT_TRUE(cancel);
+ EXPECT_FALSE(preview_ui->ShouldCancelRequest({kFirstRequestId, preview_id}));
+ EXPECT_TRUE(preview_ui->ShouldCancelRequest({kSecondRequestId, preview_id}));
// Test with kSecondRequestId.
preview_ui->OnPrintPreviewRequest(kSecondRequestId);
- cancel = false;
- preview_ui->GetCurrentPrintPreviewStatus(
- PrintHostMsg_PreviewIds(kFirstRequestId, preview_ui_addr), &cancel);
- EXPECT_TRUE(cancel);
-
- cancel = true;
- preview_ui->GetCurrentPrintPreviewStatus(
- PrintHostMsg_PreviewIds(kSecondRequestId, preview_ui_addr), &cancel);
- EXPECT_FALSE(cancel);
+ EXPECT_TRUE(preview_ui->ShouldCancelRequest({kFirstRequestId, preview_id}));
+ EXPECT_FALSE(preview_ui->ShouldCancelRequest({kSecondRequestId, preview_id}));
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc
index 77e5b23a2f3..746d0370739 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/privet_printer_handler.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
#include "chrome/common/chrome_switches.h"
#include "services/identity/public/cpp/identity_manager.h"
+#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "ui/gfx/geometry/size.h"
namespace {
@@ -140,7 +141,7 @@ void PrivetPrinterHandler::StartLister(
service_discovery_client_.get() == client.get());
service_discovery_client_ = client;
printer_lister_ = std::make_unique<cloud_print::PrivetLocalPrinterLister>(
- service_discovery_client_.get(), profile_->GetRequestContext(), this);
+ service_discovery_client_.get(), profile_->GetURLLoaderFactory(), this);
privet_lister_timer_ = std::make_unique<base::OneShotTimer>();
privet_lister_timer_->Start(FROM_HERE,
base::TimeDelta::FromSeconds(kSearchTimeoutSec),
@@ -274,7 +275,7 @@ void PrivetPrinterHandler::CreateHTTP(
privet_http_factory_ =
cloud_print::PrivetHTTPAsynchronousFactory::CreateInstance(
- profile_->GetRequestContext());
+ profile_->GetURLLoaderFactory());
privet_http_resolution_ = privet_http_factory_->CreatePrivetHTTP(name);
privet_http_resolution_->Start(device_description->address, callback);
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/sticky_settings.cc b/chromium/chrome/browser/ui/webui/print_preview/sticky_settings.cc
index e69c53e94b9..1d303aa5549 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/sticky_settings.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/sticky_settings.cc
@@ -4,10 +4,7 @@
#include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
-#include <memory>
-
#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
@@ -33,18 +30,19 @@ void StickySettings::StoreAppState(const std::string& data) {
}
void StickySettings::SaveInPrefs(PrefService* prefs) const {
- auto value = std::make_unique<base::DictionaryValue>();
+ base::Value dict(base::Value::Type::DICTIONARY);
if (printer_app_state_)
- value->SetString(kSettingAppState, printer_app_state_.value());
- prefs->Set(prefs::kPrintPreviewStickySettings, *value);
+ dict.SetKey(kSettingAppState, base::Value(*printer_app_state_));
+ prefs->Set(prefs::kPrintPreviewStickySettings, dict);
}
void StickySettings::RestoreFromPrefs(PrefService* prefs) {
const base::DictionaryValue* value =
prefs->GetDictionary(prefs::kPrintPreviewStickySettings);
- std::string buffer;
- if (value->GetString(kSettingAppState, &buffer))
- StoreAppState(buffer);
+ const base::Value* app_state =
+ value->FindKeyOfType(kSettingAppState, base::Value::Type::STRING);
+ if (app_state)
+ StoreAppState(app_state->GetString());
}
// static
diff --git a/chromium/chrome/browser/ui/webui/profile_helper.cc b/chromium/chrome/browser/ui/webui/profile_helper.cc
index 45e7d87e804..c980bfa5740 100644
--- a/chromium/chrome/browser/ui/webui/profile_helper.cc
+++ b/chromium/chrome/browser/ui/webui/profile_helper.cc
@@ -35,7 +35,7 @@ void ShowUserManager(const ProfileManager::CreateCallback& callback) {
g_browser_process->profile_manager()->CreateProfileAsync(
ProfileManager::GetSystemProfilePath(), callback, base::string16(),
- std::string(), std::string());
+ std::string());
}
std::string GetProfileUserName(Profile* profile) {
diff --git a/chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc b/chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc
index 37f4e959945..5c56ff86b96 100644
--- a/chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/profile_helper_browsertest.cc
@@ -36,7 +36,7 @@ Profile* CreateProfile() {
base::RunLoop run_loop;
profile_manager->CreateProfileAsync(
new_path, base::Bind(&UnblockOnProfileCreation, &run_loop),
- base::string16(), std::string(), std::string());
+ base::string16(), std::string());
run_loop.Run();
return profile_manager->GetProfileByPath(new_path);
}
diff --git a/chromium/chrome/browser/ui/webui/quota_internals/OWNERS b/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
index 6fb5954d8c9..af949556e32 100644
--- a/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
@@ -1,5 +1,6 @@
tzik@chromium.org
jsbell@chromium.org
+pwnall@chromium.org
# TEAM: storage-dev@chromium.org
# COMPONENT: Blink>Storage>Quota
diff --git a/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc
index c13d5fb59d5..268c322613d 100644
--- a/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc
+++ b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/ui/webui/reset_password/reset_password_ui.h"
-#include "base/metrics/histogram_functions.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
@@ -32,12 +32,12 @@ constexpr char kStringTypeUMAName[] = "PasswordProtection.InterstitialString";
// Used for UMA metric logging. Please don't reorder.
// Indicates which type of strings are shown on this page.
-enum StringType {
+enum class StringType {
GENERIC_NO_ORG_NAME = 0,
GENERIC_WITH_ORG_NAME = 1,
WARNING_NO_ORG_NAME = 2,
WARNING_WITH_ORG_NAME = 3,
- STRING_TYPE_COUNT,
+ kMaxValue = WARNING_WITH_ORG_NAME,
};
// Implementation of mojom::ResetPasswordHander.
@@ -62,10 +62,9 @@ class ResetPasswordHandlerImpl : public mojom::ResetPasswordHandler {
safe_browsing::ChromePasswordProtectionService* service = safe_browsing::
ChromePasswordProtectionService::GetPasswordProtectionService(profile);
if (service) {
- service->OnUserAction(
- web_contents_, password_type_,
- safe_browsing::PasswordProtectionService::INTERSTITIAL,
- safe_browsing::PasswordProtectionService::CHANGE_PASSWORD);
+ service->OnUserAction(web_contents_, password_type_,
+ safe_browsing::WarningUIType::INTERSTITIAL,
+ safe_browsing::WarningAction::CHANGE_PASSWORD);
}
}
@@ -106,17 +105,15 @@ base::string16 GetFormattedHostName(const std::string host_name) {
} // namespace
ResetPasswordUI::ResetPasswordUI(content::WebUI* web_ui)
- : ui::MojoWebUIController(web_ui) {
- base::DictionaryValue load_time_data;
- password_type_ = GetPasswordType(web_ui->GetWebContents());
- PopulateStrings(web_ui->GetWebContents(), &load_time_data);
+ : ui::MojoWebUIController(web_ui),
+ password_type_(GetPasswordType(web_ui->GetWebContents())) {
std::unique_ptr<content::WebUIDataSource> html_source(
content::WebUIDataSource::Create(chrome::kChromeUIResetPasswordHost));
html_source->AddResourcePath("reset_password.js", IDR_RESET_PASSWORD_JS);
html_source->AddResourcePath("reset_password.mojom.js",
IDR_RESET_PASSWORD_MOJO_JS);
html_source->SetDefaultResource(IDR_RESET_PASSWORD_HTML);
- html_source->AddLocalizedStrings(load_time_data);
+ html_source->AddLocalizedStrings(PopulateStrings());
html_source->UseGzip();
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
@@ -134,21 +131,18 @@ void ResetPasswordUI::BindResetPasswordHandler(
web_ui()->GetWebContents(), password_type_, std::move(request));
}
-void ResetPasswordUI::PopulateStrings(content::WebContents* web_contents,
- base::DictionaryValue* load_time_data) {
+base::DictionaryValue ResetPasswordUI::PopulateStrings() const {
std::string org_name =
safe_browsing::ChromePasswordProtectionService::
- GetPasswordProtectionService(
- Profile::FromBrowserContext(web_contents->GetBrowserContext()))
+ GetPasswordProtectionService(Profile::FromWebUI(web_ui()))
->GetOrganizationName(password_type_);
bool known_password_type =
password_type_ !=
safe_browsing::PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN;
if (!known_password_type) {
- base::UmaHistogramEnumeration(
+ UMA_HISTOGRAM_ENUMERATION(
safe_browsing::kInterstitialActionByUserNavigationHistogram,
- safe_browsing::PasswordProtectionService::SHOWN,
- safe_browsing::PasswordProtectionService::MAX_ACTION);
+ safe_browsing::WarningAction::SHOWN);
}
int heading_string_id = known_password_type
? IDS_RESET_PASSWORD_WARNING_HEADING
@@ -158,10 +152,10 @@ void ResetPasswordUI::PopulateStrings(content::WebContents* web_contents,
explanation_paragraph_string = l10n_util::GetStringUTF16(
known_password_type ? IDS_RESET_PASSWORD_WARNING_EXPLANATION_PARAGRAPH
: IDS_RESET_PASSWORD_EXPLANATION_PARAGRAPH);
- base::UmaHistogramEnumeration(
- kStringTypeUMAName,
- known_password_type ? WARNING_NO_ORG_NAME : GENERIC_NO_ORG_NAME,
- STRING_TYPE_COUNT);
+ UMA_HISTOGRAM_ENUMERATION(kStringTypeUMAName,
+ known_password_type
+ ? StringType::WARNING_NO_ORG_NAME
+ : StringType::GENERIC_NO_ORG_NAME);
} else {
base::string16 formatted_org_name = GetFormattedHostName(org_name);
explanation_paragraph_string = l10n_util::GetStringFUTF16(
@@ -169,18 +163,19 @@ void ResetPasswordUI::PopulateStrings(content::WebContents* web_contents,
? IDS_RESET_PASSWORD_WARNING_EXPLANATION_PARAGRAPH_WITH_ORG_NAME
: IDS_RESET_PASSWORD_EXPLANATION_PARAGRAPH_WITH_ORG_NAME,
formatted_org_name);
- base::UmaHistogramEnumeration(
- kStringTypeUMAName,
- known_password_type ? WARNING_WITH_ORG_NAME : GENERIC_WITH_ORG_NAME,
- STRING_TYPE_COUNT);
+ UMA_HISTOGRAM_ENUMERATION(kStringTypeUMAName,
+ known_password_type
+ ? StringType::WARNING_WITH_ORG_NAME
+ : StringType::GENERIC_WITH_ORG_NAME);
}
- load_time_data->SetString(
- "title", l10n_util::GetStringUTF16(IDS_RESET_PASSWORD_TITLE));
- load_time_data->SetString("heading",
- l10n_util::GetStringUTF16(heading_string_id));
- load_time_data->SetString("primaryParagraph", explanation_paragraph_string);
- load_time_data->SetString(
- "primaryButtonText",
- l10n_util::GetStringUTF16(IDS_RESET_PASSWORD_BUTTON));
+ base::DictionaryValue load_time_data;
+ load_time_data.SetString("title",
+ l10n_util::GetStringUTF16(IDS_RESET_PASSWORD_TITLE));
+ load_time_data.SetString("heading",
+ l10n_util::GetStringUTF16(heading_string_id));
+ load_time_data.SetString("primaryParagraph", explanation_paragraph_string);
+ load_time_data.SetString("primaryButtonText", l10n_util::GetStringUTF16(
+ IDS_RESET_PASSWORD_BUTTON));
+ return load_time_data;
}
diff --git a/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h
index 3519b553200..3f299695d7d 100644
--- a/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h
+++ b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h
@@ -14,10 +14,6 @@ namespace base {
class DictionaryValue;
}
-namespace content {
-class WebContents;
-}
-
// The WebUI for chrome://reset-password/.
class ResetPasswordUI : public ui::MojoWebUIController {
public:
@@ -27,11 +23,10 @@ class ResetPasswordUI : public ui::MojoWebUIController {
private:
void BindResetPasswordHandler(mojom::ResetPasswordHandlerRequest request);
- void PopulateStrings(content::WebContents* web_content,
- base::DictionaryValue* load_time_data);
+ base::DictionaryValue PopulateStrings() const;
std::unique_ptr<mojom::ResetPasswordHandler> ui_handler_;
- safe_browsing::ReusedPasswordType password_type_;
+ const safe_browsing::ReusedPasswordType password_type_;
DISALLOW_COPY_AND_ASSIGN(ResetPasswordUI);
};
diff --git a/chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc b/chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc
index ea2ef9b4a88..0bab7ef7139 100644
--- a/chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc
@@ -41,7 +41,14 @@ static void SetSandboxStatusData(content::WebUIDataSource* source) {
status & service_manager::SandboxLinux::kSeccompBPF);
source->AddBoolean("seccompTsync",
status & service_manager::SandboxLinux::kSeccompTSYNC);
- source->AddBoolean("yama", status & service_manager::SandboxLinux::kYama);
+ source->AddBoolean("yamaBroker",
+ status & service_manager::SandboxLinux::kYama);
+
+ // Yama does not enforce in user namespaces.
+ bool enforcing_yama_nonbroker =
+ status & service_manager::SandboxLinux::kYama &&
+ !(status & service_manager::SandboxLinux::kUserNS);
+ source->AddBoolean("yamaNonbroker", enforcing_yama_nonbroker);
// Require either the setuid or namespace sandbox for our first-layer sandbox.
bool good_layer1 = (status & service_manager::SandboxLinux::kSUID ||
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
index 6a343a20086..06c2c95e34e 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
@@ -20,7 +20,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
@@ -30,14 +30,14 @@
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
-#include "chrome/browser/upgrade_detector.h"
+#include "chrome/browser/upgrade_detector/upgrade_detector.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "components/google/core/browser/google_util.h"
+#include "components/google/core/common/google_util.h"
#include "components/policy/core/common/policy_namespace.h"
#include "components/policy/policy_constants.h"
#include "components/strings/grit/components_chromium_strings.h"
@@ -284,11 +284,9 @@ AboutHandler* AboutHandler::Create(content::WebUIDataSource* html_source,
? IDS_VERSION_UI_OFFICIAL
: IDS_VERSION_UI_UNOFFICIAL),
base::UTF8ToUTF16(chrome::GetChannelName()),
-#if defined(ARCH_CPU_64_BITS)
- l10n_util::GetStringUTF16(IDS_VERSION_UI_64BIT)));
-#else
- l10n_util::GetStringUTF16(IDS_VERSION_UI_32BIT)));
-#endif
+ l10n_util::GetStringUTF16(sizeof(void*) == 8
+ ? IDS_VERSION_UI_64BIT
+ : IDS_VERSION_UI_32BIT)));
html_source->AddString(
"aboutProductCopyright",
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.h b/chromium/chrome/browser/ui/webui/settings/about_handler.h
index 4c8ae08a292..6395f3060ef 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.h
@@ -15,7 +15,7 @@
#include "build/build_config.h"
#include "chrome/browser/ui/webui/help/version_updater.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "chrome/browser/upgrade_observer.h"
+#include "chrome/browser/upgrade_detector/upgrade_observer.h"
#include "components/policy/core/common/policy_service.h"
#include "content/public/browser/web_ui_message_handler.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
index dd9e351b7e1..5d5acfd7aed 100644
--- a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
@@ -30,9 +30,8 @@ void TriggerTPMFirmwareUpdate(
using chromeos::tpm_firmware_update::Mode;
// Decide which update mode to use.
- // TODO(crbug.com/854576): Re-add Mode::kPreserveDeviceState after fixing
- // interrupted update flow issue described in the bug.
- for (Mode mode : {Mode::kPowerwash}) {
+ for (Mode mode :
+ {Mode::kPreserveDeviceState, Mode::kPowerwash, Mode::kCleanup}) {
if (available_modes.count(mode) == 0) {
continue;
}
diff --git a/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc b/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc
index 090962aebcf..01225cba2aa 100644
--- a/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/change_password_handler.cc
@@ -52,12 +52,11 @@ void ChangePasswordHandler::HandleInitialize(const base::ListValue* args) {
}
void ChangePasswordHandler::HandleChangePassword(const base::ListValue* args) {
- service_->OnUserAction(
- web_ui()->GetWebContents(),
- safe_browsing::LoginReputationClientRequest::PasswordReuseEvent::
- SIGN_IN_PASSWORD,
- safe_browsing::PasswordProtectionService::CHROME_SETTINGS,
- safe_browsing::PasswordProtectionService::CHANGE_PASSWORD);
+ service_->OnUserAction(web_ui()->GetWebContents(),
+ safe_browsing::LoginReputationClientRequest::
+ PasswordReuseEvent::SIGN_IN_PASSWORD,
+ safe_browsing::WarningUIType::CHROME_SETTINGS,
+ safe_browsing::WarningAction::CHANGE_PASSWORD);
}
void ChangePasswordHandler::UpdateChangePasswordCardVisibility() {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
index 44240697552..56f573121d0 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -37,6 +38,14 @@ void AccessibilityHandler::RegisterMessages() {
"showSwitchAccessSettings",
base::BindRepeating(&AccessibilityHandler::HandleShowSwitchAccessSettings,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getStartupSoundEnabled",
+ base::BindRepeating(&AccessibilityHandler::HandleGetStartupSoundEnabled,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "setStartupSoundEnabled",
+ base::BindRepeating(&AccessibilityHandler::HandleSetStartupSoundEnabled,
+ base::Unretained(this)));
}
void AccessibilityHandler::HandleShowChromeVoxSettings(
@@ -54,6 +63,22 @@ void AccessibilityHandler::HandleShowSwitchAccessSettings(
OpenExtensionOptionsPage(extension_misc::kSwitchAccessExtensionId);
}
+void AccessibilityHandler::HandleGetStartupSoundEnabled(
+ const base::ListValue* args) {
+ AllowJavascript();
+ FireWebUIListener(
+ "startup-sound-enabled-updated",
+ base::Value(AccessibilityManager::Get()->GetStartupSoundEnabled()));
+}
+
+void AccessibilityHandler::HandleSetStartupSoundEnabled(
+ const base::ListValue* args) {
+ DCHECK_EQ(1U, args->GetSize());
+ bool enabled;
+ args->GetBoolean(0, &enabled);
+ AccessibilityManager::Get()->SetStartupSoundEnabled(enabled);
+}
+
void AccessibilityHandler::OpenExtensionOptionsPage(const char extension_id[]) {
const extensions::Extension* extension =
extensions::ExtensionRegistry::Get(profile_)->GetExtensionById(
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h
index d03c83e2ea6..26f284ad260 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h
@@ -37,6 +37,8 @@ class AccessibilityHandler : public ::settings::SettingsPageUIHandler {
void HandleShowChromeVoxSettings(const base::ListValue* args);
void HandleShowSelectToSpeakSettings(const base::ListValue* args);
void HandleShowSwitchAccessSettings(const base::ListValue* args);
+ void HandleGetStartupSoundEnabled(const base::ListValue* args);
+ void HandleSetStartupSoundEnabled(const base::ListValue* args);
void OpenExtensionOptionsPage(const char extension_id[]);
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 66d0c0748cd..125e1427992 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
@@ -25,11 +25,36 @@
namespace chromeos {
namespace settings {
+namespace {
+
+AccountManager::AccountKey GetAccountKeyFromJsCallback(
+ const base::DictionaryValue* const dictionary) {
+ const base::Value* id_value = dictionary->FindKey("id");
+ DCHECK(id_value);
+ const std::string id = id_value->GetString();
+ DCHECK(!id.empty());
+
+ const base::Value* account_type_value = dictionary->FindKey("accountType");
+ DCHECK(account_type_value);
+ const int account_type_int = account_type_value->GetInt();
+ DCHECK((account_type_int >=
+ account_manager::AccountType::ACCOUNT_TYPE_UNSPECIFIED) &&
+ (account_type_int <=
+ account_manager::AccountType::ACCOUNT_TYPE_ACTIVE_DIRECTORY));
+ const account_manager::AccountType account_type =
+ static_cast<account_manager::AccountType>(account_type_int);
+
+ return AccountManager::AccountKey{id, account_type};
+}
+
+} // namespace
+
AccountManagerUIHandler::AccountManagerUIHandler(
AccountManager* account_manager,
AccountTrackerService* account_tracker_service)
: account_manager_(account_manager),
account_tracker_service_(account_tracker_service),
+ account_mapper_util_(account_tracker_service_),
weak_factory_(this) {
DCHECK(account_manager_);
DCHECK(account_tracker_service_);
@@ -52,6 +77,10 @@ void AccountManagerUIHandler::RegisterMessages() {
"addAccount",
base::BindRepeating(&AccountManagerUIHandler::HandleAddAccount,
weak_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "removeAccount",
+ base::BindRepeating(&AccountManagerUIHandler::HandleRemoveAccount,
+ weak_factory_.GetWeakPtr()));
}
void AccountManagerUIHandler::HandleGetAccounts(const base::ListValue* args) {
@@ -92,23 +121,25 @@ void AccountManagerUIHandler::GetAccountsCallbackHandler(
}
base::DictionaryValue account;
+ account.SetString("id", account_key.id);
+ account.SetInteger("accountType", account_key.account_type);
+ account.SetBoolean("isDeviceAccount", false);
account.SetString("fullName", account_info.full_name);
account.SetString("email", account_info.email);
gfx::Image icon =
account_tracker_service_->GetAccountImage(account_info.account_id);
account.SetString("pic", webui::GetBitmapDataUrl(icon.AsBitmap()));
- // |account_key| is a GAIA account and hence |id| is the obfuscated GAIA id
- // (see |AccountManager::AccountKey|)
- if (account_key.id != device_account_id.GetGaiaId()) {
- accounts.GetList().push_back(std::move(account));
- } else {
+ if (account_mapper_util_.IsEqual(account_key, device_account_id)) {
device_account = std::move(account);
+ } else {
+ accounts.GetList().push_back(std::move(account));
}
}
// Device account must show up at the top.
if (!device_account.empty()) {
+ device_account.SetBoolean("isDeviceAccount", true);
accounts.GetList().insert(accounts.GetList().begin(),
std::move(device_account));
}
@@ -121,6 +152,27 @@ void AccountManagerUIHandler::HandleAddAccount(const base::ListValue* args) {
InlineLoginHandlerDialogChromeOS::Show();
}
+void AccountManagerUIHandler::HandleRemoveAccount(const base::ListValue* args) {
+ AllowJavascript();
+
+ const base::DictionaryValue* dictionary = nullptr;
+ args->GetList()[0].GetAsDictionary(&dictionary);
+ DCHECK(dictionary);
+
+ const AccountId device_account_id =
+ ProfileHelper::Get()
+ ->GetUserByProfile(Profile::FromWebUI(web_ui()))
+ ->GetAccountId();
+ const AccountManager::AccountKey account_key =
+ GetAccountKeyFromJsCallback(dictionary);
+ if (account_mapper_util_.IsEqual(account_key, device_account_id)) {
+ // It should not be possible to remove a device account.
+ return;
+ }
+
+ account_manager_->RemoveAccount(account_key);
+}
+
void AccountManagerUIHandler::OnJavascriptAllowed() {}
void AccountManagerUIHandler::OnJavascriptDisallowed() {}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
index 078a51cb189..b1b0b4a6a00 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/account_mapper_util.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/account_manager/account_manager.h"
#include "components/signin/core/browser/account_tracker_service.h"
@@ -51,6 +52,9 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler,
// WebUI "addAccount" message callback.
void HandleAddAccount(const base::ListValue* args);
+ // WebUI "removeAccount" message callback.
+ void HandleRemoveAccount(const base::ListValue* args);
+
// |AccountManager::GetAccounts| callback.
void GetAccountsCallbackHandler(
base::Value callback_id,
@@ -65,6 +69,8 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler,
// A non-owning pointer to |AccountTrackerService|.
AccountTrackerService* const account_tracker_service_;
+ chromeos::AccountMapperUtil account_mapper_util_;
+
base::WeakPtrFactory<AccountManagerUIHandler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AccountManagerUIHandler);
};
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 3c61e3ba330..cb6f001014e 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
@@ -15,7 +15,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -322,7 +322,8 @@ void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) {
"kUserNativePrintersAllowed is set to false";
// Used to log UMA metrics.
OnAddedPrinterCommon(printer,
- PrinterSetupResult::kNativePrintersNotAllowed);
+ PrinterSetupResult::kNativePrintersNotAllowed,
+ false);
// Used to fire the web UI listener.
OnAddPrinterError(PrinterSetupResult::kNativePrintersNotAllowed);
return;
@@ -495,7 +496,8 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
"kUserNativePrintersAllowed is set to false";
// Used to log UMA metrics.
OnAddedPrinterCommon(*printer,
- PrinterSetupResult::kNativePrintersNotAllowed);
+ PrinterSetupResult::kNativePrintersNotAllowed,
+ false);
// Used to fire the web UI listener.
OnAddPrinterError(PrinterSetupResult::kNativePrintersNotAllowed);
return;
@@ -588,7 +590,8 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
}
void CupsPrintersHandler::OnAddedPrinterCommon(const Printer& printer,
- PrinterSetupResult result_code) {
+ PrinterSetupResult result_code,
+ bool is_automatic) {
UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterSetupResult", result_code,
PrinterSetupResult::kMaxValue);
switch (result_code) {
@@ -596,7 +599,7 @@ void CupsPrintersHandler::OnAddedPrinterCommon(const Printer& printer,
UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterAdded",
printer.GetProtocol(), Printer::kProtocolMax);
PRINTER_LOG(USER) << "Performing printer setup";
- printers_manager_->PrinterInstalled(printer);
+ printers_manager_->PrinterInstalled(printer, is_automatic);
printers_manager_->UpdateConfiguredPrinter(printer);
return;
case PrinterSetupResult::kPpdNotFound:
@@ -641,7 +644,7 @@ void CupsPrintersHandler::OnAddedPrinterCommon(const Printer& printer,
void CupsPrintersHandler::OnAddedDiscoveredPrinter(
const Printer& printer,
PrinterSetupResult result_code) {
- OnAddedPrinterCommon(printer, result_code);
+ OnAddedPrinterCommon(printer, result_code, true);
if (result_code == PrinterSetupResult::kSuccess) {
FireWebUIListener("on-add-cups-printer", base::Value(result_code),
base::Value(printer.display_name()));
@@ -657,7 +660,7 @@ void CupsPrintersHandler::OnAddedSpecifiedPrinter(
const Printer& printer,
PrinterSetupResult result_code) {
PRINTER_LOG(EVENT) << "Add manual printer: " << result_code;
- OnAddedPrinterCommon(printer, result_code);
+ OnAddedPrinterCommon(printer, result_code, false);
FireWebUIListener("on-add-cups-printer", base::Value(result_code),
base::Value(printer.display_name()));
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
index 447eecb1d69..741b87e13db 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
@@ -138,7 +138,8 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
// Code common between the discovered and manual add printer code paths.
void OnAddedPrinterCommon(const Printer& printer,
- PrinterSetupResult result_code);
+ PrinterSetupResult result_code,
+ bool is_automatic);
// CupsPrintersManager::Observer override:
void OnPrintersChanged(CupsPrintersManager::PrinterClass printer_class,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
index a54f351b8b7..be85dd83362 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
@@ -14,18 +14,32 @@
#include "content/public/browser/web_ui.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"
+#include "ui/chromeos/events/event_rewriter_chromeos.h"
#include "ui/events/devices/input_device_manager.h"
namespace {
-bool HasExternalKeyboard() {
+struct KeyboardsStateResult {
+ bool has_external_non_apple_keyboard = false;
+ bool has_apple_keyboard = false;
+};
+
+KeyboardsStateResult GetKeyboardsState() {
+ KeyboardsStateResult result;
for (const ui::InputDevice& keyboard :
ui::InputDeviceManager::GetInstance()->GetKeyboardDevices()) {
- if (keyboard.type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)
- return true;
+ const ui::EventRewriterChromeOS::DeviceType type =
+ ui::EventRewriterChromeOS::GetDeviceType(keyboard);
+ if (type == ui::EventRewriterChromeOS::kDeviceAppleKeyboard) {
+ result.has_apple_keyboard = true;
+ } else if (type ==
+ ui::EventRewriterChromeOS::kDeviceExternalNonAppleKeyboard ||
+ type == ui::EventRewriterChromeOS::kDeviceExternalUnknown) {
+ result.has_external_non_apple_keyboard = true;
+ }
}
- return false;
+ return result;
}
} // namespace
@@ -115,14 +129,25 @@ void KeyboardHandler::UpdateKeyboards() {
void KeyboardHandler::UpdateShowKeys() {
// kHasChromeOSKeyboard will be unset on Chromebooks that have standalone Caps
// Lock keys.
- const base::Value has_caps_lock(
- HasExternalKeyboard() ||
- !base::CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kHasChromeOSKeyboard));
- const base::Value has_diamond_key(
+ const KeyboardsStateResult keyboards_state = GetKeyboardsState();
+ const bool has_caps_lock = keyboards_state.has_apple_keyboard ||
+ keyboards_state.has_external_non_apple_keyboard ||
+ !base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kHasChromeOSKeyboard);
+ const bool has_diamond_key =
base::CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kHasChromeOSDiamondKey));
- FireWebUIListener(kShowKeysChangedName, has_caps_lock, has_diamond_key);
+ chromeos::switches::kHasChromeOSDiamondKey);
+
+ base::Value keyboard_params(base::Value::Type::DICTIONARY);
+ keyboard_params.SetKey("showCapsLock", base::Value(has_caps_lock));
+ keyboard_params.SetKey("showDiamondKey", base::Value(has_diamond_key));
+ keyboard_params.SetKey(
+ "showExternalMetaKey",
+ base::Value(keyboards_state.has_external_non_apple_keyboard));
+ keyboard_params.SetKey("showAppleCommandKey",
+ base::Value(keyboards_state.has_apple_keyboard));
+
+ FireWebUIListener(kShowKeysChangedName, keyboard_params);
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc
index c875a4480ff..7fd0854ab0a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc
@@ -12,7 +12,7 @@
#include "base/observer_list.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/test/test_web_ui.h"
-#include "services/ui/public/cpp/input_devices/input_device_client_test_api.h"
+#include "services/ws/public/cpp/input_devices/input_device_client_test_api.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/devices/input_device.h"
@@ -45,7 +45,9 @@ class KeyboardHandlerTest : public testing::Test {
// which keys should be shown. False is returned if the message was invalid or
// not found.
bool GetLastShowKeysChangedMessage(bool* has_caps_lock_out,
- bool* has_diamond_key_out)
+ bool* has_diamond_key_out,
+ bool* has_external_meta_key_out,
+ bool* has_apple_command_key_out)
WARN_UNUSED_RESULT {
for (auto it = web_ui_.call_data().rbegin();
it != web_ui_.call_data().rend(); ++it) {
@@ -56,8 +58,29 @@ class KeyboardHandlerTest : public testing::Test {
name != KeyboardHandler::kShowKeysChangedName) {
continue;
}
- return data->arg2()->GetAsBoolean(has_caps_lock_out) &&
- data->arg3()->GetAsBoolean(has_diamond_key_out);
+
+ if (!data->arg2() ||
+ data->arg2()->type() != base::Value::Type::DICTIONARY) {
+ return false;
+ }
+
+ const base::Value* keyboard_params = data->arg2();
+ const std::vector<std::pair<std::string, bool*>> path_to_out_param = {
+ {"showCapsLock", has_caps_lock_out},
+ {"showDiamondKey", has_diamond_key_out},
+ {"showExternalMetaKey", has_external_meta_key_out},
+ {"showAppleCommandKey", has_apple_command_key_out},
+ };
+
+ for (const auto& pair : path_to_out_param) {
+ auto* found = keyboard_params->FindKey(pair.first);
+ if (!found)
+ return false;
+
+ *(pair.second) = found->GetBool();
+ }
+
+ return true;
}
return false;
}
@@ -66,8 +89,10 @@ class KeyboardHandlerTest : public testing::Test {
// is present and false otherwise. A failure is added if a message wasn't
// found.
bool HasCapsLock() {
- bool has_caps_lock = false, has_diamond_key = false;
- if (!GetLastShowKeysChangedMessage(&has_caps_lock, &has_diamond_key)) {
+ bool has_caps_lock = false;
+ bool ignored = false;
+ if (!GetLastShowKeysChangedMessage(&has_caps_lock, &ignored, &ignored,
+ &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false;
}
@@ -78,15 +103,45 @@ class KeyboardHandlerTest : public testing::Test {
// is present and false otherwise. A failure is added if a message wasn't
// found.
bool HasDiamondKey() {
- bool has_caps_lock = false, has_diamond_key = false;
- if (!GetLastShowKeysChangedMessage(&has_caps_lock, &has_diamond_key)) {
+ bool has_diamond_key = false;
+ bool ignored = false;
+ if (!GetLastShowKeysChangedMessage(&ignored, &has_diamond_key, &ignored,
+ &ignored)) {
ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
return false;
}
return has_diamond_key;
}
- ui::InputDeviceClientTestApi input_device_client_test_api_;
+ // Returns true if the last keys-changed message reported that a Meta key on
+ // an external keyboard is present and false otherwise. A failure is added if
+ // a message wasn't found.
+ bool HasExternalMetaKey() {
+ bool has_external_meta = false;
+ bool ignored = false;
+ if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &has_external_meta,
+ &ignored)) {
+ ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
+ return false;
+ }
+ return has_external_meta;
+ }
+
+ // Returns true if the last keys-changed message reported that a Command key
+ // on an Apple keyboard is present and false otherwise. A failure is added if
+ // a message wasn't found.
+ bool HasAppleCommandKey() {
+ bool has_apple_command_key = false;
+ bool ignored = false;
+ if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored,
+ &has_apple_command_key)) {
+ ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName;
+ return false;
+ }
+ return has_apple_command_key;
+ }
+
+ ws::InputDeviceClientTestApi input_device_client_test_api_;
content::TestWebUI web_ui_;
TestKeyboardHandler handler_;
KeyboardHandler::TestAPI handler_test_api_;
@@ -101,6 +156,8 @@ TEST_F(KeyboardHandlerTest, DefaultKeys) {
handler_test_api_.Initialize();
EXPECT_FALSE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
+ EXPECT_FALSE(HasExternalMetaKey());
+ EXPECT_FALSE(HasAppleCommandKey());
}
TEST_F(KeyboardHandlerTest, NonChromeOSKeyboard) {
@@ -109,6 +166,8 @@ TEST_F(KeyboardHandlerTest, NonChromeOSKeyboard) {
handler_test_api_.Initialize();
EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
+ EXPECT_FALSE(HasExternalMetaKey());
+ EXPECT_FALSE(HasAppleCommandKey());
}
TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
@@ -120,18 +179,54 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
handler_test_api_.Initialize();
EXPECT_FALSE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
+ EXPECT_FALSE(HasExternalMetaKey());
+ EXPECT_FALSE(HasAppleCommandKey());
// Simulate an external keyboard being connected. We should assume there's a
- // Caps Lock key now.
+ // Caps Lock and Meta keys now.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{2, ui::INPUT_DEVICE_EXTERNAL, "external keyboard"}});
EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
+ EXPECT_TRUE(HasExternalMetaKey());
+ EXPECT_FALSE(HasAppleCommandKey());
+
+ // Simulate an external Apple keyboard being connected. Now users can remap
+ // the command key.
+ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
+ {3, ui::INPUT_DEVICE_EXTERNAL, "Apple Inc. Apple Keyboard"}});
+ EXPECT_TRUE(HasCapsLock());
+ EXPECT_FALSE(HasDiamondKey());
+ EXPECT_FALSE(HasExternalMetaKey());
+ EXPECT_TRUE(HasAppleCommandKey());
+
+ // Simulate two external keyboards (Apple and non-Apple) are connected at the
+ // same time.
+ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
+ {2, ui::INPUT_DEVICE_EXTERNAL, "external keyboard"},
+ {3, ui::INPUT_DEVICE_EXTERNAL, "Apple Inc. Apple Keyboard"}});
+ EXPECT_TRUE(HasCapsLock());
+ EXPECT_FALSE(HasDiamondKey());
+ EXPECT_TRUE(HasExternalMetaKey());
+ EXPECT_TRUE(HasAppleCommandKey());
+
+ // Some keyboard devices don't report the string "keyboard" as part of their
+ // device names. Those should also be detcted as external keyboards, and
+ // should show the capslock and external meta remapping.
+ // https://crbug.com/834594.
+ input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
+ {4, ui::INPUT_DEVICE_EXTERNAL, "Topre Corporation Realforce 87"}});
+ EXPECT_TRUE(HasCapsLock());
+ EXPECT_FALSE(HasDiamondKey());
+ EXPECT_TRUE(HasExternalMetaKey());
+ EXPECT_FALSE(HasAppleCommandKey());
// Disconnect the external keyboard and check that the key goes away.
input_device_client_test_api_.SetKeyboardDevices({});
EXPECT_FALSE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
+ EXPECT_FALSE(HasExternalMetaKey());
+ EXPECT_FALSE(HasAppleCommandKey());
}
TEST_F(KeyboardHandlerTest, DiamondKey) {
@@ -142,6 +237,8 @@ TEST_F(KeyboardHandlerTest, DiamondKey) {
handler_test_api_.Initialize();
EXPECT_FALSE(HasCapsLock());
EXPECT_TRUE(HasDiamondKey());
+ EXPECT_FALSE(HasExternalMetaKey());
+ EXPECT_FALSE(HasAppleCommandKey());
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
index 9b221939c81..cf29c548765 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
@@ -11,7 +11,7 @@
#include "base/files/file_util.h"
#include "base/sys_info.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browsing_data/browsing_data_appcache_helper.h"
#include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h"
@@ -187,7 +187,7 @@ void StorageHandler::UpdateDownloadsSize() {
file_manager::util::GetDownloadsFolderForProfile(profile_);
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&base::ComputeDirectorySize, downloads_path),
base::Bind(&StorageHandler::OnGetDownloadsSize,
weak_ptr_factory_.GetWeakPtr()));
@@ -363,7 +363,7 @@ void StorageHandler::UpdateOtherUsersSize() {
continue;
other_users_.push_back(user);
DBusThreadManager::Get()->GetCryptohomeClient()->GetAccountDiskUsage(
- cryptohome::Identification(user->GetAccountId()),
+ cryptohome::CreateAccountIdentifierFromAccountId(user->GetAccountId()),
base::BindOnce(&StorageHandler::OnGetOtherUserSize,
weak_ptr_factory_.GetWeakPtr()));
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
index 95fdc49d9a7..7058fb6c087 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
@@ -55,13 +55,13 @@ std::unique_ptr<base::DictionaryValue> GetFingerprintsInfo(
} // namespace
FingerprintHandler::FingerprintHandler(Profile* profile)
- : profile_(profile), binding_(this), weak_ptr_factory_(this) {
+ : profile_(profile),
+ binding_(this),
+ session_observer_(this),
+ weak_ptr_factory_(this) {
service_manager::Connector* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
connector->BindInterface(device::mojom::kServiceName, &fp_service_);
- device::mojom::FingerprintObserverPtr observer;
- binding_.Bind(mojo::MakeRequest(&observer));
- fp_service_->AddFingerprintObserver(std::move(observer));
user_id_ = ProfileHelper::Get()->GetUserIdHashFromProfile(profile);
}
@@ -110,12 +110,16 @@ void FingerprintHandler::RegisterMessages() {
void FingerprintHandler::OnJavascriptAllowed() {
// SessionManager may not exist in some tests.
if (SessionManager::Get())
- SessionManager::Get()->AddObserver(this);
+ session_observer_.Add(SessionManager::Get());
+
+ device::mojom::FingerprintObserverPtr observer;
+ binding_.Bind(mojo::MakeRequest(&observer));
+ fp_service_->AddFingerprintObserver(std::move(observer));
}
void FingerprintHandler::OnJavascriptDisallowed() {
- if (SessionManager::Get())
- SessionManager::Get()->RemoveObserver(this);
+ session_observer_.RemoveAll();
+ binding_.Close();
}
void FingerprintHandler::OnRestarted() {}
@@ -123,6 +127,10 @@ void FingerprintHandler::OnRestarted() {}
void FingerprintHandler::OnEnrollScanDone(uint32_t scan_result,
bool enroll_session_complete,
int percent_complete) {
+ VLOG(1) << "Receive fingerprint enroll scan result. scan_result="
+ << scan_result
+ << ", enroll_session_complete=" << enroll_session_complete
+ << ", percent_complete=" << percent_complete;
auto scan_attempt = std::make_unique<base::DictionaryValue>();
scan_attempt->SetInteger("result", scan_result);
scan_attempt->SetBoolean("isComplete", enroll_session_complete);
@@ -134,6 +142,8 @@ void FingerprintHandler::OnEnrollScanDone(uint32_t scan_result,
void FingerprintHandler::OnAuthScanDone(
uint32_t scan_result,
const base::flat_map<std::string, std::vector<std::string>>& matches) {
+ VLOG(1) << "Receive fingerprint auth scan result. scan_result="
+ << scan_result;
if (SessionManager::Get()->session_state() == SessionState::LOCKED)
return;
@@ -160,7 +170,9 @@ void FingerprintHandler::OnAuthScanDone(
FireWebUIListener("on-fingerprint-attempt-received", *fingerprint_attempt);
}
-void FingerprintHandler::OnSessionFailed() {}
+void FingerprintHandler::OnSessionFailed() {
+ LOG(ERROR) << "Fingerprint session failed.";
+}
void FingerprintHandler::OnSessionStateChanged() {
SessionState state = SessionManager::Get()->session_state();
@@ -214,6 +226,8 @@ void FingerprintHandler::HandleGetNumFingerprints(const base::ListValue* args) {
}
void FingerprintHandler::HandleStartEnroll(const base::ListValue* args) {
+ AllowJavascript();
+
// Determines what the newly added fingerprint's name should be.
for (int i = 1; i <= kMaxAllowedFingerprints; ++i) {
std::string fingerprint_name = l10n_util::GetStringFUTF8(
@@ -228,6 +242,7 @@ void FingerprintHandler::HandleStartEnroll(const base::ListValue* args) {
void FingerprintHandler::HandleCancelCurrentEnroll(
const base::ListValue* args) {
+ AllowJavascript();
fp_service_->CancelCurrentEnrollSession(
base::Bind(&FingerprintHandler::OnCancelCurrentEnrollSession,
weak_ptr_factory_.GetWeakPtr()));
@@ -307,11 +322,13 @@ void FingerprintHandler::OnSetRecordLabel(const std::string& callback_id,
void FingerprintHandler::HandleStartAuthentication(
const base::ListValue* args) {
+ AllowJavascript();
fp_service_->StartAuthSession();
}
void FingerprintHandler::HandleEndCurrentAuthentication(
const base::ListValue* args) {
+ AllowJavascript();
fp_service_->EndCurrentAuthSession(
base::Bind(&FingerprintHandler::OnEndCurrentAuthSession,
weak_ptr_factory_.GetWeakPtr()));
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
index d3518f18970..db0c60aec42 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FINGERPRINT_HANDLER_H_
#include "base/containers/flat_map.h"
+#include "base/scoped_observer.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/session_manager/core/session_manager_observer.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -17,6 +18,10 @@ namespace base {
class ListValue;
} // namespace base
+namespace session_manager {
+class SessionManager;
+} // namespace session_manager
+
namespace chromeos {
namespace settings {
@@ -76,6 +81,9 @@ class FingerprintHandler : public ::settings::SettingsPageUIHandler,
device::mojom::FingerprintPtr fp_service_;
mojo::Binding<device::mojom::FingerprintObserver> binding_;
+ ScopedObserver<session_manager::SessionManager,
+ session_manager::SessionManagerObserver>
+ session_observer_;
base::WeakPtrFactory<FingerprintHandler> weak_ptr_factory_;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
index f9263067b4a..ee3fc39b648 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc
@@ -6,11 +6,16 @@
#include <utility>
+#include "ash/public/interfaces/assistant_controller.mojom.h"
+#include "ash/public/interfaces/constants.mojom.h"
#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chromeos/chromeos_switches.h"
#include "components/arc/arc_service_manager.h"
+#include "content/public/browser/browser_context.h"
+#include "services/service_manager/public/cpp/connector.h"
#include "ui/gfx/geometry/rect.h"
namespace chromeos {
@@ -72,6 +77,16 @@ void GoogleAssistantHandler::HandleSetGoogleAssistantContextEnabled(
void GoogleAssistantHandler::HandleShowGoogleAssistantSettings(
const base::ListValue* args) {
+ if (chromeos::switches::IsAssistantEnabled()) {
+ // Opens Google Assistant settings.
+ service_manager::Connector* connector =
+ content::BrowserContext::GetConnectorFor(profile_);
+ ash::mojom::AssistantControllerPtr assistant_controller;
+ connector->BindInterface(ash::mojom::kServiceName, &assistant_controller);
+ assistant_controller->OpenAssistantSettings();
+ return;
+ }
+
auto* service =
arc::ArcVoiceInteractionFrameworkService::GetForBrowserContext(profile_);
if (service)
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
index 8dc3a46c55f..7a4c8bed26e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
@@ -21,6 +21,7 @@
#include "components/arc/arc_service_manager.h"
#include "components/arc/common/net.mojom.h"
#include "components/arc/connection_holder.h"
+#include "components/arc/metrics/arc_metrics_constants.h"
#include "components/onc/onc_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -186,16 +187,16 @@ void InternetHandler::ConfigureThirdPartyVpn(const base::ListValue* args) {
return;
}
- if (network->vpn_provider_type() == shill::kProviderThirdPartyVpn) {
+ if (network->GetVpnProviderType() == shill::kProviderThirdPartyVpn) {
// Request that the third-party VPN provider used by the |network| show a
// configuration dialog for it.
VpnServiceFactory::GetForBrowserContext(profile_)
- ->SendShowConfigureDialogToExtension(network->vpn_provider_id(),
+ ->SendShowConfigureDialogToExtension(network->vpn_provider()->id,
network->name());
return;
}
- if (network->vpn_provider_type() == shill::kProviderArcVpn) {
+ if (network->GetVpnProviderType() == shill::kProviderArcVpn) {
auto* net_instance = ARC_GET_INSTANCE_FOR_METHOD(
arc::ArcServiceManager::Get()->arc_bridge_service()->net(),
ConfigureAndroidVpn);
@@ -208,7 +209,7 @@ void InternetHandler::ConfigureThirdPartyVpn(const base::ListValue* args) {
}
NET_LOG(ERROR) << "ConfigureThirdPartyVpn: Unsupported VPN type: "
- << network->vpn_provider_type() << " For: " << guid;
+ << network->GetVpnProviderType() << " For: " << guid;
}
void InternetHandler::RequestArcVpnProviders(const base::ListValue* args) {
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 ca84973cd35..36ef94d7f31 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
@@ -7,24 +7,101 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
+#include "chrome/browser/chromeos/multidevice_setup/android_sms_app_helper_delegate_impl.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h"
+#include "chromeos/components/proximity_auth/logging/logging.h"
#include "content/public/browser/web_ui.h"
namespace chromeos {
namespace settings {
-MultideviceHandler::MultideviceHandler() = default;
-MultideviceHandler::~MultideviceHandler() = default;
+namespace {
-void MultideviceHandler::OnJavascriptAllowed() {}
-void MultideviceHandler::OnJavascriptDisallowed() {}
+const char kPageContentDataModeKey[] = "mode";
+const char kPageContentDataHostDeviceNameKey[] = "hostDeviceName";
+const char kPageContentDataBetterTogetherStateKey[] = "betterTogetherState";
+const char kPageContentDataInstantTetheringStateKey[] = "instantTetheringState";
+const char kPageContentDataMessagesStateKey[] = "messagesState";
+const char kPageContentDataSmartLockStateKey[] = "smartLockState";
+
+void OnRetrySetHostNowResult(bool success) {
+ if (success)
+ return;
+
+ PA_LOG(WARNING) << "OnRetrySetHostNowResult(): Attempt to retry setting the "
+ << "host device failed.";
+}
+
+} // namespace
+
+MultideviceHandler::MultideviceHandler(
+ multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client,
+ std::unique_ptr<multidevice_setup::AndroidSmsAppHelperDelegate>
+ android_sms_app_helper)
+ : multidevice_setup_client_(multidevice_setup_client),
+ android_sms_app_helper_(std::move(android_sms_app_helper)),
+ multidevice_setup_observer_(this),
+ callback_weak_ptr_factory_(this) {}
+
+MultideviceHandler::~MultideviceHandler() {}
void MultideviceHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"showMultiDeviceSetupDialog",
base::BindRepeating(&MultideviceHandler::HandleShowMultiDeviceSetupDialog,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getPageContentData",
+ base::BindRepeating(&MultideviceHandler::HandleGetPageContent,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "setFeatureEnabledState",
+ base::BindRepeating(&MultideviceHandler::HandleSetFeatureEnabledState,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "removeHostDevice",
+ base::BindRepeating(&MultideviceHandler::HandleRemoveHostDevice,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "retryPendingHostSetup",
+ base::BindRepeating(&MultideviceHandler::HandleRetryPendingHostSetup,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "setUpAndroidSms",
+ base::BindRepeating(&MultideviceHandler::HandleSetUpAndroidSms,
+ base::Unretained(this)));
+}
+
+void MultideviceHandler::OnJavascriptAllowed() {
+ multidevice_setup_observer_.Add(multidevice_setup_client_);
+}
+
+void MultideviceHandler::OnJavascriptDisallowed() {
+ multidevice_setup_observer_.Remove(multidevice_setup_client_);
+
+ // Ensure that pending callbacks do not complete and cause JS to be evaluated.
+ callback_weak_ptr_factory_.InvalidateWeakPtrs();
+}
+
+void MultideviceHandler::OnHostStatusChanged(
+ const multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice&
+ host_status_with_device) {
+ UpdatePageContent();
+}
+
+void MultideviceHandler::OnFeatureStatesChanged(
+ const multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap&
+ feature_states_map) {
+ UpdatePageContent();
+}
+
+void MultideviceHandler::UpdatePageContent() {
+ std::unique_ptr<base::DictionaryValue> page_content_dictionary =
+ GeneratePageContentDataDictionary();
+ DCHECK(page_content_dictionary);
+ FireWebUIListener("settings.updateMultidevicePageContentData",
+ *page_content_dictionary);
}
void MultideviceHandler::HandleShowMultiDeviceSetupDialog(
@@ -33,6 +110,113 @@ void MultideviceHandler::HandleShowMultiDeviceSetupDialog(
multidevice_setup::MultiDeviceSetupDialog::Show();
}
+void MultideviceHandler::HandleGetPageContent(const base::ListValue* args) {
+ // This callback is expected to be the first one executed when the page is
+ // loaded, so it should be the one to allow JS calls.
+ AllowJavascript();
+
+ std::string callback_id;
+ bool result = args->GetString(0, &callback_id);
+ DCHECK(result);
+
+ std::unique_ptr<base::DictionaryValue> page_content_dictionary =
+ GeneratePageContentDataDictionary();
+ DCHECK(page_content_dictionary);
+
+ ResolveJavascriptCallback(base::Value(callback_id), *page_content_dictionary);
+}
+
+void MultideviceHandler::HandleSetFeatureEnabledState(
+ const base::ListValue* args) {
+ std::string callback_id;
+ bool result = args->GetString(0, &callback_id);
+ DCHECK(result);
+
+ int feature_as_int;
+ result = args->GetInteger(1, &feature_as_int);
+ DCHECK(result);
+
+ auto feature = static_cast<multidevice_setup::mojom::Feature>(feature_as_int);
+ DCHECK(multidevice_setup::mojom::IsKnownEnumValue(feature));
+
+ bool enabled;
+ result = args->GetBoolean(2, &enabled);
+ DCHECK(result);
+
+ base::Optional<std::string> auth_token;
+ std::string possible_token_value;
+ if (args->GetString(3, &possible_token_value))
+ auth_token = possible_token_value;
+
+ multidevice_setup_client_->SetFeatureEnabledState(
+ feature, enabled, auth_token,
+ base::BindOnce(&MultideviceHandler::OnSetFeatureStateEnabledResult,
+ callback_weak_ptr_factory_.GetWeakPtr(), callback_id));
+}
+
+void MultideviceHandler::HandleRemoveHostDevice(const base::ListValue* args) {
+ DCHECK(args->empty());
+ multidevice_setup_client_->RemoveHostDevice();
+}
+
+void MultideviceHandler::HandleRetryPendingHostSetup(
+ const base::ListValue* args) {
+ DCHECK(args->empty());
+ multidevice_setup_client_->RetrySetHostNow(
+ base::BindOnce(&OnRetrySetHostNowResult));
+}
+
+void MultideviceHandler::HandleSetUpAndroidSms(const base::ListValue* args) {
+ PA_LOG(WARNING) << "HandlingSetupSms";
+ DCHECK(args->empty());
+ android_sms_app_helper_->LaunchAndroidSmsApp();
+}
+
+void MultideviceHandler::OnSetFeatureStateEnabledResult(
+ const std::string& js_callback_id,
+ bool success) {
+ ResolveJavascriptCallback(base::Value(js_callback_id), base::Value(success));
+}
+
+std::unique_ptr<base::DictionaryValue>
+MultideviceHandler::GeneratePageContentDataDictionary() {
+ auto page_content_dictionary = std::make_unique<base::DictionaryValue>();
+
+ multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice
+ host_status_with_device = multidevice_setup_client_->GetHostStatus();
+ multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap feature_states =
+ multidevice_setup_client_->GetFeatureStates();
+
+ page_content_dictionary->SetInteger(
+ kPageContentDataModeKey,
+ static_cast<int32_t>(host_status_with_device.first));
+ page_content_dictionary->SetInteger(
+ kPageContentDataBetterTogetherStateKey,
+ static_cast<int32_t>(
+ feature_states
+ [multidevice_setup::mojom::Feature::kBetterTogetherSuite]));
+ page_content_dictionary->SetInteger(
+ kPageContentDataInstantTetheringStateKey,
+ static_cast<int32_t>(
+ feature_states
+ [multidevice_setup::mojom::Feature::kInstantTethering]));
+ page_content_dictionary->SetInteger(
+ kPageContentDataMessagesStateKey,
+ static_cast<int32_t>(
+ feature_states[multidevice_setup::mojom::Feature::kMessages]));
+ page_content_dictionary->SetInteger(
+ kPageContentDataSmartLockStateKey,
+ static_cast<int32_t>(
+ feature_states[multidevice_setup::mojom::Feature::kSmartLock]));
+
+ if (host_status_with_device.second) {
+ page_content_dictionary->SetString(kPageContentDataHostDeviceNameKey,
+ host_status_with_device.second->name());
+ }
+
+ return page_content_dictionary;
+}
+
} // namespace settings
} // namespace chromeos
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 3ab88522348..cc5e9037e95 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h
@@ -6,27 +6,78 @@
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_MULTIDEVICE_HANDLER_H_
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/scoped_observer.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "chromeos/services/multidevice_setup/public/cpp/multidevice_setup_client.h"
+#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
+#include "components/cryptauth/remote_device_ref.h"
namespace chromeos {
+namespace multidevice_setup {
+class AndroidSmsAppHelperDelegate;
+} // namespace multidevice_setup
+
namespace settings {
// Chrome "Multidevice" (a.k.a. "Connected Devices") settings page UI handler.
-class MultideviceHandler : public ::settings::SettingsPageUIHandler {
+class MultideviceHandler
+ : public ::settings::SettingsPageUIHandler,
+ public multidevice_setup::MultiDeviceSetupClient::Observer {
public:
- MultideviceHandler();
+ explicit MultideviceHandler(
+ multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client,
+ std::unique_ptr<multidevice_setup::AndroidSmsAppHelperDelegate>
+ android_sms_app_helper);
~MultideviceHandler() override;
+ protected:
// content::WebUIMessageHandler:
void RegisterMessages() override;
+ private:
// ::settings::SettingsPageUIHandler:
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
- private:
+ // 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;
+
+ // Sends the most recent PageContentData dictionary to the WebUI page as an
+ // update (e.g., not due to a getPageContent() request).
+ void UpdatePageContent();
+
void HandleShowMultiDeviceSetupDialog(const base::ListValue* args);
+ void HandleGetPageContent(const base::ListValue* args);
+ void HandleSetFeatureEnabledState(const base::ListValue* args);
+ void HandleRemoveHostDevice(const base::ListValue* args);
+ void HandleRetryPendingHostSetup(const base::ListValue* args);
+ void HandleSetUpAndroidSms(const base::ListValue* args);
+
+ void OnSetFeatureStateEnabledResult(const std::string& js_callback_id,
+ bool success);
+
+ // Returns null if requisite data has not yet been fetched (i.e., if one or
+ // both of |last_host_status_update_| and |last_feature_states_update_| is
+ // null).
+ std::unique_ptr<base::DictionaryValue> GeneratePageContentDataDictionary();
+
+ multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client_;
+ std::unique_ptr<multidevice_setup::AndroidSmsAppHelperDelegate>
+ android_sms_app_helper_;
+
+ ScopedObserver<multidevice_setup::MultiDeviceSetupClient,
+ multidevice_setup::MultiDeviceSetupClient::Observer>
+ multidevice_setup_observer_;
+
+ // Used to cancel callbacks when JavaScript becomes disallowed.
+ base::WeakPtrFactory<MultideviceHandler> callback_weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(MultideviceHandler);
};
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
new file mode 100644
index 00000000000..658795d6c18
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc
@@ -0,0 +1,330 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h"
+
+#include <memory>
+
+#include "base/macros.h"
+#include "chromeos/services/multidevice_setup/public/cpp/fake_android_sms_app_helper_delegate.h"
+#include "chromeos/services/multidevice_setup/public/cpp/fake_multidevice_setup_client.h"
+#include "components/cryptauth/remote_device_test_util.h"
+#include "content/public/test/test_web_ui.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+
+namespace settings {
+
+namespace {
+
+class TestMultideviceHandler : public MultideviceHandler {
+ public:
+ TestMultideviceHandler(
+ multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client,
+ std::unique_ptr<multidevice_setup::AndroidSmsAppHelperDelegate>
+ android_sms_app_helper)
+ : MultideviceHandler(multidevice_setup_client,
+ std::move(android_sms_app_helper)) {}
+ ~TestMultideviceHandler() override = default;
+
+ // Make public for testing.
+ using MultideviceHandler::AllowJavascript;
+ using MultideviceHandler::RegisterMessages;
+ using MultideviceHandler::set_web_ui;
+};
+
+multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap
+GenerateDefaultFeatureStatesMap() {
+ return multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap{
+ {multidevice_setup::mojom::Feature::kBetterTogetherSuite,
+ multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost},
+ {multidevice_setup::mojom::Feature::kInstantTethering,
+ multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost},
+ {multidevice_setup::mojom::Feature::kMessages,
+ multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost},
+ {multidevice_setup::mojom::Feature::kSmartLock,
+ multidevice_setup::mojom::FeatureState::kUnavailableNoVerifiedHost}};
+}
+
+void VerifyPageContentDict(
+ const base::Value* value,
+ multidevice_setup::mojom::HostStatus expected_host_status,
+ const base::Optional<cryptauth::RemoteDeviceRef>& expected_host_device,
+ const multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap&
+ feature_states_map) {
+ const base::DictionaryValue* page_content_dict;
+ EXPECT_TRUE(value->GetAsDictionary(&page_content_dict));
+
+ int mode;
+ EXPECT_TRUE(page_content_dict->GetInteger("mode", &mode));
+ EXPECT_EQ(static_cast<int>(expected_host_status), mode);
+
+ int better_together_state;
+ EXPECT_TRUE(page_content_dict->GetInteger("betterTogetherState",
+ &better_together_state));
+ auto it = feature_states_map.find(
+ multidevice_setup::mojom::Feature::kBetterTogetherSuite);
+ EXPECT_EQ(static_cast<int>(it->second), better_together_state);
+
+ int instant_tethering_state;
+ EXPECT_TRUE(page_content_dict->GetInteger("instantTetheringState",
+ &instant_tethering_state));
+ it = feature_states_map.find(
+ multidevice_setup::mojom::Feature::kInstantTethering);
+ EXPECT_EQ(static_cast<int>(it->second), instant_tethering_state);
+
+ int messages_state;
+ EXPECT_TRUE(page_content_dict->GetInteger("messagesState", &messages_state));
+ it = feature_states_map.find(multidevice_setup::mojom::Feature::kMessages);
+ EXPECT_EQ(static_cast<int>(it->second), messages_state);
+
+ int smart_lock_state;
+ EXPECT_TRUE(
+ page_content_dict->GetInteger("smartLockState", &smart_lock_state));
+ it = feature_states_map.find(multidevice_setup::mojom::Feature::kSmartLock);
+ EXPECT_EQ(static_cast<int>(it->second), smart_lock_state);
+
+ std::string host_device_name;
+ if (expected_host_device) {
+ EXPECT_TRUE(
+ page_content_dict->GetString("hostDeviceName", &host_device_name));
+ EXPECT_EQ(expected_host_device->name(), host_device_name);
+ } else {
+ EXPECT_FALSE(
+ page_content_dict->GetString("hostDeviceName", &host_device_name));
+ }
+}
+
+} // namespace
+
+class MultideviceHandlerTest : public testing::Test {
+ protected:
+ MultideviceHandlerTest()
+ : test_device_(cryptauth::CreateRemoteDeviceRefForTest()) {}
+ ~MultideviceHandlerTest() override = default;
+
+ // testing::Test:
+ void SetUp() override {
+ test_web_ui_ = std::make_unique<content::TestWebUI>();
+
+ fake_multidevice_setup_client_ =
+ std::make_unique<multidevice_setup::FakeMultiDeviceSetupClient>();
+ auto fake_android_sms_app_helper_delegate =
+ std::make_unique<multidevice_setup::FakeAndroidSmsAppHelperDelegate>();
+ fake_android_sms_app_helper_delegate_ =
+ fake_android_sms_app_helper_delegate.get();
+
+ handler_ = std::make_unique<TestMultideviceHandler>(
+ fake_multidevice_setup_client_.get(),
+ std::move(fake_android_sms_app_helper_delegate));
+ handler_->set_web_ui(test_web_ui_.get());
+ handler_->RegisterMessages();
+ handler_->AllowJavascript();
+ }
+
+ void CallGetPageContentData() {
+ size_t call_data_count_before_call = test_web_ui()->call_data().size();
+
+ base::ListValue args;
+ args.AppendString("handlerFunctionName");
+ test_web_ui()->HandleReceivedMessage("getPageContentData", &args);
+
+ 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.webUIResponse", call_data.function_name());
+ EXPECT_EQ("handlerFunctionName", call_data.arg1()->GetString());
+ EXPECT_TRUE(call_data.arg2()->GetBool());
+ VerifyPageContent(call_data.arg3());
+ }
+
+ void CallRemoveHostDevice() {
+ size_t num_remote_host_device_calls_before_call =
+ fake_multidevice_setup_client()->num_remove_host_device_called();
+ base::ListValue empty_args;
+ test_web_ui()->HandleReceivedMessage("removeHostDevice", &empty_args);
+ EXPECT_EQ(num_remote_host_device_calls_before_call + 1u,
+ fake_multidevice_setup_client()->num_remove_host_device_called());
+ }
+
+ void SimulateHostStatusUpdate(
+ multidevice_setup::mojom::HostStatus host_status,
+ const base::Optional<cryptauth::RemoteDeviceRef>& host_device) {
+ size_t call_data_count_before_call = test_web_ui()->call_data().size();
+
+ fake_multidevice_setup_client_->SetHostStatusWithDevice(
+ std::make_pair(host_status, host_device));
+ 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("settings.updateMultidevicePageContentData",
+ call_data.arg1()->GetString());
+ VerifyPageContent(call_data.arg2());
+ }
+
+ void SimulateFeatureStatesUpdate(
+ const multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap&
+ feature_states_map) {
+ size_t call_data_count_before_call = test_web_ui()->call_data().size();
+
+ fake_multidevice_setup_client_->SetFeatureStates(feature_states_map);
+ 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("settings.updateMultidevicePageContentData",
+ call_data.arg1()->GetString());
+ VerifyPageContent(call_data.arg2());
+ }
+
+ void CallRetryPendingHostSetup(bool success) {
+ base::ListValue empty_args;
+ test_web_ui()->HandleReceivedMessage("retryPendingHostSetup", &empty_args);
+ fake_multidevice_setup_client()->InvokePendingRetrySetHostNowCallback(
+ success);
+ }
+
+ void CallSetUpAndroidSms() {
+ base::ListValue empty_args;
+ test_web_ui()->HandleReceivedMessage("setUpAndroidSms", &empty_args);
+ }
+
+ void CallSetFeatureEnabledState(multidevice_setup::mojom::Feature feature,
+ bool enabled,
+ const base::Optional<std::string>& auth_token,
+ bool success) {
+ size_t call_data_count_before_call = test_web_ui()->call_data().size();
+
+ base::ListValue args;
+ args.AppendString("handlerFunctionName");
+ args.AppendInteger(static_cast<int>(feature));
+ args.AppendBoolean(enabled);
+ if (auth_token)
+ args.AppendString(*auth_token);
+
+ base::ListValue empty_args;
+ test_web_ui()->HandleReceivedMessage("setFeatureEnabledState", &args);
+ fake_multidevice_setup_client()
+ ->InvokePendingSetFeatureEnabledStateCallback(
+ feature /* expected_feature */, enabled /* expected_enabled */,
+ auth_token /* expected_auth_token */, success);
+
+ 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.webUIResponse", call_data.function_name());
+ EXPECT_EQ("handlerFunctionName", call_data.arg1()->GetString());
+ EXPECT_TRUE(call_data.arg2()->GetBool());
+ EXPECT_EQ(success, call_data.arg3()->GetBool());
+ }
+
+ const content::TestWebUI::CallData& CallDataAtIndex(size_t index) {
+ return *test_web_ui_->call_data()[index];
+ }
+
+ content::TestWebUI* test_web_ui() { return test_web_ui_.get(); }
+
+ multidevice_setup::FakeMultiDeviceSetupClient*
+ fake_multidevice_setup_client() {
+ return fake_multidevice_setup_client_.get();
+ }
+
+ multidevice_setup::FakeAndroidSmsAppHelperDelegate*
+ fake_android_sms_app_helper_delegate() {
+ return fake_android_sms_app_helper_delegate_;
+ }
+
+ const cryptauth::RemoteDeviceRef test_device_;
+
+ private:
+ void VerifyPageContent(const base::Value* value) {
+ VerifyPageContentDict(
+ value, fake_multidevice_setup_client_->GetHostStatus().first,
+ fake_multidevice_setup_client_->GetHostStatus().second,
+ fake_multidevice_setup_client_->GetFeatureStates());
+ }
+
+ std::unique_ptr<content::TestWebUI> test_web_ui_;
+ std::unique_ptr<multidevice_setup::FakeMultiDeviceSetupClient>
+ fake_multidevice_setup_client_;
+ std::unique_ptr<TestMultideviceHandler> handler_;
+
+ multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice
+ host_status_with_device_;
+ multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap
+ feature_states_map_;
+ multidevice_setup::FakeAndroidSmsAppHelperDelegate*
+ fake_android_sms_app_helper_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(MultideviceHandlerTest);
+};
+
+TEST_F(MultideviceHandlerTest, PageContentData) {
+ CallGetPageContentData();
+ CallGetPageContentData();
+
+ SimulateHostStatusUpdate(
+ multidevice_setup::mojom::HostStatus::kEligibleHostExistsButNoHostSet,
+ base::nullopt /* host_device */);
+ SimulateHostStatusUpdate(multidevice_setup::mojom::HostStatus::
+ kHostSetLocallyButWaitingForBackendConfirmation,
+ test_device_);
+ SimulateHostStatusUpdate(
+ multidevice_setup::mojom::HostStatus::kHostSetButNotYetVerified,
+ test_device_);
+ SimulateHostStatusUpdate(multidevice_setup::mojom::HostStatus::kHostVerified,
+ test_device_);
+
+ multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap
+ feature_states_map = GenerateDefaultFeatureStatesMap();
+ feature_states_map[multidevice_setup::mojom::Feature::kBetterTogetherSuite] =
+ multidevice_setup::mojom::FeatureState::kEnabledByUser;
+ SimulateFeatureStatesUpdate(feature_states_map);
+
+ feature_states_map[multidevice_setup::mojom::Feature::kBetterTogetherSuite] =
+ multidevice_setup::mojom::FeatureState::kDisabledByUser;
+ SimulateFeatureStatesUpdate(feature_states_map);
+}
+
+TEST_F(MultideviceHandlerTest, RetryPendingHostSetup) {
+ CallRetryPendingHostSetup(true /* success */);
+ CallRetryPendingHostSetup(false /* success */);
+}
+
+TEST_F(MultideviceHandlerTest, SetUpAndroidSms) {
+ EXPECT_FALSE(fake_android_sms_app_helper_delegate()->HasLaunchedApp());
+ CallSetUpAndroidSms();
+ EXPECT_TRUE(fake_android_sms_app_helper_delegate()->HasLaunchedApp());
+}
+
+TEST_F(MultideviceHandlerTest, SetFeatureEnabledState) {
+ CallSetFeatureEnabledState(
+ multidevice_setup::mojom::Feature::kBetterTogetherSuite,
+ true /* enabled */, "authToken" /* auth_token */, true /* success */);
+ CallSetFeatureEnabledState(
+ multidevice_setup::mojom::Feature::kBetterTogetherSuite,
+ false /* enabled */, "authToken" /* auth_token */, false /* success */);
+ CallSetFeatureEnabledState(
+ multidevice_setup::mojom::Feature::kBetterTogetherSuite,
+ false /* enabled */, "authToken" /* auth_token */, true /* success */);
+}
+
+TEST_F(MultideviceHandlerTest, RemoveHostDevice) {
+ CallRemoveHostDevice();
+ CallRemoveHostDevice();
+ CallRemoveHostDevice();
+}
+
+} // namespace settings
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc
index 8a5af4ee012..ff52076ee4e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc
@@ -20,11 +20,17 @@ namespace {
smb_client::SmbService* GetSmbService(Profile* profile) {
smb_client::SmbService* const service = smb_client::SmbService::Get(profile);
- DCHECK(service);
-
return service;
}
+base::Value BuildShareList(const std::vector<smb_client::SmbUrl>& shares) {
+ base::Value shares_list(base::Value::Type::LIST);
+ for (const auto& share : shares) {
+ shares_list.GetList().push_back(base::Value(share.ToString()));
+ }
+ return shares_list;
+}
+
} // namespace
SmbHandler::SmbHandler(Profile* profile)
@@ -54,6 +60,9 @@ void SmbHandler::HandleSmbMount(const base::ListValue* args) {
CHECK(args->GetString(3, &password));
smb_client::SmbService* const service = GetSmbService(profile_);
+ if (!service) {
+ return;
+ }
chromeos::file_system_provider::MountOptions mo;
mo.display_name = mount_name.empty() ? mount_url : mount_name;
@@ -79,6 +88,9 @@ void SmbHandler::HandleSmbMountResponse(SmbMountResult result) {
void SmbHandler::HandleStartDiscovery(const base::ListValue* args) {
smb_client::SmbService* const service = GetSmbService(profile_);
+ if (!service) {
+ return;
+ }
service->GatherSharesInNetwork(base::BindRepeating(
&SmbHandler::HandleGatherSharesResponse, weak_ptr_factory_.GetWeakPtr()));
@@ -91,9 +103,10 @@ void SmbHandler::HandleGatherSharesResponse(
std::move(stored_mount_call_).Run();
}
- // TODO(zentaro): Pass the shares discovered back to the UI.
- // https://crbug.com/852199.
+ AllowJavascript();
+ FireWebUIListener("on-shares-found", BuildShareList(shares_gathered));
}
+
} // namespace settings
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
index 4e45994d152..61d21286ab9 100644
--- a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc
@@ -18,6 +18,10 @@
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/file_manager/path_util.h"
+#endif
+
using base::UserMetricsAction;
namespace settings {
@@ -44,6 +48,12 @@ void DownloadsHandler::RegisterMessages() {
"selectDownloadLocation",
base::BindRepeating(&DownloadsHandler::HandleSelectDownloadLocation,
base::Unretained(this)));
+#if defined(OS_CHROMEOS)
+ web_ui()->RegisterMessageCallback(
+ "getDownloadLocationText",
+ base::BindRepeating(&DownloadsHandler::HandleGetDownloadLocationText,
+ base::Unretained(this)));
+#endif
}
void DownloadsHandler::OnJavascriptAllowed() {
@@ -105,4 +115,20 @@ void DownloadsHandler::FileSelected(const base::FilePath& path,
pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path);
}
+#if defined(OS_CHROMEOS)
+void DownloadsHandler::HandleGetDownloadLocationText(
+ const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(2U, args->GetSize());
+ std::string callback_id;
+ std::string path;
+ CHECK(args->GetString(0, &callback_id));
+ CHECK(args->GetString(1, &path));
+
+ ResolveJavascriptCallback(
+ base::Value(callback_id),
+ base::Value(file_manager::util::GetDownloadLocationText(profile_, path)));
+}
+#endif
+
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/downloads_handler.h b/chromium/chrome/browser/ui/webui/settings/downloads_handler.h
index 289cf74ab82..503455691e0 100644
--- a/chromium/chrome/browser/ui/webui/settings/downloads_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/downloads_handler.h
@@ -51,6 +51,13 @@ class DownloadsHandler : public SettingsPageUIHandler,
int index,
void* params) override;
+#if defined(OS_CHROMEOS)
+ // Callback for the "getDownloadLocationText" message. Converts actual
+ // paths in chromeos to values suitable to display to users.
+ // E.g. /home/chronos/u-<hash>/Downloads => "Downloads".
+ void HandleGetDownloadLocationText(const base::ListValue* args);
+#endif
+
Profile* profile_;
PrefChangeRegistrar pref_registrar_;
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
index 65230a3aea7..2c30e7fc48e 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
@@ -13,13 +13,13 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/buildflag.h"
+#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/plugins/plugin_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
-#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/ui/webui/policy_indicator_localized_strings_provider.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
@@ -28,17 +28,21 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
#include "components/autofill/core/browser/payments/payments_service_url.h"
+#include "components/autofill/core/browser/payments/payments_util.h"
#include "components/autofill/core/common/autofill_constants.h"
+#include "components/autofill/core/common/autofill_features.h"
#include "components/content_settings/core/common/features.h"
-#include "components/google/core/browser/google_util.h"
+#include "components/google/core/common/google_util.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#include "components/signin/core/browser/signin_buildflags.h"
#include "components/strings/grit/components_strings.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
+#include "components/unified_consent/feature.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_features.h"
+#include "media/base/media_switches.h"
#include "services/device/public/cpp/device_features.h"
#include "ui/base/l10n/l10n_util.h"
@@ -57,6 +61,7 @@
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chromeos/chromeos_features.h"
#include "chromeos/chromeos_switches.h"
+#include "chromeos/services/multidevice_setup/public/cpp/url_provider.h"
#include "components/arc/arc_util.h"
#include "components/user_manager/user_manager.h"
#include "ui/chromeos/devicetype_utils.h"
@@ -134,6 +139,9 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"moreActions", IDS_SETTINGS_MORE_ACTIONS},
{"ok", IDS_OK},
{"restart", IDS_SETTINGS_RESTART},
+#if !defined(OS_CHROMEOS)
+ {"restartToApplyChanges", IDS_SETTINGS_RESTART_TO_APPLY_CHANGES},
+#endif
{"retry", IDS_SETTINGS_RETRY},
{"save", IDS_SAVE},
{"settings", IDS_SETTINGS_SETTINGS},
@@ -203,6 +211,7 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"dictationLabel", IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL},
{"onScreenKeyboardLabel", IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL},
{"monoAudioLabel", IDS_SETTINGS_MONO_AUDIO_LABEL},
+ {"startupSoundLabel", IDS_SETTINGS_STARTUP_SOUND_LABEL},
{"a11yExplanation", IDS_SETTINGS_ACCESSIBILITY_EXPLANATION},
{"caretHighlightLabel",
IDS_SETTINGS_ACCESSIBILITY_CARET_HIGHLIGHT_DESCRIPTION},
@@ -492,6 +501,8 @@ void AddBluetoothStrings(content::WebUIDataSource* html_source) {
{"bluetoothPairDevicePageTitle",
IDS_SETTINGS_BLUETOOTH_PAIR_DEVICE_TITLE},
{"bluetoothRemove", IDS_SETTINGS_BLUETOOTH_REMOVE},
+ {"bluetoothPrimaryUserControlled",
+ IDS_SETTINGS_BLUETOOTH_PRIMARY_USER_CONTROLLED},
};
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
@@ -513,9 +524,18 @@ void AddClearBrowsingDataStrings(content::WebUIDataSource* html_source,
Profile* profile) {
LocalizedString localized_strings[] = {
{"clearTimeRange", IDS_SETTINGS_CLEAR_PERIOD_TITLE},
+ {"clearBrowsingDataWithSync", IDS_SETTINGS_CLEAR_BROWSING_DATA_WITH_SYNC},
+ {"clearBrowsingDataWithSyncError",
+ IDS_SETTINGS_CLEAR_BROWSING_DATA_WITH_SYNC_ERROR},
+ {"clearBrowsingDataWithSyncPassphraseError",
+ IDS_SETTINGS_CLEAR_BROWSING_DATA_WITH_SYNC_PASSPHRASE_ERROR},
+ {"clearBrowsingDataWithSyncPaused",
+ IDS_SETTINGS_CLEAR_BROWSING_DATA_WITH_SYNC_PAUSED},
{"clearBrowsingHistory", IDS_SETTINGS_CLEAR_BROWSING_HISTORY},
{"clearBrowsingHistorySummary",
IDS_SETTINGS_CLEAR_BROWSING_HISTORY_SUMMARY},
+ {"clearBrowsingHistorySummarySignedIn",
+ IDS_SETTINGS_CLEAR_BROWSING_HISTORY_SUMMARY_SYNC_ERROR},
{"clearDownloadHistory", IDS_SETTINGS_CLEAR_DOWNLOAD_HISTORY},
{"clearCache", IDS_SETTINGS_CLEAR_CACHE},
{"clearCookies", IDS_SETTINGS_CLEAR_COOKIES},
@@ -541,11 +561,6 @@ void AddClearBrowsingDataStrings(content::WebUIDataSource* html_source,
};
html_source->AddString(
- "clearBrowsingHistorySummarySignedIn",
- l10n_util::GetStringFUTF16(
- IDS_SETTINGS_CLEAR_BROWSING_HISTORY_SUMMARY_SIGNED_IN,
- base::ASCIIToUTF16(chrome::kMyActivityUrlInClearBrowsingData)));
- html_source->AddString(
"clearBrowsingHistorySummarySynced",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_CLEAR_BROWSING_HISTORY_SUMMARY_SYNCED,
@@ -617,6 +632,9 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
{"keyboardKeyEscape", IDS_SETTINGS_KEYBOARD_KEY_ESCAPE},
{"keyboardKeyBackspace", IDS_SETTINGS_KEYBOARD_KEY_BACKSPACE},
{"keyboardKeyDisabled", IDS_SETTINGS_KEYBOARD_KEY_DISABLED},
+ {"keyboardKeyExternalCommand",
+ IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_COMMAND},
+ {"keyboardKeyExternalMeta", IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_META},
{"keyboardSendFunctionKeys", IDS_SETTINGS_KEYBOARD_SEND_FUNCTION_KEYS},
{"keyboardSendFunctionKeysDescription",
ui::DeviceUsesKeyboardLayout2()
@@ -737,9 +755,6 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kEnableTouchCalibrationSetting));
- html_source->AddBoolean("enableDisplayZoomSetting",
- features::IsDisplayZoomSettingEnabled());
-
html_source->AddBoolean("hasExternalTouchDevice",
display::HasExternalTouchscreenDevice());
@@ -832,6 +847,8 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_UNSUPPORTED_DEVICE_MESSAGE},
{"smbShareAddedMountExistsMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE},
+ {"smbShareAddedInvalidURLMessage",
+ IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_INVALID_URL_MESSAGE},
#endif
};
AddLocalizedStringsBulk(html_source, localized_strings,
@@ -840,6 +857,8 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) {
#if defined(OS_CHROMEOS)
html_source->AddBoolean("enableNativeSmbSetting",
base::FeatureList::IsEnabled(features::kNativeSmb));
+ html_source->AddString("smbSharesLearnMoreURL",
+ GetHelpUrlWithBoard(chrome::kSmbSharesLearnMoreURL));
#endif
}
@@ -1374,18 +1393,20 @@ void AddOnStartupStrings(content::WebUIDataSource* html_source) {
arraysize(localized_strings));
}
-void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source) {
+void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source,
+ Profile* profile) {
LocalizedString localized_strings[] = {
{"passwordsAndAutofillPageTitle",
IDS_SETTINGS_PASSWORDS_AND_AUTOFILL_PAGE_TITLE},
{"googlePayments", IDS_SETTINGS_GOOGLE_PAYMENTS},
{"googlePaymentsCached", IDS_SETTINGS_GOOGLE_PAYMENTS_CACHED},
- {"autofillFormsLabel", IDS_SETTINGS_AUTOFILL_TOGGLE_LABEL},
- {"enableProfilesLabel",
- IDS_SETTINGS_AUTOFILL_ENABLE_PROFILES_TOGGLE_LABEL},
- {"enableCreditCardsLabel",
- IDS_SETTINGS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_LABEL},
- {"addresses", IDS_SETTINGS_AUTOFILL_ADDRESSES_HEADING},
+ {"enableProfilesLabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_LABEL},
+ {"enableProfilesSublabel", IDS_AUTOFILL_ENABLE_PROFILES_TOGGLE_SUBLABEL},
+ {"enableCreditCardsLabel", IDS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_LABEL},
+ {"enableCreditCardsSublabel",
+ IDS_AUTOFILL_ENABLE_CREDIT_CARDS_TOGGLE_SUBLABEL},
+ {"addresses", IDS_AUTOFILL_ADDRESSES},
+ {"addressesTitle", IDS_AUTOFILL_ADDRESSES_SETTINGS_TITLE},
{"addAddressTitle", IDS_SETTINGS_AUTOFILL_ADDRESSES_ADD_TITLE},
{"editAddressTitle", IDS_SETTINGS_AUTOFILL_ADDRESSES_EDIT_TITLE},
{"addressCountry", IDS_SETTINGS_AUTOFILL_ADDRESSES_COUNTRY},
@@ -1394,6 +1415,7 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source) {
{"removeAddress", IDS_SETTINGS_ADDRESS_REMOVE},
{"removeCreditCard", IDS_SETTINGS_CREDIT_CARD_REMOVE},
{"clearCreditCard", IDS_SETTINGS_CREDIT_CARD_CLEAR},
+ {"creditCardsDetail", IDS_SETTINGS_AUTOFILL_CREDIT_CARD_DETAIL},
{"creditCardType", IDS_SETTINGS_AUTOFILL_CREDIT_CARD_TYPE_COLUMN_LABEL},
{"creditCardExpiration", IDS_SETTINGS_CREDIT_CARD_EXPIRATION_DATE},
{"creditCardName", IDS_SETTINGS_NAME_ON_CREDIT_CARD},
@@ -1403,6 +1425,13 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source) {
{"creditCardExpired", IDS_SETTINGS_CREDIT_CARD_EXPIRED},
{"editCreditCardTitle", IDS_SETTINGS_EDIT_CREDIT_CARD_TITLE},
{"addCreditCardTitle", IDS_SETTINGS_ADD_CREDIT_CARD_TITLE},
+ {"migrateCreditCardsLabelSingle",
+ IDS_SETTINGS_SINGLE_MIGRATABLE_CARD_LABEL},
+ {"migrateCreditCardsLabelMultiple",
+ IDS_SETTINGS_MULTIPLE_MIGRATABLE_CARDS_LABEL},
+ {"migratableCardsInfoSingle", IDS_SETTINGS_SINGLE_MIGRATABLE_CARD_INFO},
+ {"migratableCardsInfoMultiple",
+ IDS_SETTINGS_MULTIPLE_MIGRATABLE_CARDS_INFO},
{"canMakePaymentToggleLabel", IDS_SETTINGS_CAN_MAKE_PAYMENT_TOGGLE_LABEL},
{"autofillDetail", IDS_SETTINGS_AUTOFILL_DETAIL},
{"passwordsSavePasswordsLabel",
@@ -1452,11 +1481,11 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source) {
// |localized_strings| array once Autofill Home is fully launched.
if (base::FeatureList::IsEnabled(password_manager::features::kAutofillHome)) {
html_source->AddLocalizedString("autofill",
- IDS_SETTINGS_AUTOFILL_AUTOFILL_HOME);
+ IDS_AUTOFILL_ADDRESSES_SETTINGS_TITLE);
html_source->AddLocalizedString("passwords",
IDS_SETTINGS_PASSWORDS_AUTOFILL_HOME);
html_source->AddLocalizedString("creditCards",
- IDS_SETTINGS_AUTOFILL_PAYMENT_METHODS);
+ IDS_AUTOFILL_PAYMENT_METHODS);
html_source->AddLocalizedString("noCreditCardsFound",
IDS_SETTINGS_PAYMENT_METHODS_NONE);
} else {
@@ -1479,9 +1508,25 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source) {
autofill::payments::GetManageAddressesUrl(0).spec());
html_source->AddString("manageCreditCardsUrl",
autofill::payments::GetManageInstrumentsUrl(0).spec());
+ html_source->AddBoolean(
+ "migrationEnabled",
+ autofill::features::GetLocalCardMigrationExperimentalFlag() ==
+ autofill::features::LocalCardMigrationExperimentalFlag::
+ kMigrationIncludeSettingsPage);
+
+ autofill::PersonalDataManager* personal_data_manager_ =
+ autofill::PersonalDataManagerFactory::GetForProfile(profile);
+ html_source->AddBoolean(
+ "hasGooglePaymentsAccount",
+ autofill::payments::GetBillingCustomerId(personal_data_manager_,
+ profile->GetPrefs()) != 0);
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
+
+ html_source->AddBoolean("EnableCompanyName",
+ base::FeatureList::IsEnabled(
+ autofill::features::kAutofillEnableCompanyName));
}
void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
@@ -1489,29 +1534,21 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"peoplePageTitle", IDS_SETTINGS_PEOPLE},
{"manageOtherPeople", IDS_SETTINGS_PEOPLE_MANAGE_OTHER_PEOPLE},
#if defined(OS_CHROMEOS)
- {"accountManagerPageTitle", IDS_SETTINGS_ACCOUNT_MANAGER_PAGE_TITLE},
{"accountManagerDescription", IDS_SETTINGS_ACCOUNT_MANAGER_DESCRIPTION},
+ {"accountManagerPageTitle", IDS_SETTINGS_ACCOUNT_MANAGER_PAGE_TITLE},
+ {"accountManagerSubMenuLabel", IDS_SETTINGS_ACCOUNT_MANAGER_SUBMENU_LABEL},
{"accountListHeader", IDS_SETTINGS_ACCOUNT_MANAGER_LIST_HEADER},
{"addAccountLabel", IDS_SETTINGS_ACCOUNT_MANAGER_ADD_ACCOUNT_LABEL},
+ {"removeAccountLabel", IDS_SETTINGS_ACCOUNT_MANAGER_REMOVE_ACCOUNT_LABEL},
{"configureFingerprintTitle", IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_TITLE},
{"configureFingerprintInstructionLocateScannerStep",
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER},
- {"configureFingerprintInstructionMoveFingerStep",
- IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_MOVE_FINGER},
{"configureFingerprintInstructionReadyStep",
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_READY},
{"configureFingerprintLiftFinger",
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_LIFT_FINGER},
- {"configureFingerprintPartialData",
- IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_PARTIAL_DATA},
- {"configureFingerprintInsufficientData",
- IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSUFFICIENT_DATA},
- {"configureFingerprintSensorDirty",
- IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_SENSOR_DIRTY},
- {"configureFingerprintTooSlow",
- IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_FINGER_TOO_SLOW},
- {"configureFingerprintTooFast",
- IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_FINGER_TOO_FAST},
+ {"configureFingerprintTryAgain",
+ IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_TRY_AGAIN},
{"configureFingerprintImmobile",
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_FINGER_IMMOBILE},
{"configureFingerprintAddAnotherButton",
@@ -1540,14 +1577,20 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"lockScreenNumberFingerprints",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NUM_FINGERPRINTS},
{"lockScreenNone", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NONE},
- {"lockScreenFingerprintEnable",
- IDS_SETTINGS_PEOPLE_LOCK_SCREEN_ENABLE_FINGERPRINT_CHECKBOX_LABEL},
{"lockScreenFingerprintNewName",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME},
{"lockScreenFingerprintTitle",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_FINGERPRINT_SUBPAGE_TITLE},
{"lockScreenFingerprintWarning",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_FINGERPRINT_LESS_SECURE},
+ {"lockScreenNotificationHide",
+ IDS_ASH_SETTINGS_LOCK_SCREEN_NOTIFICATION_HIDE},
+ {"lockScreenNotificationHideSensitive",
+ IDS_ASH_SETTINGS_LOCK_SCREEN_NOTIFICATION_HIDE_SENSITIVE},
+ {"lockScreenNotificationShow",
+ IDS_ASH_SETTINGS_LOCK_SCREEN_NOTIFICATION_SHOW},
+ {"lockScreenNotificationTitle",
+ IDS_ASH_SETTINGS_LOCK_SCREEN_NOTIFICATION_TITLE},
{"lockScreenOptionsLock", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_OPTIONS_LOCK},
{"lockScreenOptionsLoginLock",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_OPTIONS_LOGIN_LOCK},
@@ -1601,15 +1644,14 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"cancelSync", IDS_SETTINGS_SYNC_SETTINGS_CANCEL_SYNC},
#endif // defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
- {"peopleSignIn", IDS_SETTINGS_PEOPLE_SIGN_IN},
+ {"peopleSignIn", IDS_PROFILES_DICE_SIGNIN_BUTTON},
{"peopleSignOut", IDS_SETTINGS_PEOPLE_SIGN_OUT},
{"peopleSignInPrompt", IDS_SETTINGS_PEOPLE_SIGN_IN_PROMPT},
{"peopleSignInPromptSecondaryWithNoAccount",
- IDS_SETTINGS_PEOPLE_SIGN_IN_PROMPT_SECONDARY_WITH_NO_ACCOUNT},
+ IDS_SETTINGS_PEOPLE_SIGN_IN_PROMPT_SECONDARY_WITH_ACCOUNT},
{"peopleSignInPromptSecondaryWithAccount",
IDS_SETTINGS_PEOPLE_SIGN_IN_PROMPT_SECONDARY_WITH_ACCOUNT},
{"useAnotherAccount", IDS_SETTINGS_PEOPLE_SYNC_ANOTHER_ACCOUNT},
- {"syncAsName", IDS_SETTINGS_PEOPLE_SYNC_AS_NAME},
{"syncingTo", IDS_SETTINGS_PEOPLE_SYNCING_TO_ACCOUNT},
{"turnOffSync", IDS_SETTINGS_PEOPLE_SYNC_TURN_OFF},
{"signInAgain", IDS_SYNC_ERROR_USER_MENU_SIGNIN_AGAIN_BUTTON},
@@ -1640,10 +1682,10 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"deleteProfileWarningWithoutCounts",
IDS_SETTINGS_SYNC_DISCONNECT_DELETE_PROFILE_WARNING_WITHOUT_COUNTS},
{"syncDisconnectConfirm", IDS_SETTINGS_SYNC_DISCONNECT_CONFIRM},
- {"sync", IsUnifiedConsentEnabled(profile)
+ {"sync", unified_consent::IsUnifiedConsentFeatureEnabled()
? IDS_SETTINGS_SYNC_UNIFIED_CONSENT
: IDS_SETTINGS_SYNC},
- {"syncDescription", IsUnifiedConsentEnabled(profile)
+ {"syncDescription", unified_consent::IsUnifiedConsentFeatureEnabled()
? IDS_SETTINGS_SYNC_DESCRIPTION_UNIFIED_CONSENT
: IDS_SETTINGS_SYNC_DESCRIPTION},
{"nonPersonalizedServicesSectionLabel",
@@ -1655,7 +1697,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"syncExpandA11yLabel", IDS_SETTINGS_SYNC_SECTION_ACCESSIBILITY_LABEL},
{"syncAndNonPersonalizedServices",
IDS_SETTINGS_SYNC_SYNC_AND_NON_PERSONALIZED_SERVICES},
- {"syncPageTitle", IsUnifiedConsentEnabled(profile)
+ {"syncPageTitle", unified_consent::IsUnifiedConsentFeatureEnabled()
? IDS_SETTINGS_SYNC_SYNC_AND_NON_PERSONALIZED_SERVICES
: IDS_SETTINGS_SYNC_PAGE_TITLE},
{"syncLoading", IDS_SETTINGS_SYNC_LOADING},
@@ -1696,12 +1738,12 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
- // TODO(https://crbug.com/854562): Integrate these strings into the
- // |localized_strings| array once Autofill Home is fully launched.
if (base::FeatureList::IsEnabled(password_manager::features::kAutofillHome)) {
+ // TODO(https://crbug.com/854562): Integrate this string into the
+ // |localized_strings| array once Autofill Home is fully launched.
html_source->AddLocalizedString(
"enablePaymentsIntegrationCheckboxLabel",
- IDS_SETTINGS_ENABLE_PAYMENTS_INTEGRATION_CHECKBOX_LABEL_AUTOFILL_HOME);
+ IDS_AUTOFILL_ENABLE_PAYMENTS_INTEGRATION_CHECKBOX_LABEL);
} else {
html_source->AddLocalizedString(
"enablePaymentsIntegrationCheckboxLabel",
@@ -1746,12 +1788,13 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
l10n_util::GetStringFUTF8(IDS_SETTINGS_PASSPHRASE_EXPLANATION_TEXT,
base::ASCIIToUTF16(sync_dashboard_url)));
html_source->AddString(
- "passphraseResetHint",
- l10n_util::GetStringFUTF8(
- IsUnifiedConsentEnabled(profile)
- ? IDS_SETTINGS_PASSPHRASE_RESET_HINT_UNIFIED_CONSENT
- : IDS_SETTINGS_PASSPHRASE_RESET_HINT,
- base::ASCIIToUTF16(sync_dashboard_url)));
+ "passphraseResetHintEncryption",
+ l10n_util::GetStringFUTF8(IDS_SETTINGS_PASSPHRASE_RESET_HINT_ENCRYPTION,
+ base::ASCIIToUTF16(sync_dashboard_url)));
+ html_source->AddString(
+ "passphraseResetHintToggle",
+ l10n_util::GetStringFUTF8(IDS_SETTINGS_PASSPHRASE_RESET_HINT_TOGGLE,
+ base::ASCIIToUTF16(sync_dashboard_url)));
html_source->AddString(
"passphraseRecover",
l10n_util::GetStringFUTF8(IDS_SETTINGS_PASSPHRASE_RECOVER,
@@ -1773,7 +1816,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
LocalizedString sync_disconnect_strings[] = {
{"syncDisconnect", IDS_SETTINGS_PEOPLE_SYNC_TURN_OFF},
{"syncDisconnectTitle",
- IsUnifiedConsentEnabled(profile)
+ unified_consent::IsUnifiedConsentFeatureEnabled()
? IDS_SETTINGS_TURN_OFF_SYNC_AND_SIGN_OUT_DIALOG_TITLE_UNIFIED_CONSENT
: IDS_SETTINGS_TURN_OFF_SYNC_AND_SIGN_OUT_DIALOG_TITLE},
{"syncDisconnectDeleteProfile",
@@ -1784,7 +1827,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
AddLocalizedStringsBulk(html_source, sync_disconnect_strings,
arraysize(sync_disconnect_strings));
- if (IsUnifiedConsentEnabled(profile)) {
+ if (unified_consent::IsUnifiedConsentFeatureEnabled()) {
html_source->AddLocalizedString(
"syncDisconnectExplanation",
IDS_SETTINGS_SYNC_DISCONNECT_AND_SIGN_OUT_EXPLANATION_UNIFIED_CONSENT);
@@ -1813,6 +1856,13 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
html_source->AddBoolean(
"driveSuggestAvailable",
base::FeatureList::IsEnabled(omnibox::kDocumentProvider));
+
+#if defined(OS_CHROMEOS)
+ // Used to control the display of Chrome OS Account Manager submenu in the
+ // People section.
+ html_source->AddBoolean("isAccountManagerEnabled",
+ chromeos::switches::IsAccountManagerEnabled());
+#endif
}
void AddPrintingStrings(content::WebUIDataSource* html_source) {
@@ -1924,6 +1974,8 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
Profile* profile) {
LocalizedString localized_strings[] = {
{"privacyPageTitle", IDS_SETTINGS_PRIVACY},
+ {"signinAllowedTitle", IDS_SETTINGS_SIGNIN_ALLOWED},
+ {"signinAllowedDescription", IDS_SETTINGS_SIGNIN_ALLOWED_DESC},
{"doNotTrack", IDS_SETTINGS_ENABLE_DO_NOT_TRACK},
{"doNotTrackDialogTitle", IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TITLE},
{"enableContentProtectionAttestation",
@@ -1956,7 +2008,8 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
arraysize(localized_strings));
// Select strings depending on unified-consent enabledness.
- bool is_unified_consent_enabled = IsUnifiedConsentEnabled(profile);
+ bool is_unified_consent_enabled =
+ unified_consent::IsUnifiedConsentFeatureEnabled();
if (is_unified_consent_enabled) {
LocalizedString conditional_localized_strings[] = {
{"searchSuggestPref", IDS_SETTINGS_SUGGEST_PREF_UNIFIED_CONSENT},
@@ -2003,7 +2056,7 @@ void AddPrivacyStrings(content::WebUIDataSource* html_source,
}
html_source->AddString("syncAndGoogleServicesLearnMoreURL",
- IsUnifiedConsentEnabled(profile)
+ unified_consent::IsUnifiedConsentFeatureEnabled()
? chrome::kSyncAndGoogleServicesLearnMoreURL
: "");
html_source->AddString(
@@ -2125,6 +2178,10 @@ void AddGoogleAssistantStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_GOOGLE_ASSISTANT_ENABLE_HOTWORD},
{"googleAssistantEnableHotwordDescription",
IDS_SETTINGS_GOOGLE_ASSISTANT_ENABLE_HOTWORD_DESCRIPTION},
+ {"googleAssistantEnableNotification",
+ IDS_SETTINGS_GOOGLE_ASSISTANT_ENABLE_NOTIFICATION},
+ {"googleAssistantEnableNotificationDescription",
+ IDS_SETTINGS_GOOGLE_ASSISTANT_ENABLE_NOTIFICATION_DESCRIPTION},
{"googleAssistantSettings", IDS_SETTINGS_GOOGLE_ASSISTANT_SETTINGS},
};
AddLocalizedStringsBulk(html_source, localized_strings,
@@ -2215,6 +2272,10 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_ALL_SITES_DESCRIPTION},
{"siteSettingsAllSitesSearch", IDS_SETTINGS_SITE_SETTINGS_ALL_SITES_SEARCH},
{"siteSettingsAllSitesSort", IDS_SETTINGS_SITE_SETTINGS_ALL_SITES_SORT},
+ {"siteSettingsAllSitesSortMethodMostVisited",
+ IDS_SETTINGS_SITE_SETTINGS_ALL_SITES_SORT_METHOD_MOST_VISITED},
+ {"siteSettingsAllSitesSortMethodStorage",
+ IDS_SETTINGS_SITE_SETTINGS_ALL_SITES_SORT_METHOD_STORAGE},
{"siteSettingsAllSitesSortMethodName",
IDS_SETTINGS_SITE_SETTINGS_ALL_SITES_SORT_METHOD_NAME},
{"siteSettingsSiteRepresentationSeparator",
@@ -2337,11 +2398,16 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_ASK_DEFAULT_MENU},
{"siteSettingsActionAllowDefault",
IDS_SETTINGS_SITE_SETTINGS_ALLOW_DEFAULT_MENU},
+ {"siteSettingsActionAutomaticDefault",
+ IDS_SETTINGS_SITE_SETTINGS_AUTOMATIC_DEFAULT_MENU},
{"siteSettingsActionBlockDefault",
IDS_SETTINGS_SITE_SETTINGS_BLOCK_DEFAULT_MENU},
+ {"siteSettingsActionMuteDefault",
+ IDS_SETTINGS_SITE_SETTINGS_MUTE_DEFAULT_MENU},
{"siteSettingsActionAllow", IDS_SETTINGS_SITE_SETTINGS_ALLOW_MENU},
{"siteSettingsActionBlock", IDS_SETTINGS_SITE_SETTINGS_BLOCK_MENU},
{"siteSettingsActionAsk", IDS_SETTINGS_SITE_SETTINGS_ASK_MENU},
+ {"siteSettingsActionMute", IDS_SETTINGS_SITE_SETTINGS_MUTE_MENU},
{"siteSettingsActionReset", IDS_SETTINGS_SITE_SETTINGS_RESET_MENU},
{"siteSettingsActionSessionOnly",
IDS_SETTINGS_SITE_SETTINGS_SESSION_ONLY_MENU},
@@ -2427,6 +2493,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLER_ALLOW_RECOMMENDED},
{"siteSettingsPaymentHandlerBlock",
IDS_SETTINGS_SITE_SETTINGS_PAYMENT_HANDLER_BLOCK},
+ {"siteSettingsBlockAutoplaySetting",
+ IDS_SETTINGS_SITE_SETTINGS_BLOCK_AUTOPLAY},
};
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
@@ -2443,6 +2511,10 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
base::FeatureList::IsEnabled(features::kSoundContentSetting));
html_source->AddBoolean(
+ "enableBlockAutoplayContentSetting",
+ base::FeatureList::IsEnabled(media::kAutoplaySoundSettings));
+
+ html_source->AddBoolean(
"enableClipboardContentSetting",
base::FeatureList::IsEnabled(features::kClipboardContentSetting));
@@ -2568,11 +2640,13 @@ void AddMultideviceStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_MULTIDEVICE_INSTANT_TETHERING},
{"multideviceAndroidMessagesItemTitle",
IDS_SETTINGS_MULTIDEVICE_ANDROID_MESSAGES},
- {"multideviceAndroidMessagesItemSummary",
- IDS_SETTINGS_MULTIDEVICE_ANDROID_MESSAGES_SUMMARY},
{"multideviceForgetDevice", IDS_SETTINGS_MULTIDEVICE_FORGET_THIS_DEVICE},
{"multideviceForgetDeviceSummary",
IDS_SETTINGS_MULTIDEVICE_FORGET_THIS_DEVICE_EXPLANATION},
+ {"multideviceForgetDeviceDialogHeading",
+ IDS_SETTINGS_MULTIDEVICE_FORGET_DEVICE_DIALOG_HEADING},
+ {"multideviceForgetDeviceDialogMessage",
+ IDS_SETTINGS_MULTIDEVICE_FORGET_DEVICE_DIALOG_MESSAGE},
};
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
@@ -2585,22 +2659,40 @@ void AddMultideviceStrings(content::WebUIDataSource* html_source) {
"multideviceVerificationText",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_MULTIDEVICE_VERIFICATION_TEXT,
- GetHelpUrlWithBoard(chrome::kMultiDeviceLearnMoreURL)));
+ base::UTF8ToUTF16(
+ chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl()
+ .spec())));
html_source->AddString(
"multideviceCouldNotConnect",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_MULTIDEVICE_COULD_NOT_CONNECT,
- GetHelpUrlWithBoard(chrome::kMultiDeviceLearnMoreURL)));
+ base::UTF8ToUTF16(
+ chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl()
+ .spec())));
html_source->AddString(
"multideviceSetupSummary",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_MULTIDEVICE_SETUP_SUMMARY,
- GetHelpUrlWithBoard(chrome::kMultiDeviceLearnMoreURL)));
+ base::UTF8ToUTF16(
+ chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl()
+ .spec())));
+ html_source->AddString(
+ "multideviceNoHostText",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_MULTIDEVICE_NO_ELIGIBLE_HOSTS,
+ base::UTF8ToUTF16(
+ chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl()
+ .spec())));
html_source->AddString(
"multideviceSmartLockItemSummary",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_MULTIDEVICE_SMART_LOCK_SUMMARY,
GetHelpUrlWithBoard(chrome::kEasyUnlockLearnMoreUrl)));
+ html_source->AddString(
+ "multideviceAndroidMessagesItemSummary",
+ l10n_util::GetStringFUTF16(
+ IDS_SETTINGS_MULTIDEVICE_ANDROID_MESSAGES_SUMMARY,
+ GetHelpUrlWithBoard(chrome::kAndroidMessagesLearnMoreURL)));
}
#endif
@@ -2628,7 +2720,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
AddDownloadsStrings(html_source);
AddLanguagesStrings(html_source);
AddOnStartupStrings(html_source);
- AddPasswordsAndFormsStrings(html_source);
+ AddPasswordsAndFormsStrings(html_source, profile);
AddPeopleStrings(html_source, profile);
AddPrintingStrings(html_source);
AddPrivacyStrings(html_source, profile);
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
index e2feea6212e..fa6dd8d8b36 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
+++ b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
@@ -11,11 +11,11 @@
#include <utility>
#include <vector>
+#include "ash/public/cpp/ash_features.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/browser/ui/webui/settings/about_handler.h"
#include "chrome/browser/ui/webui/settings/appearance_handler.h"
@@ -45,10 +45,12 @@
#include "chrome/grit/settings_resources_map.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/pref_registry/pref_registry_syncable.h"
+#include "components/unified_consent/feature.h"
#include "content/public/browser/navigation_handle.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 "content/public/common/content_features.h"
#include "printing/buildflags/buildflags.h"
#if defined(OS_WIN)
@@ -73,7 +75,10 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
+#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
+#include "chrome/browser/chromeos/multidevice_setup/android_sms_app_helper_delegate_impl.h"
+#include "chrome/browser/chromeos/multidevice_setup/multidevice_setup_client_factory.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h"
@@ -96,6 +101,7 @@
#include "chrome/common/chrome_switches.h"
#include "chromeos/account_manager/account_manager.h"
#include "chromeos/account_manager/account_manager_factory.h"
+#include "chromeos/chromeos_features.h"
#include "chromeos/chromeos_switches.h"
#include "components/arc/arc_util.h"
#include "ui/base/ui_base_features.h"
@@ -213,8 +219,19 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
}
AddSettingsPageUIHandler(
std::make_unique<chromeos::settings::KeyboardHandler>());
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::MultideviceHandler>());
+ if (base::FeatureList::IsEnabled(
+ chromeos::features::kEnableUnifiedMultiDeviceSetup) &&
+ base::FeatureList::IsEnabled(
+ chromeos::features::kEnableUnifiedMultiDeviceSettings) &&
+ base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) {
+ AddSettingsPageUIHandler(
+ std::make_unique<chromeos::settings::MultideviceHandler>(
+ chromeos::multidevice_setup::MultiDeviceSetupClientFactory::
+ GetForProfile(profile),
+ std::make_unique<
+ chromeos::multidevice_setup::AndroidSmsAppHelperDelegateImpl>(
+ profile)));
+ }
AddSettingsPageUIHandler(
std::make_unique<chromeos::settings::PointerHandler>());
AddSettingsPageUIHandler(
@@ -297,12 +314,22 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
chromeos::quick_unlock::IsPinDisabledByPolicy(profile->GetPrefs()));
html_source->AddBoolean("fingerprintUnlockEnabled",
chromeos::quick_unlock::IsFingerprintEnabled());
+ html_source->AddBoolean("lockScreenNotificationsEnabled",
+ ash::features::IsLockScreenNotificationsEnabled());
+ html_source->AddBoolean(
+ "lockScreenHideSensitiveNotificationsSupported",
+ ash::features::IsLockScreenHideSensitiveNotificationsSupported());
html_source->AddBoolean("hasInternalStylus",
ash::stylus_utils::HasInternalStylus());
html_source->AddBoolean("showCrostini",
IsCrostiniUIAllowedForProfile(profile));
+ // TODO(crbug.com/868747): Show an explanatory message instead of hiding the
+ // storage management info.
+ html_source->AddBoolean("hideStorageInfo",
+ chromeos::DemoSession::IsDeviceInDemoMode());
+
// We have 2 variants of Android apps settings. Default case, when the Play
// Store app exists we show expandable section that allows as to
// enable/disable the Play Store and link to Android settings which is
@@ -315,8 +342,8 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source->AddBoolean("androidAppsVisible", androidAppsVisible);
html_source->AddBoolean("havePlayStoreApp", arc::IsPlayStoreAvailable());
- // TODO(mash): Support Chrome power settings in Mash. crbug.com/644348
- bool enable_power_settings = features::IsAshInBrowserProcess();
+ // TODO(mash): Support Chrome power settings in Mash. https://crbug.com/644348
+ bool enable_power_settings = !features::IsMultiProcessMash();
html_source->AddBoolean("enablePowerSettings", enable_power_settings);
if (enable_power_settings) {
AddSettingsPageUIHandler(std::make_unique<chromeos::settings::PowerHandler>(
@@ -329,7 +356,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
#endif // defined(OS_CHROMEOS)
html_source->AddBoolean("unifiedConsentEnabled",
- IsUnifiedConsentEnabled(profile));
+ unified_consent::IsUnifiedConsentFeatureEnabled());
// TODO(jdoerrie): https://crbug.com/854562.
// Remove once Autofill Home is launched.
@@ -350,12 +377,18 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
#if BUILDFLAG(OPTIMIZE_WEBUI)
+ const bool use_polymer_2 =
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2);
html_source->AddResourcePath("crisper.js", IDR_MD_SETTINGS_CRISPER_JS);
html_source->AddResourcePath("lazy_load.crisper.js",
IDR_MD_SETTINGS_LAZY_LOAD_CRISPER_JS);
- html_source->AddResourcePath("lazy_load.html",
- IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_HTML);
- html_source->SetDefaultResource(IDR_MD_SETTINGS_VULCANIZED_HTML);
+ html_source->AddResourcePath(
+ "lazy_load.html", use_polymer_2
+ ? IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML
+ : IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_HTML);
+ html_source->SetDefaultResource(use_polymer_2
+ ? IDR_MD_SETTINGS_VULCANIZED_P2_HTML
+ : IDR_MD_SETTINGS_VULCANIZED_HTML);
html_source->UseGzip(exclude_from_gzip);
#else
// Add all settings resources.
@@ -372,8 +405,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source);
}
-MdSettingsUI::~MdSettingsUI() {
-}
+MdSettingsUI::~MdSettingsUI() {}
void MdSettingsUI::AddSettingsPageUIHandler(
std::unique_ptr<content::WebUIMessageHandler> handler) {
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
index d33f651f224..57fe25578d1 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
@@ -26,7 +26,6 @@
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/signin/signin_ui_util.h"
-#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -39,7 +38,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/autofill/core/common/autofill_constants.h"
-#include "components/autofill/core/common/autofill_pref_names.h"
+#include "components/autofill/core/common/autofill_prefs.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/profile_management_switches.h"
@@ -49,8 +48,10 @@
#include "components/signin/core/browser/signin_metrics.h"
#include "components/signin/core/browser/signin_pref_names.h"
#include "components/strings/grit/components_strings.h"
-#include "components/sync/base/passphrase_type.h"
+#include "components/sync/base/passphrase_enums.h"
#include "components/sync/base/sync_prefs.h"
+#include "components/unified_consent/feature.h"
+#include "components/unified_consent/unified_consent_metrics.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
@@ -70,6 +71,7 @@
#endif
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
+#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -182,6 +184,27 @@ std::string GetSyncErrorAction(sync_ui_util::ActionType action_type) {
}
}
+#if BUILDFLAG(ENABLE_DICE_SUPPORT)
+// Returns the base::Value associated with the account, to use in the stored
+// accounts list.
+base::Value GetAccountValue(const AccountInfo& account,
+ AccountTrackerService* account_tracker) {
+ DCHECK(!account.IsEmpty());
+ base::Value dictionary(base::Value::Type::DICTIONARY);
+ dictionary.SetKey("email", base::Value(account.email));
+ dictionary.SetKey("fullName", base::Value(account.full_name));
+ dictionary.SetKey("givenName", base::Value(account.given_name));
+ const gfx::Image& account_image =
+ account_tracker->GetAccountImage(account.account_id);
+ if (!account_image.IsEmpty()) {
+ dictionary.SetKey(
+ "avatarImage",
+ base::Value(webui::GetBitmapDataUrl(account_image.AsBitmap())));
+ }
+ return dictionary;
+}
+#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
+
} // namespace
namespace settings {
@@ -242,6 +265,10 @@ void PeopleHandler::RegisterMessages() {
"SyncSetupManageOtherPeople",
base::BindRepeating(&PeopleHandler::HandleManageOtherPeople,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "UnifiedConsentToggleChanged",
+ base::BindRepeating(&PeopleHandler::OnUnifiedConsentToggleChanged,
+ base::Unretained(this)));
#if defined(OS_CHROMEOS)
web_ui()->RegisterMessageCallback(
"AttemptUserExit",
@@ -256,6 +283,9 @@ void PeopleHandler::RegisterMessages() {
"SyncSetupSignout", base::BindRepeating(&PeopleHandler::HandleSignout,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "SyncSetupPauseSync", base::BindRepeating(&PeopleHandler::HandlePauseSync,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"SyncSetupStartSignIn",
base::BindRepeating(&PeopleHandler::HandleStartSignin,
base::Unretained(this)));
@@ -330,6 +360,15 @@ void PeopleHandler::DisplayGaiaLoginInNewTabOrWindow(
force_new_tab = true;
}
+ ProfileSyncService* service = GetSyncService();
+ if (service && service->HasUnrecoverableError()) {
+ // When the user has an unrecoverable error, they first have to sign out and
+ // then sign in again.
+ SigninManagerFactory::GetForProfile(browser->profile())
+ ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS,
+ signin_metrics::SignoutDelete::IGNORE_METRIC);
+ }
+
// If the signin manager already has an authenticated username, this is a
// re-auth scenario, and we need to ensure that the user signs in with the
// same email address.
@@ -442,9 +481,8 @@ void PeopleHandler::HandleSetDatatypes(const base::ListValue* args) {
const base::Value* callback_id = nullptr;
ParseConfigurationArguments(args, &configuration, &callback_id);
- PrefService* pref_service = profile_->GetPrefs();
- pref_service->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled,
- configuration.payments_integration_enabled);
+ autofill::prefs::SetPaymentsIntegrationEnabled(
+ profile_->GetPrefs(), configuration.payments_integration_enabled);
// Start configuring the ProfileSyncService using the configuration passed
// to us from the JS layer.
@@ -482,32 +520,45 @@ void PeopleHandler::OnAccountUpdated(const AccountInfo& info) {
FireWebUIListener("stored-accounts-updated", *GetStoredAccountsList());
}
+void PeopleHandler::OnAccountImageUpdated(const std::string& account_id,
+ const gfx::Image& image) {
+ FireWebUIListener("stored-accounts-updated", *GetStoredAccountsList());
+}
+
void PeopleHandler::OnAccountRemoved(const AccountInfo& info) {
FireWebUIListener("stored-accounts-updated", *GetStoredAccountsList());
}
std::unique_ptr<base::ListValue> PeopleHandler::GetStoredAccountsList() {
- std::vector<AccountInfo> accounts =
- signin_ui_util::GetAccountsForDicePromos(profile_);
+ std::unique_ptr<base::ListValue> accounts_list =
+ std::make_unique<base::ListValue>();
+ bool dice_enabled =
+ AccountConsistencyModeManager::IsDiceEnabledForProfile(profile_);
+
+ // Dice and unified consent both disabled: do not show the list of accounts.
+ if (!dice_enabled && !unified_consent::IsUnifiedConsentFeatureEnabled())
+ return accounts_list;
AccountTrackerService* account_tracker =
AccountTrackerServiceFactory::GetForProfile(profile_);
- std::unique_ptr<base::ListValue> accounts_list(new base::ListValue);
- accounts_list->Reserve(accounts.size());
-
- for (auto const& account : accounts) {
- accounts_list->GetList().push_back(
- base::Value(base::Value::Type::DICTIONARY));
- base::Value& acc = accounts_list->GetList().back();
- acc.SetKey("email", base::Value(account.email));
- acc.SetKey("fullName", base::Value(account.full_name));
- acc.SetKey("givenName", base::Value(account.given_name));
- const gfx::Image& account_image =
- account_tracker->GetAccountImage(account.account_id);
- if (!account_image.IsEmpty()) {
- acc.SetKey(
- "avatarImage",
- base::Value(webui::GetBitmapDataUrl(account_image.AsBitmap())));
+
+ if (dice_enabled) {
+ // If dice is enabled, show all the accounts.
+ std::vector<AccountInfo> accounts =
+ signin_ui_util::GetAccountsForDicePromos(profile_);
+ accounts_list->Reserve(accounts.size());
+ for (auto const& account : accounts) {
+ accounts_list->GetList().push_back(
+ GetAccountValue(account, account_tracker));
+ }
+ } else {
+ // If dice is disabled (and unified consent enabled), show only the primary
+ // account.
+ std::string primary_account = SigninManagerFactory::GetForProfile(profile_)
+ ->GetAuthenticatedAccountId();
+ if (!primary_account.empty()) {
+ accounts_list->GetList().push_back(GetAccountValue(
+ account_tracker->GetAccountInfo(primary_account), account_tracker));
}
}
@@ -515,6 +566,7 @@ std::unique_ptr<base::ListValue> PeopleHandler::GetStoredAccountsList() {
}
void PeopleHandler::HandleStartSyncingWithEmail(const base::ListValue* args) {
+ DCHECK(AccountConsistencyModeManager::IsDiceEnabledForProfile(profile_));
const base::Value* email;
const base::Value* is_default_promo_account;
CHECK(args->Get(0, &email));
@@ -615,19 +667,14 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) {
ProfileSyncService* service = GetSyncService();
- // Just let the page open for now, even when the user's not signed in or sync
- // is disabled.
- // TODO(scottchen): finish the UI for signed-out users
- // (https://crbug.com/800972).
- if (IsUnifiedConsentEnabled(profile_) &&
- (IsProfileAuthNeededOrHasErrors() || !service)) {
+ if (unified_consent::IsUnifiedConsentFeatureEnabled()) {
if (service && !sync_blocker_)
sync_blocker_ = service->GetSetupInProgressHandle();
- // Preemptively mark login UI as active, because the user could potentially
- // sign-in directly from this UI without triggering handleShowSetupUI again.
GetLoginUIService()->SetLoginUI(this);
- FireWebUIListener("sync-prefs-changed", base::DictionaryValue());
+
+ PushSyncPrefs();
+ // Always let the page open when unified consent is enabled.
return;
}
@@ -660,11 +707,25 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) {
if (sync_startup_tracker_)
return;
- if (!service->IsEngineInitialized()) {
+ if (!service->IsEngineInitialized() ||
+ service->HasDisableReason(
+ syncer::SyncService::DISABLE_REASON_USER_CHOICE)) {
// Requesting the sync service to start may trigger call to PushSyncPrefs.
// Setting up the startup tracker beforehand correctly signals the
// re-entrant call to early exit.
- sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this));
+ sync_startup_tracker_ =
+ std::make_unique<SyncStartupTracker>(profile_, this);
+ // RequestStart() does two things:
+ // 1) If DISABLE_REASON_USER_CHOICE is set (meaning that Sync was reset via
+ // the dashboard), clears it.
+ // 2) Pokes the sync service to start *immediately*, i.e. bypass deferred
+ // startup.
+ // It's possible that both of these are already the case, i.e. the engine is
+ // already in the process of initializing, in which case RequestStart() will
+ // effectively do nothing. It's also possible that the sync service is
+ // already running in standalone transport mode and so the engine is already
+ // initialized. In that case, this will trigger the service to switch to
+ // full Sync-the-feature mode.
service->RequestStart();
// See if it's even possible to bring up the sync engine - if not
@@ -704,9 +765,11 @@ void PeopleHandler::HandleRequestPinLoginState(const base::ListValue* args) {
void PeopleHandler::HandleStartSignin(const base::ListValue* args) {
AllowJavascript();
- // Should only be called if the user is not already signed in or has an auth
- // error.
- DCHECK(IsProfileAuthNeededOrHasErrors());
+ // Should only be called if the user is not already signed in, has a auth
+ // error, or a unrecoverable sync error requiring re-auth.
+ ProfileSyncService* service = GetSyncService();
+ DCHECK(IsProfileAuthNeededOrHasErrors() ||
+ (service && service->HasUnrecoverableError()));
DisplayGaiaLogin(signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS);
}
@@ -742,6 +805,15 @@ void PeopleHandler::HandleSignout(const base::ListValue* args) {
ProfileMetrics::DELETE_PROFILE_SETTINGS);
}
}
+
+void PeopleHandler::HandlePauseSync(const base::ListValue* args) {
+ DCHECK(AccountConsistencyModeManager::IsDiceEnabledForProfile(profile_));
+ SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_);
+ DCHECK(signin_manager->IsAuthenticated());
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->UpdateCredentials(
+ signin_manager->GetAuthenticatedAccountId(),
+ OAuth2TokenServiceDelegate::kInvalidRefreshToken);
+}
#endif
void PeopleHandler::HandleGetSyncStatus(const base::ListValue* args) {
@@ -761,6 +833,15 @@ void PeopleHandler::HandleManageOtherPeople(const base::ListValue* /* args */) {
#endif // !defined(OS_CHROMEOS)
}
+void PeopleHandler::OnUnifiedConsentToggleChanged(const base::ListValue* args) {
+ bool is_toggle_checked = args->GetList()[0].GetBool();
+ if (!is_toggle_checked) {
+ unified_consent::metrics::RecordUnifiedConsentRevoked(
+ unified_consent::metrics::UnifiedConsentRevokeReason::
+ kUserDisabledSettingsToggle);
+ }
+}
+
void PeopleHandler::CloseSyncSetup() {
// Stop a timer to handle timeout in waiting for checking network connection.
engine_start_timer_.reset();
@@ -905,10 +986,9 @@ PeopleHandler::GetSyncStatusDictionary() {
base::string16 link_label;
sync_ui_util::ActionType action_type = sync_ui_util::NO_ACTION;
bool status_has_error =
- sync_ui_util::GetStatusLabels(profile_, service, *signin,
- sync_ui_util::PLAIN_TEXT, &status_label,
- &link_label, &action_type) ==
- sync_ui_util::SYNC_ERROR;
+ sync_ui_util::GetStatusLabels(profile_, service, *signin, &status_label,
+ &link_label,
+ &action_type) == sync_ui_util::SYNC_ERROR;
sync_status->SetString("statusText", status_label);
sync_status->SetBoolean("hasError", status_has_error);
sync_status->SetString("statusAction", GetSyncErrorAction(action_type));
@@ -976,9 +1056,8 @@ void PeopleHandler::PushSyncPrefs() {
PrefService* pref_service = profile_->GetPrefs();
syncer::SyncPrefs sync_prefs(pref_service);
args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced());
- args.SetBoolean(
- "paymentsIntegrationEnabled",
- pref_service->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled));
+ args.SetBoolean("paymentsIntegrationEnabled",
+ autofill::prefs::IsPaymentsIntegrationEnabled(pref_service));
args.SetBoolean("encryptAllData", service->IsEncryptEverythingEnabled());
args.SetBoolean("encryptAllDataAllowed",
service->IsEncryptEverythingAllowed());
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.h b/chromium/chrome/browser/ui/webui/settings/people_handler.h
index bfedcdc900e..6652b50d0a1 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.h
@@ -88,7 +88,6 @@ class PeopleHandler : public SettingsPageUIHandler,
PeopleHandlerTest,
DisplayConfigureWithEngineDisabledAndSyncStartupCompleted);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, SelectCustomEncryption);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
ShowSetupCustomPassphraseRequired);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSetupEncryptAll);
@@ -102,9 +101,7 @@ class PeopleHandler : public SettingsPageUIHandler,
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSigninOnAuthError);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSyncSetup);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, SuccessfullySetPassphrase);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncEverything);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncNothing);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncAllManually);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestPassphraseStillRequired);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncIndividualTypes);
@@ -117,13 +114,15 @@ class PeopleHandler : public SettingsPageUIHandler,
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest,
UnrecoverableErrorInitializingSync);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest, HandleCaptcha);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerNonCrosTest,
- SubmitAuthWithInvalidUsername);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerFirstSigninTest, DisplayBasicLogin);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
AcquireSyncBlockerWhenLoadingSyncSettingsSubpage);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, RestartSyncAfterDashboardClear);
+ FRIEND_TEST_ALL_PREFIXES(
+ PeopleHandlerTest,
+ RestartSyncAfterDashboardClearWithStandaloneTransport);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerDiceUnifiedConsentTest,
+ StoredAccountsList);
// SettingsPageUIHandler implementation.
void RegisterMessages() override;
@@ -149,6 +148,8 @@ class PeopleHandler : public SettingsPageUIHandler,
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
// AccountTrackerService::Observer implementation.
void OnAccountUpdated(const AccountInfo& info) override;
+ void OnAccountImageUpdated(const std::string& account_id,
+ const gfx::Image& image) override;
void OnAccountRemoved(const AccountInfo& info) override;
#endif
@@ -173,10 +174,14 @@ class PeopleHandler : public SettingsPageUIHandler,
#if defined(OS_CHROMEOS)
void HandleRequestPinLoginState(const base::ListValue* args);
#endif
+#if !defined(OS_CHROMEOS)
void HandleStartSignin(const base::ListValue* args);
void HandleSignout(const base::ListValue* args);
+ void HandlePauseSync(const base::ListValue* args);
+#endif
void HandleGetSyncStatus(const base::ListValue* args);
void HandleManageOtherPeople(const base::ListValue* args);
+ void OnUnifiedConsentToggleChanged(const base::ListValue* args);
#if !defined(OS_CHROMEOS)
// Displays the GAIA login form.
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 58a9f2b000a..d2f47257478 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
@@ -14,7 +14,10 @@
#include "base/stl_util.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_signin_manager_builder.h"
+#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/scoped_account_consistency.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -31,10 +34,13 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_auth_status_provider.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync/base/sync_prefs.h"
#include "components/sync_preferences/pref_service_syncable.h"
+#include "components/unified_consent/scoped_unified_consent.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller.h"
@@ -182,10 +188,9 @@ class TestingPeopleHandler : public PeopleHandler {
class TestWebUIProvider
: public TestChromeWebUIControllerFactory::WebUIProvider {
public:
- content::WebUIController* NewWebUI(content::WebUI* web_ui,
- const GURL& url) override {
- content::WebUIController* controller = new content::WebUIController(web_ui);
- return controller;
+ std::unique_ptr<content::WebUIController> NewWebUI(content::WebUI* web_ui,
+ const GURL& url) override {
+ return std::make_unique<content::WebUIController>(web_ui);
}
};
@@ -208,7 +213,7 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
mock_pss_ = static_cast<ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile(), BuildMockProfileSyncService));
- EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
+ ON_CALL(*mock_pss_, GetAuthError()).WillByDefault(ReturnRef(error_));
ON_CALL(*mock_pss_, GetPassphraseType())
.WillByDefault(Return(syncer::PassphraseType::IMPLICIT_PASSPHRASE));
ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault(
@@ -235,25 +240,26 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
// Setup the expectations for calls made when displaying the config page.
void SetDefaultExpectationsForConfigPage() {
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(Return(syncer::SyncService::DISABLE_REASON_NONE));
- EXPECT_CALL(*mock_pss_, GetRegisteredDataTypes())
- .WillRepeatedly(Return(GetAllTypes()));
- EXPECT_CALL(*mock_pss_, GetPreferredDataTypes())
- .WillRepeatedly(Return(GetAllTypes()));
- EXPECT_CALL(*mock_pss_, GetActiveDataTypes())
- .WillRepeatedly(Return(GetAllTypes()));
- EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_pss_, GetRegisteredDataTypes())
+ .WillByDefault(Return(GetAllTypes()));
+ ON_CALL(*mock_pss_, GetPreferredDataTypes())
+ .WillByDefault(Return(GetAllTypes()));
+ ON_CALL(*mock_pss_, GetActiveDataTypes())
+ .WillByDefault(Return(GetAllTypes()));
+ ON_CALL(*mock_pss_, IsEncryptEverythingAllowed())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, IsEncryptEverythingEnabled())
+ .WillByDefault(Return(false));
}
void SetupInitializedProfileSyncService() {
// An initialized ProfileSyncService will have already completed sync setup
// and will have an initialized sync engine.
ASSERT_TRUE(mock_signin_->IsInitialized());
- EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(true));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
}
void ExpectPageStatusResponse(const std::string& expected_status) {
@@ -336,10 +342,9 @@ TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) {
// Test that the HandleStartSignin call enables JavaScript.
handler_->DisallowJavascript();
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(
- Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
- EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
// Ensure that the user is not signed in before calling |HandleStartSignin()|.
SigninManager* manager = SigninManager::FromSigninManagerBase(mock_signin_);
manager->SignOut(signin_metrics::SIGNOUT_TEST,
@@ -361,10 +366,9 @@ TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) {
}
TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) {
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(
- Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
- EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
handler_->HandleShowSetupUI(nullptr);
ExpectPageStatusChanged(PeopleHandler::kDonePageStatus);
@@ -379,8 +383,8 @@ TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) {
// Verifies that the sync setup is terminated correctly when the
// sync is disabled.
TEST_F(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled) {
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(
Return(syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY));
handler_->HandleShowSetupUI(nullptr);
@@ -394,11 +398,12 @@ TEST_F(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled) {
// Verifies that the handler correctly handles a cancellation when
// it is displaying the spinner to the user.
TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndCancel) {
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(Return(syncer::SyncService::DISABLE_REASON_NONE));
- EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
error_ = GoogleServiceAuthError::AuthErrorNone();
- EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
EXPECT_CALL(*mock_pss_, RequestStart());
// We're simulating a user setting up sync, which would cause the engine to
@@ -419,12 +424,14 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndCancel) {
// to showing a configuration page when sync setup completes successfully.
TEST_F(PeopleHandlerTest,
DisplayConfigureWithEngineDisabledAndSyncStartupCompleted) {
- EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
error_ = GoogleServiceAuthError::AuthErrorNone();
// Sync engine is stopped initially, and will start up.
- EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(
+ syncer::SyncService::TransportState::WAITING_FOR_START_REQUEST));
EXPECT_CALL(*mock_pss_, RequestStart());
SetDefaultExpectationsForConfigPage();
@@ -436,9 +443,10 @@ TEST_F(PeopleHandlerTest,
Mock::VerifyAndClearExpectations(mock_pss_);
// Now, act as if the ProfileSyncService has started up.
SetDefaultExpectationsForConfigPage();
- EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(true));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
error_ = GoogleServiceAuthError::AuthErrorNone();
- EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
+ ON_CALL(*mock_pss_, GetAuthError()).WillByDefault(ReturnRef(error_));
handler_->SyncStartupCompleted();
EXPECT_EQ(2U, web_ui_.call_data().size());
@@ -457,13 +465,13 @@ TEST_F(PeopleHandlerTest,
// user has continued on.
TEST_F(PeopleHandlerTest,
DisplayConfigureWithEngineDisabledAndCancelAfterSigninSuccess) {
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(Return(syncer::SyncService::DISABLE_REASON_NONE));
- EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
error_ = GoogleServiceAuthError::AuthErrorNone();
- EXPECT_CALL(*mock_pss_, IsEngineInitialized())
- .WillOnce(Return(false))
- .WillRepeatedly(Return(true));
+ EXPECT_CALL(*mock_pss_, GetTransportState())
+ .WillOnce(Return(syncer::SyncService::TransportState::INITIALIZING))
+ .WillRepeatedly(Return(syncer::SyncService::TransportState::ACTIVE));
EXPECT_CALL(*mock_pss_, RequestStart());
SetDefaultExpectationsForConfigPage();
handler_->HandleShowSetupUI(nullptr);
@@ -481,11 +489,12 @@ TEST_F(PeopleHandlerTest,
}
TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) {
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(Return(syncer::SyncService::DISABLE_REASON_NONE));
- EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
error_ = GoogleServiceAuthError::AuthErrorNone();
- EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
EXPECT_CALL(*mock_pss_, RequestStart());
handler_->HandleShowSetupUI(nullptr);
@@ -493,7 +502,7 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) {
Mock::VerifyAndClearExpectations(mock_pss_);
error_ = GoogleServiceAuthError(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
+ ON_CALL(*mock_pss_, GetAuthError()).WillByDefault(ReturnRef(error_));
NotifySyncListeners();
// On failure, the dialog will be closed.
@@ -502,10 +511,61 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) {
LoginUIServiceFactory::GetForProfile(profile())->current_login_ui());
}
+TEST_F(PeopleHandlerTest, RestartSyncAfterDashboardClear) {
+ // Clearing sync from the dashboard results in DISABLE_REASON_USER_CHOICE
+ // being set.
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_USER_CHOICE));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::DISABLED));
+
+ // Attempting to open the setup UI should restart sync.
+ EXPECT_CALL(*mock_pss_, RequestStart()).WillOnce([&]() {
+ // RequestStart() clears DISABLE_REASON_USER_CHOICE, and immediately starts
+ // initialzing the engine.
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::INITIALIZING));
+ });
+
+ handler_->HandleShowSetupUI(nullptr);
+ ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
+}
+
+TEST_F(PeopleHandlerTest,
+ RestartSyncAfterDashboardClearWithStandaloneTransport) {
+ // Clearing sync from the dashboard results in DISABLE_REASON_USER_CHOICE
+ // being set. However, the sync engine has restarted in standalone transport
+ // mode.
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_USER_CHOICE));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
+
+ // Attempting to open the setup UI should re-enable sync-the-feature.
+ EXPECT_CALL(*mock_pss_, RequestStart()).WillOnce([&]() {
+ // RequestStart() clears DISABLE_REASON_USER_CHOICE. Since the engine is
+ // already running, it just gets reconfigured.
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::CONFIGURING));
+ });
+
+ handler_->HandleShowSetupUI(nullptr);
+ ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
+}
+
// Tests that signals not related to user intention to configure sync don't
// trigger sync engine start.
TEST_F(PeopleHandlerTest, OnlyStartEngineWhenConfiguringSync) {
- EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
EXPECT_CALL(*mock_pss_, RequestStart()).Times(0);
NotifySyncStateChanged();
}
@@ -541,10 +601,10 @@ class PeopleHandlerNonCrosTest : public PeopleHandlerTest {
// TODO(kochi): We need equivalent tests for ChromeOS.
TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) {
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(
Return(syncer::SyncService::DISABLE_REASON_UNRECOVERABLE_ERROR));
- EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
// Open the web UI.
handler_->HandleShowSetupUI(nullptr);
@@ -552,10 +612,9 @@ TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) {
}
TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) {
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(
- Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
- EXPECT_CALL(*mock_pss_, IsFirstSetupComplete()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
+ ON_CALL(*mock_pss_, IsFirstSetupComplete()).WillByDefault(Return(false));
// Open the web UI.
handler_->HandleShowSetupUI(nullptr);
@@ -570,10 +629,9 @@ TEST_F(PeopleHandlerTest, TestSyncEverything) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
handler_->HandleSetDatatypes(&list_args);
@@ -587,12 +645,11 @@ TEST_F(PeopleHandlerTest, TestPassphraseStillRequired) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
SetDefaultExpectationsForConfigPage();
@@ -612,10 +669,10 @@ TEST_F(PeopleHandlerTest, EnterExistingFrozenImplicitPassword) {
// Act as if an encryption passphrase is required the first time, then never
// again after that.
EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("oldGaiaPassphrase"))
.WillOnce(Return(true));
@@ -632,12 +689,11 @@ TEST_F(PeopleHandlerTest, SetNewCustomPassphrase) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_,
SetEncryptionPassphrase("custom_passphrase",
@@ -655,12 +711,11 @@ TEST_F(PeopleHandlerTest, EnterWrongExistingPassphrase) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("invalid_passphrase")).
WillOnce(Return(false));
@@ -683,12 +738,11 @@ TEST_F(PeopleHandlerTest, EnterBlankExistingPassphrase) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
SetDefaultExpectationsForConfigPage();
@@ -702,10 +756,9 @@ TEST_F(PeopleHandlerTest, EnterBlankExistingPassphrase) {
// data type.
TEST_F(PeopleHandlerTest, TestSyncIndividualTypes) {
syncer::ModelTypeSet user_selectable_types = GetAllTypes();
- syncer::ModelTypeSet::Iterator it;
- for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
+ for (syncer::ModelType type : user_selectable_types) {
syncer::ModelTypeSet type_to_set;
- type_to_set.Put(it.Get());
+ type_to_set.Put(type);
std::string args = GetConfiguration(NULL,
CHOOSE_WHAT_TO_SYNC,
type_to_set,
@@ -714,10 +767,9 @@ TEST_F(PeopleHandlerTest, TestSyncIndividualTypes) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_,
OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set)));
@@ -737,10 +789,9 @@ TEST_F(PeopleHandlerTest, TestSyncAllManually) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_,
OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes())));
@@ -750,10 +801,9 @@ TEST_F(PeopleHandlerTest, TestSyncAllManually) {
}
TEST_F(PeopleHandlerTest, ShowSyncSetup) {
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
// This should display the sync setup dialog (not login).
SetDefaultExpectationsForConfigPage();
@@ -773,13 +823,13 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
FakeAuthStatusProvider provider(
SigninErrorControllerFactory::GetForProfile(profile()));
provider.SetAuthError(kTestUser, error_);
- EXPECT_CALL(*mock_pss_, GetDisableReasons())
- .WillRepeatedly(Return(syncer::SyncService::DISABLE_REASON_NONE));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsEngineInitialized()).WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
#if defined(OS_CHROMEOS)
// On ChromeOS, auth errors are ignored - instead we just try to start the
@@ -806,10 +856,9 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
}
TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) {
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
SetDefaultExpectationsForConfigPage();
// This should display the sync setup dialog (not login).
@@ -835,10 +884,9 @@ TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) {
}
TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) {
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
syncer::SyncPrefs sync_prefs(profile()->GetPrefs());
sync_prefs.SetKeepEverythingSynced(false);
@@ -852,20 +900,17 @@ TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) {
TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) {
syncer::ModelTypeSet user_selectable_types = GetAllTypes();
- syncer::ModelTypeSet::Iterator it;
- for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ for (syncer::ModelType type : user_selectable_types) {
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
syncer::SyncPrefs sync_prefs(profile()->GetPrefs());
sync_prefs.SetKeepEverythingSynced(false);
SetDefaultExpectationsForConfigPage();
syncer::ModelTypeSet types;
- types.Put(it.Get());
- EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()).
- WillRepeatedly(Return(types));
+ types.Put(type);
+ ON_CALL(*mock_pss_, GetPreferredDataTypes()).WillByDefault(Return(types));
// This should display the sync setup dialog (not login).
handler_->HandleShowSetupUI(nullptr);
@@ -883,10 +928,9 @@ TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) {
}
TEST_F(PeopleHandlerTest, ShowSetupOldGaiaPassphraseRequired) {
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, GetPassphraseType())
- .WillRepeatedly(
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, GetPassphraseType())
+ .WillByDefault(
Return(syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE));
SetupInitializedProfileSyncService();
SetDefaultExpectationsForConfigPage();
@@ -900,10 +944,9 @@ TEST_F(PeopleHandlerTest, ShowSetupOldGaiaPassphraseRequired) {
}
TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) {
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, GetPassphraseType())
- .WillRepeatedly(Return(syncer::PassphraseType::CUSTOM_PASSPHRASE));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(true));
+ ON_CALL(*mock_pss_, GetPassphraseType())
+ .WillByDefault(Return(syncer::PassphraseType::CUSTOM_PASSPHRASE));
SetupInitializedProfileSyncService();
SetDefaultExpectationsForConfigPage();
@@ -916,14 +959,12 @@ TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) {
}
TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) {
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
SetDefaultExpectationsForConfigPage();
- EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled())
- .WillRepeatedly(Return(true));
+ ON_CALL(*mock_pss_, IsEncryptEverythingEnabled()).WillByDefault(Return(true));
// This should display the sync setup dialog (not login).
handler_->HandleShowSetupUI(nullptr);
@@ -933,14 +974,13 @@ TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) {
}
TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) {
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(false));
SetupInitializedProfileSyncService();
SetDefaultExpectationsForConfigPage();
- EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsEncryptEverythingAllowed())
+ .WillByDefault(Return(false));
// This should display the sync setup dialog (not login).
handler_->HandleShowSetupUI(nullptr);
@@ -956,17 +996,75 @@ TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
- .WillRepeatedly(Return(false));
- EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_pss_, IsPassphraseRequired()).WillByDefault(Return(false));
SetupInitializedProfileSyncService();
- EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
- .WillRepeatedly(Return(false));
+ ON_CALL(*mock_pss_, IsEncryptEverythingAllowed())
+ .WillByDefault(Return(false));
EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
handler_->HandleSetEncryption(&list_args);
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
}
+#if BUILDFLAG(ENABLE_DICE_SUPPORT)
+class PeopleHandlerDiceUnifiedConsentTest
+ : public ::testing::TestWithParam<std::tuple<bool, bool>> {};
+
+TEST_P(PeopleHandlerDiceUnifiedConsentTest, StoredAccountsList) {
+ content::TestBrowserThreadBundle test_browser_thread_bundle;
+
+ // Decode test parameters.
+ bool dice_enabled;
+ bool unified_consent_enabled;
+ std::tie(dice_enabled, unified_consent_enabled) = GetParam();
+ unified_consent::ScopedUnifiedConsent unified_consent(
+ unified_consent_enabled
+ ? unified_consent::UnifiedConsentFeatureState::kEnabledWithBump
+ : unified_consent::UnifiedConsentFeatureState::kDisabled);
+ ScopedAccountConsistency dice(
+ dice_enabled ? signin::AccountConsistencyMethod::kDice
+ : signin::AccountConsistencyMethod::kDiceFixAuthErrors);
+
+ // Setup the profile.
+ TestingProfile profile;
+ AccountTrackerService* account_tracker =
+ AccountTrackerServiceFactory::GetForProfile(&profile);
+ SigninManager* signin_manager = SigninManagerFactory::GetForProfile(&profile);
+ ProfileOAuth2TokenService* token_service =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(&profile);
+ std::string account_1 =
+ account_tracker->SeedAccountInfo("1234", "a@gmail.com");
+ std::string account_2 =
+ account_tracker->SeedAccountInfo("5678", "b@gmail.com");
+ token_service->UpdateCredentials(account_1, "token");
+ token_service->UpdateCredentials(account_2, "token");
+ signin_manager->SetAuthenticatedAccountInfo("1234", "a@gmail.com");
+
+ PeopleHandler handler(&profile);
+ std::unique_ptr<base::ListValue> accounts_list =
+ handler.GetStoredAccountsList();
+
+ if (dice_enabled) {
+ EXPECT_EQ(2u, accounts_list->GetSize());
+ EXPECT_EQ("a@gmail.com",
+ accounts_list->GetList()[0].FindKey("email")->GetString());
+ EXPECT_EQ("b@gmail.com",
+ accounts_list->GetList()[1].FindKey("email")->GetString());
+ } else if (unified_consent_enabled) {
+ EXPECT_EQ(1u, accounts_list->GetSize());
+ EXPECT_EQ("a@gmail.com",
+ accounts_list->GetList()[0].FindKey("email")->GetString());
+ } else {
+ EXPECT_EQ(0u, accounts_list->GetSize());
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(Test,
+ PeopleHandlerDiceUnifiedConsentTest,
+ ::testing::Combine(::testing::Bool(),
+ ::testing::Bool()));
+#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
+
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
index 1f486d9b882..e91b7de825c 100644
--- a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc
@@ -17,7 +17,7 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
-#include "components/google/core/browser/google_util.h"
+#include "components/google/core/common/google_util.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
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 871a956100d..908a8d324a7 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
@@ -18,8 +18,11 @@
#include "chrome/browser/browsing_data/counters/browsing_data_counter_factory.h"
#include "chrome/browser/browsing_data/counters/browsing_data_counter_utils.h"
#include "chrome/browser/history/web_history_service_factory.h"
+#include "chrome/browser/signin/account_reconcilor_factory.h"
+#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
@@ -28,11 +31,11 @@
#include "components/feature_engagement/buildflags.h"
#include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h"
-#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browsing_data_filter_builder.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
+#include "services/identity/public/cpp/identity_manager.h"
#include "ui/base/text/bytes_formatting.h"
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
@@ -248,15 +251,27 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
checked_other_types);
}
+ // If Sync is running, prevent it from being paused during the operation.
+ // However, if Sync is in error, clearing cookies should pause it.
+ std::unique_ptr<AccountReconcilor::ScopedSyncedDataDeletion>
+ scoped_data_deletion;
+ sync_ui_util::MessageType sync_status = sync_ui_util::GetStatus(
+ profile_, sync_service_, *SigninManagerFactory::GetForProfile(profile_));
+ if (sync_status == sync_ui_util::SYNCED) {
+ scoped_data_deletion = AccountReconcilorFactory::GetForProfile(profile_)
+ ->GetScopedSyncDataDeletion();
+ }
+
int period_selected;
CHECK(args->GetInteger(2, &period_selected));
content::BrowsingDataRemover* remover =
content::BrowserContext::GetBrowsingDataRemover(profile_);
- base::OnceClosure callback = base::BindOnce(
- &ClearBrowsingDataHandler::OnClearingTaskFinished,
- weak_ptr_factory_.GetWeakPtr(), webui_callback_id, std::move(data_types));
+ base::OnceClosure callback =
+ base::BindOnce(&ClearBrowsingDataHandler::OnClearingTaskFinished,
+ weak_ptr_factory_.GetWeakPtr(), webui_callback_id,
+ std::move(data_types), std::move(scoped_data_deletion));
browsing_data::TimePeriod time_period =
static_cast<browsing_data::TimePeriod>(period_selected);
@@ -275,7 +290,8 @@ void ClearBrowsingDataHandler::HandleClearBrowsingData(
void ClearBrowsingDataHandler::OnClearingTaskFinished(
const std::string& webui_callback_id,
- const base::flat_set<BrowsingDataType>& data_types) {
+ const base::flat_set<BrowsingDataType>& data_types,
+ std::unique_ptr<AccountReconcilor::ScopedSyncedDataDeletion> deletion) {
PrefService* prefs = profile_->GetPrefs();
int notice_shown_times = prefs->GetInteger(
browsing_data::prefs::kClearBrowsingDataHistoryNoticeShownTimes);
@@ -327,10 +343,11 @@ void ClearBrowsingDataHandler::OnStateChanged(syncer::SyncService* sync) {
}
void ClearBrowsingDataHandler::UpdateSyncState() {
- auto* signin_manager = SigninManagerFactory::GetForProfile(profile_);
+ identity::IdentityManager* identity_manager =
+ IdentityManagerFactory::GetForProfile(profile_);
CallJavascriptFunction(
"cr.webUIListenerCallback", base::Value("update-sync-state"),
- base::Value(signin_manager && signin_manager->IsAuthenticated()),
+ base::Value(identity_manager && identity_manager->HasPrimaryAccount()),
base::Value(sync_service_ && sync_service_->IsSyncActive() &&
sync_service_->GetActiveDataTypes().Has(
syncer::HISTORY_DELETE_DIRECTIVES)),
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
index 40fcfa0b06f..96e239934ac 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h
@@ -17,6 +17,7 @@
#include "components/browser_sync/profile_sync_service.h"
#include "components/browsing_data/core/browsing_data_utils.h"
#include "components/browsing_data/core/counters/browsing_data_counter.h"
+#include "components/signin/core/browser/account_reconcilor.h"
namespace base {
class ListValue;
@@ -47,12 +48,14 @@ class ClearBrowsingDataHandler : public SettingsPageUIHandler,
// Clears browsing data, called by Javascript.
void HandleClearBrowsingData(const base::ListValue* value);
-
// Called when a clearing task finished. |webui_callback_id| is provided
// by the WebUI action that initiated it.
+ // The ScopedSyncedDataDeletion is passed here to ensure that the Sync token
+ // is not invalidated before this function is run.
void OnClearingTaskFinished(
const std::string& webui_callback_id,
- const base::flat_set<browsing_data::BrowsingDataType>& data_types);
+ const base::flat_set<browsing_data::BrowsingDataType>& data_types,
+ std::unique_ptr<AccountReconcilor::ScopedSyncedDataDeletion> deletion);
// Initializes the dialog UI. Called by JavaScript when the DOM is ready.
void HandleInitialize(const base::ListValue* args);
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
index 9150748cdba..12b0a2a44ee 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
@@ -45,6 +45,9 @@ class FileSystemContext;
namespace {
+constexpr char kEffectiveTopLevelDomainPlus1Name[] = "etldPlus1";
+constexpr char kNumCookies[] = "numCookies";
+
int GetCategoryLabelID(CookieTreeNode::DetailedInfo::NodeType node_type) {
constexpr struct {
CookieTreeNode::DetailedInfo::NodeType node_type;
@@ -174,6 +177,10 @@ void CookiesViewHandler::RegisterMessages() {
base::BindRepeating(&CookiesViewHandler::HandleGetCookieDetails,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "localData.getNumCookiesList",
+ base::BindRepeating(&CookiesViewHandler::HandleGetNumCookiesList,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"localData.getNumCookiesString",
base::BindRepeating(&CookiesViewHandler::HandleGetNumCookiesString,
base::Unretained(this)));
@@ -309,53 +316,73 @@ void CookiesViewHandler::HandleGetCookieDetails(const base::ListValue* args) {
SendCookieDetails(node);
}
-void CookiesViewHandler::HandleGetNumCookiesString(
- const base::ListValue* args) {
+void CookiesViewHandler::HandleGetNumCookiesList(const base::ListValue* args) {
CHECK_EQ(2U, args->GetSize());
std::string callback_id;
CHECK(args->GetString(0, &callback_id));
- base::string16 etld_plus1;
- CHECK(args->GetString(1, &etld_plus1));
+ const base::ListValue* etld_plus1_list;
+ CHECK(args->GetList(1, &etld_plus1_list));
AllowJavascript();
CHECK(cookies_tree_model_.get());
- // This method is only interested in the number of cookies, so don't save the
- // filter and keep the existing |sorted_sites_| list.
- if (etld_plus1 != filter_)
- cookies_tree_model_->UpdateSearchResults(etld_plus1);
- int num_cookies = 0;
- const CookieTreeNode* root = cookies_tree_model_->GetRoot();
- for (int i = 0; i < root->child_count(); ++i) {
- const CookieTreeNode* site = root->GetChild(i);
- const base::string16& title = site->GetTitle();
- if (!base::EndsWith(title, etld_plus1,
- base::CompareCase::INSENSITIVE_ASCII)) {
- continue;
- }
+ base::string16 etld_plus1;
+ base::Value result(base::Value::Type::LIST);
+ for (size_t i = 0; i < etld_plus1_list->GetSize(); ++i) {
+ etld_plus1_list->GetString(i, &etld_plus1);
+ // This method is only interested in the number of cookies, so don't save
+ // |etld_plus1| as a new filter and keep the existing |sorted_sites_| list.
+ cookies_tree_model_->UpdateSearchResults(etld_plus1);
- for (int j = 0; j < site->child_count(); ++j) {
- const CookieTreeNode* category = site->GetChild(j);
- if (category->GetDetailedInfo().node_type !=
- CookieTreeNode::DetailedInfo::TYPE_COOKIES) {
+ int num_cookies = 0;
+ const CookieTreeNode* root = cookies_tree_model_->GetRoot();
+ for (int i = 0; i < root->child_count(); ++i) {
+ const CookieTreeNode* site = root->GetChild(i);
+ const base::string16& title = site->GetTitle();
+ if (!base::EndsWith(title, etld_plus1,
+ base::CompareCase::INSENSITIVE_ASCII)) {
continue;
}
- for (int k = 0; k < category->child_count(); ++k) {
- if (category->GetChild(k)->GetDetailedInfo().node_type !=
- CookieTreeNode::DetailedInfo::TYPE_COOKIE) {
+ for (int j = 0; j < site->child_count(); ++j) {
+ const CookieTreeNode* category = site->GetChild(j);
+ if (category->GetDetailedInfo().node_type !=
+ CookieTreeNode::DetailedInfo::TYPE_COOKIES) {
continue;
}
- ++num_cookies;
+ for (int k = 0; k < category->child_count(); ++k) {
+ if (category->GetChild(k)->GetDetailedInfo().node_type !=
+ CookieTreeNode::DetailedInfo::TYPE_COOKIE) {
+ continue;
+ }
+
+ ++num_cookies;
+ }
}
}
- }
- if (etld_plus1 != filter_) {
- // Restore the original |filter_|.
- cookies_tree_model_->UpdateSearchResults(filter_);
+ base::Value cookies_per_etld_plus1(base::Value::Type::DICTIONARY);
+ cookies_per_etld_plus1.SetKey(kEffectiveTopLevelDomainPlus1Name,
+ base::Value(etld_plus1));
+ cookies_per_etld_plus1.SetKey(kNumCookies, base::Value(num_cookies));
+ result.GetList().emplace_back(std::move(cookies_per_etld_plus1));
}
+ ResolveJavascriptCallback(base::Value(callback_id), result);
+
+ // Restore the original |filter_|.
+ cookies_tree_model_->UpdateSearchResults(filter_);
+}
+
+void CookiesViewHandler::HandleGetNumCookiesString(
+ const base::ListValue* args) {
+ CHECK_EQ(2U, args->GetSize());
+ std::string callback_id;
+ CHECK(args->GetString(0, &callback_id));
+ int num_cookies;
+ CHECK(args->GetInteger(1, &num_cookies));
+
+ AllowJavascript();
const base::string16 string =
num_cookies > 0 ? l10n_util::GetPluralStringFUTF16(
IDS_SETTINGS_SITE_SETTINGS_NUM_COOKIES, num_cookies)
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h
index 0b742577c16..bba06ea179a 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_cookies_view_handler.h
@@ -61,7 +61,12 @@ class CookiesViewHandler : public SettingsPageUIHandler,
// Retrieve cookie details for a specific site.
void HandleGetCookieDetails(const base::ListValue* args);
- // Gets the number of cookies formatted in a plural string, given a site.
+ // Gets a list containing the number of cookies for each domain (eTLD+1 names)
+ // given in |siteList|. This will always return a result array the same length
+ // and in the same order as |siteList|.
+ void HandleGetNumCookiesList(const base::ListValue* args);
+
+ // Gets a plural string for the given number of cookies.
void HandleGetNumCookiesString(const base::ListValue* args);
// Remove all sites data.
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
index 721518a1f17..1ea37913233 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
@@ -192,6 +192,7 @@ void ManageProfileHandler::HandleSetProfileIconToDefaultAvatar(
PrefService* pref_service = profile_->GetPrefs();
pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index);
+ pref_service->SetInteger(prefs::kProfileLocalAvatarIndex, new_icon_index);
pref_service->SetBoolean(prefs::kProfileUsingDefaultAvatar, false);
pref_service->SetBoolean(prefs::kProfileUsingGAIAAvatar, false);
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 fa89523712c..04422c787f8 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -17,11 +17,12 @@
#include "base/macros.h"
#include "base/metrics/user_metrics.h"
#include "base/values.h"
-#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/content_settings/web_site_settings_uma_util.h"
+#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/infobars/infobar_service.h"
+#include "chrome/browser/media/unified_autoplay_config.h"
#include "chrome/browser/permissions/chooser_context_base.h"
#include "chrome/browser/permissions/permission_decision_auto_blocker.h"
#include "chrome/browser/permissions/permission_manager.h"
@@ -34,11 +35,14 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/site_settings_helper.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
+#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/crx_file/id_util.h"
+#include "components/prefs/pref_change_registrar.h"
+#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
@@ -54,9 +58,6 @@
#include "ui/base/text/bytes_formatting.h"
#if defined(OS_CHROMEOS)
-#include "chrome/common/pref_names.h"
-#include "components/prefs/pref_change_registrar.h"
-#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
#endif
@@ -66,6 +67,7 @@ namespace {
constexpr char kEffectiveTopLevelDomainPlus1Name[] = "etldPlus1";
constexpr char kOriginList[] = "origins";
+constexpr char kNumCookies[] = "numCookies";
constexpr char kZoom[] = "zoom";
// Return an appropriate API Permission ID for the given string name.
@@ -149,12 +151,44 @@ void CreateOrAppendSiteGroupEntry(
}
}
-} // namespace
+// Converts a given |site_group_map| to a list of base::DictionaryValues, adding
+// the site engagement score for each origin.
+void ConvertSiteGroupMapToListValue(
+ const std::map<std::string, std::set<std::string>>& site_group_map,
+ base::Value* list_value,
+ Profile* profile) {
+ DCHECK_EQ(base::Value::Type::LIST, list_value->type());
+ DCHECK(profile);
+ SiteEngagementService* engagement_service =
+ SiteEngagementService::Get(profile);
+ for (const auto& entry : site_group_map) {
+ // eTLD+1 is the effective top level domain + 1.
+ base::Value site_group(base::Value::Type::DICTIONARY);
+ site_group.SetKey(kEffectiveTopLevelDomainPlus1Name,
+ base::Value(entry.first));
+ base::Value origin_list(base::Value::Type::LIST);
+ for (const std::string& origin : entry.second) {
+ base::Value origin_object(base::Value::Type::DICTIONARY);
+ origin_object.SetKey("origin", base::Value(origin));
+ origin_object.SetKey(
+ "engagement",
+ base::Value(engagement_service->GetScore(GURL(origin))));
+ origin_object.SetKey("usage", base::Value(0));
+ origin_list.GetList().emplace_back(std::move(origin_object));
+ }
+ site_group.SetKey(kNumCookies, base::Value(0));
+ site_group.SetKey(kOriginList, std::move(origin_list));
+ list_value->GetList().push_back(std::move(site_group));
+ }
+}
+} // namespace
SiteSettingsHandler::SiteSettingsHandler(Profile* profile)
- : profile_(profile), observer_(this) {
-}
+ : profile_(profile),
+ observer_(this),
+ pref_change_registrar_(nullptr),
+ local_storage_helper_(nullptr) {}
SiteSettingsHandler::~SiteSettingsHandler() {
}
@@ -190,6 +224,10 @@ void SiteSettingsHandler::RegisterMessages() {
base::BindRepeating(&SiteSettingsHandler::HandleGetAllSites,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "getFormattedBytes",
+ base::BindRepeating(&SiteSettingsHandler::HandleGetFormattedBytes,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"getExceptionList",
base::BindRepeating(&SiteSettingsHandler::HandleGetExceptionList,
base::Unretained(this)));
@@ -235,6 +273,14 @@ void SiteSettingsHandler::RegisterMessages() {
"removeZoomLevel",
base::BindRepeating(&SiteSettingsHandler::HandleRemoveZoomLevel,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "setBlockAutoplayEnabled",
+ base::BindRepeating(&SiteSettingsHandler::HandleSetBlockAutoplayEnabled,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "fetchBlockAutoplayStatus",
+ base::BindRepeating(&SiteSettingsHandler::HandleFetchBlockAutoplayStatus,
+ base::Unretained(this)));
}
void SiteSettingsHandler::OnJavascriptAllowed() {
@@ -263,9 +309,16 @@ void SiteSettingsHandler::OnJavascriptAllowed() {
base::Bind(&SiteSettingsHandler::OnZoomLevelChanged,
base::Unretained(this)));
-#if defined(OS_CHROMEOS)
pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>();
pref_change_registrar_->Init(profile_->GetPrefs());
+
+ // If the block autoplay pref changes send the new status.
+ pref_change_registrar_->Add(
+ prefs::kBlockAutoplayEnabled,
+ base::Bind(&SiteSettingsHandler::SendBlockAutoplayStatus,
+ base::Unretained(this)));
+
+#if defined(OS_CHROMEOS)
pref_change_registrar_->Add(
prefs::kEnableDRM,
base::Bind(&SiteSettingsHandler::OnPrefEnableDrmChanged,
@@ -277,6 +330,7 @@ void SiteSettingsHandler::OnJavascriptDisallowed() {
observer_.RemoveAll();
notification_registrar_.RemoveAll();
host_zoom_map_subscription_.reset();
+ pref_change_registrar_->Remove(prefs::kBlockAutoplayEnabled);
#if defined(OS_CHROMEOS)
pref_change_registrar_->Remove(prefs::kEnableDRM);
#endif
@@ -342,6 +396,14 @@ void SiteSettingsHandler::OnContentSettingChanged(
? ""
: secondary_pattern.ToString()));
}
+
+ // If the default sound content setting changed then we should send block
+ // autoplay status.
+ if (primary_pattern == ContentSettingsPattern() &&
+ secondary_pattern == ContentSettingsPattern() &&
+ content_type == CONTENT_SETTINGS_TYPE_SOUND) {
+ SendBlockAutoplayStatus();
+ }
}
void SiteSettingsHandler::Observe(
@@ -425,9 +487,7 @@ void SiteSettingsHandler::HandleClearUsage(
base::Unretained(this), barrier));
// Also clear the *local* storage data.
- scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper =
- new BrowsingDataLocalStorageHelper(profile_);
- local_storage_helper->DeleteOrigin(url, barrier);
+ GetLocalStorageHelper()->DeleteOrigin(url, barrier);
}
}
@@ -560,6 +620,10 @@ void SiteSettingsHandler::HandleGetAllSites(const base::ListValue* args) {
// TODO(https://crbug.com/835712): Assess performance of this method for
// unusually large numbers of stored content settings.
+ // Add sites that are using any local storage to the list.
+ GetLocalStorageHelper()->StartFetching(base::BindRepeating(
+ &SiteSettingsHandler::OnLocalStorageFetched, base::Unretained(this)));
+
// Retrieve a list of embargoed settings to check separately. This ensures
// that only settings included in |content_types| will be listed in all sites.
ContentSettingsForOneType embargo_settings;
@@ -584,9 +648,6 @@ void SiteSettingsHandler::HandleGetAllSites(const base::ListValue* args) {
// Convert |types| to a list of ContentSettingsTypes.
for (ContentSettingsType content_type : content_types) {
- // TODO(https://crbug.com/835712): Add extension content settings, plus
- // sites that use any non-zero amount of storage.
-
ContentSettingsForOneType entries;
map->GetSettingsForOneType(content_type, std::string(), &entries);
for (const ContentSettingPatternSource& e : entries) {
@@ -596,21 +657,51 @@ void SiteSettingsHandler::HandleGetAllSites(const base::ListValue* args) {
}
}
- // Convert |all_sites_map| to a list of base::DictionaryValues.
base::Value result(base::Value::Type::LIST);
- for (const auto& entry : all_sites_map) {
- // eTLD+1 is the effective top level domain + 1.
- base::Value site_group(base::Value::Type::DICTIONARY);
- site_group.SetKey(kEffectiveTopLevelDomainPlus1Name,
- base::Value(entry.first));
- base::Value origin_list(base::Value::Type::LIST);
- for (const std::string& origin : entry.second) {
- origin_list.GetList().emplace_back(origin);
+ ConvertSiteGroupMapToListValue(all_sites_map, &result, profile);
+ ResolveJavascriptCallback(*callback_id, result);
+}
+
+void SiteSettingsHandler::OnLocalStorageFetched(
+ const std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>&
+ local_storage_info) {
+ std::map<std::string, int> origin_size_map;
+ std::map<std::string, std::set<std::string>> all_sites_map;
+ for (const BrowsingDataLocalStorageHelper::LocalStorageInfo& info :
+ local_storage_info) {
+ origin_size_map.emplace(info.origin_url.spec(), info.size);
+ CreateOrAppendSiteGroupEntry(&all_sites_map, info.origin_url);
+ }
+ base::Value result(base::Value::Type::LIST);
+ ConvertSiteGroupMapToListValue(all_sites_map, &result, profile_);
+
+ // Merge the origin usage number into |result|.
+ for (size_t i = 0; i < result.GetList().size(); ++i) {
+ base::Value* site_group = &result.GetList()[i];
+ base::Value* origin_list = site_group->FindKey(kOriginList);
+
+ for (size_t i = 0; i < origin_list->GetList().size(); ++i) {
+ base::Value* origin_info = &origin_list->GetList()[i];
+ const std::string& origin = origin_info->FindKey("origin")->GetString();
+ const auto& size_info = origin_size_map.find(origin);
+ if (size_info != origin_size_map.end())
+ origin_info->SetKey("usage", base::Value(size_info->second));
}
- site_group.SetKey(kOriginList, std::move(origin_list));
- result.GetList().push_back(std::move(site_group));
}
- ResolveJavascriptCallback(*callback_id, result);
+ FireWebUIListener("onLocalStorageListFetched", result);
+}
+
+void SiteSettingsHandler::HandleGetFormattedBytes(const base::ListValue* args) {
+ AllowJavascript();
+
+ CHECK_EQ(2U, args->GetSize());
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+ int num_bytes;
+ CHECK(args->GetInteger(1, &num_bytes));
+
+ const base::string16 string = ui::FormatBytes(num_bytes);
+ ResolveJavascriptCallback(*callback_id, base::Value(string));
}
void SiteSettingsHandler::HandleGetExceptionList(const base::ListValue* args) {
@@ -1053,4 +1144,59 @@ void SiteSettingsHandler::HandleRemoveZoomLevel(const base::ListValue* args) {
host_zoom_map->SetZoomLevelForHost(origin, default_level);
}
+void SiteSettingsHandler::HandleFetchBlockAutoplayStatus(
+ const base::ListValue* args) {
+ AllowJavascript();
+ SendBlockAutoplayStatus();
+}
+
+void SiteSettingsHandler::SendBlockAutoplayStatus() {
+ if (!IsJavascriptAllowed())
+ return;
+
+ base::DictionaryValue status;
+
+ // Whether the block autoplay toggle should be checked.
+ base::DictionaryValue pref;
+ pref.SetKey(
+ "value",
+ base::Value(
+ UnifiedAutoplayConfig::ShouldBlockAutoplay(profile_) &&
+ UnifiedAutoplayConfig::IsBlockAutoplayUserModifiable(profile_)));
+ status.SetKey("pref", std::move(pref));
+
+ // Whether the block autoplay toggle should be enabled.
+ status.SetKey("enabled",
+ base::Value(UnifiedAutoplayConfig::IsBlockAutoplayUserModifiable(
+ profile_)));
+
+ FireWebUIListener("onBlockAutoplayStatusChanged", status);
+}
+
+void SiteSettingsHandler::HandleSetBlockAutoplayEnabled(
+ const base::ListValue* args) {
+ AllowJavascript();
+
+ if (!UnifiedAutoplayConfig::IsBlockAutoplayUserModifiable(profile_))
+ return;
+
+ CHECK_EQ(1U, args->GetSize());
+ bool value;
+ CHECK(args->GetBoolean(0, &value));
+
+ profile_->GetPrefs()->SetBoolean(prefs::kBlockAutoplayEnabled, value);
+}
+
+void SiteSettingsHandler::SetBrowsingDataLocalStorageHelperForTesting(
+ scoped_refptr<BrowsingDataLocalStorageHelper> helper) {
+ DCHECK(!local_storage_helper_);
+ local_storage_helper_ = helper;
+}
+
+BrowsingDataLocalStorageHelper* SiteSettingsHandler::GetLocalStorageHelper() {
+ if (!local_storage_helper_)
+ local_storage_helper_ = new BrowsingDataLocalStorageHelper(profile_);
+ return local_storage_helper_.get();
+}
+
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
index 3f5b4a470ad..7a5f9c9b787 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/scoped_observer.h"
+#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
#include "chrome/browser/storage/storage_info_fetcher.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
@@ -22,9 +23,7 @@
class HostContentSettingsMap;
class Profile;
-#if defined(OS_CHROMEOS)
class PrefChangeRegistrar;
-#endif
namespace base {
class ListValue;
@@ -85,12 +84,16 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, GetAndSetForInvalidURLs);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Incognito);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, GetAllSites);
+ FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, GetAllSitesLocalStorage);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Origins);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, Patterns);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, ZoomLevels);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerInfobarTest,
SettingPermissionsTriggersInfobar);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, SessionOnlyException);
+ FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest,
+ BlockAutoplay_SendOnRequest);
+ FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, BlockAutoplay_Update);
// Asynchronously fetches the usage for a given origin. Replies back with
// OnGetUsageInfo above.
@@ -113,6 +116,16 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
// 1, affected by any of the content settings specified in |args|.
void HandleGetAllSites(const base::ListValue* args);
+ // Called when the list of origins using local storage has been fetched, and
+ // sends this list back to the front end.
+ void OnLocalStorageFetched(
+ const std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>&
+ local_storage_info);
+
+ // Converts a given number of bytes into a human-readable format, with data
+ // units.
+ void HandleGetFormattedBytes(const base::ListValue* args);
+
// Returns the list of site exceptions for a given content settings type.
void HandleGetExceptionList(const base::ListValue* args);
@@ -151,6 +164,20 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
// Removes a particular zoom level for a given host.
void HandleRemoveZoomLevel(const base::ListValue* args);
+ // Handles the request to send block autoplay state.
+ void HandleFetchBlockAutoplayStatus(const base::ListValue* args);
+
+ // Notifies the JS side about the state of the block autoplay toggle.
+ void SendBlockAutoplayStatus();
+
+ // Updates the block autoplay enabled pref when the UI is toggled.
+ void HandleSetBlockAutoplayEnabled(const base::ListValue* args);
+
+ void SetBrowsingDataLocalStorageHelperForTesting(
+ scoped_refptr<BrowsingDataLocalStorageHelper> helper);
+
+ BrowsingDataLocalStorageHelper* GetLocalStorageHelper();
+
Profile* profile_;
content::NotificationRegistrar notification_registrar_;
@@ -168,10 +195,10 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
// Change observer for content settings.
ScopedObserver<HostContentSettingsMap, content_settings::Observer> observer_;
-#if defined(OS_CHROMEOS)
// Change observer for prefs.
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
-#endif
+
+ scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_;
DISALLOW_COPY_AND_ASSIGN(SiteSettingsHandler);
};
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 2b1e3700934..301b05f54d6 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
@@ -9,6 +9,7 @@
#include "base/test/metrics/histogram_tester.h"
#include "base/test/simple_test_clock.h"
+#include "chrome/browser/browsing_data/mock_browsing_data_local_storage_helper.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -18,6 +19,7 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/site_settings_helper.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
@@ -151,6 +153,36 @@ class SiteSettingsHandlerTest : public testing::Test {
content::TestWebUI* web_ui() { return &web_ui_; }
SiteSettingsHandler* handler() { return &handler_; }
+ void ValidateBlockAutoplay(bool expected_value, bool expected_enabled) {
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
+
+ std::string event_name;
+ ASSERT_TRUE(data.arg1()->GetAsString(&event_name));
+ EXPECT_EQ("onBlockAutoplayStatusChanged", event_name);
+
+ const base::DictionaryValue* event_data = nullptr;
+ ASSERT_TRUE(data.arg2()->GetAsDictionary(&event_data));
+
+ bool enabled;
+ ASSERT_TRUE(event_data->GetBoolean("enabled", &enabled));
+ EXPECT_EQ(expected_enabled, enabled);
+
+ const base::DictionaryValue* pref_data = nullptr;
+ ASSERT_TRUE(event_data->GetDictionary("pref", &pref_data));
+
+ bool value;
+ ASSERT_TRUE(pref_data->GetBoolean("value", &value));
+ EXPECT_EQ(expected_value, value);
+ }
+
+ void SetSoundContentSettingDefault(ContentSetting value) {
+ HostContentSettingsMap* content_settings =
+ HostContentSettingsMapFactory::GetForProfile(profile());
+ content_settings->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_SOUND,
+ value);
+ }
+
void ValidateDefault(const ContentSetting expected_setting,
const site_settings::SiteSettingSource expected_source,
size_t expected_total_calls) {
@@ -407,8 +439,10 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
site_group.FindKey("origins")->GetList();
EXPECT_EQ("example.com", etld_plus1_string);
EXPECT_EQ(2UL, origin_list.size());
- EXPECT_EQ(url1.spec(), origin_list[0].GetString());
- EXPECT_EQ(url2.spec(), origin_list[1].GetString());
+ EXPECT_EQ(url1.spec(), origin_list[0].FindKey("origin")->GetString());
+ EXPECT_EQ(0, origin_list[0].FindKey("engagement")->GetDouble());
+ EXPECT_EQ(url2.spec(), origin_list[1].FindKey("origin")->GetString());
+ EXPECT_EQ(0, origin_list[1].FindKey("engagement")->GetDouble());
}
}
@@ -434,7 +468,7 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
site_group.FindKey("origins")->GetList();
if (etld_plus1_string == "example2.net") {
EXPECT_EQ(1UL, origin_list.size());
- EXPECT_EQ(url3.spec(), origin_list[0].GetString());
+ EXPECT_EQ(url3.spec(), origin_list[0].FindKey("origin")->GetString());
} else {
EXPECT_EQ("example.com", etld_plus1_string);
}
@@ -444,6 +478,9 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
// Test embargoed settings also appear.
PermissionDecisionAutoBlocker* auto_blocker =
PermissionDecisionAutoBlocker::GetForProfile(profile());
+ base::SimpleTestClock clock;
+ clock.SetNow(base::Time::Now());
+ auto_blocker->SetClockForTesting(&clock);
const GURL url4("https://example2.co.uk");
for (int i = 0; i < 3; ++i) {
auto_blocker->RecordDismissAndEmbargo(url4,
@@ -465,11 +502,24 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
EXPECT_EQ(3UL, site_groups.size());
}
- // Add an expired embargo setting to a) an existing eTLD+1 group and b) a new
- // eTLD+1 group.
- base::SimpleTestClock clock;
- clock.SetNow(base::Time::Now());
- auto_blocker->SetClockForTesting(&clock);
+ // Check |url4| disappears from the list when its embargo expires.
+ clock.Advance(base::TimeDelta::FromDays(8));
+ handler()->HandleGetAllSites(&get_all_sites_args);
+
+ {
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIResponse", data.function_name());
+ EXPECT_EQ(kCallbackId, data.arg1()->GetString());
+ ASSERT_TRUE(data.arg2()->GetBool());
+
+ const base::Value::ListStorage& site_groups = data.arg3()->GetList();
+ EXPECT_EQ(2UL, site_groups.size());
+ EXPECT_EQ("example.com", site_groups[0].FindKey("etldPlus1")->GetString());
+ EXPECT_EQ("example2.net", site_groups[1].FindKey("etldPlus1")->GetString());
+ }
+
+ // Add an expired embargo setting to an existing eTLD+1 group and make sure it
+ // still appears.
for (int i = 0; i < 3; ++i) {
auto_blocker->RecordDismissAndEmbargo(url3,
CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
@@ -484,6 +534,7 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
auto_blocker->GetEmbargoResult(url3, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
.content_setting);
+ handler()->HandleGetAllSites(&get_all_sites_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", data.function_name());
@@ -491,10 +542,12 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
ASSERT_TRUE(data.arg2()->GetBool());
const base::Value::ListStorage& site_groups = data.arg3()->GetList();
- EXPECT_EQ(3UL, site_groups.size());
+ EXPECT_EQ(2UL, site_groups.size());
+ EXPECT_EQ("example.com", site_groups[0].FindKey("etldPlus1")->GetString());
+ EXPECT_EQ("example2.net", site_groups[1].FindKey("etldPlus1")->GetString());
}
- clock.SetNow(base::Time::Now());
+ // Add an expired embargo to a new eTLD+1 and make sure it doesn't appear.
const GURL url5("http://test.example5.com");
for (int i = 0; i < 3; ++i) {
auto_blocker->RecordDismissAndEmbargo(url5,
@@ -510,6 +563,7 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
auto_blocker->GetEmbargoResult(url5, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
.content_setting);
+ handler()->HandleGetAllSites(&get_all_sites_args);
{
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIResponse", data.function_name());
@@ -517,8 +571,71 @@ TEST_F(SiteSettingsHandlerTest, GetAllSites) {
ASSERT_TRUE(data.arg2()->GetBool());
const base::Value::ListStorage& site_groups = data.arg3()->GetList();
- EXPECT_EQ(3UL, site_groups.size());
+ EXPECT_EQ(2UL, site_groups.size());
+ EXPECT_EQ("example.com", site_groups[0].FindKey("etldPlus1")->GetString());
+ EXPECT_EQ("example2.net", site_groups[1].FindKey("etldPlus1")->GetString());
}
+
+ // Each call to HandleGetAllSites() above added a callback to the profile's
+ // BrowsingDataLocalStorageHelper, so make sure these aren't stuck waiting to
+ // run at the end of the test.
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+}
+
+TEST_F(SiteSettingsHandlerTest, GetAllSitesLocalStorage) {
+ scoped_refptr<MockBrowsingDataLocalStorageHelper>
+ mock_browsing_data_local_storage_helper =
+ new MockBrowsingDataLocalStorageHelper(profile());
+ handler()->SetBrowsingDataLocalStorageHelperForTesting(
+ mock_browsing_data_local_storage_helper);
+
+ // Add local storage for |origin|.
+ const GURL origin("https://example.com:12378");
+ mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin(origin, 1);
+
+ // Check these sites are included in the callback.
+ base::ListValue get_all_sites_args;
+ get_all_sites_args.AppendString(kCallbackId);
+ base::Value category_list(base::Value::Type::LIST);
+ get_all_sites_args.GetList().push_back(std::move(category_list));
+
+ // Wait for the fetch handler to finish, then check it includes |origin| in
+ // its result.
+ handler()->HandleGetAllSites(&get_all_sites_args);
+ EXPECT_EQ(1U, web_ui()->call_data().size());
+ mock_browsing_data_local_storage_helper->Notify();
+ EXPECT_EQ(2U, web_ui()->call_data().size());
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
+
+ std::string callback_id;
+ ASSERT_TRUE(data.arg1()->GetAsString(&callback_id));
+ EXPECT_EQ("onLocalStorageListFetched", callback_id);
+
+ const base::ListValue* local_storage_list;
+ ASSERT_TRUE(data.arg2()->GetAsList(&local_storage_list));
+ EXPECT_EQ(1U, local_storage_list->GetSize());
+
+ const base::DictionaryValue* site_group;
+ ASSERT_TRUE(local_storage_list->GetDictionary(0, &site_group));
+
+ std::string etld_plus1_string;
+ ASSERT_TRUE(site_group->GetString("etldPlus1", &etld_plus1_string));
+ ASSERT_EQ("example.com", etld_plus1_string);
+
+ const base::ListValue* origin_list;
+ ASSERT_TRUE(site_group->GetList("origins", &origin_list));
+ EXPECT_EQ(1U, origin_list->GetSize());
+
+ const base::DictionaryValue* origin_info;
+ ASSERT_TRUE(origin_list->GetDictionary(0, &origin_info));
+ EXPECT_EQ(origin.spec(), origin_info->FindKey("origin")->GetString());
+ EXPECT_EQ(0, origin_info->FindKey("engagement")->GetDouble());
+ EXPECT_EQ(1, origin_info->FindKey("usage")->GetDouble());
}
TEST_F(SiteSettingsHandlerTest, Origins) {
@@ -1147,4 +1264,50 @@ TEST_F(SiteSettingsHandlerTest, SessionOnlyException) {
histograms.ExpectTotalCount(uma_base + ".SessionOnly", 1);
}
+TEST_F(SiteSettingsHandlerTest, BlockAutoplay_SendOnRequest) {
+ base::ListValue args;
+ handler()->HandleFetchBlockAutoplayStatus(&args);
+
+ // Check that we are checked and enabled.
+ ValidateBlockAutoplay(true, true);
+}
+
+TEST_F(SiteSettingsHandlerTest, BlockAutoplay_SoundSettingUpdate) {
+ SetSoundContentSettingDefault(CONTENT_SETTING_BLOCK);
+ base::RunLoop().RunUntilIdle();
+
+ // Check that we are not checked or enabled.
+ ValidateBlockAutoplay(false, false);
+
+ SetSoundContentSettingDefault(CONTENT_SETTING_ALLOW);
+ base::RunLoop().RunUntilIdle();
+
+ // Check that we are checked and enabled.
+ ValidateBlockAutoplay(true, true);
+}
+
+TEST_F(SiteSettingsHandlerTest, BlockAutoplay_PrefUpdate) {
+ profile()->GetPrefs()->SetBoolean(prefs::kBlockAutoplayEnabled, false);
+ base::RunLoop().RunUntilIdle();
+
+ // Check that we are not checked but are enabled.
+ ValidateBlockAutoplay(false, true);
+
+ profile()->GetPrefs()->SetBoolean(prefs::kBlockAutoplayEnabled, true);
+ base::RunLoop().RunUntilIdle();
+
+ // Check that we are checked and enabled.
+ ValidateBlockAutoplay(true, true);
+}
+
+TEST_F(SiteSettingsHandlerTest, BlockAutoplay_Update) {
+ EXPECT_TRUE(profile()->GetPrefs()->GetBoolean(prefs::kBlockAutoplayEnabled));
+
+ base::ListValue data;
+ data.AppendBoolean(false);
+
+ handler()->HandleSetBlockAutoplayEnabled(&data);
+ EXPECT_FALSE(profile()->GetPrefs()->GetBoolean(prefs::kBlockAutoplayEnabled));
+}
+
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
index 0984278d7eb..d4298910124 100644
--- a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
@@ -18,12 +18,18 @@
#include "content/public/browser/web_ui.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
#include "ui/base/l10n/l10n_util.h"
namespace settings {
+TtsHandler::TtsHandler() : weak_factory_(this) {}
+
+TtsHandler::~TtsHandler() {
+ TtsController::GetInstance()->RemoveVoicesChangedDelegate(this);
+}
void TtsHandler::HandleGetAllTtsVoiceData(const base::ListValue* args) {
OnVoicesChanged();
@@ -31,8 +37,8 @@ void TtsHandler::HandleGetAllTtsVoiceData(const base::ListValue* args) {
void TtsHandler::HandleGetTtsExtensions(const base::ListValue* args) {
// Ensure the built in tts engine is loaded to be able to respond to messages.
- TtsExtensionEngine::GetInstance()->LoadBuiltInTtsExtension(
- Profile::FromWebUI(web_ui()));
+ WakeTtsEngine(nullptr);
+
base::ListValue responses;
Profile* profile = Profile::FromWebUI(web_ui());
extensions::ExtensionRegistry* registry =
@@ -141,6 +147,9 @@ void TtsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"previewTtsVoice", base::BindRepeating(&TtsHandler::HandlePreviewTtsVoice,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "wakeTtsEngine",
+ base::BindRepeating(&TtsHandler::WakeTtsEngine, base::Unretained(this)));
}
void TtsHandler::OnJavascriptAllowed() {
@@ -163,4 +172,17 @@ int TtsHandler::GetVoiceLangMatchScore(const VoiceData* voice,
: 0;
}
+void TtsHandler::WakeTtsEngine(const base::ListValue* args) {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ TtsExtensionEngine::GetInstance()->LoadBuiltInTtsExtension(profile);
+ extensions::ProcessManager::Get(profile)->WakeEventPage(
+ extension_misc::kSpeechSynthesisExtensionId,
+ base::BindRepeating(&TtsHandler::OnTtsEngineAwake,
+ weak_factory_.GetWeakPtr()));
+}
+
+void TtsHandler::OnTtsEngineAwake(bool success) {
+ OnVoicesChanged();
+}
+
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.h b/chromium/chrome/browser/ui/webui/settings/tts_handler.h
index 94dfef0c727..0f9d26426d8 100644
--- a/chromium/chrome/browser/ui/webui/settings/tts_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.h
@@ -5,16 +5,19 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_TTS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_TTS_HANDLER_H_
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/speech/tts_controller.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+class Profile;
+
namespace settings {
// Chrome "/manageAccessibility/tts/*" settings page UI handler.
class TtsHandler : public SettingsPageUIHandler, public VoicesChangedDelegate {
public:
- TtsHandler() = default;
- ~TtsHandler() override = default;
+ TtsHandler();
+ ~TtsHandler() override;
void HandleGetAllTtsVoiceData(const base::ListValue* args);
void HandleGetTtsExtensions(const base::ListValue* args);
@@ -29,9 +32,13 @@ class TtsHandler : public SettingsPageUIHandler, public VoicesChangedDelegate {
void OnVoicesChanged() override;
private:
+ void WakeTtsEngine(const base::ListValue* args);
+ void OnTtsEngineAwake(bool success);
int GetVoiceLangMatchScore(const VoiceData* voice,
const std::string& app_locale);
+ base::WeakPtrFactory<TtsHandler> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(TtsHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/settings_utils_linux.cc b/chromium/chrome/browser/ui/webui/settings_utils_linux.cc
index 7cf91d35e41..638dc467cbe 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils_linux.cc
+++ b/chromium/chrome/browser/ui/webui/settings_utils_linux.cc
@@ -11,8 +11,8 @@
#include "base/files/file_util.h"
#include "base/nix/xdg_util.h"
#include "base/process/launch.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/threading/thread_restrictions.h"
+#include "base/task/post_task.h"
+#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "content/public/browser/browser_thread.h"
@@ -63,7 +63,7 @@ void ShowLinuxProxyConfigUrl(int render_process_id, int render_view_id) {
// Start the given proxy configuration utility.
bool StartProxyConfigUtil(const char* const command[]) {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// base::LaunchProcess() returns true ("success") if the fork()
// succeeds, but not necessarily the exec(). We'd like to be able to
// use StartProxyConfigUtil() to search possible options and stop on
@@ -89,7 +89,7 @@ bool StartProxyConfigUtil(const char* const command[]) {
// failure to do so, show the Linux proxy config URL in a new tab instead.
void DetectAndStartProxyConfigUtil(int render_process_id,
int render_view_id) {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
std::unique_ptr<base::Environment> env(base::Environment::Create());
bool launched = false;
diff --git a/chromium/chrome/browser/ui/webui/settings_utils_win.cc b/chromium/chrome/browser/ui/webui/settings_utils_win.cc
index 4445ceebfe2..46a7ca83fcd 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils_win.cc
+++ b/chromium/chrome/browser/ui/webui/settings_utils_win.cc
@@ -13,7 +13,7 @@
#include "base/macros.h"
#include "base/path_service.h"
#include "base/single_thread_task_runner.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/browser_process.h"
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
index fcf3c8d6c03..6f8e2de423a 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_util.h"
-#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_delegate_impl.h"
#include "chrome/browser/ui/webui/signin/signin_utils_desktop.h"
@@ -37,9 +36,9 @@
#include "components/signin/core/browser/signin_metrics.h"
#include "components/signin/core/browser/signin_pref_names.h"
#include "components/sync/base/sync_prefs.h"
+#include "components/unified_consent/feature.h"
#include "components/unified_consent/unified_consent_service.h"
#include "content/public/browser/storage_partition.h"
-#include "net/url_request/url_request_context_getter.h"
namespace {
@@ -255,7 +254,6 @@ void DiceTurnSyncOnHelper::LoadPolicyWithCachedCredentials() {
policy::UserPolicySigninServiceFactory::GetForProfile(profile_);
policy_service->FetchPolicyForSignedInUser(
AccountIdFromAccountInfo(account_info_), dm_token_, client_id_,
- profile_->GetRequestContext(),
content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess(),
base::Bind(&DiceTurnSyncOnHelper::OnPolicyFetchComplete,
@@ -281,8 +279,7 @@ void DiceTurnSyncOnHelper::CreateNewSignedInProfile() {
base::UTF8ToUTF16(account_info_.email),
profiles::GetDefaultAvatarIconUrl(icon_index),
base::BindRepeating(&DiceTurnSyncOnHelper::CompleteInitForNewProfile,
- weak_pointer_factory_.GetWeakPtr()),
- std::string());
+ weak_pointer_factory_.GetWeakPtr()));
}
void DiceTurnSyncOnHelper::CompleteInitForNewProfile(
@@ -410,7 +407,7 @@ void DiceTurnSyncOnHelper::AbortAndDelete() {
}
void DiceTurnSyncOnHelper::EnableUnifiedConsentIfNeeded() {
- if (IsUnifiedConsentEnabled(profile_)) {
+ if (unified_consent::IsUnifiedConsentFeatureEnabled()) {
UnifiedConsentServiceFactory::GetForProfile(profile_)
->SetUnifiedConsentGiven(true);
}
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc
index cfd7e7c2862..d962685badd 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc
@@ -24,7 +24,6 @@
#include "chrome/browser/signin/scoped_account_consistency.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/test_signin_client_builder.h"
-#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/browser/unified_consent/unified_consent_service_factory.h"
@@ -39,11 +38,11 @@
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_metrics.h"
#include "components/signin/core/browser/signin_pref_names.h"
+#include "components/unified_consent/feature.h"
#include "components/unified_consent/scoped_unified_consent.h"
#include "components/unified_consent/unified_consent_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/gaia/google_service_auth_error.h"
-#include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -139,7 +138,6 @@ class FakeUserPolicySigninService : public policy::UserPolicySigninService {
nullptr,
signin_manager,
nullptr,
- nullptr,
oauth2_token_service) {}
void set_dm_token(const std::string& dm_token) { dm_token_ = dm_token; }
@@ -164,7 +162,6 @@ class FakeUserPolicySigninService : public policy::UserPolicySigninService {
const AccountId& account_id,
const std::string& dm_token,
const std::string& client_id,
- scoped_refptr<net::URLRequestContextGetter> profile_request_context,
scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory,
const PolicyFetchCallback& callback) override {
callback.Run(true);
@@ -262,8 +259,8 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test {
EXPECT_CALL(*sync_service_mock, GetSetupInProgressHandle()).Times(1);
ON_CALL(*sync_service_mock, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*sync_service_mock, IsEngineInitialized())
- .WillByDefault(Return(true));
+ ON_CALL(*sync_service_mock, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
}
void SetExpectationsForSyncStartupPending() {
@@ -272,8 +269,9 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test {
EXPECT_CALL(*sync_service_mock, GetSetupInProgressHandle()).Times(1);
ON_CALL(*sync_service_mock, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*sync_service_mock, IsEngineInitialized())
- .WillByDefault(Return(false));
+ ON_CALL(*sync_service_mock, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::INITIALIZING));
ON_CALL(*sync_service_mock, GetAuthError())
.WillByDefault(ReturnRef(kNoAuthError));
}
@@ -403,13 +401,13 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test {
GoogleServiceAuthError::AuthErrorNone();
};
-// Test class with only DicePrepareMigration enabled.
+// Test class with only DiceMigration enabled.
class DiceTurnSyncOnHelperTest : public DiceTurnSyncOnHelperTestBase {
public:
DiceTurnSyncOnHelperTest() = default;
private:
- ScopedAccountConsistencyDicePrepareMigration scoped_dice_;
+ ScopedAccountConsistencyDiceMigration scoped_dice_;
};
// Test class with Dice and UnifiedConsent enabled.
@@ -704,7 +702,7 @@ TEST_F(DiceTurnSyncOnHelperTest, ShowSyncDialogForEndConsumerAccount) {
// Tests that the user enabled unified consent,
TEST_F(DiceTurnSyncOnHelperTestWithUnifiedConsent,
ShowSyncDialogForEndConsumerAccount_UnifiedConsentEnabled) {
- ASSERT_TRUE(IsUnifiedConsentEnabled(profile()));
+ ASSERT_TRUE(unified_consent::IsUnifiedConsentFeatureEnabled());
// Set expectations.
expected_sync_confirmation_shown_ = true;
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
index 0738564db13..c50be63d5fa 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
@@ -154,7 +154,54 @@ void InlineLoginHandler::ContinueHandleInitializeMessage() {
void InlineLoginHandler::HandleCompleteLoginMessage(
const base::ListValue* args) {
- CompleteLogin(args);
+ // When the network service is enabled, the webRequest API doesn't expose
+ // cookie headers. So manually fetch the cookies for the GAIA URL from the
+ // CookieManager.
+ content::WebContents* contents = web_ui()->GetWebContents();
+ content::StoragePartition* partition =
+ content::BrowserContext::GetStoragePartitionForSite(
+ contents->GetBrowserContext(), signin::GetSigninPartitionURL());
+
+ net::CookieOptions cookie_options;
+ cookie_options.set_include_httponly();
+
+ partition->GetCookieManagerForBrowserProcess()->GetCookieList(
+ GaiaUrls::GetInstance()->gaia_url(), cookie_options,
+ base::BindOnce(&InlineLoginHandler::HandleCompleteLoginMessageWithCookies,
+ weak_ptr_factory_.GetWeakPtr(),
+ base::ListValue(args->GetList())));
+}
+
+void InlineLoginHandler::HandleCompleteLoginMessageWithCookies(
+ const base::ListValue& args,
+ const std::vector<net::CanonicalCookie>& cookies) {
+ const base::DictionaryValue* dict = nullptr;
+ args.GetDictionary(0, &dict);
+
+ const std::string& email = dict->FindKey("email")->GetString();
+ const std::string& password = dict->FindKey("password")->GetString();
+ const std::string& gaia_id = dict->FindKey("gaiaId")->GetString();
+
+ std::string auth_code;
+ for (const auto& cookie : cookies) {
+ if (cookie.Name() == "oauth_code")
+ auth_code = cookie.Value();
+ }
+
+ bool skip_for_now = false;
+ dict->GetBoolean("skipForNow", &skip_for_now);
+ bool trusted = false;
+ bool trusted_found = dict->GetBoolean("trusted", &trusted);
+
+ bool choose_what_to_sync = false;
+ dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync);
+
+ base::string16 session_index_string16;
+ dict->GetString("sessionIndex", &session_index_string16);
+ std::string session_index = base::UTF16ToASCII(session_index_string16);
+
+ CompleteLogin(email, password, gaia_id, auth_code, skip_for_now, trusted,
+ trusted_found, choose_what_to_sync, session_index);
}
void InlineLoginHandler::HandleSwitchToFullTabMessage(
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
index 58abbe7bafc..51e7508ae88 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
@@ -13,6 +13,10 @@ namespace base {
class DictionaryValue;
}
+namespace net {
+class CanonicalCookie;
+}
+
namespace signin_metrics {
enum class AccessPoint;
}
@@ -54,6 +58,12 @@ class InlineLoginHandler : public content::WebUIMessageHandler {
// work.
void HandleCompleteLoginMessage(const base::ListValue* args);
+ // Called by HandleCompleteLoginMessage after it gets the GAIA URL's cookies
+ // from the CookieManager.
+ void HandleCompleteLoginMessageWithCookies(
+ const base::ListValue& args,
+ const std::vector<net::CanonicalCookie>& cookies);
+
// JS callback to switch the UI from a constrainted dialog to a full tab.
void HandleSwitchToFullTabMessage(const base::ListValue* args);
@@ -65,7 +75,15 @@ class InlineLoginHandler : public content::WebUIMessageHandler {
void HandleDialogClose(const base::ListValue* args);
virtual void SetExtraInitParams(base::DictionaryValue& params) {}
- virtual void CompleteLogin(const base::ListValue* args) = 0;
+ virtual void CompleteLogin(const std::string& email,
+ const std::string& password,
+ const std::string& gaia_id,
+ const std::string& auth_code,
+ bool skip_for_now,
+ bool trusted,
+ bool trusted_found,
+ bool choose_what_to_sync,
+ const std::string& session_index) = 0;
base::WeakPtrFactory<InlineLoginHandler> weak_ptr_factory_;
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 35d3c1e7e66..233761c741d 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
@@ -118,15 +118,17 @@ void InlineLoginHandlerChromeOS::SetExtraInitParams(
params.SetKey("flow", base::Value("addaccount"));
}
-void InlineLoginHandlerChromeOS::CompleteLogin(const base::ListValue* args) {
- const base::DictionaryValue* auth_data = nullptr;
- CHECK(args->GetDictionary(0, &auth_data));
-
- const std::string& auth_code = auth_data->FindKey("authCode")->GetString();
+void InlineLoginHandlerChromeOS::CompleteLogin(const std::string& email,
+ const std::string& password,
+ const std::string& gaia_id,
+ const std::string& auth_code,
+ bool skip_for_now,
+ bool trusted,
+ bool trusted_found,
+ bool choose_what_to_sync,
+ const std::string& session_index) {
CHECK(!auth_code.empty());
- const std::string& gaia_id = auth_data->FindKey("gaiaId")->GetString();
CHECK(!gaia_id.empty());
- const std::string& email = auth_data->FindKey("email")->GetString();
CHECK(!email.empty());
// TODO(sinhak): Do not depend on Profile unnecessarily.
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h
index 5844d592c34..18ea95dfc62 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h
@@ -21,7 +21,15 @@ class InlineLoginHandlerChromeOS : public InlineLoginHandler {
// InlineLoginHandler overrides.
void SetExtraInitParams(base::DictionaryValue& params) override;
- void CompleteLogin(const base::ListValue* args) override;
+ void CompleteLogin(const std::string& email,
+ const std::string& password,
+ const std::string& gaia_id,
+ const std::string& auth_code,
+ bool skip_for_now,
+ bool trusted,
+ bool trusted_found,
+ bool choose_what_to_sync,
+ const std::string& session_index) override;
private:
base::RepeatingClosure close_dialog_closure_;
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 b9b1305bba4..57223ddd6f1 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
@@ -31,7 +31,7 @@
#include "chrome/browser/signin/about_signin_internals_factory.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
-#include "chrome/browser/signin/chrome_signin_client_factory.h"
+#include "chrome/browser/signin/chrome_device_id_helper.h"
#include "chrome/browser/signin/local_auth.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
@@ -499,15 +499,18 @@ void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) {
is_constrained == "1");
}
-void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
+void InlineLoginHandlerImpl::CompleteLogin(const std::string& email,
+ const std::string& password,
+ const std::string& gaia_id,
+ const std::string& auth_code,
+ bool skip_for_now,
+ bool trusted,
+ bool trusted_found,
+ bool choose_what_to_sync,
+ const std::string& session_index) {
content::WebContents* contents = web_ui()->GetWebContents();
const GURL& current_url = contents->GetURL();
- const base::DictionaryValue* dict = NULL;
- args->GetDictionary(0, &dict);
-
- bool skip_for_now = false;
- dict->GetBoolean("skipForNow", &skip_for_now);
if (skip_for_now) {
signin::SetUserSkippedPromo(Profile::FromWebUI(web_ui()));
SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE);
@@ -515,41 +518,18 @@ void InlineLoginHandlerImpl::CompleteLogin(const base::ListValue* args) {
}
// This value exists only for webview sign in.
- bool trusted = false;
- if (dict->GetBoolean("trusted", &trusted))
+ if (trusted_found)
confirm_untrusted_signin_ = !trusted;
- base::string16 email_string16;
- dict->GetString("email", &email_string16);
- DCHECK(!email_string16.empty());
- std::string email(base::UTF16ToASCII(email_string16));
-
- base::string16 password_string16;
- dict->GetString("password", &password_string16);
- std::string password(base::UTF16ToASCII(password_string16));
-
- base::string16 gaia_id_string16;
- dict->GetString("gaiaId", &gaia_id_string16);
- DCHECK(!gaia_id_string16.empty());
- std::string gaia_id = base::UTF16ToASCII(gaia_id_string16);
-
std::string is_constrained;
net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained);
- const bool is_password_separated_signin_flow = is_constrained == "1";
- base::string16 session_index_string16;
- dict->GetString("sessionIndex", &session_index_string16);
- std::string session_index = base::UTF16ToASCII(session_index_string16);
+ DCHECK(!email.empty());
+ DCHECK(!gaia_id.empty());
+ const bool is_password_separated_signin_flow = is_constrained == "1";
DCHECK(is_password_separated_signin_flow || !session_index.empty());
-
- base::string16 auth_code_string16;
- dict->GetString("authCode", &auth_code_string16);
- std::string auth_code = base::UTF16ToASCII(auth_code_string16);
DCHECK(!is_password_separated_signin_flow || !auth_code.empty());
- bool choose_what_to_sync = false;
- dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync);
-
content::StoragePartition* partition =
content::BrowserContext::GetStoragePartitionForSite(
contents->GetBrowserContext(), signin::GetSigninPartitionURL());
@@ -716,10 +696,8 @@ void InlineLoginHandlerImpl::FinishCompleteLogin(
AboutSigninInternalsFactory::GetForProfile(profile);
about_signin_internals->OnAuthenticationResultReceived("Successful");
- SigninClient* signin_client =
- ChromeSigninClientFactory::GetForProfile(profile);
std::string signin_scoped_device_id =
- signin_client->GetSigninScopedDeviceId();
+ GetSigninScopedDeviceIdForProfile(profile);
base::WeakPtr<InlineLoginHandlerImpl> handler_weak_ptr;
if (params.handler)
handler_weak_ptr = params.handler->GetWeakPtr();
@@ -784,9 +762,8 @@ void InlineLoginHandlerImpl::SyncStarterCallback(
RedirectToNtpOrAppsPage(contents, access_point);
} else if (auto_close) {
bool show_account_management = ShouldShowAccountManagement(
- current_url,
- AccountConsistencyModeManager::IsMirrorEnabledForProfile(
- Profile::FromBrowserContext(contents->GetBrowserContext())));
+ current_url, AccountConsistencyModeManager::IsMirrorEnabledForProfile(
+ Profile::FromWebUI(web_ui())));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(&InlineLoginHandlerImpl::CloseTab,
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
index fb2d86fd6e3..1e95466923c 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h
@@ -50,7 +50,15 @@ class InlineLoginHandlerImpl : public InlineLoginHandler,
private:
// InlineLoginHandler overrides:
void SetExtraInitParams(base::DictionaryValue& params) override;
- void CompleteLogin(const base::ListValue* args) override;
+ void CompleteLogin(const std::string& email,
+ const std::string& password,
+ const std::string& gaia_id,
+ const std::string& auth_code,
+ bool skip_for_now,
+ bool trusted,
+ bool trusted_found,
+ bool choose_what_to_sync,
+ const std::string& session_index) override;
// This struct exists to pass paramters to the FinishCompleteLogin() method,
// since the base::Bind() call does not support this many template args.
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
index 6e672bea55e..0fd4b89993f 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc
@@ -112,7 +112,7 @@ ContentInfo NavigateAndGetInfo(
// Returns a new WebUI object for the WebContents from |arg0|.
ACTION(ReturnNewWebUI) {
- return new content::WebUIController(arg0);
+ return std::make_unique<content::WebUIController>(arg0);
}
GURL GetSigninPromoURL() {
@@ -126,8 +126,9 @@ GURL GetSigninPromoURL() {
class FooWebUIProvider
: public TestChromeWebUIControllerFactory::WebUIProvider {
public:
- MOCK_METHOD2(NewWebUI, content::WebUIController*(content::WebUI* web_ui,
- const GURL& url));
+ MOCK_METHOD2(NewWebUI,
+ std::unique_ptr<content::WebUIController>(content::WebUI* web_ui,
+ const GURL& url));
};
const char kFooWebUIURL[] = "chrome://foo/";
@@ -140,8 +141,7 @@ bool AddToSet(std::set<content::WebContents*>* set,
std::unique_ptr<net::test_server::HttpResponse> EmptyHtmlResponseHandler(
const net::test_server::HttpRequest& request) {
- std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
- new net::test_server::BasicHttpResponse());
+ auto http_response = std::make_unique<net::test_server::BasicHttpResponse>();
http_response->set_code(net::HTTP_OK);
http_response->set_content_type("text/html");
http_response->set_content(
@@ -882,7 +882,7 @@ class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest {
content::WebUIControllerFactory::UnregisterFactoryForTesting(
ChromeWebUIControllerFactory::GetInstance());
- test_factory_.reset(new TestChromeWebUIControllerFactory);
+ test_factory_ = std::make_unique<TestChromeWebUIControllerFactory>();
content::WebUIControllerFactory::RegisterFactory(test_factory_.get());
test_factory_->AddFactoryOverride(
GURL(kFooWebUIURL).host(), &foo_provider_);
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 cf0bf54fbfd..f5ca3a721c6 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
@@ -24,7 +24,6 @@
#include "base/scoped_observer.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -34,6 +33,7 @@
#include "chrome/browser/unified_consent/unified_consent_service_factory.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/sync/base/sync_prefs.h"
+#include "components/unified_consent/feature.h"
#include "components/unified_consent/pref_names.h"
#include "components/unified_consent/unified_consent_service.h"
@@ -79,8 +79,10 @@ class ConsentBumpActivator : public BrowserListObserver,
signin_manager->GetAuthenticatedAccountId())) {
unified_consent::UnifiedConsentService* consent_service =
UnifiedConsentServiceFactory::GetForProfile(profile_);
- consent_service->RecordConsentBumpSuppressReason(
- unified_consent::ConsentBumpSuppressReason::kSyncPaused);
+ if (consent_service->ShouldShowConsentBump()) {
+ consent_service->RecordConsentBumpSuppressReason(
+ unified_consent::ConsentBumpSuppressReason::kSyncPaused);
+ }
return;
}
@@ -139,7 +141,8 @@ class ConsentBumpActivator : public BrowserListObserver,
// This should only be called after the browser has been set up, otherwise
// this might crash because the profile has not been fully initialized yet.
static bool ShouldShowConsentBumpFor(Profile* profile) {
- if (!profile->IsSyncAllowed() || !IsUnifiedConsentBumpEnabled(profile) ||
+ if (!profile->IsSyncAllowed() ||
+ !unified_consent::IsUnifiedConsentFeatureWithBumpEnabled() ||
!ProfileSyncServiceFactory::HasProfileSyncService(profile))
return false;
@@ -181,7 +184,7 @@ LoginUIService::LoginUIService(Profile* profile)
#endif
{
#if !defined(OS_CHROMEOS)
- if (IsUnifiedConsentBumpEnabled(profile)) {
+ if (unified_consent::IsUnifiedConsentFeatureWithBumpEnabled()) {
consent_bump_activator_ =
std::make_unique<ConsentBumpActivator>(this, profile);
}
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service.h b/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
index 438d77285fb..7b154a3037e 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
@@ -111,7 +111,7 @@ class LoginUIService : public KeyedService {
#endif
// List of observers.
- base::ObserverList<Observer> observer_list_;
+ base::ObserverList<Observer>::Unchecked observer_list_;
base::string16 last_login_result_;
base::string16 last_login_error_email_;
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
index ba4b6ef5ea3..499700b37f2 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
@@ -141,7 +141,7 @@ bool IsDiceSigninPageEnabled(Profile* profile) {
return (account_consistency != signin::AccountConsistencyMethod::kMirror) &&
signin::DiceMethodGreaterOrEqual(
account_consistency,
- signin::AccountConsistencyMethod::kDicePrepareMigration);
+ signin::AccountConsistencyMethod::kDiceMigration);
}
// Returns the render frame host where Gaia credentials can be filled in.
@@ -150,10 +150,9 @@ content::RenderFrameHost* GetSigninFrame(content::WebContents* web_contents) {
Profile::FromBrowserContext(web_contents->GetBrowserContext()))) {
// Dice displays the Gaia page directly in a tab.
return web_contents->GetMainFrame();
- } else {
- // Embedded signin flow, uses a sub-frame in WebUI.
- return signin::GetAuthFrame(web_contents, "signin-frame");
}
+ // Embedded signin flow, uses a sub-frame in WebUI.
+ return signin::GetAuthFrame(web_contents, "signin-frame");
}
// Waits until the condition is met, by polling.
diff --git a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc b/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
index 9a8756624e9..350714cd436 100644
--- a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
@@ -45,8 +45,7 @@ MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui)
content::WebUIDataSource::Add(profile, CreateUIDataSource(localized_strings));
// Set up the chrome://theme/ source
- ThemeSource* theme = new ThemeSource(profile);
- content::URLDataSource::Add(profile, theme);
+ content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
}
MDUserManagerUI::~MDUserManagerUI() {}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
index f8777b673ec..fcaa6c1b2a5 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
@@ -144,8 +144,7 @@ void SigninCreateProfileHandler::DoCreateProfile(const base::string16& name,
profile_path_being_created_ = ProfileManager::CreateMultiProfileAsync(
name, icon_url,
base::Bind(&SigninCreateProfileHandler::OnProfileCreated,
- weak_ptr_factory_.GetWeakPtr(), create_shortcut),
- /*supervised_user_id=*/std::string());
+ weak_ptr_factory_.GetWeakPtr(), create_shortcut));
}
void SigninCreateProfileHandler::OnProfileCreated(
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
index 1fb615c2036..06d478de150 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/signin_view_controller_delegate.h"
@@ -26,6 +25,7 @@
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/avatar_icon_util.h"
#include "components/signin/core/browser/signin_manager.h"
+#include "components/unified_consent/feature.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "url/gurl.h"
@@ -96,6 +96,10 @@ void SyncConfirmationHandler::RegisterMessages() {
"initializedWithSize",
base::BindRepeating(&SyncConfirmationHandler::HandleInitializedWithSize,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "accountImageRequest",
+ base::BindRepeating(&SyncConfirmationHandler::HandleAccountImageRequest,
+ base::Unretained(this)));
}
void SyncConfirmationHandler::HandleConfirm(const base::ListValue* args) {
@@ -115,6 +119,21 @@ void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) {
CloseModalSigninWindow(LoginUIService::ABORT_SIGNIN);
}
+void SyncConfirmationHandler::HandleAccountImageRequest(
+ const base::ListValue* args) {
+ std::string account_id = SigninManagerFactory::GetForProfile(profile_)
+ ->GetAuthenticatedAccountId();
+ AccountInfo account_info =
+ AccountTrackerServiceFactory::GetForProfile(profile_)->GetAccountInfo(
+ account_id);
+
+ // Fire the "account-image-changed" listener from |SetUserImageURL()|.
+ // Note: If the account info is not available yet in the
+ // AccountTrackerService, i.e. account_info is empty, the listener will be
+ // fired again through |OnAccountUpdated()|.
+ SetUserImageURL(account_info.picture_url);
+}
+
void SyncConfirmationHandler::RecordConsent(const base::ListValue* args) {
CHECK_EQ(2U, args->GetSize());
const std::vector<base::Value>& consent_description =
@@ -139,11 +158,31 @@ void SyncConfirmationHandler::RecordConsent(const base::ListValue* args) {
<< consent_confirmation;
int consent_confirmation_id = iter->second;
- ConsentAuditorFactory::GetForProfile(profile_)->RecordGaiaConsent(
- SigninManagerFactory::GetForProfile(profile_)
- ->GetAuthenticatedAccountId(),
- consent_feature_, consent_text_ids, consent_confirmation_id,
- consent_auditor::ConsentStatus::GIVEN);
+ consent_auditor::ConsentAuditor* consent_auditor =
+ ConsentAuditorFactory::GetForProfile(profile_);
+ const std::string& account_id = SigninManagerFactory::GetForProfile(profile_)
+ ->GetAuthenticatedAccountId();
+ // TODO(markusheintz): Use a bool unified_consent_enabled instead of a
+ // consent_auditor::Feature type variable.
+ if (consent_feature_ == consent_auditor::Feature::CHROME_UNIFIED_CONSENT) {
+ sync_pb::UserConsentTypes::UnifiedConsent unified_consent;
+ unified_consent.set_confirmation_grd_id(consent_confirmation_id);
+ for (int id : consent_text_ids) {
+ unified_consent.add_description_grd_ids(id);
+ }
+ unified_consent.set_status(sync_pb::UserConsentTypes::ConsentStatus::
+ UserConsentTypes_ConsentStatus_GIVEN);
+ consent_auditor->RecordUnifiedConsent(account_id, unified_consent);
+ } else {
+ sync_pb::UserConsentTypes::SyncConsent sync_consent;
+ sync_consent.set_confirmation_grd_id(consent_confirmation_id);
+ for (int id : consent_text_ids) {
+ sync_consent.add_description_grd_ids(id);
+ }
+ sync_consent.set_status(sync_pb::UserConsentTypes::ConsentStatus::
+ UserConsentTypes_ConsentStatus_GIVEN);
+ consent_auditor->RecordSyncConsent(account_id, sync_consent);
+ }
}
void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) {
@@ -161,6 +200,11 @@ void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) {
base::Value picture_url_value(picture_url_to_load);
web_ui()->CallJavascriptFunctionUnsafe("sync.confirmation.setUserImageURL",
picture_url_value);
+
+ if (unified_consent::IsUnifiedConsentFeatureEnabled()) {
+ AllowJavascript();
+ FireWebUIListener("account-image-changed", picture_url_value);
+ }
}
void SyncConfirmationHandler::OnAccountUpdated(const AccountInfo& info) {
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.h b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.h
index 3eb4b5bb536..9269e688a2e 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.h
@@ -63,6 +63,11 @@ class SyncConfirmationHandler : public content::WebUIMessageHandler,
// a single integer value for the height the native view should resize to.
virtual void HandleInitializedWithSize(const base::ListValue* args);
+ // Handles the "accountImageRequest" message sent after the
+ // "account-image-changed" WebUIListener was added. This method calls
+ // |SetUserImageURL| with the signed-in user's picture url.
+ virtual void HandleAccountImageRequest(const base::ListValue* args);
+
// Records the user's consent to sync. Called from |HandleConfirm| and
// |HandleGoToSettings|, and expects two parameters to be passed through
// these methods from the WebUI:
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
index 48e1cd78036..df687d3b6c2 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
-#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h"
#include "chrome/common/url_constants.h"
@@ -19,6 +18,7 @@
#include "chrome/grit/generated_resources.h"
#include "components/signin/core/browser/avatar_icon_util.h"
#include "components/strings/grit/components_strings.h"
+#include "components/unified_consent/feature.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "services/identity/public/cpp/identity_manager.h"
@@ -30,7 +30,8 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
consent_feature_(consent_auditor::Feature::CHROME_SYNC) {
Profile* profile = Profile::FromWebUI(web_ui);
bool is_sync_allowed = profile->IsSyncAllowed();
- bool is_unified_consent_enabled = IsUnifiedConsentEnabled(profile);
+ bool is_unified_consent_enabled =
+ unified_consent::IsUnifiedConsentFeatureEnabled();
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUISyncConfirmationHost);
@@ -133,8 +134,8 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
title_ids = AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)
? IDS_SYNC_CONFIRMATION_DICE_TITLE
: IDS_SYNC_CONFIRMATION_TITLE;
- confirm_button_ids = IDS_SYNC_CONFIRMATION_CONFIRM_BUTTON_LABEL;
- undo_button_ids = IDS_SYNC_CONFIRMATION_UNDO_BUTTON_LABEL;
+ confirm_button_ids = IDS_SETTINGS_TURN_ON;
+ undo_button_ids = IDS_CANCEL;
consent_feature_ = consent_auditor::Feature::CHROME_SYNC;
if (!is_sync_allowed) {
title_ids = IDS_SYNC_DISABLED_CONFIRMATION_CHROME_SYNC_TITLE;
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
index e83ded59827..d6285df2ec5 100644
--- a/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc
@@ -351,8 +351,8 @@ void UserManagerScreenHandler::HandleAuthenticatedLaunchUser(
if (!oauth_client_) {
oauth_client_.reset(new gaia::GaiaOAuthClient(
content::BrowserContext::GetDefaultStoragePartition(
- web_ui()->GetWebContents()->GetBrowserContext())->
- GetURLRequestContext()));
+ web_ui()->GetWebContents()->GetBrowserContext())
+ ->GetURLLoaderFactoryForBrowserProcess()));
}
const std::string token = entry->GetPasswordChangeDetectionToken();
@@ -496,13 +496,6 @@ void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
ProfileMetrics::SWITCH_PROFILE_MANAGER);
}
-void UserManagerScreenHandler::HandleHardlockUserPod(
- const base::ListValue* args) {
- std::string email;
- CHECK(args->GetString(0, &email));
- const AccountId account_id = AccountId::FromUserEmail(email);
-}
-
void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats(
const base::ListValue* args) {
const base::Value* profile_path_value;
@@ -796,8 +789,8 @@ void UserManagerScreenHandler::SendUserList() {
profile_value->SetString(kKeyEmailAddress, entry->GetUserName());
profile_value->SetString(kKeyDisplayName,
profiles::GetAvatarNameForProfile(profile_path));
- profile_value->Set(kKeyProfilePath,
- base::CreateFilePathValue(profile_path));
+ profile_value->SetKey(kKeyProfilePath,
+ base::CreateFilePathValue(profile_path));
profile_value->SetBoolean(kKeyPublicAccount, false);
profile_value->SetBoolean(kKeyLegacySupervisedUser,
entry->IsLegacySupervised());
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h b/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h
index eac65e54b00..7a138993aa9 100644
--- a/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.h
@@ -72,8 +72,6 @@ class UserManagerScreenHandler
void HandleLaunchUser(const base::ListValue* args);
void HandleRemoveUser(const base::ListValue* args);
void HandleAreAllProfilesLocked(const base::ListValue* args);
- void HandleAttemptUnlock(const base::ListValue* args);
- void HandleHardlockUserPod(const base::ListValue* args);
void HandleRemoveUserWarningLoadStats(const base::ListValue* args);
void HandleGetRemoveWarningDialogMessage(const base::ListValue* args);
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/DEPS b/chromium/chrome/browser/ui/webui/sync_file_system_internals/DEPS
deleted file mode 100644
index cdad3c26c29..00000000000
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- "+components/drive",
-]
diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS b/chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS
index 6bf7d0a8f63..b3c989cfce8 100644
--- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/OWNERS
@@ -1,6 +1,7 @@
calvinlo@chromium.org
kinuko@chromium.org
nhiroki@chromium.org
+pwnall@chromium.org
tzik@chromium.org
# TEAM: storage-dev@chromium.org
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js b/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js
index 273c0056480..51cf439a4b8 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js
+++ b/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+GEN('#include "components/sync/driver/sync_driver_switches.h"');
+
/**
* Test fixture for sync internals WebUI testing.
* @constructor
@@ -56,6 +58,22 @@ SyncInternalsWebUITest.prototype = {
}
};
+function SyncInternalsWebUITestWithStandaloneTransport() {}
+
+SyncInternalsWebUITestWithStandaloneTransport.prototype = {
+ __proto__: SyncInternalsWebUITest.prototype,
+
+ featureList: ['switches::kSyncStandaloneTransport', ''],
+};
+
+function SyncInternalsWebUITestWithoutStandaloneTransport() {}
+
+SyncInternalsWebUITestWithoutStandaloneTransport.prototype = {
+ __proto__: SyncInternalsWebUITest.prototype,
+
+ featureList: ['', 'switches::kSyncStandaloneTransport'],
+};
+
/**
* Constant hard-coded value to return from mock getAllNodes.
* @const
@@ -241,15 +259,25 @@ TEST_F('SyncInternalsWebUITest', 'Uninitialized', function() {
// On chromeos, browser tests are signed in by default. On other platforms,
// browser tests are signed out.
GEN('#if defined(OS_CHROMEOS)');
-TEST_F('SyncInternalsWebUITest', 'SignedIn', function() {
+TEST_F('SyncInternalsWebUITestWithStandaloneTransport', 'SignedIn', function() {
assertNotEquals(null, chrome.sync.aboutInfo);
- expectTrue(this.hasInDetails(true, 'Summary', 'Waiting for start request'));
+ expectTrue(this.hasInDetails(true, 'Transport State', 'Initializing'));
+ expectTrue(this.hasInDetails(true, 'Disable Reasons', 'None'));
expectTrue(this.hasInDetails(true, 'Username', 'stub-user@example.com'));
});
+TEST_F(
+ 'SyncInternalsWebUITestWithoutStandaloneTransport', 'SignedIn', function() {
+ assertNotEquals(null, chrome.sync.aboutInfo);
+ expectTrue(this.hasInDetails(
+ true, 'Transport State', 'Waiting for start request'));
+ expectTrue(this.hasInDetails(true, 'Disable Reasons', 'None'));
+ expectTrue(this.hasInDetails(true, 'Username', 'stub-user@example.com'));
+ });
GEN('#else');
TEST_F('SyncInternalsWebUITest', 'SignedOut', function() {
assertNotEquals(null, chrome.sync.aboutInfo);
- expectTrue(this.hasInDetails(true, 'Summary', 'Disabled (Not signed in)'));
+ expectTrue(this.hasInDetails(true, 'Transport State', 'Disabled'));
+ expectTrue(this.hasInDetails(true, 'Disable Reasons', 'Not signed in'));
expectTrue(this.hasInDetails(true, 'Username', ''));
});
GEN('#endif // defined(OS_CHROMEOS)');
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc
index 49fe3b36d86..adb42796719 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc
@@ -64,6 +64,13 @@ bool HasSomethingAtIndex(const base::ListValue* list, int index) {
return false;
}
+// Returns the initial state of the "include specifics" flag, based on whether
+// or not the corresponding command-line switch is set.
+bool GetIncludeSpecificsInitialState() {
+ return base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSyncIncludeSpecificsInProtocolLog);
+}
+
} // namespace
SyncInternalsMessageHandler::SyncInternalsMessageHandler()
@@ -72,7 +79,8 @@ SyncInternalsMessageHandler::SyncInternalsMessageHandler()
SyncInternalsMessageHandler::SyncInternalsMessageHandler(
AboutSyncDataDelegate about_sync_data_delegate)
- : about_sync_data_delegate_(std::move(about_sync_data_delegate)),
+ : include_specifics_(GetIncludeSpecificsInitialState()),
+ about_sync_data_delegate_(std::move(about_sync_data_delegate)),
weak_ptr_factory_(this) {}
SyncInternalsMessageHandler::~SyncInternalsMessageHandler() {
@@ -115,6 +123,12 @@ void SyncInternalsMessageHandler::RegisterMessages() {
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ syncer::sync_ui_util::kRequestIncludeSpecificsInitialState,
+ base::BindRepeating(&SyncInternalsMessageHandler::
+ HandleRequestIncludeSpecificsInitialState,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
syncer::sync_ui_util::kRequestUserEventsVisibility,
base::BindRepeating(
&SyncInternalsMessageHandler::HandleRequestUserEventsVisibility,
@@ -204,14 +218,26 @@ void SyncInternalsMessageHandler::HandleRequestListOfTypes(
DictionaryValue event_details;
auto type_list = std::make_unique<ListValue>();
ModelTypeSet protocol_types = syncer::ProtocolTypes();
- for (ModelTypeSet::Iterator it = protocol_types.First(); it.Good();
- it.Inc()) {
- type_list->AppendString(ModelTypeToString(it.Get()));
+ for (syncer::ModelType type : protocol_types) {
+ type_list->AppendString(ModelTypeToString(type));
}
event_details.Set(syncer::sync_ui_util::kTypes, std::move(type_list));
DispatchEvent(syncer::sync_ui_util::kOnReceivedListOfTypes, event_details);
}
+void SyncInternalsMessageHandler::HandleRequestIncludeSpecificsInitialState(
+ const ListValue* args) {
+ DCHECK(args->empty());
+ AllowJavascript();
+
+ DictionaryValue value;
+ value.SetBoolean(syncer::sync_ui_util::kIncludeSpecifics,
+ GetIncludeSpecificsInitialState());
+
+ DispatchEvent(syncer::sync_ui_util::kOnReceivedIncludeSpecificsInitialState,
+ value);
+}
+
void SyncInternalsMessageHandler::HandleGetAllNodes(const ListValue* args) {
DCHECK_EQ(1U, args->GetSize());
AllowJavascript();
@@ -292,7 +318,7 @@ void SyncInternalsMessageHandler::HandleRequestStop(
if (!service)
return;
- service->RequestStop(SyncService::KEEP_DATA);
+ service->RequestStop(SyncService::CLEAR_DATA);
}
void SyncInternalsMessageHandler::HandleTriggerRefresh(
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h
index 6d721993633..1ba4fc3b769 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h
@@ -52,9 +52,12 @@ class SyncInternalsMessageHandler : public content::WebUIMessageHandler,
// Fires an event to send updated info back to the page.
void HandleRequestUpdatedAboutInfo(const base::ListValue* args);
- // Fires and event to send the list of types back to the page.
+ // Fires an event to send the list of types back to the page.
void HandleRequestListOfTypes(const base::ListValue* args);
+ // Fires an event to send the initial state of the "include specifics" flag.
+ void HandleRequestIncludeSpecificsInitialState(const base::ListValue* args);
+
// Handler for getAllNodes message. Needs a |request_id| argument.
void HandleGetAllNodes(const base::ListValue* args);
diff --git a/chromium/chrome/browser/ui/webui/task_scheduler_internals/OWNERS b/chromium/chrome/browser/ui/webui/task_scheduler_internals/OWNERS
index ffc802c14e6..495a17c74d4 100644
--- a/chromium/chrome/browser/ui/webui/task_scheduler_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/task_scheduler_internals/OWNERS
@@ -1 +1 @@
-file://base/task_scheduler/OWNERS
+file://base/task/task_scheduler/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc b/chromium/chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc
index 641156f4958..a00370db585 100644
--- a/chromium/chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc
@@ -11,7 +11,7 @@
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h"
#include "base/numerics/safe_conversions.h"
-#include "base/task_scheduler/task_scheduler.h"
+#include "base/task/task_scheduler/task_scheduler.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
diff --git a/chromium/chrome/browser/ui/webui/theme_handler.cc b/chromium/chrome/browser/ui/webui/theme_handler.cc
index b1aaf4cdfbd..d0696a73f7b 100644
--- a/chromium/chrome/browser/ui/webui/theme_handler.cc
+++ b/chromium/chrome/browser/ui/webui/theme_handler.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/theme_handler.h"
+#include <memory>
+
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
@@ -49,8 +51,7 @@ void ThemeHandler::Observe(int type,
void ThemeHandler::InitializeCSSCaches() {
Profile* profile = GetProfile();
- ThemeSource* theme = new ThemeSource(profile);
- content::URLDataSource::Add(profile, theme);
+ content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
}
Profile* ThemeHandler::GetProfile() const {
diff --git a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc
index 5525c24d8fc..220af586aef 100644
--- a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc
+++ b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc
@@ -131,9 +131,7 @@ void TranslateInternalsHandler::OnTranslateEvent(
}
void TranslateInternalsHandler::OnRemovePrefItem(const base::ListValue* args) {
- content::WebContents* web_contents = web_ui()->GetWebContents();
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ Profile* profile = Profile::FromWebUI(web_ui());
PrefService* prefs = profile->GetOriginalProfile()->GetPrefs();
std::unique_ptr<translate::TranslatePrefs> translate_prefs(
ChromeTranslateClient::CreateTranslatePrefs(prefs));
@@ -170,9 +168,7 @@ void TranslateInternalsHandler::OnRemovePrefItem(const base::ListValue* args) {
void TranslateInternalsHandler::OnSetRecentTargetLanguage(
const base::ListValue* args) {
- content::WebContents* web_contents = web_ui()->GetWebContents();
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ Profile* profile = Profile::FromWebUI(web_ui());
PrefService* prefs = profile->GetOriginalProfile()->GetPrefs();
std::unique_ptr<translate::TranslatePrefs> translate_prefs(
ChromeTranslateClient::CreateTranslatePrefs(prefs));
@@ -212,14 +208,12 @@ void TranslateInternalsHandler::SendMessageToJs(const std::string& message,
}
void TranslateInternalsHandler::SendPrefsToJs() {
- content::WebContents* web_contents = web_ui()->GetWebContents();
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ Profile* profile = Profile::FromWebUI(web_ui());
PrefService* prefs = profile->GetOriginalProfile()->GetPrefs();
base::DictionaryValue dict;
- static const char* keys[] = {
+ static const char* const keys[] = {
prefs::kOfferTranslateEnabled,
translate::TranslatePrefs::kPrefTranslateRecentTarget,
translate::TranslatePrefs::kPrefTranslateBlockedLanguages,
@@ -242,9 +236,7 @@ void TranslateInternalsHandler::SendPrefsToJs() {
void TranslateInternalsHandler::SendSupportedLanguagesToJs() {
// Create translate prefs.
- content::WebContents* web_contents = web_ui()->GetWebContents();
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ Profile* profile = Profile::FromWebUI(web_ui());
PrefService* prefs = profile->GetOriginalProfile()->GetPrefs();
std::unique_ptr<translate::TranslatePrefs> translate_prefs(
ChromeTranslateClient::CreateTranslatePrefs(prefs));
@@ -257,11 +249,8 @@ void TranslateInternalsHandler::SendSupportedLanguagesToJs() {
translate::TranslateDownloadManager::GetSupportedLanguagesLastUpdated();
auto languages_list = std::make_unique<base::ListValue>();
- for (std::vector<std::string>::iterator it = languages.begin();
- it != languages.end(); ++it) {
- const std::string& lang = *it;
+ for (const std::string& lang : languages)
languages_list->AppendString(lang);
- }
base::DictionaryValue dict;
dict.Set("languages", std::move(languages_list));
diff --git a/chromium/chrome/browser/ui/webui/ukm/ukm_internals_ui.cc b/chromium/chrome/browser/ui/webui/ukm/ukm_internals_ui.cc
new file mode 100644
index 00000000000..0b69b7bb827
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/ukm/ukm_internals_ui.cc
@@ -0,0 +1,100 @@
+// 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/ukm/ukm_internals_ui.h"
+
+#include <stddef.h>
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/grit/browser_resources.h"
+#include "components/metrics_services_manager/metrics_services_manager.h"
+#include "components/ukm/debug/ukm_debug_data_extractor.h"
+#include "components/ukm/ukm_service.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace {
+
+content::WebUIDataSource* CreateUkmHTMLSource() {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIUkmHost);
+
+ source->AddResourcePath("ukm_internals.js", IDR_UKM_INTERNALS_JS);
+ source->SetDefaultResource(IDR_UKM_INTERNALS_HTML);
+ source->UseGzip();
+ return source;
+}
+
+// This class receives javascript messages from the renderer.
+// Note that the WebUI infrastructure runs on the UI thread, therefore all of
+// this class's methods are expected to run on the UI thread.
+class UkmMessageHandler : public content::WebUIMessageHandler {
+ public:
+ explicit UkmMessageHandler(const ukm::UkmService* ukm_service);
+ ~UkmMessageHandler() override;
+
+ // WebUIMessageHandler:
+ void RegisterMessages() override;
+
+ private:
+ void HandleRequestUkmData(const base::ListValue* args);
+
+ const ukm::UkmService* ukm_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(UkmMessageHandler);
+};
+
+UkmMessageHandler::UkmMessageHandler(const ukm::UkmService* ukm_service)
+ : ukm_service_(ukm_service) {}
+
+UkmMessageHandler::~UkmMessageHandler() {}
+
+void UkmMessageHandler::HandleRequestUkmData(const base::ListValue* args) {
+ AllowJavascript();
+
+ // Identifies the callback, used for when resolving.
+ std::string callback_id;
+ args->GetString(0, &callback_id);
+
+ base::Value ukm_debug_data =
+ ukm::debug::UkmDebugDataExtractor::GetStructuredData(ukm_service_);
+
+ ResolveJavascriptCallback(base::Value(callback_id),
+ std::move(ukm_debug_data));
+}
+
+void UkmMessageHandler::RegisterMessages() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ // We can use base::Unretained() here, as both the callback and this class are
+ // owned by UkmInternalsUI.
+ web_ui()->RegisterMessageCallback(
+ "requestUkmData",
+ base::BindRepeating(&UkmMessageHandler::HandleRequestUkmData,
+ base::Unretained(this)));
+}
+
+} // namespace
+
+// Changes to this class should be in sync with its iOS equivalent
+// ios/chrome/browser/ui/webui/ukm_internals_ui.cc
+UkmInternalsUI::UkmInternalsUI(content::WebUI* web_ui)
+ : content::WebUIController(web_ui) {
+ ukm::UkmService* ukm_service =
+ g_browser_process->GetMetricsServicesManager()->GetUkmService();
+ web_ui->AddMessageHandler(std::make_unique<UkmMessageHandler>(ukm_service));
+
+ // Set up the chrome://ukm/ source.
+ content::BrowserContext* browser_context =
+ web_ui->GetWebContents()->GetBrowserContext();
+ content::WebUIDataSource::Add(browser_context, CreateUkmHTMLSource());
+}
diff --git a/chromium/chrome/browser/ui/webui/ukm/ukm_internals_ui.h b/chromium/chrome/browser/ui/webui/ukm/ukm_internals_ui.h
new file mode 100644
index 00000000000..16055360210
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/ukm/ukm_internals_ui.h
@@ -0,0 +1,20 @@
+// 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_UKM_UKM_INTERNALS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_UKM_UKM_INTERNALS_UI_H_
+
+#include "base/macros.h"
+#include "content/public/browser/web_ui_controller.h"
+
+// Handles serving the chrome://ukm HTML and JS.
+class UkmInternalsUI : public content::WebUIController {
+ public:
+ explicit UkmInternalsUI(content::WebUI* web_ui);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UkmInternalsUI);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_UKM_UKM_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/version_handler.cc b/chromium/chrome/browser/ui/webui/version_handler.cc
index 90a780dc97a..919e04bc47d 100644
--- a/chromium/chrome/browser/ui/webui/version_handler.cc
+++ b/chromium/chrome/browser/ui/webui/version_handler.cc
@@ -12,8 +12,8 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/threading/thread_restrictions.h"
+#include "base/task/post_task.h"
+#include "base/threading/scoped_blocking_call.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/generated_resources.h"
@@ -36,7 +36,7 @@ namespace {
void GetFilePaths(const base::FilePath& profile_path,
base::string16* exec_path_out,
base::string16* profile_path_out) {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::FilePath executable_path = base::MakeAbsoluteFilePath(
base::CommandLine::ForCurrentProcess()->GetProgram());
diff --git a/chromium/chrome/browser/ui/webui/version_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/version_handler_chromeos.cc
index 95bdee7b4b3..c877fabee31 100644
--- a/chromium/chrome/browser/ui/webui/version_handler_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/version_handler_chromeos.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/webui/version_handler_chromeos.h"
#include "base/bind.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "content/public/browser/web_ui.h"
VersionHandlerChromeOS::VersionHandlerChromeOS() : weak_factory_(this) {}
@@ -16,18 +16,18 @@ void VersionHandlerChromeOS::HandleRequestVersionInfo(
const base::ListValue* args) {
// Start the asynchronous load of the versions.
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&chromeos::version_loader::GetVersion,
chromeos::version_loader::VERSION_FULL),
base::Bind(&VersionHandlerChromeOS::OnVersion,
weak_factory_.GetWeakPtr()));
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&chromeos::version_loader::GetFirmware),
base::Bind(&VersionHandlerChromeOS::OnOSFirmware,
weak_factory_.GetWeakPtr()));
base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND},
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&chromeos::version_loader::GetARCVersion),
base::Bind(&VersionHandlerChromeOS::OnARCVersion,
weak_factory_.GetWeakPtr()));
diff --git a/chromium/chrome/browser/ui/webui/version_ui.cc b/chromium/chrome/browser/ui/webui/version_ui.cc
index bc9b88c1335..3c38271942a 100644
--- a/chromium/chrome/browser/ui/webui/version_ui.cc
+++ b/chromium/chrome/browser/ui/webui/version_ui.cc
@@ -117,13 +117,9 @@ WebUIDataSource* CreateVersionUIDataSource() {
html_source->AddString(version_ui::kFlashVersion, std::string());
#endif // OS_ANDROID
-#if defined(ARCH_CPU_64_BITS)
- html_source->AddLocalizedString(version_ui::kVersionBitSize,
- IDS_VERSION_UI_64BIT);
-#else
- html_source->AddLocalizedString(version_ui::kVersionBitSize,
- IDS_VERSION_UI_32BIT);
-#endif
+ html_source->AddLocalizedString(
+ version_ui::kVersionBitSize,
+ sizeof(void*) == 8 ? IDS_VERSION_UI_64BIT : IDS_VERSION_UI_32BIT);
#if defined(OS_WIN)
html_source->AddString(
@@ -141,8 +137,6 @@ WebUIDataSource* CreateVersionUIDataSource() {
#endif
#if defined(OS_WIN)
- html_source->AddString("linker", CHROMIUM_LINKER_NAME);
-
base::string16 update_cohort_name =
install_static::InstallDetails::Get().update_cohort_name();
if (!update_cohort_name.empty()) {
@@ -177,8 +171,7 @@ VersionUI::VersionUI(content::WebUI* web_ui)
#if !defined(OS_ANDROID)
// Set up the chrome://theme/ source.
- ThemeSource* theme = new ThemeSource(profile);
- content::URLDataSource::Add(profile, theme);
+ content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
#endif
WebUIDataSource::Add(profile, CreateVersionUIDataSource());
diff --git a/chromium/chrome/browser/ui/webui/welcome_ui.cc b/chromium/chrome/browser/ui/webui/welcome_ui.cc
index 4bcca49cb97..36b786ce5fe 100644
--- a/chromium/chrome/browser/ui/webui/welcome_ui.cc
+++ b/chromium/chrome/browser/ui/webui/welcome_ui.cc
@@ -25,9 +25,10 @@
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "components/nux/constants.h"
+#include "components/nux/email/email_handler.h"
+#include "components/nux/google_apps/google_apps_handler.h"
#include "components/nux/show_promo_delegate.h"
-#include "components/nux_google_apps/constants.h"
-#include "components/nux_google_apps/google_apps_handler.h"
#include "content/public/browser/web_contents.h"
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
@@ -63,7 +64,6 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
// There are multiple possible configurations that affects the layout, but
// first add resources that are shared across all layouts.
- html_source->AddLocalizedString("acceptText", IDS_WELCOME_ACCEPT_BUTTON);
html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128);
html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256);
@@ -71,6 +71,8 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
// Otherwise use the default layout.
if (kIsBranded && is_dice) {
html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER);
+ html_source->AddLocalizedString("acceptText",
+ IDS_PROFILES_DICE_SIGNIN_BUTTON);
html_source->AddLocalizedString("secondHeaderText",
IDS_DICE_WELCOME_SECOND_HEADER);
html_source->AddLocalizedString("descriptionText",
@@ -103,6 +105,7 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
int header_id = is_everywhere_variant ? IDS_WELCOME_HEADER_AFTER_FIRST_RUN
: IDS_WELCOME_HEADER;
html_source->AddString("headerText", l10n_util::GetStringUTF16(header_id));
+ html_source->AddLocalizedString("acceptText", IDS_WELCOME_ACCEPT_BUTTON);
html_source->AddLocalizedString("descriptionText", IDS_WELCOME_DESCRIPTION);
html_source->AddLocalizedString("declineText", IDS_WELCOME_DECLINE_BUTTON);
html_source->AddResourcePath("welcome.js", IDR_WELCOME_JS);
@@ -111,17 +114,33 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
}
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
- if (base::FeatureList::IsEnabled(nux_google_apps::kNuxGoogleAppsFeature)) {
+ // To avoid diluting data collection, existing users should not be assigned
+ // an NUX group. So, the kOnboardDuringNUX flag is used to short-circuit the
+ // feature checks below.
+ PrefService* prefs = profile->GetPrefs();
+ bool onboard_during_nux =
+ prefs && prefs->GetBoolean(prefs::kOnboardDuringNUX);
+
+ if (onboard_during_nux &&
+ base::FeatureList::IsEnabled(nux::kNuxEmailFeature)) {
+ web_ui->AddMessageHandler(std::make_unique<nux::EmailHandler>(
+ profile->GetPrefs(), FaviconServiceFactory::GetForProfile(
+ profile, ServiceAccessType::EXPLICIT_ACCESS)));
+
+ nux::EmailHandler::AddSources(html_source, profile->GetPrefs());
+ }
+
+ if (onboard_during_nux &&
+ base::FeatureList::IsEnabled(nux::kNuxGoogleAppsFeature)) {
content::BrowserContext* browser_context =
web_ui->GetWebContents()->GetBrowserContext();
- web_ui->AddMessageHandler(
- std::make_unique<nux_google_apps::GoogleAppsHandler>(
- profile->GetPrefs(),
- FaviconServiceFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS),
- BookmarkModelFactory::GetForBrowserContext(browser_context)));
-
- nux_google_apps::GoogleAppsHandler::AddSources(html_source);
+ web_ui->AddMessageHandler(std::make_unique<nux::GoogleAppsHandler>(
+ profile->GetPrefs(),
+ FaviconServiceFactory::GetForProfile(
+ profile, ServiceAccessType::EXPLICIT_ACCESS),
+ BookmarkModelFactory::GetForBrowserContext(browser_context)));
+
+ nux::GoogleAppsHandler::AddSources(html_source);
}
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD
@@ -132,15 +151,23 @@ WelcomeUI::~WelcomeUI() {}
void WelcomeUI::StorePageSeen(Profile* profile, const GURL& url) {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
- if (url.EqualsIgnoringRef(GURL(nux_google_apps::kNuxGoogleAppsUrl))) {
+ if (url.EqualsIgnoringRef(GURL(nux::kNuxGoogleAppsUrl))) {
// Record that the new user experience page was visited.
profile->GetPrefs()->SetBoolean(prefs::kHasSeenGoogleAppsPromoPage, true);
// Record UMA.
- UMA_HISTOGRAM_ENUMERATION(
- nux_google_apps::kGoogleAppsInteractionHistogram,
- nux_google_apps::GoogleAppsInteraction::kPromptShown,
- nux_google_apps::GoogleAppsInteraction::kCount);
+ UMA_HISTOGRAM_ENUMERATION(nux::kGoogleAppsInteractionHistogram,
+ nux::GoogleAppsInteraction::kPromptShown,
+ nux::GoogleAppsInteraction::kCount);
+ return;
+ }
+
+ if (url.EqualsIgnoringRef(GURL(nux::kNuxEmailUrl))) {
+ // Record that the new user experience page was visited.
+ profile->GetPrefs()->SetBoolean(prefs::kHasSeenEmailPromoPage, true);
+
+ // TODO(scottchen): Record UMA.
+
return;
}
#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
diff --git a/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc b/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc
index eb83e52757c..da5eeb1c7f2 100644
--- a/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc
+++ b/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc
@@ -70,8 +70,8 @@ WelcomeWin10Handler::~WelcomeWin10Handler() {
histogram_suffix += pin_instructions_shown ? "Combined" : "Default";
// Closing the page. Record whether the instructions were useful.
- (new shell_integration::DefaultBrowserWorker(
- base::Bind(&RecordDefaultBrowserResult, histogram_suffix)))
+ base::MakeRefCounted<shell_integration::DefaultBrowserWorker>(
+ base::Bind(&RecordDefaultBrowserResult, histogram_suffix))
->StartCheckIsDefault();
if (pin_instructions_shown) {
@@ -134,8 +134,8 @@ void WelcomeWin10Handler::HandleSetDefaultBrowser(const base::ListValue* args) {
base::RecordAction(
base::UserMetricsAction("Win10WelcomePage_SetAsDefaultBrowser"));
// The worker owns itself.
- (new shell_integration::DefaultBrowserWorker(
- shell_integration::DefaultWebClientWorkerCallback()))
+ base::MakeRefCounted<shell_integration::DefaultBrowserWorker>(
+ shell_integration::DefaultWebClientWorkerCallback())
->StartSetAsDefault();
}