summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/ui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-24 11:40:17 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-24 12:42:11 +0000
commit5d87695f37678f96492b258bbab36486c59866b4 (patch)
treebe9783bbaf04fb930c4d74ca9c00b5e7954c8bc6 /chromium/chrome/browser/ui
parent6c11fb357ec39bf087b8b632e2b1e375aef1b38b (diff)
BASELINE: Update Chromium to 75.0.3770.56
Change-Id: I86d2007fd27a45d5797eee06f4c9369b8b50ac4f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui')
-rw-r--r--chromium/chrome/browser/ui/BUILD.gn306
-rw-r--r--chromium/chrome/browser/ui/libgtkui/BUILD.gn1
-rw-r--r--chromium/chrome/browser/ui/views/BUILD.gn2
-rw-r--r--chromium/chrome/browser/ui/webui/app_management/app_management.mojom7
-rw-r--r--chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/app_management/app_management_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h3
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc11
-rw-r--r--chromium/chrome/browser/ui/webui/browser_switcher/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/browser_switcher/browser_switch_ui.cc43
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc464
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h89
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc99
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h48
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h24
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc38
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h30
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc (renamed from chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc)10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h (renamed from chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h)21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc (renamed from chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc)6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.h (renamed from chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h)12
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/image_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.cc90
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.h40
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/insession_password_change_ui.cc47
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/insession_password_change_ui.h25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/OWNERS7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h17
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h35
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.h27
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc82
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h247
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_set_wallpaper.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.cc3
-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/discover_screen_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc45
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc67
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc41
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc76
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h22
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc54
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h41
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container.cc52
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container.h84
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.h43
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.cc216
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h76
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc98
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h25
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc94
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h24
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc135
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc82
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc187
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h81
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h38
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_ui.cc38
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc62
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/set_time_ui_browsertest.js37
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc2
-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.h6
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/video_source.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc511
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h84
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc394
-rw-r--r--chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h68
-rw-r--r--chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/crashes_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/dark_mode_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/dark_mode_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/dark_mode_handler_unittest.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/device_log_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/download_internals/download_internals_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_ui.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc254
-rw-r--r--chromium/chrome/browser/ui/webui/favicon_source.cc63
-rw-r--r--chromium/chrome/browser/ui/webui/favicon_source.h5
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/BUILD.gn4
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom34
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/flags_ui.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/help/version_updater_chromeos_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_page_handler_unittest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/log_web_ui_url.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/log_web_ui_url_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/managed_ui_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/management_a11y_browsertest.cc26
-rw-r--r--chromium/chrome/browser/ui/webui/management_a11y_browsertest.h23
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui.cc120
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui.h3
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui_browsertest.cc130
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui_handler.cc454
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui_handler.h31
-rw-r--r--chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc365
-rw-r--r--chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.h2
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/nacl_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h6
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h19
-rw-r--r--chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom1
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/policy_indicator_localized_strings_provider.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/policy_ui_handler.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc134
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h28
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc323
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.cc36
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.h8
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.h5
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h8
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc101
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc253
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h40
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc156
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc15
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/google_assistant_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc245
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h (renamed from chromium/chrome/browser/ui/webui/settings/md_settings_ui.h)20
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.cc243
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.h27
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc740
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc (renamed from chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc)268
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.h (renamed from chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.h)6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc251
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h78
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_ui.cc (renamed from chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc)327
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_ui.h61
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_ui_browsertest.cc (renamed from chromium/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc)6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc28
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc30
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h6
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.cc53
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h17
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.h38
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc20
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc17
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc95
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc14
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_ui.cc (renamed from chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc)50
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_ui.h (renamed from chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.h)14
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/signin_internals_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/site_settings_helper.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom8
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc82
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_browsertest.js27
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/test_files_request_filter.cc33
-rw-r--r--chromium/chrome/browser/ui/webui/test_files_request_filter.h4
-rw-r--r--chromium/chrome/browser/ui/webui/theme_handler.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/theme_handler.h26
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc88
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h48
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc277
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.h105
-rw-r--r--chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/version_handler_win.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/version_handler_win_unittest.cc23
-rw-r--r--chromium/chrome/browser/ui/webui/web_ui_test_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/web_ui_test_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/webapks_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/webui_browsertest.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/constants.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/constants.h2
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/email_handler.cc92
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/email_handler.h56
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/email_providers_list.cc67
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/email_providers_list.h21
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.cc88
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux_helper.cc139
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/nux_helper.h4
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc99
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/welcome_ui.h4
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/welcome_ui_unittest.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.cc12
309 files changed, 8458 insertions, 4750 deletions
diff --git a/chromium/chrome/browser/ui/BUILD.gn b/chromium/chrome/browser/ui/BUILD.gn
index d4ff15d0fcd..7561cab1680 100644
--- a/chromium/chrome/browser/ui/BUILD.gn
+++ b/chromium/chrome/browser/ui/BUILD.gn
@@ -43,8 +43,6 @@ jumbo_split_static_library("ui") {
"app_list/app_list_util.h",
# All other browser/ui/app_list files go under enable_app_list below.
- "autofill/autofill_dialog_models.cc",
- "autofill/autofill_dialog_models.h",
"autofill/autofill_popup_controller.h",
"autofill/autofill_popup_controller_impl.cc",
"autofill/autofill_popup_controller_impl.h",
@@ -56,19 +54,22 @@ jumbo_split_static_library("ui") {
"autofill/autofill_popup_view_delegate.h",
"autofill/chrome_autofill_client.cc",
"autofill/chrome_autofill_client.h",
- "autofill/create_card_unmask_prompt_view.h",
- "autofill/credit_card_scanner_controller.cc",
- "autofill/credit_card_scanner_controller.h",
- "autofill/credit_card_scanner_view.cc",
- "autofill/credit_card_scanner_view.h",
- "autofill/credit_card_scanner_view_delegate.h",
+ "autofill/payments/autofill_dialog_models.cc",
+ "autofill/payments/autofill_dialog_models.h",
+ "autofill/payments/autofill_ui_util.cc",
+ "autofill/payments/autofill_ui_util.h",
+ "autofill/payments/create_card_unmask_prompt_view.h",
+ "autofill/payments/credit_card_scanner_controller.cc",
+ "autofill/payments/credit_card_scanner_controller.h",
+ "autofill/payments/credit_card_scanner_view.cc",
+ "autofill/payments/credit_card_scanner_view.h",
+ "autofill/payments/credit_card_scanner_view_delegate.h",
+ "autofill/payments/payments_ui_constants.h",
"autofill/popup_constants.h",
"autofill/popup_controller_common.cc",
"autofill/popup_controller_common.h",
"autofill/popup_view_common.cc",
"autofill/popup_view_common.h",
- "bloated_renderer/bloated_renderer_tab_helper.cc",
- "bloated_renderer/bloated_renderer_tab_helper.h",
"blocked_content/blocked_window_params.cc",
"blocked_content/blocked_window_params.h",
"blocked_content/list_item_position.cc",
@@ -83,8 +84,6 @@ jumbo_split_static_library("ui") {
"blocked_content/popup_tracker.h",
"blocked_content/safe_browsing_triggered_popup_blocker.cc",
"blocked_content/safe_browsing_triggered_popup_blocker.h",
- "blocked_content/scoped_visibility_tracker.cc",
- "blocked_content/scoped_visibility_tracker.h",
"blocked_content/tab_under_navigation_throttle.cc",
"blocked_content/tab_under_navigation_throttle.h",
"blocked_content/url_list_manager.cc",
@@ -209,6 +208,8 @@ jumbo_split_static_library("ui") {
"translate/translate_bubble_model_impl.h",
"translate/translate_bubble_view_state_transition.cc",
"translate/translate_bubble_view_state_transition.h",
+ "ui_features.cc",
+ "ui_features.h",
"uninstall_browser_prompt.h",
"view_ids.h",
"web_contents_sizer.h",
@@ -311,8 +312,8 @@ jumbo_split_static_library("ui") {
"webui/sync_internals_ui.h",
"webui/test_files_request_filter.cc",
"webui/test_files_request_filter.h",
- "webui/translate_internals/translate_internals_handler.cc",
- "webui/translate_internals/translate_internals_handler.h",
+ "webui/translate_internals/chrome_translate_internals_handler.cc",
+ "webui/translate_internals/chrome_translate_internals_handler.h",
"webui/translate_internals/translate_internals_ui.cc",
"webui/translate_internals/translate_internals_ui.h",
"webui/ukm/ukm_internals_ui.cc",
@@ -358,6 +359,7 @@ jumbo_split_static_library("ui") {
public_deps = [
"//components/dom_distiller/core",
"//components/sync",
+ "//components/sync:user_events",
"//components/translate/content/browser",
"//content/public/browser",
]
@@ -426,6 +428,7 @@ jumbo_split_static_library("ui") {
"//components/heap_profiling",
"//components/history/content/browser",
"//components/history/core/browser",
+ "//components/history/core/common",
"//components/image_fetcher/core",
"//components/infobars/core",
"//components/invalidation/impl",
@@ -482,6 +485,7 @@ jumbo_split_static_library("ui") {
"//components/sync_preferences",
"//components/sync_sessions",
"//components/tracing:startup_tracing",
+ "//components/translate/translate_internals",
"//components/ui_devtools",
"//components/ukm:ukm",
"//components/ukm/content",
@@ -507,11 +511,13 @@ jumbo_split_static_library("ui") {
"//device/base",
"//device/usb",
"//extensions/buildflags",
+ "//gpu/config",
"//media",
"//net:net",
"//ppapi/buildflags",
"//printing/buildflags",
"//rlz/buildflags",
+ "//services/device/public/cpp:device_features",
"//services/identity/public/cpp",
"//services/metrics/public/cpp:ukm_builders",
"//services/network/public/mojom",
@@ -604,8 +610,6 @@ jumbo_split_static_library("ui") {
"android/autofill/card_unmask_prompt_view_android.h",
"android/autofill/credit_card_scanner_view_android.cc",
"android/autofill/credit_card_scanner_view_android.h",
- "android/autofill/password_generation_popup_view_android.cc",
- "android/autofill/password_generation_popup_view_android.h",
"android/bluetooth_chooser_android.cc",
"android/bluetooth_chooser_android.h",
"android/chrome_http_auth_handler.cc",
@@ -687,6 +691,12 @@ jumbo_split_static_library("ui") {
"android/page_info/connection_info_popup_android.h",
"android/page_info/page_info_controller_android.cc",
"android/page_info/page_info_controller_android.h",
+ "android/passwords/manual_filling_view_android.cc",
+ "android/passwords/manual_filling_view_android.h",
+ "android/passwords/password_generation_dialog_view_android.cc",
+ "android/passwords/password_generation_dialog_view_android.h",
+ "android/passwords/password_generation_editing_popup_view_android.cc",
+ "android/passwords/password_generation_editing_popup_view_android.h",
"android/simple_message_box_android.cc",
"android/snackbars/auto_signin_prompt_controller.cc",
"android/snackbars/auto_signin_prompt_controller.h",
@@ -1043,16 +1053,25 @@ jumbo_split_static_library("ui") {
"tabs/tab_strip_model_order_controller.h",
"tabs/tab_strip_model_stats_recorder.cc",
"tabs/tab_strip_model_stats_recorder.h",
+ "tabs/tab_style.cc",
+ "tabs/tab_style.h",
"tabs/tab_switch_event_latency_recorder.cc",
"tabs/tab_switch_event_latency_recorder.h",
"tabs/tab_utils.cc",
"tabs/tab_utils.h",
- "tabs/window_activity_watcher.cc",
- "tabs/window_activity_watcher.h",
"task_manager/task_manager_columns.cc",
"task_manager/task_manager_columns.h",
"task_manager/task_manager_table_model.cc",
"task_manager/task_manager_table_model.h",
+ "thumbnails/thumbnail_image.cc",
+ "thumbnails/thumbnail_image.h",
+ "thumbnails/thumbnail_page_event_adapter.cc",
+ "thumbnails/thumbnail_page_event_adapter.h",
+ "thumbnails/thumbnail_page_observer.h",
+ "thumbnails/thumbnail_tab_helper.cc",
+ "thumbnails/thumbnail_tab_helper.h",
+ "thumbnails/thumbnail_utils.cc",
+ "thumbnails/thumbnail_utils.h",
"toolbar/app_menu_icon_controller.cc",
"toolbar/app_menu_icon_controller.h",
"toolbar/app_menu_model.cc",
@@ -1080,6 +1099,10 @@ jumbo_split_static_library("ui") {
"uma_browsing_activity_observer.h",
"unload_controller.cc",
"unload_controller.h",
+ "views/intent_picker_bubble_view.cc",
+ "views/intent_picker_bubble_view.h",
+ "views/location_bar/intent_picker_view.cc",
+ "views/location_bar/intent_picker_view.h",
"webui/app_launcher_login_handler.cc",
"webui/app_launcher_login_handler.h",
"webui/app_management/app_management_page_handler.cc",
@@ -1192,10 +1215,6 @@ jumbo_split_static_library("ui") {
"webui/settings/font_handler.h",
"webui/settings/languages_handler.cc",
"webui/settings/languages_handler.h",
- "webui/settings/md_settings_localized_strings_provider.cc",
- "webui/settings/md_settings_localized_strings_provider.h",
- "webui/settings/md_settings_ui.cc",
- "webui/settings/md_settings_ui.h",
"webui/settings/metrics_reporting_handler.cc",
"webui/settings/metrics_reporting_handler.h",
"webui/settings/on_startup_handler.cc",
@@ -1216,12 +1235,18 @@ jumbo_split_static_library("ui") {
"webui/settings/settings_cookies_view_handler.h",
"webui/settings/settings_import_data_handler.cc",
"webui/settings/settings_import_data_handler.h",
+ "webui/settings/settings_localized_strings_provider.cc",
+ "webui/settings/settings_localized_strings_provider.h",
"webui/settings/settings_media_devices_selection_handler.cc",
"webui/settings/settings_media_devices_selection_handler.h",
"webui/settings/settings_page_ui_handler.cc",
"webui/settings/settings_page_ui_handler.h",
+ "webui/settings/settings_security_key_handler.cc",
+ "webui/settings/settings_security_key_handler.h",
"webui/settings/settings_startup_pages_handler.cc",
"webui/settings/settings_startup_pages_handler.h",
+ "webui/settings/settings_ui.cc",
+ "webui/settings/settings_ui.h",
"webui/settings/site_settings_handler.cc",
"webui/settings/site_settings_handler.h",
"webui/settings_utils.cc",
@@ -1264,9 +1289,11 @@ jumbo_split_static_library("ui") {
"//chrome/browser/profile_resetter:profile_reset_report_proto",
"//chrome/browser/resource_coordinator:tab_metrics_event_proto",
"//chrome/browser/resource_coordinator/tab_ranker",
+ "//chrome/browser/safe_browsing:advanced_protection",
"//chrome/browser/ui/webui/app_management:mojo_bindings",
"//chrome/common:buildflags",
"//chrome/common:search_mojom",
+ "//chrome/services/app_service/public/cpp:app_service_proxy",
"//chrome/services/app_service/public/cpp:app_update",
"//chrome/services/app_service/public/mojom",
"//components/feedback/proto",
@@ -1278,7 +1305,7 @@ jumbo_split_static_library("ui") {
"//components/web_modal",
"//components/zoom",
"//device/bluetooth",
- "//services/device/public/cpp:device_features",
+ "//device/fido",
"//services/device/public/mojom",
"//services/identity/public/cpp",
"//services/metrics/public/cpp:metrics_cpp",
@@ -1291,6 +1318,10 @@ jumbo_split_static_library("ui") {
deps += [ "//ui/ozone" ]
}
+ if (is_linux && !is_chromeos) {
+ deps += [ "//ui/base/ime/linux" ]
+ }
+
if (!toolkit_views) {
sources += [ "media_router/cloud_services_dialog.cc" ]
}
@@ -1491,10 +1522,6 @@ jumbo_split_static_library("ui") {
"views/frame/top_controls_slide_controller_chromeos.h",
"views/ime_driver/input_method_bridge_chromeos.cc",
"views/ime_driver/input_method_bridge_chromeos.h",
- "views/intent_picker_bubble_view.cc",
- "views/intent_picker_bubble_view.h",
- "views/location_bar/intent_picker_view.cc",
- "views/location_bar/intent_picker_view.h",
"views/platform_keys_certificate_selector_chromeos.cc",
"views/platform_keys_certificate_selector_chromeos.h",
"views/profiles/profile_indicator_icon.cc",
@@ -1525,6 +1552,16 @@ jumbo_split_static_library("ui") {
"webui/chromeos/bluetooth_dialog_localized_strings_provider.h",
"webui/chromeos/bluetooth_pairing_dialog.cc",
"webui/chromeos/bluetooth_pairing_dialog.h",
+ "webui/chromeos/cellular_setup/cellular_setup_dialog.cc",
+ "webui/chromeos/cellular_setup/cellular_setup_dialog.h",
+ "webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc",
+ "webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h",
+ "webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc",
+ "webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h",
+ "webui/chromeos/cellular_setup/mobile_setup_dialog.cc",
+ "webui/chromeos/cellular_setup/mobile_setup_dialog.h",
+ "webui/chromeos/cellular_setup/mobile_setup_ui.cc",
+ "webui/chromeos/cellular_setup/mobile_setup_ui.h",
"webui/chromeos/certificate_manager_dialog_ui.cc",
"webui/chromeos/certificate_manager_dialog_ui.h",
"webui/chromeos/cryptohome_ui.cc",
@@ -1541,6 +1578,10 @@ jumbo_split_static_library("ui") {
"webui/chromeos/first_run/first_run_ui.h",
"webui/chromeos/image_source.cc",
"webui/chromeos/image_source.h",
+ "webui/chromeos/insession_password_change_handler_chromeos.cc",
+ "webui/chromeos/insession_password_change_handler_chromeos.h",
+ "webui/chromeos/insession_password_change_ui.cc",
+ "webui/chromeos/insession_password_change_ui.h",
"webui/chromeos/internet_config_dialog.cc",
"webui/chromeos/internet_config_dialog.h",
"webui/chromeos/internet_detail_dialog.cc",
@@ -1610,8 +1651,8 @@ jumbo_split_static_library("ui") {
"webui/chromeos/login/gaia_screen_handler.h",
"webui/chromeos/login/hid_detection_screen_handler.cc",
"webui/chromeos/login/hid_detection_screen_handler.h",
- "webui/chromeos/login/kiosk_app_menu_handler.cc",
- "webui/chromeos/login/kiosk_app_menu_handler.h",
+ "webui/chromeos/login/js_calls_container.cc",
+ "webui/chromeos/login/js_calls_container.h",
"webui/chromeos/login/kiosk_autolaunch_screen_handler.cc",
"webui/chromeos/login/kiosk_autolaunch_screen_handler.h",
"webui/chromeos/login/kiosk_enable_screen_handler.cc",
@@ -1651,16 +1692,10 @@ jumbo_split_static_library("ui") {
"webui/chromeos/login/update_screen_handler.h",
"webui/chromeos/login/user_board_screen_handler.cc",
"webui/chromeos/login/user_board_screen_handler.h",
- "webui/chromeos/login/user_image_screen_handler.cc",
- "webui/chromeos/login/user_image_screen_handler.h",
"webui/chromeos/login/welcome_screen_handler.cc",
"webui/chromeos/login/welcome_screen_handler.h",
"webui/chromeos/login/wrong_hwid_screen_handler.cc",
"webui/chromeos/login/wrong_hwid_screen_handler.h",
- "webui/chromeos/mobile_setup_dialog.cc",
- "webui/chromeos/mobile_setup_dialog.h",
- "webui/chromeos/mobile_setup_ui.cc",
- "webui/chromeos/mobile_setup_ui.h",
"webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc",
"webui/chromeos/multidevice_setup/multidevice_setup_dialog.h",
"webui/chromeos/multidevice_setup/multidevice_setup_handler.cc",
@@ -1735,12 +1770,16 @@ jumbo_split_static_library("ui") {
"webui/settings/chromeos/internet_handler.h",
"webui/settings/chromeos/multidevice_handler.cc",
"webui/settings/chromeos/multidevice_handler.h",
+ "webui/settings/chromeos/os_settings_ui.cc",
+ "webui/settings/chromeos/os_settings_ui.h",
"webui/settings/tts_handler.cc",
"webui/settings/tts_handler.h",
"webui/signin/inline_login_handler_chromeos.cc",
"webui/signin/inline_login_handler_chromeos.h",
"webui/signin/inline_login_handler_dialog_chromeos.cc",
"webui/signin/inline_login_handler_dialog_chromeos.h",
+ "webui/signin/inline_login_handler_modal_delegate.cc",
+ "webui/signin/inline_login_handler_modal_delegate.h",
"webui/version_handler_chromeos.cc",
"webui/version_handler_chromeos.h",
"window_sizer/window_sizer_ash.cc",
@@ -1753,16 +1792,23 @@ jumbo_split_static_library("ui") {
"//ash/public/cpp/resources:ash_public_unscaled_resources",
"//ash/public/cpp/vector_icons",
"//chrome/browser/chromeos",
+ "//chromeos",
"//chromeos/assistant:buildflags",
"//chromeos/audio",
+ "//chromeos/components/account_manager",
"//chromeos/components/multidevice",
"//chromeos/components/multidevice/debug_webui",
"//chromeos/components/multidevice/logging",
"//chromeos/components/proximity_auth",
"//chromeos/components/tether",
+ "//chromeos/constants",
"//chromeos/cryptohome",
"//chromeos/dbus",
- "//chromeos/dbus:cryptohome_proto",
+ "//chromeos/dbus/audio",
+ "//chromeos/dbus/cryptohome",
+ "//chromeos/dbus/cryptohome:cryptohome_proto",
+ "//chromeos/dbus/power",
+ "//chromeos/dbus/session_manager",
"//chromeos/dbus/system_clock",
"//chromeos/login/auth",
"//chromeos/login/login_state",
@@ -1778,6 +1824,7 @@ jumbo_split_static_library("ui") {
"//chromeos/services/multidevice_setup/public/mojom",
"//chromeos/settings",
"//chromeos/strings",
+ "//chromeos/system",
"//components/arc",
"//components/captive_portal",
"//components/consent_auditor:consent_auditor",
@@ -1792,7 +1839,7 @@ jumbo_split_static_library("ui") {
"//services/device/public/mojom",
"//services/ws/public/cpp",
"//services/ws/public/mojom",
- "//ui/base/ime",
+ "//ui/base/ime/chromeos",
"//ui/chromeos",
"//ui/chromeos/events",
"//ui/compositor_extra",
@@ -1823,6 +1870,10 @@ jumbo_split_static_library("ui") {
"views/close_bubble_on_tab_activation_helper.h",
"views/hats/hats_bubble_view.cc",
"views/hats/hats_bubble_view.h",
+ "views/profiles/incognito_menu_view.cc",
+ "views/profiles/incognito_menu_view.h",
+ "views/profiles/profile_menu_view_base.cc",
+ "views/profiles/profile_menu_view_base.h",
"webui/discards/discards_ui.cc",
"webui/discards/discards_ui.h",
"webui/signin/inline_login_handler.cc",
@@ -1865,8 +1916,6 @@ jumbo_split_static_library("ui") {
"views/profiles/dice_accounts_menu.h",
"views/profiles/profile_chooser_view.cc",
"views/profiles/profile_chooser_view.h",
- "views/profiles/profile_menu_view_base.cc",
- "views/profiles/profile_menu_view_base.h",
"views/profiles/signin_view_controller_delegate_views.cc",
"views/profiles/signin_view_controller_delegate_views.h",
"views/profiles/user_manager_view.cc",
@@ -1885,8 +1934,6 @@ jumbo_split_static_library("ui") {
"webui/settings/system_handler.h",
"webui/signin/inline_login_handler_impl.cc",
"webui/signin/inline_login_handler_impl.h",
- "webui/signin/md_user_manager_ui.cc",
- "webui/signin/md_user_manager_ui.h",
"webui/signin/signin_create_profile_handler.cc",
"webui/signin/signin_create_profile_handler.h",
"webui/signin/signin_email_confirmation_dialog.cc",
@@ -1907,16 +1954,14 @@ jumbo_split_static_library("ui") {
"webui/signin/sync_confirmation_ui.h",
"webui/signin/user_manager_screen_handler.cc",
"webui/signin/user_manager_screen_handler.h",
+ "webui/signin/user_manager_ui.cc",
+ "webui/signin/user_manager_ui.h",
"webui/welcome/nux/bookmark_handler.cc",
"webui/welcome/nux/bookmark_handler.h",
"webui/welcome/nux/bookmark_item.cc",
"webui/welcome/nux/bookmark_item.h",
"webui/welcome/nux/constants.cc",
"webui/welcome/nux/constants.h",
- "webui/welcome/nux/email_handler.cc",
- "webui/welcome/nux/email_handler.h",
- "webui/welcome/nux/email_providers_list.cc",
- "webui/welcome/nux/email_providers_list.h",
"webui/welcome/nux/google_apps_handler.cc",
"webui/welcome/nux/google_apps_handler.h",
"webui/welcome/nux/ntp_background_fetcher.cc",
@@ -2068,14 +2113,6 @@ jumbo_split_static_library("ui") {
"cocoa/main_menu_builder.h",
"cocoa/main_menu_builder.mm",
"cocoa/main_menu_item.h",
- "cocoa/media_picker/desktop_media_picker_bridge.h",
- "cocoa/media_picker/desktop_media_picker_bridge.mm",
- "cocoa/media_picker/desktop_media_picker_cocoa.h",
- "cocoa/media_picker/desktop_media_picker_cocoa.mm",
- "cocoa/media_picker/desktop_media_picker_controller.h",
- "cocoa/media_picker/desktop_media_picker_controller.mm",
- "cocoa/media_picker/desktop_media_picker_item.h",
- "cocoa/media_picker/desktop_media_picker_item.mm",
"cocoa/native_window_tracker_cocoa.h",
"cocoa/native_window_tracker_cocoa.mm",
"cocoa/nsmenuitem_additions.h",
@@ -2110,8 +2147,6 @@ jumbo_split_static_library("ui") {
"cocoa/touchbar/credit_card_autofill_touch_bar_controller.mm",
"cocoa/touchbar/web_textfield_touch_bar_controller.h",
"cocoa/touchbar/web_textfield_touch_bar_controller.mm",
- "cocoa/ui_localizer.h",
- "cocoa/ui_localizer.mm",
"cocoa/window_size_autosaver.h",
"cocoa/window_size_autosaver.mm",
"views/apps/chrome_app_window_client_views_mac.mm",
@@ -2122,6 +2157,8 @@ jumbo_split_static_library("ui") {
"views/frame/browser_non_client_frame_view_factory_mac.mm",
"views/frame/browser_non_client_frame_view_mac.h",
"views/frame/browser_non_client_frame_view_mac.mm",
+ "views/frame/immersive_mode_controller_mac.h",
+ "views/frame/immersive_mode_controller_mac.mm",
"views/frame/native_browser_frame_factory_mac.mm",
"views/tab_contents/chrome_web_contents_view_delegate_views_mac.h",
"views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm",
@@ -2136,7 +2173,6 @@ jumbo_split_static_library("ui") {
allow_circular_includes_from += [ "//chrome/browser/apps/app_shim" ]
deps += [
- "//chrome/app/nibs:localizer_table",
"//chrome/browser/apps/app_shim",
"//extensions/components/native_app_window",
"//third_party/google_toolbox_for_mac",
@@ -2205,6 +2241,8 @@ jumbo_split_static_library("ui") {
"views/try_chrome_dialog_win/try_chrome_dialog.h",
"views/uninstall_view.cc",
"views/uninstall_view.h",
+ "webui/conflicts/conflicts_data_fetcher.cc",
+ "webui/conflicts/conflicts_data_fetcher.h",
"webui/conflicts/conflicts_handler.cc",
"webui/conflicts/conflicts_handler.h",
"webui/conflicts/conflicts_ui.cc",
@@ -2344,22 +2382,24 @@ jumbo_split_static_library("ui") {
if (toolkit_views) {
sources += [
- "autofill/local_card_migration_bubble.h",
- "autofill/local_card_migration_bubble_controller_impl.cc",
- "autofill/local_card_migration_bubble_controller_impl.h",
- "autofill/local_card_migration_controller_observer.h",
- "autofill/local_card_migration_dialog.h",
- "autofill/local_card_migration_dialog_controller_impl.cc",
- "autofill/local_card_migration_dialog_controller_impl.h",
- "autofill/local_card_migration_dialog_factory.h",
- "autofill/local_card_migration_dialog_state.h",
- "autofill/manage_migration_ui_controller.cc",
- "autofill/manage_migration_ui_controller.h",
- "autofill/save_card_bubble_controller_impl.cc",
- "autofill/save_card_bubble_controller_impl.h",
- "autofill/save_card_bubble_view.h",
- "autofill/save_card_ui.h",
+ "autofill/payments/local_card_migration_bubble.h",
+ "autofill/payments/local_card_migration_bubble_controller_impl.cc",
+ "autofill/payments/local_card_migration_bubble_controller_impl.h",
+ "autofill/payments/local_card_migration_controller_observer.h",
+ "autofill/payments/local_card_migration_dialog.h",
+ "autofill/payments/local_card_migration_dialog_controller_impl.cc",
+ "autofill/payments/local_card_migration_dialog_controller_impl.h",
+ "autofill/payments/local_card_migration_dialog_factory.h",
+ "autofill/payments/local_card_migration_dialog_state.h",
+ "autofill/payments/manage_migration_ui_controller.cc",
+ "autofill/payments/manage_migration_ui_controller.h",
+ "autofill/payments/save_card_bubble_controller_impl.cc",
+ "autofill/payments/save_card_bubble_controller_impl.h",
+ "autofill/payments/save_card_bubble_view.h",
+ "autofill/payments/save_card_ui.h",
"bubble_anchor_util.h",
+ "manifest_web_app_browser_controller.cc",
+ "manifest_web_app_browser_controller.h",
# This test header is included because it contains forward declarations
# needed for "friend" statements for use in tests.
@@ -2388,28 +2428,31 @@ jumbo_split_static_library("ui") {
"views/autofill/autofill_popup_base_view.h",
"views/autofill/autofill_popup_view_native_views.cc",
"views/autofill/autofill_popup_view_native_views.h",
- "views/autofill/card_unmask_prompt_views.cc",
- "views/autofill/card_unmask_prompt_views.h",
- "views/autofill/local_card_migration_bubble_views.cc",
- "views/autofill/local_card_migration_bubble_views.h",
- "views/autofill/local_card_migration_dialog_view.cc",
- "views/autofill/local_card_migration_dialog_view.h",
- "views/autofill/local_card_migration_error_dialog_view.cc",
- "views/autofill/local_card_migration_error_dialog_view.h",
- "views/autofill/local_card_migration_icon_view.cc",
- "views/autofill/local_card_migration_icon_view.h",
- "views/autofill/migratable_card_view.cc",
- "views/autofill/migratable_card_view.h",
- "views/autofill/save_card_bubble_views.cc",
- "views/autofill/save_card_bubble_views.h",
- "views/autofill/save_card_icon_view.cc",
- "views/autofill/save_card_icon_view.h",
- "views/autofill/save_card_manage_cards_bubble_views.cc",
- "views/autofill/save_card_manage_cards_bubble_views.h",
- "views/autofill/save_card_offer_bubble_views.cc",
- "views/autofill/save_card_offer_bubble_views.h",
- "views/autofill/save_card_sign_in_promo_bubble_views.cc",
- "views/autofill/save_card_sign_in_promo_bubble_views.h",
+ "views/autofill/payments/card_unmask_prompt_views.cc",
+ "views/autofill/payments/card_unmask_prompt_views.h",
+ "views/autofill/payments/dialog_view_ids.h",
+ "views/autofill/payments/local_card_migration_bubble_views.cc",
+ "views/autofill/payments/local_card_migration_bubble_views.h",
+ "views/autofill/payments/local_card_migration_dialog_view.cc",
+ "views/autofill/payments/local_card_migration_dialog_view.h",
+ "views/autofill/payments/local_card_migration_error_dialog_view.cc",
+ "views/autofill/payments/local_card_migration_error_dialog_view.h",
+ "views/autofill/payments/local_card_migration_icon_view.cc",
+ "views/autofill/payments/local_card_migration_icon_view.h",
+ "views/autofill/payments/migratable_card_view.cc",
+ "views/autofill/payments/migratable_card_view.h",
+ "views/autofill/payments/payments_view_util.cc",
+ "views/autofill/payments/payments_view_util.h",
+ "views/autofill/payments/save_card_bubble_views.cc",
+ "views/autofill/payments/save_card_bubble_views.h",
+ "views/autofill/payments/save_card_icon_view.cc",
+ "views/autofill/payments/save_card_icon_view.h",
+ "views/autofill/payments/save_card_manage_cards_bubble_views.cc",
+ "views/autofill/payments/save_card_manage_cards_bubble_views.h",
+ "views/autofill/payments/save_card_offer_bubble_views.cc",
+ "views/autofill/payments/save_card_offer_bubble_views.h",
+ "views/autofill/payments/save_card_sign_in_promo_bubble_views.cc",
+ "views/autofill/payments/save_card_sign_in_promo_bubble_views.h",
"views/autofill/view_util.cc",
"views/autofill/view_util.h",
"views/bookmarks/bookmark_bar_view.cc",
@@ -2459,6 +2502,16 @@ jumbo_split_static_library("ui") {
"views/content_setting_domain_list_view.h",
"views/cookie_info_view.cc",
"views/cookie_info_view.h",
+ "views/desktop_capture/desktop_media_list_controller.cc",
+ "views/desktop_capture/desktop_media_list_controller.h",
+ "views/desktop_capture/desktop_media_list_view.cc",
+ "views/desktop_capture/desktop_media_list_view.h",
+ "views/desktop_capture/desktop_media_picker_views.cc",
+ "views/desktop_capture/desktop_media_picker_views.h",
+ "views/desktop_capture/desktop_media_source_view.cc",
+ "views/desktop_capture/desktop_media_source_view.h",
+ "views/desktop_capture/desktop_media_tab_list.cc",
+ "views/desktop_capture/desktop_media_tab_list.h",
"views/device_chooser_content_view.cc",
"views/device_chooser_content_view.h",
"views/download/download_danger_prompt_views.cc",
@@ -2490,10 +2543,22 @@ jumbo_split_static_library("ui") {
"views/extensions/extension_keybinding_registry_views.cc",
"views/extensions/extension_keybinding_registry_views.h",
"views/extensions/extension_uninstall_dialog_view.cc",
- "views/extensions/pwa_confirmation_view.cc",
- "views/extensions/pwa_confirmation_view.h",
+ "views/extensions/extensions_menu_button.cc",
+ "views/extensions/extensions_menu_button.h",
+ "views/extensions/extensions_menu_view.cc",
+ "views/extensions/extensions_menu_view.h",
+ "views/extensions/extensions_toolbar_button.cc",
+ "views/extensions/extensions_toolbar_button.h",
+ "views/extensions/pwa_confirmation.cc",
+ "views/extensions/pwa_confirmation.h",
+ "views/extensions/pwa_confirmation_bubble_view.cc",
+ "views/extensions/pwa_confirmation_bubble_view.h",
+ "views/extensions/pwa_confirmation_dialog_view.cc",
+ "views/extensions/pwa_confirmation_dialog_view.h",
"views/extensions/web_app_info_image_source.cc",
"views/extensions/web_app_info_image_source.h",
+ "views/feature_promos/feature_promo_bubble_timeout.cc",
+ "views/feature_promos/feature_promo_bubble_timeout.h",
"views/feature_promos/feature_promo_bubble_view.cc",
"views/feature_promos/feature_promo_bubble_view.h",
"views/find_bar_host.cc",
@@ -2541,6 +2606,8 @@ jumbo_split_static_library("ui") {
"views/frame/system_menu_model_builder.h",
"views/frame/system_menu_model_delegate.cc",
"views/frame/system_menu_model_delegate.h",
+ "views/frame/tab_strip_region_view.cc",
+ "views/frame/tab_strip_region_view.h",
"views/frame/toolbar_button_provider.h",
"views/frame/top_container_view.cc",
"views/frame/top_container_view.h",
@@ -2664,8 +2731,8 @@ jumbo_split_static_library("ui") {
"views/overlay/skip_ad_label_button.h",
"views/overlay/track_image_button.cc",
"views/overlay/track_image_button.h",
- "views/page_action/page_action_icon_container_view.cc",
- "views/page_action/page_action_icon_container_view.h",
+ "views/page_action/omnibox_page_action_icon_container_view.cc",
+ "views/page_action/omnibox_page_action_icon_container_view.h",
"views/page_action/page_action_icon_view.cc",
"views/page_action/page_action_icon_view.h",
"views/page_action/pwa_install_view.cc",
@@ -2716,6 +2783,8 @@ jumbo_split_static_library("ui") {
"views/payments/error_message_view_controller.h",
"views/payments/order_summary_view_controller.cc",
"views/payments/order_summary_view_controller.h",
+ "views/payments/payment_handler_modal_dialog_manager_delegate.cc",
+ "views/payments/payment_handler_modal_dialog_manager_delegate.h",
"views/payments/payment_handler_web_flow_view_controller.cc",
"views/payments/payment_handler_web_flow_view_controller.h",
"views/payments/payment_method_view_controller.cc",
@@ -2812,13 +2881,15 @@ jumbo_split_static_library("ui") {
"views/tabs/tab_hover_card_bubble_view.h",
"views/tabs/tab_icon.cc",
"views/tabs/tab_icon.h",
+ "views/tabs/tab_renderer_data.cc",
+ "views/tabs/tab_renderer_data.h",
"views/tabs/tab_strip.cc",
"views/tabs/tab_strip.h",
"views/tabs/tab_strip_controller.h",
"views/tabs/tab_strip_layout.cc",
"views/tabs/tab_strip_layout.h",
- "views/tabs/tab_style.cc",
- "views/tabs/tab_style.h",
+ "views/tabs/tab_style_views.cc",
+ "views/tabs/tab_style_views.h",
"views/tabs/window_finder.h",
"views/task_manager_view.cc",
"views/task_manager_view.h",
@@ -2845,8 +2916,12 @@ jumbo_split_static_library("ui") {
"views/toolbar/toolbar_actions_bar_bubble_views.h",
"views/toolbar/toolbar_button.cc",
"views/toolbar/toolbar_button.h",
+ "views/toolbar/toolbar_icon_container_view.cc",
+ "views/toolbar/toolbar_icon_container_view.h",
"views/toolbar/toolbar_ink_drop_util.cc",
"views/toolbar/toolbar_ink_drop_util.h",
+ "views/toolbar/toolbar_page_action_icon_container_view.cc",
+ "views/toolbar/toolbar_page_action_icon_container_view.h",
"views/toolbar/toolbar_view.cc",
"views/toolbar/toolbar_view.h",
"views/touch_uma/touch_uma.cc",
@@ -2867,6 +2942,8 @@ jumbo_split_static_library("ui") {
"views/webauthn/authenticator_request_dialog_view.h",
"views/webauthn/authenticator_request_sheet_view.cc",
"views/webauthn/authenticator_request_sheet_view.h",
+ "views/webauthn/authenticator_select_account_sheet_view.cc",
+ "views/webauthn/authenticator_select_account_sheet_view.h",
"views/webauthn/authenticator_transport_selector_sheet_view.cc",
"views/webauthn/authenticator_transport_selector_sheet_view.h",
"views/webauthn/ble_device_selection_sheet_view.cc",
@@ -2879,6 +2956,8 @@ jumbo_split_static_library("ui") {
"views/webauthn/sheet_view_factory.h",
"views_mode_controller.cc",
"views_mode_controller.h",
+ "web_app_browser_controller.cc",
+ "web_app_browser_controller.h",
"webauthn/authenticator_request_sheet_model.h",
"webauthn/ble_device_hover_list_model.cc",
"webauthn/ble_device_hover_list_model.h",
@@ -2897,6 +2976,7 @@ jumbo_split_static_library("ui") {
"//components/constrained_window",
"//components/payments/content",
"//components/payments/core",
+ "//components/ui_devtools/views",
"//device/vr/buildflags:buildflags",
"//services/ws/public/cpp/input_devices",
"//ui/views:buildflags",
@@ -2976,7 +3056,6 @@ jumbo_split_static_library("ui") {
if (use_aura) {
deps += [
- "//components/ui_devtools/views",
"//services/ws/public/cpp",
"//services/ws/public/mojom",
]
@@ -3073,12 +3152,6 @@ jumbo_split_static_library("ui") {
"views/apps/shaped_app_window_targeter.h",
"views/color_chooser_aura.cc",
"views/color_chooser_aura.h",
- "views/desktop_capture/desktop_media_list_view.cc",
- "views/desktop_capture/desktop_media_list_view.h",
- "views/desktop_capture/desktop_media_picker_views.cc",
- "views/desktop_capture/desktop_media_picker_views.h",
- "views/desktop_capture/desktop_media_source_view.cc",
- "views/desktop_capture/desktop_media_source_view.h",
"views/dropdown_bar_host_aura.cc",
"views/frame/browser_non_client_frame_view_factory_chromeos.cc",
"views/ime/ime_window_frame_view.cc",
@@ -3303,10 +3376,6 @@ jumbo_split_static_library("ui") {
"app_list/page_break_app_item.h",
"app_list/page_break_constants.cc",
"app_list/page_break_constants.h",
- "app_list/plugin_vm/plugin_vm_app_item.cc",
- "app_list/plugin_vm/plugin_vm_app_item.h",
- "app_list/plugin_vm/plugin_vm_app_model_builder.cc",
- "app_list/plugin_vm/plugin_vm_app_model_builder.h",
"app_list/search/app_service_app_result.cc",
"app_list/search/app_service_app_result.h",
"app_list/search/arc_app_result.cc",
@@ -3366,7 +3435,10 @@ jumbo_split_static_library("ui") {
"views/plugin_vm/plugin_vm_launcher_view.cc",
"views/plugin_vm/plugin_vm_launcher_view.h",
]
- deps += [ "//chrome/services/app_service/public/cpp:app_update" ]
+ deps += [
+ "//chrome/services/app_service/public/cpp:app_update",
+ "//chrome/services/app_service/public/cpp:icon_loader",
+ ]
}
}
@@ -3480,12 +3552,18 @@ jumbo_split_static_library("ui") {
"views/extensions/media_galleries_dialog_views.h",
"views/extensions/media_gallery_checkbox_view.cc",
"views/extensions/media_gallery_checkbox_view.h",
+ "web_applications/system_web_app_ui_utils_chromeos.cc",
+ "web_applications/system_web_app_ui_utils_chromeos.h",
"web_applications/web_app_dialog_utils.cc",
"web_applications/web_app_dialog_utils.h",
"web_applications/web_app_metrics.cc",
"web_applications/web_app_metrics.h",
"web_applications/web_app_metrics_factory.cc",
"web_applications/web_app_metrics_factory.h",
+ "web_applications/web_app_ui_delegate_impl.cc",
+ "web_applications/web_app_ui_delegate_impl.h",
+ "web_applications/web_app_ui_delegate_impl_factory.cc",
+ "web_applications/web_app_ui_delegate_impl_factory.h",
"webui/extensions/extension_basic_info.cc",
"webui/extensions/extension_basic_info.h",
"webui/extensions/extension_icon_source.cc",
@@ -3496,11 +3574,7 @@ jumbo_split_static_library("ui") {
deps += [ "//apps/ui/views" ]
}
if (use_aura) {
- sources += [
- "views/chrome_javascript_native_dialog_factory_views.cc",
- "views/extensions/extension_popup_aura.cc",
- "views/extensions/extension_popup_aura.h",
- ]
+ sources += [ "views/chrome_javascript_native_dialog_factory_views.cc" ]
deps += [ "//ui/wm/public" ]
}
}
diff --git a/chromium/chrome/browser/ui/libgtkui/BUILD.gn b/chromium/chrome/browser/ui/libgtkui/BUILD.gn
index 407f90ce6b2..ced5ef6d9e7 100644
--- a/chromium/chrome/browser/ui/libgtkui/BUILD.gn
+++ b/chromium/chrome/browser/ui/libgtkui/BUILD.gn
@@ -106,6 +106,7 @@ jumbo_component("libgtkui") {
"//ui/aura",
"//ui/base",
"//ui/base/ime",
+ "//ui/base/ime/linux",
"//ui/display",
"//ui/events",
"//ui/events:dom_keyboard_layout",
diff --git a/chromium/chrome/browser/ui/views/BUILD.gn b/chromium/chrome/browser/ui/views/BUILD.gn
index 07f24ef87e2..9e4f35b6eb3 100644
--- a/chromium/chrome/browser/ui/views/BUILD.gn
+++ b/chromium/chrome/browser/ui/views/BUILD.gn
@@ -16,8 +16,6 @@ component("views") {
"event_utils.cc",
"event_utils.h",
"tab_icon_view_model.h",
- "tabs/tab_renderer_data.cc",
- "tabs/tab_renderer_data.h",
"tabs/tab_strip_observer.cc",
"tabs/tab_strip_observer.h",
"tabs/tab_strip_types.h",
diff --git a/chromium/chrome/browser/ui/webui/app_management/app_management.mojom b/chromium/chrome/browser/ui/webui/app_management/app_management.mojom
index 4053cde606d..cfad5cba531 100644
--- a/chromium/chrome/browser/ui/webui/app_management/app_management.mojom
+++ b/chromium/chrome/browser/ui/webui/app_management/app_management.mojom
@@ -61,9 +61,10 @@ interface Page {
// App Service. It should always match the AppPermission enum in
// app_permissions.mojom
enum ArcPermissionType {
- CAMERA,
- LOCATION,
- MICROPHONE,
+ CAMERA = 0,
+ LOCATION = 1,
+ MICROPHONE = 2,
+ NOTIFICATIONS = 3,
};
// This enum takes the important permission values from the
diff --git a/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc b/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
index 91ff9966323..1cbf7dfcef8 100644
--- a/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/app_management/app_management_page_handler.cc
@@ -9,10 +9,11 @@
#include "base/containers/flat_map.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/apps/app_service/app_service_proxy.h"
+#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/services/app_service/public/cpp/app_registry_cache.h"
+#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "chrome/services/app_service/public/mojom/types.mojom.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
@@ -48,7 +49,8 @@ AppManagementPageHandler::AppManagementPageHandler(
shelf_delegate_(this)
#endif
{
- apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_);
+ apps::AppServiceProxy* proxy =
+ apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito
@@ -62,7 +64,8 @@ AppManagementPageHandler::~AppManagementPageHandler() {}
void AppManagementPageHandler::OnPinnedChanged(const std::string& app_id,
bool pinned) {
- apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_);
+ apps::AppServiceProxy* proxy =
+ apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito
@@ -87,7 +90,8 @@ void AppManagementPageHandler::OnPinnedChanged(const std::string& app_id,
}
void AppManagementPageHandler::GetApps(GetAppsCallback callback) {
- apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_);
+ apps::AppServiceProxy* proxy =
+ apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito
@@ -136,7 +140,8 @@ void AppManagementPageHandler::SetPinned(const std::string& app_id,
void AppManagementPageHandler::SetPermission(
const std::string& app_id,
apps::mojom::PermissionPtr permission) {
- apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_);
+ apps::AppServiceProxy* proxy =
+ apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito
@@ -147,7 +152,8 @@ void AppManagementPageHandler::SetPermission(
}
void AppManagementPageHandler::Uninstall(const std::string& app_id) {
- apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_);
+ apps::AppServiceProxy* proxy =
+ apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito
@@ -158,7 +164,8 @@ void AppManagementPageHandler::Uninstall(const std::string& app_id) {
}
void AppManagementPageHandler::OpenNativeSettings(const std::string& app_id) {
- apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_);
+ apps::AppServiceProxy* proxy =
+ apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito
diff --git a/chromium/chrome/browser/ui/webui/app_management/app_management_ui.cc b/chromium/chrome/browser/ui/webui/app_management/app_management_ui.cc
index 2c9df00855e..b435f1b4290 100644
--- a/chromium/chrome/browser/ui/webui/app_management/app_management_ui.cc
+++ b/chromium/chrome/browser/ui/webui/app_management/app_management_ui.cc
@@ -26,7 +26,7 @@ namespace {
content::WebUIDataSource* CreateAppManagementUIHTMLSource(Profile* profile) {
content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIAppLauncherPageHost);
+ content::WebUIDataSource::Create(chrome::kChromeUIAppManagementHost);
source->AddLocalizedString("appListTitle", IDS_APP_MANAGEMENT_APP_LIST_TITLE);
source->AddLocalizedString("appNoPermission",
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc
index 307117aa58b..9c03d9fa3fe 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc
@@ -5,12 +5,19 @@
#include "chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h"
#include "base/bind.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
+#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
+#include "components/bookmarks/managed/managed_bookmark_service.h"
+#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "components/prefs/pref_service.h"
+#include "components/user_prefs/user_prefs.h"
BookmarksBrowserTest::BookmarksBrowserTest() {}
@@ -39,6 +46,48 @@ void BookmarksBrowserTest::SetCanEditBookmarks(bool canEdit) {
bookmarks::prefs::kEditBookmarksEnabled, canEdit);
}
+void BookmarksBrowserTest::SetupExtensionAPITest() {
+ // Add managed bookmarks.
+ Profile* profile = browser()->profile();
+ bookmarks::BookmarkModel* model =
+ BookmarkModelFactory::GetForBrowserContext(profile);
+ bookmarks::ManagedBookmarkService* managed =
+ ManagedBookmarkServiceFactory::GetForProfile(profile);
+ bookmarks::test::WaitForBookmarkModelToLoad(model);
+
+ base::ListValue list;
+ std::unique_ptr<base::DictionaryValue> node(new base::DictionaryValue());
+ node->SetString("name", "Managed Bookmark");
+ node->SetString("url", "http://www.chromium.org");
+ list.Append(std::move(node));
+ node.reset(new base::DictionaryValue());
+ node->SetString("name", "Managed Folder");
+ node->Set("children", std::make_unique<base::ListValue>());
+ list.Append(std::move(node));
+ profile->GetPrefs()->Set(bookmarks::prefs::kManagedBookmarks, list);
+ ASSERT_EQ(2, managed->managed_node()->child_count());
+}
+
+void BookmarksBrowserTest::SetupExtensionAPIEditDisabledTest() {
+ Profile* profile = browser()->profile();
+
+ // Provide some testing data here, since bookmark editing will be disabled
+ // within the extension.
+ bookmarks::BookmarkModel* model =
+ BookmarkModelFactory::GetForBrowserContext(profile);
+ bookmarks::test::WaitForBookmarkModelToLoad(model);
+ const bookmarks::BookmarkNode* bar = model->bookmark_bar_node();
+ const bookmarks::BookmarkNode* folder =
+ model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder"));
+ model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"),
+ GURL("http://aaa.example.com"));
+ model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"),
+ GURL("http://bbb.example.com"));
+
+ PrefService* prefs = user_prefs::UserPrefs::Get(profile);
+ prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false);
+}
+
void BookmarksBrowserTest::HandleSetIncognitoAvailability(
const base::ListValue* args) {
AllowJavascript();
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h
index d15170bba9c..fe2bc149a2e 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h
+++ b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h
@@ -17,6 +17,9 @@ class BookmarksBrowserTest : public WebUIBrowserTest,
void SetIncognitoAvailability(int availability);
void SetCanEditBookmarks(bool canEdit);
+ void SetupExtensionAPITest();
+ void SetupExtensionAPIEditDisabledTest();
+
private:
void HandleSetIncognitoAvailability(const base::ListValue* args);
void HandleSetCanEditBookmarks(const base::ListValue* args);
diff --git a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
index 0542e022aea..dd095e0a904 100644
--- a/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
+++ b/chromium/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
@@ -47,8 +47,8 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
// Build an Accelerator to describe undo shortcut
// NOTE: the undo shortcut is also defined in bookmarks/command_manager.js
- // TODO(b/893033): de-duplicate shortcut by moving all shortcut definitions
- // from JS to C++.
+ // TODO(crbug/893033): de-duplicate shortcut by moving all shortcut
+ // definitions from JS to C++.
ui::Accelerator undoAccelerator(ui::VKEY_Z, ui::EF_PLATFORM_ACCELERATOR);
source->AddString("undoDescription", l10n_util::GetStringFUTF16(
IDS_BOOKMARK_BAR_UNDO_DESCRIPTION,
@@ -122,10 +122,6 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
IDS_BOOKMARK_MANAGER_SEARCH_BUTTON);
AddLocalizedString(source, "sidebarAxLabel",
IDS_BOOKMARK_MANAGER_SIDEBAR_AX_LABEL);
- AddLocalizedString(source, "sidebarNodeCollapseAxLabel",
- IDS_BOOKMARK_MANAGER_SIDEBAR_NODE_COLLAPSE_AX_LABEL);
- AddLocalizedString(source, "sidebarNodeExpandAxLabel",
- IDS_BOOKMARK_MANAGER_SIDEBAR_NODE_EXPAND_AX_LABEL);
AddLocalizedString(source, "searchCleared", IDS_SEARCH_CLEARED);
AddLocalizedString(source, "searchResults", IDS_SEARCH_RESULTS);
AddLocalizedString(source, "saveEdit", IDS_SAVE);
@@ -197,9 +193,6 @@ content::WebUIDataSource* CreateBookmarksUIHTMLSource(Profile* profile) {
source->AddResourcePath("store_client.html", IDR_BOOKMARKS_STORE_CLIENT_HTML);
source->AddResourcePath("store_client.js", IDR_BOOKMARKS_STORE_CLIENT_JS);
source->AddResourcePath("strings.html", IDR_BOOKMARKS_STRINGS_HTML);
- source->AddResourcePath("toast_manager.html",
- IDR_BOOKMARKS_TOAST_MANAGER_HTML);
- source->AddResourcePath("toast_manager.js", IDR_BOOKMARKS_TOAST_MANAGER_JS);
source->AddResourcePath("toolbar.html", IDR_BOOKMARKS_TOOLBAR_HTML);
source->AddResourcePath("toolbar.js", IDR_BOOKMARKS_TOOLBAR_JS);
source->AddResourcePath("util.html", IDR_BOOKMARKS_UTIL_HTML);
diff --git a/chromium/chrome/browser/ui/webui/browser_switcher/OWNERS b/chromium/chrome/browser/ui/webui/browser_switcher/OWNERS
index 3bfa6d85787..02916cd005d 100644
--- a/chromium/chrome/browser/ui/webui/browser_switcher/OWNERS
+++ b/chromium/chrome/browser/ui/webui/browser_switcher/OWNERS
@@ -1,2 +1,4 @@
pastarmovj@chromium.org
nicolaso@chromium.org
+
+# COMPONENT: Enterprise>BrowserSwitcher
diff --git a/chromium/chrome/browser/ui/webui/browser_switcher/browser_switch_ui.cc b/chromium/chrome/browser/ui/webui/browser_switcher/browser_switch_ui.cc
index 9f5fd6a0119..55116062ce6 100644
--- a/chromium/chrome/browser/ui/webui/browser_switcher/browser_switch_ui.cc
+++ b/chromium/chrome/browser/ui/webui/browser_switcher/browser_switch_ui.cc
@@ -29,6 +29,7 @@
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
@@ -71,16 +72,38 @@ content::WebUIDataSource* CreateBrowserSwitchUIHTMLSource(
auto* service = GetBrowserSwitcherService(web_ui);
source->AddInteger("launchDelay", service->prefs().GetDelay());
- source->AddLocalizedString("countdownTitle",
- IDS_ABOUT_BROWSER_SWITCH_COUNTDOWN_TITLE);
- source->AddLocalizedString("description",
- IDS_ABOUT_BROWSER_SWITCH_DESCRIPTION);
- source->AddLocalizedString("errorTitle",
- IDS_ABOUT_BROWSER_SWITCH_ERROR_TITLE);
- source->AddLocalizedString("genericError",
- IDS_ABOUT_BROWSER_SWITCH_GENERIC_ERROR);
- source->AddLocalizedString("openingTitle",
- IDS_ABOUT_BROWSER_SWITCH_OPENING_TITLE);
+ std::string browser_name = service->driver()->GetBrowserName();
+ source->AddString("browserName", browser_name);
+
+ if (browser_name.empty()) {
+ // Browser name could not be auto-detected. Say "alternative browser"
+ // instead of naming the browser.
+ source->AddLocalizedString(
+ "countdownTitle",
+ IDS_ABOUT_BROWSER_SWITCH_COUNTDOWN_TITLE_UNKNOWN_BROWSER);
+ source->AddLocalizedString(
+ "description", IDS_ABOUT_BROWSER_SWITCH_DESCRIPTION_UNKNOWN_BROWSER);
+ source->AddLocalizedString(
+ "errorTitle", IDS_ABOUT_BROWSER_SWITCH_ERROR_TITLE_UNKNOWN_BROWSER);
+ source->AddLocalizedString(
+ "genericError", IDS_ABOUT_BROWSER_SWITCH_GENERIC_ERROR_UNKNOWN_BROWSER);
+ source->AddLocalizedString(
+ "openingTitle", IDS_ABOUT_BROWSER_SWITCH_OPENING_TITLE_UNKNOWN_BROWSER);
+ } else {
+ // Browser name was auto-detected. Name it in the text.
+ source->AddLocalizedString(
+ "countdownTitle",
+ IDS_ABOUT_BROWSER_SWITCH_COUNTDOWN_TITLE_KNOWN_BROWSER);
+ source->AddLocalizedString(
+ "description", IDS_ABOUT_BROWSER_SWITCH_DESCRIPTION_KNOWN_BROWSER);
+ source->AddLocalizedString(
+ "errorTitle", IDS_ABOUT_BROWSER_SWITCH_ERROR_TITLE_KNOWN_BROWSER);
+ source->AddLocalizedString(
+ "genericError", IDS_ABOUT_BROWSER_SWITCH_GENERIC_ERROR_KNOWN_BROWSER);
+ source->AddLocalizedString(
+ "openingTitle", IDS_ABOUT_BROWSER_SWITCH_OPENING_TITLE_KNOWN_BROWSER);
+ }
+
source->AddLocalizedString("protocolError",
IDS_ABOUT_BROWSER_SWITCH_PROTOCOL_ERROR);
source->AddLocalizedString("title", IDS_ABOUT_BROWSER_SWITCH_TITLE);
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 14811cf7131..c89eb5b38bb 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
@@ -25,6 +25,7 @@
#include "chrome/browser/ui/webui/autofill_internals_ui.h"
#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h"
#include "chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.h"
+#include "chrome/browser/ui/webui/chromeos/insession_password_change_ui.h"
#include "chrome/browser/ui/webui/components_ui.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/browser/ui/webui/crashes_ui.h"
@@ -52,7 +53,7 @@
#include "chrome/browser/ui/webui/policy_ui.h"
#include "chrome/browser/ui/webui/predictors/predictors_ui.h"
#include "chrome/browser/ui/webui/quota_internals/quota_internals_ui.h"
-#include "chrome/browser/ui/webui/settings/md_settings_ui.h"
+#include "chrome/browser/ui/webui/settings/settings_ui.h"
#include "chrome/browser/ui/webui/settings_utils.h"
#include "chrome/browser/ui/webui/signin_internals_ui.h"
#include "chrome/browser/ui/webui/supervised_user_internals_ui.h"
@@ -66,6 +67,7 @@
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/webui_url_constants.h"
#include "components/dom_distiller/core/dom_distiller_constants.h"
#include "components/dom_distiller/core/dom_distiller_features.h"
#include "components/dom_distiller/core/dom_distiller_service.h"
@@ -149,6 +151,8 @@
#include "chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_ui.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h"
#include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.h"
#include "chrome/browser/ui/webui/chromeos/certificate_manager_dialog_ui.h"
#include "chrome/browser/ui/webui/chromeos/cryptohome_ui.h"
#include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
@@ -156,7 +160,6 @@
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
-#include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h"
#include "chrome/browser/ui/webui/chromeos/network_ui.h"
#include "chrome/browser/ui/webui/chromeos/power_ui.h"
@@ -166,6 +169,7 @@
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.h"
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.h"
#include "chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_ui.h"
+#include "chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h"
#include "chrome/browser/ui/webui/signin/inline_login_ui.h"
#include "chromeos/components/multidevice/debug_webui/proximity_auth_ui.h"
#include "chromeos/components/multidevice/debug_webui/url_constants.h"
@@ -185,10 +189,10 @@
#include "chrome/browser/ui/sync/sync_promo_ui.h"
#include "chrome/browser/ui/webui/browser_switcher/browser_switch_ui.h"
#include "chrome/browser/ui/webui/signin/inline_login_ui.h"
-#include "chrome/browser/ui/webui/signin/md_user_manager_ui.h"
#include "chrome/browser/ui/webui/signin/signin_email_confirmation_ui.h"
#include "chrome/browser/ui/webui/signin/signin_error_ui.h"
#include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h"
+#include "chrome/browser/ui/webui/signin/user_manager_ui.h"
#include "chrome/browser/ui/webui/welcome/welcome_ui.h"
#endif
@@ -226,10 +230,8 @@
#include "extensions/common/manifest.h"
#endif
-#if defined(SAFE_BROWSING_DB_LOCAL)
-#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
+#if defined(FULL_SAFE_BROWSING)
#include "chrome/browser/ui/webui/reset_password/reset_password_ui.h"
-#include "components/safe_browsing/features.h"
#endif
using content::WebUI;
@@ -428,7 +430,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
***************************************************************************/
#if !defined(OS_ANDROID)
if (AppManagementUI::IsEnabled() &&
- url.host_piece() == chrome::kChromeUIAppLauncherPageHost && profile &&
+ url.host_piece() == chrome::kChromeUIAppManagementHost && profile &&
!profile->IsGuestSession()) {
return &NewWebUI<AppManagementUI>;
}
@@ -449,6 +451,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
if (profile->IsGuestSession() &&
(url.host_piece() == chrome::kChromeUIAppLauncherPageHost ||
+ url.host_piece() == chrome::kChromeUIAppManagementHost ||
url.host_piece() == chrome::kChromeUIBookmarksHost ||
url.host_piece() == chrome::kChromeUIHistoryHost ||
url.host_piece() == chrome::kChromeUIExtensionsHost)) {
@@ -467,7 +470,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<NewTabUI>;
// Settings are implemented with native UI elements on Android.
if (url.host_piece() == chrome::kChromeUISettingsHost)
- return &NewWebUI<settings::MdSettingsUI>;
+ return &NewWebUI<settings::SettingsUI>;
if (url.host_piece() == chrome::kChromeUIExtensionsHost)
return &NewWebUI<extensions::ExtensionsUI>;
if (url.host_piece() == chrome::kChromeUIHistoryHost)
@@ -487,10 +490,19 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<SetAsDefaultBrowserUI>;
#endif
#if defined(OS_CHROMEOS)
+ if (url.host_piece() == chrome::kChromeUIPasswordChangeHost) {
+ if (!profile->GetPrefs()->GetBoolean(
+ prefs::kSamlInSessionPasswordChangeEnabled)) {
+ return nullptr;
+ }
+ return &NewWebUI<chromeos::InSessionPasswordChangeUI>;
+ }
if (url.host_piece() == chrome::kChromeUIAccountManagerWelcomeHost)
return &NewWebUI<chromeos::AccountManagerWelcomeUI>;
if (url.host_piece() == chrome::kChromeUIBluetoothPairingHost)
return &NewWebUI<chromeos::BluetoothPairingDialogUI>;
+ if (url.host_piece() == chrome::kChromeUICellularSetupHost)
+ return &NewWebUI<chromeos::cellular_setup::CellularSetupDialogUI>;
if (url.host_piece() == chrome::kChromeUICertificateManagerHost)
return &NewWebUI<chromeos::CertificateManagerDialogUI>;
if (url.host_piece() == chrome::kChromeUICryptohomeHost)
@@ -500,13 +512,15 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host_piece() == chrome::kChromeUIFirstRunHost)
return &NewWebUI<chromeos::FirstRunUI>;
if (url.host_piece() == chrome::kChromeUIMobileSetupHost)
- return &NewWebUI<chromeos::MobileSetupUI>;
+ return &NewWebUI<chromeos::cellular_setup::MobileSetupUI>;
if (url.host_piece() == chrome::kChromeUIMultiDeviceSetupHost)
return &NewWebUI<chromeos::multidevice_setup::MultiDeviceSetupDialogUI>;
if (url.host_piece() == chrome::kChromeUINetworkHost)
return &NewWebUI<chromeos::NetworkUI>;
if (url.host_piece() == chrome::kChromeUIOobeHost)
return &NewWebUI<chromeos::OobeUI>;
+ if (url.host_piece() == chrome::kChromeUIOSSettingsHost)
+ return &NewWebUI<chromeos::settings::OSSettingsUI>;
if (url.host_piece() == chrome::kChromeUIPowerHost)
return &NewWebUI<chromeos::PowerUI>;
if (url.host_piece() == chromeos::multidevice::kChromeUIProximityAuthHost)
@@ -579,7 +593,7 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
#endif // defined(OS_ANDROID)
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
if (url.host_piece() == chrome::kChromeUIMdUserManagerHost)
- return &NewWebUI<MDUserManagerUI>;
+ return &NewWebUI<UserManagerUI>;
if (url.host_piece() == chrome::kChromeUISigninErrorHost &&
(!profile->IsOffTheRecord() ||
profile->GetOriginalProfile()->IsSystemProfile()))
@@ -687,14 +701,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<MediaEngagementUI>;
}
-#if defined(SAFE_BROWSING_DB_LOCAL)
- bool enable_reset_password =
- base::FeatureList::IsEnabled(
- safe_browsing::kForceEnableResetPasswordWebUI) ||
- safe_browsing::ChromePasswordProtectionService::
- IsPasswordReuseProtectionConfigured(profile);
- if (url.host_piece() == chrome::kChromeUIResetPasswordHost &&
- enable_reset_password) {
+#if defined(FULL_SAFE_BROWSING)
+ if (url.host_piece() == chrome::kChromeUIResetPasswordHost) {
return &NewWebUI<ResetPasswordUI>;
}
#endif
@@ -891,6 +899,10 @@ base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
if (page_url.host_piece() == chrome::kChromeUIManagementHost)
return ManagementUI::GetFaviconResourceBytes(scale_factor);
+ // Android doesn't use the App Management page.
+ if (page_url.host_piece() == chrome::kChromeUIAppManagementHost)
+ return settings_utils::GetFaviconResourceBytes(scale_factor);
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
if (page_url.host_piece() == chrome::kChromeUIExtensionsHost) {
return extensions::ExtensionsUI::GetFaviconResourceBytes(scale_factor);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/OWNERS
index 0c7e289e51e..d5176c55865 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/OWNERS
@@ -4,5 +4,5 @@ satorux@chromium.org
stevenjb@chromium.org
xiyuan@chromium.org
-per-file network*=stevenjb@chromium.org
+per-file network*=file://chromeos/network/OWNERS
per-file drive_internals_ui.*=file://ui/file_manager/OWNERS
diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc
index 5c276f89ff3..977f24ae326 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc
@@ -21,8 +21,8 @@ namespace chromeos {
namespace {
AccountManagerWelcomeDialog* g_dialog = nullptr;
-constexpr int kSigninDialogWidth = 600;
-constexpr int kSigninDialogHeight = 500;
+constexpr int kSigninDialogWidth = 768;
+constexpr int kSigninDialogHeight = 640;
constexpr int kMaxNumTimesShown = 1;
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.cc
index 10f0d45b755..22077439b60 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.cc
@@ -5,15 +5,24 @@
#include "chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.h"
#include "base/bind.h"
+#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h"
namespace chromeos {
+namespace {
+
+constexpr char kAccountManagerLearnMoreURL[] =
+ "https://support.google.com/chromebook/?p=google_accounts";
+
+} // namespace
+
AccountManagerWelcomeUI::AccountManagerWelcomeUI(content::WebUI* web_ui)
: ui::WebDialogUI(web_ui), weak_factory_(this) {
content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
@@ -28,8 +37,10 @@ AccountManagerWelcomeUI::AccountManagerWelcomeUI(content::WebUI* web_ui)
// Add localized strings.
html_source->AddLocalizedString("welcomeTitle",
IDS_ACCOUNT_MANAGER_WELCOME_TITLE);
- html_source->AddLocalizedString("welcomeMessage",
- IDS_ACCOUNT_MANAGER_WELCOME_TEXT);
+ html_source->AddString("welcomeMessage",
+ l10n_util::GetStringFUTF16(
+ IDS_ACCOUNT_MANAGER_WELCOME_TEXT,
+ base::ASCIIToUTF16(kAccountManagerLearnMoreURL)));
html_source->AddLocalizedString("okButton", IDS_APP_OK);
// Add required resources.
diff --git a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc
index 6aaa395f7a5..98c1e481487 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.cc
@@ -10,18 +10,39 @@
#include "ash/public/cpp/shell_window_ids.h"
#include "base/base64.h"
#include "base/bind.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/json/json_reader.h"
+#include "base/json/json_writer.h"
+#include "base/linux_util.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/process/process_iterator.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_tokenizer.h"
+#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/values.h"
+#include "chrome/browser/chromeos/arc/tracing/arc_graphics_jank_detector.h"
+#include "chrome/browser/chromeos/arc/tracing/arc_system_model.h"
+#include "chrome/browser/chromeos/arc/tracing/arc_system_stat_collector.h"
#include "chrome/browser/chromeos/arc/tracing/arc_tracing_graphics_model.h"
#include "chrome/browser/chromeos/arc/tracing/arc_tracing_model.h"
+#include "chrome/browser/chromeos/file_manager/path_util.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
+#include "components/arc/arc_prefs.h"
+#include "components/arc/arc_util.h"
#include "components/exo/shell_surface_util.h"
-#include "components/exo/wm_helper_chromeos.h"
+#include "components/exo/surface.h"
+#include "components/exo/wm_helper.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/tracing_controller.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/codec/png_codec.h"
+#include "ui/views/widget/widget.h"
namespace chromeos {
@@ -30,35 +51,280 @@ namespace {
constexpr char kKeyIcon[] = "icon";
constexpr char kKeyTitle[] = "title";
constexpr char kKeyTasks[] = "tasks";
-constexpr char kTaskIdPrefix[] = "org.chromium.arc.";
-// Scans for all ARC windows and and extracts the title and optionally icon.
-void CreateTaskMap(aura::Window* window, base::DictionaryValue* tasks) {
- if (!window->IsVisible())
+constexpr char kLastTracingModelName[] = "last_tracing_model.json";
+
+// Maximum interval to display.
+constexpr base::TimeDelta kMaxIntervalToDisplay =
+ base::TimeDelta::FromSecondsD(3.0);
+
+base::FilePath GetLastTracingModelPath(Profile* profile) {
+ DCHECK(profile);
+ return file_manager::util::GetDownloadsFolderForProfile(profile).AppendASCII(
+ kLastTracingModelName);
+}
+
+std::pair<base::Value, std::string> MaybeLoadLastGraphicsModel(
+ const base::FilePath& last_model_path) {
+ std::string json_content;
+ if (!base::ReadFileToString(last_model_path, &json_content))
+ return std::make_pair(base::Value(), std::string());
+
+ base::Optional<base::Value> model = base::JSONReader::Read(json_content);
+ if (!model || !model->is_dict())
+ return std::make_pair(base::Value(), "Failed to read last tracing model");
+
+ arc::ArcTracingGraphicsModel graphics_model;
+ base::DictionaryValue* dictionary = nullptr;
+ model->GetAsDictionary(&dictionary);
+ if (!graphics_model.LoadFromValue(*dictionary))
+ return std::make_pair(base::Value(), "Failed to load last tracing model");
+
+ return std::make_pair(std::move(*model), "Loaded last tracing model");
+}
+
+class ProcessFilterPassAll : public base::ProcessFilter {
+ public:
+ ProcessFilterPassAll() = default;
+ ~ProcessFilterPassAll() override = default;
+
+ // base::ProcessFilter:
+ bool Includes(const base::ProcessEntry& process) const override {
+ return true;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ProcessFilterPassAll);
+};
+
+// Reads name of thread from /proc/pid/task/tid/status.
+bool ReadNameFromStatus(pid_t pid, pid_t tid, std::string* out_name) {
+ std::string status;
+ if (!base::ReadFileToString(base::FilePath(base::StringPrintf(
+ "/proc/%d/task/%d/status", pid, tid)),
+ &status)) {
+ return false;
+ }
+ base::StringTokenizer tokenizer(status, "\n");
+ while (tokenizer.GetNext()) {
+ base::StringPiece value_str(tokenizer.token_piece());
+ if (!value_str.starts_with("Name:"))
+ continue;
+ std::vector<base::StringPiece> split_value_str = base::SplitStringPiece(
+ value_str, "\t", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
+ DCHECK_EQ(2U, split_value_str.size());
+ *out_name = split_value_str[1].as_string();
+ return true;
+ }
+
+ return false;
+}
+
+// Helper that clarifies thread and process names. Tracing events may not have
+// enough data for this. Also it determines the process pid the thread belongs
+// to.
+void UpdateThreads(arc::ArcSystemModel::ThreadMap* threads) {
+ ProcessFilterPassAll filter_pass_all;
+ base::ProcessIterator process_iterator(&filter_pass_all);
+
+ std::vector<pid_t> tids;
+ std::string name;
+ for (const auto& process : process_iterator.Snapshot()) {
+ tids.clear();
+ base::GetThreadsForProcess(process.pid(), &tids);
+ bool process_in_use = threads->find(process.pid()) != threads->end();
+ for (pid_t tid : tids) {
+ if (threads->find(tid) != threads->end()) {
+ process_in_use = true;
+ (*threads)[tid].pid = process.pid();
+ if (!ReadNameFromStatus(process.pid(), tid, &(*threads)[tid].name))
+ LOG(WARNING) << "Failed to update thread name " << tid;
+ }
+ }
+ if (process_in_use) {
+ (*threads)[process.pid()].pid = process.pid();
+ if (!ReadNameFromStatus(process.pid(), process.pid(),
+ &(*threads)[process.pid()].name)) {
+ LOG(WARNING) << "Failed to update process name " << process.pid();
+ }
+ }
+ }
+}
+
+std::pair<base::Value, std::string> BuildGraphicsModel(
+ const std::string& data,
+ base::DictionaryValue tasks_info,
+ std::unique_ptr<arc::ArcSystemStatCollector> system_stat_collector,
+ const base::TimeTicks& time_min,
+ const base::TimeTicks& time_max,
+ const base::FilePath& last_model_path) {
+ DCHECK(system_stat_collector);
+
+ arc::ArcTracingModel common_model;
+ const base::TimeTicks time_min_clamped =
+ std::max(time_min, time_max - kMaxIntervalToDisplay);
+ common_model.SetMinMaxTime(
+ (time_min_clamped - base::TimeTicks()).InMicroseconds(),
+ (time_max - base::TimeTicks()).InMicroseconds());
+
+ if (!common_model.Build(data))
+ return std::make_pair(base::Value(), "Failed to process tracing data");
+
+ system_stat_collector->Flush(time_min, time_max,
+ &common_model.system_model());
+
+ arc::ArcTracingGraphicsModel graphics_model;
+ if (!graphics_model.Build(common_model))
+ return std::make_pair(base::Value(), "Failed to build tracing model");
+
+ UpdateThreads(&graphics_model.system_model().thread_map());
+
+ std::unique_ptr<base::DictionaryValue> model = graphics_model.Serialize();
+ model->SetKey(kKeyTasks, std::move(tasks_info));
+
+ std::string json_content;
+ base::JSONWriter::WriteWithOptions(
+ *model, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_content);
+ DCHECK(!json_content.empty());
+
+ if (!base::WriteFile(last_model_path, json_content.c_str(),
+ json_content.length())) {
+ LOG(ERROR) << "Failed serialize model to " << last_model_path.value()
+ << ".";
+ }
+
+ return std::make_pair(std::move(*model), "Tracing model is ready");
+}
+
+std::pair<base::Value, std::string> LoadGraphicsModel(
+ const std::string& json_text) {
+ arc::ArcTracingGraphicsModel graphics_model;
+ if (!graphics_model.LoadFromJson(json_text))
+ return std::make_pair(base::Value(), "Failed to load tracing model");
+
+ std::unique_ptr<base::DictionaryValue> model = graphics_model.Serialize();
+ return std::make_pair(std::move(*model), "Tracing model is loaded");
+}
+
+} // namespace
+
+ArcGraphicsTracingHandler::ArcGraphicsTracingHandler()
+ : wm_helper_(exo::WMHelper::HasInstance() ? exo::WMHelper::GetInstance()
+ : nullptr),
+ weak_ptr_factory_(this) {
+ DCHECK(wm_helper_);
+
+ aura::Window* const current_active = wm_helper_->GetActiveWindow();
+ if (current_active) {
+ OnWindowActivated(ActivationReason::ACTIVATION_CLIENT /* not used */,
+ current_active, nullptr);
+ }
+ wm_helper_->AddActivationObserver(this);
+}
+
+ArcGraphicsTracingHandler::~ArcGraphicsTracingHandler() {
+ wm_helper_->RemoveActivationObserver(this);
+ DiscardActiveArcWindow();
+
+ if (tracing_active_)
+ StopTracing();
+}
+
+void ArcGraphicsTracingHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "ready", base::BindRepeating(&ArcGraphicsTracingHandler::HandleReady,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "setStopOnJank",
+ base::BindRepeating(&ArcGraphicsTracingHandler::HandleSetStopOnJank,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "loadFromText",
+ base::BindRepeating(&ArcGraphicsTracingHandler::HandleLoadFromText,
+ base::Unretained(this)));
+}
+
+void ArcGraphicsTracingHandler::OnWindowActivated(ActivationReason reason,
+ aura::Window* gained_active,
+ aura::Window* lost_active) {
+ // Handle ARC current active window if any.
+ DiscardActiveArcWindow();
+
+ if (!gained_active)
return;
- // ARC window is top level window, all its parents have type not set.
- if (window->type() == aura::client::WINDOW_TYPE_UNKNOWN) {
- for (aura::Window* child_window : window->children())
- CreateTaskMap(child_window, tasks);
+ active_task_id_ = arc::GetWindowTaskId(gained_active);
+ if (active_task_id_ <= 0)
return;
+
+ arc_active_window_ = gained_active;
+ arc_active_window_->AddObserver(this);
+ arc_active_window_->AddPreTargetHandler(this);
+
+ // Limit tracing by newly activated window.
+ tracing_time_min_ = TRACE_TIME_TICKS_NOW();
+ jank_detector_ =
+ std::make_unique<arc::ArcGraphicsJankDetector>(base::BindRepeating(
+ &ArcGraphicsTracingHandler::OnJankDetected, base::Unretained(this)));
+
+ UpdateActiveArcWindowInfo();
+
+ exo::Surface* const surface = exo::GetShellMainSurface(arc_active_window_);
+ DCHECK(surface);
+ surface->SetCommitCallback(base::BindRepeating(
+ &ArcGraphicsTracingHandler::OnCommit, weak_ptr_factory_.GetWeakPtr()));
+}
+
+void ArcGraphicsTracingHandler::OnCommit(exo::Surface* surface) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ jank_detector_->OnSample();
+}
+
+void ArcGraphicsTracingHandler::OnJankDetected(const base::Time& timestamp) {
+ VLOG(1) << "Jank detected " << timestamp;
+ if (tracing_active_ && stop_on_jank_) {
+ StopTracing();
+ Activate();
}
+}
- // Verifies if this is top-level ARC window.
- const std::string* arc_app_id = exo::GetShellApplicationId(window);
- if (!arc_app_id)
+void ArcGraphicsTracingHandler::OnWindowPropertyChanged(aura::Window* window,
+ const void* key,
+ intptr_t old) {
+ DCHECK_EQ(arc_active_window_, window);
+ if (key != aura::client::kAppIconKey)
return;
- // Root surface may not have task id.
- const size_t prefix_pos = arc_app_id->find(kTaskIdPrefix);
- if (prefix_pos)
+ UpdateActiveArcWindowInfo();
+}
+
+void ArcGraphicsTracingHandler::OnWindowDestroying(aura::Window* window) {
+ DCHECK_EQ(arc_active_window_, window);
+ DiscardActiveArcWindow();
+}
+
+void ArcGraphicsTracingHandler::OnKeyEvent(ui::KeyEvent* event) {
+ DCHECK(arc_active_window_);
+ if (event->type() != ui::ET_KEY_RELEASED || event->key_code() != ui::VKEY_G ||
+ !event->IsControlDown() || !event->IsShiftDown()) {
return;
+ }
+ if (tracing_active_) {
+ StopTracing();
+ Activate();
+ } else {
+ StartTracing();
+ }
+}
+void ArcGraphicsTracingHandler::UpdateActiveArcWindowInfo() {
+ DCHECK(arc_active_window_);
base::DictionaryValue task_information;
- task_information.SetKey(kKeyTitle, base::Value(window->GetTitle()));
+ task_information.SetKey(kKeyTitle,
+ base::Value(arc_active_window_->GetTitle()));
const gfx::ImageSkia* app_icon =
- window->GetProperty(aura::client::kAppIconKey);
+ arc_active_window_->GetProperty(aura::client::kAppIconKey);
if (app_icon) {
std::vector<unsigned char> png_data;
if (gfx::PNGCodec::EncodeBGRASkBitmap(
@@ -72,74 +338,91 @@ void CreateTaskMap(aura::Window* window, base::DictionaryValue* tasks) {
}
}
- tasks->SetKey(arc_app_id->c_str() + strlen(kTaskIdPrefix),
- std::move(task_information));
+ tasks_info_.SetKey(base::StringPrintf("%d", active_task_id_),
+ std::move(task_information));
}
-std::unique_ptr<base::Value> BuildGraphicsModel(const std::string& data) {
- arc::ArcTracingModel common_model;
- if (!common_model.Build(data)) {
- LOG(ERROR) << "Failed to build common model";
- return nullptr;
- }
-
- arc::ArcTracingGraphicsModel graphics_model;
- if (!graphics_model.Build(common_model)) {
- LOG(ERROR) << "Failed to build graphic buffers model";
- return nullptr;
- }
+void ArcGraphicsTracingHandler::DiscardActiveArcWindow() {
+ if (!arc_active_window_)
+ return;
- std::unique_ptr<base::DictionaryValue> model = graphics_model.Serialize();
- base::DictionaryValue tasks;
- // Scan for ARC++ windows
- // TODO(https://crbug.com/887156): Fix the mash.
- if (!features::IsMultiProcessMash()) {
- CreateTaskMap(
- exo::WMHelperChromeOS::GetInstance()->GetPrimaryDisplayContainer(
- ash::kShellWindowId_DefaultContainer),
- &tasks);
- }
- model->SetKey(kKeyTasks, std::move(tasks));
+ exo::Surface* const surface = exo::GetShellMainSurface(arc_active_window_);
+ DCHECK(surface);
+ surface->SetCommitCallback(exo::Surface::CommitCallback());
- return model;
+ arc_active_window_->RemovePreTargetHandler(this);
+ arc_active_window_->RemoveObserver(this);
+ jank_detector_.reset();
+ arc_active_window_ = nullptr;
}
-} // namespace
-
-ArcGraphicsTracingHandler::ArcGraphicsTracingHandler()
- : weak_ptr_factory_(this) {}
+void ArcGraphicsTracingHandler::Activate() {
+ aura::Window* const window =
+ web_ui()->GetWebContents()->GetTopLevelNativeWindow();
+ if (!window) {
+ LOG(ERROR) << "Failed to activate, no top level window.";
+ return;
+ }
-ArcGraphicsTracingHandler::~ArcGraphicsTracingHandler() = default;
+ views::Widget* const widget = views::Widget::GetWidgetForNativeWindow(window);
+ if (!widget) {
+ LOG(ERROR) << "Failed to activate, no widget for top level window.";
+ return;
+ }
-void ArcGraphicsTracingHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "startTracing",
- base::BindRepeating(&ArcGraphicsTracingHandler::HandleStartTracing,
- base::Unretained(this)));
+ widget->Activate();
}
-void ArcGraphicsTracingHandler::StartTracing(double duration) {
+void ArcGraphicsTracingHandler::StartTracing() {
+ SetStatus("Collecting samples...");
+
base::trace_event::TraceConfig config(
"-*,exo,viz,toplevel,gpu,cc,blink,disabled-by-default-android "
"gfx,disabled-by-default-android hal",
base::trace_event::RECORD_CONTINUOUSLY);
config.EnableSystrace();
+ tracing_active_ = true;
+ if (jank_detector_)
+ jank_detector_->Reset();
+ system_stat_colletor_ = std::make_unique<arc::ArcSystemStatCollector>();
+ system_stat_colletor_->Start(kMaxIntervalToDisplay);
content::TracingController::GetInstance()->StartTracing(
config, base::BindOnce(&ArcGraphicsTracingHandler::OnTracingStarted,
- weak_ptr_factory_.GetWeakPtr(), duration));
+ weak_ptr_factory_.GetWeakPtr()));
}
void ArcGraphicsTracingHandler::StopTracing() {
- content::TracingController::GetInstance()->StopTracing(
- content::TracingController::CreateStringEndpoint(
- base::BindRepeating(&ArcGraphicsTracingHandler::OnTracingStopped,
- weak_ptr_factory_.GetWeakPtr())));
+ SetStatus("Building model...");
+
+ tracing_active_ = false;
+
+ tracing_time_max_ = TRACE_TIME_TICKS_NOW();
+
+ if (system_stat_colletor_)
+ system_stat_colletor_->Stop();
+
+ content::TracingController* const controller =
+ content::TracingController::GetInstance();
+
+ if (!controller->IsTracing())
+ return;
+
+ controller->StopTracing(content::TracingController::CreateStringEndpoint(
+ base::BindRepeating(&ArcGraphicsTracingHandler::OnTracingStopped,
+ weak_ptr_factory_.GetWeakPtr())));
+}
+
+void ArcGraphicsTracingHandler::SetStatus(const std::string& status) {
+ AllowJavascript();
+ CallJavascriptFunction("cr.ArcGraphicsTracing.setStatus",
+ base::Value(status.empty() ? "Idle" : status));
}
-void ArcGraphicsTracingHandler::OnTracingStarted(double duration) {
- tracing_timer_.Start(FROM_HERE, base::TimeDelta::FromSecondsD(duration),
- base::BindOnce(&ArcGraphicsTracingHandler::StopTracing,
- base::Unretained(this)));
+void ArcGraphicsTracingHandler::OnTracingStarted() {
+ tasks_info_.Clear();
+ UpdateActiveArcWindowInfo();
+
+ tracing_time_min_ = TRACE_TIME_TICKS_NOW();
}
void ArcGraphicsTracingHandler::OnTracingStopped(
@@ -147,35 +430,60 @@ void ArcGraphicsTracingHandler::OnTracingStopped(
base::RefCountedString* trace_data) {
std::string string_data;
string_data.swap(trace_data->data());
-
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
- base::BindOnce(&BuildGraphicsModel, std::move(string_data)),
+ base::BindOnce(&BuildGraphicsModel, std::move(string_data),
+ std::move(tasks_info_), std::move(system_stat_colletor_),
+ tracing_time_min_, tracing_time_max_,
+ GetLastTracingModelPath(Profile::FromWebUI(web_ui()))),
base::BindOnce(&ArcGraphicsTracingHandler::OnGraphicsModelReady,
weak_ptr_factory_.GetWeakPtr()));
}
void ArcGraphicsTracingHandler::OnGraphicsModelReady(
- std::unique_ptr<base::Value> model) {
- if (!model)
+ std::pair<base::Value, std::string> result) {
+ SetStatus(result.second);
+
+ if (!result.first.is_dict())
return;
- AllowJavascript();
- CallJavascriptFunction("cr.ArcGraphicsTracing.setModel", *model);
+
+ CallJavascriptFunction("cr.ArcGraphicsTracing.setModel",
+ std::move(result.first));
+}
+
+void ArcGraphicsTracingHandler::HandleReady(const base::ListValue* args) {
+ base::PostTaskWithTraitsAndReplyWithResult(
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
+ base::BindOnce(&MaybeLoadLastGraphicsModel,
+ GetLastTracingModelPath(Profile::FromWebUI(web_ui()))),
+ base::BindOnce(&ArcGraphicsTracingHandler::OnGraphicsModelReady,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void ArcGraphicsTracingHandler::HandleSetStopOnJank(
+ const base::ListValue* args) {
+ DCHECK_EQ(1U, args->GetSize());
+ if (!args->GetList()[0].is_bool()) {
+ LOG(ERROR) << "Invalid input";
+ return;
+ }
+ stop_on_jank_ = args->GetList()[0].GetBool();
}
-void ArcGraphicsTracingHandler::HandleStartTracing(
+void ArcGraphicsTracingHandler::HandleLoadFromText(
const base::ListValue* args) {
- DCHECK_EQ(2U, args->GetSize());
- if ((!args->GetList()[0].is_double() && !args->GetList()[0].is_int()) ||
- (!args->GetList()[1].is_double() && !args->GetList()[1].is_int())) {
+ DCHECK_EQ(1U, args->GetSize());
+ if (!args->GetList()[0].is_string()) {
LOG(ERROR) << "Invalid input";
return;
}
- const double delay = args->GetList()[0].GetDouble();
- const double duration = args->GetList()[1].GetDouble();
- tracing_timer_.Start(FROM_HERE, base::TimeDelta::FromSecondsD(delay),
- base::BindOnce(&ArcGraphicsTracingHandler::StartTracing,
- base::Unretained(this), duration));
+
+ base::PostTaskWithTraitsAndReplyWithResult(
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
+ base::BindOnce(&LoadGraphicsModel,
+ std::move(args->GetList()[0].GetString())),
+ base::BindOnce(&ArcGraphicsTracingHandler::OnGraphicsModelReady,
+ weak_ptr_factory_.GetWeakPtr()));
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h
index 661a2cce01c..dc37db92a82 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/arc_graphics_tracing/arc_graphics_tracing_handler.h
@@ -5,22 +5,38 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ARC_GRAPHICS_TRACING_ARC_GRAPHICS_TRACING_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ARC_GRAPHICS_TRACING_ARC_GRAPHICS_TRACING_HANDLER_H_
+#include <map>
#include <memory>
#include <utility>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/timer/timer.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "ui/aura/window_observer.h"
+#include "ui/events/event_handler.h"
+#include "ui/wm/public/activation_change_observer.h"
+
+namespace arc {
+class ArcGraphicsJankDetector;
+class ArcSystemStatCollector;
+} // namespace arc
namespace base {
class ListValue;
class RefCountedString;
} // namespace base
+namespace exo {
+class Surface;
+class WMHelper;
+} // namespace exo
+
namespace chromeos {
-class ArcGraphicsTracingHandler : public content::WebUIMessageHandler {
+class ArcGraphicsTracingHandler : public content::WebUIMessageHandler,
+ public wm::ActivationChangeObserver,
+ public aura::WindowObserver,
+ public ui::EventHandler {
public:
ArcGraphicsTracingHandler();
~ArcGraphicsTracingHandler() override;
@@ -28,22 +44,77 @@ class ArcGraphicsTracingHandler : public content::WebUIMessageHandler {
// content::WebUIMessageHandler:
void RegisterMessages() override;
+ // wm::ActivationChangeObserver:
+ void OnWindowActivated(ActivationReason reason,
+ aura::Window* gained_active,
+ aura::Window* lost_active) override;
+
+ // aura::WindowObserver:
+ void OnWindowPropertyChanged(aura::Window* window,
+ const void* key,
+ intptr_t old) override;
+ void OnWindowDestroying(aura::Window* window) override;
+
+ // ui::EventHandler:
+ void OnKeyEvent(ui::KeyEvent* event) override;
+
private:
- void StartTracing(double duration);
+ void Activate();
+ void StartTracing();
void StopTracing();
+ void SetStatus(const std::string& status);
- void OnTracingStarted(double duration);
+ void OnTracingStarted();
void OnTracingStopped(std::unique_ptr<const base::DictionaryValue> metadata,
base::RefCountedString* trace_data);
- // Called when graphics model is built and ready.
- void OnGraphicsModelReady(std::unique_ptr<base::Value> model);
+ // Called when graphics model is built or load. Extra string parameter
+ // contains a status. In case model cannot be built/load empty |base::Value|
+ // is returned.
+ void OnGraphicsModelReady(std::pair<base::Value, std::string> result);
// Handlers for calls from JS.
- void HandleStartTracing(const base::ListValue* args);
+ void HandleReady(const base::ListValue* args);
+ void HandleSetStopOnJank(const base::ListValue* args);
+ void HandleLoadFromText(const base::ListValue* args);
+
+ // Updates title and icon for the active ARC window.
+ void UpdateActiveArcWindowInfo();
+
+ // Stops tracking ARC window for janks.
+ void DiscardActiveArcWindow();
+
+ // Called from exo::Surface on commit.
+ void OnCommit(exo::Surface* surface);
+
+ // Called in case jank is detected in active ARC window.
+ void OnJankDetected(const base::Time& timestamp);
+
+ // Indicates that tracing was initiated by this handler.
+ bool tracing_active_ = false;
+
+ // Determines if tracing should stop in case jank is detected runtime.
+ bool stop_on_jank_ = true;
+
+ exo::WMHelper* const wm_helper_;
+ aura::Window* arc_active_window_ = nullptr;
+
+ // Time filter for tracing, since ARC++ window was activated last until
+ // tracing is stopped.
+ base::TimeTicks tracing_time_min_;
+ base::TimeTicks tracing_time_max_;
+
+ // Task id for current ARC window.
+ int active_task_id_ = -1;
+
+ // Used to detect janks for the currently active ARC++ window.
+ std::unique_ptr<arc::ArcGraphicsJankDetector> jank_detector_;
+
+ // Collects system stat runtime.
+ std::unique_ptr<arc::ArcSystemStatCollector> system_stat_colletor_;
- // To implement start/stop tracing.
- base::OneShotTimer tracing_timer_;
+ // Information about tasks, title and icon.
+ base::DictionaryValue tasks_info_;
base::WeakPtrFactory<ArcGraphicsTracingHandler> weak_ptr_factory_;
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 e48715a0c66..95216bd990d 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
@@ -104,7 +104,7 @@ void AssistantOptInUI::OnDialogClosed() {
}
void AssistantOptInUI::Initialize() {
- js_calls_container_.ExecuteDeferredJSCalls();
+ js_calls_container_.ExecuteDeferredJSCalls(web_ui());
}
// AssistantOptInDialog
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc
index 787a7a56b8c..abc7950d9dd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.cc
@@ -14,11 +14,49 @@
#include "chromeos/services/assistant/public/features.h"
#include "components/arc/arc_prefs.h"
#include "components/consent_auditor/consent_auditor.h"
+#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
+namespace {
+
+bool IsPreferenceDefaultEnabled(const PrefService* prefs,
+ const std::string& path) {
+ const PrefService::Preference* pref = prefs->FindPreference(path);
+
+ if (pref->IsManaged())
+ return pref->GetValue()->GetBool();
+
+ if (pref->GetRecommendedValue())
+ return pref->GetRecommendedValue()->GetBool();
+
+ return true;
+}
+
+bool IsScreenContextDefaultEnabled(PrefService* prefs) {
+ return IsPreferenceDefaultEnabled(
+ prefs, arc::prefs::kVoiceInteractionContextEnabled);
+}
+
+bool IsScreenContextToggleDisabled(PrefService* prefs) {
+ return prefs->IsManagedPreference(
+ arc::prefs::kVoiceInteractionContextEnabled);
+}
+
+bool IsHotwordDefaultEnabled(PrefService* prefs) {
+ return IsPreferenceDefaultEnabled(
+ prefs, arc::prefs::kVoiceInteractionHotwordEnabled);
+}
+
+bool IsHotwordToggleDisabled(PrefService* prefs) {
+ return prefs->IsManagedPreference(
+ arc::prefs::kVoiceInteractionHotwordEnabled);
+}
+
+} // namespace
+
namespace chromeos {
void RecordAssistantOptInStatus(AssistantOptInFlowStatus status) {
@@ -106,11 +144,11 @@ 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) {
+ const assistant::EmailOptInUi& email_optin_ui,
+ PrefService* prefs) {
base::Value get_more_data(base::Value::Type::LIST);
- if (!base::FeatureList::IsEnabled(
- assistant::features::kAssistantVoiceMatch)) {
+ if (!IsVoiceMatchEnabled(prefs)) {
// Process hotword data.
base::Value hotword_data(base::Value::Type::DICTIONARY);
hotword_data.SetKey("id", base::Value("hotword"));
@@ -120,7 +158,10 @@ base::Value CreateGetMoreData(bool email_optin_needed,
hotword_data.SetKey(
"description",
base::Value(l10n_util::GetStringUTF16(IDS_ASSISTANT_HOTWORD_DESC)));
- hotword_data.SetKey("defaultEnabled", base::Value(true));
+ hotword_data.SetKey("defaultEnabled",
+ base::Value(IsHotwordDefaultEnabled(prefs)));
+ hotword_data.SetKey("toggleDisabled",
+ base::Value(IsHotwordToggleDisabled(prefs)));
hotword_data.SetKey(
"iconUri",
base::Value("https://www.gstatic.com/images/icons/material/system/"
@@ -135,7 +176,10 @@ base::Value CreateGetMoreData(bool email_optin_needed,
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("defaultEnabled",
+ base::Value(IsScreenContextDefaultEnabled(prefs)));
+ context_data.SetKey("toggleDisabled",
+ base::Value(IsScreenContextToggleDisabled(prefs)));
context_data.SetKey(
"iconUri",
base::Value("https://www.gstatic.com/images/icons/material/system/"
@@ -231,4 +275,16 @@ bool IsHotwordDspAvailable() {
return false;
}
+bool IsVoiceMatchEnabled(const PrefService* prefs) {
+ if (!base::FeatureList::IsEnabled(assistant::features::kAssistantVoiceMatch))
+ return false;
+
+ // If the hotword preference is managed, then we should not do Voice Match
+ // if the administrator has disabled the hotword.
+ if (prefs->IsManagedPreference(arc::prefs::kVoiceInteractionHotwordEnabled))
+ return prefs->GetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled);
+
+ return true;
+}
+
} // 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
index 67b5c7e1bb1..53d49d18dca 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h
@@ -7,12 +7,14 @@
#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"
+
+class PrefService;
+class Profile;
+
+namespace base {
+class Value;
+} // namespace base
namespace chromeos {
@@ -61,7 +63,8 @@ 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);
+ const assistant::EmailOptInUi& email_optin_ui,
+ PrefService* prefs);
// Get string constants for settings ui.
base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui,
@@ -73,6 +76,8 @@ void RecordActivityControlConsent(Profile* profile,
bool IsHotwordDspAvailable();
+bool IsVoiceMatchEnabled(const PrefService* prefs);
+
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_UTILS_H_
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 3dcc59bf70d..38cfba55fca 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
@@ -21,13 +21,14 @@ namespace chromeos {
namespace {
-constexpr int kBluetoothPairingDialogHeight = 350;
+constexpr int kBluetoothPairingDialogHeight = 375;
void AddBluetoothStrings(content::WebUIDataSource* html_source) {
struct {
const char* name;
int id;
} localized_strings[] = {
+ {"bluetoothPairDeviceTitle", IDS_SETTINGS_BLUETOOTH_PAIR_DEVICE_TITLE},
{"ok", IDS_OK},
{"cancel", IDS_CANCEL},
{"close", IDS_CLOSE},
@@ -68,9 +69,8 @@ BluetoothPairingDialog::BluetoothPairingDialog(
const base::string16& name_for_display,
bool paired,
bool connected)
- : SystemWebDialogDelegate(
- GURL(chrome::kChromeUIBluetoothPairingURL),
- l10n_util::GetStringUTF16(IDS_SETTINGS_BLUETOOTH_PAIR_DEVICE_TITLE)),
+ : SystemWebDialogDelegate(GURL(chrome::kChromeUIBluetoothPairingURL),
+ base::string16() /* title */),
address_(address) {
device_data_.SetString("address", address);
device_data_.SetString("name", name_for_display);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/OWNERS
new file mode 100644
index 00000000000..e26edaf5262
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/OWNERS
@@ -0,0 +1,2 @@
+khorimoto@chromium.org
+tbarzic@chromium.org
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc
new file mode 100644
index 00000000000..6dbe658c960
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.cc
@@ -0,0 +1,99 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser_dialogs.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/grit/cellular_setup_resources.h"
+#include "chrome/grit/cellular_setup_resources_map.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/aura/window.h"
+
+namespace chromeos {
+
+namespace cellular_setup {
+
+namespace {
+
+// TODO(azeemarshad): Determine the exact height and width of the dialog. The
+// current mocks are unclear, so these are just a guess.
+constexpr int kDialogHeightPx = 850;
+constexpr int kDialogWidthPx = 650;
+
+CellularSetupDialog* dialog_instance = nullptr;
+
+} // namespace
+
+// static
+void CellularSetupDialog::ShowDialog(const std::string& cellular_network_guid) {
+ if (dialog_instance) {
+ dialog_instance->dialog_window()->Focus();
+ return;
+ }
+
+ dialog_instance = new CellularSetupDialog();
+
+ // Note: chrome::ShowWebDialog() is used instead of
+ // dialog_instance->ShowSystemDialog() because it provides the dialog to
+ // ability to switch to full-screen in tablet mode.
+ chrome::ShowWebDialog(nullptr /* parent */,
+ ProfileManager::GetActiveUserProfile(),
+ dialog_instance);
+}
+
+CellularSetupDialog::CellularSetupDialog()
+ : SystemWebDialogDelegate(GURL(chrome::kChromeUICellularSetupUrl),
+ base::string16()) {}
+
+CellularSetupDialog::~CellularSetupDialog() = default;
+
+void CellularSetupDialog::GetDialogSize(gfx::Size* size) const {
+ size->SetSize(kDialogWidthPx, kDialogHeightPx);
+}
+
+bool CellularSetupDialog::CanResizeDialog() const {
+ return false;
+}
+
+void CellularSetupDialog::OnDialogClosed(const std::string& json_retval) {
+ DCHECK(this == dialog_instance);
+ dialog_instance = nullptr;
+
+ // Note: The call below deletes |this|, so there is no further need to keep
+ // track of the pointer.
+ SystemWebDialogDelegate::OnDialogClosed(json_retval);
+}
+
+CellularSetupDialogUI::CellularSetupDialogUI(content::WebUI* web_ui)
+ : ui::MojoWebDialogUI(web_ui) {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUICellularSetupHost);
+
+ chromeos::cellular_setup::AddLocalizedStrings(source);
+ source->SetJsonPath("strings.js");
+ source->SetDefaultResource(IDR_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_HTML);
+
+ // Note: The |kCellularSetupResourcesSize| and |kCellularSetupResources|
+ // fields are defined in the generated file
+ // chrome/grit/cellular_setup_resources_map.h.
+ for (size_t i = 0; i < kCellularSetupResourcesSize; ++i) {
+ source->AddResourcePath(kCellularSetupResources[i].name,
+ kCellularSetupResources[i].value);
+ }
+
+ content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
+
+ // TODO(khorimoto): Add Mojo bindings to this WebUI so that Mojo calls can
+ // occur in JavaScript.
+}
+
+CellularSetupDialogUI::~CellularSetupDialogUI() = default;
+
+} // namespace cellular_setup
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h
new file mode 100644
index 00000000000..164c12f02ce
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h
@@ -0,0 +1,48 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_H_
+
+#include "base/macros.h"
+#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+#include "ui/web_dialogs/web_dialog_ui.h"
+
+namespace chromeos {
+
+namespace cellular_setup {
+
+// Dialog which displays the cellular setup flow which allows users to
+// activate their un-activated SIM cards. This dialog is only used when the
+// kUpdatedCellularActivationUi flag is enabled; see go/cros-cellular-design.
+class CellularSetupDialog : public SystemWebDialogDelegate {
+ protected:
+ CellularSetupDialog();
+ ~CellularSetupDialog() override;
+
+ // ui::WebDialogDelegate
+ void GetDialogSize(gfx::Size* size) const override;
+ bool CanResizeDialog() const override;
+ void OnDialogClosed(const std::string& json_retval) override;
+
+ private:
+ friend void OpenCellularSetupDialog(const std::string& cellular_network_guid);
+ static void ShowDialog(const std::string& cellular_network_guid);
+
+ DISALLOW_COPY_AND_ASSIGN(CellularSetupDialog);
+};
+
+class CellularSetupDialogUI : public ui::MojoWebDialogUI {
+ public:
+ explicit CellularSetupDialogUI(content::WebUI* web_ui);
+ ~CellularSetupDialogUI() override;
+
+ DISALLOW_COPY_AND_ASSIGN(CellularSetupDialogUI);
+};
+
+} // namespace cellular_setup
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc
new file mode 100644
index 00000000000..a95ee83f973
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.cc
@@ -0,0 +1,27 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h"
+
+#include "base/feature_list.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h"
+#include "chromeos/constants/chromeos_features.h"
+
+namespace chromeos {
+
+namespace cellular_setup {
+
+void OpenCellularSetupDialog(const std::string& cellular_network_guid) {
+ if (base::FeatureList::IsEnabled(
+ chromeos::features::kUpdatedCellularActivationUi)) {
+ CellularSetupDialog::ShowDialog(cellular_network_guid);
+ } else {
+ MobileSetupDialog::ShowByNetworkId(cellular_network_guid);
+ }
+}
+
+} // namespace cellular_setup
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h
new file mode 100644
index 00000000000..e8477d8703f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h
@@ -0,0 +1,24 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_LAUNCHER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_LAUNCHER_H_
+
+#include <string>
+
+namespace chromeos {
+
+namespace cellular_setup {
+
+// Opens the cellular setup dialog for the cellular network with the provided
+// GUID; if the dialog is already open, this function focuses it. Note that this
+// function may open a different dialog depending on whether the
+// kUpdatedCellularActivationUi flag is enabled.
+void OpenCellularSetupDialog(const std::string& cellular_network_guid);
+
+} // namespace cellular_setup
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_DIALOG_LAUNCHER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc
new file mode 100644
index 00000000000..c8112a8f061
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.cc
@@ -0,0 +1,38 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h"
+
+#include "base/stl_util.h"
+#include "chrome/browser/ui/webui/localized_string.h"
+#include "components/login/localized_values_builder.h"
+#include "components/strings/grit/components_strings.h"
+#include "content/public/browser/web_ui_data_source.h"
+
+namespace chromeos {
+
+namespace cellular_setup {
+
+namespace {
+
+// TODO(azeemarshad): Add localized strings for cellular setup flow.
+constexpr LocalizedString kLocalizedStringsWithoutPlaceholders[] = {
+ {"cancel", IDS_CANCEL},
+};
+
+} // namespace
+
+void AddLocalizedStrings(content::WebUIDataSource* html_source) {
+ AddLocalizedStringsBulk(html_source, kLocalizedStringsWithoutPlaceholders,
+ base::size(kLocalizedStringsWithoutPlaceholders));
+}
+
+void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder) {
+ for (const auto& entry : kLocalizedStringsWithoutPlaceholders)
+ builder->Add(entry.name, entry.id);
+}
+
+} // namespace cellular_setup
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h
new file mode 100644
index 00000000000..6ab522f5b34
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_localized_strings_provider.h
@@ -0,0 +1,30 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_H_
+
+namespace login {
+class LocalizedValuesBuilder;
+}
+
+namespace content {
+class WebUIDataSource;
+}
+
+namespace chromeos {
+
+namespace cellular_setup {
+
+// Adds the strings needed for the cellular setup flow to |html_source|.
+void AddLocalizedStrings(content::WebUIDataSource* html_source);
+
+// Same as AddLocalizedStrings() but for a LocalizedValuesBuilder.
+void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder);
+
+} // namespace cellular_setup
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_CELLULAR_SETUP_LOCALIZED_STRINGS_PROVIDER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc
index 76ff0738b50..542665cbd5a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/mobile/mobile_activator.h"
@@ -21,6 +21,8 @@
namespace chromeos {
+namespace cellular_setup {
+
namespace {
constexpr int kMobileSetupDialogWidth = 850;
@@ -70,6 +72,10 @@ void MobileSetupDialog::GetDialogSize(gfx::Size* size) const {
size->SetSize(kMobileSetupDialogWidth, kMobileSetupDialogHeight);
}
+bool MobileSetupDialog::CanResizeDialog() const {
+ return true;
+}
+
std::string MobileSetupDialog::GetDialogArgs() const {
return std::string();
}
@@ -94,4 +100,6 @@ void MobileSetupDialog::OnCloseContents(content::WebContents* source,
l10n_util::GetStringUTF16(IDS_MOBILE_CANCEL_ACTIVATION));
}
+} // namespace cellular_setup
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h
index e15ad870e3d..4739b83e39e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_dialog.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_DIALOG_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_DIALOG_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_MOBILE_SETUP_DIALOG_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_MOBILE_SETUP_DIALOG_H_
#include "base/macros.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
@@ -12,23 +12,32 @@ namespace chromeos {
class NetworkState;
-class MobileSetupDialog : public SystemWebDialogDelegate {
- public:
- static void ShowByNetworkId(const std::string& network_id);
+namespace cellular_setup {
+// Dialog used for cellular activation flow when the
+// kUpdatedCellularActivationUi flag is disabled.
+// DEPRECATED: Being replaced by new UI; see https://crbug.com/778021.
+class MobileSetupDialog : public SystemWebDialogDelegate {
protected:
explicit MobileSetupDialog(const NetworkState& network);
~MobileSetupDialog() override;
// ui::WebDialogDelegate
void GetDialogSize(gfx::Size* size) const override;
+ bool CanResizeDialog() const override;
std::string GetDialogArgs() const override;
void OnCloseContents(content::WebContents* source,
bool* out_close_dialog) override;
+ private:
+ friend void OpenCellularSetupDialog(const std::string& cellular_network_guid);
+ static void ShowByNetworkId(const std::string& network_id);
+
DISALLOW_COPY_AND_ASSIGN(MobileSetupDialog);
};
+} // namespace cellular_setup
+
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_DIALOG_H_
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_MOBILE_SETUP_DIALOG_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc
index 8fb50f2e459..060cab439e7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.h"
#include <stddef.h>
@@ -46,6 +46,8 @@
namespace chromeos {
+namespace cellular_setup {
+
namespace {
// Host page JS API function names.
@@ -604,4 +606,6 @@ MobileSetupUI::MobileSetupUI(content::WebUI* web_ui) : ui::WebDialogUI(web_ui) {
MobileSetupUI::~MobileSetupUI() = default;
+} // namespace cellular_setup
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.h
index 8334f116b4a..a9d6fcc2c8e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/cellular_setup/mobile_setup_ui.h
@@ -2,16 +2,20 @@
// 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_MOBILE_SETUP_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_MOBILE_SETUP_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_MOBILE_SETUP_UI_H_
#include "base/macros.h"
#include "ui/web_dialogs/web_dialog_ui.h"
namespace chromeos {
+namespace cellular_setup {
+
// A custom WebUI that defines datasource for mobile setup registration page
// that is used in Chrome OS activate modem and perform plan subscription tasks.
+// This WebUI is being replaced and is only shown when the
+// kUpdatedCellularActivationUi flag is disabled; see go/cros-cellular-design.
class MobileSetupUI : public ui::WebDialogUI {
public:
explicit MobileSetupUI(content::WebUI* web_ui);
@@ -21,6 +25,8 @@ class MobileSetupUI : public ui::WebDialogUI {
DISALLOW_COPY_AND_ASSIGN(MobileSetupUI);
};
+} // namespace cellular_setup
+
} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MOBILE_SETUP_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_CELLULAR_SETUP_MOBILE_SETUP_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc
index 8878f366d91..a2b95c06332 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/task/post_task.h"
#include "base/values.h"
-#include "chromeos/dbus/cryptohome_client.h"
+#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
@@ -29,8 +29,7 @@ void CryptohomeWebUIHandler::RegisterMessages() {
}
void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) {
- CryptohomeClient* cryptohome_client =
- DBusThreadManager::Get()->GetCryptohomeClient();
+ CryptohomeClient* cryptohome_client = CryptohomeClient::Get();
cryptohome_client->IsMounted(GetCryptohomeBoolCallback("is-mounted"));
cryptohome_client->TpmIsReady(GetCryptohomeBoolCallback("tpm-is-ready"));
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 46e535b2610..670f76e0edf 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -50,6 +50,7 @@
#include "google_apis/drive/drive_api_error_codes.h"
#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/time_util.h"
+#include "net/base/filename_util.h"
using content::BrowserThread;
@@ -760,6 +761,10 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
if (log_path.empty())
return;
+ MaybeCallJavascript(
+ "updateOtherServiceLogsUrl",
+ base::Value(net::FilePathToFileURL(log_path.DirName()).spec()));
+
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce(&GetServiceLogContents, log_path,
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 210336fd343..85c54f11143 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
@@ -15,9 +15,9 @@
#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/audio/fake_cras_audio_client.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 "chromeos/dbus/power/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"
@@ -141,25 +141,22 @@ class DeviceEmulatorMessageHandler::CrasAudioObserver
public:
explicit CrasAudioObserver(DeviceEmulatorMessageHandler* owner)
: owner_(owner) {
- owner_->fake_cras_audio_client_->AddObserver(this);
+ chromeos::FakeCrasAudioClient::Get()->AddObserver(this);
}
~CrasAudioObserver() override {
- owner_->fake_cras_audio_client_->RemoveObserver(this);
+ chromeos::FakeCrasAudioClient::Get()->RemoveObserver(this);
}
// chromeos::CrasAudioClient::Observer.
- void NodesChanged() override;
+ void NodesChanged() override { owner_->HandleRequestAudioNodes(nullptr); }
private:
DeviceEmulatorMessageHandler* owner_;
+
DISALLOW_COPY_AND_ASSIGN(CrasAudioObserver);
};
-void DeviceEmulatorMessageHandler::CrasAudioObserver::NodesChanged() {
- owner_->HandleRequestAudioNodes(nullptr);
-}
-
class DeviceEmulatorMessageHandler::PowerObserver
: public PowerManagerClient::Observer {
public:
@@ -201,8 +198,6 @@ DeviceEmulatorMessageHandler::DeviceEmulatorMessageHandler()
: fake_bluetooth_device_client_(
static_cast<bluez::FakeBluetoothDeviceClient*>(
bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient())),
- fake_cras_audio_client_(static_cast<chromeos::FakeCrasAudioClient*>(
- chromeos::DBusThreadManager::Get()->GetCrasAudioClient())),
fake_power_manager_client_(chromeos::FakePowerManagerClient::Get()),
weak_ptr_factory_(this) {
device::BluetoothAdapterFactory::GetAdapter(
@@ -307,7 +302,8 @@ void DeviceEmulatorMessageHandler::HandleRequestAudioNodes(
// Get every active audio node and create a dictionary to
// send it to JavaScript.
base::ListValue audio_nodes;
- for (const AudioNode& node : fake_cras_audio_client_->node_list()) {
+ for (const AudioNode& node :
+ chromeos::FakeCrasAudioClient::Get()->node_list()) {
std::unique_ptr<base::DictionaryValue> audio_node(
new base::DictionaryValue());
@@ -339,7 +335,7 @@ void DeviceEmulatorMessageHandler::HandleInsertAudioNode(
CHECK(device_dict->GetString("id", &tmp_id));
CHECK(base::StringToUint64(tmp_id, &audio_node.id));
- fake_cras_audio_client_->InsertAudioNodeToList(audio_node);
+ chromeos::FakeCrasAudioClient::Get()->InsertAudioNodeToList(audio_node);
}
void DeviceEmulatorMessageHandler::HandleRemoveAudioNode(
@@ -349,7 +345,7 @@ void DeviceEmulatorMessageHandler::HandleRemoveAudioNode(
CHECK(args->GetString(0, &tmp_id));
CHECK(base::StringToUint64(tmp_id, &id));
- fake_cras_audio_client_->RemoveAudioNodeFromList(id);
+ chromeos::FakeCrasAudioClient::Get()->RemoveAudioNodeFromList(id);
}
void DeviceEmulatorMessageHandler::HandleSetHasTouchpad(
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 9c6690616ff..0aca35bab32 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
@@ -30,7 +30,6 @@ class FakeBluetoothDeviceClient;
namespace chromeos {
-class FakeCrasAudioClient;
class FakePowerManagerClient;
// Handler class for the Device Emulator page operations.
@@ -70,11 +69,11 @@ class DeviceEmulatorMessageHandler :
// that there can be multiple current active nodes.
void HandleRequestAudioNodes(const base::ListValue* args);
- // Create a node and add the node to the current AudioNodeList in
- // |fake_cras_audio_client_|.
+ // Create a node and add the node to the current AudioNodeList in the
+ // FakeCrasAudioClient.
void HandleInsertAudioNode(const base::ListValue* args);
- // Removes an AudioNode from the current list in |fake_cras_audio_client_|.
+ // Removes an AudioNode from the current list in the FakeCrasAudioClient
// based on the node id.
void HandleRemoveAudioNode(const base::ListValue* args);
@@ -88,7 +87,6 @@ class DeviceEmulatorMessageHandler :
// asynchronously.
void UpdateBatteryPercent(const base::ListValue* args);
void UpdateBatteryState(const base::ListValue* args);
- void UpdateExternalPower(const base::ListValue* args);
void UpdateTimeToEmpty(const base::ListValue* args);
void UpdateTimeToFull(const base::ListValue* args);
void UpdatePowerSources(const base::ListValue* args);
@@ -132,7 +130,6 @@ class DeviceEmulatorMessageHandler :
bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_;
std::unique_ptr<BluetoothObserver> bluetooth_observer_;
- FakeCrasAudioClient* fake_cras_audio_client_;
std::unique_ptr<CrasAudioObserver> cras_audio_observer_;
FakePowerManagerClient* fake_power_manager_client_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/image_source.cc b/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
index 5fe26023bb6..0c8e627e816 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/image_source.cc
@@ -16,7 +16,7 @@
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.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/insession_password_change_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.cc
new file mode 100644
index 00000000000..dc0f34653cd
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.cc
@@ -0,0 +1,90 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.h"
+
+#include <string>
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/macros.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+#include "chromeos/constants/chromeos_switches.h"
+#include "components/prefs/pref_service.h"
+#include "components/user_manager/user_manager.h"
+
+namespace chromeos {
+
+InSessionPasswordChangeHandler::InSessionPasswordChangeHandler() = default;
+InSessionPasswordChangeHandler::~InSessionPasswordChangeHandler() = default;
+
+void InSessionPasswordChangeHandler::HandleInitialize(
+ const base::ListValue* value) {
+ const Profile* profile = Profile::FromWebUI(web_ui());
+ CHECK(profile->GetPrefs()->GetBoolean(
+ prefs::kSamlInSessionPasswordChangeEnabled));
+
+ AllowJavascript();
+ base::Value params(base::Value::Type::DICTIONARY);
+ const std::string password_change_url =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kSamlPasswordChangeUrl);
+ params.SetKey("passwordChangeUrl", base::Value(password_change_url));
+ const user_manager::User* user =
+ ProfileHelper::Get()->GetUserByProfile(profile);
+ if (user)
+ params.SetKey("userName", base::Value(user->GetDisplayEmail()));
+ CallJavascriptFunction("insession.password.change.loadAuthExtension", params);
+}
+
+void InSessionPasswordChangeHandler::HandleChangePassword(
+ const base::ListValue* params) {
+ const base::Value& old_passwords = params->GetList()[0];
+ const base::Value& new_passwords = params->GetList()[1];
+ VLOG(4) << "Scraped " << old_passwords.GetList().size() << " old passwords";
+ VLOG(4) << "Scraped " << new_passwords.GetList().size() << " new passwords";
+ user_manager::User* user =
+ ProfileHelper::Get()->GetUserByProfile(Profile::FromWebUI(web_ui()));
+ user_manager::UserManager::Get()->SaveForceOnlineSignin(user->GetAccountId(),
+ true);
+ if (new_passwords.GetList().size() == 1 &&
+ old_passwords.GetList().size() > 0) {
+ UserContext user_context(*user);
+ user_context.SetKey(Key(new_passwords.GetList()[0].GetString()));
+ authenticator_ = new ChromeCryptohomeAuthenticator(this);
+ authenticator_->MigrateKey(user_context,
+ old_passwords.GetList()[0].GetString());
+ }
+}
+
+void InSessionPasswordChangeHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "initialize",
+ base::BindRepeating(&InSessionPasswordChangeHandler::HandleInitialize,
+ weak_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "changePassword",
+ base::BindRepeating(&InSessionPasswordChangeHandler::HandleChangePassword,
+ weak_factory_.GetWeakPtr()));
+}
+
+void InSessionPasswordChangeHandler::OnAuthSuccess(
+ const UserContext& user_context) {
+ VLOG(3) << "Cryptohome password is changed.";
+ user_manager::UserManager::Get()->SaveForceOnlineSignin(
+ user_context.GetAccountId(), false);
+ authenticator_.reset();
+}
+
+void InSessionPasswordChangeHandler::OnAuthFailure(const AuthFailure& error) {
+ // TODO(rsorokin): Ask user for the old password
+ VLOG(1) << "Failed to change cryptohome password: " << error.GetErrorString();
+ authenticator_.reset();
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.h b/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.h
new file mode 100644
index 00000000000..aed2376af21
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.h
@@ -0,0 +1,40 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_INSESSION_PASSWORD_CHANGE_HANDLER_CHROMEOS_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_INSESSION_PASSWORD_CHANGE_HANDLER_CHROMEOS_H_
+
+#include "base/memory/weak_ptr.h"
+#include "base/values.h"
+#include "chromeos/login/auth/auth_status_consumer.h"
+#include "chromeos/login/auth/cryptohome_authenticator.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace chromeos {
+
+class InSessionPasswordChangeHandler : public content::WebUIMessageHandler,
+ AuthStatusConsumer {
+ public:
+ InSessionPasswordChangeHandler();
+ ~InSessionPasswordChangeHandler() override;
+
+ // content::WebUIMessageHandler:
+ void RegisterMessages() override;
+
+ void HandleInitialize(const base::ListValue*);
+ void HandleChangePassword(const base::ListValue* passwords);
+
+ // AuthStatusConsumer:
+ void OnAuthFailure(const AuthFailure& error) override;
+ void OnAuthSuccess(const UserContext& user_context) override;
+
+ private:
+ scoped_refptr<CryptohomeAuthenticator> authenticator_;
+ base::WeakPtrFactory<InSessionPasswordChangeHandler> weak_factory_{this};
+ DISALLOW_COPY_AND_ASSIGN(InSessionPasswordChangeHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_INSESSION_PASSWORD_CHANGE_HANDLER_CHROMEOS_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_ui.cc
new file mode 100644
index 00000000000..eb4c9d46c12
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_ui.cc
@@ -0,0 +1,47 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/insession_password_change_ui.h"
+
+#include <memory>
+
+#include "base/bind.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/insession_password_change_handler_chromeos.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/browser_resources.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/prefs/pref_service.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/strings/grit/ui_strings.h"
+
+namespace chromeos {
+
+InSessionPasswordChangeUI::InSessionPasswordChangeUI(content::WebUI* web_ui)
+ : ui::WebDialogUI(web_ui) {
+ Profile* profile = Profile::FromWebUI(web_ui);
+ CHECK(profile->GetPrefs()->GetBoolean(
+ prefs::kSamlInSessionPasswordChangeEnabled));
+
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUIPasswordChangeHost);
+
+ web_ui->AddMessageHandler(std::make_unique<InSessionPasswordChangeHandler>());
+
+ source->SetJsonPath("strings.js");
+
+ source->SetDefaultResource(IDR_PASSWORD_CHANGE_HTML);
+
+ source->AddResourcePath("password_change.css", IDR_PASSWORD_CHANGE_CSS);
+ source->AddResourcePath("authenticator.js",
+ IDR_PASSWORD_CHANGE_AUTHENTICATOR_JS);
+ source->AddResourcePath("password_change.js", IDR_PASSWORD_CHANGE_JS);
+
+ content::WebUIDataSource::Add(profile, source);
+}
+
+InSessionPasswordChangeUI::~InSessionPasswordChangeUI() = default;
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_ui.h b/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_ui.h
new file mode 100644
index 00000000000..b012a52592e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/insession_password_change_ui.h
@@ -0,0 +1,25 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_INSESSION_PASSWORD_CHANGE_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_INSESSION_PASSWORD_CHANGE_UI_H_
+
+#include "base/macros.h"
+#include "ui/web_dialogs/web_dialog_ui.h"
+
+namespace chromeos {
+
+// For chrome:://password-change
+class InSessionPasswordChangeUI : public ui::WebDialogUI {
+ public:
+ explicit InSessionPasswordChangeUI(content::WebUI* web_ui);
+ ~InSessionPasswordChangeUI() override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(InSessionPasswordChangeUI);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_INSESSION_PASSWORD_CHANGE_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
index 5a1a5f7ca14..dc266335d62 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
@@ -1,4 +1,11 @@
+# (in PST)
achuith@chromium.org
alemate@chromium.org
jdufault@chromium.org
+tbarzic@chromium.org
+
+# (in CET)
+antrim@chromium.org
per-file *active_directory*=rsorokin@chromium.org
+
+# COMPONENT: UI>Shell>OOBE
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
index 57a5c53c988..d29cbf62c3a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
@@ -7,12 +7,12 @@
#include <memory>
#include "base/bind.h"
+#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/core_oobe_view.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/login/auth/authpolicy_login_helper.h"
#include "chromeos/login/auth/key.h"
#include "components/login/localized_values_builder.h"
#include "components/user_manager/known_user.h"
@@ -22,7 +22,6 @@ namespace chromeos {
namespace {
-constexpr char kJsScreenPath[] = "login.ActiveDirectoryPasswordChangeScreen";
constexpr char kUsernameKey[] = "username";
constexpr char kErrorKey[] = "error";
@@ -42,10 +41,9 @@ ActiveDirectoryPasswordChangeScreenHandler::
CoreOobeView* core_oobe_view)
: BaseScreenHandler(OobeScreen::SCREEN_ACTIVE_DIRECTORY_PASSWORD_CHANGE,
js_calls_container),
- authpolicy_login_helper_(std::make_unique<AuthPolicyLoginHelper>()),
+ authpolicy_login_helper_(std::make_unique<AuthPolicyHelper>()),
core_oobe_view_(core_oobe_view),
weak_factory_(this) {
- set_call_js_prefix(kJsScreenPath);
}
ActiveDirectoryPasswordChangeScreenHandler::
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h
index 3f8d66dca16..74b41552268 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h
@@ -8,8 +8,8 @@
#include <string>
#include "base/macros.h"
+#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-#include "chromeos/login/auth/authpolicy_login_helper.h"
namespace authpolicy {
class ActiveDirectoryAccountInfo;
@@ -49,8 +49,8 @@ class ActiveDirectoryPasswordChangeScreenHandler : public BaseScreenHandler {
// Shows the screen with the error message corresponding to |error|.
void ShowScreenWithError(int error);
- // Callback called by AuthPolicyLoginHelper::AuthenticateUser with results and
- // error code. (see AuthPolicyLoginHelper::AuthenticateUser)
+ // Callback called by AuthPolicyHelper::AuthenticateUser with results and
+ // error code. (see AuthPolicyHelper::AuthenticateUser)
void OnAuthFinished(
const std::string& username,
const Key& key,
@@ -59,7 +59,7 @@ class ActiveDirectoryPasswordChangeScreenHandler : public BaseScreenHandler {
// Helper to call AuthPolicyClient and cancel calls if needed. Used to change
// password on the Active Directory server.
- std::unique_ptr<AuthPolicyLoginHelper> authpolicy_login_helper_;
+ std::unique_ptr<AuthPolicyHelper> authpolicy_login_helper_;
// Non-owned. Used to display signin error.
CoreOobeView* core_oobe_view_ = nullptr;
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 db98949d350..60b1c10d338 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
@@ -14,8 +14,6 @@
namespace {
-const char kJsScreenPath[] = "login.AppDownloadingScreen";
-
int GetNumberOfUserSelectedApps() {
const Profile* profile = ProfileManager::GetActiveUserProfile();
const PrefService* pref_service = profile->GetPrefs();
@@ -32,7 +30,7 @@ namespace chromeos {
AppDownloadingScreenHandler::AppDownloadingScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.AppDownloadingScreen.userActed");
}
AppDownloadingScreenHandler::~AppDownloadingScreenHandler() {}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h
index 9995b81a034..4a38e0314d6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h
@@ -6,13 +6,28 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_APP_DOWNLOADING_SCREEN_HANDLER_H_
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/screens/app_downloading_screen_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace chromeos {
class AppDownloadingScreen;
+class AppDownloadingScreenView {
+ public:
+ constexpr static OobeScreen kScreenId = OobeScreen::SCREEN_APP_DOWNLOADING;
+
+ virtual ~AppDownloadingScreenView() = default;
+
+ // Sets screen this view belongs to.
+ virtual void Bind(AppDownloadingScreen* screen) = 0;
+
+ // Shows the contents of the screen.
+ virtual void Show() = 0;
+
+ // Hides the contents of the screen.
+ virtual void Hide() = 0;
+};
+
// The sole implementation of the AppDownloadingScreenView, using WebUI.
class AppDownloadingScreenHandler : public BaseScreenHandler,
public AppDownloadingScreenView {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
index 388ffa6b821..9b9707d2b22 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
@@ -9,6 +9,7 @@
#include "base/values.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/chromeos/login/app_launch_controller.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/network_error.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
@@ -24,8 +25,6 @@
namespace {
-const char kJsScreenPath[] = "login.AppLaunchSplashScreen";
-
// Returns network name by service path.
std::string GetNetworkName(const std::string& service_path) {
const chromeos::NetworkState* network =
@@ -47,14 +46,13 @@ AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler(
: BaseScreenHandler(kScreenId, js_calls_container),
network_state_informer_(network_state_informer),
error_screen_(error_screen) {
- set_call_js_prefix(kJsScreenPath);
network_state_informer_->AddObserver(this);
}
AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() {
network_state_informer_->RemoveObserver(this);
- if (delegate_)
- delegate_->OnDeletingSplashScreenView();
+ if (controller_)
+ controller_->OnDeletingSplashScreenView();
}
void AppLaunchSplashScreenHandler::DeclareLocalizedValues(
@@ -131,8 +129,8 @@ void AppLaunchSplashScreenHandler::UpdateAppLaunchState(AppLaunchState state) {
}
void AppLaunchSplashScreenHandler::SetDelegate(
- AppLaunchSplashScreenHandler::Delegate* delegate) {
- delegate_ = delegate;
+ AppLaunchController* controller) {
+ controller_ = controller;
}
void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() {
@@ -140,7 +138,7 @@ void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() {
if (state == NetworkStateInformer::ONLINE) {
online_state_ = true;
if (!network_config_requested_) {
- delegate_->OnNetworkStateChanged(true);
+ controller_->OnNetworkStateChanged(true);
return;
}
}
@@ -198,15 +196,14 @@ void AppLaunchSplashScreenHandler::OnNetworkReady() {
void AppLaunchSplashScreenHandler::UpdateState(
NetworkError::ErrorReason reason) {
- if (!delegate_ ||
- (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK &&
- state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) {
+ if (!controller_ || (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK &&
+ state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) {
return;
}
bool new_online_state =
network_state_informer_->state() == NetworkStateInformer::ONLINE;
- delegate_->OnNetworkStateChanged(new_online_state);
+ controller_->OnNetworkStateChanged(new_online_state);
online_state_ = new_online_state;
}
@@ -250,33 +247,33 @@ int AppLaunchSplashScreenHandler::GetProgressMessageFromState(
}
void AppLaunchSplashScreenHandler::HandleConfigureNetwork() {
- if (delegate_)
- delegate_->OnConfigureNetwork();
+ if (controller_)
+ controller_->OnConfigureNetwork();
else
LOG(WARNING) << "No delegate set to handle network configuration.";
}
void AppLaunchSplashScreenHandler::HandleCancelAppLaunch() {
- if (delegate_)
- delegate_->OnCancelAppLaunch();
+ if (controller_)
+ controller_->OnCancelAppLaunch();
else
LOG(WARNING) << "No delegate set to handle cancel app launch";
}
void AppLaunchSplashScreenHandler::HandleNetworkConfigRequested() {
- if (!delegate_ || network_config_done_)
+ if (!controller_ || network_config_done_)
return;
network_config_requested_ = true;
- delegate_->OnNetworkConfigRequested(true);
+ controller_->OnNetworkConfigRequested(true);
}
void AppLaunchSplashScreenHandler::HandleContinueAppLaunch() {
DCHECK(online_state_);
- if (delegate_ && online_state_) {
+ if (controller_ && online_state_) {
network_config_requested_ = false;
network_config_done_ = true;
- delegate_->OnNetworkConfigRequested(false);
+ controller_->OnNetworkConfigRequested(false);
Show(app_id_);
}
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h
index a818ee89aac..250e858dfc6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h
@@ -9,13 +9,51 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/screens/app_launch_splash_screen_view.h"
#include "chrome/browser/chromeos/login/screens/error_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
namespace chromeos {
+class AppLaunchController;
+
+// Interface for UI implementations of the AppLaunchSplashScreen.
+class AppLaunchSplashScreenView {
+ public:
+ enum AppLaunchState {
+ APP_LAUNCH_STATE_PREPARING_NETWORK,
+ APP_LAUNCH_STATE_INSTALLING_APPLICATION,
+ APP_LAUNCH_STATE_WAITING_APP_WINDOW,
+ APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT,
+ APP_LAUNCH_STATE_SHOWING_NETWORK_CONFIGURE_UI,
+ };
+
+ constexpr static OobeScreen kScreenId = OobeScreen::SCREEN_APP_LAUNCH_SPLASH;
+
+ virtual ~AppLaunchSplashScreenView() {}
+
+ // Sets screen this view belongs to.
+ virtual void SetDelegate(AppLaunchController* controller) = 0;
+
+ // Shows the contents of the screen.
+ virtual void Show(const std::string& app_id) = 0;
+
+ // Hides the contents of the screen.
+ virtual void Hide() = 0;
+
+ // Set the current app launch state.
+ virtual void UpdateAppLaunchState(AppLaunchState state) = 0;
+
+ // Sets whether configure network control is visible.
+ virtual void ToggleNetworkConfig(bool visible) = 0;
+
+ // Shows the network error and configure UI.
+ virtual void ShowNetworkConfigureUI() = 0;
+
+ // Returns true if the default network has Internet access.
+ virtual bool IsNetworkReady() = 0;
+};
+
// A class that handles the WebUI hooks for the app launch splash screen.
class AppLaunchSplashScreenHandler
: public BaseScreenHandler,
@@ -41,7 +79,7 @@ class AppLaunchSplashScreenHandler
void Hide() override;
void ToggleNetworkConfig(bool visible) override;
void UpdateAppLaunchState(AppLaunchState state) override;
- void SetDelegate(AppLaunchSplashScreenHandler::Delegate* delegate) override;
+ void SetDelegate(AppLaunchController* controller) override;
void ShowNetworkConfigureUI() override;
bool IsNetworkReady() override;
@@ -58,7 +96,7 @@ class AppLaunchSplashScreenHandler
void HandleContinueAppLaunch();
void HandleNetworkConfigRequested();
- AppLaunchSplashScreenHandler::Delegate* delegate_ = nullptr;
+ AppLaunchController* controller_ = nullptr;
bool show_on_init_ = false;
std::string app_id_;
AppLaunchState state_ = APP_LAUNCH_STATE_PREPARING_NETWORK;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
index 422e6ed06e5..ae7fa0e10db 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
@@ -7,6 +7,7 @@
#include <memory>
#include "base/values.h"
+#include "chrome/browser/chromeos/login/arc_kiosk_controller.h"
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
@@ -16,22 +17,15 @@
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/image/image_skia.h"
-namespace {
-
-constexpr char kJsScreenPath[] = "login.ArcKioskSplashScreen";
-}
-
namespace chromeos {
ArcKioskSplashScreenHandler::ArcKioskSplashScreenHandler(
JSCallsContainer* js_calls_container)
- : BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
-}
+ : BaseScreenHandler(kScreenId, js_calls_container) {}
ArcKioskSplashScreenHandler::~ArcKioskSplashScreenHandler() {
- if (delegate_)
- delegate_->OnDeletingSplashScreenView();
+ if (controller_)
+ controller_->OnDeletingSplashScreenView();
}
void ArcKioskSplashScreenHandler::DeclareLocalizedValues(
@@ -79,9 +73,8 @@ void ArcKioskSplashScreenHandler::UpdateArcKioskState(ArcKioskState state) {
SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state)));
}
-void ArcKioskSplashScreenHandler::SetDelegate(
- ArcKioskSplashScreenHandler::Delegate* delegate) {
- delegate_ = delegate;
+void ArcKioskSplashScreenHandler::SetDelegate(ArcKioskController* controller) {
+ controller_ = controller;
}
void ArcKioskSplashScreenHandler::PopulateAppInfo(
@@ -115,11 +108,11 @@ int ArcKioskSplashScreenHandler::GetProgressMessageFromState(
}
void ArcKioskSplashScreenHandler::HandleCancelArcKioskLaunch() {
- if (!delegate_) {
+ if (!controller_) {
LOG(WARNING) << "No delegate set to handle cancel app launch";
return;
}
- delegate_->OnCancelArcKioskLaunch();
+ controller_->OnCancelArcKioskLaunch();
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h
index 1121cce9252..b5166a33c04 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h
@@ -8,7 +8,6 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/screens/arc_kiosk_splash_screen_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace base {
@@ -17,6 +16,36 @@ class DictionaryValue;
namespace chromeos {
+class ArcKioskController;
+
+// Interface for UI implementations of the ArcKioskSplashScreen.
+class ArcKioskSplashScreenView {
+ public:
+ enum class ArcKioskState {
+ STARTING_SESSION,
+ WAITING_APP_LAUNCH,
+ WAITING_APP_WINDOW,
+ };
+
+ constexpr static OobeScreen kScreenId = OobeScreen::SCREEN_ARC_KIOSK_SPLASH;
+
+ ArcKioskSplashScreenView() = default;
+
+ virtual ~ArcKioskSplashScreenView() = default;
+
+ // Shows the contents of the screen.
+ virtual void Show() = 0;
+
+ // Set the current ARC kiosk state.
+ virtual void UpdateArcKioskState(ArcKioskState state) = 0;
+
+ // Sets screen this view belongs to.
+ virtual void SetDelegate(ArcKioskController* controller) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ArcKioskSplashScreenView);
+};
+
// A class that handles the WebUI hooks for the ARC kiosk splash screen.
class ArcKioskSplashScreenHandler : public BaseScreenHandler,
public ArcKioskSplashScreenView {
@@ -36,14 +65,14 @@ class ArcKioskSplashScreenHandler : public BaseScreenHandler,
// ArcKioskSplashScreenView implementation:
void Show() override;
void UpdateArcKioskState(ArcKioskState state) override;
- void SetDelegate(ArcKioskSplashScreenHandler::Delegate* delegate) override;
+ void SetDelegate(ArcKioskController* controller) override;
void PopulateAppInfo(base::DictionaryValue* out_info);
void SetLaunchText(const std::string& text);
int GetProgressMessageFromState(ArcKioskState state);
void HandleCancelArcKioskLaunch();
- ArcKioskSplashScreenHandler::Delegate* delegate_ = nullptr;
+ ArcKioskController* controller_ = nullptr;
bool show_on_init_ = false;
DISALLOW_COPY_AND_ASSIGN(ArcKioskSplashScreenHandler);
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 c0706b04796..56d55c7d0c9 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
@@ -5,8 +5,8 @@
#include "chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h"
#include "base/command_line.h"
+#include "base/hash/sha1.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"
@@ -43,12 +43,6 @@ using ArcPlayTermsOfServiceConsent =
using sync_pb::UserConsentTypes;
-namespace {
-
-const char kJsScreenPath[] = "login.ArcTermsOfServiceScreen";
-
-} // namespace
-
namespace chromeos {
ArcTermsOfServiceScreenHandler::ArcTermsOfServiceScreenHandler(
@@ -56,7 +50,7 @@ ArcTermsOfServiceScreenHandler::ArcTermsOfServiceScreenHandler(
: BaseScreenHandler(kScreenId, js_calls_container),
is_child_account_(
user_manager::UserManager::Get()->IsLoggedInAsChildUser()) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.ArcTermsOfServiceScreen.userActed");
}
ArcTermsOfServiceScreenHandler::~ArcTermsOfServiceScreenHandler() {
@@ -139,6 +133,7 @@ void ArcTermsOfServiceScreenHandler::DeclareLocalizedValues(
builder->Add("arcTextReviewSettings", IDS_ARC_REVIEW_SETTINGS);
builder->Add("arcTextMetricsManagedEnabled",
IDS_ARC_OOBE_TERMS_DIALOG_METRICS_MANAGED_ENABLED);
+ builder->Add("arcTextMetricsDemoApps", IDS_ARC_OOBE_TERMS_DIALOG_DEMO_APPS);
builder->Add("arcAcceptAndContinueGoogleServiceConfirmation",
IDS_ARC_OPT_IN_ACCEPT_AND_CONTINUE_GOOGLE_SERVICE_CONFIRMATION);
builder->Add("arcLearnMoreStatistics",
@@ -282,7 +277,8 @@ void ArcTermsOfServiceScreenHandler::DoShow() {
// Hide the Skip button if the ToS screen can not be skipped during OOBE.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kEnableArcOobeOptinNoSkip)) {
+ chromeos::switches::kEnableArcOobeOptinNoSkip) ||
+ arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)) {
CallJS("login.ArcTermsOfServiceScreen.hideSkipButton");
}
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 b6435e5a604..6a8fd69e7cd 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
@@ -54,7 +54,7 @@ class ArcTermsOfServiceScreenHandler
// OobeUI::Observer:
void OnCurrentScreenChanged(OobeScreen current_screen,
OobeScreen new_screen) override;
- void OnScreenInitialized(OobeScreen screen) override {}
+ void OnDestroyingOobeUI() override {}
// system::TimezoneSettings::Observer:
void TimezoneChanged(const icu::TimeZone& timezone) override;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
index 395454ca5d6..540df02f96c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/assistant/assistant_pref_util.h"
@@ -23,13 +24,13 @@
#include "components/arc/arc_prefs.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
+#include "components/user_manager/user_manager.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 kRecordPressed[] = "record-pressed";
@@ -44,7 +45,7 @@ AssistantOptInFlowScreenHandler::AssistantOptInFlowScreenHandler(
: BaseScreenHandler(kScreenId, js_calls_container),
client_binding_(this),
weak_factory_(this) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.AssistantOptInFlowScreen.userActed");
}
AssistantOptInFlowScreenHandler::~AssistantOptInFlowScreenHandler() {
@@ -359,8 +360,11 @@ void AssistantOptInFlowScreenHandler::OnGetSettingsResponse(
// Process get more data.
email_optin_needed_ = settings_ui.has_email_opt_in_ui() &&
settings_ui.email_opt_in_ui().has_title();
+ auto* profile_helper = ProfileHelper::Get();
+ const auto* user = user_manager::UserManager::Get()->GetActiveUser();
auto get_more_data =
- CreateGetMoreData(email_optin_needed_, settings_ui.email_opt_in_ui());
+ CreateGetMoreData(email_optin_needed_, settings_ui.email_opt_in_ui(),
+ profile_helper->GetProfileByUser(user)->GetPrefs());
bool skip_get_more =
skip_third_party_disclosure && !get_more_data.GetList().size();
@@ -376,9 +380,9 @@ void AssistantOptInFlowScreenHandler::OnGetSettingsResponse(
// Pass string constants dictionary.
auto dictionary = GetSettingsUiStrings(settings_ui, activity_control_needed_);
- dictionary.SetKey("voiceMatchFeatureEnabled",
- base::Value(base::FeatureList::IsEnabled(
- assistant::features::kAssistantVoiceMatch)));
+ dictionary.SetKey("voiceMatchEnabled",
+ base::Value(IsVoiceMatchEnabled(
+ ProfileManager::GetActiveUserProfile()->GetPrefs())));
ReloadContent(dictionary);
}
@@ -444,12 +448,11 @@ void AssistantOptInFlowScreenHandler::HandleThirdPartyScreenUserAction(
void AssistantOptInFlowScreenHandler::HandleVoiceMatchScreenUserAction(
const std::string& action) {
- if (!base::FeatureList::IsEnabled(
- assistant::features::kAssistantVoiceMatch)) {
- return;
- }
PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
+ if (!IsVoiceMatchEnabled(prefs))
+ return;
+
if (action == kVoiceMatchDone) {
RecordAssistantOptInStatus(VOICE_MATCH_ENROLLMENT_DONE);
voice_match_enrollment_done_ = true;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc
index 37a61d6e58b..0bd92519d4d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_handler.cc
@@ -8,18 +8,11 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-const char kJsScreenPath[] = "login.AutoEnrollmentCheckScreen";
-
-} // namespace
-
namespace chromeos {
AutoEnrollmentCheckScreenHandler::AutoEnrollmentCheckScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
}
AutoEnrollmentCheckScreenHandler::~AutoEnrollmentCheckScreenHandler() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc
index 6293cb90b89..57c6e84bfdc 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.cc
@@ -4,12 +4,35 @@
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
+#include "chrome/browser/chromeos/login/screens/base_screen.h"
+#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
+#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
+
namespace chromeos {
BaseScreenHandler::BaseScreenHandler(OobeScreen oobe_screen,
JSCallsContainer* js_calls_container)
: BaseWebUIHandler(js_calls_container), oobe_screen_(oobe_screen) {}
-BaseScreenHandler::~BaseScreenHandler() {}
+BaseScreenHandler::~BaseScreenHandler() = default;
+
+void BaseScreenHandler::SetBaseScreen(BaseScreen* base_screen) {
+ if (base_screen_ == base_screen)
+ return;
+ base_screen_ = base_screen;
+}
+
+void BaseScreenHandler::RegisterMessages() {
+ if (!user_acted_method_path_.empty()) {
+ AddCallback(user_acted_method_path_, &BaseScreenHandler::HandleUserAction);
+ }
+
+ BaseWebUIHandler::RegisterMessages();
+}
+
+void BaseScreenHandler::HandleUserAction(const std::string& action_id) {
+ if (base_screen_)
+ base_screen_->OnUserAction(action_id);
+}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.h
index dcbbdedaf31..027f4a8ba67 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/base_screen_handler.h
@@ -11,6 +11,8 @@
namespace chromeos {
+class BaseScreen;
+
// Base class for the OOBE/Login WebUI handlers which provide methods specific
// to a particular OobeScreen.
class BaseScreenHandler : public BaseWebUIHandler {
@@ -21,10 +23,35 @@ class BaseScreenHandler : public BaseWebUIHandler {
OobeScreen oobe_screen() const { return oobe_screen_; }
+ void SetBaseScreen(BaseScreen* base_screen);
+
+ // BaseWebUIHandler:
+ void RegisterMessages() override;
+
+ protected:
+ // Set the method identifier for a userActed callback. The actual callback
+ // will be registered in RegisterMessages so this should be called in the
+ // constructor. This takes the full method path, ie,
+ // "login.WelcomeScreen.userActed".
+ //
+ // If this is not called then userActed-style callbacks will not be available
+ // for the screen.
+ void set_user_acted_method_path(const std::string& user_acted_method_path) {
+ user_acted_method_path_ = user_acted_method_path;
+ }
+
private:
+ // Handles user action.
+ void HandleUserAction(const std::string& action_id);
+
+ // Path that is used to invoke user actions.
+ std::string user_acted_method_path_;
+
// OobeScreen that this handler corresponds to.
OobeScreen oobe_screen_ = OobeScreen::SCREEN_UNKNOWN;
+ BaseScreen* base_screen_ = nullptr;
+
DISALLOW_COPY_AND_ASSIGN(BaseScreenHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc
index 25d655fd322..021907c86b5 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.cc
@@ -8,46 +8,20 @@
#include "base/logging.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/login/screens/base_screen.h"
-#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "components/login/localized_values_builder.h"
#include "content/public/browser/web_ui.h"
namespace chromeos {
-JSCallsContainer::JSCallsContainer() = default;
-
-JSCallsContainer::~JSCallsContainer() = default;
-
-void JSCallsContainer::ExecuteDeferredJSCalls() {
- DCHECK(!is_initialized());
- is_initialized_ = true;
- // Copy deferred_js_calls_ into a separate variable to avoid any potential
- // concurrent modifications.
- auto calls = std::move(deferred_js_calls_);
- for (const auto& call : calls)
- call.Run();
- // We're initialized so no more calls should have been queued.
- // TODO(jdufault): Rework this class API so that this is not possible.
- DCHECK(deferred_js_calls_.empty());
-}
-
BaseWebUIHandler::BaseWebUIHandler(JSCallsContainer* js_calls_container)
: js_calls_container_(js_calls_container) {}
-BaseWebUIHandler::~BaseWebUIHandler() {
- if (base_screen_)
- base_screen_->set_model_view_channel(nullptr);
-}
+BaseWebUIHandler::~BaseWebUIHandler() = default;
void BaseWebUIHandler::InitializeBase() {
page_is_ready_ = true;
Initialize();
- if (!pending_context_changes_.empty()) {
- CommitContextChanges(pending_context_changes_);
- pending_context_changes_.Clear();
- }
}
void BaseWebUIHandler::GetLocalizedStrings(base::DictionaryValue* dict) {
@@ -56,26 +30,10 @@ void BaseWebUIHandler::GetLocalizedStrings(base::DictionaryValue* dict) {
GetAdditionalParameters(dict);
}
-std::string BaseWebUIHandler::FullMethodPath(const std::string& method) const {
- DCHECK(!method.empty());
- return js_screen_path_prefix_ + method;
-}
-
void BaseWebUIHandler::RegisterMessages() {
- AddCallback(FullMethodPath("userActed"),
- &BaseScreenHandler::HandleUserAction);
- AddCallback(FullMethodPath("contextChanged"),
- &BaseScreenHandler::HandleContextChanged);
DeclareJSCallbacks();
}
-void BaseWebUIHandler::CommitContextChanges(const base::DictionaryValue& diff) {
- if (!page_is_ready())
- pending_context_changes_.MergeDictionary(&diff);
- else
- CallJS(FullMethodPath("contextChanged"), diff);
-}
-
void BaseWebUIHandler::GetAdditionalParameters(base::DictionaryValue* dict) {}
void BaseWebUIHandler::ShowScreen(OobeScreen screen) {
@@ -105,28 +63,26 @@ OobeScreen BaseWebUIHandler::GetCurrentScreen() const {
return oobe_ui->current_screen();
}
-gfx::NativeWindow BaseWebUIHandler::GetNativeWindow() {
- return LoginDisplayHost::default_host()->GetNativeWindow();
-}
-
-void BaseWebUIHandler::SetBaseScreen(BaseScreen* base_screen) {
- if (base_screen_ == base_screen)
- return;
- if (base_screen_)
- base_screen_->set_model_view_channel(nullptr);
- base_screen_ = base_screen;
- if (base_screen_)
- base_screen_->set_model_view_channel(this);
-}
-
-void BaseWebUIHandler::HandleUserAction(const std::string& action_id) {
- if (base_screen_)
- base_screen_->OnUserAction(action_id);
+void BaseWebUIHandler::InsertIntoList(std::vector<base::Value>*) {}
+
+void BaseWebUIHandler::MaybeRecordIncomingEvent(
+ const std::string& function_name,
+ const base::ListValue* args) {
+ if (js_calls_container_->record_all_events_for_test()) {
+ // Do a clone so |args| is still available for the actual handler.
+ std::vector<base::Value> arguments = std::move(args->Clone().GetList());
+ js_calls_container_->events()->emplace_back(
+ JSCallsContainer::Event(JSCallsContainer::Event::Type::kIncoming,
+ function_name, std::move(arguments)));
+ }
}
-void BaseWebUIHandler::HandleContextChanged(const base::DictionaryValue* diff) {
- if (diff && base_screen_)
- base_screen_->OnContextChanged(*diff);
+void BaseWebUIHandler::OnRawCallback(
+ const std::string& function_name,
+ const content::WebUI::MessageCallback callback,
+ const base::ListValue* args) {
+ MaybeRecordIncomingEvent(function_name, args);
+ callback.Run(args);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h
index 9722baa6aaf..61c9eefd06b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/base_webui_handler.h
@@ -6,15 +6,15 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_BASE_WEBUI_HANDLER_H_
#include <string>
+#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/model_view_channel.h"
+#include "chrome/browser/ui/webui/chromeos/login/js_calls_container.h"
#include "components/login/base_screen_handler_utils.h"
-#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "ui/gfx/native_widget_types.h"
@@ -29,49 +29,14 @@ class LocalizedValuesBuilder;
namespace chromeos {
-class BaseScreen;
class OobeUI;
-// A helper class to store deferred Javascript calls, shared by subclasses of
-// BaseWebUIHandler.
-// TODO(jdufault): Move into a separate file
-class JSCallsContainer {
- public:
- JSCallsContainer();
- ~JSCallsContainer();
-
- // Used to decide whether the JS call should be deferred.
- bool is_initialized() const { return is_initialized_; }
-
- // Used to add deferred calls to.
- std::vector<base::Closure>& deferred_js_calls() { return deferred_js_calls_; }
-
- // Executes Javascript calls that were deferred while the instance was not
- // initialized yet.
- void ExecuteDeferredJSCalls();
-
- private:
- // Whether the instance is initialized.
- //
- // The instance becomes initialized after the corresponding message is
- // received from Javascript side.
- bool is_initialized_ = false;
-
- // Javascript calls that have been deferred while the instance was not
- // initialized yet.
- std::vector<base::Closure> deferred_js_calls_;
-};
-
// Base class for all oobe/login WebUI handlers. These handlers are the binding
// layer that allow the C++ and JavaScript code to communicate.
//
// If the deriving type is associated with a specific OobeScreen, it should
// derive from BaseScreenHandler instead of BaseWebUIHandler.
-//
-// TODO(jdufault): Move all OobeScreen related concepts out of BaseWebUIHandler
-// and into BaseScreenHandler.
-class BaseWebUIHandler : public content::WebUIMessageHandler,
- public ModelViewChannel {
+class BaseWebUIHandler : public content::WebUIMessageHandler {
public:
explicit BaseWebUIHandler(JSCallsContainer* js_calls_container);
~BaseWebUIHandler() override;
@@ -82,27 +47,10 @@ class BaseWebUIHandler : public content::WebUIMessageHandler,
// WebUIMessageHandler implementation:
void RegisterMessages() override;
- // ModelViewChannel implementation:
- void CommitContextChanges(const base::DictionaryValue& diff) override;
-
// This method is called when page is ready. It propagates to inherited class
// via virtual Initialize() method (see below).
void InitializeBase();
- // Set the prefix used when running CallJs with a method. For example,
- // set_call_js_prefix("Oobe")
- // CallJs("lock") -> Invokes JS global named "Oobe.lock"
- void set_call_js_prefix(const std::string& prefix) {
- js_screen_path_prefix_ = prefix + ".";
- }
-
- void set_async_assets_load_id(const std::string& async_assets_load_id) {
- async_assets_load_id_ = async_assets_load_id;
- }
- const std::string& async_assets_load_id() const {
- return async_assets_load_id_;
- }
-
protected:
// All subclasses should implement this method to provide localized values.
virtual void DeclareLocalizedValues(
@@ -110,110 +58,57 @@ class BaseWebUIHandler : public content::WebUIMessageHandler,
// All subclasses should implement this method to register callbacks for JS
// messages.
- //
- // TODO (ygorshenin, crbug.com/433797): make this method purely vrtual when
- // all screens will be switched to use ScreenContext.
virtual void DeclareJSCallbacks() {}
// Subclasses can override these methods to pass additional parameters
- // to loadTimeData. Generally, it is a bad approach, and it should be replaced
- // with Context at some point.
+ // to loadTimeData.
virtual void GetAdditionalParameters(base::DictionaryValue* parameters);
- void CallJS(const std::string& function_name) {
- if (js_calls_container_->is_initialized()) {
- web_ui()->CallJavascriptFunctionUnsafe(function_name);
- } else {
- js_calls_container_->deferred_js_calls().push_back(
- base::Bind(&BaseWebUIHandler::CallJavascriptFunctionImmediate<>,
- base::Unretained(this), function_name));
- }
- }
-
- template <typename A1>
- void CallJS(const std::string& function_name, const A1& arg1) {
- if (js_calls_container_->is_initialized()) {
- web_ui()->CallJavascriptFunctionUnsafe(function_name,
- ::login::MakeValue(arg1));
- } else {
- js_calls_container_->deferred_js_calls().push_back(base::Bind(
- &BaseWebUIHandler::CallJavascriptFunctionImmediate<base::Value>,
- base::Unretained(this), function_name,
- ::login::MakeValue(arg1).Clone()));
- }
- }
-
- template <typename A1, typename A2>
- void CallJS(const std::string& function_name,
- const A1& arg1,
- const A2& arg2) {
- if (js_calls_container_->is_initialized()) {
- web_ui()->CallJavascriptFunctionUnsafe(
- function_name, ::login::MakeValue(arg1), ::login::MakeValue(arg2));
- } else {
- js_calls_container_->deferred_js_calls().push_back(base::Bind(
- &BaseWebUIHandler::CallJavascriptFunctionImmediate<base::Value,
- base::Value>,
- base::Unretained(this), function_name,
- ::login::MakeValue(arg1).Clone(), ::login::MakeValue(arg2).Clone()));
- }
- }
-
- template <typename A1, typename A2, typename A3>
- void CallJS(const std::string& function_name,
- const A1& arg1,
- const A2& arg2,
- const A3& arg3) {
- if (js_calls_container_->is_initialized()) {
- web_ui()->CallJavascriptFunctionUnsafe(
- function_name, ::login::MakeValue(arg1), ::login::MakeValue(arg2),
- ::login::MakeValue(arg3));
- } else {
- js_calls_container_->deferred_js_calls().push_back(base::Bind(
- &BaseWebUIHandler::CallJavascriptFunctionImmediate<
- base::Value, base::Value, base::Value>,
- base::Unretained(this), function_name,
- ::login::MakeValue(arg1).Clone(), ::login::MakeValue(arg2).Clone(),
- ::login::MakeValue(arg3).Clone()));
+ // Run a JavaScript function. If the backing webui that this handler is not
+ // fully loaded, then the JS call will be deferred and executed after the
+ // initialize message.
+ //
+ // All CallJS invocations can be recorded for tests if CallJS recording is
+ // enabled.
+ template <typename... Args>
+ void CallJS(const std::string& function_name, const Args&... args) {
+ // Record the call if the WebUI is not loaded or if we are in a test.
+ if (!js_calls_container_->is_initialized() ||
+ js_calls_container_->record_all_events_for_test()) {
+ std::vector<base::Value> arguments;
+ InsertIntoList(&arguments, args...);
+ js_calls_container_->events()->emplace_back(
+ JSCallsContainer::Event(JSCallsContainer::Event::Type::kOutgoing,
+ function_name, std::move(arguments)));
}
- }
- template <typename A1, typename A2, typename A3, typename A4>
- void CallJS(const std::string& function_name,
- const A1& arg1,
- const A2& arg2,
- const A3& arg3,
- const A4& arg4) {
- if (js_calls_container_->is_initialized()) {
+ // Make the call now if the WebUI is loaded.
+ if (js_calls_container_->is_initialized())
web_ui()->CallJavascriptFunctionUnsafe(
- function_name, ::login::MakeValue(arg1), ::login::MakeValue(arg2),
- ::login::MakeValue(arg3), ::login::MakeValue(arg4));
- } else {
- js_calls_container_->deferred_js_calls().push_back(base::Bind(
- &BaseWebUIHandler::CallJavascriptFunctionImmediate<
- base::Value, base::Value, base::Value, base::Value>,
- base::Unretained(this), function_name,
- ::login::MakeValue(arg1).Clone(), ::login::MakeValue(arg2).Clone(),
- ::login::MakeValue(arg3).Clone(), ::login::MakeValue(arg4).Clone()));
- }
+ function_name, ::login::MakeValue(args).Clone()...);
}
- // Shortcut methods for adding WebUI callbacks.
+ // Register WebUI callbacks. The callbacks will be recorded if recording is
+ // enabled.
template <typename T>
- void AddRawCallback(const std::string& name,
+ void AddRawCallback(const std::string& function_name,
void (T::*method)(const base::ListValue* args)) {
+ content::WebUI::MessageCallback callback =
+ base::BindRepeating(method, base::Unretained(static_cast<T*>(this)));
web_ui()->RegisterMessageCallback(
- name,
- base::BindRepeating(method, base::Unretained(static_cast<T*>(this))));
+ function_name,
+ base::BindRepeating(&BaseWebUIHandler::OnRawCallback,
+ base::Unretained(this), function_name, callback));
}
-
template <typename T, typename... Args>
- void AddCallback(const std::string& name, void (T::*method)(Args...)) {
+ void AddCallback(const std::string& function_name,
+ void (T::*method)(Args...)) {
base::RepeatingCallback<void(Args...)> callback =
- base::Bind(method, base::Unretained(static_cast<T*>(this)));
+ base::BindRepeating(method, base::Unretained(static_cast<T*>(this)));
web_ui()->RegisterMessageCallback(
- name,
- base::BindRepeating(&::login::CallbackWrapper<Args...>, callback));
+ function_name,
+ base::BindRepeating(&BaseWebUIHandler::OnCallback<Args...>,
+ base::Unretained(this), function_name, callback));
}
// Called when the page is ready and handler can do initialization.
@@ -234,49 +129,49 @@ class BaseWebUIHandler : public content::WebUIMessageHandler,
// Whether page is ready.
bool page_is_ready() const { return page_is_ready_; }
- // Returns the window which shows us.
- virtual gfx::NativeWindow GetNativeWindow();
-
- void SetBaseScreen(BaseScreen* base_screen);
-
private:
friend class OobeUI;
- // This function provides a unique name for every overload of
- // CallJavascriptFunctionUnsafe, allowing it to be used in base::Bind.
+ // InsertIntoList takes a template parameter pack and expands into the
+ // following form:
+ //
+ // for (auto arg : args)
+ // stroage->emplace_back(::login::MakeValue(arg).Clone());
+ //
+ // This cannot be expressed with the current parameter pack expansion rules
+ // and the only way to do it is via compile-time recursion.
+ template <typename Head, typename... Tail>
+ void InsertIntoList(std::vector<base::Value>* storage,
+ const Head& head,
+ const Tail&... tail) {
+ storage->emplace_back(::login::MakeValue(head).Clone());
+ InsertIntoList(storage, tail...);
+ }
+ // Base condition for the recursion, when there are no more elements to
+ // insert. Does nothing.
+ void InsertIntoList(std::vector<base::Value>*);
+
+ // Record |function_name| and |args| as an incoming event if recording is
+ // enabled.
+ void MaybeRecordIncomingEvent(const std::string& function_name,
+ const base::ListValue* args);
+
+ // These two functions wrap Add(Raw)Callback so that the incoming JavaScript
+ // event can be recorded.
+ void OnRawCallback(const std::string& function_name,
+ const content::WebUI::MessageCallback callback,
+ const base::ListValue* args);
template <typename... Args>
- void CallJavascriptFunctionImmediate(const std::string& function_name,
- const Args&... args) {
- web_ui()->CallJavascriptFunctionUnsafe(function_name, args...);
+ void OnCallback(const std::string& function_name,
+ const base::RepeatingCallback<void(Args...)>& callback,
+ const base::ListValue* args) {
+ MaybeRecordIncomingEvent(function_name, args);
+ ::login::CallbackWrapper<Args...>(callback, args);
}
- // Returns full name of JS method based on screen and method names.
- std::string FullMethodPath(const std::string& method) const;
-
- // Handles user action.
- void HandleUserAction(const std::string& action_id);
-
- // Handles situation when screen context is changed.
- void HandleContextChanged(const base::DictionaryValue* diff);
-
// Keeps whether page is ready.
bool page_is_ready_ = false;
- BaseScreen* base_screen_ = nullptr;
-
- // Full name of the corresponding JS screen object. Can be empty, if
- // there are no corresponding screen object or several different
- // objects.
- std::string js_screen_path_prefix_;
-
- // The string id used in the async asset load in JS. If it is set to a
- // non empty value, the Initialize will be deferred until the underlying load
- // is finished.
- std::string async_assets_load_id_;
-
- // Pending changes to context which will be sent when the page will be ready.
- base::DictionaryValue pending_context_changes_;
-
JSCallsContainer* js_calls_container_ = nullptr; // non-owning pointers.
DISALLOW_COPY_AND_ASSIGN(BaseWebUIHandler);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
index 85c395cc24b..8dd92f5554b 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
@@ -62,8 +62,6 @@ namespace chromeos {
namespace {
-const char kJsScreenPath[] = "cr.ui.Oobe";
-
bool IsRemoraRequisition() {
policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
g_browser_process->platform_part()
@@ -94,7 +92,6 @@ CoreOobeHandler::CoreOobeHandler(JSCallsContainer* js_calls_container)
version_info_updater_(this),
weak_ptr_factory_(this) {
DCHECK(js_calls_container);
- set_call_js_prefix(kJsScreenPath);
AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
CHECK(accessibility_manager);
accessibility_subscription_ = accessibility_manager->RegisterCallback(
@@ -208,7 +205,6 @@ void CoreOobeHandler::RegisterMessages() {
&CoreOobeHandler::HandleEnableDockedMagnifier);
AddCallback("setDeviceRequisition",
&CoreOobeHandler::HandleSetDeviceRequisition);
- AddCallback("screenAssetsLoaded", &CoreOobeHandler::HandleScreenAssetsLoaded);
AddRawCallback("skipToLoginForTesting",
&CoreOobeHandler::HandleSkipToLoginForTesting);
AddCallback("skipToUpdateForTesting",
@@ -217,7 +213,6 @@ void CoreOobeHandler::RegisterMessages() {
AddCallback("toggleResetScreen", &CoreOobeHandler::HandleToggleResetScreen);
AddCallback("toggleEnableDebuggingScreen",
&CoreOobeHandler::HandleEnableDebuggingScreen);
- AddCallback("headerBarVisible", &CoreOobeHandler::HandleHeaderBarVisible);
AddCallback("raiseTabKeyEvent", &CoreOobeHandler::HandleRaiseTabKeyEvent);
// Note: Used by enterprise_RemoraRequisitionDisplayUsage.py:
// TODO(felixe): Use chrome.system.display or cros_display_config.mojom,
@@ -303,10 +298,6 @@ void CoreOobeHandler::ReloadEulaContent(
CallJS("cr.ui.Oobe.reloadEulaContent", dictionary);
}
-void CoreOobeHandler::ShowControlBar(bool show) {
- CallJS("cr.ui.Oobe.showControlBar", show);
-}
-
void CoreOobeHandler::SetVirtualKeyboardShown(bool shown) {
CallJS("cr.ui.Oobe.setVirtualKeyboardShown", shown);
}
@@ -402,11 +393,6 @@ void CoreOobeHandler::HandleSetDeviceRequisition(
}
}
-void CoreOobeHandler::HandleScreenAssetsLoaded(
- const std::string& screen_async_load_id) {
- GetOobeUI()->OnScreenAssetsLoaded(screen_async_load_id);
-}
-
void CoreOobeHandler::HandleSkipToLoginForTesting(const base::ListValue* args) {
LoginScreenContext context;
@@ -479,11 +465,6 @@ void CoreOobeHandler::ShowOobeUI(bool show) {
UpdateOobeUIVisibility();
}
-void CoreOobeHandler::UpdateShutdownAndRebootVisibility(
- bool reboot_on_shutdown) {
- CallJS("cr.ui.Oobe.showShutdown", !reboot_on_shutdown);
-}
-
void CoreOobeHandler::SetLoginUserCount(int user_count) {
CallJS("cr.ui.Oobe.setLoginUserCount", user_count);
}
@@ -584,7 +565,6 @@ void CoreOobeHandler::UpdateKeyboardState() {
if (!features::IsUsingWindowService()) {
const bool is_keyboard_shown =
ChromeKeyboardControllerClient::Get()->is_keyboard_visible();
- ShowControlBar(!is_keyboard_shown);
SetVirtualKeyboardShown(is_keyboard_shown);
}
}
@@ -618,17 +598,12 @@ void CoreOobeHandler::OnAccessibilityStatusChanged(
void CoreOobeHandler::HandleLaunchHelpApp(double help_topic_id) {
if (!help_app_.get())
- help_app_ = new HelpAppLauncher(GetNativeWindow());
+ help_app_ = new HelpAppLauncher(
+ LoginDisplayHost::default_host()->GetNativeWindow());
help_app_->ShowHelpTopic(
static_cast<HelpAppLauncher::HelpTopic>(help_topic_id));
}
-void CoreOobeHandler::HandleHeaderBarVisible() {
- LoginDisplayHost* login_display_host = LoginDisplayHost::default_host();
- if (login_display_host)
- login_display_host->SetStatusAreaVisible(true);
-}
-
void CoreOobeHandler::HandleRaiseTabKeyEvent(bool reverse) {
ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_TAB, ui::EF_NONE);
if (reverse)
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 324e0f93d03..815091d2f96 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
@@ -104,7 +104,6 @@ class CoreOobeHandler : public BaseWebUIHandler,
void ClearErrors() override;
void ReloadContent(const base::DictionaryValue& dictionary) override;
void ReloadEulaContent(const base::DictionaryValue& dictionary) override;
- void ShowControlBar(bool show) override;
void SetVirtualKeyboardShown(bool displayed) override;
void SetClientAreaSize(int width, int height) override;
void ShowDeviceResetScreen() override;
@@ -134,13 +133,11 @@ class CoreOobeHandler : public BaseWebUIHandler,
void HandleSkipUpdateEnrollAfterEula();
void HandleUpdateCurrentScreen(const std::string& screen);
void HandleSetDeviceRequisition(const std::string& requisition);
- void HandleScreenAssetsLoaded(const std::string& screen_async_load_id);
void HandleSkipToLoginForTesting(const base::ListValue* args);
void HandleSkipToUpdateForTesting();
void HandleLaunchHelpApp(double help_topic_id);
void HandleToggleResetScreen();
void HandleEnableDebuggingScreen();
- void HandleHeaderBarVisible();
void HandleSetOobeBootstrappingSlave();
void HandleGetPrimaryDisplayNameForTesting(const base::ListValue* args);
void GetPrimaryDisplayNameCallback(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc
index 74b95b90224..1c7189648e2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.cc
@@ -9,18 +9,12 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-constexpr char kJsScreenPath[] = "login.DemoPreferencesScreen";
-
-} // namespace
-
namespace chromeos {
DemoPreferencesScreenHandler::DemoPreferencesScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.DemoPreferencesScreen.userActed");
}
DemoPreferencesScreenHandler::~DemoPreferencesScreenHandler() {
@@ -39,6 +33,12 @@ void DemoPreferencesScreenHandler::Bind(DemoPreferencesScreen* screen) {
BaseScreenHandler::SetBaseScreen(screen);
}
+void DemoPreferencesScreenHandler::SetInputMethodId(
+ const std::string& input_method) {
+ CallJS("login.DemoPreferencesScreen.setInputMethodIdFromBackend",
+ input_method);
+}
+
void DemoPreferencesScreenHandler::Initialize() {}
void DemoPreferencesScreenHandler::DeclareLocalizedValues(
@@ -55,4 +55,31 @@ void DemoPreferencesScreenHandler::DeclareLocalizedValues(
builder->Add("countryDropdownLabel", IDS_COUNTRY_DROPDOWN_LABEL);
}
+void DemoPreferencesScreenHandler::DeclareJSCallbacks() {
+ AddCallback("DemoPreferencesScreen.setLocaleId",
+ &DemoPreferencesScreenHandler::HandleSetLocaleId);
+ AddCallback("DemoPreferencesScreen.setInputMethodId",
+ &DemoPreferencesScreenHandler::HandleSetInputMethodId);
+ AddCallback("DemoPreferencesScreen.setDemoModeCountry",
+ &DemoPreferencesScreenHandler::HandleSetDemoModeCountry);
+}
+
+void DemoPreferencesScreenHandler::HandleSetLocaleId(
+ const std::string& language_id) {
+ if (screen_)
+ screen_->SetLocale(language_id);
+}
+
+void DemoPreferencesScreenHandler::HandleSetInputMethodId(
+ const std::string& input_method_id) {
+ if (screen_)
+ screen_->SetInputMethod(input_method_id);
+}
+
+void DemoPreferencesScreenHandler::HandleSetDemoModeCountry(
+ const std::string& country_id) {
+ if (screen_)
+ screen_->SetDemoModeCountry(country_id);
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h
index 334a8c2383e..67cb16e2a68 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/demo_preferences_screen_handler.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEMO_PREFERENCES_SCREEN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEMO_PREFERENCES_SCREEN_HANDLER_H_
+#include <string>
+
#include "chrome/browser/chromeos/login/screens/demo_preferences_screen_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
@@ -23,13 +25,19 @@ class DemoPreferencesScreenHandler : public BaseScreenHandler,
void Show() override;
void Hide() override;
void Bind(DemoPreferencesScreen* screen) override;
+ void SetInputMethodId(const std::string& input_method) override;
// BaseScreenHandler:
void Initialize() override;
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
+ void DeclareJSCallbacks() override;
private:
+ void HandleSetLocaleId(const std::string& language_id);
+ void HandleSetInputMethodId(const std::string& language_id);
+ void HandleSetDemoModeCountry(const std::string& country_id);
+
DemoPreferencesScreen* screen_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(DemoPreferencesScreenHandler);
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 41ed07ea4f2..13f49e44eab 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
@@ -12,18 +12,12 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-constexpr char kJsScreenPath[] = "login.DemoSetupScreen";
-
-} // namespace
-
namespace chromeos {
DemoSetupScreenHandler::DemoSetupScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.DemoSetupScreen.userActed");
}
DemoSetupScreenHandler::~DemoSetupScreenHandler() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc
index 1eb016f8a0c..799463ef898 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/device_disabled_screen_handler.cc
@@ -9,18 +9,11 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-const char kJsScreenPath[] = "login.DeviceDisabledScreen";
-
-} // namespace
-
namespace chromeos {
DeviceDisabledScreenHandler::DeviceDisabledScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
}
DeviceDisabledScreenHandler::~DeviceDisabledScreenHandler() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc
index f65d9146088..f3d17c9f2a2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.cc
@@ -4,18 +4,9 @@
#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h"
-namespace {
-
-const char kDiscoverJsPrefix[] = "discover.";
-
-} // namespace
-
namespace chromeos {
-DiscoverHandler::DiscoverHandler(const std::string& screen_name,
- JSCallsContainer* js_calls_container)
- : BaseWebUIHandler(js_calls_container) {
- set_call_js_prefix(kDiscoverJsPrefix + screen_name);
-}
+DiscoverHandler::DiscoverHandler(JSCallsContainer* js_calls_container)
+ : BaseWebUIHandler(js_calls_container) {}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h
index 1793e28d4ab..b72962e2a1d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h
@@ -15,8 +15,7 @@ namespace chromeos {
// Base class for Discover modules WebUI message handler.
class DiscoverHandler : public BaseWebUIHandler {
public:
- DiscoverHandler(const std::string& module_name,
- JSCallsContainer* js_calls_container);
+ explicit DiscoverHandler(JSCallsContainer* js_calls_container);
~DiscoverHandler() override = default;
private:
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc
index e1d4de0452c..9074fdcfb1d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_ui.cc
@@ -100,7 +100,7 @@ void DiscoverUI::GetAdditionalParameters(base::DictionaryValue* dict) {
void DiscoverUI::Initialize() {
for (Observer& observer : observers_)
observer.OnInitialized();
- js_calls_container_.ExecuteDeferredJSCalls();
+ js_calls_container_.ExecuteDeferredJSCalls(web_ui_);
}
void DiscoverUI::Show() {}
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
index 39268c45e77..1617526e79f 100644
--- 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
@@ -37,8 +37,7 @@ class DiscoverModuleLaunchHelpAppHandler : public DiscoverHandler {
DiscoverModuleLaunchHelpAppHandler::DiscoverModuleLaunchHelpAppHandler(
JSCallsContainer* js_calls_container)
- : DiscoverHandler(DiscoverModuleLaunchHelpApp::kModuleName,
- js_calls_container) {}
+ : DiscoverHandler(js_calls_container) {}
void DiscoverModuleLaunchHelpAppHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc
index f33be2524e7..b43a2040cf9 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc
@@ -50,7 +50,7 @@ class DiscoverModulePinSetupHandler : public DiscoverHandler {
DiscoverModulePinSetupHandler::DiscoverModulePinSetupHandler(
base::WeakPtr<DiscoverModulePinSetup> module,
JSCallsContainer* js_calls_container)
- : DiscoverHandler(DiscoverModulePinSetup::kModuleName, js_calls_container),
+ : DiscoverHandler(js_calls_container),
module_(module),
weak_factory_(this) {}
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
index ebac5c3add2..2368cb9767b 100644
--- 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
@@ -31,8 +31,7 @@ class DiscoverModuleRedeemOffersHandler : public DiscoverHandler {
DiscoverModuleRedeemOffersHandler::DiscoverModuleRedeemOffersHandler(
JSCallsContainer* js_calls_container)
- : DiscoverHandler(DiscoverModuleRedeemOffers::kModuleName,
- js_calls_container) {}
+ : DiscoverHandler(js_calls_container) {}
void DiscoverModuleRedeemOffersHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_set_wallpaper.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_set_wallpaper.cc
index 412b34e4c5b..302aaee430a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_set_wallpaper.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_set_wallpaper.cc
@@ -35,8 +35,7 @@ class DiscoverModuleSetWallpaperHandler : public DiscoverHandler {
DiscoverModuleSetWallpaperHandler::DiscoverModuleSetWallpaperHandler(
JSCallsContainer* js_calls_container)
- : DiscoverHandler(DiscoverModuleSetWallpaper::kModuleName,
- js_calls_container) {}
+ : DiscoverHandler(js_calls_container) {}
void DiscoverModuleSetWallpaperHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
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
index af6248307d9..da7e72eb649 100644
--- 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
@@ -30,8 +30,7 @@ class DiscoverModuleSyncFilesHandler : public DiscoverHandler {
DiscoverModuleSyncFilesHandler::DiscoverModuleSyncFilesHandler(
JSCallsContainer* js_calls_container)
- : DiscoverHandler(DiscoverModuleSyncFiles::kModuleName,
- js_calls_container) {}
+ : DiscoverHandler(js_calls_container) {}
void DiscoverModuleSyncFilesHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
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 2eb387ed874..6ee59675fb7 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
@@ -30,7 +30,7 @@ class DiscoverModuleWelcomeHandler : public DiscoverHandler {
DiscoverModuleWelcomeHandler::DiscoverModuleWelcomeHandler(
JSCallsContainer* js_calls_container)
- : DiscoverHandler(DiscoverModuleWelcome::kModuleName, js_calls_container) {}
+ : DiscoverHandler(js_calls_container) {}
void DiscoverModuleWelcomeHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover_screen_handler.cc
index 7bd59779b1d..520c7c1f7e2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/discover_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover_screen_handler.cc
@@ -6,18 +6,12 @@
#include "chrome/browser/chromeos/login/screens/discover_screen.h"
-namespace {
-
-const char kJsScreenPath[] = "login.DiscoverScreen";
-
-} // namespace
-
namespace chromeos {
DiscoverScreenHandler::DiscoverScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.DiscoverScreen.userActed");
}
DiscoverScreenHandler::~DiscoverScreenHandler() {}
@@ -26,7 +20,7 @@ void DiscoverScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {}
void DiscoverScreenHandler::RegisterMessages() {
- BaseWebUIHandler::RegisterMessages();
+ BaseScreenHandler::RegisterMessages();
discover_ui_.RegisterMessages(web_ui());
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc
index 0db2527cf58..675b9ba5791 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.cc
@@ -11,16 +11,19 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
+#include "chrome/browser/chromeos/login/screens/enable_debugging_screen.h"
+#include "chrome/browser/chromeos/login/screens/enable_debugging_screen_view.h"
+#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/login_web_dialog.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_switches.h"
-#include "chromeos/dbus/cryptohome_client.h"
+#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon_client.h"
-#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/dbus/power/power_manager_client.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
@@ -28,24 +31,17 @@
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"
-namespace {
-
-const char kJsScreenPath[] = "login.EnableDebuggingScreen";
-
-} // namespace
-
namespace chromeos {
EnableDebuggingScreenHandler::EnableDebuggingScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container),
weak_ptr_factory_(this) {
- set_call_js_prefix(kJsScreenPath);
}
EnableDebuggingScreenHandler::~EnableDebuggingScreenHandler() {
- if (delegate_)
- delegate_->OnViewDestroyed(this);
+ if (screen_)
+ screen_->OnViewDestroyed(this);
}
void EnableDebuggingScreenHandler::ShowWithParams() {
@@ -56,8 +52,7 @@ void EnableDebuggingScreenHandler::ShowWithParams() {
DVLOG(1) << "Showing enable debugging screen.";
// Wait for cryptohomed before checking debugd. See http://crbug.com/440506.
- chromeos::CryptohomeClient* client =
- chromeos::DBusThreadManager::Get()->GetCryptohomeClient();
+ chromeos::CryptohomeClient* client = chromeos::CryptohomeClient::Get();
client->WaitForServiceToBeAvailable(base::Bind(
&EnableDebuggingScreenHandler::OnCryptohomeDaemonAvailabilityChecked,
weak_ptr_factory_.GetWeakPtr()));
@@ -76,8 +71,8 @@ void EnableDebuggingScreenHandler::Hide() {
weak_ptr_factory_.InvalidateWeakPtrs();
}
-void EnableDebuggingScreenHandler::SetDelegate(Delegate* delegate) {
- delegate_ = delegate;
+void EnableDebuggingScreenHandler::SetDelegate(EnableDebuggingScreen* screen) {
+ screen_ = screen;
if (page_is_ready())
Initialize();
}
@@ -127,7 +122,7 @@ void EnableDebuggingScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
}
void EnableDebuggingScreenHandler::Initialize() {
- if (!page_is_ready() || !delegate_)
+ if (!page_is_ready() || !screen_)
return;
if (show_on_init_) {
@@ -150,13 +145,13 @@ void EnableDebuggingScreenHandler::RegisterMessages() {
}
void EnableDebuggingScreenHandler::HandleOnCancel() {
- if (delegate_)
- delegate_->OnExit(false);
+ if (screen_)
+ screen_->OnExit(false);
}
void EnableDebuggingScreenHandler::HandleOnDone() {
- if (delegate_)
- delegate_->OnExit(true);
+ if (screen_)
+ screen_->OnExit(true);
}
void EnableDebuggingScreenHandler::HandleOnRemoveRootFSProtection() {
@@ -283,12 +278,10 @@ void EnableDebuggingScreenHandler::HandleOnLearnMore() {
l10n_util::GetStringUTF8(IDS_ENABLE_DEBUGGING_HELP);
const GURL data_url = GURL("data:text/html;charset=utf-8," + help_content);
- LoginWebDialog* dialog = new LoginWebDialog(
- Profile::FromWebUI(web_ui()),
- NULL,
- GetNativeWindow(),
- base::string16(),
- data_url);
+ LoginWebDialog* dialog =
+ new LoginWebDialog(Profile::FromWebUI(web_ui()), NULL,
+ LoginDisplayHost::default_host()->GetNativeWindow(),
+ base::string16(), data_url);
dialog->Show();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h
index 34c4ee84f48..222824208fb 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h
@@ -27,7 +27,7 @@ class EnableDebuggingScreenHandler : public EnableDebuggingScreenView,
// EnableDebuggingScreenView implementation:
void Show() override;
void Hide() override;
- void SetDelegate(Delegate* delegate) override;
+ void SetDelegate(EnableDebuggingScreen* screen) override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
@@ -76,7 +76,7 @@ class EnableDebuggingScreenHandler : public EnableDebuggingScreenView,
// Updates UI state.
void UpdateUIState(UIState state);
- Delegate* delegate_ = nullptr;
+ EnableDebuggingScreen* screen_ = nullptr;
// Keeps whether screen should be shown right after initialization.
bool show_on_init_ = false;
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 49d1fcd5ca3..57d39302423 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
@@ -30,11 +30,11 @@
#include "chromeos/cryptohome/async_method_caller.h"
#include "chromeos/cryptohome/cryptohome_util.h"
#include "chromeos/cryptohome/homedir_methods.h"
-#include "chromeos/dbus/cryptohome_client.h"
+#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/power/power_manager_client.h"
+#include "chromeos/dbus/power/power_policy_controller.h"
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
-#include "chromeos/dbus/power_manager_client.h"
-#include "chromeos/dbus/power_policy_controller.h"
#include "components/login/localized_values_builder.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
@@ -49,8 +49,6 @@
namespace {
-constexpr char kJsScreenPath[] = "login.EncryptionMigrationScreen";
-
// Path to the mount point to check the available space.
constexpr char kCheckStoragePath[] = "/home";
@@ -259,13 +257,12 @@ EncryptionMigrationScreenHandler::EncryptionMigrationScreenHandler(
: BaseScreenHandler(kScreenId, js_calls_container),
tick_clock_(base::DefaultTickClock::GetInstance()),
weak_ptr_factory_(this) {
- set_call_js_prefix(kJsScreenPath);
free_disk_space_fetcher_ = base::Bind(&base::SysInfo::AmountOfFreeDiskSpace,
base::FilePath(kCheckStoragePath));
}
EncryptionMigrationScreenHandler::~EncryptionMigrationScreenHandler() {
- DBusThreadManager::Get()->GetCryptohomeClient()->RemoveObserver(this);
+ CryptohomeClient::Get()->RemoveObserver(this);
PowerManagerClient::Get()->RemoveObserver(this);
if (delegate_)
delegate_->OnViewDestroyed(this);
@@ -578,7 +575,7 @@ void EncryptionMigrationScreenHandler::StartMigration() {
} else {
auth_request = CreateAuthorizationRequest();
}
- DBusThreadManager::Get()->GetCryptohomeClient()->MountEx(
+ CryptohomeClient::Get()->MountEx(
cryptohome::CreateAccountIdentifierFromAccountId(
user_context_.GetAccountId()),
auth_request, mount,
@@ -605,8 +602,8 @@ void EncryptionMigrationScreenHandler::OnMountExistingVault(
cryptohome::MigrateToDircryptoRequest request;
request.set_minimal_migration(IsMinimalMigration());
- DBusThreadManager::Get()->GetCryptohomeClient()->AddObserver(this);
- DBusThreadManager::Get()->GetCryptohomeClient()->MigrateToDircrypto(
+ CryptohomeClient::Get()->AddObserver(this);
+ CryptohomeClient::Get()->MigrateToDircrypto(
cryptohome::CreateAccountIdentifierFromAccountId(
user_context_.GetAccountId()),
request,
@@ -653,7 +650,7 @@ void EncryptionMigrationScreenHandler::RemoveCryptohome() {
cryptohome::AccountIdentifier account_id_proto;
account_id_proto.set_account_id(cryptohome_id.id());
- DBusThreadManager::Get()->GetCryptohomeClient()->RemoveEx(
+ CryptohomeClient::Get()->RemoveEx(
account_id_proto,
base::BindOnce(&EncryptionMigrationScreenHandler::OnRemoveCryptohome,
weak_ptr_factory_.GetWeakPtr()));
@@ -714,7 +711,7 @@ void EncryptionMigrationScreenHandler::DircryptoMigrationProgress(
RecordMigrationResultSuccess(IsResumingIncompleteMigration(),
IsArcKiosk());
// Stop listening to the progress updates.
- DBusThreadManager::Get()->GetCryptohomeClient()->RemoveObserver(this);
+ CryptohomeClient::Get()->RemoveObserver(this);
// If the battery level decreased during migration, record the consumed
// battery level.
if (current_battery_percent_ &&
@@ -751,7 +748,7 @@ void EncryptionMigrationScreenHandler::DircryptoMigrationProgress(
RecordMigrationResultGeneralFailure(IsResumingIncompleteMigration(),
IsArcKiosk());
// Stop listening to the progress updates.
- DBusThreadManager::Get()->GetCryptohomeClient()->RemoveObserver(this);
+ CryptohomeClient::Get()->RemoveObserver(this);
// Shows error screen after removing user directory is completed.
RemoveCryptohome();
break;
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 35364a39376..8e2c0c1bbca 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
@@ -15,9 +15,9 @@
#include "chrome/browser/chromeos/login/screens/encryption_migration_screen_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
+#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/cryptohome/rpc.pb.h"
-#include "chromeos/dbus/cryptohome_client.h"
-#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/login/auth/user_context.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
#include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h"
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 acdcf14933b..081fdff1bfb 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
@@ -16,11 +16,10 @@
#include "chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h"
#include "chromeos/cryptohome/homedir_methods.h"
#include "chromeos/cryptohome/mock_async_method_caller.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#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/dbus/cryptohome/account_identifier_operators.h"
+#include "chromeos/dbus/cryptohome/fake_cryptohome_client.h"
+#include "chromeos/dbus/power/fake_power_manager_client.h"
+#include "chromeos/dbus/power/power_policy_controller.h"
#include "chromeos/login/auth/key.h"
#include "chromeos/login/auth/user_context.h"
#include "components/account_id/account_id.h"
@@ -129,14 +128,10 @@ class EncryptionMigrationScreenHandlerTest : public testing::Test {
cryptohome::AsyncMethodCaller::InitializeForTesting(
mock_async_method_caller_);
- // Set up fake DBusThreadManager parts.
- fake_cryptohome_client_ = new FakeCryptohomeClient();
- DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient(
- base::WrapUnique<CryptohomeClient>(fake_cryptohome_client_));
-
- PowerManagerClient::Initialize();
-
- DBusThreadManager::Initialize();
+ // Set up fake dbus clients.
+ CryptohomeClient::InitializeFake();
+ fake_cryptohome_client_ = FakeCryptohomeClient::Get();
+ PowerManagerClient::InitializeFake();
PowerPolicyController::Initialize(PowerManagerClient::Get());
@@ -145,7 +140,7 @@ class EncryptionMigrationScreenHandlerTest : public testing::Test {
user_context_.SetKey(
Key(Key::KeyType::KEY_TYPE_SALTED_SHA256, "salt", "secret"));
- js_calls_container_.ExecuteDeferredJSCalls();
+ js_calls_container_.ExecuteDeferredJSCalls(&test_web_ui_);
encryption_migration_screen_handler_ =
std::make_unique<TestEncryptionMigrationScreenHandler>(
&js_calls_container_);
@@ -165,8 +160,8 @@ class EncryptionMigrationScreenHandlerTest : public testing::Test {
encryption_migration_screen_handler_.reset();
PowerPolicyController::Shutdown();
- DBusThreadManager::Shutdown();
PowerManagerClient::Shutdown();
+ CryptohomeClient::Shutdown();
cryptohome::AsyncMethodCaller::Shutdown();
}
@@ -175,7 +170,7 @@ class EncryptionMigrationScreenHandlerTest : public testing::Test {
base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_enabler_;
- FakeCryptohomeClient* fake_cryptohome_client_ = nullptr;
+ FakeCryptohomeClient* fake_cryptohome_client_ = nullptr; // unowned
cryptohome::MockAsyncMethodCaller* mock_async_method_caller_ = nullptr;
JSCallsContainer js_calls_container_;
std::unique_ptr<TestEncryptionMigrationScreenHandler>
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 45984e0ff00..bb90faa49a0 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
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
#include <algorithm>
+#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -17,11 +18,13 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
+#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h"
#include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/network_error.h"
#include "chrome/browser/chromeos/login/signin_partition_manager.h"
+#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
@@ -29,7 +32,6 @@
#include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/login/auth/authpolicy_login_helper.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "components/login/localized_values_builder.h"
@@ -45,8 +47,6 @@
namespace chromeos {
namespace {
-const char kJsScreenPath[] = "login.OAuthEnrollmentScreen";
-
// Enrollment step names.
const char kEnrollmentStepSignin[] = "signin";
const char kEnrollmentStepAdJoin[] = "ad-join";
@@ -139,21 +139,21 @@ constexpr struct {
IDS_AD_ENCRYPTION_LEGACY_SUBTITLE,
authpolicy::KerberosEncryptionTypes::ENC_TYPES_LEGACY}};
-std::unique_ptr<base::ListValue> GetEncryptionTypesList() {
+base::ListValue GetEncryptionTypesList() {
const authpolicy::KerberosEncryptionTypes default_types =
authpolicy::KerberosEncryptionTypes::ENC_TYPES_STRONG;
- auto encryption_list = std::make_unique<base::ListValue>();
+ base::ListValue encryption_list;
for (const auto& enc_types : kEncryptionTypes) {
- auto enc_option = std::make_unique<base::DictionaryValue>();
- enc_option->SetKey(
+ base::DictionaryValue enc_option;
+ enc_option.SetKey(
"title", base::Value(l10n_util::GetStringUTF16(enc_types.title_id)));
- enc_option->SetKey(
+ enc_option.SetKey(
"subtitle",
base::Value(l10n_util::GetStringUTF16(enc_types.subtitle_id)));
- enc_option->SetKey("value", base::Value(enc_types.id));
- enc_option->SetKey(
- "selected", base::Value(default_types == enc_types.encryption_types));
- encryption_list->Append(std::move(enc_option));
+ enc_option.SetKey("value", base::Value(enc_types.id));
+ enc_option.SetKey("selected",
+ base::Value(default_types == enc_types.encryption_types));
+ encryption_list.GetList().emplace_back(std::move(enc_option));
}
return encryption_list;
}
@@ -181,8 +181,6 @@ EnrollmentScreenHandler::EnrollmentScreenHandler(
error_screen_(error_screen),
histogram_helper_(new ErrorScreensHistogramHelper("Enrollment")),
weak_ptr_factory_(this) {
- set_call_js_prefix(kJsScreenPath);
- set_async_assets_load_id(GetOobeScreenName(kScreenId));
DCHECK(network_state_informer_.get());
DCHECK(error_screen_);
network_state_informer_->AddObserver(this);
@@ -262,7 +260,6 @@ void EnrollmentScreenHandler::ShowActiveDirectoryScreen(
if (!domain_join_config.empty()) {
active_directory_domain_join_config_ = domain_join_config;
- show_unlock_password_ = true;
active_directory_join_type_ =
ActiveDirectoryDomainJoinType::NOT_USING_CONFIGURATION;
}
@@ -271,7 +268,8 @@ void EnrollmentScreenHandler::ShowActiveDirectoryScreen(
CallJS("login.OAuthEnrollmentScreen.setAdJoinParams",
std::string() /* machineName */, std::string() /* userName */,
static_cast<int>(ActiveDirectoryErrorState::NONE),
- show_unlock_password_);
+ !active_directory_domain_join_config_
+ .empty() /* show_unlock_password */);
ShowStep(kEnrollmentStepAdJoin);
return;
}
@@ -284,28 +282,28 @@ void EnrollmentScreenHandler::ShowActiveDirectoryScreen(
CallJS("login.OAuthEnrollmentScreen.setAdJoinParams", machine_name,
username,
static_cast<int>(ActiveDirectoryErrorState::BAD_USERNAME),
- show_unlock_password_);
+ false /* show_unlock_password */);
ShowStep(kEnrollmentStepAdJoin);
return;
case authpolicy::ERROR_BAD_PASSWORD:
CallJS("login.OAuthEnrollmentScreen.setAdJoinParams", machine_name,
username,
static_cast<int>(ActiveDirectoryErrorState::BAD_AUTH_PASSWORD),
- show_unlock_password_);
+ false /* show_unlock_password */);
ShowStep(kEnrollmentStepAdJoin);
return;
case authpolicy::ERROR_MACHINE_NAME_TOO_LONG:
CallJS("login.OAuthEnrollmentScreen.setAdJoinParams", machine_name,
username,
static_cast<int>(ActiveDirectoryErrorState::MACHINE_NAME_TOO_LONG),
- show_unlock_password_);
+ false /* show_unlock_password */);
ShowStep(kEnrollmentStepAdJoin);
return;
case authpolicy::ERROR_INVALID_MACHINE_NAME:
CallJS("login.OAuthEnrollmentScreen.setAdJoinParams", machine_name,
username,
static_cast<int>(ActiveDirectoryErrorState::MACHINE_NAME_INVALID),
- show_unlock_password_);
+ false /* show_unlock_password */);
ShowStep(kEnrollmentStepAdJoin);
return;
case authpolicy::ERROR_PASSWORD_EXPIRED:
@@ -619,7 +617,7 @@ void EnrollmentScreenHandler::DeclareLocalizedValues(
void EnrollmentScreenHandler::GetAdditionalParameters(
base::DictionaryValue* parameters) {
- parameters->Set("encryptionTypesList", GetEncryptionTypesList());
+ parameters->SetKey("encryptionTypesList", GetEncryptionTypesList());
}
bool EnrollmentScreenHandler::IsOnEnrollmentScreen() const {
@@ -637,17 +635,18 @@ void EnrollmentScreenHandler::OnAdConfigurationUnlocked(
CallJS("login.OAuthEnrollmentScreen.setAdJoinParams",
std::string() /* machineName */, std::string() /* userName */,
static_cast<int>(ActiveDirectoryErrorState::BAD_UNLOCK_PASSWORD),
- show_unlock_password_);
+ true /* show_unlock_password */);
return;
}
- std::unique_ptr<base::ListValue> options =
- base::ListValue::From(base::JSONReader::ReadDeprecated(
- unlocked_data, base::JSONParserOptions::JSON_ALLOW_TRAILING_COMMAS));
- if (!options) {
+ active_directory_domain_join_config_.clear();
+ base::Optional<base::Value> options = base::JSONReader::Read(
+ unlocked_data, base::JSONParserOptions::JSON_ALLOW_TRAILING_COMMAS);
+ if (!options || !options->is_list()) {
ShowError(IDS_AD_JOIN_CONFIG_NOT_PARSED, true);
- show_unlock_password_ = false;
- CallJS("login.OAuthEnrollmentScreen.setAdJoinConfiguration",
- base::ListValue());
+ CallJS("login.OAuthEnrollmentScreen.setAdJoinParams",
+ std::string() /* machineName */, std::string() /* userName */,
+ static_cast<int>(ActiveDirectoryErrorState::NONE),
+ false /* show_unlock_password */);
return;
}
base::DictionaryValue custom;
@@ -655,7 +654,6 @@ void EnrollmentScreenHandler::OnAdConfigurationUnlocked(
"name",
base::Value(l10n_util::GetStringUTF8(IDS_AD_CONFIG_SELECTION_CUSTOM)));
options->GetList().push_back(std::move(custom));
- show_unlock_password_ = false;
active_directory_join_type_ =
ActiveDirectoryDomainJoinType::USING_CONFIGURATION;
CallJS("login.OAuthEnrollmentScreen.setAdJoinConfiguration", *options);
@@ -805,7 +803,8 @@ void EnrollmentScreenHandler::HandleCompleteLogin(const std::string& user) {
void EnrollmentScreenHandler::OnGetCookiesForCompleteLogin(
const std::string& user,
- const std::vector<net::CanonicalCookie>& cookies) {
+ const std::vector<net::CanonicalCookie>& cookies,
+ const net::CookieStatusList& excluded_cookies) {
std::string auth_code;
for (const auto& cookie : cookies) {
if (cookie.Name() == "oauth_code") {
@@ -827,7 +826,6 @@ void EnrollmentScreenHandler::HandleAdCompleteLogin(
const std::string& user_name,
const std::string& password) {
observe_network_failure_ = false;
- show_unlock_password_ = false;
DCHECK(controller_);
controller_->OnActiveDirectoryCredsProvided(
machine_name, distinguished_name,
@@ -836,7 +834,7 @@ void EnrollmentScreenHandler::HandleAdCompleteLogin(
void EnrollmentScreenHandler::HandleAdUnlockConfiguration(
const std::string& password) {
- AuthPolicyLoginHelper::DecryptConfiguration(
+ AuthPolicyHelper::DecryptConfiguration(
active_directory_domain_join_config_, password,
base::BindOnce(&EnrollmentScreenHandler::OnAdConfigurationUnlocked,
weak_ptr_factory_.GetWeakPtr()));
@@ -862,7 +860,8 @@ void EnrollmentScreenHandler::HandleDeviceAttributesProvided(
void EnrollmentScreenHandler::HandleOnLearnMore() {
if (!help_app_.get())
- help_app_ = new HelpAppLauncher(GetNativeWindow());
+ help_app_ = new HelpAppLauncher(
+ LoginDisplayHost::default_host()->GetNativeWindow());
help_app_->ShowHelpTopic(HelpAppLauncher::HELP_DEVICE_ATTRIBUTES);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
index aa5bf675b13..1c3e6cf860a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
@@ -7,6 +7,7 @@
#include <memory>
#include <string>
+#include <vector>
#include "base/macros.h"
#include "chrome/browser/chromeos/login/enrollment/enrollment_screen_view.h"
@@ -104,7 +105,8 @@ class EnrollmentScreenHandler
void HandleCompleteLogin(const std::string& user);
void OnGetCookiesForCompleteLogin(
const std::string& user,
- const std::vector<net::CanonicalCookie>& cookies);
+ const std::vector<net::CanonicalCookie>& cookies,
+ const net::CookieStatusList& excluded_cookies);
void HandleAdCompleteLogin(const std::string& machine_name,
const std::string& distinguished_name,
const std::string& encryption_types,
@@ -170,9 +172,6 @@ class EnrollmentScreenHandler
ActiveDirectoryDomainJoinType active_directory_join_type_ =
ActiveDirectoryDomainJoinType::COUNT;
- // Whether unlock password input step should be shown.
- bool show_unlock_password_ = false;
-
// True if screen was not shown yet.
bool first_show_ = true;
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 3a51ef9ecae..1ed2833fb60 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
@@ -13,18 +13,11 @@
#include "ui/chromeos/devicetype_utils.h"
#include "ui/strings/grit/ui_strings.h"
-namespace {
-
-const char kJsScreenPath[] = "login.ErrorMessageScreen";
-
-} // namespace
-
namespace chromeos {
ErrorScreenHandler::ErrorScreenHandler(JSCallsContainer* js_calls_container)
- : BaseScreenHandler(kScreenId, js_calls_container),
- weak_ptr_factory_(this) {
- set_call_js_prefix(kJsScreenPath);
+ : BaseScreenHandler(kScreenId, js_calls_container) {
+ set_user_acted_method_path("login.ErrorMessageScreen.userActed");
}
ErrorScreenHandler::~ErrorScreenHandler() {
@@ -39,14 +32,14 @@ void ErrorScreenHandler::Show() {
}
BaseScreenHandler::ShowScreen(kScreenId);
if (screen_)
- screen_->OnShow();
+ screen_->DoShow();
showing_ = true;
}
void ErrorScreenHandler::Hide() {
showing_ = false;
if (screen_)
- screen_->OnHide();
+ screen_->DoHide();
}
void ErrorScreenHandler::Bind(ErrorScreen* screen) {
@@ -63,6 +56,32 @@ void ErrorScreenHandler::ShowOobeScreen(OobeScreen screen) {
ShowScreen(screen);
}
+void ErrorScreenHandler::SetErrorStateCode(
+ NetworkError::ErrorState error_state) {
+ CallJS("login.ErrorMessageScreen.setErrorState",
+ static_cast<int>(error_state));
+}
+
+void ErrorScreenHandler::SetErrorStateNetwork(const std::string& network_name) {
+ CallJS("login.ErrorMessageScreen.setErrorStateNetwork", network_name);
+}
+
+void ErrorScreenHandler::SetGuestSigninAllowed(bool value) {
+ CallJS("login.ErrorMessageScreen.allowGuestSignin", value);
+}
+
+void ErrorScreenHandler::SetOfflineSigninAllowed(bool value) {
+ CallJS("login.ErrorMessageScreen.allowOfflineLogin", value);
+}
+
+void ErrorScreenHandler::SetShowConnectingIndicator(bool value) {
+ CallJS("login.ErrorMessageScreen.showConnectingIndicator", value);
+}
+
+void ErrorScreenHandler::SetUIState(NetworkError::UIState ui_state) {
+ CallJS("login.ErrorMessageScreen.setUIState", static_cast<int>(ui_state));
+}
+
void ErrorScreenHandler::RegisterMessages() {
AddCallback("hideCaptivePortal",
&ErrorScreenHandler::HandleHideCaptivePortal);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h
index d79f03dafb0..efe8c73ed12 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.h
@@ -25,6 +25,12 @@ class ErrorScreenHandler : public BaseScreenHandler, public NetworkErrorView {
void Bind(ErrorScreen* screen) override;
void Unbind() override;
void ShowOobeScreen(OobeScreen screen) override;
+ void SetErrorStateCode(NetworkError::ErrorState error_state) override;
+ void SetErrorStateNetwork(const std::string& network_name) override;
+ void SetGuestSigninAllowed(bool value) override;
+ void SetOfflineSigninAllowed(bool value) override;
+ void SetShowConnectingIndicator(bool value) override;
+ void SetUIState(NetworkError::UIState ui_state) override;
// WebUIMessageHandler:
void RegisterMessages() override;
@@ -46,7 +52,7 @@ class ErrorScreenHandler : public BaseScreenHandler, public NetworkErrorView {
// Whether the error screen is currently shown.
bool showing_ = false;
- base::WeakPtrFactory<ErrorScreenHandler> weak_ptr_factory_;
+ base::WeakPtrFactory<ErrorScreenHandler> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ErrorScreenHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc
index 7c24280e298..fbb0b5d0cd1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/login/oobe_screen.h"
#include "chrome/browser/chromeos/login/screens/core_oobe_view.h"
#include "chrome/browser/chromeos/login/screens/eula_screen.h"
+#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
@@ -24,10 +25,6 @@
#include "rlz/buildflags/buildflags.h"
#include "url/gurl.h"
-namespace {
-constexpr char kJsScreenPath[] = "login.EulaScreen";
-}
-
namespace chromeos {
EulaScreenHandler::EulaScreenHandler(JSCallsContainer* js_calls_container,
@@ -35,7 +32,7 @@ EulaScreenHandler::EulaScreenHandler(JSCallsContainer* js_calls_container,
: BaseScreenHandler(kScreenId, js_calls_container),
core_oobe_view_(core_oobe_view),
weak_factory_(this) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.EulaScreen.userActed");
}
EulaScreenHandler::~EulaScreenHandler() {
@@ -68,7 +65,6 @@ void EulaScreenHandler::Unbind() {
void EulaScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->Add("eulaScreenTitle", IDS_EULA_SCREEN_TITLE);
builder->Add("eulaScreenAccessibleTitle", IDS_EULA_SCREEN_ACCESSIBLE_TITLE);
builder->Add("checkboxLogging", IDS_EULA_CHECKBOX_ENABLE_LOGGING);
builder->Add("back", IDS_EULA_BACK_BUTTON);
@@ -113,6 +109,8 @@ void EulaScreenHandler::DeclareJSCallbacks() {
AddCallback("eulaOnLearnMore", &EulaScreenHandler::HandleOnLearnMore);
AddCallback("eulaOnInstallationSettingsPopupOpened",
&EulaScreenHandler::HandleOnInstallationSettingsPopupOpened);
+ AddCallback("EulaScreen.usageStatsEnabled",
+ &EulaScreenHandler::HandleUsageStatsEnabled);
}
void EulaScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) {
@@ -141,7 +139,8 @@ void EulaScreenHandler::OnPasswordFetched(const std::string& tpm_password) {
void EulaScreenHandler::HandleOnLearnMore() {
if (!help_app_.get())
- help_app_ = new HelpAppLauncher(GetNativeWindow());
+ help_app_ = new HelpAppLauncher(
+ LoginDisplayHost::default_host()->GetNativeWindow());
help_app_->ShowHelpTopic(HelpAppLauncher::HELP_STATS_USAGE);
}
@@ -150,6 +149,11 @@ void EulaScreenHandler::HandleOnInstallationSettingsPopupOpened() {
screen_->InitiatePasswordFetch();
}
+void EulaScreenHandler::HandleUsageStatsEnabled(bool enabled) {
+ if (screen_)
+ screen_->SetUsageStatsEnabled(enabled);
+}
+
void EulaScreenHandler::UpdateLocalizedValues(
::login::SecureModuleUsed secure_module_used) {
base::DictionaryValue updated_secure_module_strings;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h
index 13092f3acc6..df8d8c82096 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h
@@ -48,6 +48,7 @@ class EulaScreenHandler : public EulaView, public BaseScreenHandler {
// JS messages handlers.
void HandleOnLearnMore();
void HandleOnInstallationSettingsPopupOpened();
+ void HandleUsageStatsEnabled(bool enabled);
void UpdateLocalizedValues(::login::SecureModuleUsed secure_module_used);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc
index c26c0771842..3a5f9178d5c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/fingerprint_setup_screen_handler.cc
@@ -21,8 +21,6 @@
namespace {
-const char kJsScreenPath[] = "login.FingerprintSetupScreen";
-
// The max number of fingerprints that can be stored.
constexpr int kMaxAllowedFingerprints = 3;
@@ -52,7 +50,7 @@ namespace chromeos {
FingerprintSetupScreenHandler::FingerprintSetupScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.FingerprintSetupScreen.userActed");
service_manager::Connector* connector =
content::ServiceManagerConnection::GetForProcess()->GetConnector();
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 362a6b70a12..e25fc11e925 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
@@ -8,6 +8,7 @@
#include "ash/public/cpp/ash_features.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
@@ -22,6 +23,7 @@
#include "base/task/post_task.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/login/lock_screen_utils.h"
#include "chrome/browser/chromeos/login/reauth_stats.h"
@@ -54,7 +56,6 @@
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/constants/devicetype.h"
#include "chromeos/dbus/util/version_loader.h"
-#include "chromeos/login/auth/authpolicy_login_helper.h"
#include "chromeos/login/auth/user_context.h"
#include "chromeos/settings/cros_settings_names.h"
#include "components/login/localized_values_builder.h"
@@ -84,7 +85,6 @@ namespace chromeos {
namespace {
-const char kJsScreenPath[] = "login.GaiaSigninScreen";
const char kAuthIframeParentName[] = "signin-frame";
const char kRestrictiveProxyURL[] = "https://www.google.com/generate_204";
@@ -185,14 +185,6 @@ void UpdateAuthParams(base::DictionaryValue* params,
// nosignup flow if new users are not allowed.
if (!allow_new_user || is_restrictive_proxy)
params->SetString("flow", "nosignup");
-
- params->SetBoolean("supervisedUsersCanCreate", false);
-
- // Now check whether we're in multi-profiles user adding scenario and
- // disable GAIA right panel features if that's the case.
- if (UserAddingScreen::Get()->IsRunning()) {
- params->SetBoolean("supervisedUsersCanCreate", false);
- }
}
void RecordSAMLScrapingVerificationResultInHistogram(bool success) {
@@ -297,7 +289,6 @@ GaiaScreenHandler::GaiaScreenHandler(
active_directory_password_change_screen_handler),
weak_factory_(this) {
DCHECK(network_state_informer_.get());
- set_call_js_prefix(kJsScreenPath);
}
GaiaScreenHandler::~GaiaScreenHandler() {
@@ -355,7 +346,8 @@ void GaiaScreenHandler::LoadGaiaWithPartition(
base::BindOnce(&GaiaScreenHandler::OnSetCookieForLoadGaiaWithPartition,
weak_factory_.GetWeakPtr(), context, partition_name);
if (context.gaps_cookie.empty()) {
- std::move(callback).Run(true);
+ std::move(callback).Run(
+ net::CanonicalCookie::CookieInclusionStatus::INCLUDE);
return;
}
@@ -372,18 +364,23 @@ void GaiaScreenHandler::LoadGaiaWithPartition(
std::string gaps_cookie_value(kGAPSCookie);
gaps_cookie_value += "=" + context.gaps_cookie;
+ net::CookieOptions options;
+ options.set_include_httponly();
+ // Permit it to set a SameSite cookie if it wants to.
+ options.set_same_site_cookie_context(
+ net::CookieOptions::SameSiteCookieContext::SAME_SITE_STRICT);
std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create(
GaiaUrls::GetInstance()->gaia_url(), gaps_cookie_value, base::Time::Now(),
- net::CookieOptions()));
+ options));
partition->GetCookieManagerForBrowserProcess()->SetCanonicalCookie(
- *cc.get(), "https", true /* modify_http_only */, std::move(callback));
+ *cc.get(), "https", options, std::move(callback));
}
void GaiaScreenHandler::OnSetCookieForLoadGaiaWithPartition(
const GaiaContext& context,
const std::string& partition_name,
- bool success) {
+ net::CanonicalCookie::CookieInclusionStatus status) {
std::unique_ptr<std::string> version = std::make_unique<std::string>();
std::unique_ptr<bool> consent = std::make_unique<bool>();
base::OnceClosure get_version_and_consent =
@@ -417,7 +414,7 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
params.SetInteger("screenMode", screen_mode);
if (screen_mode == GAIA_SCREEN_MODE_AD && !authpolicy_login_helper_)
- authpolicy_login_helper_ = std::make_unique<AuthPolicyLoginHelper>();
+ authpolicy_login_helper_ = std::make_unique<AuthPolicyHelper>();
if (screen_mode != GAIA_SCREEN_MODE_OFFLINE) {
const std::string app_locale = g_browser_process->GetApplicationLocale();
@@ -490,6 +487,10 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
params.SetString("webviewPartitionName", partition_name);
+ params.SetBoolean("extractSamlPasswordAttributes",
+ Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean(
+ prefs::kSamlInSessionPasswordChangeEnabled));
+
frame_state_ = FRAME_STATE_LOADING;
CallJS("login.GaiaSigninScreen.loadAuthExtension", params);
}
@@ -519,7 +520,6 @@ void GaiaScreenHandler::MonitorOfflineIdle(bool is_online) {
void GaiaScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE_TAB_PROMPT);
builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML);
builder->Add("backButton", IDS_ACCNAME_BACK);
builder->Add("closeButton", IDS_CLOSE);
@@ -620,6 +620,12 @@ void GaiaScreenHandler::RegisterMessages() {
&GaiaScreenHandler::HandleUpdateSigninUIState);
AddCallback("showGuestInOobe", &GaiaScreenHandler::HandleShowGuestInOobe);
+ if (Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean(
+ prefs::kSamlInSessionPasswordChangeEnabled)) {
+ AddCallback("updatePasswordAttributes",
+ &GaiaScreenHandler::HandleUpdatePasswordAttributes);
+ }
+
// Allow UMA metrics collection from JS.
web_ui()->AddMessageHandler(std::make_unique<MetricsHandler>());
}
@@ -810,7 +816,8 @@ void GaiaScreenHandler::OnGetCookiesForCompleteAuthentication(
const std::string& password,
bool using_saml,
const ::login::StringList& services,
- const std::vector<net::CanonicalCookie>& cookies) {
+ const std::vector<net::CanonicalCookie>& cookies,
+ const net::CookieStatusList& excluded_cookies) {
std::string auth_code, gaps_cookie;
for (const auto& cookie : cookies) {
if (cookie.Name() == kOAUTHCodeCookie)
@@ -943,6 +950,25 @@ void GaiaScreenHandler::HandleUpdateSigninUIState(int state) {
}
}
+void GaiaScreenHandler::HandleUpdatePasswordAttributes(
+ const std::string& passwordModifiedTimestamp,
+ const std::string& passwordExpirationTimestamp,
+ const std::string& passwordChangeUrl) {
+ CHECK(Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean(
+ prefs::kSamlInSessionPasswordChangeEnabled));
+ // TODO(olsen): Store this information in the user's session, use it to show a
+ // notification when the user's password is expired / is soon to expire.
+ if (passwordModifiedTimestamp.empty() &&
+ passwordExpirationTimestamp.empty() && passwordChangeUrl.empty()) {
+ VLOG(4) << "No password attributes extracted from SAML response";
+ } else {
+ VLOG(4) << "Extracted password attributes from SAML response: {";
+ VLOG(4) << "passwordModifiedTimestamp: " << passwordModifiedTimestamp;
+ VLOG(4) << "passwordExpirationTimestamp: " << passwordExpirationTimestamp;
+ VLOG(4) << "passwordChangeUrl: " << passwordChangeUrl << " }";
+ }
+}
+
void GaiaScreenHandler::HandleShowGuestInOobe(bool show) {
LoginScreenClient::Get()->login_screen()->SetShowGuestButtonInOobe(show);
}
@@ -1056,7 +1082,8 @@ void GaiaScreenHandler::SubmitLoginFormForTest() {
std::string code =
"document.getElementById('identifier').value = '" + test_user_ + "';"
"document.getElementById('nextButton').click();";
- frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code));
+ frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code),
+ base::NullCallback());
if (!test_services_.empty()) {
// Prefix each doublequote with backslash, so that it will remain correct
@@ -1065,13 +1092,15 @@ void GaiaScreenHandler::SubmitLoginFormForTest() {
base::ReplaceChars(test_services_, "\"", "\\\"", &escaped_services);
code = "document.getElementById('services').value = \"" + escaped_services +
"\";";
- frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code));
+ frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code),
+ base::NullCallback());
}
if (!test_pass_.empty()) {
code = "document.getElementById('password').value = '" + test_pass_ + "';";
code += "document.getElementById('nextButton').click();";
- frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code));
+ frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code),
+ base::NullCallback());
}
// Test properties are cleared in HandleCompleteLogin because the form
@@ -1116,7 +1145,8 @@ void GaiaScreenHandler::ShowSigninScreenForTest(const std::string& username,
// reload gaia then follow the loading case.
if (frame_state() == GaiaScreenHandler::FRAME_STATE_LOADED) {
SubmitLoginFormForTest();
- } else if (frame_state() != GaiaScreenHandler::FRAME_STATE_LOADING) {
+ } else if (frame_state() != GaiaScreenHandler::FRAME_STATE_LOADING &&
+ !auth_extension_being_loaded_) {
OnShowAddUser();
}
}
@@ -1206,7 +1236,7 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
LoadAuthExtension(!gaia_silent_load_ /* force */, false /* offline */);
signin_screen_handler_->UpdateUIState(
- SigninScreenHandler::UI_STATE_GAIA_SIGNIN, nullptr);
+ SigninScreenHandler::UI_STATE_GAIA_SIGNIN);
core_oobe_view_->UpdateKeyboardState();
if (gaia_silent_load_) {
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 8ed8521137a..a4757c2b594 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
@@ -6,15 +6,16 @@
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_GAIA_SCREEN_HANDLER_H_
#include <string>
+#include <vector>
#include "base/command_line.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "chrome/browser/chromeos/authpolicy/authpolicy_helper.h"
#include "chrome/browser/chromeos/login/screens/core_oobe_view.h"
#include "chrome/browser/chromeos/login/screens/gaia_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
-#include "chromeos/login/auth/authpolicy_login_helper.h"
#include "chromeos/network/portal_detector/network_portal_detector.h"
#include "net/base/net_errors.h"
@@ -76,9 +77,10 @@ class GaiaScreenHandler : public BaseScreenHandler,
const std::string& partition_name);
// Called after the GAPS cookie, if present, is added to the cookie store.
- void OnSetCookieForLoadGaiaWithPartition(const GaiaContext& context,
- const std::string& partition_name,
- bool success);
+ void OnSetCookieForLoadGaiaWithPartition(
+ const GaiaContext& context,
+ const std::string& partition_name,
+ net::CanonicalCookie::CookieInclusionStatus status);
// Callback that loads GAIA after version and stat consent information has
// been retrieved.
@@ -126,7 +128,8 @@ class GaiaScreenHandler : public BaseScreenHandler,
const std::string& password,
bool using_saml,
const ::login::StringList& services,
- const std::vector<net::CanonicalCookie>& cookies);
+ const std::vector<net::CanonicalCookie>& cookies,
+ const net::CookieStatusList& excluded_cookies);
void HandleCompleteLogin(const std::string& gaia_id,
const std::string& typed_email,
const std::string& password,
@@ -154,6 +157,13 @@ class GaiaScreenHandler : public BaseScreenHandler,
const std::string& gaia_id);
void HandleUpdateSigninUIState(int state);
+ // Allows for a password expiry notification to be shown using information
+ // extracted from the SAML response during SAML auth flow.
+ void HandleUpdatePasswordAttributes(
+ const std::string& passwordModifiedTimestamp,
+ const std::string& passwordExpirationTimestamp,
+ const std::string& passwordChangeUrl);
+
// Allows WebUI to control the login shelf's guest button visibility during
// OOBE.
void HandleShowGuestInOobe(bool show);
@@ -304,7 +314,7 @@ class GaiaScreenHandler : public BaseScreenHandler,
// Helper to call AuthPolicyClient and cancel calls if needed. Used to
// authenticate users against Active Directory server.
- std::unique_ptr<AuthPolicyLoginHelper> authpolicy_login_helper_;
+ std::unique_ptr<AuthPolicyHelper> authpolicy_login_helper_;
// Makes untrusted authority certificates from device policy available for
// client certificate discovery.
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
index d7ba6f20b19..60421cb9df1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
@@ -20,12 +20,6 @@
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
-namespace {
-
-const char kJsScreenPath[] = "login.HIDDetectionScreen";
-
-} // namespace
-
namespace chromeos {
HIDDetectionScreenHandler::HIDDetectionScreenHandler(
@@ -33,7 +27,6 @@ HIDDetectionScreenHandler::HIDDetectionScreenHandler(
CoreOobeView* core_oobe_view)
: BaseScreenHandler(kScreenId, js_calls_container),
core_oobe_view_(core_oobe_view) {
- set_call_js_prefix(kJsScreenPath);
}
HIDDetectionScreenHandler::~HIDDetectionScreenHandler() {
@@ -77,6 +70,53 @@ void HIDDetectionScreenHandler::CheckIsScreenRequired(
screen_->CheckIsScreenRequired(on_check_done);
}
+void HIDDetectionScreenHandler::SetKeyboardState(const std::string& value) {
+ keyboard_state_ = value;
+ CallJS("login.HIDDetectionScreen.setKeyboardState", value);
+}
+
+void HIDDetectionScreenHandler::SetMouseState(const std::string& value) {
+ mouse_state_ = value;
+ CallJS("login.HIDDetectionScreen.setMouseState", value);
+}
+
+void HIDDetectionScreenHandler::SetKeyboardPinCode(const std::string& value) {
+ keyboard_pin_code_ = value;
+ CallJS("login.HIDDetectionScreen.setKeyboardPinCode", value);
+}
+
+void HIDDetectionScreenHandler::SetNumKeysEnteredExpected(bool value) {
+ num_keys_entered_expected_ = value;
+ CallJS("login.HIDDetectionScreen.setNumKeysEnteredExpected", value);
+}
+
+void HIDDetectionScreenHandler::SetNumKeysEnteredPinCode(int value) {
+ num_keys_entered_pin_code_ = value;
+ CallJS("login.HIDDetectionScreen.setNumKeysEnteredPinCode", value);
+}
+
+void HIDDetectionScreenHandler::SetMouseDeviceName(const std::string& value) {
+ mouse_device_name_ = value;
+ CallJS("login.HIDDetectionScreen.setMouseDeviceName", value);
+}
+
+void HIDDetectionScreenHandler::SetKeyboardDeviceName(
+ const std::string& value) {
+ keyboard_device_name_ = value;
+ CallJS("login.HIDDetectionScreen.setKeyboardDeviceName", value);
+}
+
+void HIDDetectionScreenHandler::SetKeyboardDeviceLabel(
+ const std::string& value) {
+ keyboard_device_label_ = value;
+ CallJS("login.HIDDetectionScreen.setKeyboardDeviceLabel", value);
+}
+
+void HIDDetectionScreenHandler::SetContinueButtonEnabled(bool value) {
+ continue_button_enabled_ = value;
+ CallJS("login.HIDDetectionScreen.setContinueButtonEnabled", value);
+}
+
void HIDDetectionScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("hidDetectionContinue", IDS_HID_DETECTION_CONTINUE_BUTTON);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h
index 3aa4051823f..956d8dc9cbf 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h
@@ -35,6 +35,15 @@ class HIDDetectionScreenHandler
void Unbind() override;
void CheckIsScreenRequired(
const base::Callback<void(bool)>& on_check_done) override;
+ void SetKeyboardState(const std::string& value) override;
+ void SetMouseState(const std::string& value) override;
+ void SetKeyboardPinCode(const std::string& value) override;
+ void SetNumKeysEnteredExpected(bool value) override;
+ void SetNumKeysEnteredPinCode(int value) override;
+ void SetMouseDeviceName(const std::string& value) override;
+ void SetKeyboardDeviceName(const std::string& value) override;
+ void SetKeyboardDeviceLabel(const std::string& value) override;
+ void SetContinueButtonEnabled(bool value) override;
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
@@ -45,10 +54,42 @@ class HIDDetectionScreenHandler
// Registers the preference for derelict state.
static void RegisterPrefs(PrefRegistrySimple* registry);
+ // State that has been exported to JS. Used by tests.
+ std::string keyboard_state_for_test() const { return keyboard_state_; }
+ std::string mouse_state_for_test() const { return mouse_state_; }
+ std::string keyboard_pin_code_for_test() const { return keyboard_pin_code_; }
+ bool num_keys_entered_expected_for_test() const {
+ return num_keys_entered_expected_;
+ }
+ int num_keys_entered_pin_code_for_test() const {
+ return num_keys_entered_pin_code_;
+ }
+ std::string mouse_device_name_for_test() const { return mouse_device_name_; }
+ std::string keyboard_device_name_for_test() const {
+ return keyboard_device_name_;
+ }
+ std::string keyboard_device_label_for_test() const {
+ return keyboard_device_label_;
+ }
+ bool continue_button_enabled_for_test() const {
+ return continue_button_enabled_;
+ }
+
private:
// JS messages handlers.
void HandleOnContinue();
+ // Cached values that have been sent to JS. Used by tests.
+ std::string keyboard_state_;
+ std::string mouse_state_;
+ std::string keyboard_pin_code_;
+ bool num_keys_entered_expected_ = false;
+ int num_keys_entered_pin_code_ = 0;
+ std::string mouse_device_name_;
+ std::string keyboard_device_name_;
+ std::string keyboard_device_label_;
+ bool continue_button_enabled_ = false;
+
HIDDetectionScreen* screen_ = nullptr;
CoreOobeView* core_oobe_view_ = nullptr;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container.cc b/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container.cc
new file mode 100644
index 00000000000..e2cc397832f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container.cc
@@ -0,0 +1,52 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/js_calls_container.h"
+
+#include "content/public/browser/web_ui.h"
+
+namespace chromeos {
+
+JSCallsContainer::Event::Event(Type type,
+ const std::string& function_name,
+ std::vector<base::Value>&& arguments)
+ : type(type),
+ function_name(function_name),
+ arguments(std::move(arguments)) {}
+
+JSCallsContainer::Event::~Event() = default;
+
+JSCallsContainer::Event::Event(Event&&) = default;
+
+JSCallsContainer::JSCallsContainer() = default;
+
+JSCallsContainer::~JSCallsContainer() = default;
+
+void JSCallsContainer::ExecuteDeferredJSCalls(content::WebUI* web_ui) {
+ DCHECK(!is_initialized());
+ is_initialized_ = true;
+
+ // Execute recorded outgoing events.
+ for (const auto& event : events_) {
+ if (event.type != Event::Type::kOutgoing)
+ continue;
+
+ // event.arguments is of type std::vector<base::Value>, but
+ // CallJavascriptFunctionUnsafe requires std::vector<const base::Value*>.
+ // Construct the new vector of pointers from the existing data.
+ std::vector<const base::Value*> args;
+ args.reserve(event.arguments.size());
+ auto* bp = event.arguments.data();
+ for (size_t i = 0; i < event.arguments.size(); ++i)
+ args.push_back(bp + i);
+ web_ui->CallJavascriptFunctionUnsafe(event.function_name, args);
+ }
+
+ // Reduce memory usage / drop potentially sensitive data if we're not
+ // recording for a test.
+ if (!record_all_events_for_test_)
+ events_.clear();
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container.h b/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container.h
new file mode 100644
index 00000000000..1b429e2097e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container.h
@@ -0,0 +1,84 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_JS_CALLS_CONTAINER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_JS_CALLS_CONTAINER_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "base/values.h"
+
+namespace content {
+class WebUI;
+}
+
+namespace chromeos {
+
+// A helper class to store deferred Javascript calls, shared by subclasses of
+// BaseWebUIHandler.
+class JSCallsContainer {
+ public:
+ // An event is a message/JS call to or from WebUI.
+ struct Event {
+ enum class Type {
+ // This event was sent from C++ to JS.
+ kOutgoing,
+ // This event was sent from JS to C++.
+ kIncoming,
+ };
+
+ Event(Type type,
+ const std::string& function_name,
+ std::vector<base::Value>&& arguments);
+ ~Event();
+ Event(Event&&);
+ Event(const Event&) = delete;
+ Event& operator=(const Event&) = delete;
+
+ Type type;
+ std::string function_name;
+ std::vector<base::Value> arguments;
+ };
+
+ JSCallsContainer();
+ ~JSCallsContainer();
+ JSCallsContainer(const JSCallsContainer&) = delete;
+ JSCallsContainer& operator=(const JSCallsContainer&) = delete;
+
+ // Used to decide whether the JS call should be deferred.
+ bool is_initialized() const { return is_initialized_; }
+
+ // Enable event recording.
+ void set_record_all_events_for_test() { record_all_events_for_test_ = true; }
+
+ // If true then all JS calls should be recorded.
+ bool record_all_events_for_test() const {
+ return record_all_events_for_test_;
+ }
+
+ // Recorded events. This is mutable and can be modified.
+ std::vector<Event>* events() { return &events_; }
+
+ // Executes Javascript calls that were deferred while the instance was not
+ // initialized yet.
+ void ExecuteDeferredJSCalls(content::WebUI* web_ui);
+
+ private:
+ // Whether the instance is initialized.
+ //
+ // The instance becomes initialized after the corresponding message is
+ // received from Javascript side.
+ bool is_initialized_ = false;
+
+ // Decide if incoming and outgoing JS calls should be recorded. Recording
+ // should only be used for tests.
+ bool record_all_events_for_test_ = false;
+
+ std::vector<Event> events_;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_JS_CALLS_CONTAINER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.cc b/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.cc
new file mode 100644
index 00000000000..e485181f2d5
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.cc
@@ -0,0 +1,49 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.h"
+
+#include <sstream>
+
+#include "chrome/browser/ui/webui/chromeos/login/js_calls_container.h"
+
+namespace chromeos {
+
+JSCallsContainerTestApi::JSCallsContainerTestApi(
+ JSCallsContainer* js_calls_container)
+ : js_calls_container_(js_calls_container) {
+ // Try to avoid a race condition where events potentially get dropped because
+ // recording hasn't been enabled yet.
+ DCHECK(js_calls_container_->record_all_events_for_test() ||
+ js_calls_container_->events()->empty());
+
+ js_calls_container_->set_record_all_events_for_test();
+}
+
+JSCallsContainerTestApi::~JSCallsContainerTestApi() {
+ auto build_function_string =
+ [](const JSCallsContainer::Event& event) -> std::string {
+ std::stringstream result;
+ result << event.function_name;
+ result << '(';
+ bool first = true;
+ for (const base::Value& value : event.arguments) {
+ if (!first)
+ result << ", ";
+ first = false;
+ result << value;
+ }
+ result << ')';
+ return result.str();
+ };
+
+ for (const auto& event : *js_calls_container_->events()) {
+ if (event.type == JSCallsContainer::Event::Type::kIncoming)
+ Incoming(build_function_string(event));
+ else
+ Outgoing(build_function_string(event));
+ }
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.h b/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.h
new file mode 100644
index 00000000000..f56b398f271
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/js_calls_container_test_api.h
@@ -0,0 +1,43 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_JS_CALLS_CONTAINER_TEST_API_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_JS_CALLS_CONTAINER_TEST_API_H_
+
+#include "base/macros.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace chromeos {
+
+class JSCallsContainer;
+
+// Enables setting up expectations for incoming and outgoing JavaScript in
+// OOBE/login. When constructed this automatically enables event recording;
+// JavaScript messages from before this is constructed may not be captured.
+//
+// Messages are automatically dispatched to the mocks in the destructor.
+class JSCallsContainerTestApi {
+ public:
+ explicit JSCallsContainerTestApi(JSCallsContainer* js_calls_container);
+ ~JSCallsContainerTestApi();
+
+ // |function| has arguments serialized to make matching easier. For example, a
+ // valid invocation looks like
+ //
+ // EXPECT_CALL(test_api,
+ // Outgoing("login.MyComponent.setUpdateRequired(true, 5)"));
+
+ // Notification from WebUI to C++
+ MOCK_METHOD1(Incoming, void(std::string function));
+ // Notification from C++ to WebUI
+ MOCK_METHOD1(Outgoing, void(std::string function));
+
+ private:
+ JSCallsContainer* const js_calls_container_;
+ DISALLOW_COPY_AND_ASSIGN(JSCallsContainerTestApi);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_JS_CALLS_CONTAINER_TEST_API_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.cc
deleted file mode 100644
index f0dee832975..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.cc
+++ /dev/null
@@ -1,216 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h"
-
-#include <stddef.h>
-
-#include <utility>
-
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/system/sys_info.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
-#include "chrome/browser/chromeos/login/existing_user_controller.h"
-#include "chrome/browser/chromeos/login/screens/network_error.h"
-#include "chrome/grit/generated_resources.h"
-#include "chromeos/constants/chromeos_switches.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/web_ui.h"
-#include "extensions/grit/extensions_browser_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/webui/web_ui_util.h"
-
-namespace chromeos {
-
-namespace {
-
-// JS functions that define new and old kiosk UI API.
-const char kKioskSetAppsNewAPI[] = "login.AccountPickerScreen.setApps";
-const char kKioskSetAppsOldAPI[] = "login.AppsMenuButton.setApps";
-const char kKioskShowErrorNewAPI[] = "login.AccountPickerScreen.showAppError";
-const char kKioskShowErrorOldAPI[] = "login.AppsMenuButton.showError";
-
-} // namespace
-
-KioskAppMenuHandler::KioskAppMenuHandler(
- const scoped_refptr<NetworkStateInformer>& network_state_informer)
- : is_webui_initialized_(false),
- network_state_informer_(network_state_informer),
- weak_ptr_factory_(this) {
- KioskAppManager::Get()->AddObserver(this);
- network_state_informer_->AddObserver(this);
- ArcKioskAppManager::Get()->AddObserver(this);
-}
-
-KioskAppMenuHandler::~KioskAppMenuHandler() {
- KioskAppManager::Get()->RemoveObserver(this);
- network_state_informer_->RemoveObserver(this);
- ArcKioskAppManager::Get()->RemoveObserver(this);
-}
-
-void KioskAppMenuHandler::GetLocalizedStrings(
- base::DictionaryValue* localized_strings) {
- localized_strings->SetString(
- "showApps",
- l10n_util::GetStringUTF16(IDS_KIOSK_APPS_BUTTON));
- localized_strings->SetString(
- "confirmKioskAppDiagnosticModeFormat",
- l10n_util::GetStringUTF16(IDS_LOGIN_CONFIRM_KIOSK_DIAGNOSTIC_FORMAT));
- localized_strings->SetString(
- "confirmKioskAppDiagnosticModeYes",
- l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL));
- localized_strings->SetString(
- "confirmKioskAppDiagnosticModeNo",
- l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL));
- localized_strings->SetBoolean(
- "kioskAppHasLaunchError",
- KioskAppLaunchError::Get() != KioskAppLaunchError::NONE);
-}
-
-void KioskAppMenuHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "initializeKioskApps",
- base::BindRepeating(&KioskAppMenuHandler::HandleInitializeKioskApps,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "kioskAppsLoaded",
- base::BindRepeating(&KioskAppMenuHandler::HandleKioskAppsLoaded,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "checkKioskAppLaunchError",
- base::BindRepeating(&KioskAppMenuHandler::HandleCheckKioskAppLaunchError,
- base::Unretained(this)));
-}
-
-// static
-bool KioskAppMenuHandler::EnableNewKioskUI() {
- // Turn off new kiosk UI for M34/35.
- // TODO(xiyuan, nkostylev): Revist for http://crbug.com/362062.
- return false;
-}
-
-void KioskAppMenuHandler::SendKioskApps() {
- if (!is_webui_initialized_)
- return;
-
- KioskAppManager::Apps apps;
- KioskAppManager::Get()->GetApps(&apps);
-
- base::ListValue apps_list;
- for (size_t i = 0; i < apps.size(); ++i) {
- const KioskAppManager::App& app_data = apps[i];
-
- std::unique_ptr<base::DictionaryValue> app_info(
- new base::DictionaryValue());
- app_info->SetBoolean("isApp", true);
- app_info->SetString("id", app_data.app_id);
- app_info->SetBoolean("isAndroidApp", false);
- // Unused for native apps. Added for consistency with Android apps.
- app_info->SetString("account_email", app_data.account_id.GetUserEmail());
- app_info->SetString("label", app_data.name);
-
- std::string icon_url;
- if (app_data.icon.isNull()) {
- icon_url =
- webui::GetBitmapDataUrl(*ui::ResourceBundle::GetSharedInstance()
- .GetImageNamed(IDR_APP_DEFAULT_ICON)
- .ToSkBitmap());
- } else {
- icon_url = webui::GetBitmapDataUrl(*app_data.icon.bitmap());
- }
- app_info->SetString("iconUrl", icon_url);
-
- apps_list.Append(std::move(app_info));
- }
-
- ArcKioskAppManager::Apps arc_apps;
- ArcKioskAppManager::Get()->GetAllApps(&arc_apps);
- for (size_t i = 0; i < arc_apps.size(); ++i) {
- std::unique_ptr<base::DictionaryValue> app_info(
- new base::DictionaryValue());
- app_info->SetBoolean("isApp", true);
- app_info->SetBoolean("isAndroidApp", true);
- app_info->SetString("id", arc_apps[i]->app_id());
- app_info->SetString("account_email",
- arc_apps[i]->account_id().GetUserEmail());
- app_info->SetString("label", arc_apps[i]->name());
-
- std::string icon_url;
- if (arc_apps[i]->icon().isNull()) {
- icon_url =
- webui::GetBitmapDataUrl(*ui::ResourceBundle::GetSharedInstance()
- .GetImageNamed(IDR_APP_DEFAULT_ICON)
- .ToSkBitmap());
- } else {
- icon_url = webui::GetBitmapDataUrl(*arc_apps[i]->icon().bitmap());
- }
- app_info->SetString("iconUrl", icon_url);
-
- apps_list.Append(std::move(app_info));
- }
-
- web_ui()->CallJavascriptFunctionUnsafe(
- EnableNewKioskUI() ? kKioskSetAppsNewAPI : kKioskSetAppsOldAPI,
- apps_list);
-}
-
-void KioskAppMenuHandler::HandleInitializeKioskApps(
- const base::ListValue* args) {
- is_webui_initialized_ = true;
- SendKioskApps();
- UpdateState(NetworkError::ERROR_REASON_UPDATE);
-}
-
-void KioskAppMenuHandler::HandleKioskAppsLoaded(
- const base::ListValue* args) {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_KIOSK_APPS_LOADED,
- content::NotificationService::AllSources(),
- content::NotificationService::NoDetails());
-}
-
-void KioskAppMenuHandler::HandleCheckKioskAppLaunchError(
- const base::ListValue* args) {
- KioskAppLaunchError::Error error = KioskAppLaunchError::Get();
- if (error == KioskAppLaunchError::NONE)
- return;
- KioskAppLaunchError::RecordMetricAndClear();
-
- const std::string error_message = KioskAppLaunchError::GetErrorMessage(error);
- bool new_kiosk_ui = EnableNewKioskUI();
- web_ui()->CallJavascriptFunctionUnsafe(
- new_kiosk_ui ? kKioskShowErrorNewAPI : kKioskShowErrorOldAPI,
- base::Value(error_message));
-}
-
-void KioskAppMenuHandler::OnKioskAppsSettingsChanged() {
- SendKioskApps();
-}
-
-void KioskAppMenuHandler::OnKioskAppDataChanged(const std::string& app_id) {
- SendKioskApps();
-}
-
-void KioskAppMenuHandler::OnKioskAppDataLoadFailure(const std::string& app_id) {
- SendKioskApps();
-}
-
-void KioskAppMenuHandler::UpdateState(NetworkError::ErrorReason reason) {
- if (network_state_informer_->state() == NetworkStateInformer::ONLINE)
- KioskAppManager::Get()->RetryFailedAppDataFetch();
-}
-
-void KioskAppMenuHandler::OnArcKioskAppsChanged() {
- SendKioskApps();
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h
deleted file mode 100644
index ce1e5473701..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_KIOSK_APP_MENU_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_KIOSK_APP_MENU_HANDLER_H_
-
-#include <memory>
-#include <string>
-
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
-#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
-#include "chrome/browser/chromeos/login/screens/network_error.h"
-#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace chromeos {
-
-// KioskAppMenuHandler supplies kiosk apps data to apps menu on sign-in
-// screen when app mode is enabled and handles "launchKioskApp" request
-// from the apps menu.
-class KioskAppMenuHandler
- : public content::WebUIMessageHandler,
- public KioskAppManagerObserver,
- public NetworkStateInformer::NetworkStateInformerObserver,
- public ArcKioskAppManager::ArcKioskAppManagerObserver {
- public:
- explicit KioskAppMenuHandler(
- const scoped_refptr<NetworkStateInformer>& network_state_informer);
- ~KioskAppMenuHandler() override;
-
- void GetLocalizedStrings(base::DictionaryValue* localized_strings);
-
- // content::WebUIMessageHandler overrides:
- void RegisterMessages() override;
-
- // Returns true if new kiosk UI is enabled.
- static bool EnableNewKioskUI();
-
- private:
- // Sends all kiosk apps to webui.
- void SendKioskApps();
-
- // JS callbacks.
- void HandleInitializeKioskApps(const base::ListValue* args);
- void HandleKioskAppsLoaded(const base::ListValue* args);
- void HandleCheckKioskAppLaunchError(const base::ListValue* args);
-
- // KioskAppManagerObserver overrides:
- void OnKioskAppsSettingsChanged() override;
- void OnKioskAppDataChanged(const std::string& app_id) override;
- void OnKioskAppDataLoadFailure(const std::string& app_id) override;
-
- // NetworkStateInformer::NetworkStateInformerObserver overrides:
- void UpdateState(NetworkError::ErrorReason reason) override;
-
- // ArcKioskAppManager::ArcKioskAppManagerObserver overrides:
- void OnArcKioskAppsChanged() override;
-
- // True when WebUI is initialized. Otherwise don't allow calling JS functions.
- bool is_webui_initialized_;
-
- scoped_refptr<NetworkStateInformer> network_state_informer_;
-
- base::WeakPtrFactory<KioskAppMenuHandler> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(KioskAppMenuHandler);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_KIOSK_APP_MENU_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc
index ba35003786e..078bcd97af2 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.cc
@@ -16,7 +16,7 @@
#include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/session_manager_client.h"
+#include "chromeos/dbus/session_manager/session_manager_client.h"
#include "components/login/localized_values_builder.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
@@ -24,18 +24,11 @@
#include "content/public/browser/notification_service.h"
#include "ui/base/webui/web_ui_util.h"
-namespace {
-
-const char kJsScreenPath[] = "login.AutolaunchScreen";
-
-} // namespace
-
namespace chromeos {
KioskAutolaunchScreenHandler::KioskAutolaunchScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
KioskAppManager::Get()->AddObserver(this);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc
index 41a6c0dffa9..1f4eb1d8cd6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.cc
@@ -17,19 +17,12 @@
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
-namespace {
-
-const char kJsScreenPath[] = "login.KioskEnableScreen";
-
-} // namespace
-
namespace chromeos {
KioskEnableScreenHandler::KioskEnableScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container),
weak_ptr_factory_(this) {
- set_call_js_prefix(kJsScreenPath);
}
KioskEnableScreenHandler::~KioskEnableScreenHandler() {
@@ -74,7 +67,6 @@ void KioskEnableScreenHandler::SetDelegate(Delegate* delegate) {
void KioskEnableScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->Add("kioskEnableTitle", IDS_KIOSK_ENABLE_SCREEN_WARNING);
builder->Add("kioskEnableWarningText",
IDS_KIOSK_ENABLE_SCREEN_WARNING);
builder->Add("kioskEnableWarningDetails",
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc
index 7189ed29cf2..63a72505d35 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.cc
@@ -18,12 +18,6 @@ MockInputMethodManagerWithInputMethods::
~MockInputMethodManagerWithInputMethods() {
}
-std::unique_ptr<input_method::InputMethodDescriptors>
-MockInputMethodManagerWithInputMethods::GetSupportedInputMethods() const {
- return std::unique_ptr<input_method::InputMethodDescriptors>(
- new input_method::InputMethodDescriptors(descriptors_));
-}
-
void MockInputMethodManagerWithInputMethods::AddInputMethod(
const std::string& id,
const std::string& raw_layout,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.h b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.h
index 8136458bc60..1b460c9f073 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.h
@@ -22,10 +22,6 @@ class MockInputMethodManagerWithInputMethods
MockInputMethodManagerWithInputMethods();
~MockInputMethodManagerWithInputMethods() override;
- // input_method::MockInputMethodManagerImpl:
- std::unique_ptr<input_method::InputMethodDescriptors>
- GetSupportedInputMethods() const override;
-
void AddInputMethod(const std::string& id,
const std::string& raw_layout,
const std::string& language_code);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc
index 46a99135a0d..7449e5194ca 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/l10n_util_unittest.cc
@@ -16,7 +16,7 @@
#include "chrome/browser/chromeos/customization/customization_document.h"
#include "chrome/browser/chromeos/input_method/input_method_configuration.h"
#include "chrome/browser/ui/webui/chromeos/login/l10n_util_test_util.h"
-#include "chromeos/system/statistics_provider.h"
+#include "chromeos/system/fake_statistics_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ime/chromeos/component_extension_ime_manager.h"
@@ -59,8 +59,10 @@ class L10nUtilTest : public testing::Test {
private:
base::test::ScopedTaskEnvironment scoped_task_environment_;
-
+ system::ScopedFakeStatisticsProvider scoped_fake_statistics_provider_;
MockInputMethodManagerWithInputMethods* input_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(L10nUtilTest);
};
L10nUtilTest::L10nUtilTest()
@@ -69,13 +71,10 @@ L10nUtilTest::L10nUtilTest()
input_manager_->SetComponentExtensionIMEManager(
std::make_unique<ComponentExtensionIMEManager>());
- chromeos::system::StatisticsProvider::GetInstance()
- ->StartLoadingMachineStatistics(false);
base::RunLoop().RunUntilIdle();
}
L10nUtilTest::~L10nUtilTest() {
- chromeos::system::StatisticsProvider::GetInstance()->Shutdown();
chromeos::input_method::Shutdown();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc
index f48656a41ef..d0cdb09f4bf 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.cc
@@ -8,18 +8,11 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-const char kJsScreenPath[] = "login.MarketingOptInScreen";
-
-} // namespace
-
namespace chromeos {
MarketingOptInScreenHandler::MarketingOptInScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
}
MarketingOptInScreenHandler::~MarketingOptInScreenHandler() {}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc
index bc735441b1d..4ceafb89644 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc
@@ -9,18 +9,12 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-const char kJsScreenPath[] = "login.MultiDeviceSetupScreen";
-
-} // namespace
-
namespace chromeos {
MultiDeviceSetupScreenHandler::MultiDeviceSetupScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.MultiDeviceSetupScreen.userActed");
}
MultiDeviceSetupScreenHandler::~MultiDeviceSetupScreenHandler() = default;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
index e4224b78652..f6f70ea5851 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
@@ -17,19 +17,13 @@
#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(JSCallsContainer* js_calls_container,
CoreOobeView* core_oobe_view)
: BaseScreenHandler(kScreenId, js_calls_container),
core_oobe_view_(core_oobe_view) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.NetworkScreen.userActed");
DCHECK(core_oobe_view_);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
index def6426b4f1..a0e563f6057 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc
@@ -99,7 +99,8 @@ void OobeDisplayChooser::MoveToTouchDisplay() {
config_properties->set_primary = true;
cros_display_config_ptr_->SetDisplayProperties(
base::NumberToString(device.target_display_id),
- std::move(config_properties), base::DoNothing());
+ std::move(config_properties), ash::mojom::DisplayConfigSource::kUser,
+ base::DoNothing());
break;
}
}
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 083f591158e..3a5adc9c22c 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
@@ -48,6 +48,7 @@ class TestCrosDisplayConfig : public ash::mojom::CrosDisplayConfigController {
GetDisplayUnitInfoListCallback callback) override {}
void SetDisplayProperties(const std::string& id,
ash::mojom::DisplayConfigPropertiesPtr properties,
+ ash::mojom::DisplayConfigSource source,
SetDisplayPropertiesCallback callback) override {
if (properties->set_primary) {
int64_t display_id;
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 2cbdfee5e0a..96901b262e3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
@@ -59,7 +59,6 @@
#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/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"
@@ -77,7 +76,6 @@
#include "chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h"
-#include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
@@ -131,8 +129,6 @@ constexpr char kArcPlaystoreLogoPath[] = "playstore.svg";
constexpr char kArcSupervisionIconPath[] = "supervision_icon.png";
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 kLoginJSPath[] = "login.js";
@@ -148,11 +144,6 @@ constexpr char kLogo24PX2XSvgPath[] = "logo_24px-2x.svg";
constexpr char kSyncConsentIcons[] = "sync-consent-icons.html";
#endif
-// Paths for deferred resource loading.
-constexpr char kEnrollmentCSSPath[] = "enrollment.css";
-constexpr char kEnrollmentHTMLPath[] = "enrollment.html";
-constexpr char kEnrollmentJSPath[] = "enrollment.js";
-
// Adds various product logo resources.
void AddProductLogoResources(content::WebUIDataSource* source) {
// Required for Assistant OOBE.
@@ -191,14 +182,6 @@ void AddArcScreensResources(content::WebUIDataSource* source) {
IDR_ARC_SUPPORT_RECOMMEND_APP_LIST_VIEW_HTML);
}
-// 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);
-}
-
void AddFingerprintResources(content::WebUIDataSource* source) {
if (quick_unlock::IsFingerprintReaderOnKeyboard()) {
source->AddResourcePath("fingerprint_scanner_animation.png",
@@ -267,12 +250,6 @@ content::WebUIDataSource* CreateOobeUIDataSource(
AddFingerprintResources(source);
AddSyncConsentResources(source);
AddArcScreensResources(source);
- AddEnterpriseEnrollmentResources(source);
-
- if (display_type == OobeUI::kLoginDisplay) {
- source->AddResourcePath(kCustomElementsUserPodHTMLPath,
- IDR_CUSTOM_ELEMENTS_USER_POD_HTML);
- }
source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS);
source->OverrideContentSecurityPolicyChildSrc(base::StringPrintf(
@@ -284,7 +261,8 @@ content::WebUIDataSource* CreateOobeUIDataSource(
const bool is_running_test = command_line->HasSwitch(::switches::kTestName) ||
command_line->HasSwitch(::switches::kTestType);
if (is_running_test)
- source->SetRequestFilter(::test::GetTestFilesRequestFilter());
+ source->SetRequestFilter(::test::GetTestShouldHandleRequest(),
+ ::test::GetTestFilesRequestFilter());
return source;
}
@@ -369,7 +347,7 @@ void OobeUI::ConfigureOobeDisplay() {
AddScreenHandler(
std::make_unique<ErrorScreenHandler>(js_calls_container_.get()));
- error_screen_.reset(new ErrorScreen(nullptr, GetView<ErrorScreenHandler>()));
+ error_screen_ = std::make_unique<ErrorScreen>(GetView<ErrorScreenHandler>());
ErrorScreen* error_screen = error_screen_.get();
AddScreenHandler(std::make_unique<EnrollmentScreenHandler>(
@@ -391,9 +369,6 @@ void OobeUI::ConfigureOobeDisplay() {
std::make_unique<AppDownloadingScreenHandler>(js_calls_container_.get()));
AddScreenHandler(
- std::make_unique<UserImageScreenHandler>(js_calls_container_.get()));
-
- AddScreenHandler(
std::make_unique<UserBoardScreenHandler>(js_calls_container_.get()));
AddScreenHandler(
@@ -457,12 +432,6 @@ void OobeUI::ConfigureOobeDisplay() {
AddScreenHandler(std::make_unique<MultiDeviceSetupScreenHandler>(
js_calls_container_.get()));
- // 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));
-
Profile* profile = Profile::FromWebUI(web_ui());
// Set up the chrome://theme/ source, for Chrome logo.
content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
@@ -551,7 +520,10 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
&OobeUI::BindPrivilegedHostDeviceSetter, base::Unretained(this)));
}
-OobeUI::~OobeUI() {}
+OobeUI::~OobeUI() {
+ for (Observer& observer : observer_list_)
+ observer.OnDestroyingOobeUI();
+}
CoreOobeView* OobeUI::GetCoreOobeView() {
return core_handler_;
@@ -661,10 +633,6 @@ MultiDeviceSetupScreenView* OobeUI::GetMultiDeviceSetupScreenView() {
return GetView<MultiDeviceSetupScreenHandler>();
}
-UserImageView* OobeUI::GetUserImageView() {
- return GetView<UserImageScreenHandler>();
-}
-
ErrorScreen* OobeUI::GetErrorScreen() {
return error_screen_.get();
}
@@ -681,10 +649,6 @@ NetworkScreenView* OobeUI::GetNetworkScreenView() {
return GetView<NetworkScreenHandler>();
}
-void OobeUI::OnShutdownPolicyChanged(bool reboot_on_shutdown) {
- core_handler_->UpdateShutdownAndRebootVisibility(reboot_on_shutdown);
-}
-
AppLaunchSplashScreenView* OobeUI::GetAppLaunchSplashScreenView() {
return GetView<AppLaunchSplashScreenHandler>();
}
@@ -702,7 +666,6 @@ void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
handler->GetLocalizedStrings(localized_strings);
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, localized_strings);
- kiosk_app_menu_handler_->GetLocalizedStrings(localized_strings);
#if defined(GOOGLE_CHROME_BUILD)
localized_strings->SetString("buildType", "chrome");
@@ -715,8 +678,6 @@ void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
localized_strings->SetString("highlightStrength",
keyboard_driven_oobe ? "strong" : "normal");
- bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI();
- localized_strings->SetString("newKioskUI", new_kiosk_ui ? "on" : "off");
localized_strings->SetString(
"showViewsLock", ash::switches::IsUsingViewsLock() ? "on" : "off");
localized_strings->SetString(
@@ -739,32 +700,18 @@ void OobeUI::AddScreenHandler(std::unique_ptr<BaseScreenHandler> handler) {
}
void OobeUI::InitializeHandlers() {
- js_calls_container_->ExecuteDeferredJSCalls();
+ js_calls_container_->ExecuteDeferredJSCalls(web_ui());
ready_ = true;
for (size_t i = 0; i < ready_callbacks_.size(); ++i)
ready_callbacks_[i].Run();
ready_callbacks_.clear();
- // Notify 'initialize' for synchronously loaded screens.
- for (BaseWebUIHandler* handler : webui_only_handlers_) {
- if (handler->async_assets_load_id().empty()) {
- handler->InitializeBase();
- }
- }
- for (BaseScreenHandler* handler : screen_handlers_) {
- if (handler->async_assets_load_id().empty()) {
- handler->InitializeBase();
- ScreenInitialized(handler->oobe_screen());
- }
- }
-
- // Instantiate the ShutdownPolicyHandler.
- shutdown_policy_handler_.reset(
- new ShutdownPolicyHandler(CrosSettings::Get(), this));
+ for (BaseWebUIHandler* handler : webui_only_handlers_)
+ handler->InitializeBase();
- // Trigger an initial update.
- shutdown_policy_handler_->NotifyDelegateWithShutdownPolicy();
+ for (BaseScreenHandler* handler : screen_handlers_)
+ handler->InitializeBase();
}
void OobeUI::CurrentScreenChanged(OobeScreen new_screen) {
@@ -775,11 +722,6 @@ void OobeUI::CurrentScreenChanged(OobeScreen new_screen) {
observer.OnCurrentScreenChanged(current_screen_, new_screen);
}
-void OobeUI::ScreenInitialized(OobeScreen screen) {
- for (Observer& observer : observer_list_)
- observer.OnScreenInitialized(screen);
-}
-
bool OobeUI::IsScreenInitialized(OobeScreen screen) {
for (BaseScreenHandler* handler : screen_handlers_) {
if (handler->oobe_screen() == screen) {
@@ -789,22 +731,6 @@ bool OobeUI::IsScreenInitialized(OobeScreen screen) {
return false;
}
-void OobeUI::OnScreenAssetsLoaded(const std::string& async_assets_load_id) {
- DCHECK(!async_assets_load_id.empty());
-
- for (BaseWebUIHandler* handler : webui_only_handlers_) {
- if (handler->async_assets_load_id() == async_assets_load_id) {
- handler->InitializeBase();
- }
- }
- for (BaseScreenHandler* handler : screen_handlers_) {
- if (handler->async_assets_load_id() == async_assets_load_id) {
- handler->InitializeBase();
- ScreenInitialized(handler->oobe_screen());
- }
- }
-}
-
bool OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) {
if (!ready_)
ready_callbacks_.push_back(display_is_ready_callback);
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 9c111fdd79e..f848ebf7cd3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
@@ -15,7 +15,6 @@
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/settings/shutdown_policy_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
@@ -50,7 +49,6 @@ class DiscoverScreenView;
class FingerprintSetupScreenView;
class GaiaView;
class HIDDetectionView;
-class KioskAppMenuHandler;
class KioskAutolaunchScreenView;
class KioskEnableScreenView;
class LoginScreenContext;
@@ -67,7 +65,6 @@ class SigninScreenHandlerDelegate;
class SyncConsentScreenView;
class TermsOfServiceScreenView;
class UserBoardView;
-class UserImageView;
class UpdateView;
class UpdateRequiredView;
class SupervisionTransitionScreenView;
@@ -78,8 +75,7 @@ class WrongHWIDScreenView;
// - welcome screen (setup language/keyboard/network).
// - eula screen (CrOS (+ OEM) EULA content/TPM password/crash reporting).
// - update screen.
-class OobeUI : public ui::MojoWebUIController,
- public ShutdownPolicyHandler::Delegate {
+class OobeUI : public ui::MojoWebUIController {
public:
// List of known types of OobeUI. Type added as path in chrome://oobe url, for
// example chrome://oobe/user-adding.
@@ -98,7 +94,7 @@ class OobeUI : public ui::MojoWebUIController,
virtual void OnCurrentScreenChanged(OobeScreen current_screen,
OobeScreen new_screen) = 0;
- virtual void OnScreenInitialized(OobeScreen screen) = 0;
+ virtual void OnDestroyingOobeUI() = 0;
protected:
virtual ~Observer() {}
@@ -125,7 +121,6 @@ class OobeUI : public ui::MojoWebUIController,
ArcTermsOfServiceScreenView* GetArcTermsOfServiceScreenView();
RecommendAppsScreenView* GetRecommendAppsScreenView();
AppDownloadingScreenView* GetAppDownloadingScreenView();
- UserImageView* GetUserImageView();
ErrorScreen* GetErrorScreen();
WrongHWIDScreenView* GetWrongHWIDScreenView();
AutoEnrollmentCheckScreenView* GetAutoEnrollmentCheckScreenView();
@@ -144,9 +139,6 @@ class OobeUI : public ui::MojoWebUIController,
NetworkScreenView* GetNetworkScreenView();
MarketingOptInScreenView* GetMarketingOptInScreenView();
- // ShutdownPolicyHandler::Delegate
- void OnShutdownPolicyChanged(bool reboot_on_shutdown) override;
-
// Collects localized strings from the owned handlers.
void GetLocalizedStrings(base::DictionaryValue* localized_strings);
@@ -156,15 +148,8 @@ class OobeUI : public ui::MojoWebUIController,
// Called when the screen has changed.
void CurrentScreenChanged(OobeScreen screen);
- // Called when the screen was initialized.
- void ScreenInitialized(OobeScreen screen);
-
bool IsScreenInitialized(OobeScreen screen);
- // Invoked after the async assets load. The screen handler that has the same
- // async assets load id will be initialized.
- void OnScreenAssetsLoaded(const std::string& async_assets_load_id);
-
bool IsJSReady(const base::Closure& display_is_ready_callback);
// Shows or hides OOBE UI elements.
@@ -252,9 +237,6 @@ class OobeUI : public ui::MojoWebUIController,
std::vector<BaseWebUIHandler*> webui_only_handlers_; // Non-owning pointers.
std::vector<BaseScreenHandler*> screen_handlers_; // Non-owning pointers.
- KioskAppMenuHandler* kiosk_app_menu_handler_ =
- nullptr; // Non-owning pointers.
-
std::unique_ptr<ErrorScreen> error_screen_;
// Id of the current oobe/login screen.
@@ -273,9 +255,6 @@ class OobeUI : public ui::MojoWebUIController,
// List of registered observers.
base::ObserverList<Observer>::Unchecked observer_list_;
- // Observer of CrosSettings watching the kRebootOnShutdown policy.
- std::unique_ptr<ShutdownPolicyHandler> shutdown_policy_handler_;
-
std::unique_ptr<OobeDisplayChooser> oobe_display_chooser_;
// Store the deferred JS calls before the screen handler instance is
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 e5894cda505..32cb05dfb22 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
@@ -18,8 +18,6 @@
namespace {
-const char kJsScreenPath[] = "login.RecommendAppsScreen";
-
constexpr const char kUserActionSkip[] = "recommendAppsSkip";
constexpr const char kUserActionRetry[] = "recommendAppsRetry";
constexpr const char kUserActionInstall[] = "recommendAppsInstall";
@@ -76,7 +74,6 @@ namespace chromeos {
RecommendAppsScreenHandler::RecommendAppsScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
}
RecommendAppsScreenHandler::~RecommendAppsScreenHandler() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
index 8b46908ed4f..187aa5d01cd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.cc
@@ -13,21 +13,15 @@
#include "chrome/browser/chromeos/login/screens/reset_screen.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
-#include "chromeos/dbus/session_manager_client.h"
+#include "chromeos/dbus/session_manager/session_manager_client.h"
#include "components/login/localized_values_builder.h"
#include "components/strings/grit/components_strings.h"
-namespace {
-
-const char kJsScreenPath[] = "login.ResetScreen";
-
-} // namespace
-
namespace chromeos {
ResetScreenHandler::ResetScreenHandler(JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.ResetScreen.userActed");
}
ResetScreenHandler::~ResetScreenHandler() {
@@ -35,6 +29,16 @@ ResetScreenHandler::~ResetScreenHandler() {
screen_->OnViewDestroyed(this);
}
+void ResetScreenHandler::Bind(ResetScreen* screen) {
+ screen_ = screen;
+ BaseScreenHandler::SetBaseScreen(screen_);
+}
+
+void ResetScreenHandler::Unbind() {
+ screen_ = nullptr;
+ BaseScreenHandler::SetBaseScreen(nullptr);
+}
+
void ResetScreenHandler::Show() {
if (!page_is_ready()) {
show_on_init_ = true;
@@ -48,7 +52,6 @@ void ResetScreenHandler::Hide() {
void ResetScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
- builder->Add("resetScreenTitle", IDS_RESET_SCREEN_TITLE);
builder->Add("resetScreenAccessibleTitle", IDS_RESET_SCREEN_TITLE);
builder->Add("resetScreenIconTitle", IDS_RESET_SCREEN_ICON_TITLE);
builder->Add("resetScreenIllustrationTitle",
@@ -94,6 +97,11 @@ void ResetScreenHandler::DeclareLocalizedValues(
builder->Add("confirmResetButton", IDS_RESET_SCREEN_POPUP_CONFIRM_BUTTON);
}
+void ResetScreenHandler::DeclareJSCallbacks() {
+ AddCallback("ResetScreen.setTpmFirmwareUpdateChecked",
+ &ResetScreenHandler::HandleSetTpmFirmwareUpdateChecked);
+}
+
void ResetScreenHandler::Initialize() {
if (!page_is_ready())
return;
@@ -104,14 +112,70 @@ void ResetScreenHandler::Initialize() {
}
}
-void ResetScreenHandler::Bind(ResetScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreen(screen_);
+void ResetScreenHandler::SetIsRollbackAvailable(bool value) {
+ is_rollback_available_ = value;
+ CallJS("login.ResetScreen.setIsRollbackAvailable", value);
}
-void ResetScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreen(nullptr);
+void ResetScreenHandler::SetIsRollbackChecked(bool value) {
+ is_rollback_checked_ = value;
+ CallJS("login.ResetScreen.setIsRollbackChecked", value);
+}
+
+void ResetScreenHandler::SetIsTpmFirmwareUpdateAvailable(bool value) {
+ CallJS("login.ResetScreen.setIsTpmFirmwareUpdateAvailable", value);
+}
+
+void ResetScreenHandler::SetIsTpmFirmwareUpdateChecked(bool value) {
+ is_tpm_firmware_update_checked_ = value;
+ CallJS("login.ResetScreen.setIsTpmFirmwareUpdateChecked", value);
+}
+
+void ResetScreenHandler::SetIsTpmFirmwareUpdateEditable(bool value) {
+ CallJS("login.ResetScreen.setIsTpmFirmwareUpdateEditable", value);
+}
+
+void ResetScreenHandler::SetTpmFirmwareUpdateMode(
+ tpm_firmware_update::Mode value) {
+ mode_ = value;
+ CallJS("login.ResetScreen.setTpmFirmwareUpdateMode", static_cast<int>(value));
+}
+
+void ResetScreenHandler::SetIsConfirmational(bool value) {
+ CallJS("login.ResetScreen.setIsConfirmational", value);
+}
+
+void ResetScreenHandler::SetIsOfficialBuild(bool value) {
+ CallJS("login.ResetScreen.setIsOfficialBuild", value);
+}
+
+void ResetScreenHandler::SetScreenState(State value) {
+ state_ = value;
+ CallJS("login.ResetScreen.setScreenState", static_cast<int>(value));
+}
+
+ResetView::State ResetScreenHandler::GetScreenState() {
+ return state_;
+}
+
+tpm_firmware_update::Mode ResetScreenHandler::GetTpmFirmwareUpdateMode() {
+ return mode_;
+}
+
+bool ResetScreenHandler::GetIsRollbackAvailable() {
+ return is_rollback_available_;
+}
+
+bool ResetScreenHandler::GetIsRollbackChecked() {
+ return is_rollback_checked_;
+}
+
+bool ResetScreenHandler::GetIsTpmFirmwareUpdateChecked() {
+ return is_tpm_firmware_update_checked_;
+}
+
+void ResetScreenHandler::HandleSetTpmFirmwareUpdateChecked(bool value) {
+ is_tpm_firmware_update_checked_ = value;
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
index f69d5b2cb65..e23e06bf8e5 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h
@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/login/screens/reset_view.h"
+#include "chrome/browser/chromeos/tpm_firmware_update.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "content/public/browser/web_ui.h"
@@ -29,14 +30,37 @@ class ResetScreenHandler : public ResetView,
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
+ void DeclareJSCallbacks() override;
void Initialize() override;
+ void SetIsRollbackAvailable(bool value) override;
+ void SetIsRollbackChecked(bool value) override;
+ void SetIsTpmFirmwareUpdateAvailable(bool value) override;
+ void SetIsTpmFirmwareUpdateChecked(bool value) override;
+ void SetIsTpmFirmwareUpdateEditable(bool value) override;
+ void SetTpmFirmwareUpdateMode(tpm_firmware_update::Mode value) override;
+ void SetIsConfirmational(bool value) override;
+ void SetIsOfficialBuild(bool value) override;
+ void SetScreenState(State value) override;
+ State GetScreenState() override;
+ tpm_firmware_update::Mode GetTpmFirmwareUpdateMode() override;
+ bool GetIsRollbackAvailable() override;
+ bool GetIsRollbackChecked() override;
+ bool GetIsTpmFirmwareUpdateChecked() override;
private:
+ void HandleSetTpmFirmwareUpdateChecked(bool value);
+
ResetScreen* screen_ = nullptr;
// If true, Initialize() will call Show().
bool show_on_init_ = false;
+ ResetView::State state_ = ResetView::State::kRestartRequired;
+ tpm_firmware_update::Mode mode_ = tpm_firmware_update::Mode::kNone;
+ bool is_rollback_available_ = false;
+ bool is_rollback_checked_ = false;
+ bool is_tpm_firmware_update_checked_ = false;
+
DISALLOW_COPY_AND_ASSIGN(ResetScreenHandler);
};
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 7f656be840c..d0fec1de240 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
@@ -12,8 +12,6 @@
#include "ash/public/cpp/login_constants.h"
#include "ash/public/cpp/wallpaper_types.h"
-#include "ash/public/interfaces/constants.mojom.h"
-#include "ash/public/interfaces/shutdown.mojom.h"
#include "ash/public/interfaces/tray_action.mojom.h"
#include "base/bind.h"
#include "base/i18n/number_formatting.h"
@@ -83,7 +81,7 @@
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/login/auth/key.h"
#include "chromeos/login/auth/user_context.h"
#include "chromeos/network/network_state.h"
@@ -102,9 +100,7 @@
#include "components/version_info/version_info.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/common/service_manager_connection.h"
#include "google_apis/gaia/gaia_auth_util.h"
-#include "services/service_manager/public/cpp/connector.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/ime/chromeos/ime_keyboard.h"
#include "ui/base/ime/chromeos/input_method_descriptor.h"
@@ -326,14 +322,6 @@ void SigninScreenHandler::DeclareLocalizedValues(
builder->Add("submitButtonAccessibleName",
IDS_LOGIN_POD_SUBMIT_BUTTON_ACCESSIBLE_NAME);
builder->Add("signedIn", IDS_SCREEN_LOCK_ACTIVE_USER);
- builder->Add("launchAppButton", IDS_LAUNCH_APP_BUTTON);
- builder->Add("restart", IDS_ASH_SHELF_RESTART_BUTTON);
- builder->Add("shutDown", IDS_ASH_SHELF_SHUTDOWN_BUTTON);
- builder->Add("addUser", IDS_ASH_ADD_USER_BUTTON);
- builder->Add("browseAsGuest", IDS_ASH_BROWSE_AS_GUEST_BUTTON);
- builder->Add("moreOptions", IDS_MORE_OPTIONS_BUTTON);
- builder->Add("cancel", IDS_ASH_SHELF_CANCEL_BUTTON);
- builder->Add("signOutUser", IDS_ASH_SHELF_SIGN_OUT_BUTTON);
builder->Add("offlineLogin", IDS_OFFLINE_LOGIN_HTML);
builder->Add("ownerUserPattern", IDS_LOGIN_POD_OWNER_USER);
builder->Add("removeUser", IDS_LOGIN_POD_REMOVE_USER);
@@ -440,15 +428,6 @@ void SigninScreenHandler::DeclareLocalizedValues(
IDS_ENTERPRISE_ENROLLMENT_AUTH_FATAL_ERROR);
builder->Add("insecureURLEnrollmentError",
IDS_ENTERPRISE_ENROLLMENT_AUTH_INSECURE_URL_ERROR);
-
- builder->Add("unrecoverableCryptohomeErrorMessageTitle",
- IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_TITLE);
- builder->Add("unrecoverableCryptohomeErrorMessage",
- IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_MESSAGE);
- builder->Add("unrecoverableCryptohomeErrorContinue",
- IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_CONTINUE);
- builder->Add("unrecoverableCryptohomeErrorRecreatingProfile",
- IDS_LOGIN_UNRECOVERABLE_CRYPTOHOME_ERROR_WAIT_MESSAGE);
}
void SigninScreenHandler::RegisterMessages() {
@@ -460,7 +439,6 @@ void SigninScreenHandler::RegisterMessages() {
&SigninScreenHandler::HandleLaunchPublicSession);
AddRawCallback("offlineLogin", &SigninScreenHandler::HandleOfflineLogin);
AddCallback("rebootSystem", &SigninScreenHandler::HandleRebootSystem);
- AddCallback("shutdownSystem", &SigninScreenHandler::HandleShutdownSystem);
AddCallback("removeUser", &SigninScreenHandler::HandleRemoveUser);
AddCallback("toggleEnrollmentScreen",
&SigninScreenHandler::HandleToggleEnrollmentScreen);
@@ -470,7 +448,6 @@ void SigninScreenHandler::RegisterMessages() {
&SigninScreenHandler::HandleToggleKioskEnableScreen);
AddCallback("accountPickerReady",
&SigninScreenHandler::HandleAccountPickerReady);
- AddCallback("signOutUser", &SigninScreenHandler::HandleSignOutUser);
AddCallback("openInternetDetailDialog",
&SigninScreenHandler::HandleOpenInternetDetailDialog);
AddCallback("loginVisible", &SigninScreenHandler::HandleLoginVisible);
@@ -497,14 +474,6 @@ void SigninScreenHandler::RegisterMessages() {
AddCallback("maxIncorrectPasswordAttempts",
&SigninScreenHandler::HandleMaxIncorrectPasswordAttempts);
AddCallback("sendFeedback", &SigninScreenHandler::HandleSendFeedback);
- AddCallback("sendFeedbackAndResyncUserData",
- &SigninScreenHandler::HandleSendFeedbackAndResyncUserData);
-
- // This message is sent by the kiosk app menu, but is handled here
- // so we can tell the delegate to launch the app.
- AddCallback("launchKioskApp", &SigninScreenHandler::HandleLaunchKioskApp);
- AddCallback("launchArcKioskApp",
- &SigninScreenHandler::HandleLaunchArcKioskApp);
}
void SigninScreenHandler::Show(const LoginScreenContext& context,
@@ -592,23 +561,20 @@ void SigninScreenHandler::ShowImpl() {
->GetImeKeyboard()
->SetCapsLockEnabled(false);
- base::DictionaryValue params;
- params.SetBoolean("disableAddUser", AllWhitelistedUsersPresent());
- UpdateUIState(UI_STATE_ACCOUNT_PICKER, &params);
+ UpdateUIState(UI_STATE_ACCOUNT_PICKER);
}
}
-void SigninScreenHandler::UpdateUIState(UIState ui_state,
- base::DictionaryValue* params) {
+void SigninScreenHandler::UpdateUIState(UIState ui_state) {
switch (ui_state) {
case UI_STATE_GAIA_SIGNIN:
ui_state_ = UI_STATE_GAIA_SIGNIN;
- ShowScreenWithData(OobeScreen::SCREEN_GAIA_SIGNIN, params);
+ ShowScreen(OobeScreen::SCREEN_GAIA_SIGNIN);
break;
case UI_STATE_ACCOUNT_PICKER:
ui_state_ = UI_STATE_ACCOUNT_PICKER;
gaia_screen_handler_->CancelShowGaiaAsync();
- ShowScreenWithData(OobeScreen::SCREEN_ACCOUNT_PICKER, params);
+ ShowScreen(OobeScreen::SCREEN_ACCOUNT_PICKER);
break;
default:
NOTREACHED();
@@ -850,12 +816,6 @@ void SigninScreenHandler::Initialize() {
}
}
-gfx::NativeWindow SigninScreenHandler::GetNativeWindow() {
- if (native_window_delegate_)
- return native_window_delegate_->GetNativeWindow();
- return nullptr;
-}
-
void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(prefs::kUsersLastInputMethod);
}
@@ -967,8 +927,7 @@ void SigninScreenHandler::OnPreferencesChanged() {
// We need to reload GAIA if UI_STATE_UNKNOWN or the allow new user setting
// has changed so that reloaded GAIA shows/hides the option to create a new
// account.
- UpdateUIState(UI_STATE_ACCOUNT_PICKER, nullptr);
- UpdateAddButtonStatus();
+ UpdateUIState(UI_STATE_ACCOUNT_PICKER);
}
}
@@ -1008,10 +967,6 @@ void SigninScreenHandler::ShowWhitelistCheckFailedError() {
gaia_screen_handler_->ShowWhitelistCheckFailedError();
}
-void SigninScreenHandler::ShowUnrecoverableCrypthomeErrorDialog() {
- CallJS("login.UnrecoverableCryptohomeErrorScreen.show");
-}
-
void SigninScreenHandler::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -1074,11 +1029,6 @@ bool SigninScreenHandler::ShouldLoadGaia() const {
is_account_picker_showing_first_time_;
}
-void SigninScreenHandler::UpdateAddButtonStatus() {
- CallJS("cr.ui.login.DisplayManager.updateAddUserButtonStatus",
- AllWhitelistedUsersPresent());
-}
-
void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin) {
@@ -1178,16 +1128,7 @@ void SigninScreenHandler::HandleOfflineLogin(const base::ListValue* args) {
gaia_screen_handler_->set_populated_email(email);
gaia_screen_handler_->LoadAuthExtension(true /* force */, true /* offline */);
- UpdateUIState(UI_STATE_GAIA_SIGNIN, nullptr);
-}
-
-void SigninScreenHandler::HandleShutdownSystem() {
- ash::mojom::ShutdownControllerPtr shutdown_controller;
- content::ServiceManagerConnection::GetForProcess()
- ->GetConnector()
- ->BindInterface(ash::mojom::kServiceName, &shutdown_controller);
-
- shutdown_controller->RequestShutdownFromLoginScreen();
+ UpdateUIState(UI_STATE_GAIA_SIGNIN);
}
void SigninScreenHandler::HandleRebootSystem() {
@@ -1207,7 +1148,6 @@ void SigninScreenHandler::HandleRemoveUser(const AccountId& account_id) {
if (!delegate_)
return;
delegate_->RemoveUser(account_id);
- UpdateAddButtonStatus();
}
void SigninScreenHandler::HandleToggleEnrollmentScreen() {
@@ -1239,8 +1179,7 @@ void SigninScreenHandler::HandleToggleKioskAutolaunchScreen() {
void SigninScreenHandler::LoadUsers(const user_manager::UserList& users,
const base::ListValue& users_list) {
- CallJS("login.AccountPickerScreen.loadUsers", users_list,
- delegate_->IsShowGuest());
+ CallJS("login.AccountPickerScreen.loadUsers", users_list);
// Enable pin for any users who can use it.
// TODO(jdufault): Cache pin state in BrowserProcess::local_state() so we
@@ -1266,19 +1205,6 @@ void SigninScreenHandler::HandleAccountPickerReady() {
return;
}
- PrefService* prefs = g_browser_process->local_state();
- if (prefs->GetBoolean(prefs::kFactoryResetRequested)) {
- if (core_oobe_view_)
- core_oobe_view_->ShowDeviceResetScreen();
-
- return;
- } else if (prefs->GetBoolean(prefs::kDebuggingFeaturesRequested)) {
- if (core_oobe_view_)
- core_oobe_view_->ShowEnableDebuggingScreen();
-
- return;
- }
-
is_account_picker_showing_first_time_ = true;
// The wallpaper may have been set before the instance is initialized, so make
@@ -1303,11 +1229,6 @@ void SigninScreenHandler::HandleAccountPickerReady() {
delegate_->OnSigninScreenReady();
}
-void SigninScreenHandler::HandleSignOutUser() {
- if (delegate_)
- delegate_->Signout();
-}
-
void SigninScreenHandler::HandleOpenInternetDetailDialog() {
// Empty string opens the internet detail dialog for the default network.
InternetDetailDialog::ShowDialog("");
@@ -1443,22 +1364,6 @@ void SigninScreenHandler::SendPublicSessionKeyboardLayouts(
account_id, locale, *keyboard_layouts);
}
-void SigninScreenHandler::HandleLaunchKioskApp(const AccountId& app_account_id,
- bool diagnostic_mode) {
- UserContext context(user_manager::USER_TYPE_KIOSK_APP, app_account_id);
- SigninSpecifics specifics;
- specifics.kiosk_diagnostic_mode = diagnostic_mode;
- if (delegate_)
- delegate_->Login(context, specifics);
-}
-
-void SigninScreenHandler::HandleLaunchArcKioskApp(
- const AccountId& app_account_id) {
- UserContext context(user_manager::USER_TYPE_ARC_KIOSK_APP, app_account_id);
- if (delegate_)
- delegate_->Login(context, SigninSpecifics());
-}
-
void SigninScreenHandler::HandleGetTabletModeState() {
CallJS("login.AccountPickerScreen.setTabletModeState",
TabletModeClient::Get()->tablet_mode_enabled());
@@ -1496,21 +1401,6 @@ void SigninScreenHandler::HandleSendFeedback() {
weak_factory_.GetWeakPtr()));
}
-void SigninScreenHandler::HandleSendFeedbackAndResyncUserData() {
- const std::string description = base::StringPrintf(
- "Auto generated feedback for http://crbug.com/547857.\n"
- "(uniquifier:%s)",
- base::NumberToString(base::Time::Now().ToInternalValue()).c_str());
-
- login_feedback_ =
- std::make_unique<LoginFeedback>(Profile::FromWebUI(web_ui()));
- login_feedback_->Request(
- description,
- base::BindOnce(
- &SigninScreenHandler::OnUnrecoverableCryptohomeFeedbackFinished,
- weak_factory_.GetWeakPtr()));
-}
-
bool SigninScreenHandler::AllWhitelistedUsersPresent() {
CrosSettings* cros_settings = CrosSettings::Get();
bool allow_new_user = false;
@@ -1574,15 +1464,6 @@ void SigninScreenHandler::OnFeedbackFinished() {
login_feedback_.reset();
}
-void SigninScreenHandler::OnUnrecoverableCryptohomeFeedbackFinished() {
- CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI");
-
- // Recreate user's cryptohome after the feedback is attempted.
- HandleResyncUserData();
-
- login_feedback_.reset();
-}
-
void SigninScreenHandler::OnAllowedInputMethodsChanged() {
if (!webui_visible_)
return;
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 57de4217785..9256d90029a 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
@@ -26,7 +26,7 @@
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
-#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/network/portal_detector/network_portal_detector.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_observer.h"
@@ -47,7 +47,6 @@ enum class TrayActionState;
} // namespace ash
namespace base {
-class DictionaryValue;
class ListValue;
}
@@ -93,7 +92,6 @@ class LoginDisplayWebUIHandler {
virtual void ShowPasswordChangedDialog(bool show_password_error,
const std::string& email) = 0;
virtual void ShowWhitelistCheckFailedError() = 0;
- virtual void ShowUnrecoverableCrypthomeErrorDialog() = 0;
virtual void LoadUsers(const user_manager::UserList& users,
const base::ListValue& users_list) = 0;
@@ -225,7 +223,7 @@ class SigninScreenHandler
// OobeUI::Observer implementation:
void OnCurrentScreenChanged(OobeScreen current_screen,
OobeScreen new_screen) override;
- void OnScreenInitialized(OobeScreen screen) override {}
+ void OnDestroyingOobeUI() override {}
// ash::mojom::WallpaperObserver implementation:
void OnWallpaperChanged(uint32_t image_id) override;
@@ -261,9 +259,8 @@ class SigninScreenHandler
void ShowImpl();
// Updates current UI of the signin screen according to |ui_state|
- // argument. Optionally it can pass screen initialization data via
- // |params| argument.
- void UpdateUIState(UIState ui_state, base::DictionaryValue* params);
+ // argument.
+ void UpdateUIState(UIState ui_state);
void UpdateStateInternal(NetworkError::ErrorReason reason, bool force_update);
void SetupAndShowOfflineMessage(NetworkStateInformer::State state,
@@ -276,7 +273,6 @@ class SigninScreenHandler
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
void Initialize() override;
- gfx::NativeWindow GetNativeWindow() override;
// WebUIMessageHandler implementation:
void RegisterMessages() override;
@@ -298,7 +294,6 @@ class SigninScreenHandler
const std::string& email) override;
void ShowErrorScreen(LoginDisplay::SigninError error_id) override;
void ShowWhitelistCheckFailedError() override;
- void ShowUnrecoverableCrypthomeErrorDialog() override;
void LoadUsers(const user_manager::UserList& users,
const base::ListValue& users_list) override;
@@ -313,8 +308,6 @@ class SigninScreenHandler
// TabletModeClientObserver:
void OnTabletModeToggled(bool enabled) override;
- void UpdateAddButtonStatus();
-
// Restore input focus to current user pod.
void RefocusCurrentPod();
@@ -338,7 +331,6 @@ class SigninScreenHandler
const std::string& locale,
const std::string& input_method);
void HandleOfflineLogin(const base::ListValue* args);
- void HandleShutdownSystem();
void HandleRebootSystem();
void HandleRemoveUser(const AccountId& account_id);
void HandleToggleEnrollmentScreen();
@@ -354,7 +346,6 @@ class SigninScreenHandler
// * After OOBE enrollment when policy contains device local accounts.
// * On multiple sign-in account selection.
void HandleAccountPickerReady();
- void HandleSignOutUser();
void HandleOpenInternetDetailDialog();
void HandleLoginVisible(const std::string& source);
void HandleCancelPasswordChangedFlow(const AccountId& account_id);
@@ -378,7 +369,6 @@ class SigninScreenHandler
void HandleFirstIncorrectPasswordAttempt(const AccountId& account_id);
void HandleMaxIncorrectPasswordAttempts(const AccountId& account_id);
void HandleSendFeedback();
- void HandleSendFeedbackAndResyncUserData();
// Implements user sign-in.
void AuthenticateExistingUser(const AccountId& account_id,
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc
index a79033e88a7..afbd0859f76 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/supervision_transition_screen_handler.cc
@@ -21,7 +21,6 @@
namespace {
-constexpr char kJsScreenPath[] = "login.SupervisionTransitionScreen";
constexpr base::TimeDelta kWaitingTimeout = base::TimeDelta::FromMinutes(2);
} // namespace
@@ -31,7 +30,6 @@ namespace chromeos {
SupervisionTransitionScreenHandler::SupervisionTransitionScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
}
SupervisionTransitionScreenHandler::~SupervisionTransitionScreenHandler() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
index 471107776a9..b9f404dbace 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
@@ -12,8 +12,6 @@
namespace {
-const char kJsScreenPath[] = "login.SyncConsentScreen";
-
// This helper function gets strings from WebUI and a set of known string
// resource ids, and converts strings back to IDs. It CHECKs if string is not
// found in resources.
@@ -60,7 +58,7 @@ namespace chromeos {
SyncConsentScreenHandler::SyncConsentScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.SyncConsentScreen.userActed");
}
SyncConsentScreenHandler::~SyncConsentScreenHandler() {}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
index 9b5753eeb4c..ea0e3ccab1d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.cc
@@ -30,12 +30,6 @@
#include "content/public/browser/web_ui.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
-namespace {
-
-const char kJsScreenPath[] = "login.TermsOfServiceScreen";
-
-} // namespace
-
namespace chromeos {
TermsOfServiceScreenHandler::TermsOfServiceScreenHandler(
@@ -43,7 +37,6 @@ TermsOfServiceScreenHandler::TermsOfServiceScreenHandler(
CoreOobeView* core_oobe_view)
: BaseScreenHandler(kScreenId, js_calls_container),
core_oobe_view_(core_oobe_view) {
- set_call_js_prefix(kJsScreenPath);
}
TermsOfServiceScreenHandler::~TermsOfServiceScreenHandler() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc
index 16995e2b874..a91034af634 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.cc
@@ -13,18 +13,11 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-const char kJsScreenPath[] = "login.UpdateRequiredScreen";
-
-} // namespace
-
namespace chromeos {
UpdateRequiredScreenHandler::UpdateRequiredScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
}
UpdateRequiredScreenHandler::~UpdateRequiredScreenHandler() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc
index 97bae0b70fd..caa21e642c3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.cc
@@ -13,17 +13,11 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-const char kJsScreenPath[] = "login.UpdateScreen";
-
-} // namespace
-
namespace chromeos {
UpdateScreenHandler::UpdateScreenHandler(JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.UpdateScreen.userActed");
}
UpdateScreenHandler::~UpdateScreenHandler() {
@@ -31,12 +25,63 @@ UpdateScreenHandler::~UpdateScreenHandler() {
screen_->OnViewDestroyed(this);
}
+void UpdateScreenHandler::Show() {
+ if (!page_is_ready()) {
+ show_on_init_ = true;
+ return;
+ }
+ ShowScreen(kScreenId);
+}
+
+void UpdateScreenHandler::Hide() {}
+
+void UpdateScreenHandler::Bind(UpdateScreen* screen) {
+ screen_ = screen;
+ BaseScreenHandler::SetBaseScreen(screen_);
+}
+
+void UpdateScreenHandler::Unbind() {
+ screen_ = nullptr;
+ BaseScreenHandler::SetBaseScreen(nullptr);
+}
+
+void UpdateScreenHandler::SetEstimatedTimeLeft(int value) {
+ CallJS("login.UpdateScreen.setEstimatedTimeLeft", value);
+}
+
+void UpdateScreenHandler::SetShowEstimatedTimeLeft(bool value) {
+ CallJS("login.UpdateScreen.showEstimatedTimeLeft", value);
+}
+
+void UpdateScreenHandler::SetUpdateCompleted(bool value) {
+ CallJS("login.UpdateScreen.setUpdateCompleted", value);
+}
+
+void UpdateScreenHandler::SetShowCurtain(bool value) {
+ CallJS("login.UpdateScreen.showUpdateCurtain", value);
+}
+
+void UpdateScreenHandler::SetProgressMessage(const base::string16& value) {
+ CallJS("login.UpdateScreen.setProgressMessage", value);
+}
+
+void UpdateScreenHandler::SetProgress(int value) {
+ CallJS("login.UpdateScreen.setUpdateProgress", value);
+}
+
+void UpdateScreenHandler::SetRequiresPermissionForCellular(bool value) {
+ CallJS("login.UpdateScreen.setRequiresPermissionForCellular", value);
+}
+
+void UpdateScreenHandler::SetCancelUpdateShortcutEnabled(bool value) {
+ CallJS("login.UpdateScreen.setCancelUpdateShortcutEnabled", value);
+}
+
void UpdateScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("checkingForUpdatesMsg", IDS_CHECKING_FOR_UPDATE_MSG);
builder->Add("installingUpdateDesc", IDS_UPDATE_MSG);
builder->Add("updateCompeletedMsg", IDS_UPDATE_COMPLETED);
- builder->Add("updateScreenTitle", IDS_UPDATE_SCREEN_TITLE);
builder->Add("updateScreenAccessibleTitle",
IDS_UPDATE_SCREEN_ACCESSIBLE_TITLE);
builder->Add("checkingForUpdates", IDS_CHECKING_FOR_UPDATES);
@@ -72,25 +117,4 @@ void UpdateScreenHandler::Initialize() {
}
}
-void UpdateScreenHandler::Show() {
- if (!page_is_ready()) {
- show_on_init_ = true;
- return;
- }
- ShowScreen(kScreenId);
-}
-
-void UpdateScreenHandler::Hide() {
-}
-
-void UpdateScreenHandler::Bind(UpdateScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreen(screen_);
-}
-
-void UpdateScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreen(nullptr);
-}
-
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h
index 5f8648349f1..fbca33da5f1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/update_screen_handler.h
@@ -25,6 +25,14 @@ class UpdateScreenHandler : public UpdateView, public BaseScreenHandler {
void Hide() override;
void Bind(UpdateScreen* screen) override;
void Unbind() override;
+ void SetEstimatedTimeLeft(int value) override;
+ void SetShowEstimatedTimeLeft(bool value) override;
+ void SetUpdateCompleted(bool value) override;
+ void SetShowCurtain(bool value) override;
+ void SetProgressMessage(const base::string16& value) override;
+ void SetProgress(int value) override;
+ void SetRequiresPermissionForCellular(bool value) override;
+ void SetCancelUpdateShortcutEnabled(bool value) override;
// BaseScreenHandler:
void DeclareLocalizedValues(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc
index 2042a7dbb39..857cdfe006e 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.cc
@@ -94,12 +94,12 @@ void UserBoardScreenHandler::SetAuthType(
void UserBoardScreenHandler::Bind(UserSelectionScreen* screen) {
screen_ = screen;
- BaseWebUIHandler::SetBaseScreen(screen_);
+ SetBaseScreen(screen_);
}
void UserBoardScreenHandler::Unbind() {
screen_ = nullptr;
- BaseWebUIHandler::SetBaseScreen(nullptr);
+ SetBaseScreen(nullptr);
}
base::WeakPtr<UserBoardView> UserBoardScreenHandler::GetWeakPtr() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc
deleted file mode 100644
index f922809bc2f..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc
+++ /dev/null
@@ -1,187 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h"
-
-#include <utility>
-
-#include "base/base64.h"
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/metrics/histogram_macros.h"
-#include "base/stl_util.h"
-#include "base/values.h"
-#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
-#include "chrome/browser/chromeos/login/existing_user_controller.h"
-#include "chrome/browser/chromeos/login/oobe_screen.h"
-#include "chrome/browser/chromeos/login/screens/user_image_screen.h"
-#include "chrome/browser/chromeos/login/ui/login_display_webui.h"
-#include "chrome/browser/chromeos/login/users/default_user_image/default_user_images.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/browser_resources.h"
-#include "chrome/grit/generated_resources.h"
-#include "chromeos/audio/chromeos_sounds.h"
-#include "components/login/localized_values_builder.h"
-#include "components/strings/grit/components_strings.h"
-#include "components/user_manager/user.h"
-#include "media/audio/sounds/sounds_manager.h"
-#include "net/base/data_url.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "url/gurl.h"
-
-namespace {
-
-const char kJsScreenPath[] = "login.UserImageScreen";
-
-} // namespace
-
-namespace chromeos {
-
-UserImageScreenHandler::UserImageScreenHandler(
- JSCallsContainer* js_calls_container)
- : BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- media::SoundsManager* manager = media::SoundsManager::Get();
- manager->Initialize(SOUND_OBJECT_DELETE,
- bundle.GetRawDataResource(IDR_SOUND_OBJECT_DELETE_WAV));
- manager->Initialize(SOUND_CAMERA_SNAP,
- bundle.GetRawDataResource(IDR_SOUND_CAMERA_SNAP_WAV));
-}
-
-UserImageScreenHandler::~UserImageScreenHandler() {
- if (screen_)
- screen_->OnViewDestroyed(this);
-}
-
-void UserImageScreenHandler::Initialize() {
- if (show_on_init_) {
- Show();
- show_on_init_ = false;
- }
-}
-
-void UserImageScreenHandler::Bind(UserImageScreen* screen) {
- screen_ = screen;
- BaseScreenHandler::SetBaseScreen(screen_);
-}
-
-void UserImageScreenHandler::Unbind() {
- screen_ = nullptr;
- BaseScreenHandler::SetBaseScreen(nullptr);
-}
-
-void UserImageScreenHandler::Show() {
- if (!page_is_ready()) {
- show_on_init_ = true;
- return;
- }
- screen_show_time_ = base::Time::Now();
- ShowScreen(kScreenId);
-
- // When shown, query camera presence.
- if (screen_ && is_ready_)
- screen_->OnScreenReady();
-}
-
-void UserImageScreenHandler::Hide() {
-}
-
-void UserImageScreenHandler::DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) {
- builder->Add("userImageScreenTitle", IDS_USER_IMAGE_SCREEN_TITLE);
- builder->Add("userImageScreenDescription",
- IDS_USER_IMAGE_SCREEN_DESCRIPTION);
- builder->Add("takePhoto", IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO);
- builder->Add("captureVideo", IDS_OPTIONS_CHANGE_PICTURE_CAPTURE_VIDEO);
- builder->Add("discardPhoto", IDS_OPTIONS_CHANGE_PICTURE_DISCARD_PHOTO);
- builder->Add("switchModeToCamera",
- IDS_OPTIONS_CHANGE_PICTURE_SWITCH_MODE_TO_CAMERA);
- builder->Add("switchModeToVideo",
- IDS_OPTIONS_CHANGE_PICTURE_SWITCH_MODE_TO_VIDEO);
- builder->Add("profilePhoto", IDS_IMAGE_SCREEN_PROFILE_PHOTO);
- builder->Add("profilePhotoLoading",
- IDS_IMAGE_SCREEN_PROFILE_LOADING_PHOTO);
- builder->Add("okButtonText", IDS_OK);
- builder->Add("photoFromCamera", IDS_OPTIONS_CHANGE_PICTURE_PHOTO_FROM_CAMERA);
- builder->Add("syncingPreferences", IDS_IMAGE_SCREEN_SYNCING_PREFERENCES);
-}
-
-void UserImageScreenHandler::RegisterMessages() {
- AddCallback("getImages", &UserImageScreenHandler::HandleGetImages);
- AddCallback("screenReady", &UserImageScreenHandler::HandleScreenReady);
- AddCallback("discardPhoto", &UserImageScreenHandler::HandleDiscardPhoto);
- AddCallback("photoTaken", &UserImageScreenHandler::HandlePhotoTaken);
- AddCallback("selectImage", &UserImageScreenHandler::HandleSelectImage);
- AddCallback("onUserImageAccepted",
- &UserImageScreenHandler::HandleImageAccepted);
- AddCallback("onUserImageScreenShown",
- &UserImageScreenHandler::HandleScreenShown);
-}
-
-// TODO(antrim) : It looks more like parameters for "Init" rather than callback.
-void UserImageScreenHandler::HandleGetImages() {
- base::DictionaryValue result;
- result.SetInteger("first", default_user_image::GetFirstDefaultImage());
- std::unique_ptr<base::ListValue> default_images =
- default_user_image::GetAsDictionary(true /* all */);
- result.Set("images", std::move(default_images));
- CallJS("login.UserImageScreen.setDefaultImages", result);
-}
-
-void UserImageScreenHandler::HandleScreenReady() {
- is_ready_ = true;
- if (screen_)
- screen_->OnScreenReady();
-}
-
-void UserImageScreenHandler::HandlePhotoTaken(const std::string& image_url) {
- AccessibilityManager::Get()->PlayEarcon(
- SOUND_CAMERA_SNAP, PlaySoundOption::ONLY_IF_SPOKEN_FEEDBACK_ENABLED);
-
- std::string raw_data;
- base::StringPiece url(image_url);
- const char kDataUrlPrefix[] = "data:image/png;base64,";
- const size_t kDataUrlPrefixLength = base::size(kDataUrlPrefix) - 1;
- if (!url.starts_with(kDataUrlPrefix) ||
- !base::Base64Decode(url.substr(kDataUrlPrefixLength), &raw_data)) {
- LOG(WARNING) << "Invalid image URL";
- return;
- }
-
- if (screen_)
- screen_->OnPhotoTaken(raw_data);
-}
-
-void UserImageScreenHandler::HandleDiscardPhoto() {
- AccessibilityManager::Get()->PlayEarcon(
- SOUND_OBJECT_DELETE, PlaySoundOption::ONLY_IF_SPOKEN_FEEDBACK_ENABLED);
-}
-
-void UserImageScreenHandler::HandleSelectImage(const std::string& image_type,
- const std::string& image_url,
- bool is_user_selection) {
- if (screen_)
- screen_->OnImageSelected(image_type, image_url, is_user_selection);
-}
-
-void UserImageScreenHandler::HandleImageAccepted() {
- if (screen_)
- screen_->OnImageAccepted();
-}
-
-void UserImageScreenHandler::HandleScreenShown() {
- DCHECK(!screen_show_time_.is_null());
-
- base::TimeDelta delta = base::Time::Now() - screen_show_time_;
- VLOG(1) << "Screen load time: " << delta.InSecondsF();
- UMA_HISTOGRAM_TIMES("UserImage.ScreenIsShownTime", delta);
-}
-
-void UserImageScreenHandler::HideCurtain() {
- CallJS("login.UserImageScreen.hideCurtain");
-}
-
-} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h
deleted file mode 100644
index 3fea9aab370..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_
-
-#include <string>
-
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/time/time.h"
-#include "chrome/browser/chromeos/login/screens/user_image_view.h"
-#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
-#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/native_widget_types.h"
-
-namespace chromeos {
-
-// WebUI implementation of UserImageView. It is used to interact with the JS
-// page allowing user to select an avatar.
-class UserImageScreenHandler : public UserImageView, public BaseScreenHandler {
- public:
- explicit UserImageScreenHandler(JSCallsContainer* js_calls_container);
- ~UserImageScreenHandler() override;
-
- private:
- // BaseScreenHandler implementation:
- void Initialize() override;
- void DeclareLocalizedValues(
- ::login::LocalizedValuesBuilder* builder) override;
-
- // WebUIMessageHandler implementation:
- void RegisterMessages() override;
-
- // UserImageView implementation:
- void Bind(UserImageScreen* screen) override;
- void Unbind() override;
- void Show() override;
- void Hide() override;
- void HideCurtain() override;
-
- // Sends image data to the page.
- void HandleGetImages();
-
- // Screen ready to be shown.
- void HandleScreenReady();
-
- // Handles photo taken with WebRTC UI.
- void HandlePhotoTaken(const std::string& image_url);
-
- // Handles 'discard-photo' button click.
- void HandleDiscardPhoto();
-
- // Handles clicking on default user image.
- void HandleSelectImage(const std::string& image_type,
- const std::string& image_url,
- bool is_user_selection);
-
- // Called when user accept the image closing the screen.
- void HandleImageAccepted();
-
- // Called when the user image screen has been loaded and shown.
- void HandleScreenShown();
-
- UserImageScreen* screen_ = nullptr;
-
- // Keeps whether screen should be shown right after initialization.
- bool show_on_init_ = false;
-
- // Keeps whether screen has loaded all default images and redy to be shown.
- bool is_ready_ = false;
-
- base::Time screen_show_time_;
-
- DISALLOW_COPY_AND_ASSIGN(UserImageScreenHandler);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_IMAGE_SCREEN_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.cc
index 7df979af8c5..d8c998bf9bb 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
@@ -35,12 +35,6 @@
#include "ui/base/ime/chromeos/extension_ime_util.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
-namespace {
-
-const char kJsScreenPath[] = "login.WelcomeScreen";
-
-} // namespace
-
namespace chromeos {
// WelcomeScreenHandler, public: -----------------------------------------------
@@ -49,7 +43,7 @@ WelcomeScreenHandler::WelcomeScreenHandler(JSCallsContainer* js_calls_container,
CoreOobeView* core_oobe_view)
: BaseScreenHandler(kScreenId, js_calls_container),
core_oobe_view_(core_oobe_view) {
- set_call_js_prefix(kJsScreenPath);
+ set_user_acted_method_path("login.WelcomeScreen.userActed");
DCHECK(core_oobe_view_);
}
@@ -114,10 +108,6 @@ void WelcomeScreenHandler::SetInputMethodId(
CallJS("login.WelcomeScreen.onInputMethodIdSetFromBackend", input_method_id);
}
-void WelcomeScreenHandler::SetTimezoneId(const std::string& timezone_id) {
- CallJS("login.WelcomeScreen.onTimezoneIdSetFromBackend", timezone_id);
-}
-
// WelcomeScreenHandler, BaseScreenHandler implementation: --------------------
void WelcomeScreenHandler::DeclareLocalizedValues(
@@ -127,8 +117,6 @@ void WelcomeScreenHandler::DeclareLocalizedValues(
else
builder->Add("welcomeScreenGreeting", IDS_WELCOME_SCREEN_GREETING);
- builder->Add("welcomeScreenTitle", IDS_WELCOME_SCREEN_TITLE);
-
// MD-OOBE (oobe-welcome-md)
builder->Add("debuggingFeaturesLink", IDS_WELCOME_ENABLE_DEV_FEATURES_LINK);
builder->Add("timezoneDropdownLabel", IDS_TIMEZONE_DROPDOWN_LABEL);
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 de60b3cecef..38b5be34a27 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h
@@ -9,7 +9,6 @@
#include <string>
#include "base/macros.h"
-#include "chrome/browser/chromeos/login/screens/welcome_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
namespace base {
@@ -19,6 +18,36 @@ class ListValue;
namespace chromeos {
class CoreOobeView;
+class WelcomeScreen;
+
+// Interface for WelcomeScreenHandler.
+class WelcomeView {
+ public:
+ constexpr static OobeScreen kScreenId = OobeScreen::SCREEN_OOBE_WELCOME;
+
+ virtual ~WelcomeView() {}
+
+ // Shows the contents of the screen.
+ virtual void Show() = 0;
+
+ // Hides the contents of the screen.
+ virtual void Hide() = 0;
+
+ // Binds |screen| to the view.
+ virtual void Bind(WelcomeScreen* screen) = 0;
+
+ // Unbinds model from the view.
+ virtual void Unbind() = 0;
+
+ // Stops demo mode detection.
+ virtual void StopDemoModeDetection() = 0;
+
+ // Reloads localized contents.
+ virtual void ReloadLocalizedContent() = 0;
+
+ // Change the current input method.
+ virtual void SetInputMethodId(const std::string& input_method_id) = 0;
+};
// WebUI implementation of WelcomeScreenView. It is used to interact with
// the welcome screen (part of the page) of the OOBE.
@@ -28,8 +57,7 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler {
CoreOobeView* core_oobe_view);
~WelcomeScreenHandler() override;
- private:
- // WelcomeView implementation:
+ // WelcomeView:
void Show() override;
void Hide() override;
void Bind(WelcomeScreen* screen) override;
@@ -37,15 +65,15 @@ class WelcomeScreenHandler : public WelcomeView, public BaseScreenHandler {
void StopDemoModeDetection() override;
void ReloadLocalizedContent() override;
void SetInputMethodId(const std::string& input_method_id) override;
- void SetTimezoneId(const std::string& timezone_id) override;
- // BaseScreenHandler implementation:
+ // BaseScreenHandler:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
void DeclareJSCallbacks() override;
void GetAdditionalParameters(base::DictionaryValue* dict) override;
void Initialize() override;
+ private:
// JS callbacks.
void HandleSetLocaleId(const std::string& locale_id);
void HandleSetInputMethodId(const std::string& input_method_id);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc
index dacdaa0de6f..a8331d2c29f 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.cc
@@ -8,18 +8,11 @@
#include "chrome/grit/generated_resources.h"
#include "components/login/localized_values_builder.h"
-namespace {
-
-const char kJsScreenPath[] = "login.WrongHWIDScreen";
-
-} // namespace
-
namespace chromeos {
WrongHWIDScreenHandler::WrongHWIDScreenHandler(
JSCallsContainer* js_calls_container)
: BaseScreenHandler(kScreenId, js_calls_container) {
- set_call_js_prefix(kJsScreenPath);
}
WrongHWIDScreenHandler::~WrongHWIDScreenHandler() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc
index 29d6bbc74f8..3ccb3286b03 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.cc
@@ -8,7 +8,7 @@
#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/settings_window_manager_chromeos.h"
#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
#include "chrome/common/webui_url_constants.h"
#include "components/user_manager/user.h"
@@ -60,8 +60,8 @@ void MultideviceSetupHandler::HandleGetProfileInfo(
void MultideviceSetupHandler::HandleOpenMultiDeviceSettings(
const base::ListValue* args) {
DCHECK(args->empty());
- chrome::ShowSettingsSubPageForProfile(Profile::FromWebUI(web_ui()),
- chrome::kConnectedDevicesSubPage);
+ chrome::SettingsWindowManager::GetInstance()->ShowOSSettings(
+ Profile::FromWebUI(web_ui()), chrome::kConnectedDevicesSubPage);
}
} // namespace multidevice_setup
diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
index 7494e78e108..1513366c2d6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/network_ui.cc
@@ -14,6 +14,7 @@
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/extensions/tab_helper.h"
+#include "chrome/browser/ui/webui/chromeos/cellular_setup/cellular_setup_dialog_launcher.h"
#include "chrome/browser/ui/webui/chromeos/internet_config_dialog.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chrome/common/url_constants.h"
@@ -37,8 +38,10 @@ namespace chromeos {
namespace {
+constexpr char kAddNetwork[] = "addNetwork";
constexpr char kGetNetworkProperties[] = "getShillNetworkProperties";
constexpr char kGetDeviceProperties[] = "getShillDeviceProperties";
+constexpr char kOpenCellularActivationUi[] = "openCellularActivationUi";
bool GetServicePathFromGuid(const std::string& guid,
std::string* service_path) {
@@ -84,6 +87,10 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
// WebUIMessageHandler implementation.
void RegisterMessages() override {
web_ui()->RegisterMessageCallback(
+ kAddNetwork,
+ base::BindRepeating(&NetworkConfigMessageHandler::AddNetwork,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
kGetNetworkProperties,
base::BindRepeating(
&NetworkConfigMessageHandler::GetShillNetworkProperties,
@@ -94,9 +101,10 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
&NetworkConfigMessageHandler::GetShillDeviceProperties,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "addNetwork",
- base::BindRepeating(&NetworkConfigMessageHandler::AddNetwork,
- base::Unretained(this)));
+ kOpenCellularActivationUi,
+ base::BindRepeating(
+ &NetworkConfigMessageHandler::OpenCellularActivationUi,
+ base::Unretained(this)));
}
private:
@@ -165,6 +173,19 @@ class NetworkConfigMessageHandler : public content::WebUIMessageHandler {
weak_ptr_factory_.GetWeakPtr(), type, kGetDeviceProperties));
}
+ void OpenCellularActivationUi(const base::ListValue* arg_list) {
+ const NetworkState* cellular_network =
+ NetworkHandler::Get()->network_state_handler()->FirstNetworkByType(
+ NetworkTypePattern::Cellular());
+ if (cellular_network)
+ cellular_setup::OpenCellularSetupDialog(cellular_network->guid());
+
+ AllowJavascript();
+ CallJavascriptFunction(
+ base::StringPrintf("NetworkUI.%sResult", kOpenCellularActivationUi),
+ base::Value(cellular_network != nullptr));
+ }
+
void GetShillDevicePropertiesSuccess(
const std::string& device_path,
const base::DictionaryValue& dictionary) {
@@ -263,6 +284,17 @@ void NetworkUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
l10n_util::GetStringUTF16(IDS_NETWORK_UI_FAVORITE_NETWORKS));
localized_strings->SetString(
"devicesLabel", l10n_util::GetStringUTF16(IDS_NETWORK_UI_DEVICES));
+
+ localized_strings->SetString(
+ "cellularActivationLabel",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_NO_CELLULAR_ACTIVATION_LABEL));
+ localized_strings->SetString(
+ "cellularActivationButtonText",
+ l10n_util::GetStringUTF16(
+ IDS_NETWORK_UI_OPEN_CELLULAR_ACTIVATION_BUTTON_TEXT));
+ localized_strings->SetString(
+ "noCellularErrorText",
+ l10n_util::GetStringUTF16(IDS_NETWORK_UI_NO_CELLULAR_ERROR_TEXT));
}
NetworkUI::NetworkUI(content::WebUI* web_ui)
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 a40bd56e9ba..a5e4b5daf33 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui.cc
@@ -12,7 +12,9 @@
#include "base/bind_helpers.h"
#include "base/build_time.h"
#include "base/macros.h"
+#include "base/scoped_observer.h"
#include "base/values.h"
+#include "chrome/browser/chromeos/set_time_dialog.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/system/timezone_util.h"
#include "chrome/browser/profiles/profile.h"
@@ -20,8 +22,8 @@
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/dbus/system_clock/system_clock_client.h"
-#include "chromeos/login/login_state/login_state.h"
#include "chromeos/settings/timezone_settings.h"
+#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -35,19 +37,16 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
public chromeos::SystemClockClient::Observer,
public system::TimezoneSettings::Observer {
public:
- SetTimeMessageHandler() {
- system::TimezoneSettings::GetInstance()->AddObserver(this);
- SystemClockClient::Get()->AddObserver(this);
- }
-
- ~SetTimeMessageHandler() override {
- system::TimezoneSettings::GetInstance()->RemoveObserver(this);
- SystemClockClient::Get()->RemoveObserver(this);
- }
+ SetTimeMessageHandler() = default;
+ ~SetTimeMessageHandler() override = default;
// WebUIMessageHandler:
void RegisterMessages() override {
web_ui()->RegisterMessageCallback(
+ "setTimePageReady",
+ base::BindRepeating(&SetTimeMessageHandler::OnPageReady,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"setTimeInSeconds",
base::BindRepeating(&SetTimeMessageHandler::OnSetTime,
base::Unretained(this)));
@@ -57,10 +56,22 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
base::Unretained(this)));
}
+ void OnJavascriptAllowed() override {
+ clock_observer_.Add(SystemClockClient::Get());
+ timezone_observer_.Add(system::TimezoneSettings::GetInstance());
+ }
+
+ void OnJavascriptDisallowed() override {
+ clock_observer_.RemoveAll();
+ timezone_observer_.RemoveAll();
+ }
+
private:
+ void OnPageReady(const base::ListValue* args) { AllowJavascript(); }
+
// SystemClockClient::Observer:
void SystemClockUpdated() override {
- web_ui()->CallJavascriptFunctionUnsafe("settime.TimeSetter.updateTime");
+ FireWebUIListener("system-clock-updated");
}
// UI actually shows real device timezone, but only allows changing the user
@@ -70,8 +81,7 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
// system::TimezoneSettings::Observer:
void TimezoneChanged(const icu::TimeZone& timezone) override {
base::Value timezone_id(system::TimezoneSettings::GetTimezoneID(timezone));
- web_ui()->CallJavascriptFunctionUnsafe("settime.TimeSetter.setTimezone",
- timezone_id);
+ FireWebUIListener("system-timezone-changed", timezone_id);
}
// Handler for Javascript call to set the system clock when the user sets a
@@ -102,6 +112,11 @@ class SetTimeMessageHandler : public content::WebUIMessageHandler,
system::SetTimezoneFromUI(profile, timezone_id);
}
+ ScopedObserver<SystemClockClient, SystemClockClient::Observer>
+ clock_observer_{this};
+ ScopedObserver<system::TimezoneSettings, system::TimezoneSettings::Observer>
+ timezone_observer_{this};
+
DISALLOW_COPY_AND_ASSIGN(SetTimeMessageHandler);
};
@@ -116,19 +131,19 @@ SetTimeUI::SetTimeUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
source->AddLocalizedString("setTimeTitle", IDS_SET_TIME_TITLE);
source->AddLocalizedString("prompt", IDS_SET_TIME_PROMPT);
- source->AddLocalizedString("doneButton", IDS_SET_TIME_BUTTON_CLOSE);
- source->AddLocalizedString("timezone",
- IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION);
+ source->AddLocalizedString("timezoneLabel", IDS_SET_TIME_TIMEZONE_LABEL);
source->AddLocalizedString("dateLabel", IDS_SET_TIME_DATE_LABEL);
source->AddLocalizedString("timeLabel", IDS_SET_TIME_TIME_LABEL);
+ source->AddLocalizedString("doneButton", IDS_DONE);
base::DictionaryValue values;
+ // List of list of strings: [[ID, name], [ID, name], ...]
values.Set("timezoneList", chromeos::system::GetTimezoneList());
// If we are not logged in, we need to show the time zone dropdown.
// Otherwise, we can leave |currentTimezoneId| blank.
std::string current_timezone_id;
- if (!LoginState::Get()->IsUserLoggedIn())
+ if (SetTimeDialog::ShouldShowTimezone())
CrosSettings::Get()->GetString(kSystemTimezone, &current_timezone_id);
values.SetString("currentTimezoneId", current_timezone_id);
values.SetDouble("buildTime", base::GetBuildTime().ToJsTime());
@@ -136,14 +151,17 @@ SetTimeUI::SetTimeUI(content::WebUI* web_ui) : WebDialogUI(web_ui) {
source->AddLocalizedStrings(values);
source->SetJsonPath("strings.js");
- source->AddResourcePath("set_time.css", IDR_SET_TIME_CSS);
- source->AddResourcePath("set_time.js", IDR_SET_TIME_JS);
- source->SetDefaultResource(IDR_SET_TIME_HTML);
+ source->UseGzip();
+ source->AddResourcePath("set_time_browser_proxy.html",
+ IDR_SET_TIME_BROWSER_PROXY_HTML);
+ source->AddResourcePath("set_time_browser_proxy.js",
+ IDR_SET_TIME_BROWSER_PROXY_JS);
+ source->AddResourcePath("set_time_dialog.js", IDR_SET_TIME_DIALOG_JS);
+ source->SetDefaultResource(IDR_SET_TIME_DIALOG_HTML);
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
-SetTimeUI::~SetTimeUI() {
-}
+SetTimeUI::~SetTimeUI() = default;
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui_browsertest.js b/chromium/chrome/browser/ui/webui/chromeos/set_time_ui_browsertest.js
deleted file mode 100644
index 1249c87450f..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/set_time_ui_browsertest.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-GEN('#if defined(OS_CHROMEOS)');
-
-/**
- * SetTimeWebUITest tests loading and interacting with the SetTimeUI web UI,
- * which is normally shown as a dialog.
- * @constructor
- * @extends {testing.Test}
- */
-function SetTimeWebUITest() {}
-
-SetTimeWebUITest.prototype = {
- __proto__: testing.Test.prototype,
-
- /**
- * Browse to set time dialog.
- * @override
- */
- browsePreload: 'chrome://set-time/',
-};
-
-TEST_F('SetTimeWebUITest', 'testChangeTimezone', function() {
- assertEquals(this.browsePreload, document.location.href);
-
- var TimeSetter = settime.TimeSetter;
-
- // Verify timezone.
- TimeSetter.setTimezone('America/New_York');
- expectEquals('America/New_York', $('timezone-select').value);
- TimeSetter.setTimezone('Europe/Moscow');
- expectEquals('Europe/Moscow', $('timezone-select').value);
-});
-
-GEN('#endif');
diff --git a/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
index 2e5b4c353f2..614813d57ed 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/slow_ui.cc
@@ -49,9 +49,10 @@ content::WebUIDataSource* CreateSlowUIHTMLSource() {
source->AddLocalizedString("slowDescription", IDS_SLOW_DESCRIPTION);
source->AddLocalizedString("slowWarning", IDS_SLOW_WARNING);
- source->SetJsonPath("strings.js");
source->AddResourcePath("slow.js", IDR_SLOW_JS);
+ source->AddResourcePath("slow.css", IDR_SLOW_CSS);
source->SetDefaultResource(IDR_SLOW_HTML);
+ source->UseGzip();
return source;
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc
index c85fa6da82c..c7cc5bffd2d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.cc
@@ -19,7 +19,7 @@ namespace chromeos {
namespace smb_dialog {
namespace {
-constexpr int kSmbShareDialogHeight = 522;
+constexpr int kSmbShareDialogHeight = 524;
void AddSmbSharesStrings(content::WebUIDataSource* html_source) {
// Add strings specific to smb_dialog.
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 1c5c87bf0d9..cb9f0cb2843 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
@@ -94,6 +94,10 @@ void SystemWebDialogDelegate::GetDialogSize(gfx::Size* size) const {
size->SetSize(kDialogWidth, kDialogHeight);
}
+bool SystemWebDialogDelegate::CanResizeDialog() const {
+ return false;
+}
+
std::string SystemWebDialogDelegate::GetDialogArgs() const {
return std::string();
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h
index d28c825317d..2d9cc364a82 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
@@ -49,6 +49,7 @@ class SystemWebDialogDelegate : public ui::WebDialogDelegate {
void GetWebUIMessageHandlers(
std::vector<content::WebUIMessageHandler*>* handlers) const override;
void GetDialogSize(gfx::Size* size) const override;
+ bool CanResizeDialog() const override;
std::string GetDialogArgs() const override;
void OnDialogShown(content::WebUI* webui,
content::RenderViewHost* render_view_host) override;
@@ -72,6 +73,9 @@ class SystemWebDialogDelegate : public ui::WebDialogDelegate {
protected:
FRIEND_TEST_ALL_PREFIXES(SystemWebDialogLoginTest, NonModalTest);
+
+ // Returns the dialog window (pointer to |aura::Window|). This will be a
+ // |nullptr| if the dialog has not been created yet.
gfx::NativeWindow dialog_window() const { return dialog_window_; }
private:
@@ -79,7 +83,7 @@ class SystemWebDialogDelegate : public ui::WebDialogDelegate {
base::string16 title_;
content::WebUI* webui_ = nullptr;
ui::ModalType modal_type_;
- gfx::NativeWindow dialog_window_;
+ gfx::NativeWindow dialog_window_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(SystemWebDialogDelegate);
};
diff --git a/chromium/chrome/browser/ui/webui/chromeos/video_source.cc b/chromium/chrome/browser/ui/webui/chromeos/video_source.cc
index c269329efd6..c42955ad542 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/video_source.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/video_source.cc
@@ -14,7 +14,7 @@
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
-#include "base/task/task_scheduler/task_scheduler.h"
+#include "base/task/thread_pool/thread_pool.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/common/url_constants.h"
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc
new file mode 100644
index 00000000000..e75d19e24b7
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.cc
@@ -0,0 +1,511 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h"
+
+#include <string>
+#include <utility>
+
+#include "base/task/post_task.h"
+#include "base/win/windows_version.h"
+#include "chrome/browser/conflicts/module_database_win.h"
+#include "content/public/browser/browser_task_traits.h"
+#include "content/public/browser/browser_thread.h"
+
+#if defined(GOOGLE_CHROME_BUILD)
+#include "base/enterprise_util.h"
+#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
+
+namespace {
+
+// Converts the process_types bit field to a simple string representation where
+// each process type is represented by a letter. E.g. B for browser process.
+// Full process names are not used in order to save horizontal space in the
+// conflicts UI.
+std::string GetProcessTypesString(const ModuleInfoData& module_data) {
+ uint32_t process_types = module_data.process_types;
+
+ if (!process_types)
+ return "None";
+
+ std::string result;
+ if (process_types & ProcessTypeToBit(content::PROCESS_TYPE_BROWSER))
+ result.append("B");
+ if (process_types & ProcessTypeToBit(content::PROCESS_TYPE_RENDERER))
+ result.append("R");
+ // TODO(pmonette): Add additional process types as more get supported.
+
+ return result;
+}
+
+#if defined(GOOGLE_CHROME_BUILD)
+
+// Strings used twice.
+constexpr char kNotLoaded[] = "Not loaded";
+constexpr char kAllowedInProcessType[] = "Allowed - Loaded in allowed process";
+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 kNotAnalyzed[] =
+ "Tolerated - Not analyzed (See https://crbug.com/892294)";
+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::kNotLoaded:
+ return kNotLoaded;
+ case BlockingDecision::kAllowedInProcessType:
+ return kAllowedInProcessType;
+ 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::kNotAnalyzed:
+ return kNotAnalyzed;
+ 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::kAllowedInProcessType:
+ return kAllowedInProcessType;
+ 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::kNotAnalyzed:
+ return kNotAnalyzed;
+ 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) {
+ if (!incompatible_applications_updater && !module_blacklist_cache_updater)
+ return std::string();
+
+ std::string status;
+
+ // The blocking status is shown over the warning status.
+ if (module_blacklist_cache_updater) {
+ 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) {
+ AppendString(GetModuleWarningDecisionString(
+ module_key, incompatible_applications_updater),
+ &status);
+ }
+
+ return status;
+}
+#endif // defined(GOOGLE_CHROME_BUILD)
+
+enum ThirdPartyFeaturesStatus {
+ // The third-party features are not available in non-Google Chrome builds.
+ kNonGoogleChromeBuild,
+ // The third-party features are not available on Windows 7.
+ kNotAvailableWin7,
+ // 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
+ // ThirdPartyModulesBlocking features are disabled.
+ kFeatureDisabled,
+ // The Module List version received is invalid.
+ kModuleListInvalid,
+ // There is no Module List version available.
+ kNoModuleListAvailable,
+ // Only the IncompatibleApplicationsWarning feature is initialized.
+ kWarningInitialized,
+ // Only the ThirdPartyModulesBlocking feature is initialized.
+ kBlockingInitialized,
+ // Both the IncompatibleApplicationsWarning and the
+ // ThirdPartyModulesBlocking feature are initialized.
+ kWarningAndBlockingInitialized,
+};
+
+#if defined(GOOGLE_CHROME_BUILD)
+ThirdPartyFeaturesStatus GetThirdPartyFeaturesStatus(
+ base::Optional<ThirdPartyConflictsManager::State>
+ third_party_conflicts_manager_state) {
+ // The ThirdPartyConflictsManager instance exists if we have its state.
+ if (third_party_conflicts_manager_state.has_value()) {
+ switch (third_party_conflicts_manager_state.value()) {
+ case ThirdPartyConflictsManager::State::kModuleListInvalidFailure:
+ return kModuleListInvalid;
+ case ThirdPartyConflictsManager::State::kNoModuleListAvailableFailure:
+ return kNoModuleListAvailable;
+ case ThirdPartyConflictsManager::State::kWarningInitialized:
+ return kWarningInitialized;
+ case ThirdPartyConflictsManager::State::kBlockingInitialized:
+ return kBlockingInitialized;
+ case ThirdPartyConflictsManager::State::kWarningAndBlockingInitialized:
+ return kWarningAndBlockingInitialized;
+ case ThirdPartyConflictsManager::State::kDestroyed:
+ // Turning off the feature via group policy is the only way to have the
+ // manager destroyed.
+ return kPolicyDisabled;
+ }
+ }
+
+ // Figure out why the manager instance doesn't exist.
+ if (base::win::GetVersion() <= base::win::VERSION_WIN7)
+ return kNotAvailableWin7;
+
+ if (!ModuleDatabase::IsThirdPartyBlockingPolicyEnabled())
+ return kPolicyDisabled;
+
+ if (!IncompatibleApplicationsUpdater::IsWarningEnabled() &&
+ !ModuleBlacklistCacheUpdater::IsBlockingEnabled()) {
+ return kFeatureDisabled;
+ }
+
+ if (base::IsMachineExternallyManaged())
+ return kEnterpriseManaged;
+
+ // The above 3 cases are the only possible reasons why the manager wouldn't
+ // exist.
+ NOTREACHED();
+ return kFeatureDisabled;
+}
+#endif
+
+bool IsThirdPartyFeatureEnabled(ThirdPartyFeaturesStatus status) {
+ return status == kWarningInitialized || status == kBlockingInitialized ||
+ status == kWarningAndBlockingInitialized;
+}
+
+std::string GetThirdPartyFeaturesStatusString(ThirdPartyFeaturesStatus status) {
+ switch (status) {
+ case ThirdPartyFeaturesStatus::kNonGoogleChromeBuild:
+ return "The third-party features are not available in non-Google Chrome "
+ "builds.";
+ case ThirdPartyFeaturesStatus::kNotAvailableWin7:
+ return "The third-party features are not available on Windows 7.";
+ 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:
+ if (base::win::GetVersion() < base::win::VERSION_WIN10)
+ return "The ThirdPartyModulesBlocking feature is disabled.";
+
+ return "Both the IncompatibleApplicationsWarning and "
+ "ThirdPartyModulesBlocking features are disabled.";
+ case ThirdPartyFeaturesStatus::kModuleListInvalid:
+ return "Disabled - The Module List component version is invalid.";
+ case ThirdPartyFeaturesStatus::kNoModuleListAvailable:
+ return "Disabled - There is no Module List version available.";
+ case ThirdPartyFeaturesStatus::kWarningInitialized:
+ DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN10);
+ return "The IncompatibleApplicationsWarning feature is enabled, while "
+ "the ThirdPartyModulesBlocking feature is disabled.";
+ case ThirdPartyFeaturesStatus::kBlockingInitialized:
+ if (base::win::GetVersion() < base::win::VERSION_WIN10)
+ return "The ThirdPartyModulesBlocking feature is enabled.";
+
+ return "The ThirdPartyModulesBlocking feature is enabled, while the "
+ "IncompatibleApplicationsWarning feature is disabled.";
+ case ThirdPartyFeaturesStatus::kWarningAndBlockingInitialized:
+ DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN10);
+ return "Both the IncompatibleApplicationsWarning and "
+ "ThirdPartyModulesBlocking features are enabled";
+ }
+}
+
+void OnConflictsDataFetched(
+ ConflictsDataFetcher::OnConflictsDataFetchedCallback
+ on_conflicts_data_fetched_callback,
+ base::DictionaryValue results,
+ ThirdPartyFeaturesStatus third_party_features_status) {
+ // Third-party conflicts status.
+ results.SetBoolean("thirdPartyFeatureEnabled",
+ IsThirdPartyFeatureEnabled(third_party_features_status));
+ results.SetString(
+ "thirdPartyFeatureStatus",
+ GetThirdPartyFeaturesStatusString(third_party_features_status));
+
+ std::move(on_conflicts_data_fetched_callback).Run(std::move(results));
+}
+
+#if defined(GOOGLE_CHROME_BUILD)
+void OnModuleDataFetched(ConflictsDataFetcher::OnConflictsDataFetchedCallback
+ on_conflicts_data_fetched_callback,
+ base::DictionaryValue results,
+ base::Optional<ThirdPartyConflictsManager::State>
+ third_party_conflicts_manager_state) {
+ OnConflictsDataFetched(
+ std::move(on_conflicts_data_fetched_callback), std::move(results),
+ GetThirdPartyFeaturesStatus(third_party_conflicts_manager_state));
+}
+#endif // defined(GOOGLE_CHROME_BUILD)
+
+} // namespace
+
+ConflictsDataFetcher::~ConflictsDataFetcher() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+
+ if (module_list_)
+ ModuleDatabase::GetInstance()->RemoveObserver(this);
+}
+
+// static
+ConflictsDataFetcher::UniquePtr ConflictsDataFetcher::Create(
+ OnConflictsDataFetchedCallback on_conflicts_data_fetched_callback) {
+ return std::unique_ptr<ConflictsDataFetcher, base::OnTaskRunnerDeleter>(
+ new ConflictsDataFetcher(std::move(on_conflicts_data_fetched_callback)),
+ base::OnTaskRunnerDeleter(ModuleDatabase::GetTaskRunner()));
+}
+
+ConflictsDataFetcher::ConflictsDataFetcher(
+ OnConflictsDataFetchedCallback on_conflicts_data_fetched_callback)
+ : on_conflicts_data_fetched_callback_(
+ std::move(on_conflicts_data_fetched_callback))
+#if defined(GOOGLE_CHROME_BUILD)
+ ,
+ weak_ptr_factory_(this)
+#endif
+{
+ DETACH_FROM_SEQUENCE(sequence_checker_);
+
+ ModuleDatabase::GetTaskRunner()->PostTask(
+ FROM_HERE,
+ base::BindOnce(
+ &ConflictsDataFetcher::InitializeOnModuleDatabaseTaskRunner,
+ base::Unretained(this)));
+}
+
+void ConflictsDataFetcher::InitializeOnModuleDatabaseTaskRunner() {
+#if defined(GOOGLE_CHROME_BUILD)
+ // If the ThirdPartyConflictsManager instance exists, wait until it is fully
+ // initialized before retrieving the list of modules.
+ auto* third_party_conflicts_manager =
+ ModuleDatabase::GetInstance()->third_party_conflicts_manager();
+ if (third_party_conflicts_manager) {
+ third_party_conflicts_manager->ForceInitialization(base::BindRepeating(
+ &ConflictsDataFetcher::OnManagerInitializationComplete,
+ weak_ptr_factory_.GetWeakPtr()));
+ return;
+ }
+#endif
+
+ GetListOfModules();
+}
+
+#if defined(GOOGLE_CHROME_BUILD)
+void ConflictsDataFetcher::OnManagerInitializationComplete(
+ ThirdPartyConflictsManager::State state) {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+
+ third_party_conflicts_manager_state_ = state;
+
+ GetListOfModules();
+}
+#endif // defined(GOOGLE_CHROME_BUILD)
+
+void ConflictsDataFetcher::GetListOfModules() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+
+ // The request is handled asynchronously, filling up the |module_list_|,
+ // and will callback via OnModuleDatabaseIdle() on completion.
+ module_list_ = std::make_unique<base::ListValue>();
+
+ auto* module_database = ModuleDatabase::GetInstance();
+ module_database->IncreaseInspectionPriority();
+ module_database->AddObserver(this);
+}
+
+void ConflictsDataFetcher::OnNewModuleFound(const ModuleInfoKey& module_key,
+ const ModuleInfoData& module_data) {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK(module_list_);
+
+ auto data = std::make_unique<base::DictionaryValue>();
+
+ data->SetString("third_party_module_status", std::string());
+#if defined(GOOGLE_CHROME_BUILD)
+ if (ModuleDatabase::GetInstance()->third_party_conflicts_manager()) {
+ auto* incompatible_applications_updater =
+ ModuleDatabase::GetInstance()
+ ->third_party_conflicts_manager()
+ ->incompatible_applications_updater();
+ auto* module_blacklist_cache_updater =
+ ModuleDatabase::GetInstance()
+ ->third_party_conflicts_manager()
+ ->module_blacklist_cache_updater();
+
+ data->SetString(
+ "third_party_module_status",
+ GetModuleStatusString(module_key, incompatible_applications_updater,
+ module_blacklist_cache_updater));
+ }
+#endif // defined(GOOGLE_CHROME_BUILD)
+
+ std::string type_string;
+ if (module_data.module_properties & ModuleInfoData::kPropertyShellExtension)
+ type_string = "Shell extension";
+ data->SetString("type_description", type_string);
+
+ const auto& inspection_result = *module_data.inspection_result;
+ data->SetString("location", inspection_result.location);
+ data->SetString("name", inspection_result.basename);
+ data->SetString("product_name", inspection_result.product_name);
+ data->SetString("description", inspection_result.description);
+ data->SetString("version", inspection_result.version);
+ data->SetString("digital_signer", inspection_result.certificate_info.subject);
+ data->SetString("code_id", GenerateCodeId(module_key));
+ data->SetString("process_types", GetProcessTypesString(module_data));
+
+ module_list_->Append(std::move(data));
+}
+
+void ConflictsDataFetcher::OnModuleDatabaseIdle() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ DCHECK(module_list_);
+
+ ModuleDatabase::GetInstance()->RemoveObserver(this);
+
+ base::DictionaryValue results;
+ results.SetInteger("moduleCount", module_list_->GetSize());
+ results.Set("moduleList", std::move(module_list_));
+
+#if defined(GOOGLE_CHROME_BUILD)
+ // The state of third-party features must be determined on the UI thread.
+ base::PostTaskWithTraits(
+ FROM_HERE, {content::BrowserThread::UI},
+ base::BindOnce(
+ OnModuleDataFetched, std::move(on_conflicts_data_fetched_callback_),
+ std::move(results), std::move(third_party_conflicts_manager_state_)));
+#else
+ // The third-party features are always disabled on Chromium builds.
+ base::PostTaskWithTraits(
+ FROM_HERE, {content::BrowserThread::UI},
+ base::BindOnce(OnConflictsDataFetched,
+ std::move(on_conflicts_data_fetched_callback_),
+ std::move(results), kNonGoogleChromeBuild));
+#endif
+}
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h
new file mode 100644
index 00000000000..e1d0533b403
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h
@@ -0,0 +1,84 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CONFLICTS_CONFLICTS_DATA_FETCHER_H_
+#define CHROME_BROWSER_UI_WEBUI_CONFLICTS_CONFLICTS_DATA_FETCHER_H_
+
+#include <memory>
+
+#include "base/callback.h"
+#include "base/optional.h"
+#include "base/sequence_checker.h"
+#include "base/sequenced_task_runner.h"
+#include "build/build_config.h"
+#include "chrome/browser/conflicts/module_database_observer_win.h"
+
+#if defined(GOOGLE_CHROME_BUILD)
+#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h"
+#endif
+
+namespace base {
+class DictionaryValue;
+class ListValue;
+} // namespace base
+
+// This class is responsible for gathering the list of modules for the
+// chrome://conflicts page and the state of the third-party features on the
+// ModuleDatabase task runner and sending it back to the UI thread. The instance
+// should be deleted once the OnConflictsDataFetchedCallback is invoked.
+class ConflictsDataFetcher : public ModuleDatabaseObserver {
+ public:
+ using UniquePtr =
+ std::unique_ptr<ConflictsDataFetcher, base::OnTaskRunnerDeleter>;
+ using OnConflictsDataFetchedCallback =
+ base::OnceCallback<void(base::DictionaryValue results)>;
+
+ ~ConflictsDataFetcher() override;
+
+ // Creates the instance and initializes it on the ModuleDatabase task runner.
+ // |on_conflicts_data_fetched_callback| will be invoked on the caller's
+ // sequence.
+ static UniquePtr Create(
+ OnConflictsDataFetchedCallback on_conflicts_data_fetched_callback);
+
+ private:
+ explicit ConflictsDataFetcher(
+ OnConflictsDataFetchedCallback on_conflicts_data_fetched_callback);
+
+ void InitializeOnModuleDatabaseTaskRunner();
+
+#if defined(GOOGLE_CHROME_BUILD)
+ // Invoked when the ThirdPartyConflictsManager initialization state is
+ // available.
+ void OnManagerInitializationComplete(ThirdPartyConflictsManager::State state);
+#endif
+
+ // Registers this instance to the ModuleDatabase to retrieve the list of
+ // modules via the ModuleDatabaseObserver API.
+ void GetListOfModules();
+
+ // ModuleDatabaseObserver:
+ void OnNewModuleFound(const ModuleInfoKey& module_key,
+ const ModuleInfoData& module_data) override;
+ void OnModuleDatabaseIdle() override;
+
+ OnConflictsDataFetchedCallback on_conflicts_data_fetched_callback_;
+
+ // Temporarily holds the module list while the modules are being
+ // enumerated.
+ std::unique_ptr<base::ListValue> module_list_;
+
+ SEQUENCE_CHECKER(sequence_checker_);
+
+#if defined(GOOGLE_CHROME_BUILD)
+ base::Optional<ThirdPartyConflictsManager::State>
+ third_party_conflicts_manager_state_;
+
+ base::WeakPtrFactory<ConflictsDataFetcher> weak_ptr_factory_;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(ConflictsDataFetcher);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_CONFLICTS_CONFLICTS_DATA_FETCHER_H_
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
index f0ed130bea4..55b5fc5ef3e 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.cc
@@ -7,404 +7,46 @@
#include <utility>
#include "base/bind.h"
-#include "base/bind_helpers.h"
-#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"
-#include "chrome/browser/conflicts/module_info_win.h"
-#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
-#include "ui/base/l10n/l10n_util.h"
-#if defined(GOOGLE_CHROME_BUILD)
-#include "base/enterprise_util.h"
-#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
+ConflictsHandler::ConflictsHandler()
+ : conflicts_data_fetcher_(nullptr, base::OnTaskRunnerDeleter(nullptr)),
+ weak_ptr_factory_(this) {}
-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 kNotAnalyzed[] =
- "Tolerated - Not analyzed (See https://crbug.com/892294)";
-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::kNotAnalyzed:
- return kNotAnalyzed;
- 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::kNotAnalyzed:
- return kNotAnalyzed;
- 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) {
- if (!incompatible_applications_updater && !module_blacklist_cache_updater)
- return std::string();
-
- std::string status;
-
- // The blocking status is shown over the warning status.
- if (module_blacklist_cache_updater) {
- 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) {
- AppendString(GetModuleWarningDecisionString(
- module_key, incompatible_applications_updater),
- &status);
- }
-
- return status;
-}
-#endif // defined(GOOGLE_CHROME_BUILD)
-
-} // namespace
-
-ConflictsHandler::ConflictsHandler() : weak_ptr_factory_(this) {}
-
-ConflictsHandler::~ConflictsHandler() {
- if (module_list_)
- ModuleDatabase::GetInstance()->RemoveObserver(this);
-}
+ConflictsHandler::~ConflictsHandler() = default;
void ConflictsHandler::RegisterMessages() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
web_ui()->RegisterMessageCallback(
"requestModuleList",
base::BindRepeating(&ConflictsHandler::HandleRequestModuleList,
base::Unretained(this)));
}
-void ConflictsHandler::OnNewModuleFound(const ModuleInfoKey& module_key,
- const ModuleInfoData& module_data) {
- DCHECK(module_list_);
-
- auto data = std::make_unique<base::DictionaryValue>();
-
- data->SetString("third_party_module_status", std::string());
-#if defined(GOOGLE_CHROME_BUILD)
- if (ModuleDatabase::GetInstance()->third_party_conflicts_manager()) {
- auto* incompatible_applications_updater =
- ModuleDatabase::GetInstance()
- ->third_party_conflicts_manager()
- ->incompatible_applications_updater();
- auto* module_blacklist_cache_updater =
- ModuleDatabase::GetInstance()
- ->third_party_conflicts_manager()
- ->module_blacklist_cache_updater();
-
- data->SetString(
- "third_party_module_status",
- GetModuleStatusString(module_key, incompatible_applications_updater,
- module_blacklist_cache_updater));
- }
-#endif // defined(GOOGLE_CHROME_BUILD)
-
- std::string type_string;
- if (module_data.module_properties & ModuleInfoData::kPropertyShellExtension)
- type_string = "Shell extension";
- data->SetString("type_description", type_string);
-
- const auto& inspection_result = *module_data.inspection_result;
- data->SetString("location", inspection_result.location);
- data->SetString("name", inspection_result.basename);
- data->SetString("product_name", inspection_result.product_name);
- data->SetString("description", inspection_result.description);
- data->SetString("version", inspection_result.version);
- data->SetString("digital_signer", inspection_result.certificate_info.subject);
- data->SetString("code_id", GenerateCodeId(module_key));
-
- module_list_->Append(std::move(data));
-}
-
-void ConflictsHandler::OnModuleDatabaseIdle() {
- DCHECK(module_list_);
- DCHECK(!module_list_callback_id_.empty());
-
- ModuleDatabase::GetInstance()->RemoveObserver(this);
-
- base::DictionaryValue results;
- results.SetInteger("moduleCount", module_list_->GetSize());
- results.Set("moduleList", std::move(module_list_));
-
- // Third-party conflicts status.
- ThirdPartyFeaturesStatus third_party_features_status =
- third_party_features_status_.value();
- results.SetBoolean("thirdPartyFeatureEnabled",
- IsThirdPartyFeatureEnabled(third_party_features_status));
- results.SetString(
- "thirdPartyFeatureStatus",
- GetThirdPartyFeaturesStatusString(third_party_features_status));
-
- AllowJavascript();
- ResolveJavascriptCallback(base::Value(module_list_callback_id_), results);
-}
-
void ConflictsHandler::HandleRequestModuleList(const base::ListValue* args) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
// Make sure the JS doesn't call 'requestModuleList' more than once.
// TODO(739291): It would be better to kill the renderer instead of the
// browser for malformed messages.
- CHECK(!module_list_);
-
CHECK_EQ(1U, args->GetSize());
CHECK(args->GetString(0, &module_list_callback_id_));
-#if defined(GOOGLE_CHROME_BUILD)
- // If the ThirdPartyConflictsManager instance exists, wait until it is fully
- // initialized before retrieving the list of modules.
- auto* third_party_conflicts_manager =
- ModuleDatabase::GetInstance()->third_party_conflicts_manager();
- if (third_party_conflicts_manager) {
- third_party_conflicts_manager->ForceInitialization(
- base::BindRepeating(&ConflictsHandler::OnManagerInitializationComplete,
- weak_ptr_factory_.GetWeakPtr()));
- return;
- }
-
- // Figure out why the manager instance doesn't exist.
- if (!ModuleDatabase::IsThirdPartyBlockingPolicyEnabled())
- third_party_features_status_ = kPolicyDisabled;
-
- if (!base::FeatureList::IsEnabled(features::kThirdPartyModulesBlocking) &&
- !IncompatibleApplicationsUpdater::IsWarningEnabled()) {
- third_party_features_status_ = kFeatureDisabled;
- }
-
- if (base::IsMachineExternallyManaged())
- 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)
- third_party_features_status_ = kNonGoogleChromeBuild;
-#endif
-
- GetListOfModules();
-}
-
-#if defined(GOOGLE_CHROME_BUILD)
-void ConflictsHandler::OnManagerInitializationComplete(
- ThirdPartyConflictsManager::State state) {
- switch (state) {
- case ThirdPartyConflictsManager::State::kModuleListInvalidFailure:
- third_party_features_status_ = kModuleListInvalid;
- break;
- case ThirdPartyConflictsManager::State::kNoModuleListAvailableFailure:
- third_party_features_status_ = kNoModuleListAvailable;
- break;
- case ThirdPartyConflictsManager::State::kWarningInitialized:
- third_party_features_status_ = kWarningInitialized;
- break;
- case ThirdPartyConflictsManager::State::kBlockingInitialized:
- third_party_features_status_ = kBlockingInitialized;
- break;
- case ThirdPartyConflictsManager::State::kWarningAndBlockingInitialized:
- third_party_features_status_ = kWarningAndBlockingInitialized;
- break;
- case ThirdPartyConflictsManager::State::kDestroyed:
- // Turning off the feature via group policy is the only way to have the
- // manager destroyed.
- third_party_features_status_ = kPolicyDisabled;
- break;
- }
-
- GetListOfModules();
+ conflicts_data_fetcher_ = ConflictsDataFetcher::Create(
+ base::BindOnce(&ConflictsHandler::OnConflictsDataFetched,
+ weak_ptr_factory_.GetWeakPtr()));
}
-#endif // defined(GOOGLE_CHROME_BUILD)
-void ConflictsHandler::GetListOfModules() {
- // The request is handled asynchronously, filling up the |module_list_|,
- // and will callback via OnModuleDatabaseIdle() on completion.
- module_list_ = std::make_unique<base::ListValue>();
-
- auto* module_database = ModuleDatabase::GetInstance();
- module_database->IncreaseInspectionPriority();
- module_database->AddObserver(this);
-}
-
-// static
-bool ConflictsHandler::IsThirdPartyFeatureEnabled(
- ThirdPartyFeaturesStatus status) {
- return status == kWarningInitialized || status == kBlockingInitialized ||
- status == kWarningAndBlockingInitialized;
-}
-
-// static
-std::string ConflictsHandler::GetThirdPartyFeaturesStatusString(
- ThirdPartyFeaturesStatus status) {
- switch (status) {
- 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:
- if (base::win::GetVersion() < base::win::VERSION_WIN10)
- return "The ThirdPartyModulesBlocking feature is disabled.";
+void ConflictsHandler::OnConflictsDataFetched(base::DictionaryValue results) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DCHECK(!module_list_callback_id_.empty());
- return "Both the IncompatibleApplicationsWarning and "
- "ThirdPartyModulesBlocking features are disabled.";
- case ThirdPartyFeaturesStatus::kModuleListInvalid:
- return "Disabled - The Module List component version is invalid.";
- case ThirdPartyFeaturesStatus::kNoModuleListAvailable:
- return "Disabled - There is no Module List version available.";
- case ThirdPartyFeaturesStatus::kWarningInitialized:
- DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN10);
- return "The IncompatibleApplicationsWarning feature is enabled, while "
- "the ThirdPartyModulesBlocking feature is disabled.";
- case ThirdPartyFeaturesStatus::kBlockingInitialized:
- if (base::win::GetVersion() < base::win::VERSION_WIN10)
- return "The ThirdPartyModulesBlocking feature is enabled.";
+ conflicts_data_fetcher_ = nullptr;
- return "The ThirdPartyModulesBlocking feature is enabled, while the "
- "IncompatibleApplicationsWarning feature is disabled.";
- case ThirdPartyFeaturesStatus::kWarningAndBlockingInitialized:
- DCHECK_GE(base::win::GetVersion(), base::win::VERSION_WIN10);
- return "Both the IncompatibleApplicationsWarning and "
- "ThirdPartyModulesBlocking features are enabled";
- }
+ AllowJavascript();
+ ResolveJavascriptCallback(base::Value(module_list_callback_id_), results);
}
diff --git a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
index 99ff0e656e4..35f4dcc7d36 100644
--- a/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
+++ b/chromium/chrome/browser/ui/webui/conflicts/conflicts_handler.h
@@ -5,94 +5,40 @@
#ifndef CHROME_BROWSER_UI_WEBUI_CONFLICTS_CONFLICTS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CONFLICTS_CONFLICTS_HANDLER_H_
-#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "chrome/browser/conflicts/module_database_observer_win.h"
+#include "chrome/browser/ui/webui/conflicts/conflicts_data_fetcher.h"
#include "content/public/browser/web_ui_message_handler.h"
-#if defined(GOOGLE_CHROME_BUILD)
-#include "chrome/browser/conflicts/third_party_conflicts_manager_win.h"
-#endif
-
namespace base {
+class DictionaryValue;
class Listvalue;
}
// This class takes care of sending the list of all loaded modules to the
// chrome://conflicts WebUI page when it is requested.
-class ConflictsHandler : public content::WebUIMessageHandler,
- public ModuleDatabaseObserver {
+class ConflictsHandler : public content::WebUIMessageHandler {
public:
ConflictsHandler();
~ConflictsHandler() override;
private:
- 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
- // ThirdPartyModulesBlocking features are disabled.
- kFeatureDisabled,
- // The Module List version received is invalid.
- kModuleListInvalid,
- // There is no Module List version available.
- kNoModuleListAvailable,
- // Only the IncompatibleApplicationsWarning feature is initialized.
- kWarningInitialized,
- // Only the ThirdPartyModulesBlocking feature is initialized.
- kBlockingInitialized,
- // Both the IncompatibleApplicationsWarning and the
- // ThirdPartyModulesBlocking feature are initialized.
- kWarningAndBlockingInitialized,
- };
-
// content::WebUIMessageHandler:
void RegisterMessages() override;
- // ModuleDatabaseObserver:
- void OnNewModuleFound(const ModuleInfoKey& module_key,
- const ModuleInfoData& module_data) override;
- void OnModuleDatabaseIdle() override;
-
// Callback for the "requestModuleList" message.
void HandleRequestModuleList(const base::ListValue* args);
-#if defined(GOOGLE_CHROME_BUILD)
- // Invoked when the ThirdPartyConflictsManager initialization state is
- // available.
- void OnManagerInitializationComplete(ThirdPartyConflictsManager::State state);
-#endif
-
- // Registers this instance to the ModuleDatabase to retrieve the list of
- // modules via the ModuleDatabaseObserver API.
- void GetListOfModules();
-
- // Returns true if one of the third-party features is enabled and active.
- static bool IsThirdPartyFeatureEnabled(ThirdPartyFeaturesStatus status);
-
- // Returns the status string of the third-party features.
- static std::string GetThirdPartyFeaturesStatusString(
- ThirdPartyFeaturesStatus status);
+ void OnConflictsDataFetched(base::DictionaryValue results);
// The ID of the callback that will get invoked with the module list.
std::string module_list_callback_id_;
- // Temporarily holds the module list while the modules are being
- // enumerated.
- std::unique_ptr<base::ListValue> module_list_;
-
- base::Optional<ThirdPartyFeaturesStatus> third_party_features_status_;
+ // Responsible for fetching the list of modules from the ModuleDatabase, which
+ // lives on a different sequence.
+ ConflictsDataFetcher::UniquePtr conflicts_data_fetcher_;
base::WeakPtrFactory<ConflictsHandler> weak_ptr_factory_;
diff --git a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc
index 6beaf18c4ba..d372f98a958 100644
--- a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc
+++ b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc
@@ -25,7 +25,6 @@
#include "extensions/buildflags/buildflags.h"
#include "net/cookies/canonical_cookie.h"
#include "storage/common/fileapi/file_system_types.h"
-#include "third_party/blink/public/mojom/appcache/appcache_info.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/text/bytes_formatting.h"
@@ -51,9 +50,6 @@ const char kKeySendFor[] = "sendfor";
const char kKeyAccessibleToScript[] = "accessibleToScript";
const char kKeySize[] = "size";
const char kKeyOrigin[] = "origin";
-const char kKeyManifest[] = "manifest";
-
-const char kKeyAccessed[] = "accessed";
const char kKeyCreated[] = "created";
const char kKeyExpires[] = "expires";
const char kKeyModified[] = "modified";
@@ -155,16 +151,14 @@ bool CookiesTreeModelUtil::GetCookieTreeNodeDictionary(
case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: {
dict->SetString(kKeyType, "app_cache");
- const blink::mojom::AppCacheInfo& appcache_info =
- *node.GetDetailedInfo().appcache_info;
-
- dict->SetString(kKeyManifest, appcache_info.manifest_url.spec());
- dict->SetString(kKeySize, ui::FormatBytes(appcache_info.size));
- dict->SetString(kKeyCreated, base::UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(appcache_info.creation_time)));
- dict->SetString(kKeyAccessed, base::UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(appcache_info.last_access_time)));
+ const content::StorageUsageInfo& usage_info =
+ *node.GetDetailedInfo().usage_info;
+ dict->SetString(kKeyOrigin, usage_info.origin.Serialize());
+ dict->SetString(kKeySize, ui::FormatBytes(usage_info.total_size_bytes));
+ dict->SetString(kKeyModified,
+ base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(
+ usage_info.last_modified)));
break;
}
case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: {
diff --git a/chromium/chrome/browser/ui/webui/crashes_ui.cc b/chromium/chrome/browser/ui/webui/crashes_ui.cc
index a5e5fd09899..bd4ba6632fc 100644
--- a/chromium/chrome/browser/ui/webui/crashes_ui.cc
+++ b/chromium/chrome/browser/ui/webui/crashes_ui.cc
@@ -106,7 +106,7 @@ CrashesDOMHandler::CrashesDOMHandler()
}
CrashesDOMHandler::~CrashesDOMHandler() {
- upload_list_->CancelCallback();
+ upload_list_->CancelLoadCallback();
}
void CrashesDOMHandler::RegisterMessages() {
diff --git a/chromium/chrome/browser/ui/webui/dark_mode_handler.cc b/chromium/chrome/browser/ui/webui/dark_mode_handler.cc
index cf5e50ad21d..3569eb0c7a9 100644
--- a/chromium/chrome/browser/ui/webui/dark_mode_handler.cc
+++ b/chromium/chrome/browser/ui/webui/dark_mode_handler.cc
@@ -9,8 +9,8 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/values.h"
-#include "chrome/browser/browser_features.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/ui_features.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/native_theme/native_theme.h"
@@ -65,7 +65,6 @@ std::unique_ptr<base::DictionaryValue> DarkModeHandler::GetDataSourceUpdate()
auto update = std::make_unique<base::DictionaryValue>();
bool use_dark_mode = UseDarkMode();
update->SetKey("dark", base::Value(use_dark_mode ? "dark" : ""));
- update->SetKey("darkMode", base::Value(use_dark_mode));
return update;
}
diff --git a/chromium/chrome/browser/ui/webui/dark_mode_handler.h b/chromium/chrome/browser/ui/webui/dark_mode_handler.h
index 6d42a71765d..a47965ac677 100644
--- a/chromium/chrome/browser/ui/webui/dark_mode_handler.h
+++ b/chromium/chrome/browser/ui/webui/dark_mode_handler.h
@@ -61,8 +61,8 @@ class DarkModeHandler : public content::WebUIMessageHandler {
bool UseDarkMode() const;
- // Generates a dictionary with "dark" and "darkMode" i18n keys based on
- // |using_dark_|. Called initialize and on each change for notifications.
+ // Generates a dictionary with "dark" i18n key based on |using_dark_|. Called
+ // in Initialize() and on each change for notifications.
std::unique_ptr<base::DictionaryValue> GetDataSourceUpdate() const;
void OnDarkModeChanged(bool dark_mode);
diff --git a/chromium/chrome/browser/ui/webui/dark_mode_handler_unittest.cc b/chromium/chrome/browser/ui/webui/dark_mode_handler_unittest.cc
index e9dca146dc9..8efcdd048ee 100644
--- a/chromium/chrome/browser/ui/webui/dark_mode_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/dark_mode_handler_unittest.cc
@@ -7,8 +7,8 @@
#include "base/test/scoped_feature_list.h"
#include "base/token.h"
#include "base/values.h"
-#include "chrome/browser/browser_features.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/ui_features.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -48,16 +48,12 @@ class DarkModeHandlerTest : public testing::Test {
const auto* replacements = source()->GetReplacements();
const auto dark_it = replacements->find("dark");
- const auto* local_strings = source()->GetLocalizedStrings();
- const auto* dark_mode =
- local_strings->FindKeyOfType("darkMode", base::Value::Type::BOOLEAN);
-
- if (dark_it == replacements->end() || !dark_mode) {
+ if (dark_it == replacements->end()) {
ADD_FAILURE();
return false;
}
- return dark_it->second == "dark" && dark_mode->GetBool();
+ return dark_it->second == "dark";
}
private:
diff --git a/chromium/chrome/browser/ui/webui/device_log_ui.cc b/chromium/chrome/browser/ui/webui/device_log_ui.cc
index 5cec52a31c3..fcf70251b2a 100644
--- a/chromium/chrome/browser/ui/webui/device_log_ui.cc
+++ b/chromium/chrome/browser/ui/webui/device_log_ui.cc
@@ -78,6 +78,7 @@ DeviceLogUI::DeviceLogUI(content::WebUI* web_ui)
html->AddLocalizedString("logTypeUsbText", IDS_DEVICE_LOG_TYPE_USB);
html->AddLocalizedString("logTypeHidText", IDS_DEVICE_LOG_TYPE_HID);
html->AddLocalizedString("logTypePrinterText", IDS_DEVICE_LOG_TYPE_PRINTER);
+ html->AddLocalizedString("logTypeFidoText", IDS_DEVICE_LOG_TYPE_FIDO);
html->AddLocalizedString("logEntryFormat", IDS_DEVICE_LOG_ENTRY);
html->SetJsonPath("strings.js");
diff --git a/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui.cc b/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui.cc
index 4208aeecdc8..9cbcaea9424 100644
--- a/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/download_internals/download_internals_ui.cc
@@ -36,7 +36,6 @@ DownloadInternalsUI::DownloadInternalsUI(content::WebUI* web_ui)
html_source->UseGzip();
Profile* profile = Profile::FromWebUI(web_ui);
- html_source->AddBoolean("isIncognito", profile->IsOffTheRecord());
content::WebUIDataSource::Add(profile, html_source);
diff --git a/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc b/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
index 9f595a7bbb7..b11826238c4 100644
--- a/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
+++ b/chromium/chrome/browser/ui/webui/downloads/downloads_ui.cc
@@ -15,6 +15,7 @@
#include "base/values.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/safe_browsing/advanced_protection_status_manager.h"
#include "chrome/browser/ui/webui/dark_mode_handler.h"
#include "chrome/browser/ui/webui/downloads/downloads_dom_handler.h"
#include "chrome/browser/ui/webui/managed_ui_handler.h"
@@ -35,6 +36,8 @@
#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/accelerators/accelerator.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
using content::BrowserContext;
@@ -73,12 +76,26 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
// Dangerous file.
source->AddLocalizedString("dangerFileDesc",
IDS_BLOCK_REASON_GENERIC_DOWNLOAD);
- source->AddLocalizedString("dangerDownloadDesc",
- IDS_BLOCK_REASON_DANGEROUS_DOWNLOAD);
- source->AddLocalizedString("dangerUncommonDesc",
- IDS_BLOCK_REASON_UNCOMMON_DOWNLOAD);
- source->AddLocalizedString("dangerSettingsDesc",
- IDS_BLOCK_REASON_UNWANTED_DOWNLOAD);
+
+ bool requests_ap_verdicts = safe_browsing::AdvancedProtectionStatusManager::
+ RequestsAdvancedProtectionVerdicts(profile);
+
+ source->AddLocalizedString(
+ "dangerDownloadDesc",
+ requests_ap_verdicts
+ ? IDS_BLOCK_REASON_DANGEROUS_DOWNLOAD_IN_ADVANCED_PROTECTION
+ : IDS_BLOCK_REASON_DANGEROUS_DOWNLOAD);
+ source->AddLocalizedString(
+ "dangerUncommonDesc",
+ requests_ap_verdicts
+ ? IDS_BLOCK_REASON_UNCOMMON_DOWNLOAD_IN_ADVANCED_PROTECTION
+ : IDS_BLOCK_REASON_UNCOMMON_DOWNLOAD);
+ source->AddLocalizedString(
+ "dangerSettingsDesc",
+ requests_ap_verdicts
+ ? IDS_BLOCK_REASON_UNWANTED_DOWNLOAD_IN_ADVANCED_PROTECTION
+ : IDS_BLOCK_REASON_UNWANTED_DOWNLOAD);
+
source->AddLocalizedString("dangerSave", IDS_CONFIRM_DOWNLOAD);
source->AddLocalizedString("dangerRestore", IDS_CONFIRM_DOWNLOAD_RESTORE);
source->AddLocalizedString("dangerDiscard", IDS_DISCARD_DOWNLOAD);
@@ -94,6 +111,19 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
IDS_DOWNLOAD_LINK_REMOVE_ARIA_LABEL);
source->AddLocalizedString("controlRetry", IDS_DOWNLOAD_LINK_RETRY);
source->AddLocalizedString("controlledByUrl", IDS_DOWNLOAD_BY_EXTENSION_URL);
+ source->AddLocalizedString("toastClearedAll", IDS_DOWNLOAD_TOAST_CLEARED_ALL);
+ source->AddLocalizedString("toastRemovedFromList",
+ IDS_DOWNLOAD_TOAST_REMOVED_FROM_LIST);
+ source->AddLocalizedString("undo", IDS_DOWNLOAD_UNDO);
+
+ // Build an Accelerator to describe undo shortcut
+ // NOTE: the undo shortcut is also defined in downloads/downloads.html
+ // TODO(crbug/893033): de-duplicate shortcut by moving all shortcut
+ // definitions from JS to C++.
+ ui::Accelerator undoAccelerator(ui::VKEY_Z, ui::EF_PLATFORM_ACCELERATOR);
+ source->AddString("undoDescription", l10n_util::GetStringFUTF16(
+ IDS_DOWNLOAD_UNDO_DESCRIPTION,
+ undoAccelerator.GetShortcutText()));
PrefService* prefs = profile->GetPrefs();
source->AddBoolean("allowDeletingHistory",
diff --git a/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_ui.cc b/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_ui.cc
index 7bf61851c53..f8bb27ec3d9 100644
--- a/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_ui.cc
@@ -26,7 +26,8 @@ EocInternalsUI::EocInternalsUI(content::WebUI* web_ui)
source->AddResourcePath("eoc_internals.css", IDR_EOC_INTERNALS_CSS);
source->AddResourcePath("eoc_internals.js", IDR_EOC_INTERNALS_JS);
- source->AddResourcePath("eoc_internals.mojom.js", IDR_EOC_INTERNALS_MOJO_JS);
+ source->AddResourcePath("eoc_internals.mojom-lite.js",
+ IDR_EOC_INTERNALS_MOJOM_LITE_JS);
source->SetDefaultResource(IDR_EOC_INTERNALS_HTML);
source->UseGzip();
diff --git a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
index 427748838b9..22fee225778 100644
--- a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
@@ -111,9 +111,9 @@ KioskAppsHandler::KioskAppsHandler(OwnerSettingsServiceChromeOS* service)
weak_ptr_factory_(this) {}
KioskAppsHandler::~KioskAppsHandler() {
- // TODO(scottchen): This is needed because OnJavascriptDisallowed only called
+ // TODO(tommycli): This is needed because OnJavascriptDisallowed only called
// with refresh or off-page navigation, otherwise DCHECK triggered when
- // exiting. Ask tommycli for more information.
+ // exiting.
kiosk_app_manager_->RemoveObserver(this);
}
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
index 7af2b48f715..7d66742b077 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
@@ -276,7 +276,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionsActivityLogTest, TestActivityLogVisible) {
// The querySelectors and shadowRoots are used here in order to penetrate
// multiple nested shadow DOMs created by Polymer components
// in the chrome://extensions page.
- // See chrome/browser/resources/md_extensions for the Polymer code.
+ // See chrome/browser/resources/extensions for the Polymer code.
// This test only serves as an end to end test, and most of the functionality
// is covered in the JS unit tests.
bool has_api_call = false;
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
index 5708b886b51..9ac40798da8 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -128,101 +128,105 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
{"searchResultsPlural", IDS_SEARCH_RESULTS_PLURAL},
{"searchResultsSingular", IDS_SEARCH_RESULTS_SINGULAR},
- // Multi-use strings defined in md_extensions_strings.grdp.
- {"remove", IDS_MD_EXTENSIONS_REMOVE},
+ // Multi-use strings defined in extensions_strings.grdp.
+ {"remove", IDS_EXTENSIONS_REMOVE},
// Add extension-specific strings.
{"title", IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE},
- {"toolbarTitle", IDS_MD_EXTENSIONS_TOOLBAR_TITLE},
- {"mainMenu", IDS_MD_EXTENSIONS_MENU_BUTTON_LABEL},
- {"search", IDS_MD_EXTENSIONS_SEARCH},
+ {"toolbarTitle", IDS_EXTENSIONS_TOOLBAR_TITLE},
+ {"mainMenu", IDS_EXTENSIONS_MENU_BUTTON_LABEL},
+ {"search", IDS_EXTENSIONS_SEARCH},
// TODO(dpapad): Use a single merged string resource for "Clear search".
{"clearSearch", IDS_DOWNLOAD_CLEAR_SEARCH},
- {"sidebarExtensions", IDS_MD_EXTENSIONS_SIDEBAR_EXTENSIONS},
- {"appsTitle", IDS_MD_EXTENSIONS_APPS_TITLE},
- {"noExtensionsOrApps", IDS_MD_EXTENSIONS_NO_INSTALLED_ITEMS},
- {"noDescription", IDS_MD_EXTENSIONS_NO_DESCRIPTION},
- {"viewInStore", IDS_MD_EXTENSIONS_ITEM_CHROME_WEB_STORE},
- {"extensionWebsite", IDS_MD_EXTENSIONS_ITEM_EXTENSION_WEBSITE},
+ {"sidebarExtensions", IDS_EXTENSIONS_SIDEBAR_EXTENSIONS},
+ {"appsTitle", IDS_EXTENSIONS_APPS_TITLE},
+ {"noExtensionsOrApps", IDS_EXTENSIONS_NO_INSTALLED_ITEMS},
+ {"noDescription", IDS_EXTENSIONS_NO_DESCRIPTION},
+ {"viewInStore", IDS_EXTENSIONS_ITEM_CHROME_WEB_STORE},
+ {"extensionWebsite", IDS_EXTENSIONS_ITEM_EXTENSION_WEBSITE},
{"dropToInstall", IDS_EXTENSIONS_INSTALL_DROP_TARGET},
- {"errorsPageHeading", IDS_MD_EXTENSIONS_ERROR_PAGE_HEADING},
- {"clearActivities", IDS_MD_EXTENSIONS_CLEAR_ACTIVITIES},
- {"clearAll", IDS_MD_EXTENSIONS_ERROR_CLEAR_ALL},
- {"clearEntry", IDS_MD_EXTENSIONS_A11Y_CLEAR_ENTRY},
+ {"errorsPageHeading", IDS_EXTENSIONS_ERROR_PAGE_HEADING},
+ {"clearActivities", IDS_EXTENSIONS_CLEAR_ACTIVITIES},
+ {"clearAll", IDS_EXTENSIONS_ERROR_CLEAR_ALL},
+ {"clearEntry", IDS_EXTENSIONS_A11Y_CLEAR_ENTRY},
{"logLevel", IDS_EXTENSIONS_LOG_LEVEL_INFO},
{"warnLevel", IDS_EXTENSIONS_LOG_LEVEL_WARN},
{"errorLevel", IDS_EXTENSIONS_LOG_LEVEL_ERROR},
- {"anonymousFunction", IDS_MD_EXTENSIONS_ERROR_ANONYMOUS_FUNCTION},
- {"errorContext", IDS_MD_EXTENSIONS_ERROR_CONTEXT},
- {"errorContextUnknown", IDS_MD_EXTENSIONS_ERROR_CONTEXT_UNKNOWN},
- {"stackTrace", IDS_MD_EXTENSIONS_ERROR_STACK_TRACE},
+ {"anonymousFunction", IDS_EXTENSIONS_ERROR_ANONYMOUS_FUNCTION},
+ {"errorContext", IDS_EXTENSIONS_ERROR_CONTEXT},
+ {"errorContextUnknown", IDS_EXTENSIONS_ERROR_CONTEXT_UNKNOWN},
+ {"stackTrace", IDS_EXTENSIONS_ERROR_STACK_TRACE},
// TODO(dpapad): Unify with Settings' IDS_SETTINGS_WEB_STORE.
- {"openChromeWebStore", IDS_MD_EXTENSIONS_SIDEBAR_OPEN_CHROME_WEB_STORE},
- {"keyboardShortcuts", IDS_MD_EXTENSIONS_SIDEBAR_KEYBOARD_SHORTCUTS},
+ {"openChromeWebStore", IDS_EXTENSIONS_SIDEBAR_OPEN_CHROME_WEB_STORE},
+ {"keyboardShortcuts", IDS_EXTENSIONS_SIDEBAR_KEYBOARD_SHORTCUTS},
{"incognitoInfoWarning", IDS_EXTENSIONS_INCOGNITO_WARNING},
- {"hostPermissionsDescription",
- IDS_MD_EXTENSIONS_HOST_PERMISSIONS_DESCRIPTION},
- {"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},
- {"hostAccessOnAllSites", IDS_MD_EXTENSIONS_HOST_ACCESS_ON_ALL_SITES},
+ {"hostPermissionsDescription", IDS_EXTENSIONS_HOST_PERMISSIONS_DESCRIPTION},
+ {"hostPermissionsEdit", IDS_EXTENSIONS_HOST_PERMISSIONS_EDIT},
+ {"hostPermissionsHeading", IDS_EXTENSIONS_ITEM_HOST_PERMISSIONS_HEADING},
+ {"hostAccessOnClick", IDS_EXTENSIONS_HOST_ACCESS_ON_CLICK},
+ {"hostAccessOnSpecificSites", IDS_EXTENSIONS_HOST_ACCESS_ON_SPECIFIC_SITES},
+ {"hostAccessOnAllSites", IDS_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},
+ {"itemId", IDS_EXTENSIONS_ITEM_ID},
+ {"itemInspectViews", IDS_EXTENSIONS_ITEM_INSPECT_VIEWS},
// NOTE: This text reads "<n> more". It's possible that it should be using
// a plural string instead. Unfortunately, this is non-trivial since we
// don't expose that capability to JS yet. Since we don't know it's a
// problem, use a simple placeholder for now.
- {"itemInspectViewsExtra", IDS_MD_EXTENSIONS_ITEM_INSPECT_VIEWS_EXTRA},
- {"noActiveViews", IDS_MD_EXTENSIONS_ITEM_NO_ACTIVE_VIEWS},
- {"itemAllowIncognito", IDS_MD_EXTENSIONS_ITEM_ALLOW_INCOGNITO},
- {"itemDescriptionLabel", IDS_MD_EXTENSIONS_ITEM_DESCRIPTION},
- {"itemDependencies", IDS_MD_EXTENSIONS_ITEM_DEPENDENCIES},
- {"itemDependentEntry", IDS_MD_EXTENSIONS_DEPENDENT_ENTRY},
- {"itemDetails", IDS_MD_EXTENSIONS_ITEM_DETAILS},
- {"itemErrors", IDS_MD_EXTENSIONS_ITEM_ERRORS},
- {"accessibilityErrorLine", IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_LINE},
+ {"itemInspectViewsExtra", IDS_EXTENSIONS_ITEM_INSPECT_VIEWS_EXTRA},
+ {"noActiveViews", IDS_EXTENSIONS_ITEM_NO_ACTIVE_VIEWS},
+ {"itemAllowIncognito", IDS_EXTENSIONS_ITEM_ALLOW_INCOGNITO},
+ {"itemDescriptionLabel", IDS_EXTENSIONS_ITEM_DESCRIPTION},
+ {"itemDependencies", IDS_EXTENSIONS_ITEM_DEPENDENCIES},
+ {"itemDependentEntry", IDS_EXTENSIONS_DEPENDENT_ENTRY},
+ {"itemDetails", IDS_EXTENSIONS_ITEM_DETAILS},
+ {"itemErrors", IDS_EXTENSIONS_ITEM_ERRORS},
+ {"accessibilityErrorLine", IDS_EXTENSIONS_ACCESSIBILITY_ERROR_LINE},
{"accessibilityErrorMultiLine",
- IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_MULTI_LINE},
- {"activityLogPageHeading", IDS_MD_EXTENSIONS_ACTIVITY_LOG_PAGE_HEADING},
- {"activityLogTypeColumn", IDS_MD_EXTENSIONS_ACTIVITY_LOG_TYPE_COLUMN},
- {"activityLogNameColumn", IDS_MD_EXTENSIONS_ACTIVITY_LOG_NAME_COLUMN},
- {"activityLogCountColumn", IDS_MD_EXTENSIONS_ACTIVITY_LOG_COUNT_COLUMN},
- {"activityLogTimeColumn", IDS_MD_EXTENSIONS_ACTIVITY_LOG_TIME_COLUMN},
- {"activityLogSearchLabel", IDS_MD_EXTENSIONS_ACTIVITY_LOG_SEARCH_LABEL},
+ IDS_EXTENSIONS_ACCESSIBILITY_ERROR_MULTI_LINE},
+ {"activityLogPageHeading", IDS_EXTENSIONS_ACTIVITY_LOG_PAGE_HEADING},
+ {"activityLogTypeColumn", IDS_EXTENSIONS_ACTIVITY_LOG_TYPE_COLUMN},
+ {"activityLogNameColumn", IDS_EXTENSIONS_ACTIVITY_LOG_NAME_COLUMN},
+ {"activityLogCountColumn", IDS_EXTENSIONS_ACTIVITY_LOG_COUNT_COLUMN},
+ {"activityLogTimeColumn", IDS_EXTENSIONS_ACTIVITY_LOG_TIME_COLUMN},
+ {"activityLogSearchLabel", IDS_EXTENSIONS_ACTIVITY_LOG_SEARCH_LABEL},
{"activityLogHistoryTabHeading",
- IDS_MD_EXTENSIONS_ACTIVITY_LOG_HISTORY_TAB_HEADING},
+ IDS_EXTENSIONS_ACTIVITY_LOG_HISTORY_TAB_HEADING},
{"activityLogStreamTabHeading",
- IDS_MD_EXTENSIONS_ACTIVITY_LOG_STREAM_TAB_HEADING},
- {"startActivityStream", IDS_MD_EXTENSIONS_START_ACTIVITY_STREAM},
- {"stopActivityStream", IDS_MD_EXTENSIONS_STOP_ACTIVITY_STREAM},
- {"emptyStreamStarted", IDS_MD_EXTENSIONS_EMPTY_STREAM_STARTED},
- {"emptyStreamStopped", IDS_MD_EXTENSIONS_EMPTY_STREAM_STOPPED},
- {"appIcon", IDS_MD_EXTENSIONS_APP_ICON},
- {"extensionIcon", IDS_MD_EXTENSIONS_EXTENSION_ICON},
- {"extensionA11yAssociation", IDS_MD_EXTENSIONS_EXTENSION_A11Y_ASSOCIATION},
- {"itemIdHeading", IDS_MD_EXTENSIONS_ITEM_ID_HEADING},
- {"extensionEnabled", IDS_MD_EXTENSIONS_EXTENSION_ENABLED},
- {"appEnabled", IDS_MD_EXTENSIONS_APP_ENABLED},
+ IDS_EXTENSIONS_ACTIVITY_LOG_STREAM_TAB_HEADING},
+ {"startActivityStream", IDS_EXTENSIONS_START_ACTIVITY_STREAM},
+ {"stopActivityStream", IDS_EXTENSIONS_STOP_ACTIVITY_STREAM},
+ {"emptyStreamStarted", IDS_EXTENSIONS_EMPTY_STREAM_STARTED},
+ {"emptyStreamStopped", IDS_EXTENSIONS_EMPTY_STREAM_STOPPED},
+ {"activityArgumentsHeading", IDS_EXTENSIONS_ACTIVITY_ARGUMENTS_HEADING},
+ {"webRequestInfoHeading", IDS_EXTENSIONS_WEB_REQUEST_INFO_HEADING},
+ {"activityLogMoreActionsLabel",
+ IDS_EXTENSIONS_ACTIVITY_LOG_MORE_ACTIONS_LABEL},
+ {"activityLogExpandAll", IDS_EXTENSIONS_ACTIVITY_LOG_EXPAND_ALL},
+ {"activityLogCollapseAll", IDS_EXTENSIONS_ACTIVITY_LOG_COLLAPSE_ALL},
+ {"appIcon", IDS_EXTENSIONS_APP_ICON},
+ {"extensionIcon", IDS_EXTENSIONS_EXTENSION_ICON},
+ {"extensionA11yAssociation", IDS_EXTENSIONS_EXTENSION_A11Y_ASSOCIATION},
+ {"itemIdHeading", IDS_EXTENSIONS_ITEM_ID_HEADING},
+ {"extensionEnabled", IDS_EXTENSIONS_EXTENSION_ENABLED},
+ {"appEnabled", IDS_EXTENSIONS_APP_ENABLED},
{"installWarnings", IDS_EXTENSIONS_INSTALL_WARNINGS},
{"itemExtensionPath", IDS_EXTENSIONS_PATH},
- {"itemOff", IDS_MD_EXTENSIONS_ITEM_OFF},
- {"itemOn", IDS_MD_EXTENSIONS_ITEM_ON},
- {"itemOptions", IDS_MD_EXTENSIONS_ITEM_OPTIONS},
- {"itemPermissions", IDS_MD_EXTENSIONS_ITEM_PERMISSIONS},
- {"itemPermissionsEmpty", IDS_MD_EXTENSIONS_ITEM_PERMISSIONS_EMPTY},
- {"itemRemoveExtension", IDS_MD_EXTENSIONS_ITEM_REMOVE_EXTENSION},
- {"itemSiteAccess", IDS_MD_EXTENSIONS_ITEM_SITE_ACCESS},
- {"itemSiteAccessAddHost", IDS_MD_EXTENSIONS_ITEM_SITE_ACCESS_ADD_HOST},
- {"itemSiteAccessEmpty", IDS_MD_EXTENSIONS_ITEM_SITE_ACCESS_EMPTY},
- {"itemSource", IDS_MD_EXTENSIONS_ITEM_SOURCE},
- {"itemSourcePolicy", IDS_MD_EXTENSIONS_ITEM_SOURCE_POLICY},
- {"itemSourceSideloaded", IDS_MD_EXTENSIONS_ITEM_SOURCE_SIDELOADED},
- {"itemSourceUnpacked", IDS_MD_EXTENSIONS_ITEM_SOURCE_UNPACKED},
- {"itemSourceWebstore", IDS_MD_EXTENSIONS_ITEM_SOURCE_WEBSTORE},
- {"itemVersion", IDS_MD_EXTENSIONS_ITEM_VERSION},
+ {"itemOff", IDS_EXTENSIONS_ITEM_OFF},
+ {"itemOn", IDS_EXTENSIONS_ITEM_ON},
+ {"itemOptions", IDS_EXTENSIONS_ITEM_OPTIONS},
+ {"itemPermissions", IDS_EXTENSIONS_ITEM_PERMISSIONS},
+ {"itemPermissionsEmpty", IDS_EXTENSIONS_ITEM_PERMISSIONS_EMPTY},
+ {"itemRemoveExtension", IDS_EXTENSIONS_ITEM_REMOVE_EXTENSION},
+ {"itemSiteAccess", IDS_EXTENSIONS_ITEM_SITE_ACCESS},
+ {"itemSiteAccessAddHost", IDS_EXTENSIONS_ITEM_SITE_ACCESS_ADD_HOST},
+ {"itemSiteAccessEmpty", IDS_EXTENSIONS_ITEM_SITE_ACCESS_EMPTY},
+ {"itemSource", IDS_EXTENSIONS_ITEM_SOURCE},
+ {"itemSourcePolicy", IDS_EXTENSIONS_ITEM_SOURCE_POLICY},
+ {"itemSourceSideloaded", IDS_EXTENSIONS_ITEM_SOURCE_SIDELOADED},
+ {"itemSourceUnpacked", IDS_EXTENSIONS_ITEM_SOURCE_UNPACKED},
+ {"itemSourceWebstore", IDS_EXTENSIONS_ITEM_SOURCE_WEBSTORE},
+ {"itemVersion", IDS_EXTENSIONS_ITEM_VERSION},
// TODO(dpapad): Replace this with an Extensions specific string.
{"itemSize", IDS_DIRECTORY_LISTING_SIZE},
{"itemAllowOnFileUrls", IDS_EXTENSIONS_ALLOW_FILE_ACCESS},
@@ -233,46 +237,46 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
{"itemRepair", IDS_EXTENSIONS_REPAIR_CORRUPTED},
{"itemReload", IDS_EXTENSIONS_RELOAD_TERMINATED},
{"loadErrorCouldNotLoadManifest",
- IDS_MD_EXTENSIONS_LOAD_ERROR_COULD_NOT_LOAD_MANIFEST},
- {"loadErrorHeading", IDS_MD_EXTENSIONS_LOAD_ERROR_HEADING},
- {"loadErrorFileLabel", IDS_MD_EXTENSIONS_LOAD_ERROR_FILE_LABEL},
- {"loadErrorErrorLabel", IDS_MD_EXTENSIONS_LOAD_ERROR_ERROR_LABEL},
- {"loadErrorRetry", IDS_MD_EXTENSIONS_LOAD_ERROR_RETRY},
- {"loadingActivities", IDS_MD_EXTENSIONS_LOADING_ACTIVITIES},
- {"noActivities", IDS_MD_EXTENSIONS_NO_ACTIVITIES},
+ IDS_EXTENSIONS_LOAD_ERROR_COULD_NOT_LOAD_MANIFEST},
+ {"loadErrorHeading", IDS_EXTENSIONS_LOAD_ERROR_HEADING},
+ {"loadErrorFileLabel", IDS_EXTENSIONS_LOAD_ERROR_FILE_LABEL},
+ {"loadErrorErrorLabel", IDS_EXTENSIONS_LOAD_ERROR_ERROR_LABEL},
+ {"loadErrorRetry", IDS_EXTENSIONS_LOAD_ERROR_RETRY},
+ {"loadingActivities", IDS_EXTENSIONS_LOADING_ACTIVITIES},
+ {"noActivities", IDS_EXTENSIONS_NO_ACTIVITIES},
{"noErrorsToShow", IDS_EXTENSIONS_ERROR_NO_ERRORS_CODE_MESSAGE},
{"runtimeHostsDialogInputError",
- IDS_MD_EXTENSIONS_RUNTIME_HOSTS_DIALOG_INPUT_ERROR},
+ IDS_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},
- {"packDialogProceedAnyway", IDS_MD_EXTENSIONS_PACK_DIALOG_PROCEED_ANYWAY},
- {"packDialogBrowse", IDS_MD_EXTENSIONS_PACK_DIALOG_BROWSE_BUTTON},
+ IDS_EXTENSIONS_RUNTIME_HOSTS_DIALOG_INPUT_LABEL},
+ {"runtimeHostsDialogTitle", IDS_EXTENSIONS_RUNTIME_HOSTS_DIALOG_TITLE},
+ {"packDialogTitle", IDS_EXTENSIONS_PACK_DIALOG_TITLE},
+ {"packDialogWarningTitle", IDS_EXTENSIONS_PACK_DIALOG_WARNING_TITLE},
+ {"packDialogErrorTitle", IDS_EXTENSIONS_PACK_DIALOG_ERROR_TITLE},
+ {"packDialogProceedAnyway", IDS_EXTENSIONS_PACK_DIALOG_PROCEED_ANYWAY},
+ {"packDialogBrowse", IDS_EXTENSIONS_PACK_DIALOG_BROWSE_BUTTON},
{"packDialogExtensionRoot",
- IDS_MD_EXTENSIONS_PACK_DIALOG_EXTENSION_ROOT_LABEL},
- {"packDialogKeyFile", IDS_MD_EXTENSIONS_PACK_DIALOG_KEY_FILE_LABEL},
+ IDS_EXTENSIONS_PACK_DIALOG_EXTENSION_ROOT_LABEL},
+ {"packDialogKeyFile", IDS_EXTENSIONS_PACK_DIALOG_KEY_FILE_LABEL},
{"packDialogContent", IDS_EXTENSION_PACK_DIALOG_HEADING},
- {"packDialogConfirm", IDS_MD_EXTENSIONS_PACK_DIALOG_CONFIRM_BUTTON},
- {"shortcutNotSet", IDS_MD_EXTENSIONS_SHORTCUT_NOT_SET},
- {"shortcutScopeGlobal", IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_GLOBAL},
- {"shortcutScopeLabel", IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_LABEL},
- {"shortcutScopeInChrome", IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_IN_CHROME},
- {"shortcutTypeAShortcut", IDS_MD_EXTENSIONS_TYPE_A_SHORTCUT},
- {"shortcutIncludeStartModifier", IDS_MD_EXTENSIONS_INCLUDE_START_MODIFIER},
- {"shortcutTooManyModifiers", IDS_MD_EXTENSIONS_TOO_MANY_MODIFIERS},
- {"shortcutNeedCharacter", IDS_MD_EXTENSIONS_NEED_CHARACTER},
- {"toolbarDevMode", IDS_MD_EXTENSIONS_DEVELOPER_MODE},
- {"toolbarLoadUnpacked", IDS_MD_EXTENSIONS_TOOLBAR_LOAD_UNPACKED},
- {"toolbarPack", IDS_MD_EXTENSIONS_TOOLBAR_PACK},
- {"toolbarUpdateNow", IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_NOW},
- {"toolbarUpdateNowTooltip", IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_NOW_TOOLTIP},
- {"toolbarUpdateDone", IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_DONE},
- {"toolbarUpdatingToast", IDS_MD_EXTENSIONS_TOOLBAR_UPDATING_TOAST},
+ {"packDialogConfirm", IDS_EXTENSIONS_PACK_DIALOG_CONFIRM_BUTTON},
+ {"shortcutNotSet", IDS_EXTENSIONS_SHORTCUT_NOT_SET},
+ {"shortcutScopeGlobal", IDS_EXTENSIONS_SHORTCUT_SCOPE_GLOBAL},
+ {"shortcutScopeLabel", IDS_EXTENSIONS_SHORTCUT_SCOPE_LABEL},
+ {"shortcutScopeInChrome", IDS_EXTENSIONS_SHORTCUT_SCOPE_IN_CHROME},
+ {"shortcutTypeAShortcut", IDS_EXTENSIONS_TYPE_A_SHORTCUT},
+ {"shortcutIncludeStartModifier", IDS_EXTENSIONS_INCLUDE_START_MODIFIER},
+ {"shortcutTooManyModifiers", IDS_EXTENSIONS_TOO_MANY_MODIFIERS},
+ {"shortcutNeedCharacter", IDS_EXTENSIONS_NEED_CHARACTER},
+ {"toolbarDevMode", IDS_EXTENSIONS_DEVELOPER_MODE},
+ {"toolbarLoadUnpacked", IDS_EXTENSIONS_TOOLBAR_LOAD_UNPACKED},
+ {"toolbarPack", IDS_EXTENSIONS_TOOLBAR_PACK},
+ {"toolbarUpdateNow", IDS_EXTENSIONS_TOOLBAR_UPDATE_NOW},
+ {"toolbarUpdateNowTooltip", IDS_EXTENSIONS_TOOLBAR_UPDATE_NOW_TOOLTIP},
+ {"toolbarUpdateDone", IDS_EXTENSIONS_TOOLBAR_UPDATE_DONE},
+ {"toolbarUpdatingToast", IDS_EXTENSIONS_TOOLBAR_UPDATING_TOAST},
{"updateRequiredByPolicy",
- IDS_MD_EXTENSIONS_DISABLED_UPDATE_REQUIRED_BY_POLICY},
+ IDS_EXTENSIONS_DISABLED_UPDATE_REQUIRED_BY_POLICY},
{"viewActivityLog", IDS_EXTENSIONS_VIEW_ACTIVITY_LOG},
{"viewBackgroundPage", IDS_EXTENSIONS_BACKGROUND_PAGE},
{"viewIncognito", IDS_EXTENSIONS_VIEW_INCOGNITO},
@@ -280,17 +284,17 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
{"viewIframe", IDS_EXTENSIONS_VIEW_IFRAME},
#if defined(OS_CHROMEOS)
- {"manageKioskApp", IDS_MD_EXTENSIONS_MANAGE_KIOSK_APP},
- {"kioskAddApp", IDS_MD_EXTENSIONS_KIOSK_ADD_APP},
- {"kioskAddAppHint", IDS_MD_EXTENSIONS_KIOSK_ADD_APP_HINT},
- {"kioskEnableAutoLaunch", IDS_MD_EXTENSIONS_KIOSK_ENABLE_AUTO_LAUNCH},
- {"kioskDisableAutoLaunch", IDS_MD_EXTENSIONS_KIOSK_DISABLE_AUTO_LAUNCH},
- {"kioskAutoLaunch", IDS_MD_EXTENSIONS_KIOSK_AUTO_LAUNCH},
- {"kioskInvalidApp", IDS_MD_EXTENSIONS_KIOSK_INVALID_APP},
+ {"manageKioskApp", IDS_EXTENSIONS_MANAGE_KIOSK_APP},
+ {"kioskAddApp", IDS_EXTENSIONS_KIOSK_ADD_APP},
+ {"kioskAddAppHint", IDS_EXTENSIONS_KIOSK_ADD_APP_HINT},
+ {"kioskEnableAutoLaunch", IDS_EXTENSIONS_KIOSK_ENABLE_AUTO_LAUNCH},
+ {"kioskDisableAutoLaunch", IDS_EXTENSIONS_KIOSK_DISABLE_AUTO_LAUNCH},
+ {"kioskAutoLaunch", IDS_EXTENSIONS_KIOSK_AUTO_LAUNCH},
+ {"kioskInvalidApp", IDS_EXTENSIONS_KIOSK_INVALID_APP},
{"kioskDisableBailout",
- IDS_MD_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_LABEL},
+ IDS_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_LABEL},
{"kioskDisableBailoutWarningTitle",
- IDS_MD_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_TITLE},
+ IDS_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_TITLE},
#endif
};
AddLocalizedStringsBulk(source, kLocalizedStrings,
@@ -298,10 +302,10 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
source->AddString("errorLinesNotShownSingular",
l10n_util::GetPluralStringFUTF16(
- IDS_MD_EXTENSIONS_ERROR_LINES_NOT_SHOWN, 1));
+ IDS_EXTENSIONS_ERROR_LINES_NOT_SHOWN, 1));
source->AddString("errorLinesNotShownPlural",
l10n_util::GetPluralStringFUTF16(
- IDS_MD_EXTENSIONS_ERROR_LINES_NOT_SHOWN, 2));
+ IDS_EXTENSIONS_ERROR_LINES_NOT_SHOWN, 2));
source->AddString(
"itemSuspiciousInstall",
l10n_util::GetStringFUTF16(
@@ -317,7 +321,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
source->AddString(
"kioskDisableBailoutWarningBody",
l10n_util::GetStringFUTF16(
- IDS_MD_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_BODY,
+ IDS_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_BODY,
l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME)));
#endif
source->AddString(
@@ -336,11 +340,11 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
source->AddString(kLoadTimeClassesKey, GetLoadTimeClasses(in_dev_mode));
#if BUILDFLAG(OPTIMIZE_WEBUI)
- source->AddResourcePath("crisper.js", IDR_MD_EXTENSIONS_CRISPER_JS);
+ source->AddResourcePath("crisper.js", IDR_EXTENSIONS_CRISPER_JS);
source->SetDefaultResource(
- base::FeatureList::IsEnabled(features::kWebUIPolymer2) ?
- IDR_MD_EXTENSIONS_VULCANIZED_P2_HTML :
- IDR_MD_EXTENSIONS_VULCANIZED_HTML);
+ base::FeatureList::IsEnabled(features::kWebUIPolymer2)
+ ? IDR_EXTENSIONS_VULCANIZED_P2_HTML
+ : IDR_EXTENSIONS_VULCANIZED_HTML);
source->UseGzip();
#else
// Add all MD Extensions resources.
@@ -348,7 +352,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(Profile* profile,
source->AddResourcePath(kExtensionsResources[i].name,
kExtensionsResources[i].value);
}
- source->SetDefaultResource(IDR_MD_EXTENSIONS_EXTENSIONS_HTML);
+ source->SetDefaultResource(IDR_EXTENSIONS_EXTENSIONS_HTML);
#endif
return source;
diff --git a/chromium/chrome/browser/ui/webui/favicon_source.cc b/chromium/chrome/browser/ui/webui/favicon_source.cc
index 7a04b208ed9..77ab61af121 100644
--- a/chromium/chrome/browser/ui/webui/favicon_source.cc
+++ b/chromium/chrome/browser/ui/webui/favicon_source.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/history/top_sites_factory.h"
@@ -19,27 +20,42 @@
#include "components/history/core/browser/top_sites.h"
#include "components/sync_sessions/open_tabs_ui_delegate.h"
#include "components/sync_sessions/session_sync_service.h"
+#include "content/public/browser/web_contents.h"
#include "net/url_request/url_request.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/native_theme/native_theme.h"
#include "ui/resources/grit/ui_resources.h"
+#include "url/gurl.h"
-FaviconSource::IconRequest::IconRequest()
- : size_in_dip(gfx::kFaviconSize), device_scale_factor(1.0f) {
+namespace {
+favicon::FaviconRequestOrigin ParseFaviconRequestOrigin(const GURL& url) {
+ GURL history_url(chrome::kChromeUIHistoryURL);
+ if (url == history_url.Resolve("/syncedTabs"))
+ return favicon::FaviconRequestOrigin::HISTORY_SYNCED_TABS;
+ if (url == history_url)
+ return favicon::FaviconRequestOrigin::HISTORY;
+ return favicon::FaviconRequestOrigin::UNKNOWN;
}
+} // namespace
+
+FaviconSource::IconRequest::IconRequest()
+ : size_in_dip(gfx::kFaviconSize),
+ device_scale_factor(1.0f),
+ icon_request_origin(favicon::FaviconRequestOrigin::UNKNOWN) {}
FaviconSource::IconRequest::IconRequest(
const content::URLDataSource::GotDataCallback& cb,
const GURL& path,
int size,
- float scale)
+ float scale,
+ favicon::FaviconRequestOrigin origin)
: callback(cb),
request_path(path),
size_in_dip(size),
- device_scale_factor(scale) {
-}
+ device_scale_factor(scale),
+ icon_request_origin(origin) {}
FaviconSource::IconRequest::IconRequest(const IconRequest& other) = default;
@@ -84,15 +100,22 @@ void FaviconSource::StartDataRequest(
int desired_size_in_pixel =
std::ceil(parsed.size_in_dip * parsed.device_scale_factor);
+ content::WebContents* web_contents = wc_getter.Run();
+ // web_contents->GetURL will not necessarily yield the original URL that
+ // started the request, but for collecting metrics for chrome://history and
+ // chrome://history/syncedTabs this will be ok.
+ favicon::FaviconRequestOrigin unsafe_request_origin =
+ web_contents ? ParseFaviconRequestOrigin(web_contents->GetURL())
+ : favicon::FaviconRequestOrigin::UNKNOWN;
if (parsed.is_icon_url) {
// TODO(michaelbai): Change GetRawFavicon to support combination of
// IconType.
favicon_service->GetRawFavicon(
url, favicon_base::IconType::kFavicon, desired_size_in_pixel,
- base::Bind(&FaviconSource::OnFaviconDataAvailable,
- base::Unretained(this),
- IconRequest(callback, url, parsed.size_in_dip,
- parsed.device_scale_factor)),
+ base::Bind(
+ &FaviconSource::OnFaviconDataAvailable, base::Unretained(this),
+ IconRequest(callback, url, parsed.size_in_dip,
+ parsed.device_scale_factor, unsafe_request_origin)),
&cancelable_task_tracker_);
} else {
// Intercept requests for prepopulated pages if TopSites exists.
@@ -123,10 +146,10 @@ void FaviconSource::StartDataRequest(
favicon_service->GetRawFaviconForPageURL(
url, {favicon_base::IconType::kFavicon}, desired_size_in_pixel,
fallback_to_host,
- base::Bind(&FaviconSource::OnFaviconDataAvailable,
- base::Unretained(this),
- IconRequest(callback, url, parsed.size_in_dip,
- parsed.device_scale_factor)),
+ base::Bind(
+ &FaviconSource::OnFaviconDataAvailable, base::Unretained(this),
+ IconRequest(callback, url, parsed.size_in_dip,
+ parsed.device_scale_factor, unsafe_request_origin)),
&cancelable_task_tracker_);
}
}
@@ -184,16 +207,26 @@ void FaviconSource::OnFaviconDataAvailable(
const IconRequest& request,
const favicon_base::FaviconRawBitmapResult& bitmap_result) {
if (bitmap_result.is_valid()) {
+ favicon::RecordFaviconRequestMetric(request.icon_request_origin,
+ favicon::FaviconAvailability::kLocal);
// Forward the data along to the networking system.
request.callback.Run(bitmap_result.bitmap_data.get());
- } else if (!HandleMissingResource(request)) {
+ } else if (HandleMissingResource(request)) {
+ favicon::RecordFaviconRequestMetric(request.icon_request_origin,
+ favicon::FaviconAvailability::kSync);
+ // The response was already treated by HandleMissingResource.
+ } else {
+ favicon::RecordFaviconRequestMetric(
+ request.icon_request_origin,
+ favicon::FaviconAvailability::kNotAvailable);
SendDefaultResponse(request);
}
}
void FaviconSource::SendDefaultResponse(
const content::URLDataSource::GotDataCallback& callback) {
- SendDefaultResponse(IconRequest(callback, GURL(), 16, 1.0f));
+ SendDefaultResponse(IconRequest(callback, GURL(), 16, 1.0f,
+ favicon::FaviconRequestOrigin::UNKNOWN));
}
void FaviconSource::SendDefaultResponse(const IconRequest& icon_request) {
diff --git a/chromium/chrome/browser/ui/webui/favicon_source.h b/chromium/chrome/browser/ui/webui/favicon_source.h
index 53e867313dd..4b72ee5a0cb 100644
--- a/chromium/chrome/browser/ui/webui/favicon_source.h
+++ b/chromium/chrome/browser/ui/webui/favicon_source.h
@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h"
#include "base/task/cancelable_task_tracker.h"
#include "components/favicon/core/favicon_service.h"
+#include "components/favicon_base/favicon_request_metrics.h"
#include "content/public/browser/url_data_source.h"
#include "ui/gfx/favicon_size.h"
@@ -78,7 +79,8 @@ class FaviconSource : public content::URLDataSource {
IconRequest(const content::URLDataSource::GotDataCallback& cb,
const GURL& path,
int size,
- float scale);
+ float scale,
+ favicon::FaviconRequestOrigin origin);
IconRequest(const IconRequest& other);
~IconRequest();
@@ -86,6 +88,7 @@ class FaviconSource : public content::URLDataSource {
GURL request_path;
int size_in_dip;
float device_scale_factor;
+ favicon::FaviconRequestOrigin icon_request_origin;
};
// Called when the favicon data is missing to perform additional checks to
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/BUILD.gn b/chromium/chrome/browser/ui/webui/feed_internals/BUILD.gn
index a5a97629de3..846c29a4ccc 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/BUILD.gn
+++ b/chromium/chrome/browser/ui/webui/feed_internals/BUILD.gn
@@ -8,4 +8,8 @@ mojom("mojo_bindings") {
sources = [
"feed_internals.mojom",
]
+
+ public_deps = [
+ "//url/mojom:url_mojom_gurl",
+ ]
}
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom
index aa466691a47..bf6f965d32a 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals.mojom
@@ -4,10 +4,24 @@
module feed_internals.mojom;
+import "url/mojom/url.mojom";
+
// General properties of Feed suggestions.
struct Properties {
- // Whether the Feed is enabled.
+ // Whether the Feed feature flag is enabled.
bool is_feed_enabled;
+
+ // Whether suggested articles section is expanded.
+ bool is_feed_visible;
+
+ // Whether suggested articles are allowed. Typically set by policy.
+ bool is_feed_allowed;
+
+ // Whether prefetching for offline availability is enabled.
+ bool is_prefetching_enabled;
+
+ // Feed fetch URL.
+ url.mojom.Url feed_fetch_url;
};
struct UserClassifier {
@@ -27,6 +41,9 @@ struct LastFetchProperties {
// Last fetch status.
int32 last_fetch_status;
+ // Reason for the last fetch.
+ string last_fetch_trigger;
+
// Last fetch time.
Time? last_fetch_time;
@@ -41,16 +58,16 @@ struct Suggestion {
string title;
// URL of the suggested page.
- string url;
+ url.mojom.Url url;
// Name of the content's publisher.
string publisher_name;
// URL of the image associated with the suggestion.
- string image_url;
+ url.mojom.Url image_url;
// URL of the suggested page's favicon.
- string favicon_url;
+ url.mojom.Url favicon_url;
};
// Time wrapper to allow for nullable objects.
@@ -77,6 +94,15 @@ interface PageHandler {
// Feed.
ClearCachedDataAndRefreshFeed();
+ // Trigger a refresh of the Feed.
+ RefreshFeed();
+
// Get the last known content with metadata.
GetCurrentContent() => (array<Suggestion> suggestions);
+
+ // Internal state dump of the Feed library's process scope.
+ GetFeedProcessScopeDump() => (string dump);
+
+ // Record all Feed metrics into a log.
+ GetFeedHistograms() => (string log);
};
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc
index d1601c39a7d..51c01b6e21d 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.cc
@@ -4,10 +4,13 @@
#include "chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h"
+#include <string>
#include <utility>
#include "base/feature_list.h"
+#include "base/metrics/statistics_recorder.h"
#include "base/time/time.h"
+#include "chrome/browser/android/feed/feed_debugging_bridge.h"
#include "chrome/browser/android/feed/feed_lifecycle_bridge.h"
#include "components/feed/content/feed_host_service.h"
#include "components/feed/content/feed_offline_host.h"
@@ -15,16 +18,30 @@
#include "components/feed/core/pref_names.h"
#include "components/feed/core/user_classifier.h"
#include "components/feed/feed_feature_list.h"
+#include "components/offline_pages/core/prefetch/prefetch_prefs.h"
#include "components/offline_pages/core/prefetch/suggestions_provider.h"
#include "components/prefs/pref_service.h"
namespace {
+const char kFeedHistogramPrefix[] = "ContentSuggestions.Feed.";
+
feed_internals::mojom::TimePtr ToMojoTime(base::Time time) {
return time.is_null() ? nullptr
: feed_internals::mojom::Time::New(time.ToJsTime());
}
+std::string TriggerTypeToString(feed::FeedSchedulerHost::TriggerType trigger) {
+ switch (trigger) {
+ case feed::FeedSchedulerHost::TriggerType::kNtpShown:
+ return "NTP Shown";
+ case feed::FeedSchedulerHost::TriggerType::kForegrounded:
+ return "Foregrounded";
+ case feed::FeedSchedulerHost::TriggerType::kFixedTimer:
+ return "Fixed Timer";
+ }
+}
+
} // namespace
FeedInternalsPageHandler::FeedInternalsPageHandler(
@@ -45,6 +62,12 @@ void FeedInternalsPageHandler::GetGeneralProperties(
properties->is_feed_enabled =
base::FeatureList::IsEnabled(feed::kInterestFeedContentSuggestions);
+ properties->is_feed_visible =
+ pref_service_->GetBoolean(feed::prefs::kArticlesListVisible);
+ properties->is_feed_allowed = IsFeedAllowed();
+ properties->is_prefetching_enabled =
+ offline_pages::prefetch_prefs::IsEnabled(pref_service_);
+ properties->feed_fetch_url = feed::GetFeedFetchUrlForDebugging();
std::move(callback).Run(std::move(properties));
}
@@ -72,6 +95,8 @@ void FeedInternalsPageHandler::GetLastFetchProperties(
properties->last_fetch_status =
feed_scheduler_host_->GetLastFetchStatusForDebugging();
+ properties->last_fetch_trigger = TriggerTypeToString(
+ feed_scheduler_host_->GetLastFetchTriggerTypeForDebugging());
properties->last_fetch_time =
ToMojoTime(pref_service_->GetTime(feed::prefs::kLastFetchAttemptTime));
properties->refresh_suppress_time =
@@ -89,8 +114,18 @@ void FeedInternalsPageHandler::ClearCachedDataAndRefreshFeed() {
feed::FeedLifecycleBridge::ClearCachedData();
}
+void FeedInternalsPageHandler::RefreshFeed() {
+ feed::TriggerRefreshForDebugging();
+}
+
void FeedInternalsPageHandler::GetCurrentContent(
GetCurrentContentCallback callback) {
+ if (!IsFeedAllowed()) {
+ std::move(callback).Run(
+ std::vector<feed_internals::mojom::SuggestionPtr>());
+ return;
+ }
+
feed_offline_host_->GetCurrentArticleSuggestions(base::BindOnce(
&FeedInternalsPageHandler::OnGetCurrentArticleSuggestionsDone,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
@@ -104,13 +139,29 @@ void FeedInternalsPageHandler::OnGetCurrentArticleSuggestionsDone(
for (offline_pages::PrefetchSuggestion result : results) {
auto suggestion = feed_internals::mojom::Suggestion::New();
suggestion->title = std::move(result.article_title);
- suggestion->url = result.article_url.spec();
+ suggestion->url = std::move(result.article_url);
suggestion->publisher_name = std::move(result.article_attribution);
- suggestion->image_url = result.thumbnail_url.spec();
- suggestion->favicon_url = result.favicon_url.spec();
+ suggestion->image_url = std::move(result.thumbnail_url);
+ suggestion->favicon_url = std::move(result.favicon_url);
suggestions.push_back(std::move(suggestion));
}
std::move(callback).Run(std::move(suggestions));
}
+
+void FeedInternalsPageHandler::GetFeedProcessScopeDump(
+ GetFeedProcessScopeDumpCallback callback) {
+ std::move(callback).Run(feed::GetFeedProcessScopeDumpForDebugging());
+}
+
+bool FeedInternalsPageHandler::IsFeedAllowed() {
+ return pref_service_->GetBoolean(feed::prefs::kEnableSnippets);
+}
+
+void FeedInternalsPageHandler::GetFeedHistograms(
+ GetFeedHistogramsCallback callback) {
+ std::string log;
+ base::StatisticsRecorder::WriteGraph(kFeedHistogramPrefix, &log);
+ std::move(callback).Run(log);
+}
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h
index 277fb4c4257..67f1327fe9a 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_page_handler.h
@@ -39,7 +39,10 @@ class FeedInternalsPageHandler : public feed_internals::mojom::PageHandler {
void ClearUserClassifierProperties() override;
void GetLastFetchProperties(GetLastFetchPropertiesCallback) override;
void ClearCachedDataAndRefreshFeed() override;
+ void RefreshFeed() override;
void GetCurrentContent(GetCurrentContentCallback) override;
+ void GetFeedProcessScopeDump(GetFeedProcessScopeDumpCallback) override;
+ void GetFeedHistograms(GetFeedHistogramsCallback) override;
private:
// Binding from the mojo interface to concrete implementation.
@@ -49,6 +52,8 @@ class FeedInternalsPageHandler : public feed_internals::mojom::PageHandler {
GetCurrentContentCallback callback,
std::vector<offline_pages::PrefetchSuggestion> suggestions);
+ bool IsFeedAllowed();
+
// Services that provide the data and functionality.
feed::FeedSchedulerHost* feed_scheduler_host_;
feed::FeedOfflineHost* feed_offline_host_;
diff --git a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc
index 32658cd8756..ab18f72b41c 100644
--- a/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/feed_internals/feed_internals_ui.cc
@@ -22,6 +22,7 @@ FeedInternalsUI::FeedInternalsUI(content::WebUI* web_ui)
source->AddResourcePath("feed_internals.js", IDR_FEED_INTERNALS_JS);
source->AddResourcePath("feed_internals.mojom-lite.js",
IDR_FEED_INTERNALS_MOJO_JS);
+ source->AddResourcePath("url/mojom/url.mojom-lite.js", IDR_URL_MOJOM_LITE_JS);
source->AddResourcePath("feed_internals.css", IDR_FEED_INTERNALS_CSS);
source->SetDefaultResource(IDR_FEED_INTERNALS_HTML);
source->UseGzip();
diff --git a/chromium/chrome/browser/ui/webui/flags_ui.cc b/chromium/chrome/browser/ui/webui/flags_ui.cc
index 37410de78d5..9a8710a35ce 100644
--- a/chromium/chrome/browser/ui/webui/flags_ui.cc
+++ b/chromium/chrome/browser/ui/webui/flags_ui.cc
@@ -51,6 +51,10 @@
#include "components/user_manager/user_manager.h"
#endif
+#if !defined(OS_ANDROID)
+#include "chrome/browser/ui/webui/dark_mode_handler.h"
+#endif
+
using content::WebContents;
using content::WebUIMessageHandler;
@@ -348,7 +352,13 @@ FlagsUI::FlagsUI(content::WebUI* web_ui)
#endif
// Set up the about:flags source.
- content::WebUIDataSource::Add(profile, CreateFlagsUIHTMLSource());
+ auto* source = CreateFlagsUIHTMLSource();
+#if !defined(OS_ANDROID)
+ // Android hasn't implemented NativeTheme::SystemDarkModeEnabled() yet, which
+ // DarkModeHandler relies on to determine "darkness".
+ DarkModeHandler::Initialize(web_ui, source);
+#endif
+ content::WebUIDataSource::Add(profile, source);
}
FlagsUI::~FlagsUI() {
diff --git a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc
index 943d9bd0818..fb31dea54af 100644
--- a/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/help/version_updater_chromeos.cc
@@ -19,7 +19,7 @@
#include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
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 4127290b805..a19b61e6e61 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
@@ -15,7 +15,7 @@
#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"
+#include "chromeos/dbus/shill/shill_service_client.h"
#include "chromeos/network/network_handler.h"
#include "components/user_manager/scoped_user_manager.h"
#include "content/public/test/test_browser_thread_bundle.h"
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 d504f1e43b0..106d51160df 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
@@ -18,6 +18,7 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/previews/core/previews_experiments.h"
#include "components/previews/core/previews_switches.h"
+#include "net/base/features.h"
#include "net/nqe/network_quality_estimator_params.h"
#include "services/network/public/cpp/network_quality_tracker.h"
#include "services/network/public/cpp/network_switches.h"
@@ -99,7 +100,8 @@ std::string GetFeatureFlagStatus(const std::string& feature_name) {
std::string GetNonFlagEctValue() {
std::map<std::string, std::string> nqe_params;
- base::GetFieldTrialParams("NetworkQualityEstimator", &nqe_params);
+ base::GetFieldTrialParamsByFeature(net::features::kNetworkQualityEstimator,
+ &nqe_params);
if (nqe_params.find(net::kForceEffectiveConnectionType) != nqe_params.end()) {
return "Fieldtrial forced " +
nqe_params[net::kForceEffectiveConnectionType];
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 972c02998cc..e308815f6e7 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
@@ -40,6 +40,7 @@
#include "components/previews/core/previews_switches.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "mojo/public/cpp/bindings/binding.h"
+#include "net/base/features.h"
#include "net/nqe/effective_connection_type.h"
#include "net/nqe/network_quality_estimator_params.h"
#include "services/network/public/cpp/network_switches.h"
@@ -543,8 +544,8 @@ TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsEctForceFieldtrialValue) {
std::map<std::string, std::string> params;
params[net::kForceEffectiveConnectionType] = expected_ect;
- ASSERT_TRUE(base::AssociateFieldTrialParams(trial_name, group_name, params));
- base::FieldTrialList::CreateFieldTrial(trial_name, group_name);
+ scoped_feature_list_->InitAndEnableFeatureWithParameters(
+ net::features::kNetworkQualityEstimator, params);
page_handler_->GetPreviewsFlagsDetails(
base::BindOnce(&MockGetPreviewsFlagsCallback));
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 4318cbcdd9e..122663b64ce 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
@@ -42,8 +42,8 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/browser_process.h"
#include "chrome/common/pref_names.h"
-#include "chromeos/account_manager/account_manager.h"
-#include "chromeos/account_manager/account_manager_factory.h"
+#include "chromeos/components/account_manager/account_manager.h"
+#include "chromeos/components/account_manager/account_manager_factory.h"
#include "chromeos/constants/chromeos_switches.h"
#include "components/prefs/pref_service.h"
#endif
diff --git a/chromium/chrome/browser/ui/webui/log_web_ui_url.cc b/chromium/chrome/browser/ui/webui/log_web_ui_url.cc
index cb42bf243ca..2c0253db04d 100644
--- a/chromium/chrome/browser/ui/webui/log_web_ui_url.cc
+++ b/chromium/chrome/browser/ui/webui/log_web_ui_url.cc
@@ -6,7 +6,7 @@
#include <stdint.h>
-#include "base/hash.h"
+#include "base/hash/hash.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/common/url_constants.h"
#include "content/public/common/url_constants.h"
diff --git a/chromium/chrome/browser/ui/webui/log_web_ui_url_browsertest.cc b/chromium/chrome/browser/ui/webui/log_web_ui_url_browsertest.cc
index 47835d2bbe6..9bf7d5207f9 100644
--- a/chromium/chrome/browser/ui/webui/log_web_ui_url_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/log_web_ui_url_browsertest.cc
@@ -8,7 +8,7 @@
#include <vector>
-#include "base/hash.h"
+#include "base/hash/hash.h"
#include "base/macros.h"
#include "base/test/metrics/histogram_tester.h"
#include "chrome/browser/ui/browser.h"
diff --git a/chromium/chrome/browser/ui/webui/managed_ui_handler.cc b/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
index 4a69e87e12c..538636e697d 100644
--- a/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/managed_ui_handler.cc
@@ -7,7 +7,6 @@
#include <utility>
#include "base/bind.h"
-#include "base/feature_list.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -15,9 +14,7 @@
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/managed_ui.h"
-#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui.h"
@@ -123,15 +120,10 @@ std::unique_ptr<base::DictionaryValue> ManagedUIHandler::GetDataSourceUpdate()
const {
auto update = std::make_unique<base::DictionaryValue>();
- bool link_to_management_page = base::FeatureList::IsEnabled(
- features::kLinkManagedNoticeToChromeUIManagementURL);
-
update->SetKey("managedByOrg",
base::Value(l10n_util::GetStringFUTF16(
IDS_MANAGED_BY_ORG_WITH_HYPERLINK,
- base::UTF8ToUTF16(link_to_management_page
- ? chrome::kChromeUIManagementURL
- : chrome::kManagedUiLearnMoreUrl)
+ base::UTF8ToUTF16(chrome::kChromeUIManagementURL)
#if defined(OS_CHROMEOS)
,
ui::GetChromeOSDeviceName()
diff --git a/chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc
index 756c7f2fedf..7f2201ca46a 100644
--- a/chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/managed_ui_handler_unittest.cc
@@ -7,7 +7,6 @@
#include "base/test/scoped_feature_list.h"
#include "base/token.h"
#include "base/values.h"
-#include "chrome/browser/browser_features.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
diff --git a/chromium/chrome/browser/ui/webui/management_a11y_browsertest.cc b/chromium/chrome/browser/ui/webui/management_a11y_browsertest.cc
new file mode 100644
index 00000000000..196f5abc01d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/management_a11y_browsertest.cc
@@ -0,0 +1,26 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/management_a11y_browsertest.h"
+
+#include "base/path_service.h"
+#include "chrome/browser/extensions/chrome_test_extension_loader.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_paths.h"
+
+ManagementA11yUIBrowserTest::ManagementA11yUIBrowserTest() {
+ CHECK(base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
+ test_data_dir_ = test_data_dir_.AppendASCII("extensions");
+}
+
+ManagementA11yUIBrowserTest::~ManagementA11yUIBrowserTest() {}
+
+void ManagementA11yUIBrowserTest::InstallPowerfulPolicyEnforcedExtension() {
+ extensions::ChromeTestExtensionLoader loader(browser()->profile());
+ loader.set_ignore_manifest_warnings(true);
+ loader.set_grant_permissions(true);
+ loader.set_location(extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD);
+ loader.LoadExtension(test_data_dir_.AppendASCII("good.crx"));
+}
diff --git a/chromium/chrome/browser/ui/webui/management_a11y_browsertest.h b/chromium/chrome/browser/ui/webui/management_a11y_browsertest.h
new file mode 100644
index 00000000000..a1e3bf75832
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/management_a11y_browsertest.h
@@ -0,0 +1,23 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_MANAGEMENT_A11Y_BROWSERTEST_H_
+#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_A11Y_BROWSERTEST_H_
+
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "chrome/test/base/web_ui_browser_test.h"
+
+// C++ test fixture used by management_a11y_test.js.
+class ManagementA11yUIBrowserTest : public WebUIBrowserTest {
+ public:
+ ManagementA11yUIBrowserTest();
+ ~ManagementA11yUIBrowserTest() override;
+
+ protected:
+ void InstallPowerfulPolicyEnforcedExtension();
+ base::FilePath test_data_dir_;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_A11Y_BROWSERTEST_H_
diff --git a/chromium/chrome/browser/ui/webui/management_ui.cc b/chromium/chrome/browser/ui/webui/management_ui.cc
index 336a210eb9e..9b00b461b2a 100644
--- a/chromium/chrome/browser/ui/webui/management_ui.cc
+++ b/chromium/chrome/browser/ui/webui/management_ui.cc
@@ -8,16 +8,18 @@
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/dark_mode_handler.h"
#include "chrome/browser/ui/webui/localized_string.h"
#include "chrome/browser/ui/webui/management_ui_handler.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
+#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/safe_browsing/common/safebrowsing_constants.h"
#include "components/strings/grit/components_strings.h"
-#include "content/public/browser/web_ui.h"
#include "extensions/buildflags/buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -27,47 +29,25 @@
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/grit/chromium_strings.h"
#include "ui/chromeos/devicetype_utils.h"
+#else // defined(OS_CHROMEOS)
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#endif // defined(OS_CHROMEOS)
namespace {
-#if defined(OS_CHROMEOS)
-
-base::string16 GetChromeOSManagementPageTitle() {
- policy::BrowserPolicyConnectorChromeOS* connector =
- g_browser_process->platform_part()->browser_policy_connector_chromeos();
- const auto device_type = ui::GetChromeOSDeviceTypeResourceId();
- if (!connector->IsEnterpriseManaged()) {
- return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_NOT_MANAGED_TITLE,
- l10n_util::GetStringUTF16(device_type));
- }
-
- std::string display_domain = connector->GetEnterpriseDisplayDomain();
-
- if (display_domain.empty()) {
- if (!connector->IsActiveDirectoryManaged()) {
- return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_TITLE_MANAGED,
- l10n_util::GetStringUTF16(device_type));
- }
- display_domain = connector->GetRealm();
- }
-
- return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_TITLE_BY,
- l10n_util::GetStringUTF16(device_type),
- base::UTF8ToUTF16(display_domain));
-}
-#endif // defined(OS_CHROMEOS)
-
-content::WebUIDataSource* CreateManagementUIHtmlSource() {
+content::WebUIDataSource* CreateManagementUIHtmlSource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIManagementHost);
-#if defined(OS_CHROMEOS)
- source->AddString("title", GetChromeOSManagementPageTitle());
-#endif // defined(OS_CHROMEOS)
+ source->AddString("pageSubtitle",
+ ManagementUI::GetManagementPageSubtitle(profile));
static constexpr LocalizedString kLocalizedStrings[] = {
#if defined(OS_CHROMEOS)
+ {"learnMore", IDS_LEARN_MORE},
+ {"localTrustRoots", IDS_MANAGEMENT_LOCAL_TRUST_ROOTS},
+ {"managementTrustRootsConfigured", IDS_MANAGEMENT_TRUST_ROOTS_CONFIGURED},
{"deviceConfiguration", IDS_MANAGEMENT_DEVICE_CONFIGURATION},
{"deviceReporting", IDS_MANAGEMENT_DEVICE_REPORTING},
{kManagementLogUploadEnabled, IDS_MANAGEMENT_LOG_UPLOAD_ENABLED},
@@ -78,17 +58,20 @@ content::WebUIDataSource* CreateManagementUIHtmlSource() {
{kManagementReportNetworkInterfaces,
IDS_MANAGEMENT_REPORT_DEVICE_NETWORK_INTERFACES},
{kManagementReportUsers, IDS_MANAGEMENT_REPORT_DEVICE_USERS},
+ {kManagementPrinting, IDS_MANAGEMENT_REPORT_PRINTING},
#endif // defined(OS_CHROMEOS)
{"browserReporting", IDS_MANAGEMENT_BROWSER_REPORTING},
{"browserReportingExplanation",
IDS_MANAGEMENT_BROWSER_REPORTING_EXPLANATION},
{"extensionReporting", IDS_MANAGEMENT_EXTENSION_REPORTING},
- {"extensionsInstalled", IDS_MANAGEMENT_EXTENSIONS_INSTALLED},
+ {"extensionReportingTitle", IDS_MANAGEMENT_EXTENSIONS_INSTALLED},
{"extensionName", IDS_MANAGEMENT_EXTENSIONS_NAME},
{"extensionPermissions", IDS_MANAGEMENT_EXTENSIONS_PERMISSIONS},
- {"localTrustRoots", IDS_MANAGEMENT_LOCAL_TRUST_ROOTS},
- {"managementTrustRootsNotConfigured",
- IDS_MANAGEMENT_TRUST_ROOTS_NOT_CONFIGURED},
+ {"title", IDS_MANAGEMENT_TITLE},
+ {"toolbarTitle", IDS_MANAGEMENT_TOOLBAR_TITLE},
+ {"searchPrompt", IDS_SETTINGS_SEARCH_PROMPT},
+ {"clearSearch", IDS_DOWNLOAD_CLEAR_SEARCH},
+ {"backButton", IDS_ACCNAME_BACK},
#if BUILDFLAG(ENABLE_EXTENSIONS)
{kManagementExtensionReportMachineName,
IDS_MANAGEMENT_EXTENSION_REPORT_MACHINE_NAME},
@@ -114,15 +97,13 @@ content::WebUIDataSource* CreateManagementUIHtmlSource() {
l10n_util::GetStringFUTF16(
IDS_MANAGEMENT_EXTENSION_REPORT_SAFE_BROWSING_WARNINGS,
base::UTF8ToUTF16(safe_browsing::kSafeBrowsingUrl)));
-
-#if BUILDFLAG(ENABLE_EXTENSIONS)
-
-#endif // BUILDFLAG(ENABLE_EXTENSIONS)
-
#if defined(OS_CHROMEOS)
- source->AddLocalizedString("managementTrustRootsConfigured",
- IDS_MANAGEMENT_TRUST_ROOTS_CONFIGURED);
+ source->AddString("managementDeviceLearnMoreUrl",
+ chrome::kLearnMoreEnterpriseURL);
+ source->AddString("managementAccountLearnMoreUrl",
+ chrome::kManagedUiLearnMoreUrl);
#endif // defined(OS_CHROMEOS)
+
source->SetJsonPath("strings.js");
// Add required resources.
source->AddResourcePath("management_browser_proxy.html",
@@ -146,14 +127,55 @@ base::RefCountedMemory* ManagementUI::GetFaviconResourceBytes(
IDR_MANAGEMENT_FAVICON, scale_factor);
}
+// static
+base::string16 ManagementUI::GetManagementPageSubtitle(Profile* profile) {
+#if defined(OS_CHROMEOS)
+ policy::BrowserPolicyConnectorChromeOS* connector =
+ g_browser_process->platform_part()->browser_policy_connector_chromeos();
+ const auto device_type = ui::GetChromeOSDeviceTypeResourceId();
+ if (!connector->IsEnterpriseManaged() &&
+ !policy::ProfilePolicyConnectorFactory::IsProfileManaged(profile)) {
+ return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE,
+ l10n_util::GetStringUTF16(device_type));
+ }
+
+ std::string display_domain = connector->GetEnterpriseDisplayDomain();
+
+ if (display_domain.empty())
+ display_domain = connector->GetRealm();
+ if (display_domain.empty())
+ display_domain = ManagementUIHandler::GetAccountDomain(profile);
+ if (display_domain.empty()) {
+ return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED,
+ l10n_util::GetStringUTF16(device_type));
+ }
+ return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY,
+ l10n_util::GetStringUTF16(device_type),
+ base::UTF8ToUTF16(display_domain));
+#else // defined(OS_CHROMEOS)
+ const auto management_domain = ManagementUIHandler::GetAccountDomain(profile);
+ const auto managed =
+ policy::ProfilePolicyConnectorFactory::IsProfileManaged(profile) ||
+ g_browser_process->browser_policy_connector()->HasMachineLevelPolicies();
+ if (management_domain.empty()) {
+ return l10n_util::GetStringUTF16(managed
+ ? IDS_MANAGEMENT_SUBTITLE
+ : IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE);
+ }
+ if (managed) {
+ return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY,
+ base::UTF8ToUTF16(management_domain));
+ }
+ return l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE);
+#endif // defined(OS_CHROMEOS)
+}
+
ManagementUI::ManagementUI(content::WebUI* web_ui) : WebUIController(web_ui) {
- content::WebUIDataSource* source = CreateManagementUIHtmlSource();
- Profile* profile = Profile::FromWebUI(web_ui);
- auto management_ui_handler = std::make_unique<ManagementUIHandler>();
- management_ui_handler->InitializeManagementContextualStrings(profile, source);
- web_ui->AddMessageHandler(std::move(management_ui_handler));
+ content::WebUIDataSource* source =
+ CreateManagementUIHtmlSource(Profile::FromWebUI(web_ui));
+ ManagementUIHandler::Initialize(web_ui, source);
DarkModeHandler::Initialize(web_ui, source);
- content::WebUIDataSource::Add(profile, source);
+ content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
}
ManagementUI::~ManagementUI() {}
diff --git a/chromium/chrome/browser/ui/webui/management_ui.h b/chromium/chrome/browser/ui/webui/management_ui.h
index f3be72a22ed..86f66238d9b 100644
--- a/chromium/chrome/browser/ui/webui/management_ui.h
+++ b/chromium/chrome/browser/ui/webui/management_ui.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_H_
#include "base/macros.h"
+#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/web_ui_controller.h"
#include "ui/base/resource/scale_factor.h"
@@ -26,6 +27,8 @@ class ManagementUI : public content::WebUIController {
static base::RefCountedMemory* GetFaviconResourceBytes(
ui::ScaleFactor scale_factor);
+ static base::string16 GetManagementPageSubtitle(Profile* profile);
+
private:
DISALLOW_COPY_AND_ASSIGN(ManagementUI);
};
diff --git a/chromium/chrome/browser/ui/webui/management_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/management_ui_browsertest.cc
new file mode 100644
index 00000000000..efc934ad8b1
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/management_ui_browsertest.cc
@@ -0,0 +1,130 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/json/json_reader.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/policy/chrome_browser_policy_connector.h"
+#include "chrome/browser/policy/profile_policy_connector.h"
+#include "chrome/browser/policy/profile_policy_connector_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/webui/management_ui.h"
+#include "chrome/browser/ui/webui/management_ui_handler.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "components/policy/core/browser/browser_policy_connector.h"
+#include "components/policy/core/common/mock_configuration_policy_provider.h"
+#include "components/strings/grit/components_strings.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/test/browser_test_utils.h"
+#include "ui/base/l10n/l10n_util.h"
+
+class ManagementUITest : public InProcessBrowserTest {
+ public:
+ ManagementUITest() = default;
+ ~ManagementUITest() override = default;
+
+ void SetUpInProcessBrowserTestFixture() override {
+ EXPECT_CALL(provider_, IsInitializationComplete(testing::_))
+ .WillRepeatedly(testing::Return(true));
+ policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
+ }
+
+ void VerifyTexts(base::Value* actual_values,
+ std::map<std::string, base::string16>& expected_values) {
+ base::DictionaryValue* values_as_dict = NULL;
+ actual_values->GetAsDictionary(&values_as_dict);
+ for (const auto& val : expected_values) {
+ base::string16 actual_value;
+ values_as_dict->GetString(val.first, &actual_value);
+ ASSERT_EQ(actual_value, val.second);
+ }
+ }
+ policy::MockConfigurationPolicyProvider* provider() { return &provider_; }
+
+ policy::ProfilePolicyConnector* profile_policy_connector() {
+ return policy::ProfilePolicyConnectorFactory::GetForBrowserContext(
+ browser()->profile());
+ }
+
+ private:
+ policy::MockConfigurationPolicyProvider provider_;
+
+ DISALLOW_COPY_AND_ASSIGN(ManagementUITest);
+};
+
+#if !defined(OS_CHROMEOS)
+IN_PROC_BROWSER_TEST_F(ManagementUITest, ManagementStateChange) {
+ profile_policy_connector()->OverrideIsManagedForTesting(false);
+ ui_test_utils::NavigateToURL(browser(), GURL("chrome://management"));
+
+ // The browser is not managed.
+ const std::string javascript =
+ "management.ManagementBrowserProxyImpl.getInstance()"
+ " .getContextualManagedData()"
+ " .then(managed_result => "
+ " domAutomationController.send(JSON.stringify(managed_result)));";
+
+ content::WebContents* contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ std::string unmanaged_json;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents, javascript,
+ &unmanaged_json));
+
+ std::unique_ptr<base::Value> unmanaged_value_ptr =
+ base::JSONReader::ReadDeprecated(unmanaged_json);
+ std::map<std::string, base::string16> expected_unmanaged_values{
+ {"browserManagementNotice",
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_NOT_MANAGED_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))},
+ {"extensionReportingTitle",
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED)},
+ {"pageSubtitle",
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE)},
+ {"accountManagedInfo.overview", base::string16()},
+ {"accountManagedInfo.data", base::string16()},
+ {"accountManagedInfo.setup", base::string16()},
+ };
+
+ VerifyTexts(unmanaged_value_ptr.get(), expected_unmanaged_values);
+
+ // The browser is managed.
+ profile_policy_connector()->OverrideIsManagedForTesting(true);
+
+ policy::PolicyMap policy_map;
+ policy_map.Set("test-policy", policy::POLICY_LEVEL_MANDATORY,
+ policy::POLICY_SCOPE_MACHINE, policy::POLICY_SOURCE_PLATFORM,
+ std::make_unique<base::Value>("hello world"), nullptr);
+ provider()->UpdateExtensionPolicy(policy_map,
+ kOnPremReportingExtensionBetaId);
+
+ contents = browser()->tab_strip_model()->GetActiveWebContents();
+ std::string managed_json;
+
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(contents, javascript,
+ &managed_json));
+
+ std::unique_ptr<base::Value> managed_value_ptr =
+ base::JSONReader::ReadDeprecated(managed_json);
+ std::map<std::string, base::string16> expected_managed_values{
+ {"browserManagementNotice",
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_BROWSER_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))},
+ {"extensionReportingTitle",
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED)},
+ {"pageSubtitle", l10n_util::GetStringUTF16(IDS_MANAGEMENT_SUBTITLE)},
+ {"accountManagedInfo.overview",
+ l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION_UNKNOWN_DOMAIN)},
+ {"accountManagedInfo.data",
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA)},
+ {"accountManagedInfo.setup",
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP)},
+ };
+
+ VerifyTexts(managed_value_ptr.get(), expected_managed_values);
+}
+#endif // !defined(OS_CHROMEOS)
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler.cc b/chromium/chrome/browser/ui/webui/management_ui_handler.cc
index 6535e87431f..d276f4c01e7 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/management_ui_handler.cc
@@ -34,14 +34,16 @@
#if defined(OS_CHROMEOS)
#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/policy/device_status_collector.h"
#include "chrome/browser/chromeos/policy/policy_cert_service.h"
#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
+#include "chrome/browser/chromeos/policy/status_collector/device_status_collector.h"
#include "chrome/browser/chromeos/policy/status_uploader.h"
#include "chrome/browser/chromeos/policy/system_log_uploader.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/grit/chromium_strings.h"
+#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
+#include "ui/chromeos/devicetype_utils.h"
#endif // defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -107,12 +109,21 @@ enum class ReportingType {
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+#if defined(OS_CHROMEOS)
const char kManagementLogUploadEnabled[] = "managementLogUploadEnabled";
const char kManagementReportActivityTimes[] = "managementReportActivityTimes";
const char kManagementReportHardwareStatus[] = "managementReportHardwareStatus";
const char kManagementReportNetworkInterfaces[] =
"managementReportNetworkInterfaces";
const char kManagementReportUsers[] = "managementReportUsers";
+const char kManagementPrinting[] = "managementPrinting";
+const char kDeviceManagedInfo[] = "deviceManagedInfo";
+#endif // defined(OS_CHROMEOS)
+
+const char kOverview[] = "overview";
+const char kAccountManagedInfo[] = "accountManagedInfo";
+const char kSetup[] = "setup";
+const char kData[] = "data";
namespace {
@@ -120,6 +131,14 @@ bool IsProfileManaged(Profile* profile) {
return policy::ProfilePolicyConnectorFactory::IsProfileManaged(profile);
}
+#if defined(OS_CHROMEOS)
+bool IsDeviceManaged() {
+ policy::BrowserPolicyConnectorChromeOS* connector =
+ g_browser_process->platform_part()->browser_policy_connector_chromeos();
+ return connector->IsEnterpriseManaged();
+}
+#endif // defined(OS_CHROMEOS)
+
#if !defined(OS_CHROMEOS)
bool IsBrowserManaged() {
return g_browser_process->browser_policy_connector()
@@ -127,70 +146,6 @@ bool IsBrowserManaged() {
}
#endif // !defined(OS_CHROMEOS)
-std::string GetAccountDomain(Profile* profile) {
- auto username = profile->GetProfileUserName();
- size_t email_separator_pos = username.find('@');
- bool is_email = email_separator_pos != std::string::npos &&
- email_separator_pos < username.length() - 1;
-
- if (!is_email)
- return std::string();
-
- const std::string domain = gaia::ExtractDomainName(std::move(username));
-
- auto consumer_domain_pos = domain.find("gmail.com");
- if (consumer_domain_pos == std::string::npos)
- consumer_domain_pos = domain.find("googlemail.com");
-
- return consumer_domain_pos == std::string::npos ? domain : std::string();
-}
-
-#if !defined(OS_CHROMEOS)
-void GetDataManagementBrowserContextualSourceUpdate(
- base::DictionaryValue* update,
- Profile* profile,
- bool managed) {
- auto management_domain = GetAccountDomain(profile);
-
- if (management_domain.empty()) {
- update->SetString(
- "extensionsInstalled",
- l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED));
-
- update->SetString("browserManagementNotice",
- l10n_util::GetStringFUTF16(
- managed ? IDS_MANAGEMENT_BROWSER_NOTICE
- : IDS_MANAGEMENT_NOT_MANAGED_NOTICE,
- base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
- update->SetString("title", l10n_util::GetStringUTF16(
- managed ? IDS_MANAGEMENT_TITLE
- : IDS_MANAGEMENT_NOT_MANAGED_TITLE));
-
- } else {
- update->SetString(
- "extensionsInstalled",
- l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY,
- base::UTF8ToUTF16(management_domain)));
-
- update->SetString(
- "browserManagementNotice",
- managed ? l10n_util::GetStringFUTF16(
- IDS_MANAGEMENT_MANAGEMENT_BY_NOTICE,
- base::UTF8ToUTF16(management_domain),
- base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))
- : l10n_util::GetStringFUTF16(
- IDS_MANAGEMENT_NOT_MANAGED_NOTICE,
- base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
- update->SetString(
- "title",
- managed
- ? l10n_util::GetStringFUTF16(IDS_MANAGEMENT_TITLE_BY,
- base::UTF8ToUTF16(management_domain))
- : l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_TITLE));
- }
-}
-#endif // !defined(OS_CHROMEOS)
-
#if defined(OS_CHROMEOS)
enum class DeviceReportingType {
@@ -198,7 +153,8 @@ enum class DeviceReportingType {
kDeviceActivity,
kDeviceStatistics,
kDevice,
- kLogs
+ kLogs,
+ kPrint
};
// Corresponds to DeviceReportingType in management_browser_proxy.js
@@ -214,6 +170,8 @@ std::string ToJSDeviceReportingType(const DeviceReportingType& type) {
return "device";
case DeviceReportingType::kLogs:
return "logs";
+ case DeviceReportingType::kPrint:
+ return "print";
default:
NOTREACHED() << "Unknown device reporting type";
return "device";
@@ -229,7 +187,7 @@ void AddDeviceReportingElement(base::Value* report_sources,
report_sources->GetList().push_back(std::move(data));
}
-void AddDeviceReportingInfo(base::Value* report_sources) {
+void AddDeviceReportingInfo(base::Value* report_sources, Profile* profile) {
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -243,24 +201,24 @@ void AddDeviceReportingInfo(base::Value* report_sources) {
if (!manager)
return;
- const policy::DeviceStatusCollector* collector =
- manager->GetStatusUploader()->device_status_collector();
+ const policy::StatusCollector* collector =
+ manager->GetStatusUploader()->status_collector();
// Elements appear on the page in the order they are added.
- if (collector->report_activity_times()) {
+ if (collector->ShouldReportActivityTimes()) {
AddDeviceReportingElement(report_sources, kManagementReportActivityTimes,
DeviceReportingType::kDeviceActivity);
} else {
- if (collector->report_users()) {
+ if (collector->ShouldReportUsers()) {
AddDeviceReportingElement(report_sources, kManagementReportUsers,
DeviceReportingType::kSupervisedUser);
}
}
- if (collector->report_hardware_status()) {
+ if (collector->ShouldReportHardwareStatus()) {
AddDeviceReportingElement(report_sources, kManagementReportHardwareStatus,
DeviceReportingType::kDeviceStatistics);
}
- if (collector->report_network_interfaces()) {
+ if (collector->ShouldReportNetworkInterfaces()) {
AddDeviceReportingElement(report_sources,
kManagementReportNetworkInterfaces,
DeviceReportingType::kDevice);
@@ -269,6 +227,12 @@ void AddDeviceReportingInfo(base::Value* report_sources) {
AddDeviceReportingElement(report_sources, kManagementLogUploadEnabled,
DeviceReportingType::kLogs);
}
+
+ if (profile->GetPrefs()->GetBoolean(
+ prefs::kPrintingSendUsernameAndFilenameEnabled)) {
+ AddDeviceReportingElement(report_sources, kManagementPrinting,
+ DeviceReportingType::kPrint);
+ }
}
#endif // defined(OS_CHROMEOS)
@@ -337,6 +301,26 @@ const char* GetReportingTypeValue(ReportingType reportingType) {
} // namespace
+// TODO(raleksandov) Move to util class or smth similar.
+// static
+std::string ManagementUIHandler::GetAccountDomain(Profile* profile) {
+ auto username = profile->GetProfileUserName();
+ size_t email_separator_pos = username.find('@');
+ bool is_email = email_separator_pos != std::string::npos &&
+ email_separator_pos < username.length() - 1;
+
+ if (!is_email)
+ return std::string();
+
+ const std::string domain = gaia::ExtractDomainName(std::move(username));
+
+ auto consumer_domain_pos = domain.find("gmail.com");
+ if (consumer_domain_pos == std::string::npos)
+ consumer_domain_pos = domain.find("googlemail.com");
+
+ return consumer_domain_pos == std::string::npos ? domain : std::string();
+}
+
ManagementUIHandler::ManagementUIHandler() {
#if BUILDFLAG(ENABLE_EXTENSIONS)
reporting_extension_ids_ = {kOnPremReportingExtensionStableId,
@@ -346,29 +330,32 @@ ManagementUIHandler::ManagementUIHandler() {
}
ManagementUIHandler::~ManagementUIHandler() {
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- RemoveObservers();
-#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+ DisallowJavascript();
+}
+
+void ManagementUIHandler::Initialize(content::WebUI* web_ui,
+ content::WebUIDataSource* source) {
+ InitializeInternal(web_ui, source, Profile::FromWebUI(web_ui));
}
+// static
+void ManagementUIHandler::InitializeInternal(content::WebUI* web_ui,
+ content::WebUIDataSource* source,
+ Profile* profile) {
+ auto handler = std::make_unique<ManagementUIHandler>();
-void ManagementUIHandler::InitializeManagementContextualStrings(
- Profile* profile,
- content::WebUIDataSource* web_data_source) {
#if defined(OS_CHROMEOS)
- managed_ = IsProfileManaged(profile);
+ handler->managed_ = IsProfileManaged(profile) || IsDeviceManaged();
#else
- managed_ = IsProfileManaged(profile) || IsBrowserManaged();
+ handler->managed_ = IsProfileManaged(profile) || IsBrowserManaged();
#endif // defined(OS_CHROMEOS)
- web_data_source->AddLocalizedStrings(
- *GetDataManagementContextualSourceUpdate(profile));
- web_ui_data_source_name_ = web_data_source->GetSource();
+ web_ui->AddMessageHandler(std::move(handler));
}
void ManagementUIHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "getDeviceManagementStatus",
- base::BindRepeating(&ManagementUIHandler::HandleGetDeviceManagementStatus,
+ "getContextualManagedData",
+ base::BindRepeating(&ManagementUIHandler::HandleGetContextualManagedData,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getExtensions",
@@ -391,6 +378,10 @@ void ManagementUIHandler::RegisterMessages() {
}
#if BUILDFLAG(ENABLE_EXTENSIONS)
+void ManagementUIHandler::OnJavascriptAllowed() {
+ AddObservers();
+}
+
void ManagementUIHandler::OnJavascriptDisallowed() {
RemoveObservers();
}
@@ -492,7 +483,88 @@ void ManagementUIHandler::AddExtensionReportingInfo(
}
}
-const policy::PolicyService* ManagementUIHandler::GetPolicyService() const {
+base::DictionaryValue ManagementUIHandler::GetContextualManagedData(
+ Profile* profile) const {
+ base::DictionaryValue response;
+
+#if defined(OS_CHROMEOS)
+ policy::BrowserPolicyConnectorChromeOS* connector =
+ g_browser_process->platform_part()->browser_policy_connector_chromeos();
+ std::string management_domain = connector->GetEnterpriseDisplayDomain();
+ if (management_domain.empty())
+ management_domain = connector->GetRealm();
+ if (management_domain.empty())
+ management_domain = GetAccountDomain(profile);
+#else
+ std::string management_domain = GetAccountDomain(profile);
+#endif
+
+ if (management_domain.empty()) {
+ response.SetString(
+ "extensionReportingTitle",
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED));
+
+#if !defined(OS_CHROMEOS)
+ response.SetString("browserManagementNotice",
+ l10n_util::GetStringFUTF16(
+ managed_ ? IDS_MANAGEMENT_BROWSER_NOTICE
+ : IDS_MANAGEMENT_NOT_MANAGED_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
+ response.SetString("pageSubtitle",
+ l10n_util::GetStringUTF16(
+ managed_ ? IDS_MANAGEMENT_SUBTITLE
+ : IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE));
+#else
+ const auto device_type = ui::GetChromeOSDeviceTypeResourceId();
+ response.SetString("pageSubtitle",
+ managed_ ? l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_SUBTITLE_MANAGED,
+ l10n_util::GetStringUTF16(device_type))
+ : l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE,
+ l10n_util::GetStringUTF16(device_type)));
+#endif // !defined(OS_CHROMEOS)
+
+ } else {
+ response.SetString(
+ "extensionReportingTitle",
+ l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY,
+ base::UTF8ToUTF16(management_domain)));
+
+#if !defined(OS_CHROMEOS)
+ response.SetString(
+ "browserManagementNotice",
+ managed_ ? l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_MANAGEMENT_BY_NOTICE,
+ base::UTF8ToUTF16(management_domain),
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl))
+ : l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_NOT_MANAGED_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
+ response.SetString(
+ "pageSubtitle",
+ managed_
+ ? l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY,
+ base::UTF8ToUTF16(management_domain))
+ : l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE));
+#else
+ const auto device_type = ui::GetChromeOSDeviceTypeResourceId();
+ response.SetString("pageSubtitle",
+ managed_ ? l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_SUBTITLE_MANAGED_BY,
+ l10n_util::GetStringUTF16(device_type),
+ base::UTF8ToUTF16(management_domain))
+ : l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE,
+ l10n_util::GetStringUTF16(device_type)));
+#endif // !defined(OS_CHROMEOS)
+ }
+ response.SetBoolean("managed", managed_);
+ GetManagementStatus(profile, &response);
+ return response;
+}
+
+policy::PolicyService* ManagementUIHandler::GetPolicyService() const {
return policy::ProfilePolicyConnectorFactory::GetForBrowserContext(
Profile::FromWebUI(web_ui()))
->policy_service();
@@ -506,43 +578,130 @@ const extensions::Extension* ManagementUIHandler::GetEnabledExtension(
}
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
-std::unique_ptr<base::DictionaryValue>
-ManagementUIHandler::GetDataManagementContextualSourceUpdate(
- Profile* profile) const {
- auto update = std::make_unique<base::DictionaryValue>();
-#if !defined(OS_CHROMEOS)
- GetDataManagementBrowserContextualSourceUpdate(update.get(), profile,
- managed_);
-#endif // !defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS)
+void AddStatusDeviceManagedInfo(base::Value* status,
+ const std::string& device_domain) {
+ base::Value info(base::Value::Type::DICTIONARY);
+ info.SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_DEVICE_MANAGED_CLARIFICATION,
+ base::UTF8ToUTF16(device_domain))));
+ info.SetKey(kSetup, base::Value(l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_DEVICE_MANAGED_SETUP)));
+ info.SetKey(kData, base::Value(l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_DEVICE_MANAGED_DATA)));
+ status->SetKey(kDeviceManagedInfo, std::move(info));
+}
+
+void AddStatusDeviceAndAccountManagedInfo(
+ base::Value* status,
+ const std::string& device_and_account_domain) {
+ base::Value info(base::Value::Type::DICTIONARY);
+ info.SetKey(kOverview,
+ base::Value(l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_CLARIFICATION,
+ base::UTF8ToUTF16(device_and_account_domain))));
+ info.SetKey(kSetup, base::Value(l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_SETUP)));
+ info.SetKey(kData, base::Value(l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_DATA)));
+ status->SetKey(kDeviceManagedInfo, std::move(info));
+}
+#endif // defined(OS_CHROMEOS)
- return update;
+void AddStatusAccountManagedInfo(base::Value* status,
+ const std::string& account_domain) {
+ base::Value info(base::Value::Type::DICTIONARY);
+ if (account_domain.empty()) {
+ info.SetKey(
+ kOverview,
+ base::Value(l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION_UNKNOWN_DOMAIN)));
+ } else {
+ info.SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION,
+ base::UTF8ToUTF16(account_domain))));
+ }
+ info.SetKey(kSetup, base::Value(l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP)));
+ info.SetKey(kData, base::Value(l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA)));
+ status->SetKey(kAccountManagedInfo, std::move(info));
}
-base::string16 ManagementUIHandler::GetEnterpriseManagementStatusString() {
- auto* profile = Profile::FromWebUI(web_ui());
- const bool account_managed = IsProfileManaged(profile);
+#if defined(OS_CHROMEOS)
+void AddStatusOverviewManagedDeviceAndAccount(
+ base::Value* status,
+ const std::string& device_domain,
+ const std::string& account_domain) {
+ status->SetKey(kOverview,
+ base::Value(l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_DEVICE_MANAGED_BY_ACCOUNT_MANAGED_BY,
+ base::UTF8ToUTF16(device_domain),
+ base::UTF8ToUTF16(account_domain))));
+ AddStatusDeviceManagedInfo(status, device_domain);
+ AddStatusAccountManagedInfo(status, account_domain);
+}
+
+void AddStatusOverviewManagedDeviceAndAccount(
+ base::Value* status,
+ const std::string& device_and_account_domain) {
+ status->SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_BY,
+ base::UTF8ToUTF16(device_and_account_domain))));
+ AddStatusDeviceAndAccountManagedInfo(status, device_and_account_domain);
+ status->SetKey(kAccountManagedInfo, base::Value());
+}
+
+void AddStatusOverviewManagedDevice(base::Value* status,
+ const std::string& device_domain) {
+ status->SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_DEVICE_MANAGED_BY,
+ base::UTF8ToUTF16(device_domain))));
+ AddStatusDeviceManagedInfo(status, device_domain);
+ status->SetKey(kAccountManagedInfo, base::Value());
+}
+
+#endif // defined(OS_CHROMEOS)
+
+void AddStatusOverviewManagedAccount(base::Value* status,
+ const std::string& account_domain) {
+#if defined(OS_CHROMEOS)
+ status->SetKey(kOverview, base::Value(l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_ACCOUNT_MANAGED_BY,
+ base::UTF8ToUTF16(account_domain))));
+ status->SetKey(kDeviceManagedInfo, base::Value());
+#endif // defined(OS_CHROMEOS)
+ AddStatusAccountManagedInfo(status, account_domain);
+}
+
+#if defined(OS_CHROMEOS)
+void AddStatusOverviewNotManaged(base::Value* status) {
+ status->SetKey(kOverview, base::Value(l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_DEVICE_NOT_MANAGED)));
+ status->SetKey(kAccountManagedInfo, base::Value());
+ status->SetKey(kDeviceManagedInfo, base::Value());
+}
+#endif // defined(OS_CHROMEOS)
+
+void ManagementUIHandler::GetManagementStatus(Profile* profile,
+ base::Value* status) const {
const std::string account_domain = GetAccountDomain(profile);
- bool profile_associated_with_gaia_account = true;
#if defined(OS_CHROMEOS)
- profile_associated_with_gaia_account =
+ const bool account_managed = IsProfileManaged(profile);
+ const bool profile_associated_with_gaia_account =
chromeos::IsProfileAssociatedWithGaiaAccount(profile);
-#endif // defined(OS_CHROMEOS)
- bool device_managed = false;
std::string device_domain;
-#if defined(OS_CHROMEOS)
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
- device_managed = connector->IsEnterpriseManaged();
+ const bool device_managed = connector->IsEnterpriseManaged();
if (device_managed)
device_domain = connector->GetEnterpriseDisplayDomain();
if (device_domain.empty() && connector->IsActiveDirectoryManaged())
device_domain = connector->GetRealm();
-#endif // defined(OS_CHROMEOS)
bool primary_user_managed = false;
std::string primary_user_account_domain;
-#if defined(OS_CHROMEOS)
auto* primary_user = user_manager::UserManager::Get()->GetPrimaryUser();
if (primary_user) {
auto* primary_profile =
@@ -552,47 +711,38 @@ base::string16 ManagementUIHandler::GetEnterpriseManagementStatusString() {
primary_user_account_domain = GetAccountDomain(primary_profile);
}
}
-#endif // defined(OS_CHROMEOS)
if (device_managed) {
DCHECK(!device_domain.empty());
if (account_managed) {
if (device_domain == account_domain ||
!profile_associated_with_gaia_account) {
- return l10n_util::GetStringFUTF16(
- IDS_MANAGEMENT_DEVICE_AND_ACCOUNT_MANAGED_BY,
- base::UTF8ToUTF16(device_domain));
+ AddStatusOverviewManagedDeviceAndAccount(status, device_domain);
+ return;
}
DCHECK(!account_domain.empty());
- return l10n_util::GetStringFUTF16(
- IDS_MANAGEMENT_DEVICE_MANAGED_BY_ACCOUNT_MANAGED_BY,
- base::UTF8ToUTF16(device_domain), base::UTF8ToUTF16(account_domain));
+ AddStatusOverviewManagedDeviceAndAccount(status, device_domain,
+ account_domain);
+ return;
}
- return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_DEVICE_MANAGED_BY,
- base::UTF8ToUTF16(device_domain));
- }
-
- if (account_managed) {
- return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_BY,
- base::UTF8ToUTF16(account_domain));
+ AddStatusOverviewManagedDevice(status, device_domain);
+ return;
}
if (primary_user_managed) {
- return l10n_util::GetStringFUTF16(
- IDS_MANAGEMENT_ACCOUNT_MANAGED_BY,
- base::UTF8ToUTF16(primary_user_account_domain));
+ AddStatusOverviewManagedAccount(status, primary_user_account_domain);
+ return;
}
+#endif // defined(OS_CHROMEOS)
- return l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_NOT_MANAGED);
-}
+ if (managed_) {
+ AddStatusOverviewManagedAccount(status, account_domain);
+ return;
+ }
-void ManagementUIHandler::HandleGetDeviceManagementStatus(
- const base::ListValue* args) {
- base::RecordAction(base::UserMetricsAction("ManagementPageViewed"));
- AllowJavascript();
- base::Value managed_string(GetEnterpriseManagementStatusString());
- ResolveJavascriptCallback(args->GetList()[0] /* callback_id */,
- managed_string);
+#if defined(OS_CHROMEOS)
+ AddStatusOverviewNotManaged(status);
+#endif // defined(OS_CHROMEOS)
}
void ManagementUIHandler::HandleGetExtensions(const base::ListValue* args) {
@@ -635,13 +785,20 @@ void ManagementUIHandler::HandleGetDeviceReportingInfo(
base::Value report_sources(base::Value::Type::LIST);
AllowJavascript();
- AddDeviceReportingInfo(&report_sources);
+ AddDeviceReportingInfo(&report_sources, Profile::FromWebUI(web_ui()));
ResolveJavascriptCallback(args->GetList()[0] /* callback_id */,
report_sources);
}
#endif // defined(OS_CHROMEOS)
+void ManagementUIHandler::HandleGetContextualManagedData(
+ const base::ListValue* args) {
+ AllowJavascript();
+ auto result = GetContextualManagedData(Profile::FromWebUI(web_ui()));
+ ResolveJavascriptCallback(args->GetList()[0] /* callback_id */,
+ std::move(result));
+}
void ManagementUIHandler::HandleInitBrowserReportingInfo(
const base::ListValue* args) {
@@ -649,7 +806,6 @@ void ManagementUIHandler::HandleInitBrowserReportingInfo(
AllowJavascript();
#if BUILDFLAG(ENABLE_EXTENSIONS)
AddExtensionReportingInfo(&report_sources);
- AddObservers();
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
ResolveJavascriptCallback(args->GetList()[0] /* callback_id */,
report_sources);
@@ -684,7 +840,7 @@ void ManagementUIHandler::OnExtensionUnloaded(
void ManagementUIHandler::OnManagedStateChanged() {
auto* profile = Profile::FromWebUI(web_ui());
#if defined(OS_CHROMEOS)
- bool managed = IsProfileManaged(profile);
+ bool managed = IsProfileManaged(profile) || IsDeviceManaged();
#else
bool managed = IsProfileManaged(profile) || IsBrowserManaged();
#endif // defined(OS_CHROMEOS)
@@ -694,31 +850,13 @@ void ManagementUIHandler::OnManagedStateChanged() {
managed_ = managed;
- auto data_source_update = GetDataManagementContextualSourceUpdate(profile);
- FireWebUIListener("update-load-time-data", data_source_update->Clone());
-
- content::WebUIDataSource::Update(profile, web_ui_data_source_name_,
- std::move(data_source_update));
+ FireWebUIListener("managed_state_changed");
}
void ManagementUIHandler::OnPolicyUpdated(
- const policy::PolicyNamespace& ns,
+ const policy::PolicyNamespace& /*ns*/,
const policy::PolicyMap& /*previous*/,
const policy::PolicyMap& /*current*/) {
- const policy::PolicyNamespace
- on_prem_reporting_extension_stable_policy_namespace =
- policy::PolicyNamespace(policy::POLICY_DOMAIN_EXTENSIONS,
- kOnPremReportingExtensionStableId);
- const policy::PolicyNamespace
- on_prem_reporting_extension_beta_policy_namespace =
- policy::PolicyNamespace(policy::POLICY_DOMAIN_EXTENSIONS,
- kOnPremReportingExtensionBetaId);
-
- if (ns == on_prem_reporting_extension_stable_policy_namespace ||
- ns == on_prem_reporting_extension_beta_policy_namespace) {
- return;
- }
-
OnManagedStateChanged();
NotifyBrowserReportingInfoUpdated();
}
@@ -733,9 +871,7 @@ void ManagementUIHandler::AddObservers() {
extensions::ExtensionRegistry::Get(profile)->AddObserver(this);
- policy::PolicyService* policy_service =
- policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile)
- ->policy_service();
+ auto* policy_service = GetPolicyService();
policy_service->AddObserver(policy::POLICY_DOMAIN_EXTENSIONS, this);
pref_registrar_.Init(profile->GetPrefs());
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler.h b/chromium/chrome/browser/ui/webui/management_ui_handler.h
index 28cf7d19699..daca8ea6eb1 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/management_ui_handler.h
@@ -9,6 +9,7 @@
#include <set>
#include <string>
+#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "chrome/common/url_constants.h"
@@ -23,6 +24,7 @@
#include "extensions/browser/extension_registry_observer.h"
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
+#if defined(OS_CHROMEOS)
// Constants defining the IDs for the localized strings sent to the page as
// load time data.
extern const char kManagementLogUploadEnabled[];
@@ -30,6 +32,8 @@ extern const char kManagementReportActivityTimes[];
extern const char kManagementReportHardwareStatus[];
extern const char kManagementReportNetworkInterfaces[];
extern const char kManagementReportUsers[];
+extern const char kManagementPrinting[];
+#endif // defined(OS_CHROMEOS)
#if BUILDFLAG(ENABLE_EXTENSIONS)
extern const char kCloudReportingExtensionId[];
@@ -77,7 +81,6 @@ class PolicyService;
class Profile;
// The JavaScript message handler for the chrome://management page.
-// TODO(ydago): Increase test coverage of this class
#if BUILDFLAG(ENABLE_EXTENSIONS)
class ManagementUIHandler : public content::WebUIMessageHandler,
public extensions::ExtensionRegistryObserver,
@@ -89,30 +92,35 @@ class ManagementUIHandler : public content::WebUIMessageHandler {
ManagementUIHandler();
~ManagementUIHandler() override;
- void InitializeManagementContextualStrings(
- Profile* profile,
- content::WebUIDataSource* web_data_source);
+ static void Initialize(content::WebUI* web_ui,
+ content::WebUIDataSource* source);
+
// content::WebUIMessageHandler implementation.
void RegisterMessages() override;
+ void SetManagedForTesting(bool managed) { managed_ = managed; }
+
+ static std::string GetAccountDomain(Profile* profile);
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
+ void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
protected:
+ // Protected for testing.
+ static void InitializeInternal(content::WebUI* web_ui,
+ content::WebUIDataSource* source,
+ Profile* profile);
void AddExtensionReportingInfo(base::Value* report_sources);
- virtual const policy::PolicyService* GetPolicyService() const;
+ base::DictionaryValue GetContextualManagedData(Profile* profile) const;
+ virtual policy::PolicyService* GetPolicyService() const;
virtual const extensions::Extension* GetEnabledExtension(
const std::string& extensionId) const;
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
private:
- std::unique_ptr<base::DictionaryValue>
- GetDataManagementContextualSourceUpdate(Profile* profile) const;
-
- base::string16 GetEnterpriseManagementStatusString();
-
- void HandleGetDeviceManagementStatus(const base::ListValue* args);
+ void GetManagementStatus(Profile* profile, base::Value* status) const;
#if defined(OS_CHROMEOS)
void HandleGetDeviceReportingInfo(const base::ListValue* args);
@@ -124,6 +132,7 @@ class ManagementUIHandler : public content::WebUIMessageHandler {
void HandleGetLocalTrustRootsInfo(const base::ListValue* args);
#endif // defined(OS_CHROMEOS)
+ void HandleGetContextualManagedData(const base::ListValue* args);
void HandleInitBrowserReportingInfo(const base::ListValue* args);
#if BUILDFLAG(ENABLE_EXTENSIONS)
diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc b/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc
index 4bc787f78cd..f081a564856 100644
--- a/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/management_ui_handler_unittest.cc
@@ -6,20 +6,42 @@
#include <set>
#include <string>
+#include "base/strings/utf_string_conversions.h"
+
#include "chrome/browser/ui/webui/management_ui_handler.h"
+#include "chrome/test/base/testing_profile.h"
#include "components/policy/core/common/mock_policy_service.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_namespace.h"
#include "components/policy/core/common/policy_service.h"
+#include "components/strings/grit/components_strings.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/l10n/l10n_util.h"
+
+#if defined(OS_CHROMEOS)
+#include "ui/chromeos/devicetype_utils.h"
+#endif // defined(OS_CHROMEOS)
+
using testing::_;
+using testing::Return;
using testing::ReturnRef;
+struct ContextualManagementSourceUpdate {
+ base::string16* extension_reporting_title;
+ base::string16* browser_management_notice;
+ base::string16* subtitle;
+ base::string16* management_overview;
+ base::string16* management_overview_data_notice;
+ base::string16* management_overview_setup_notice;
+ bool* managed;
+};
+
class TestManagementUIHandler : public ManagementUIHandler {
public:
TestManagementUIHandler() = default;
@@ -31,13 +53,18 @@ class TestManagementUIHandler : public ManagementUIHandler {
cloud_reporting_extension_exists_ = enable;
}
+ base::DictionaryValue GetContextualManagedDataForTesting(
+ Profile* profile) const {
+ return GetContextualManagedData(profile);
+ }
+
base::Value GetExtensionReportingInfo() {
base::Value report_sources(base::Value::Type::LIST);
AddExtensionReportingInfo(&report_sources);
return report_sources;
}
- const policy::PolicyService* GetPolicyService() const override {
+ policy::PolicyService* GetPolicyService() const override {
return policy_service_;
}
@@ -66,12 +93,348 @@ class ManagementUIHandlerTests : public testing::Test {
std::make_unique<base::Value>(true), nullptr);
}
+ void ExtractContextualSourceUpdate(
+ const base::DictionaryValue& data,
+ const ContextualManagementSourceUpdate& extracted) {
+ data.GetString("extensionReportingTitle",
+ extracted.extension_reporting_title);
+ data.GetString("browserManagementNotice",
+ extracted.browser_management_notice);
+ data.GetString("pageSubtitle", extracted.subtitle);
+ data.GetString("accountManagedInfo.overview",
+ extracted.management_overview);
+ data.GetString("accountManagedInfo.data",
+ extracted.management_overview_data_notice);
+ data.GetString("accountManagedInfo.setup",
+ extracted.management_overview_setup_notice);
+ data.GetBoolean("managed", extracted.managed);
+ }
+
protected:
TestManagementUIHandler handler_;
+ content::TestBrowserThreadBundle thread_bundle_;
policy::MockPolicyService policy_service_;
policy::PolicyMap empty_policy_map_;
};
+#if !defined(OS_CHROMEOS)
+TEST_F(ManagementUIHandlerTests,
+ ManagementContextualSourceUpdateUnmanagedNoDomain) {
+ auto profile = TestingProfile::Builder().Build();
+
+ base::string16 extension_reporting_title;
+ base::string16 browser_management_notice;
+ base::string16 subtitle;
+ base::string16 management_overview;
+ base::string16 management_overview_data_notice;
+ base::string16 management_overview_setup_notice;
+ bool managed;
+ ContextualManagementSourceUpdate extracted{&extension_reporting_title,
+ &browser_management_notice,
+ &subtitle,
+ &management_overview,
+ &management_overview_data_notice,
+ &management_overview_setup_notice,
+ &managed};
+
+ handler_.SetManagedForTesting(false);
+ auto data = handler_.GetContextualManagedDataForTesting(profile.get());
+ ExtractContextualSourceUpdate(data, extracted);
+
+ EXPECT_EQ(data.DictSize(), 4u);
+ EXPECT_EQ(extension_reporting_title,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED));
+ EXPECT_EQ(browser_management_notice,
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_NOT_MANAGED_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
+ EXPECT_EQ(subtitle,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE));
+ EXPECT_EQ(management_overview, base::string16());
+ EXPECT_EQ(management_overview_data_notice, base::string16());
+ EXPECT_EQ(management_overview_setup_notice, base::string16());
+}
+
+TEST_F(ManagementUIHandlerTests,
+ ManagementContextualSourceUpdateManagedNoDomain) {
+ auto profile = TestingProfile::Builder().Build();
+
+ base::string16 extension_reporting_title;
+ base::string16 browser_management_notice;
+ base::string16 subtitle;
+ base::string16 management_overview;
+ base::string16 management_overview_data_notice;
+ base::string16 management_overview_setup_notice;
+ bool managed;
+ ContextualManagementSourceUpdate extracted{&extension_reporting_title,
+ &browser_management_notice,
+ &subtitle,
+ &management_overview,
+ &management_overview_data_notice,
+ &management_overview_setup_notice,
+ &managed};
+
+ handler_.SetManagedForTesting(true);
+ auto data = handler_.GetContextualManagedDataForTesting(profile.get());
+ ExtractContextualSourceUpdate(data, extracted);
+
+ EXPECT_EQ(data.DictSize(), 5u);
+ EXPECT_EQ(extension_reporting_title,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED));
+ EXPECT_EQ(browser_management_notice,
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_BROWSER_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
+ EXPECT_EQ(subtitle, l10n_util::GetStringUTF16(IDS_MANAGEMENT_SUBTITLE));
+ EXPECT_EQ(management_overview,
+ l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION_UNKNOWN_DOMAIN));
+ EXPECT_EQ(management_overview_data_notice,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA));
+ EXPECT_EQ(management_overview_setup_notice,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP));
+ EXPECT_TRUE(managed);
+}
+
+TEST_F(ManagementUIHandlerTests,
+ ManagementContextualSourceUpdateManagedConsumerDomain) {
+ TestingProfile::Builder builder;
+ builder.SetProfileName("managed@gmail.com");
+ auto profile = builder.Build();
+
+ base::string16 extensions_installed;
+ base::string16 browser_management_notice;
+ base::string16 subtitle;
+ base::string16 management_overview;
+ base::string16 management_overview_data_notice;
+ base::string16 management_overview_setup_notice;
+ bool managed;
+ ContextualManagementSourceUpdate extracted{&extensions_installed,
+ &browser_management_notice,
+ &subtitle,
+ &management_overview,
+ &management_overview_data_notice,
+ &management_overview_setup_notice,
+ &managed};
+
+ handler_.SetManagedForTesting(true);
+ auto data = handler_.GetContextualManagedDataForTesting(profile.get());
+ ExtractContextualSourceUpdate(data, extracted);
+
+ EXPECT_EQ(data.DictSize(), 5u);
+ EXPECT_EQ(extensions_installed,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED));
+ EXPECT_EQ(browser_management_notice,
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_BROWSER_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
+ EXPECT_EQ(subtitle, l10n_util::GetStringUTF16(IDS_MANAGEMENT_SUBTITLE));
+ EXPECT_EQ(management_overview,
+ l10n_util::GetStringUTF16(
+ IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION_UNKNOWN_DOMAIN));
+ EXPECT_EQ(management_overview_data_notice,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA));
+ EXPECT_EQ(management_overview_setup_notice,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP));
+ EXPECT_TRUE(managed);
+}
+
+TEST_F(ManagementUIHandlerTests,
+ ManagementContextualSourceUpdateUnmanagedKnownDomain) {
+ TestingProfile::Builder builder;
+ builder.SetProfileName("managed@manager.com");
+ auto profile = builder.Build();
+
+ base::string16 extension_reporting_title;
+ base::string16 browser_management_notice;
+ base::string16 subtitle;
+ base::string16 management_overview;
+ base::string16 management_overview_data_notice;
+ base::string16 management_overview_setup_notice;
+ bool managed;
+ ContextualManagementSourceUpdate extracted{&extension_reporting_title,
+ &browser_management_notice,
+ &subtitle,
+ &management_overview,
+ &management_overview_data_notice,
+ &management_overview_setup_notice,
+ &managed};
+
+ handler_.SetManagedForTesting(false);
+
+ auto data = handler_.GetContextualManagedDataForTesting(profile.get());
+ ExtractContextualSourceUpdate(data, extracted);
+
+ EXPECT_EQ(data.DictSize(), 4u);
+ EXPECT_EQ(extension_reporting_title,
+ l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY,
+ base::UTF8ToUTF16("manager.com")));
+ EXPECT_EQ(browser_management_notice,
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_NOT_MANAGED_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
+ EXPECT_EQ(subtitle,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE));
+ EXPECT_EQ(management_overview, base::string16());
+ EXPECT_EQ(management_overview_data_notice, base::string16());
+ EXPECT_EQ(management_overview_setup_notice, base::string16());
+ EXPECT_FALSE(managed);
+}
+
+TEST_F(ManagementUIHandlerTests,
+ ManagementContextualSourceUpdateUnmanagedCustomerDomain) {
+ TestingProfile::Builder builder;
+ builder.SetProfileName("managed@googlemail.com");
+ auto profile = builder.Build();
+
+ base::string16 extension_reporting_title;
+ base::string16 browser_management_notice;
+ base::string16 subtitle;
+ base::string16 management_overview;
+ base::string16 management_overview_data_notice;
+ base::string16 management_overview_setup_notice;
+ bool managed;
+ ContextualManagementSourceUpdate extracted{&extension_reporting_title,
+ &browser_management_notice,
+ &subtitle,
+ &management_overview,
+ &management_overview_data_notice,
+ &management_overview_setup_notice,
+ &managed};
+
+ handler_.SetManagedForTesting(false);
+
+ auto data = handler_.GetContextualManagedDataForTesting(profile.get());
+ ExtractContextualSourceUpdate(data, extracted);
+
+ EXPECT_EQ(data.DictSize(), 4u);
+ EXPECT_EQ(extension_reporting_title,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED));
+ EXPECT_EQ(browser_management_notice,
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_NOT_MANAGED_NOTICE,
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
+ EXPECT_EQ(subtitle,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE));
+ EXPECT_EQ(management_overview, base::string16());
+ EXPECT_EQ(management_overview_data_notice, base::string16());
+ EXPECT_EQ(management_overview_setup_notice, base::string16());
+ EXPECT_FALSE(managed);
+}
+
+TEST_F(ManagementUIHandlerTests,
+ ManagementContextualSourceUpdateManagedKnownDomain) {
+ TestingProfile::Builder builder;
+ builder.SetProfileName("managed@manager.com");
+ auto profile = builder.Build();
+
+ base::string16 extension_reporting_title;
+ base::string16 browser_management_notice;
+ base::string16 subtitle;
+ base::string16 management_overview;
+ base::string16 management_overview_data_notice;
+ base::string16 management_overview_setup_notice;
+ bool managed;
+ ContextualManagementSourceUpdate extracted{&extension_reporting_title,
+ &browser_management_notice,
+ &subtitle,
+ &management_overview,
+ &management_overview_data_notice,
+ &management_overview_setup_notice,
+ &managed};
+
+ handler_.SetManagedForTesting(true);
+ auto data = handler_.GetContextualManagedDataForTesting(profile.get());
+ ExtractContextualSourceUpdate(data, extracted);
+
+ EXPECT_EQ(data.DictSize(), 5u);
+ EXPECT_EQ(extension_reporting_title,
+ l10n_util::GetStringFUTF16(IDS_MANAGEMENT_EXTENSIONS_INSTALLED_BY,
+ base::UTF8ToUTF16("manager.com")));
+ EXPECT_EQ(
+ browser_management_notice,
+ l10n_util::GetStringFUTF16(
+ IDS_MANAGEMENT_MANAGEMENT_BY_NOTICE, base::UTF8ToUTF16("manager.com"),
+ base::UTF8ToUTF16(chrome::kManagedUiLearnMoreUrl)));
+ EXPECT_EQ(subtitle,
+ l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY,
+ base::UTF8ToUTF16("manager.com")));
+ EXPECT_EQ(
+ management_overview,
+ l10n_util::GetStringFUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_CLARIFICATION,
+ base::UTF8ToUTF16("manager.com")));
+ EXPECT_EQ(management_overview_data_notice,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_DATA));
+ EXPECT_EQ(management_overview_setup_notice,
+ l10n_util::GetStringUTF16(IDS_MANAGEMENT_ACCOUNT_MANAGED_SETUP));
+ EXPECT_TRUE(managed);
+}
+
+#endif // !defined(OS_CHROMEOS)
+
+#if defined(OS_CHROMEOS)
+TEST_F(ManagementUIHandlerTests,
+ ManagementContextualSourceUpdateManagedAccountKnownDomain) {
+ TestingProfile::Builder builder;
+ builder.SetProfileName("managed@manager.com");
+ auto profile = builder.Build();
+ const auto device_type = ui::GetChromeOSDeviceTypeResourceId();
+
+ base::string16 extensions_installed;
+ base::string16 browser_management_notice;
+ base::string16 subtitle;
+ base::string16 management_overview;
+ base::string16 management_overview_data_notice;
+ base::string16 management_overview_setup_notice;
+ bool managed;
+ ContextualManagementSourceUpdate extracted{&extensions_installed,
+ &browser_management_notice,
+ &subtitle,
+ &management_overview,
+ &management_overview_data_notice,
+ &management_overview_setup_notice,
+ &managed};
+
+ handler_.SetManagedForTesting(true);
+ auto data = handler_.GetContextualManagedDataForTesting(profile.get());
+ ExtractContextualSourceUpdate(data, extracted);
+
+ EXPECT_EQ(subtitle,
+ l10n_util::GetStringFUTF16(IDS_MANAGEMENT_SUBTITLE_MANAGED_BY,
+ l10n_util::GetStringUTF16(device_type),
+ base::UTF8ToUTF16("manager.com")));
+ EXPECT_TRUE(managed);
+}
+
+TEST_F(ManagementUIHandlerTests, ManagementContextualSourceUpdateUnmanaged) {
+ auto profile = TestingProfile::Builder().Build();
+ const auto device_type = ui::GetChromeOSDeviceTypeResourceId();
+
+ base::string16 extension_reporting_title;
+ base::string16 browser_management_notice;
+ base::string16 subtitle;
+ base::string16 management_overview;
+ base::string16 management_overview_data_notice;
+ base::string16 management_overview_setup_notice;
+ bool managed;
+ ContextualManagementSourceUpdate extracted{&extension_reporting_title,
+ &browser_management_notice,
+ &subtitle,
+ &management_overview,
+ &management_overview_data_notice,
+ &management_overview_setup_notice,
+ &managed};
+
+ handler_.SetManagedForTesting(false);
+ auto data = handler_.GetContextualManagedDataForTesting(profile.get());
+ ExtractContextualSourceUpdate(data, extracted);
+ EXPECT_EQ(subtitle,
+ l10n_util::GetStringFUTF16(IDS_MANAGEMENT_NOT_MANAGED_SUBTITLE,
+ l10n_util::GetStringUTF16(device_type)));
+ EXPECT_FALSE(managed);
+}
+#endif
+
TEST_F(ManagementUIHandlerTests, ExtensionReportingInfoNoPolicySetNoMessage) {
handler_.EnableCloudReportingExtension(false);
auto reporting_info = handler_.GetExtensionReportingInfo();
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 cf1891051ff..1684c692e11 100644
--- a/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
@@ -184,7 +184,7 @@ WebRtcLogsDOMHandler::WebRtcLogsDOMHandler(Profile* profile)
WebRtcLogsDOMHandler::~WebRtcLogsDOMHandler() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- text_log_upload_list_->CancelCallback();
+ text_log_upload_list_->CancelLoadCallback();
}
void WebRtcLogsDOMHandler::RegisterMessages() {
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 a9af36aab49..75c75604250 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
@@ -62,6 +62,6 @@ TestingProfile::TestingFactories MediaRouterWebUITest::GetTestingFactories() {
return factories;
}
-BrowserWindow* MediaRouterWebUITest::CreateBrowserWindow() {
- return new DialogTestBrowserWindow;
+std::unique_ptr<BrowserWindow> MediaRouterWebUITest::CreateBrowserWindow() {
+ return std::make_unique<DialogTestBrowserWindow>();
}
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.h b/chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.h
index 364e518e836..b52ae525fc6 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.h
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_web_ui_test.h
@@ -17,7 +17,7 @@ class MediaRouterWebUITest : public BrowserWithTestWindowTest {
protected:
// BrowserWithTestWindowTest:
TestingProfile::TestingFactories GetTestingFactories() override;
- BrowserWindow* CreateBrowserWindow() override;
+ std::unique_ptr<BrowserWindow> CreateBrowserWindow() override;
private:
// When this is set to true, MockMediaRouterUIService is instantiated.
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc
index 029f6403340..b6b9fe2eda5 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc
@@ -1119,8 +1119,12 @@ void MediaRouterWebUIMessageHandler::MaybeUpdateFirstRunFlowData() {
AccountInfo MediaRouterWebUIMessageHandler::GetAccountInfo() {
identity::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()));
- return identity_manager ? identity_manager->GetPrimaryAccountInfo()
- : AccountInfo();
+ if (!identity_manager)
+ return AccountInfo();
+ base::Optional<AccountInfo> primary_account_info =
+ identity_manager->FindExtendedAccountInfoForAccount(
+ identity_manager->GetPrimaryAccountInfo());
+ return primary_account_info.value_or(AccountInfo{});
}
int MediaRouterWebUIMessageHandler::CurrentCastModeForRouteId(
diff --git a/chromium/chrome/browser/ui/webui/nacl_ui.cc b/chromium/chrome/browser/ui/webui/nacl_ui.cc
index 78babd67252..6fc7196596c 100644
--- a/chromium/chrome/browser/ui/webui/nacl_ui.cc
+++ b/chromium/chrome/browser/ui/webui/nacl_ui.cc
@@ -197,7 +197,7 @@ void NaClDomHandler::AddOperatingSystemInfo(base::ListValue* list) {
os_label += " SP" + base::NumberToString(os->service_pack().major);
if (os->service_pack().minor > 0)
os_label += "." + base::NumberToString(os->service_pack().minor);
- if (os->architecture() == base::win::OSInfo::X64_ARCHITECTURE)
+ if (os->GetArchitecture() == base::win::OSInfo::X64_ARCHITECTURE)
os_label += " 64 bit";
#endif
AddPair(list, l10n_util::GetStringUTF16(IDS_VERSION_UI_OS),
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 a70b0ac0095..9a0fe68249c 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
@@ -12,6 +12,7 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/memory/weak_ptr.h"
#include "base/task/post_task.h"
#include "base/values.h"
diff --git a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
index 0ebb19b3121..d52d5c7d397 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc
@@ -22,6 +22,7 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/extensions/bookmark_app_extension_util.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_ui_util.h"
@@ -254,6 +255,10 @@ void AppLauncherHandler::RegisterMessages() {
base::BindRepeating(&AppLauncherHandler::HandleCreateAppShortcut,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "installAppLocally",
+ base::BindRepeating(&AppLauncherHandler::HandleInstallAppLocally,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"showAppInfo", base::BindRepeating(&AppLauncherHandler::HandleShowAppInfo,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
@@ -618,6 +623,29 @@ void AppLauncherHandler::HandleCreateAppShortcut(const base::ListValue* args) {
base::Callback<void(bool)>());
}
+void AppLauncherHandler::HandleInstallAppLocally(const base::ListValue* args) {
+ std::string extension_id;
+ CHECK(args->GetString(0, &extension_id));
+
+ const Extension* extension =
+ extension_service_->GetExtensionById(extension_id, true);
+ if (!extension)
+ return;
+
+ auto* profile = Profile::FromBrowserContext(
+ web_ui()->GetWebContents()->GetBrowserContext());
+ SetBookmarkAppIsLocallyInstalled(profile, extension, true);
+ if (extensions::CanBookmarkAppCreateOsShortcuts()) {
+ extensions::BookmarkAppCreateOsShortcuts(
+ profile, extension, true /* add_to_desktop */, base::DoNothing());
+ }
+
+ // Use the appAdded to update the app icon's color to no longer be greyscale.
+ std::unique_ptr<base::DictionaryValue> app_info(GetAppInfo(extension));
+ if (app_info)
+ web_ui()->CallJavascriptFunctionUnsafe("ntp.appAdded", *app_info);
+}
+
void AppLauncherHandler::HandleShowAppInfo(const base::ListValue* args) {
std::string extension_id;
CHECK(args->GetString(0, &extension_id));
diff --git a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
index 5e9bf46b6e0..c2a7659aeb9 100644
--- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
+++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.h
@@ -112,6 +112,10 @@ class AppLauncherHandler
// [extension_id].
void HandleCreateAppShortcut(const base::ListValue* args);
+ // Handles the "installAppLocally" message with |args| containing
+ // [extension_id].
+ void HandleInstallAppLocally(const base::ListValue* args);
+
// Handles the "showAppInfo" message with |args| containing [extension_id].
void HandleShowAppInfo(const base::ListValue* args);
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 5026d255ad9..f565648b2d4 100644
--- a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.cc
@@ -8,11 +8,13 @@
#include <string>
#include "base/bind.h"
+#include "base/feature_list.h"
#include "base/i18n/rtl.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
#include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
#include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
@@ -29,6 +31,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/native_theme/native_theme.h"
#include "url/gurl.h"
namespace {
@@ -50,7 +53,11 @@ const char* GetHtmlTextDirection(const base::string16& text) {
///////////////////////////////////////////////////////////////////////////////
// NewTabUI
-NewTabUI::NewTabUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
+NewTabUI::NewTabUI(content::WebUI* web_ui)
+ : content::WebUIController(web_ui),
+ dark_mode_observer_(ui::NativeTheme::GetInstanceForNativeUi(),
+ base::BindRepeating(&NewTabUI::OnDarkModeChanged,
+ base::Unretained(this))) {
web_ui->OverrideTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
Profile* profile = GetProfile();
@@ -69,6 +76,8 @@ NewTabUI::NewTabUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
pref_change_registrar_.Add(
prefs::kWebKitDefaultFontSize,
base::Bind(&NewTabUI::OnDefaultFontSizeChanged, base::Unretained(this)));
+
+ dark_mode_observer_.Start();
}
NewTabUI::~NewTabUI() {}
@@ -82,6 +91,16 @@ void NewTabUI::OnShowBookmarkBarChanged() {
attached);
}
+void NewTabUI::OnDarkModeChanged(bool /*dark_mode*/) {
+ if (!web_ui() || !web_ui()->CanCallJavascript())
+ return;
+
+ bool enabled = base::FeatureList::IsEnabled(features::kWebUIDarkMode);
+ web_ui()->CallJavascriptFunctionUnsafe(
+ "document.documentElement.toggleAttribute", base::Value("dark"),
+ base::Value(enabled && dark_mode_observer_.InDarkMode()));
+}
+
void NewTabUI::OnDefaultFontSizeChanged() {
web_ui()->CallJavascriptFunctionUnsafe("ntp.defaultFontSizeChanged");
}
diff --git a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h
index e3bf3c65dd7..f5e776de279 100644
--- a/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h
+++ b/chromium/chrome/browser/ui/webui/ntp/new_tab_ui.h
@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "base/strings/string16.h"
+#include "chrome/browser/ui/dark_mode_observer.h"
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui_controller.h"
@@ -73,11 +74,14 @@ class NewTabUI : public content::WebUIController {
DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource);
};
- void OnShowBookmarkBarChanged();
+ void OnDarkModeChanged(bool dark_mode);
void OnDefaultFontSizeChanged();
+ void OnShowBookmarkBarChanged();
Profile* GetProfile() const;
+ DarkModeObserver dark_mode_observer_;
+
PrefChangeRegistrar pref_change_registrar_;
DISALLOW_COPY_AND_ASSIGN(NewTabUI);
diff --git a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 605023bcbf7..285c5318198 100644
--- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -16,7 +16,6 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/themes/theme_properties.h"
@@ -24,6 +23,7 @@
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/apps/app_info_dialog.h"
#include "chrome/browser/ui/layout_constants.h"
+#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/app_launcher_login_handler.h"
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
#include "chrome/common/buildflags.h"
@@ -51,6 +51,7 @@
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/color_utils.h"
+#include "ui/native_theme/native_theme.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -134,7 +135,9 @@ std::string GetNewTabBackgroundTilingCSS(
} // namespace
NTPResourceCache::NTPResourceCache(Profile* profile)
- : profile_(profile), is_swipe_tracking_from_scroll_events_enabled_(false) {
+ : profile_(profile),
+ is_swipe_tracking_from_scroll_events_enabled_(false),
+ theme_observer_(this) {
registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
content::Source<ThemeService>(
ThemeServiceFactory::GetForProfile(profile)));
@@ -150,6 +153,8 @@ NTPResourceCache::NTPResourceCache(Profile* profile)
profile_pref_change_registrar_.Add(prefs::kSignInPromoShowNTPBubble,
callback);
profile_pref_change_registrar_.Add(prefs::kHideWebStoreIcon, callback);
+
+ theme_observer_.Add(ui::NativeTheme::GetInstanceForNativeUi());
}
NTPResourceCache::~NTPResourceCache() {}
@@ -230,6 +235,11 @@ void NTPResourceCache::Observe(int type,
Invalidate();
}
+void NTPResourceCache::OnNativeThemeUpdated(ui::NativeTheme* updated_theme) {
+ DCHECK_EQ(updated_theme, ui::NativeTheme::GetInstanceForNativeUi());
+ Invalidate();
+}
+
void NTPResourceCache::OnPreferenceChanged() {
// A change occurred to one of the preferences we care about, so flush the
// cache.
@@ -244,6 +254,7 @@ void NTPResourceCache::Invalidate() {
new_tab_html_ = nullptr;
new_tab_incognito_css_ = nullptr;
new_tab_css_ = nullptr;
+ new_tab_guest_html_ = nullptr;
}
void NTPResourceCache::CreateNewTabIncognitoHTML() {
@@ -338,6 +349,8 @@ void NTPResourceCache::CreateNewTabGuestHTML() {
l10n_util::GetStringUTF16(guest_tab_link_ids));
localized_strings.SetString("learnMoreLink", guest_tab_link);
+ SetDarkKey(&localized_strings);
+
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &localized_strings);
@@ -391,6 +404,8 @@ void NTPResourceCache::CreateNewTabHTML() {
GetLocalizedString(IDS_APP_CONTEXT_MENU_SHOW_INFO));
load_time_data.SetString("appcreateshortcut",
GetLocalizedString(IDS_NEW_TAB_APP_CREATE_SHORTCUT));
+ load_time_data.SetString("appinstalllocally",
+ GetLocalizedString(IDS_NEW_TAB_APP_INSTALL_LOCALLY));
load_time_data.SetString("appDefaultPageName",
GetLocalizedString(IDS_APP_DEFAULT_PAGE_NAME));
load_time_data.SetString(
@@ -439,12 +454,6 @@ void NTPResourceCache::CreateNewTabHTML() {
load_time_data.SetBoolean("showWebStoreIcon",
!prefs->GetBoolean(prefs::kHideWebStoreIcon));
- load_time_data.SetBoolean("enableNewBookmarkApps",
- extensions::util::IsNewBookmarkAppsEnabled());
-
- load_time_data.SetBoolean("canHostedAppsOpenInWindows",
- extensions::util::CanHostedAppsOpenInWindows());
-
load_time_data.SetBoolean("canShowAppInfoDialog",
CanShowAppInfoDialog());
@@ -461,6 +470,8 @@ void NTPResourceCache::CreateNewTabHTML() {
"isUserSignedIn",
IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount());
+ SetDarkKey(&load_time_data);
+
// Load the new tab page appropriate for this build.
base::StringPiece new_tab_html(
ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
@@ -537,6 +548,8 @@ void NTPResourceCache::CreateNewTabCSS() {
// Colors.
substitutions["colorBackground"] =
color_utils::SkColorToRgbaString(color_background);
+ substitutions["colorLink"] = color_utils::SkColorToRgbString(
+ GetThemeColor(tp, ThemeProperties::COLOR_NTP_LINK));
substitutions["backgroundBarDetached"] = GetNewTabBackgroundCSS(tp, false);
substitutions["backgroundBarAttached"] = GetNewTabBackgroundCSS(tp, true);
substitutions["backgroundTiling"] = GetNewTabBackgroundTilingCSS(tp);
@@ -574,3 +587,11 @@ void NTPResourceCache::CreateNewTabCSS() {
ui::ReplaceTemplateExpressions(new_tab_theme_css, substitutions);
new_tab_css_ = base::RefCountedString::TakeString(&css_string);
}
+
+void NTPResourceCache::SetDarkKey(base::Value* dict) {
+ DCHECK(dict && dict->is_dict());
+ bool use_dark =
+ base::FeatureList::IsEnabled(features::kWebUIDarkMode) &&
+ ui::NativeTheme::GetInstanceForNativeUi()->SystemDarkModeEnabled();
+ dict->SetKey("dark", base::Value(use_dark ? "dark" : ""));
+}
diff --git a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
index 827b2eeacd3..354de3c3e10 100644
--- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
+++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.h
@@ -8,27 +8,35 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/scoped_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "ui/native_theme/native_theme_observer.h"
class Profile;
namespace base {
class RefCountedMemory;
+class Value;
}
namespace content {
class RenderProcessHost;
}
+namespace ui {
+class NativeTheme;
+}
+
// This class keeps a cache of NTP resources (HTML and CSS) so we don't have to
// regenerate them all the time.
// Note: This is only used for incognito and guest mode NTPs (NewTabUI), as well
// as for (non-incognito) app launcher pages (AppLauncherPageUI).
class NTPResourceCache : public content::NotificationObserver,
- public KeyedService {
+ public KeyedService,
+ public ui::NativeThemeObserver {
public:
enum WindowType {
NORMAL,
@@ -42,7 +50,7 @@ class NTPResourceCache : public content::NotificationObserver,
base::RefCountedMemory* GetNewTabHTML(WindowType win_type);
base::RefCountedMemory* GetNewTabCSS(WindowType win_type);
- // content::NotificationObserver interface.
+ // content::NotificationObserver:
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
@@ -51,6 +59,9 @@ class NTPResourceCache : public content::NotificationObserver,
Profile* profile, content::RenderProcessHost* render_host);
private:
+ // ui::NativeThemeObserver:
+ void OnNativeThemeUpdated(ui::NativeTheme* updated_theme) override;
+
void OnPreferenceChanged();
// Invalidates the NTPResourceCache.
@@ -70,6 +81,8 @@ class NTPResourceCache : public content::NotificationObserver,
void CreateNewTabGuestHTML();
+ void SetDarkKey(base::Value* dict);
+
Profile* profile_;
scoped_refptr<base::RefCountedMemory> new_tab_html_;
@@ -84,6 +97,8 @@ class NTPResourceCache : public content::NotificationObserver,
// Set based on platform_util::IsSwipeTrackingFromScrollEventsEnabled.
bool is_swipe_tracking_from_scroll_events_enabled_;
+ ScopedObserver<ui::NativeTheme, NTPResourceCache> theme_observer_;
+
DISALLOW_COPY_AND_ASSIGN(NTPResourceCache);
};
diff --git a/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc b/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc
index 7ccfd40ed52..82ed17f9101 100644
--- a/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/ntp_tiles_internals_ui.cc
@@ -12,7 +12,6 @@
#include "chrome/browser/history/top_sites_factory.h"
#include "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search/suggestions/image_decoder_impl.h"
#include "chrome/browser/search/suggestions/suggestions_service_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/common/url_constants.h"
diff --git a/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc b/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc
index e96e1e9a7cd..ce641d7f909 100644
--- a/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc
@@ -34,6 +34,7 @@
#include "components/offline_pages/core/prefetch/prefetch_background_task_handler.h"
#include "components/offline_pages/core/prefetch/prefetch_dispatcher.h"
#include "components/offline_pages/core/prefetch/prefetch_downloader.h"
+#include "components/offline_pages/core/prefetch/prefetch_gcm_handler.h"
#include "components/offline_pages/core/prefetch/prefetch_prefs.h"
#include "components/offline_pages/core/prefetch/prefetch_service.h"
#include "components/offline_pages/core/prefetch/prefetch_types.h"
@@ -258,19 +259,27 @@ void OfflineInternalsUIMessageHandler::HandleGetNetworkStatus(
void OfflineInternalsUIMessageHandler::HandleScheduleNwake(
const base::ListValue* args) {
AllowJavascript();
- const base::Value* callback_id;
- CHECK(args->Get(0, &callback_id));
+ CHECK(!args->GetList().empty());
+ base::Value callback_id = args->GetList()[0].Clone();
if (prefetch_service_) {
- prefetch_service_->GetPrefetchBackgroundTaskHandler()
- ->EnsureTaskScheduled();
- ResolveJavascriptCallback(*callback_id, base::Value("Scheduled."));
+ prefetch_service_->GetGCMToken(base::BindOnce(
+ &OfflineInternalsUIMessageHandler::ScheduleNwakeWithGCMToken,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback_id)));
} else {
- RejectJavascriptCallback(*callback_id,
+ RejectJavascriptCallback(callback_id,
base::Value("No prefetch service available."));
}
}
+void OfflineInternalsUIMessageHandler::ScheduleNwakeWithGCMToken(
+ base::Value callback_id,
+ const std::string& gcm_token) {
+ prefetch_service_->GetPrefetchBackgroundTaskHandler()->EnsureTaskScheduled(
+ gcm_token);
+ ResolveJavascriptCallback(callback_id, base::Value("Scheduled."));
+}
+
void OfflineInternalsUIMessageHandler::HandleCancelNwake(
const base::ListValue* args) {
AllowJavascript();
@@ -445,6 +454,8 @@ void OfflineInternalsUIMessageHandler::HandleSetPrefetchTestingHeader(
offline_pages::prefetch_prefs::SetPrefetchTestingHeader(
prefs, args->GetList()[0].GetString());
+
+ offline_pages::prefetch_prefs::SetEnabledByServer(prefs, true);
}
void OfflineInternalsUIMessageHandler::HandleGetPrefetchTestingHeader(
diff --git a/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h b/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h
index 09a718680fa..61e06e47c1d 100644
--- a/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h
@@ -85,6 +85,8 @@ class OfflineInternalsUIMessageHandler : public content::WebUIMessageHandler {
// Schedules an NWake signal.
void HandleScheduleNwake(const base::ListValue* args);
+ void ScheduleNwakeWithGCMToken(base::Value callback_id,
+ const std::string& gcm_token);
// Cancels an NWake signal.
void HandleCancelNwake(const base::ListValue* args);
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom b/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
index 7e6f9f93ddb..f24279a4c32 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
@@ -43,6 +43,7 @@ struct AutocompleteMatch {
int32 duplicates;
bool from_previous;
array<AutocompleteAdditionalInfo> additional_info;
+ string document_type;
};
struct AutocompleteResultsForProvider {
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
index f9715b337e6..132a25c209d 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
@@ -198,6 +198,8 @@ struct TypeConverter<mojom::AutocompleteMatchPtr, AutocompleteMatch> {
result->additional_info =
mojo::ConvertTo<std::vector<mojom::AutocompleteAdditionalInfoPtr>>(
input.additional_info);
+ result->document_type =
+ AutocompleteMatch::DocumentTypeString(input.document_type);
return result;
}
};
diff --git a/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc b/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc
index 946af1c19f1..1cf3620d094 100644
--- a/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc
+++ b/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc
@@ -6,6 +6,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/dark_mode_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
@@ -27,7 +28,7 @@ content::WebUIDataSource* CreateHTMLSource(Profile* profile,
else if (host_name == chrome::kChromeUIHistoryHost)
page_title = l10n_util::GetStringUTF16(IDS_HISTORY_TITLE);
else if (host_name == chrome::kChromeUIExtensionsHost)
- page_title = l10n_util::GetStringUTF16(IDS_MD_EXTENSIONS_TOOLBAR_TITLE);
+ page_title = l10n_util::GetStringUTF16(IDS_EXTENSIONS_TOOLBAR_TITLE);
else
page_title = base::UTF8ToUTF16(host_name);
@@ -48,5 +49,7 @@ PageNotAvailableForGuestUI::PageNotAvailableForGuestUI(
const std::string& host_name)
: WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
- content::WebUIDataSource::Add(profile, CreateHTMLSource(profile, host_name));
+ auto* source = CreateHTMLSource(profile, host_name);
+ DarkModeHandler::Initialize(web_ui, source);
+ content::WebUIDataSource::Add(profile, source);
}
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 e7e5f6e90f6..cc28e91c1c8 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
@@ -32,7 +32,9 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source) {
IDS_CONTROLLED_SETTING_EXTENSION_WITHOUT_NAME},
#if defined(OS_CHROMEOS)
{"controlledSettingShared", IDS_CONTROLLED_SETTING_SHARED},
- {"controlledSettingOwner", IDS_CONTROLLED_SETTING_OWNER},
+ {"controlledSettingWithOwner", IDS_CONTROLLED_SETTING_WITH_OWNER},
+ {"controlledSettingNoOwner", IDS_CONTROLLED_SETTING_NO_OWNER},
+ {"controlledSettingParent", IDS_CONTROLLED_SETTING_PARENT},
#endif
};
AddLocalizedStringsBulk(html_source, localized_strings,
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc
index 44939494b0e..93cec93e971 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/policy/schema_registry_service.h"
-#include "chrome/browser/policy/schema_registry_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -59,8 +58,7 @@ class PolicySchemaAvailableWaiter : public policy::SchemaRegistry::Observer {
public:
PolicySchemaAvailableWaiter(Profile* profile,
const policy::PolicyNamespace& policy_namespace)
- : registry_(policy::SchemaRegistryServiceFactory::GetForContext(profile)
- ->registry()),
+ : registry_(profile->GetPolicySchemaRegistryService()->registry()),
policy_namespace_(policy_namespace) {}
~PolicySchemaAvailableWaiter() override { registry_->RemoveObserver(this); }
@@ -327,7 +325,7 @@ void PolicyUITest::VerifyExportingPolicies(
browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_TRUE(content::ExecuteScript(contents, javascript));
- base::TaskScheduler::GetInstance()->FlushForTesting();
+ base::ThreadPool::GetInstance()->FlushForTesting();
// Open the created file.
base::ScopedAllowBlockingForTesting allow_blocking;
std::string file_contents;
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
index abe7222cdfe..aa706efd9ee 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
@@ -31,7 +31,6 @@
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/policy/schema_registry_service.h"
-#include "chrome/browser/policy/schema_registry_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/browser/cloud/message_util.h"
@@ -72,7 +71,6 @@
#include "chrome/browser/chromeos/policy/user_policy_manager_factory_chromeos.h"
#include "components/user_manager/user_manager.h"
#else
-#include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#endif
@@ -603,9 +601,10 @@ PolicyUIHandler::PolicyUIHandler()
PolicyUIHandler::~PolicyUIHandler() {
GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_CHROME, this);
GetPolicyService()->RemoveObserver(policy::POLICY_DOMAIN_EXTENSIONS, this);
- policy::SchemaRegistry* registry =
- policy::SchemaRegistryServiceFactory::GetForContext(
- Profile::FromWebUI(web_ui())->GetOriginalProfile())->registry();
+ policy::SchemaRegistry* registry = Profile::FromWebUI(web_ui())
+ ->GetOriginalProfile()
+ ->GetPolicySchemaRegistryService()
+ ->registry();
registry->RemoveObserver(this);
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -651,6 +650,7 @@ void PolicyUIHandler::AddCommonLocalizedStringsToSource(
}
void PolicyUIHandler::RegisterMessages() {
+ Profile* profile = Profile::FromWebUI(web_ui());
#if defined(OS_CHROMEOS)
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -668,7 +668,6 @@ void PolicyUIHandler::RegisterMessages() {
const user_manager::UserManager* user_manager =
user_manager::UserManager::Get();
- Profile* profile = Profile::FromWebUI(web_ui());
policy::DeviceLocalAccountPolicyService* local_account_service =
user_manager->IsLoggedInAsPublicAccount()
? connector->GetDeviceLocalAccountPolicyService()
@@ -694,8 +693,7 @@ void PolicyUIHandler::RegisterMessages() {
}
#else
policy::UserCloudPolicyManager* user_cloud_policy_manager =
- policy::UserCloudPolicyManagerFactory::GetForBrowserContext(
- web_ui()->GetWebContents()->GetBrowserContext());
+ profile->GetUserCloudPolicyManager();
if (user_cloud_policy_manager) {
user_status_provider_ = std::make_unique<UserCloudPolicyStatusProvider>(
user_cloud_policy_manager->core());
@@ -733,9 +731,10 @@ void PolicyUIHandler::RegisterMessages() {
extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))
->AddObserver(this);
#endif
- policy::SchemaRegistry* registry =
- policy::SchemaRegistryServiceFactory::GetForContext(
- Profile::FromWebUI(web_ui())->GetOriginalProfile())->registry();
+ policy::SchemaRegistry* registry = Profile::FromWebUI(web_ui())
+ ->GetOriginalProfile()
+ ->GetPolicySchemaRegistryService()
+ ->registry();
registry->AddObserver(this);
web_ui()->RegisterMessageCallback(
@@ -783,9 +782,9 @@ void PolicyUIHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns,
base::Value PolicyUIHandler::GetPolicyNames() const {
base::DictionaryValue names;
Profile* profile = Profile::FromWebUI(web_ui());
- policy::SchemaRegistry* registry =
- policy::SchemaRegistryServiceFactory::GetForContext(
- profile->GetOriginalProfile())->registry();
+ policy::SchemaRegistry* registry = profile->GetOriginalProfile()
+ ->GetPolicySchemaRegistryService()
+ ->registry();
scoped_refptr<policy::SchemaMap> schema_map = registry->schema_map();
// Add Chrome policy names.
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 bbc9c6faee9..ccc6c46d291 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
@@ -20,15 +20,12 @@
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
#include "components/cloud_devices/common/cloud_device_description.h"
#include "components/cloud_devices/common/printer_description.h"
-#include "device/base/device_client.h"
-#include "device/usb/mojo/type_converters.h"
#include "device/usb/public/mojom/device.mojom.h"
-#include "device/usb/usb_device.h"
-#include "device/usb/usb_service.h"
#include "extensions/browser/api/device_permissions_manager.h"
#include "extensions/browser/api/printer_provider/printer_provider_api.h"
#include "extensions/browser/api/printer_provider/printer_provider_api_factory.h"
#include "extensions/browser/api/printer_provider/printer_provider_print_job.h"
+#include "extensions/browser/api/usb/usb_device_manager.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/api/printer_provider/usb_printer_manifest_data.h"
#include "extensions/common/permissions/permissions_data.h"
@@ -38,12 +35,12 @@
#include "printing/print_job_constants.h"
#include "printing/pwg_raster_settings.h"
-using device::UsbDevice;
using extensions::DevicePermissionsManager;
using extensions::DictionaryBuilder;
using extensions::Extension;
using extensions::ExtensionRegistry;
using extensions::ListBuilder;
+using extensions::UsbDeviceManager;
using extensions::UsbPrinterManifestData;
namespace printing {
@@ -78,10 +75,11 @@ bool HasUsbPrinterProviderPermissions(const Extension* extension) {
extensions::APIPermission::kUsb);
}
-std::string GenerateProvisionalUsbPrinterId(const Extension* extension,
- const UsbDevice* device) {
+std::string GenerateProvisionalUsbPrinterId(
+ const Extension* extension,
+ const device::mojom::UsbDeviceInfo& device) {
return base::StringPrintf("%s:%s:%s", kProvisionalUsbLabel,
- extension->id().c_str(), device->guid().c_str());
+ extension->id().c_str(), device.guid.c_str());
}
bool ParseProvisionalUsbPrinterId(const std::string& printer_id,
@@ -140,9 +138,10 @@ void ExtensionPrinterHandler::StartGetPrinters(
}
if (extension_supports_usb_printers) {
- device::UsbService* service = device::DeviceClient::Get()->GetUsbService();
pending_enumeration_count_++;
- service->GetDevices(
+ UsbDeviceManager* usb_manager = UsbDeviceManager::Get(profile_);
+ DCHECK(usb_manager);
+ usb_manager->GetDevices(
base::Bind(&ExtensionPrinterHandler::OnUsbDevicesEnumerated,
weak_ptr_factory_.GetWeakPtr(), callback));
}
@@ -215,8 +214,11 @@ void ExtensionPrinterHandler::StartGrantPrinterAccess(
return;
}
- device::UsbService* service = device::DeviceClient::Get()->GetUsbService();
- scoped_refptr<UsbDevice> device = service->GetDevice(device_guid);
+ UsbDeviceManager* usb_manager = UsbDeviceManager::Get(profile_);
+ DCHECK(usb_manager);
+
+ const device::mojom::UsbDeviceInfo* device =
+ usb_manager->GetDeviceInfo(device_guid);
if (!device) {
std::move(callback).Run(base::DictionaryValue());
return;
@@ -224,12 +226,10 @@ void ExtensionPrinterHandler::StartGrantPrinterAccess(
DevicePermissionsManager* permissions_manager =
DevicePermissionsManager::Get(profile_);
- auto device_info = device::mojom::UsbDeviceInfo::From(*device);
- DCHECK(device_info);
- permissions_manager->AllowUsbDevice(extension_id, *device_info);
+ permissions_manager->AllowUsbDevice(extension_id, *device);
GetPrinterProviderAPI(profile_)->DispatchGetUsbPrinterInfoRequested(
- extension_id, *device_info,
+ extension_id, *device,
base::BindOnce(&ExtensionPrinterHandler::WrapGetPrinterInfoCallback,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
@@ -318,7 +318,7 @@ void ExtensionPrinterHandler::WrapGetPrinterInfoCallback(
void ExtensionPrinterHandler::OnUsbDevicesEnumerated(
const AddedPrintersCallback& callback,
- const std::vector<scoped_refptr<UsbDevice>>& devices) {
+ std::vector<device::mojom::UsbDeviceInfoPtr> devices) {
ExtensionRegistry* registry = ExtensionRegistry::Get(profile_);
DevicePermissionsManager* permissions_manager =
DevicePermissionsManager::Get(profile_);
@@ -337,8 +337,8 @@ void ExtensionPrinterHandler::OnUsbDevicesEnumerated(
if (manifest_data->SupportsDevice(*device)) {
std::unique_ptr<extensions::UsbDevicePermission::CheckParam> param =
extensions::UsbDevicePermission::CheckParam::ForUsbDevice(
- extension.get(), device.get());
- if (device_permissions->FindUsbDeviceEntry(device) ||
+ extension.get(), *device);
+ if (device_permissions->FindUsbDeviceEntry(*device) ||
extension->permissions_data()->CheckAPIPermissionWithParam(
extensions::APIPermission::kUsbDevice, param.get())) {
// Skip devices the extension already has permission to access.
@@ -347,13 +347,14 @@ void ExtensionPrinterHandler::OnUsbDevicesEnumerated(
printer_list.Append(
DictionaryBuilder()
- .Set("id", GenerateProvisionalUsbPrinterId(extension.get(),
- device.get()))
+ .Set("id",
+ GenerateProvisionalUsbPrinterId(extension.get(), *device))
.Set("name",
DevicePermissionsManager::GetPermissionMessage(
- device->vendor_id(), device->product_id(),
- device->manufacturer_string(),
- device->product_string(), base::string16(), false))
+ device->vendor_id, device->product_id,
+ device->manufacturer_name.value_or(base::string16()),
+ device->product_name.value_or(base::string16()),
+ base::string16(), false))
.Set("extensionId", extension->id())
.Set("extensionName", extension->name())
.Set("provisional", true)
diff --git a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h
index 6cceb78a076..2dacc08b396 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h
@@ -25,10 +25,6 @@ namespace cloud_devices {
class CloudDeviceDescription;
}
-namespace device {
-class UsbDevice;
-}
-
namespace gfx {
class Size;
}
@@ -98,7 +94,7 @@ class ExtensionPrinterHandler : public PrinterHandler {
void OnUsbDevicesEnumerated(
const AddedPrintersCallback& callback,
- const std::vector<scoped_refptr<device::UsbDevice>>& devices);
+ std::vector<device::mojom::UsbDeviceInfoPtr> devices);
Profile* const profile_;
GetPrintersDoneCallback done_callback_;
diff --git a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
index af526b30c5f..ae0c9005f7c 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc
@@ -28,15 +28,13 @@
#include "chrome/test/base/testing_profile.h"
#include "components/version_info/version_info.h"
#include "content/public/test/test_utils.h"
-#include "device/base/mock_device_client.h"
-#include "device/usb/mock_usb_device.h"
-#include "device/usb/mock_usb_service.h"
-#include "device/usb/mojo/type_converters.h"
+#include "device/usb/public/cpp/fake_usb_device_manager.h"
#include "device/usb/public/mojom/device.mojom.h"
#include "extensions/browser/api/device_permissions_manager.h"
#include "extensions/browser/api/printer_provider/printer_provider_api.h"
#include "extensions/browser/api/printer_provider/printer_provider_api_factory.h"
#include "extensions/browser/api/printer_provider/printer_provider_print_job.h"
+#include "extensions/browser/api/usb/usb_device_manager.h"
#include "extensions/common/extension.h"
#include "extensions/common/value_builder.h"
#include "printing/pdf_render_settings.h"
@@ -46,8 +44,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/size.h"
-using device::MockUsbDevice;
-using device::MockUsbService;
+using device::mojom::UsbDeviceInfoPtr;
using extensions::DictionaryBuilder;
using extensions::Extension;
using extensions::PrinterProviderAPI;
@@ -508,6 +505,13 @@ class ExtensionPrinterHandlerTest : public testing::Test {
pwg_raster_converter_ = pwg_raster_converter.get();
extension_printer_handler_->SetPwgRasterConverterForTesting(
std::move(pwg_raster_converter));
+
+ // Set fake USB device manager for extensions::UsbDeviceManager.
+ device::mojom::UsbDeviceManagerPtr usb_manager_ptr;
+ fake_usb_manager_.AddBinding(mojo::MakeRequest(&usb_manager_ptr));
+ extensions::UsbDeviceManager::Get(env_.profile())
+ ->SetDeviceManagerForTesting(std::move(usb_manager_ptr));
+ base::RunLoop().RunUntilIdle();
}
protected:
@@ -517,11 +521,7 @@ class ExtensionPrinterHandlerTest : public testing::Test {
->GetForBrowserContext(env_.profile()));
}
- device::MockUsbService& usb_service() {
- return *device_client_.usb_service();
- }
-
- device::MockDeviceClient device_client_;
+ device::FakeUsbDeviceManager fake_usb_manager_;
TestExtensionEnvironment env_;
std::unique_ptr<ExtensionPrinterHandler> extension_printer_handler_;
@@ -587,12 +587,11 @@ TEST_F(ExtensionPrinterHandlerTest, GetPrinters_Reset) {
}
TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) {
- scoped_refptr<device::UsbDevice> device0 =
- base::MakeRefCounted<MockUsbDevice>(0, 0, "Google", "USB Printer", "");
- usb_service().AddDevice(device0);
- scoped_refptr<device::UsbDevice> device1 =
- base::MakeRefCounted<MockUsbDevice>(0, 1, "Google", "USB Printer", "");
- usb_service().AddDevice(device1);
+ UsbDeviceInfoPtr device0 =
+ fake_usb_manager_.CreateAndAddDevice(0, 0, "Google", "USB Printer", "");
+ UsbDeviceInfoPtr device1 =
+ fake_usb_manager_.CreateAndAddDevice(0, 1, "Google", "USB Printer", "");
+ base::RunLoop().RunUntilIdle();
const Extension* extension_1 =
env_.MakeExtension(*base::test::ParseJsonDeprecated(kExtension1),
@@ -603,9 +602,7 @@ TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) {
extensions::DevicePermissionsManager* permissions_manager =
extensions::DevicePermissionsManager::Get(env_.profile());
- auto device_info_0 = device::mojom::UsbDeviceInfo::From(*device0);
- DCHECK(device_info_0);
- permissions_manager->AllowUsbDevice(extension_2->id(), *device_info_0);
+ permissions_manager->AllowUsbDevice(extension_2->id(), *device0);
size_t call_count = 0;
std::unique_ptr<base::ListValue> printers;
@@ -628,7 +625,7 @@ TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) {
DictionaryBuilder()
.Set("id", base::StringPrintf("provisional-usb:%s:%s",
extension_1->id().c_str(),
- device0->guid().c_str()))
+ device0->guid.c_str()))
.Set("name", "USB Printer")
.Set("extensionName", "Provider 1")
.Set("extensionId", extension_1->id())
@@ -638,7 +635,7 @@ TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) {
DictionaryBuilder()
.Set("id", base::StringPrintf("provisional-usb:%s:%s",
extension_2->id().c_str(),
- device1->guid().c_str()))
+ device1->guid.c_str()))
.Set("name", "USB Printer")
.Set("extensionName", "Provider 2")
.Set("extensionId", extension_2->id())
@@ -980,15 +977,15 @@ TEST_F(ExtensionPrinterHandlerTest, Print_Pwg_FailedConversion) {
}
TEST_F(ExtensionPrinterHandlerTest, GrantUsbPrinterAccess) {
- auto device =
- base::MakeRefCounted<MockUsbDevice>(0, 0, "Google", "USB Printer", "");
- usb_service().AddDevice(device);
+ UsbDeviceInfoPtr device =
+ fake_usb_manager_.CreateAndAddDevice(0, 0, "Google", "USB Printer", "");
+ base::RunLoop().RunUntilIdle();
size_t call_count = 0;
std::unique_ptr<base::DictionaryValue> printer_info;
std::string printer_id = base::StringPrintf(
- "provisional-usb:fake extension id:%s", device->guid().c_str());
+ "provisional-usb:fake extension id:%s", device->guid.c_str());
extension_printer_handler_->StartGrantPrinterAccess(
printer_id, base::Bind(&RecordPrinterInfo, &call_count, &printer_info));
@@ -1012,16 +1009,16 @@ TEST_F(ExtensionPrinterHandlerTest, GrantUsbPrinterAccess) {
}
TEST_F(ExtensionPrinterHandlerTest, GrantUsbPrinterAccess_Reset) {
- auto device =
- base::MakeRefCounted<MockUsbDevice>(0, 0, "Google", "USB Printer", "");
- usb_service().AddDevice(device);
+ UsbDeviceInfoPtr device =
+ fake_usb_manager_.CreateAndAddDevice(0, 0, "Google", "USB Printer", "");
+ base::RunLoop().RunUntilIdle();
size_t call_count = 0;
std::unique_ptr<base::DictionaryValue> printer_info;
extension_printer_handler_->StartGrantPrinterAccess(
base::StringPrintf("provisional-usb:fake extension id:%s",
- device->guid().c_str()),
+ device->guid.c_str()),
base::Bind(&RecordPrinterInfo, &call_count, &printer_info));
EXPECT_FALSE(printer_info.get());
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 c14ef978f64..0d407d495e7 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,6 +11,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/post_task.h"
#include "base/values.h"
@@ -41,6 +42,9 @@ namespace {
using chromeos::CupsPrintersManager;
using chromeos::CupsPrintersManagerFactory;
+// We only support sending username for named users but just in case.
+const char kUsernamePlaceholder[] = "chronos";
+
// Store the name used in CUPS, Printer#id in |printer_name|, the description
// as the system_driverinfo option value, and the Printer#display_name in
// the |printer_description| field. This will match how Mac OS X presents
@@ -73,18 +77,21 @@ void CapabilitiesFetched(base::Value policies,
std::move(cb).Run(std::move(printer_info));
}
-void FetchCapabilities(std::unique_ptr<chromeos::Printer> printer,
+void FetchCapabilities(const chromeos::Printer& printer,
base::Value policies,
LocalPrinterHandlerChromeos::GetCapabilityCallback cb) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- PrinterBasicInfo basic_info = ToBasicInfo(*printer);
+ PrinterBasicInfo basic_info = ToBasicInfo(printer);
+ bool has_secure_protocol = !printer.HasNetworkProtocol() ||
+ printer.GetProtocol() == chromeos::Printer::kIpps;
// USER_VISIBLE because the result is displayed in the print preview dialog.
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
- base::BindOnce(&GetSettingsOnBlockingPool, printer->id(), basic_info,
- PrinterSemanticCapsAndDefaults::Papers(), nullptr),
+ base::BindOnce(&GetSettingsOnBlockingPool, printer.id(), basic_info,
+ PrinterSemanticCapsAndDefaults::Papers(),
+ has_secure_protocol, nullptr),
base::BindOnce(&CapabilitiesFetched, std::move(policies), std::move(cb)));
}
@@ -92,17 +99,46 @@ void FetchCapabilities(std::unique_ptr<chromeos::Printer> printer,
LocalPrinterHandlerChromeos::LocalPrinterHandlerChromeos(
Profile* profile,
- content::WebContents* preview_web_contents)
+ content::WebContents* preview_web_contents,
+ chromeos::CupsPrintersManager* printers_manager,
+ std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer)
: profile_(profile),
preview_web_contents_(preview_web_contents),
- printers_manager_(
- CupsPrintersManagerFactory::GetForBrowserContext(profile)),
- printer_configurer_(chromeos::PrinterConfigurer::Create(profile)),
+ printers_manager_(printers_manager),
+ printer_configurer_(std::move(printer_configurer)),
weak_factory_(this) {
// Construct the CupsPrintJobManager to listen for printing events.
chromeos::CupsPrintJobManagerFactory::GetForBrowserContext(profile);
}
+// static
+std::unique_ptr<LocalPrinterHandlerChromeos>
+LocalPrinterHandlerChromeos::CreateDefault(
+ Profile* profile,
+ content::WebContents* preview_web_contents) {
+ chromeos::CupsPrintersManager* printers_manager(
+ CupsPrintersManagerFactory::GetForBrowserContext(profile));
+ std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer(
+ chromeos::PrinterConfigurer::Create(profile));
+ // Using 'new' to access non-public constructor.
+ return base::WrapUnique(new LocalPrinterHandlerChromeos(
+ profile, preview_web_contents, printers_manager,
+ std::move(printer_configurer)));
+}
+
+// static
+std::unique_ptr<LocalPrinterHandlerChromeos>
+LocalPrinterHandlerChromeos::CreateForTesting(
+ Profile* profile,
+ content::WebContents* preview_web_contents,
+ chromeos::CupsPrintersManager* printers_manager,
+ std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer) {
+ // Using 'new' to access non-public constructor.
+ return base::WrapUnique(new LocalPrinterHandlerChromeos(
+ profile, preview_web_contents, printers_manager,
+ std::move(printer_configurer)));
+}
+
LocalPrinterHandlerChromeos::~LocalPrinterHandlerChromeos() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
}
@@ -127,9 +163,8 @@ void LocalPrinterHandlerChromeos::StartGetPrinters(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
PrinterList printer_list;
- AddPrintersToList(
- printers_manager_->GetPrinters(CupsPrintersManager::kConfigured),
- &printer_list);
+ AddPrintersToList(printers_manager_->GetPrinters(CupsPrintersManager::kSaved),
+ &printer_list);
AddPrintersToList(
printers_manager_->GetPrinters(CupsPrintersManager::kEnterprise),
&printer_list);
@@ -146,7 +181,7 @@ void LocalPrinterHandlerChromeos::StartGetCapability(
GetCapabilityCallback cb) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- std::unique_ptr<chromeos::Printer> printer =
+ base::Optional<chromeos::Printer> printer =
printers_manager_->GetPrinter(printer_name);
if (!printer) {
// If the printer was removed, the lookup will fail.
@@ -161,46 +196,37 @@ void LocalPrinterHandlerChromeos::StartGetCapability(
chromeos::Printer::kProtocolMax);
if (printers_manager_->IsPrinterInstalled(*printer)) {
- // Skip setup if the printer is already installed.
- HandlePrinterSetup(std::move(printer), std::move(cb), chromeos::kSuccess);
+ // Skip setup if the printer does not need to be installed.
+ HandlePrinterSetup(*printer, std::move(cb),
+ /*record_usb_setup_source=*/false, chromeos::kSuccess);
return;
}
- const chromeos::Printer& printer_ref = *printer;
printer_configurer_->SetUpPrinter(
- printer_ref,
- base::BindOnce(&LocalPrinterHandlerChromeos::HandlePrinterSetup,
- weak_factory_.GetWeakPtr(), std::move(printer),
- std::move(cb)));
+ *printer, base::BindOnce(&LocalPrinterHandlerChromeos::HandlePrinterSetup,
+ weak_factory_.GetWeakPtr(), *printer,
+ std::move(cb), printer->IsUsbProtocol()));
}
void LocalPrinterHandlerChromeos::HandlePrinterSetup(
- std::unique_ptr<chromeos::Printer> printer,
+ const chromeos::Printer& printer,
GetCapabilityCallback cb,
+ bool record_usb_setup_source,
chromeos::PrinterSetupResult result) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
switch (result) {
case chromeos::PrinterSetupResult::kSuccess: {
- VLOG(1) << "Printer setup successful for " << printer->id()
+ VLOG(1) << "Printer setup successful for " << printer.id()
<< " fetching properties";
- printers_manager_->PrinterInstalled(*printer, true /*is_automatic*/);
-
- // populate |policies| with policies for native printers.
- base::Value policies(base::Value::Type::DICTIONARY);
- const PrefService* prefs = profile_->GetPrefs();
- policies.SetKey(
- kAllowedColorModes,
- base::Value(prefs->GetInteger(prefs::kPrintingAllowedColorModes)));
- policies.SetKey(
- kAllowedDuplexModes,
- base::Value(prefs->GetInteger(prefs::kPrintingAllowedDuplexModes)));
- policies.SetKey(kDefaultColorMode,
- base::Value(prefs->Get(prefs::kPrintingColorDefault)));
- policies.SetKey(kDefaultDuplexMode,
- base::Value(prefs->Get(prefs::kPrintingDuplexDefault)));
+ if (record_usb_setup_source) {
+ // Record UMA for USB printer setup source.
+ chromeos::PrinterConfigurer::RecordUsbPrinterSetupSource(
+ chromeos::UsbPrinterSetupSource::kPrintPreview);
+ }
+ printers_manager_->PrinterInstalled(printer, true /*is_automatic*/);
// fetch settings on the blocking pool and invoke callback.
- FetchCapabilities(std::move(printer), std::move(policies), std::move(cb));
+ FetchCapabilities(printer, GetNativePrinterPolicies(), std::move(cb));
return;
}
case chromeos::PrinterSetupResult::kPpdNotFound:
@@ -223,6 +249,7 @@ void LocalPrinterHandlerChromeos::HandlePrinterSetup(
case chromeos::PrinterSetupResult::kInvalidPrinterUpdate:
case chromeos::PrinterSetupResult::kDbusNoReply:
case chromeos::PrinterSetupResult::kDbusTimeout:
+ case chromeos::PrinterSetupResult::kEditSuccess:
LOG(ERROR) << "Unexpected error in printer setup. " << result;
break;
case chromeos::PrinterSetupResult::kMaxValue:
@@ -243,14 +270,39 @@ void LocalPrinterHandlerChromeos::StartPrint(
UMA_HISTOGRAM_MEMORY_KB("Printing.CUPS.PrintDocumentSize", size_in_kb);
if (profile_->GetPrefs()->GetBoolean(
prefs::kPrintingSendUsernameAndFilenameEnabled)) {
- settings.SetKey(kSettingUsername,
- base::Value(chromeos::ProfileHelper::Get()
- ->GetUserByProfile(profile_)
- ->display_email()));
+ std::string username = chromeos::ProfileHelper::Get()
+ ->GetUserByProfile(profile_)
+ ->display_email();
+ settings.SetKey(
+ kSettingUsername,
+ base::Value(username.empty() ? kUsernamePlaceholder : username));
+ settings.SetKey(kSettingJobTitle, base::Value(job_title));
settings.SetKey(kSettingSendUserInfo, base::Value(true));
}
StartLocalPrint(std::move(settings), std::move(print_data),
preview_web_contents_, std::move(callback));
}
+base::Value LocalPrinterHandlerChromeos::GetNativePrinterPolicies() const {
+ base::Value policies(base::Value::Type::DICTIONARY);
+ const PrefService* prefs = profile_->GetPrefs();
+ policies.SetKey(
+ kAllowedColorModes,
+ base::Value(prefs->GetInteger(prefs::kPrintingAllowedColorModes)));
+ policies.SetKey(
+ kAllowedDuplexModes,
+ base::Value(prefs->GetInteger(prefs::kPrintingAllowedDuplexModes)));
+ policies.SetKey(
+ kAllowedPinModes,
+ base::Value(prefs->GetInteger(prefs::kPrintingAllowedPinModes)));
+ policies.SetKey(kDefaultColorMode,
+ base::Value(prefs->GetInteger(prefs::kPrintingColorDefault)));
+ policies.SetKey(
+ kDefaultDuplexMode,
+ base::Value(prefs->GetInteger(prefs::kPrintingDuplexDefault)));
+ policies.SetKey(kDefaultPinMode,
+ base::Value(prefs->GetInteger(prefs::kPrintingPinDefault)));
+ return policies;
+}
+
} // namespace printing
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 de085a0db32..edca6f79919 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
@@ -27,8 +27,16 @@ namespace printing {
class LocalPrinterHandlerChromeos : public PrinterHandler {
public:
- LocalPrinterHandlerChromeos(Profile* profile,
- content::WebContents* preview_web_contents);
+ static std::unique_ptr<LocalPrinterHandlerChromeos> CreateDefault(
+ Profile* profile,
+ content::WebContents* preview_web_contents);
+
+ static std::unique_ptr<LocalPrinterHandlerChromeos> CreateForTesting(
+ Profile* profile,
+ content::WebContents* preview_web_contents,
+ chromeos::CupsPrintersManager* printers_manager,
+ std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer);
+
~LocalPrinterHandlerChromeos() override;
// PrinterHandler implementation
@@ -44,8 +52,22 @@ class LocalPrinterHandlerChromeos : public PrinterHandler {
PrintCallback callback) override;
private:
- void HandlePrinterSetup(std::unique_ptr<chromeos::Printer> printer,
+ FRIEND_TEST_ALL_PREFIXES(LocalPrinterHandlerChromeosTest,
+ GetNativePrinterPolicies);
+
+ explicit LocalPrinterHandlerChromeos(
+ Profile* profile,
+ content::WebContents* preview_web_contents,
+ chromeos::CupsPrintersManager* printers_manager,
+ std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer);
+
+ // Creates a value dictionary containing the printing policies set by
+ // |profile_|.
+ base::Value GetNativePrinterPolicies() const;
+
+ void HandlePrinterSetup(const chromeos::Printer& printer,
GetCapabilityCallback cb,
+ bool record_usb_setup_source,
chromeos::PrinterSetupResult result);
Profile* const profile_;
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc
new file mode 100644
index 00000000000..a079503537a
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos_unittest.cc
@@ -0,0 +1,323 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc"
+
+#include <algorithm>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "base/bind.h"
+#include "base/containers/flat_set.h"
+#include "base/json/json_string_value_serializer.h"
+#include "base/memory/ref_counted.h"
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.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 "printing/backend/print_backend.h"
+#include "printing/backend/test_print_backend.h"
+#include "printing/print_job_constants.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace printing {
+
+namespace {
+
+using chromeos::CupsPrintersManager;
+using chromeos::Printer;
+using chromeos::PrinterConfigurer;
+using chromeos::PrinterSetupCallback;
+using chromeos::PrinterSetupResult;
+
+// Used as a callback to StartGetPrinters in tests.
+// Increases |*call_count| and records values returned by StartGetPrinters.
+void RecordPrinterList(size_t* call_count,
+ std::unique_ptr<base::ListValue>* printers_out,
+ const base::ListValue& printers) {
+ ++(*call_count);
+ printers_out->reset(printers.DeepCopy());
+}
+
+// Used as a callback to StartGetPrinters in tests.
+// Records that the test is done.
+void RecordPrintersDone(bool* is_done_out) {
+ *is_done_out = true;
+}
+
+void RecordGetCapability(std::unique_ptr<base::Value>* capabilities_out,
+ base::Value capability) {
+ capabilities_out->reset(capability.DeepCopy());
+}
+
+Printer CreateTestPrinter(const std::string& id, const std::string& name) {
+ Printer printer;
+ printer.set_id(id);
+ printer.set_display_name(name);
+ return printer;
+}
+
+Printer CreateEnterprisePrinter(const std::string& id,
+ const std::string& name) {
+ Printer printer = CreateTestPrinter(id, name);
+ printer.set_source(Printer::SRC_POLICY);
+ return printer;
+}
+
+class FakeCupsPrintersManager : public CupsPrintersManager {
+ public:
+ FakeCupsPrintersManager() : printers_(kNumPrinterClasses) {}
+
+ std::vector<Printer> GetPrinters(PrinterClass printer_class) const override {
+ return printers_[printer_class];
+ }
+
+ void RemoveUnavailablePrinters(std::vector<Printer>*) const override {}
+ void UpdateSavedPrinter(const Printer& printer) override {}
+ void RemoveSavedPrinter(const std::string& printer_id) override {}
+ void AddObserver(CupsPrintersManager::Observer* observer) override {}
+ void RemoveObserver(CupsPrintersManager::Observer* observer) override {}
+ void PrinterInstalled(const Printer& printer, bool is_automatic) override {}
+ void RecordSetupAbandoned(const Printer& printer) override {}
+
+ bool IsPrinterInstalled(const Printer& printer) const override {
+ return installed_.contains(printer.id());
+ }
+
+ base::Optional<Printer> GetPrinter(const std::string& id) const override {
+ // Search through each class of printers and find a printer with a
+ // matching id.
+ for (const std::vector<Printer>& v : printers_) {
+ auto iter = std::find_if(
+ v.begin(), v.end(), [&id](const Printer& p) { return p.id() == id; });
+ if (iter != v.end()) {
+ return *iter;
+ }
+ }
+ return base::nullopt;
+ }
+
+ // Add |printer| to the corresponding list in |printers_| bases on the given
+ // |printer_class|.
+ void AddPrinter(const Printer& printer, PrinterClass printer_class) {
+ ASSERT_LT(printer_class, printers_.size());
+ printers_[printer_class].push_back(printer);
+ }
+
+ void InstallPrinter(const std::string& id) { installed_.insert(id); }
+
+ private:
+ std::vector<std::vector<Printer>> printers_;
+ base::flat_set<std::string> installed_;
+};
+
+class FakePrinterConfigurer : public PrinterConfigurer {
+ public:
+ void SetUpPrinter(const Printer& printer,
+ PrinterSetupCallback callback) override {
+ std::move(callback).Run(PrinterSetupResult::kSuccess);
+ }
+};
+
+// Converts JSON string to base::ListValue object.
+// On failure, returns NULL and fills |*error| string.
+std::unique_ptr<base::ListValue> GetJSONAsListValue(const std::string& json,
+ std::string* error) {
+ auto ret = base::ListValue::From(
+ JSONStringValueDeserializer(json).Deserialize(nullptr, error));
+ if (!ret)
+ *error = "Value is not a list.";
+ return ret;
+}
+
+} // namespace
+
+class LocalPrinterHandlerChromeosTest : public testing::Test {
+ public:
+ LocalPrinterHandlerChromeosTest() = default;
+ ~LocalPrinterHandlerChromeosTest() override = default;
+
+ void SetUp() override {
+ test_backend_ = base::MakeRefCounted<TestPrintBackend>();
+ PrintBackend::SetPrintBackendForTesting(test_backend_.get());
+ local_printer_handler_ = LocalPrinterHandlerChromeos::CreateForTesting(
+ &profile_, nullptr, &printers_manager_,
+ std::make_unique<FakePrinterConfigurer>());
+ }
+
+ protected:
+ // Must outlive |profile_|.
+ content::TestBrowserThreadBundle thread_bundle_;
+ // Must outlive |printers_manager_|.
+ TestingProfile profile_;
+ scoped_refptr<TestPrintBackend> test_backend_;
+ FakeCupsPrintersManager printers_manager_;
+ std::unique_ptr<LocalPrinterHandlerChromeos> local_printer_handler_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(LocalPrinterHandlerChromeosTest);
+};
+
+TEST_F(LocalPrinterHandlerChromeosTest, GetPrinters) {
+ size_t call_count = 0;
+ std::unique_ptr<base::ListValue> printers;
+ bool is_done = false;
+
+ Printer saved_printer = CreateTestPrinter("printer1", "saved");
+ Printer enterprise_printer =
+ CreateEnterprisePrinter("printer2", "enterprise");
+ Printer automatic_printer = CreateTestPrinter("printer3", "automatic");
+
+ printers_manager_.AddPrinter(saved_printer, CupsPrintersManager::kSaved);
+ printers_manager_.AddPrinter(enterprise_printer,
+ CupsPrintersManager::kEnterprise);
+ printers_manager_.AddPrinter(automatic_printer,
+ CupsPrintersManager::kAutomatic);
+
+ local_printer_handler_->StartGetPrinters(
+ base::BindRepeating(&RecordPrinterList, &call_count, &printers),
+ base::BindOnce(&RecordPrintersDone, &is_done));
+
+ EXPECT_EQ(call_count, 1u);
+ EXPECT_TRUE(is_done);
+ ASSERT_TRUE(printers);
+
+ const std::string expected_list = R"(
+ [
+ {
+ "cupsEnterprisePrinter": false,
+ "deviceName": "printer1",
+ "printerDescription": "",
+ "printerName": "saved",
+ "printerOptions": {
+ "cupsEnterprisePrinter": "false",
+ "system_driverinfo": ""
+ }
+ },
+ {
+ "cupsEnterprisePrinter": true,
+ "deviceName": "printer2",
+ "printerDescription": "",
+ "printerName": "enterprise",
+ "printerOptions": {
+ "cupsEnterprisePrinter": "true",
+ "system_driverinfo": ""
+ }
+ },
+ {
+ "cupsEnterprisePrinter": false,
+ "deviceName": "printer3",
+ "printerDescription": "",
+ "printerName": "automatic",
+ "printerOptions": {
+ "cupsEnterprisePrinter": "false",
+ "system_driverinfo": ""
+ }
+ }
+ ]
+ )";
+ std::string error;
+ std::unique_ptr<base::ListValue> expected_printers(
+ GetJSONAsListValue(expected_list, &error));
+ ASSERT_TRUE(expected_printers) << "Error deserializing printers: " << error;
+ EXPECT_EQ(*printers, *expected_printers);
+}
+
+// Tests that fetching capabilities for an existing installed printer is
+// successful.
+TEST_F(LocalPrinterHandlerChromeosTest, StartGetCapabilityValidPrinter) {
+ Printer saved_printer = CreateTestPrinter("printer1", "saved");
+ printers_manager_.AddPrinter(saved_printer, CupsPrintersManager::kSaved);
+ printers_manager_.InstallPrinter("printer1");
+
+ // Add printer capabilities to |test_backend_|.
+ PrinterSemanticCapsAndDefaults caps;
+ test_backend_->AddValidPrinter(
+ "printer1", std::make_unique<PrinterSemanticCapsAndDefaults>(caps));
+
+ std::unique_ptr<base::Value> fetched_caps;
+ local_printer_handler_->StartGetCapability(
+ "printer1", base::BindOnce(&RecordGetCapability, &fetched_caps));
+
+ thread_bundle_.RunUntilIdle();
+
+ ASSERT_TRUE(fetched_caps);
+ base::DictionaryValue* dict;
+ ASSERT_TRUE(fetched_caps->GetAsDictionary(&dict));
+ ASSERT_TRUE(dict->HasKey(kSettingCapabilities));
+ ASSERT_TRUE(dict->HasKey(kPrinter));
+}
+
+// Test that printers which have not yet been installed are installed with
+// SetUpPrinter before their capabilities are fetched.
+TEST_F(LocalPrinterHandlerChromeosTest, StartGetCapabilityPrinterNotInstalled) {
+ Printer discovered_printer = CreateTestPrinter("printer1", "discovered");
+ // NOTE: The printer |discovered_printer| is not installed using
+ // InstallPrinter.
+ printers_manager_.AddPrinter(discovered_printer,
+ CupsPrintersManager::kDiscovered);
+
+ // Add printer capabilities to |test_backend_|.
+ PrinterSemanticCapsAndDefaults caps;
+ test_backend_->AddValidPrinter(
+ "printer1", std::make_unique<PrinterSemanticCapsAndDefaults>(caps));
+
+ std::unique_ptr<base::Value> fetched_caps;
+ local_printer_handler_->StartGetCapability(
+ "printer1", base::BindOnce(&RecordGetCapability, &fetched_caps));
+
+ thread_bundle_.RunUntilIdle();
+
+ ASSERT_TRUE(fetched_caps);
+ base::DictionaryValue* dict;
+ ASSERT_TRUE(fetched_caps->GetAsDictionary(&dict));
+ ASSERT_TRUE(dict->HasKey(kSettingCapabilities));
+ ASSERT_TRUE(dict->HasKey(kPrinter));
+}
+
+// In this test we expect the StartGetCapability to bail early because the
+// provided printer can't be found in the CupsPrintersManager.
+TEST_F(LocalPrinterHandlerChromeosTest, StartGetCapabilityInvalidPrinter) {
+ std::unique_ptr<base::Value> fetched_caps;
+ local_printer_handler_->StartGetCapability(
+ "invalid printer", base::BindOnce(&RecordGetCapability, &fetched_caps));
+
+ thread_bundle_.RunUntilIdle();
+
+ ASSERT_TRUE(fetched_caps);
+ EXPECT_TRUE(fetched_caps->is_none());
+}
+
+TEST_F(LocalPrinterHandlerChromeosTest, GetNativePrinterPolicies) {
+ sync_preferences::TestingPrefServiceSyncable* prefs =
+ profile_.GetTestingPrefService();
+
+ prefs->SetUserPref(prefs::kPrintingAllowedColorModes,
+ std::make_unique<base::Value>(1));
+ prefs->SetUserPref(prefs::kPrintingAllowedDuplexModes,
+ std::make_unique<base::Value>(0));
+ prefs->SetUserPref(prefs::kPrintingAllowedPinModes,
+ std::make_unique<base::Value>(1));
+ prefs->SetUserPref(prefs::kPrintingColorDefault,
+ std::make_unique<base::Value>(2));
+ prefs->SetUserPref(prefs::kPrintingDuplexDefault,
+ std::make_unique<base::Value>(4));
+ prefs->SetUserPref(prefs::kPrintingPinDefault,
+ std::make_unique<base::Value>(0));
+
+ base::Value expected_policies(base::Value::Type::DICTIONARY);
+ expected_policies.SetKey(kAllowedColorModes, base::Value(1));
+ expected_policies.SetKey(kAllowedDuplexModes, base::Value(0));
+ expected_policies.SetKey(kAllowedPinModes, base::Value(1));
+ expected_policies.SetKey(kDefaultColorMode, base::Value(2));
+ expected_policies.SetKey(kDefaultDuplexMode, base::Value(4));
+ expected_policies.SetKey(kDefaultPinMode, base::Value(0));
+
+ EXPECT_EQ(expected_policies,
+ local_printer_handler_->GetNativePrinterPolicies());
+}
+
+} // namespace printing
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 8ddb28eb3b0..03bd08a9b71 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
@@ -28,6 +28,20 @@ namespace printing {
namespace {
+scoped_refptr<base::TaskRunner> CreatePrinterHandlerTaskRunner() {
+ // USER_VISIBLE because the result is displayed in the print preview dialog.
+ static constexpr base::TaskTraits kTraits = {
+ base::MayBlock(), base::TaskPriority::USER_VISIBLE};
+
+#if defined(OS_WIN)
+ // Windows drivers are likely not thread-safe.
+ return base::CreateSingleThreadTaskRunnerWithTraits(kTraits);
+#elif defined(USE_CUPS)
+ // CUPS is thread safe.
+ return base::CreateTaskRunnerWithTraits(kTraits);
+#endif
+}
+
PrinterList EnumeratePrintersAsync() {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
@@ -63,6 +77,7 @@ base::Value FetchCapabilitiesAsync(const std::string& device_name) {
return base::Value();
return GetSettingsOnBlockingPool(device_name, basic_info, additional_papers,
+ /* has_secure_protocol */ false,
print_backend);
}
@@ -81,7 +96,8 @@ std::string GetDefaultPrinterAsync() {
LocalPrinterHandlerDefault::LocalPrinterHandlerDefault(
content::WebContents* preview_web_contents)
- : preview_web_contents_(preview_web_contents) {}
+ : preview_web_contents_(preview_web_contents),
+ task_runner_(CreatePrinterHandlerTaskRunner()) {}
LocalPrinterHandlerDefault::~LocalPrinterHandlerDefault() {}
@@ -90,10 +106,9 @@ void LocalPrinterHandlerDefault::Reset() {}
void LocalPrinterHandlerDefault::GetDefaultPrinter(DefaultPrinterCallback cb) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- // USER_VISIBLE because the result is displayed in the print preview dialog.
- base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
- base::BindOnce(&GetDefaultPrinterAsync), std::move(cb));
+ base::PostTaskAndReplyWithResult(task_runner_.get(), FROM_HERE,
+ base::BindOnce(&GetDefaultPrinterAsync),
+ std::move(cb));
}
void LocalPrinterHandlerDefault::StartGetPrinters(
@@ -102,10 +117,8 @@ void LocalPrinterHandlerDefault::StartGetPrinters(
VLOG(1) << "Enumerate printers start";
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- // USER_VISIBLE because the result is displayed in the print preview dialog.
- base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
- base::BindOnce(&EnumeratePrintersAsync),
+ base::PostTaskAndReplyWithResult(
+ task_runner_.get(), FROM_HERE, base::BindOnce(&EnumeratePrintersAsync),
base::BindOnce(&ConvertPrinterListForCallback, callback,
std::move(done_callback)));
}
@@ -115,9 +128,8 @@ void LocalPrinterHandlerDefault::StartGetCapability(
GetCapabilityCallback cb) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- // USER_VISIBLE because the result is displayed in the print preview dialog.
- base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
+ base::PostTaskAndReplyWithResult(
+ task_runner_.get(), FROM_HERE,
base::BindOnce(&FetchCapabilitiesAsync, device_name), std::move(cb));
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.h b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.h
index 085c5ad2f53..25659249abb 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_default.h
@@ -10,10 +10,15 @@
#include "base/callback_forward.h"
#include "base/macros.h"
+#include "base/memory/scoped_refptr.h"
#include "base/strings/string16.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
+namespace base {
+class TaskRunner;
+}
+
namespace content {
class WebContents;
}
@@ -41,6 +46,9 @@ class LocalPrinterHandlerDefault : public PrinterHandler {
private:
content::WebContents* const preview_web_contents_;
+ // TaskRunner for blocking tasks. Threading behavior is platform-specific.
+ scoped_refptr<base::TaskRunner> const task_runner_;
+
DISALLOW_COPY_AND_ASSIGN(LocalPrinterHandlerDefault);
};
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 e3322a2b85c..ab1f3fe8db5 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
@@ -80,6 +80,7 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
#include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h"
+#include "chrome/browser/ui/settings_window_manager_chromeos.h"
#include "chromeos/printing/printer_configuration.h"
#include "services/identity/public/cpp/scope_set.h"
#endif
@@ -545,6 +546,12 @@ void PrintPreviewHandler::RegisterMessages() {
base::BindRepeating(
&PrintPreviewHandler::HandleGrantExtensionPrinterAccess,
base::Unretained(this)));
+#if defined(OS_CHROMEOS)
+ web_ui()->RegisterMessageCallback(
+ "openPrinterSettings",
+ base::BindRepeating(&PrintPreviewHandler::HandleOpenPrinterSettings,
+ base::Unretained(this)));
+#endif
}
void PrintPreviewHandler::OnJavascriptAllowed() {
@@ -906,6 +913,16 @@ void PrintPreviewHandler::HandleClosePreviewDialog(
regenerate_preview_request_count_);
}
+#if defined(OS_CHROMEOS)
+void PrintPreviewHandler::HandleOpenPrinterSettings(
+ const base::ListValue* args) {
+ auto* const settings_manager = chrome::SettingsWindowManager::GetInstance();
+ settings_manager->ShowChromePageForProfile(
+ Profile::FromWebUI(web_ui()),
+ chrome::GetSettingsUrl(chrome::kPrintingSettingsSubPage));
+}
+#endif
+
void PrintPreviewHandler::GetNumberFormatAndMeasurementSystem(
base::DictionaryValue* settings) {
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 d6efb6a5eb0..f48a7699b5a 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
@@ -240,6 +240,11 @@ class PrintPreviewHandler : public content::WebUIMessageHandler,
// preview is displayed.
void HandleGetInitialSettings(const base::ListValue* args);
+#if defined(OS_CHROMEOS)
+ // Opens printer settings in the Chrome OS Settings App.
+ void HandleOpenPrinterSettings(const base::ListValue* args);
+#endif
+
void SendInitialSettings(const std::string& callback_id,
const std::string& default_printer);
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 5248587fa68..3f7e7a601b3 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
@@ -30,6 +30,7 @@
#include "chrome/browser/printing/print_preview_data_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/webui/dark_mode_handler.h"
#include "chrome/browser/ui/webui/localized_string.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
@@ -79,7 +80,7 @@ const char kBasicPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29";
const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)";
#endif
-PrintPreviewUI::TestingDelegate* g_testing_delegate = nullptr;
+PrintPreviewUI::TestDelegate* g_test_delegate = nullptr;
// Thread-safe wrapper around a std::map to keep track of mappings from
// PrintPreviewUI IDs to most recent print preview request IDs.
@@ -130,28 +131,32 @@ base::LazyInstance<PrintPreviewRequestIdMapWithLock>::DestructorAtExit
base::LazyInstance<base::IDMap<PrintPreviewUI*>>::DestructorAtExit
g_print_preview_ui_id_map = LAZY_INSTANCE_INITIALIZER;
+bool ShouldHandleRequestCallback(const std::string& path) {
+ // ChromeWebUIDataSource handles most requests except for the print preview
+ // data.
+ return PrintPreviewUI::ParseDataPath(path, nullptr, nullptr);
+}
+
// Get markup or other resources for the print preview page.
-bool HandleRequestCallback(
+void HandleRequestCallback(
const std::string& path,
const content::WebUIDataSource::GotDataCallback& callback) {
// ChromeWebUIDataSource handles most requests except for the print preview
// data.
int preview_ui_id;
int page_index;
- if (!PrintPreviewUI::ParseDataPath(path, &preview_ui_id, &page_index))
- return false;
+ CHECK(PrintPreviewUI::ParseDataPath(path, &preview_ui_id, &page_index));
scoped_refptr<base::RefCountedMemory> data;
PrintPreviewDataService::GetInstance()->GetDataEntry(preview_ui_id,
page_index, &data);
if (data.get()) {
callback.Run(data.get());
- return true;
+ return;
}
// Invalid request.
auto empty_bytes = base::MakeRefCounted<base::RefCountedBytes>();
callback.Run(empty_bytes.get());
- return true;
}
void AddPrintPreviewStrings(content::WebUIDataSource* source) {
@@ -221,9 +226,11 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
{"optionFitToPage", IDS_PRINT_PREVIEW_OPTION_FIT_TO_PAGE},
{"optionHeaderFooter", IDS_PRINT_PREVIEW_OPTION_HEADER_FOOTER},
{"optionLandscape", IDS_PRINT_PREVIEW_OPTION_LANDSCAPE},
+ {"optionLongEdge", IDS_PRINT_PREVIEW_OPTION_LONG_EDGE},
{"optionPortrait", IDS_PRINT_PREVIEW_OPTION_PORTRAIT},
{"optionRasterize", IDS_PRINT_PREVIEW_OPTION_RASTERIZE},
{"optionSelectionOnly", IDS_PRINT_PREVIEW_OPTION_SELECTION_ONLY},
+ {"optionShortEdge", IDS_PRINT_PREVIEW_OPTION_SHORT_EDGE},
{"optionTwoSided", IDS_PRINT_PREVIEW_OPTION_TWO_SIDED},
{"optionsLabel", IDS_PRINT_PREVIEW_OPTIONS_LABEL},
{"pageRangeLimitInstructionWithValue",
@@ -233,11 +240,14 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
{"pagesLabel", IDS_PRINT_PREVIEW_PAGES_LABEL},
{"pagesPerSheetLabel", IDS_PRINT_PREVIEW_PAGES_PER_SHEET_LABEL},
{"previewFailed", IDS_PRINT_PREVIEW_FAILED},
+ {"printOnBothSidesLabel", IDS_PRINT_PREVIEW_PRINT_ON_BOTH_SIDES_LABEL},
{"printButton", IDS_PRINT_PREVIEW_PRINT_BUTTON},
{"printDestinationsTitle", IDS_PRINT_PREVIEW_PRINT_DESTINATIONS_TITLE},
{"printPagesLabel", IDS_PRINT_PREVIEW_PRINT_PAGES_LABEL},
{"printPreviewPageLabelPlural", IDS_PRINT_PREVIEW_PAGE_LABEL_PLURAL},
{"printPreviewPageLabelSingular", IDS_PRINT_PREVIEW_PAGE_LABEL_SINGULAR},
+ {"printPreviewNewSummaryFormatShort",
+ IDS_PRINT_PREVIEW_NEW_SUMMARY_FORMAT_SHORT},
{"printPreviewSheetsLabelPlural", IDS_PRINT_PREVIEW_SHEETS_LABEL_PLURAL},
{"printPreviewSheetsLabelSingular",
IDS_PRINT_PREVIEW_SHEETS_LABEL_SINGULAR},
@@ -271,6 +281,9 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
#if defined(OS_CHROMEOS)
{"configuringFailedText", IDS_PRINT_CONFIGURING_FAILED_TEXT},
{"configuringInProgressText", IDS_PRINT_CONFIGURING_IN_PROGRESS_TEXT},
+ {"optionPin", IDS_PRINT_PREVIEW_OPTION_PIN},
+ {"pinErrorMessage", IDS_PRINT_PREVIEW_PIN_ERROR_MESSAGE},
+ {"pinPlaceholder", IDS_PRINT_PREVIEW_PIN_PLACEHOLDER},
#endif
#if defined(OS_MACOSX)
{"openPdfInPreviewOption", IDS_PRINT_PREVIEW_OPEN_PDF_IN_PREVIEW_APP},
@@ -317,6 +330,15 @@ void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) {
base::FeatureList::IsEnabled(features::kCloudPrinterHandler);
source->AddBoolean("cloudPrinterHandlerEnabled",
cloud_printer_handler_enabled);
+ bool new_print_preview_layout_enabled =
+ base::FeatureList::IsEnabled(features::kNewPrintPreviewLayout);
+ source->AddBoolean("newPrintPreviewLayoutEnabled",
+ new_print_preview_layout_enabled);
+ // The key for the string below needs to be all lowercase, since it is used
+ // as an attribute and attributes are lowercased when the page is bundled.
+ source->AddString("newprintpreviewlayout", new_print_preview_layout_enabled
+ ? "new-print-preview-layout"
+ : "");
}
std::vector<std::string> SetupPrintPreviewPlugin(
@@ -406,7 +428,8 @@ std::vector<std::string> SetupPrintPreviewPlugin(
source->AddResourcePath(resource.path, resource.id);
}
- source->SetRequestFilter(base::BindRepeating(&HandleRequestCallback));
+ source->SetRequestFilter(base::BindRepeating(&ShouldHandleRequestCallback),
+ base::BindRepeating(&HandleRequestCallback));
source->OverrideContentSecurityPolicyChildSrc("child-src 'self';");
source->DisableDenyXFrameOptions();
source->OverrideContentSecurityPolicyObjectSrc("object-src 'self';");
@@ -471,6 +494,7 @@ PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui)
// Set up the chrome://print/ data source.
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource* source = CreatePrintPreviewUISource(profile);
+ DarkModeHandler::Initialize(web_ui, source);
content::WebUIDataSource::Add(profile, source);
// Set up the chrome://theme/ source.
@@ -641,8 +665,8 @@ void PrintPreviewUI::OnDidStartPreview(
page_size_ = params.page_size;
ClearAllPreviewData();
- if (g_testing_delegate)
- g_testing_delegate->DidGetPreviewPageCount(params.page_count);
+ if (g_test_delegate)
+ g_test_delegate->DidGetPreviewPageCount(params.page_count);
handler_->SendPageCountReady(params.page_count, params.fit_to_page_scaling,
request_id);
}
@@ -693,8 +717,8 @@ void PrintPreviewUI::OnDidPreviewPage(
SetPrintPreviewDataForIndex(page_number, std::move(data));
- if (g_testing_delegate)
- g_testing_delegate->DidRenderPreviewPage(web_ui()->GetWebContents());
+ if (g_test_delegate)
+ g_test_delegate->DidRenderPreviewPage(web_ui()->GetWebContents());
handler_->SendPagePreviewReady(page_number, *id_, preview_request_id);
}
@@ -770,8 +794,8 @@ void PrintPreviewUI::OnSetOptionsFromDocument(
}
// static
-void PrintPreviewUI::SetDelegateForTesting(TestingDelegate* delegate) {
- g_testing_delegate = delegate;
+void PrintPreviewUI::SetDelegateForTesting(TestDelegate* delegate) {
+ g_test_delegate = delegate;
}
void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) {
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 39b654aeb4a..2958b36ecef 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
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <memory>
+#include <string>
#include <vector>
#include "base/callback_forward.h"
@@ -185,13 +186,16 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
int request_id);
// Allows tests to wait until the print preview dialog is loaded.
- class TestingDelegate {
+ class TestDelegate {
public:
virtual void DidGetPreviewPageCount(int page_count) = 0;
virtual void DidRenderPreviewPage(content::WebContents* preview_dialog) = 0;
+
+ protected:
+ virtual ~TestDelegate() = default;
};
- static void SetDelegateForTesting(TestingDelegate* delegate);
+ static void SetDelegateForTesting(TestDelegate* delegate);
// Allows for tests to set a file path to print a PDF to. This also initiates
// the printing without having to click a button on the print preview dialog.
diff --git a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc
index d5fcabdf66a..84afb6f3be9 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.cc
@@ -38,8 +38,8 @@ std::unique_ptr<PrinterHandler> PrinterHandler::CreateForLocalPrinters(
content::WebContents* preview_web_contents,
Profile* profile) {
#if defined(OS_CHROMEOS)
- return std::make_unique<LocalPrinterHandlerChromeos>(profile,
- preview_web_contents);
+ return LocalPrinterHandlerChromeos::CreateDefault(profile,
+ preview_web_contents);
#else
return std::make_unique<LocalPrinterHandlerDefault>(preview_web_contents);
#endif
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 e2acd7b8d41..69e40cd06f9 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
@@ -111,8 +111,8 @@ ResetPasswordUI::ResetPasswordUI(content::WebUI* web_ui)
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->AddResourcePath("reset_password.mojom-lite.js",
+ IDR_RESET_PASSWORD_MOJOM_LITE_JS);
html_source->SetDefaultResource(IDR_RESET_PASSWORD_HTML);
html_source->AddLocalizedStrings(PopulateStrings());
html_source->UseGzip();
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
index 3bb9116bb70..2ae0eb80edd 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
@@ -64,7 +64,7 @@
#include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
#include "chrome/browser/ui/webui/help/version_updater_chromeos.h"
#include "chromeos/constants/chromeos_switches.h"
-#include "chromeos/dbus/power_manager_client.h"
+#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/dbus/util/version_loader.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_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 a3562e851d2..64e4f292e47 100644
--- a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "build/build_config.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#if defined(OS_CHROMEOS)
@@ -18,6 +19,10 @@
#include "components/user_manager/user_manager.h"
#endif // defined(OS_CHROMEOS)
+#if defined(OS_MACOSX)
+#include "chrome/browser/first_run/upgrade_util_mac.h"
+#endif
+
namespace settings {
namespace {
@@ -81,6 +86,11 @@ void BrowserLifetimeHandler::HandleRestart(
void BrowserLifetimeHandler::HandleRelaunch(
const base::ListValue* args) {
+#if defined(OS_MACOSX)
+ if (!upgrade_util::ShouldContinueToRelaunchForUpgrade())
+ return;
+#endif // OS_MACOSX
+
chrome::AttemptRelaunch();
}
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 caccda79fb5..adf3b5397e3 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
@@ -12,12 +12,12 @@
#include "base/macros.h"
#include "base/values.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h"
-#include "chromeos/account_manager/account_manager.h"
-#include "chromeos/account_manager/account_manager_factory.h"
+#include "chromeos/components/account_manager/account_manager_factory.h"
#include "components/user_manager/user.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -31,6 +31,19 @@ namespace settings {
namespace {
+constexpr char kFamilyLink[] = "Family Link";
+
+std::string GetEnterpriseDomainFromUsername(const std::string& username) {
+ size_t email_separator_pos = username.find('@');
+ bool is_email = email_separator_pos != std::string::npos &&
+ email_separator_pos < username.length() - 1;
+
+ if (!is_email)
+ return std::string();
+
+ return gaia::ExtractDomainName(username);
+}
+
AccountManager::AccountKey GetAccountKeyFromJsCallback(
const base::DictionaryValue* const dictionary) {
const base::Value* id_value = dictionary->FindKey("id");
@@ -150,7 +163,7 @@ void AccountManagerUIHandler::OnGetAccounts(
!identity_manager_->HasAccountWithRefreshTokenInPersistentErrorState(
maybe_account_info->account_id));
account.SetString("fullName", maybe_account_info->full_name);
- account.SetString("email", maybe_account_info->email);
+ account.SetString("email", stored_account.raw_email);
if (!maybe_account_info->account_image.IsEmpty()) {
account.SetString("pic",
webui::GetBitmapDataUrl(
@@ -174,6 +187,19 @@ void AccountManagerUIHandler::OnGetAccounts(
// Device account must show up at the top.
if (!device_account.empty()) {
device_account.SetBoolean("isDeviceAccount", true);
+
+ // Check if user is managed.
+ const Profile* const profile = Profile::FromWebUI(web_ui());
+ if (profile->IsChild()) {
+ device_account.SetString("organization", kFamilyLink);
+ } else if (policy::ProfilePolicyConnectorFactory::IsProfileManaged(
+ profile)) {
+ device_account.SetString(
+ "organization",
+ GetEnterpriseDomainFromUsername(
+ identity_manager_->GetPrimaryAccountInfo().email));
+ }
+
accounts.GetList().insert(accounts.GetList().begin(),
std::move(device_account));
}
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 029da8d3344..05462762595 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
@@ -12,7 +12,7 @@
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "chromeos/account_manager/account_manager.h"
+#include "chromeos/components/account_manager/account_manager.h"
#include "services/identity/public/cpp/identity_manager.h"
namespace chromeos {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
index a9e5e26cfa4..2038031a39e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
@@ -41,8 +41,8 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/url_constants.h"
-#include "media/audio/sounds/sounds_manager.h"
#include "net/base/data_url.h"
+#include "services/audio/public/cpp/sounds/sounds_manager.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
@@ -88,7 +88,7 @@ ChangePictureHandler::ChangePictureHandler()
user_manager_observer_(this),
camera_observer_(this) {
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
- media::SoundsManager* manager = media::SoundsManager::Get();
+ audio::SoundsManager* manager = audio::SoundsManager::Get();
manager->Initialize(SOUND_OBJECT_DELETE,
bundle.GetRawDataResource(IDR_SOUND_OBJECT_DELETE_WAV));
manager->Initialize(SOUND_CAMERA_SNAP,
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
index d8f69e3f354..7559e034ef9 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/ui/webui/settings/chromeos/crostini_handler.h"
#include <string>
+#include <utility>
+#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -23,11 +25,7 @@ CrostiniHandler::CrostiniHandler(Profile* profile)
: profile_(profile), weak_ptr_factory_(this) {}
CrostiniHandler::~CrostiniHandler() {
- if (crostini::CrostiniManager::GetForProfile(profile_)
- ->HasInstallerViewStatusObserver(this)) {
- crostini::CrostiniManager::GetForProfile(profile_)
- ->RemoveInstallerViewStatusObserver(this);
- }
+ DisallowJavascript();
}
void CrostiniHandler::RegisterMessages() {
@@ -49,6 +47,14 @@ void CrostiniHandler::RegisterMessages() {
base::BindRepeating(&CrostiniHandler::HandleRemoveCrostiniSharedPath,
weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
+ "getCrostiniSharedUsbDevices",
+ base::BindRepeating(&CrostiniHandler::HandleGetCrostiniSharedUsbDevices,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "setCrostiniUsbDeviceShared",
+ base::BindRepeating(&CrostiniHandler::HandleSetCrostiniUsbDeviceShared,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
"exportCrostiniContainer",
base::BindRepeating(&CrostiniHandler::HandleExportCrostiniContainer,
weak_ptr_factory_.GetWeakPtr()));
@@ -61,8 +67,25 @@ void CrostiniHandler::RegisterMessages() {
base::BindRepeating(
&CrostiniHandler::HandleCrostiniInstallerStatusRequest,
weak_ptr_factory_.GetWeakPtr()));
+}
+
+void CrostiniHandler::OnJavascriptAllowed() {
crostini::CrostiniManager::GetForProfile(profile_)
->AddInstallerViewStatusObserver(this);
+ if (chromeos::CrosUsbDetector::Get()) {
+ chromeos::CrosUsbDetector::Get()->AddSharedUsbDeviceObserver(this);
+ }
+}
+
+void CrostiniHandler::OnJavascriptDisallowed() {
+ if (crostini::CrostiniManager::GetForProfile(profile_)
+ ->HasInstallerViewStatusObserver(this)) {
+ crostini::CrostiniManager::GetForProfile(profile_)
+ ->RemoveInstallerViewStatusObserver(this);
+ }
+ if (chromeos::CrosUsbDetector::Get()) {
+ chromeos::CrosUsbDetector::Get()->RemoveSharedUsbDeviceObserver(this);
+ }
}
void CrostiniHandler::HandleRequestCrostiniInstallerView(
@@ -97,12 +120,15 @@ void CrostiniHandler::HandleGetCrostiniSharedPathsDisplayText(
void CrostiniHandler::HandleRemoveCrostiniSharedPath(
const base::ListValue* args) {
- CHECK_EQ(1U, args->GetSize());
+ CHECK_EQ(2U, args->GetSize());
+ std::string vm_name;
+ CHECK(args->GetString(0, &vm_name));
std::string path;
- CHECK(args->GetString(0, &path));
+ CHECK(args->GetString(1, &path));
crostini::CrostiniSharePath::GetForProfile(profile_)->UnsharePath(
- crostini::kCrostiniDefaultVmName, base::FilePath(path),
+ vm_name, base::FilePath(path),
+ /*unpersist=*/true,
base::BindOnce(
[](const std::string& path, bool result, std::string failure_reason) {
if (!result) {
@@ -113,6 +139,65 @@ void CrostiniHandler::HandleRemoveCrostiniSharedPath(
path));
}
+namespace {
+base::ListValue UsbDevicesToListValue(
+ const std::vector<SharedUsbDeviceInfo> shared_usbs) {
+ base::ListValue usb_devices_list;
+ for (auto device : shared_usbs) {
+ base::Value device_info(base::Value::Type::DICTIONARY);
+ device_info.SetKey("guid", base::Value(device.guid));
+ device_info.SetKey("label", base::Value(device.label));
+ device_info.SetKey("shared", base::Value(device.shared));
+ usb_devices_list.GetList().push_back(std::move(device_info));
+ }
+ return usb_devices_list;
+}
+} // namespace
+
+void CrostiniHandler::HandleGetCrostiniSharedUsbDevices(
+ const base::ListValue* args) {
+ AllowJavascript();
+ CHECK_EQ(1U, args->GetSize());
+
+ std::string callback_id = args->GetList()[0].GetString();
+
+ chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
+ if (!detector) {
+ ResolveJavascriptCallback(base::Value(callback_id), base::ListValue());
+ return;
+ }
+
+ ResolveJavascriptCallback(
+ base::Value(callback_id),
+ UsbDevicesToListValue(detector->GetSharedUsbDevices()));
+}
+
+void CrostiniHandler::HandleSetCrostiniUsbDeviceShared(
+ const base::ListValue* args) {
+ CHECK_EQ(2U, args->GetSize());
+ const auto& args_list = args->GetList();
+ std::string guid = args_list[0].GetString();
+ bool shared = args_list[1].GetBool();
+
+ chromeos::CrosUsbDetector* detector = chromeos::CrosUsbDetector::Get();
+ if (!detector)
+ return;
+
+ if (shared) {
+ detector->AttachUsbDeviceToVm(crostini::kCrostiniDefaultVmName, guid,
+ base::DoNothing());
+ return;
+ }
+ detector->DetachUsbDeviceFromVm(crostini::kCrostiniDefaultVmName, guid,
+ base::DoNothing());
+}
+
+void CrostiniHandler::OnSharedUsbDevicesChanged(
+ const std::vector<SharedUsbDeviceInfo> shared_usbs) {
+ FireWebUIListener("crostini-shared-usb-devices-changed",
+ UsbDevicesToListValue(shared_usbs));
+}
+
void CrostiniHandler::HandleExportCrostiniContainer(
const base::ListValue* args) {
CHECK_EQ(0U, args->GetSize());
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
index 6358b30e17b..cda0346383e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
@@ -5,8 +5,11 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CROSTINI_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CROSTINI_HANDLER_H_
+#include <vector>
+
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
+#include "chrome/browser/chromeos/usb/cros_usb_detector.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile;
@@ -19,15 +22,16 @@ namespace chromeos {
namespace settings {
class CrostiniHandler : public ::settings::SettingsPageUIHandler,
- public crostini::InstallerViewStatusObserver {
+ public crostini::InstallerViewStatusObserver,
+ public chromeos::SharedUsbDeviceObserver {
public:
explicit CrostiniHandler(Profile* profile);
~CrostiniHandler() override;
// SettingsPageUIHandler
void RegisterMessages() override;
- void OnJavascriptAllowed() override {}
- void OnJavascriptDisallowed() override {}
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
private:
void HandleRequestCrostiniInstallerView(const base::ListValue* args);
@@ -38,6 +42,13 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler,
void HandleGetCrostiniSharedPathsDisplayText(const base::ListValue* args);
// Remove a specified path from being shared.
void HandleRemoveCrostiniSharedPath(const base::ListValue* args);
+ // Returns a list of available USB devices.
+ void HandleGetCrostiniSharedUsbDevices(const base::ListValue* args);
+ // Set the share state of a USB device.
+ void HandleSetCrostiniUsbDeviceShared(const base::ListValue* args);
+ // chromeos::SharedUsbDeviceObserver.
+ void OnSharedUsbDevicesChanged(
+ const std::vector<SharedUsbDeviceInfo> shared_usbs) override;
// Export the crostini container.
void HandleExportCrostiniContainer(const base::ListValue* args);
// Import the crostini container.
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 28b9e86154d..d4c16b23d88 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
@@ -13,6 +13,7 @@
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
+#include "base/optional.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -49,6 +50,7 @@
#include "content/public/browser/web_ui.h"
#include "google_apis/google_api_keys.h"
#include "net/base/filename_util.h"
+#include "net/base/ip_endpoint.h"
#include "net/url_request/url_request_context_getter.h"
#include "printing/backend/print_backend.h"
@@ -253,15 +255,43 @@ Printer::PpdReference GetPpdReference(const base::Value* info) {
} // namespace
-CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui)
- : profile_(Profile::FromWebUI(webui)),
- ppd_provider_(CreatePpdProvider(profile_)),
- printer_configurer_(PrinterConfigurer::Create(profile_)),
- printers_manager_(
- CupsPrintersManagerFactory::GetForBrowserContext(profile_)),
+CupsPrintersHandler::CupsPrintersHandler(
+ Profile* profile,
+ scoped_refptr<PpdProvider> ppd_provider,
+ std::unique_ptr<PrinterConfigurer> printer_configurer,
+ CupsPrintersManager* printers_manager)
+ : profile_(profile),
+ ppd_provider_(ppd_provider),
+ printer_configurer_(std::move(printer_configurer)),
+ printers_manager_(printers_manager),
+ endpoint_resolver_(std::make_unique<local_discovery::EndpointResolver>()),
printers_manager_observer_(this),
weak_factory_(this) {}
+// static
+std::unique_ptr<CupsPrintersHandler> CupsPrintersHandler::Create(
+ content::WebUI* webui) {
+ Profile* profile(Profile::FromWebUI(webui));
+ auto ppd_provider = CreatePpdProvider(profile);
+ auto printer_configurer = PrinterConfigurer::Create(profile);
+ CupsPrintersManager* printers_manager =
+ CupsPrintersManagerFactory::GetForBrowserContext(profile);
+ // Using 'new' to access non-public constructor.
+ return base::WrapUnique(new CupsPrintersHandler(
+ profile, ppd_provider, std::move(printer_configurer), printers_manager));
+}
+
+// static
+std::unique_ptr<CupsPrintersHandler> CupsPrintersHandler::CreateForTesting(
+ Profile* profile,
+ scoped_refptr<PpdProvider> ppd_provider,
+ std::unique_ptr<PrinterConfigurer> printer_configurer,
+ CupsPrintersManager* printers_manager) {
+ // Using 'new' to access non-public constructor.
+ return base::WrapUnique(new CupsPrintersHandler(
+ profile, ppd_provider, std::move(printer_configurer), printers_manager));
+}
+
CupsPrintersHandler::~CupsPrintersHandler() = default;
void CupsPrintersHandler::RegisterMessages() {
@@ -282,6 +312,10 @@ void CupsPrintersHandler::RegisterMessages() {
base::BindRepeating(&CupsPrintersHandler::HandleAddCupsPrinter,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ "reconfigureCupsPrinter",
+ base::BindRepeating(&CupsPrintersHandler::HandleReconfigureCupsPrinter,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"getPrinterInfo",
base::BindRepeating(&CupsPrintersHandler::HandleGetPrinterInfo,
base::Unretained(this)));
@@ -331,6 +365,10 @@ void CupsPrintersHandler::OnJavascriptDisallowed() {
printers_manager_observer_.RemoveAll();
}
+void CupsPrintersHandler::SetWebUIForTest(content::WebUI* web_ui) {
+ set_web_ui(web_ui);
+}
+
void CupsPrintersHandler::HandleGetCupsPrintersList(
const base::ListValue* args) {
AllowJavascript();
@@ -340,7 +378,7 @@ void CupsPrintersHandler::HandleGetCupsPrintersList(
CHECK(args->GetString(0, &callback_id));
std::vector<Printer> printers =
- printers_manager_->GetPrinters(CupsPrintersManager::kConfigured);
+ printers_manager_->GetPrinters(CupsPrintersManager::kSaved);
auto response = BuildCupsPrintersList(printers);
ResolveJavascriptCallback(base::Value(callback_id), response);
@@ -356,25 +394,18 @@ void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) {
printer.set_display_name(printer_name);
if (!profile_->GetPrefs()->GetBoolean(prefs::kUserNativePrintersAllowed)) {
- PRINTER_LOG(DEBUG) << "HandleAddCupsPrinter() called when "
+ PRINTER_LOG(DEBUG) << "HandleUpdateCupsPrinter() called when "
"kUserNativePrintersAllowed is set to false";
- // Used to log UMA metrics.
- OnAddedPrinterCommon(printer,
- PrinterSetupResult::kNativePrintersNotAllowed,
- false);
+ OnAddedOrEditedPrinterCommon(printer,
+ PrinterSetupResult::kNativePrintersNotAllowed,
+ false /* is_automatic */);
// Used to fire the web UI listener.
- OnAddPrinterError(PrinterSetupResult::kNativePrintersNotAllowed);
+ OnAddOrEditPrinterError(PrinterSetupResult::kNativePrintersNotAllowed);
return;
}
- PRINTER_LOG(USER) << "Comitting printer update";
- printers_manager_->UpdateConfiguredPrinter(printer);
-
- // TODO(xdai): Replace "on-add-cups-printer" callback with Promise resolve
- // function.
- FireWebUIListener("on-add-cups-printer",
- base::Value(PrinterSetupResult::kSuccess),
- base::Value(printer_name));
+ OnAddedOrEditedSpecifiedPrinter(printer, true /* is_printer_edit */,
+ PrinterSetupResult::kEditSuccess);
}
void CupsPrintersHandler::HandleRemoveCupsPrinter(const base::ListValue* args) {
@@ -393,11 +424,12 @@ void CupsPrintersHandler::HandleRemoveCupsPrinter(const base::ListValue* args) {
Printer::PrinterProtocol protocol = printer->GetProtocol();
// Printer is deleted here. Do not access after this line.
- printers_manager_->RemoveConfiguredPrinter(printer_id);
+ printers_manager_->RemoveSavedPrinter(printer_id);
DebugDaemonClient* client = DBusThreadManager::Get()->GetDebugDaemonClient();
- client->CupsRemovePrinter(
- printer_name, base::Bind(&OnRemovedPrinter, protocol), base::DoNothing());
+ client->CupsRemovePrinter(printer_id,
+ base::BindOnce(&OnRemovedPrinter, protocol),
+ base::DoNothing());
}
void CupsPrintersHandler::HandleGetPrinterInfo(const base::ListValue* args) {
@@ -448,7 +480,7 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::ListValue* args) {
}
void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
- std::unique_ptr<Printer> printer,
+ Printer printer,
bool success,
const std::string& make,
const std::string& model,
@@ -465,9 +497,9 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
// manufacturer and model are set with make_and_model because they are
// derived from make_and_model for compatability and are slated for
// removal.
- printer->set_manufacturer(make);
- printer->set_model(model);
- printer->set_make_and_model(make_and_model);
+ printer.set_manufacturer(make);
+ printer.set_model(model);
+ printer.set_make_and_model(make_and_model);
PRINTER_LOG(DEBUG) << "Printer queried for make and model "
<< make_and_model;
}
@@ -475,10 +507,11 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
// Autoconfig available, use it.
if (ipp_everywhere) {
PRINTER_LOG(DEBUG) << "Performing autoconf setup";
- printer->mutable_ppd_reference()->autoconf = true;
+ printer.mutable_ppd_reference()->autoconf = true;
printer_configurer_->SetUpPrinter(
- *printer, base::Bind(&CupsPrintersHandler::OnAddedDiscoveredPrinter,
- weak_factory_.GetWeakPtr(), *printer));
+ printer,
+ base::BindOnce(&CupsPrintersHandler::OnAddedDiscoveredPrinter,
+ weak_factory_.GetWeakPtr(), printer));
return;
}
}
@@ -487,7 +520,7 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
// much information as we can about the printer, and ask the user to supply
// the rest.
PRINTER_LOG(EVENT) << "Could not query printer. Fallback to asking the user";
- FireManuallyAddDiscoveredPrinter(*printer);
+ FireManuallyAddDiscoveredPrinter(printer);
}
void CupsPrintersHandler::OnAutoconfQueried(
@@ -555,26 +588,35 @@ void CupsPrintersHandler::OnPpdResolved(const std::string& callback_id,
void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
AllowJavascript();
+ AddOrReconfigurePrinter(args, false /* is_printer_edit */);
+}
+
+void CupsPrintersHandler::HandleReconfigureCupsPrinter(
+ const base::ListValue* args) {
+ AllowJavascript();
+ AddOrReconfigurePrinter(args, true /* is_printer_edit */);
+}
+void CupsPrintersHandler::AddOrReconfigurePrinter(const base::ListValue* args,
+ bool is_printer_edit) {
const base::DictionaryValue* printer_dict = nullptr;
CHECK(args->GetDictionary(0, &printer_dict));
std::unique_ptr<Printer> printer = DictToPrinter(*printer_dict);
if (!printer) {
PRINTER_LOG(ERROR) << "Failed to parse printer URI";
- OnAddPrinterError(PrinterSetupResult::kFatalError);
+ OnAddOrEditPrinterError(PrinterSetupResult::kFatalError);
return;
}
if (!profile_->GetPrefs()->GetBoolean(prefs::kUserNativePrintersAllowed)) {
- PRINTER_LOG(DEBUG) << "HandleAddCupsPrinter() called when "
+ PRINTER_LOG(DEBUG) << "AddOrReconfigurePrinter() called when "
"kUserNativePrintersAllowed is set to false";
- // Used to log UMA metrics.
- OnAddedPrinterCommon(*printer,
- PrinterSetupResult::kNativePrintersNotAllowed,
- false);
+ OnAddedOrEditedPrinterCommon(*printer,
+ PrinterSetupResult::kNativePrintersNotAllowed,
+ false /* is_automatic */);
// Used to fire the web UI listener.
- OnAddPrinterError(PrinterSetupResult::kNativePrintersNotAllowed);
+ OnAddOrEditPrinterError(PrinterSetupResult::kNativePrintersNotAllowed);
return;
}
@@ -582,21 +624,26 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
// If the returned optional does not contain a value then it means that the
// printer's uri was not able to be parsed successfully.
PRINTER_LOG(ERROR) << "Failed to parse printer URI";
- OnAddPrinterError(PrinterSetupResult::kFatalError);
+ OnAddOrEditPrinterError(PrinterSetupResult::kFatalError);
return;
}
- // If the provided printer already exists, grab the existing printer object
- // and check that we are not making any changes that will make the printer
- // unusable.
- if (!printer->id().empty()) {
- std::unique_ptr<Printer> existing_printer =
- printers_manager_->GetPrinter(printer->id());
- if (existing_printer) {
- if (!IsValidUriChange(*existing_printer, *printer)) {
- OnAddPrinterError(PrinterSetupResult::kInvalidPrinterUpdate);
- return;
- }
+ // Grab the existing printer object and check that we are not making any
+ // changes that will make |existing_printer_object| unusable.
+ if (printer->id().empty()) {
+ // If the printer object has not already been created, error out since this
+ // is not a valid case.
+ PRINTER_LOG(ERROR) << "Failed to parse printer ID";
+ OnAddOrEditPrinterError(PrinterSetupResult::kFatalError);
+ return;
+ }
+
+ base::Optional<Printer> existing_printer_object =
+ printers_manager_->GetPrinter(printer->id());
+ if (existing_printer_object) {
+ if (!IsValidUriChange(*existing_printer_object, *printer)) {
+ OnAddOrEditPrinterError(PrinterSetupResult::kInvalidPrinterUpdate);
+ return;
}
}
@@ -622,7 +669,7 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
GURL tmp = net::FilePathToFileURL(base::FilePath(printer_ppd_path));
if (!tmp.is_valid()) {
LOG(ERROR) << "Invalid ppd path: " << printer_ppd_path;
- OnAddPrinterError(PrinterSetupResult::kInvalidPpd);
+ OnAddOrEditPrinterError(PrinterSetupResult::kInvalidPpd);
return;
}
printer->mutable_ppd_reference()->user_supplied_ppd_url = tmp.spec();
@@ -640,7 +687,7 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
}
if (!found) {
LOG(ERROR) << "Failed to get ppd reference";
- OnAddPrinterError(PrinterSetupResult::kPpdNotFound);
+ OnAddOrEditPrinterError(PrinterSetupResult::kPpdNotFound);
return;
}
@@ -660,13 +707,15 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
}
printer_configurer_->SetUpPrinter(
- *printer, base::Bind(&CupsPrintersHandler::OnAddedSpecifiedPrinter,
- weak_factory_.GetWeakPtr(), *printer));
+ *printer,
+ base::BindOnce(&CupsPrintersHandler::OnAddedOrEditedSpecifiedPrinter,
+ weak_factory_.GetWeakPtr(), *printer, is_printer_edit));
}
-void CupsPrintersHandler::OnAddedPrinterCommon(const Printer& printer,
- PrinterSetupResult result_code,
- bool is_automatic) {
+void CupsPrintersHandler::OnAddedOrEditedPrinterCommon(
+ const Printer& printer,
+ PrinterSetupResult result_code,
+ bool is_automatic) {
UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterSetupResult", result_code,
PrinterSetupResult::kMaxValue);
switch (result_code) {
@@ -675,7 +724,15 @@ void CupsPrintersHandler::OnAddedPrinterCommon(const Printer& printer,
printer.GetProtocol(), Printer::kProtocolMax);
PRINTER_LOG(USER) << "Performing printer setup";
printers_manager_->PrinterInstalled(printer, is_automatic);
- printers_manager_->UpdateConfiguredPrinter(printer);
+ if (printer.IsUsbProtocol()) {
+ // Record UMA for USB printer setup source.
+ PrinterConfigurer::RecordUsbPrinterSetupSource(
+ UsbPrinterSetupSource::kSettings);
+ }
+ return;
+ case PrinterSetupResult::kEditSuccess:
+ PRINTER_LOG(USER) << "Printer updated";
+ printers_manager_->UpdateSavedPrinter(printer);
return;
case PrinterSetupResult::kPpdNotFound:
PRINTER_LOG(ERROR) << "Could not locate requested PPD";
@@ -725,9 +782,9 @@ void CupsPrintersHandler::OnAddedPrinterCommon(const Printer& printer,
void CupsPrintersHandler::OnAddedDiscoveredPrinter(
const Printer& printer,
PrinterSetupResult result_code) {
- OnAddedPrinterCommon(printer, result_code, true);
+ OnAddedOrEditedPrinterCommon(printer, result_code, /*is_automatic=*/true);
if (result_code == PrinterSetupResult::kSuccess) {
- FireWebUIListener("on-add-cups-printer", base::Value(result_code),
+ FireWebUIListener("on-add-or-edit-cups-printer", base::Value(result_code),
base::Value(printer.display_name()));
} else {
PRINTER_LOG(EVENT) << "Automatic setup failed for discovered printer. "
@@ -737,18 +794,23 @@ void CupsPrintersHandler::OnAddedDiscoveredPrinter(
}
}
-void CupsPrintersHandler::OnAddedSpecifiedPrinter(
+void CupsPrintersHandler::OnAddedOrEditedSpecifiedPrinter(
const Printer& printer,
+ bool is_printer_edit,
PrinterSetupResult result_code) {
- PRINTER_LOG(EVENT) << "Add manual printer: " << result_code;
- OnAddedPrinterCommon(printer, result_code, false);
- FireWebUIListener("on-add-cups-printer", base::Value(result_code),
+ if (is_printer_edit && result_code == PrinterSetupResult::kSuccess) {
+ result_code = PrinterSetupResult::kEditSuccess;
+ }
+ PRINTER_LOG(EVENT) << "Add/Update manual printer: " << result_code;
+ OnAddedOrEditedPrinterCommon(printer, result_code, /*is_automatic=*/false);
+ FireWebUIListener("on-add-or-edit-cups-printer", base::Value(result_code),
base::Value(printer.display_name()));
}
-void CupsPrintersHandler::OnAddPrinterError(PrinterSetupResult result_code) {
+void CupsPrintersHandler::OnAddOrEditPrinterError(
+ PrinterSetupResult result_code) {
PRINTER_LOG(EVENT) << "Add printer error: " << result_code;
- FireWebUIListener("on-add-cups-printer", base::Value(result_code),
+ FireWebUIListener("on-add-or-edit-cups-printer", base::Value(result_code),
base::Value(""));
}
@@ -918,7 +980,7 @@ void CupsPrintersHandler::OnPrintersChanged(
discovered_printers_ = printers;
UpdateDiscoveredPrinters();
break;
- case CupsPrintersManager::kConfigured: {
+ case CupsPrintersManager::kSaved: {
auto printers_list = BuildCupsPrintersList(printers);
FireWebUIListener("on-printers-changed", printers_list);
break;
@@ -955,12 +1017,12 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter(
CHECK(args->GetString(0, &printer_id));
PRINTER_LOG(USER) << "Adding discovered printer";
- std::unique_ptr<Printer> printer = printers_manager_->GetPrinter(printer_id);
- if (printer == nullptr) {
+ base::Optional<Printer> printer = printers_manager_->GetPrinter(printer_id);
+ if (!printer) {
PRINTER_LOG(ERROR) << "Discovered printer disappeared";
// Printer disappeared, so we don't have information about it anymore and
// can't really do much. Fail the add.
- FireWebUIListener("on-add-cups-printer", base::Value(false),
+ FireWebUIListener("on-add-or-edit-cups-printer", base::Value(false),
base::Value(printer_id));
return;
}
@@ -968,7 +1030,7 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter(
if (!printer->GetUriComponents().has_value()) {
PRINTER_LOG(DEBUG) << "Could not parse uri";
// The printer uri was not parsed successfully. Fail the add.
- FireWebUIListener("on-add-cups-printer", base::Value(false),
+ FireWebUIListener("on-add-or-edit-cups-printer", base::Value(false),
base::Value(printer_id));
return;
}
@@ -987,18 +1049,15 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter(
// The mDNS record doesn't guarantee we can setup the printer. Query it to
// see if we want to try IPP.
- const std::string printer_uri = printer->effective_uri();
- if (IsIppUri(printer_uri)) {
- PRINTER_LOG(EVENT) << "Query printer for IPP attributes";
- QueryAutoconf(
- printer_uri,
- base::Bind(&CupsPrintersHandler::OnAutoconfQueriedDiscovered,
- weak_factory_.GetWeakPtr(), base::Passed(&printer)));
- } else {
- PRINTER_LOG(EVENT) << "Request make and model from user";
- // If it's not an IPP printer, the user must choose a PPD.
- FireManuallyAddDiscoveredPrinter(*printer);
+ auto address = printer->GetHostAndPort();
+ if (address.IsEmpty()) {
+ PRINTER_LOG(ERROR) << "Address is invalid";
+ OnAddedDiscoveredPrinter(*printer, PrinterSetupResult::kPrinterUnreachable);
+ return;
}
+ endpoint_resolver_->Start(
+ address, base::BindOnce(&CupsPrintersHandler::OnIpResolved,
+ weak_factory_.GetWeakPtr(), std::move(*printer)));
}
void CupsPrintersHandler::HandleGetPrinterPpdManufacturerAndModel(
@@ -1043,5 +1102,33 @@ void CupsPrintersHandler::FireManuallyAddDiscoveredPrinter(
*GetCupsPrinterInfo(printer));
}
+void CupsPrintersHandler::OnIpResolved(const Printer& printer,
+ const net::IPEndPoint& endpoint) {
+ bool address_resolved = endpoint.address().IsValid();
+ UMA_HISTOGRAM_BOOLEAN("Printing.CUPS.AddressResolutionResult",
+ address_resolved);
+ if (!address_resolved) {
+ PRINTER_LOG(ERROR) << printer.make_and_model() << " IP Resolution failed";
+ OnAddedDiscoveredPrinter(printer, PrinterSetupResult::kPrinterUnreachable);
+ return;
+ }
+
+ PRINTER_LOG(EVENT) << printer.make_and_model() << " IP Resolution succeeded";
+ std::string resolved_uri = printer.ReplaceHostAndPort(endpoint);
+
+ if (IsIppUri(resolved_uri)) {
+ PRINTER_LOG(EVENT) << "Query printer for IPP attributes";
+ QueryAutoconf(
+ resolved_uri,
+ base::BindRepeating(&CupsPrintersHandler::OnAutoconfQueriedDiscovered,
+ weak_factory_.GetWeakPtr(), printer));
+ return;
+ }
+
+ PRINTER_LOG(EVENT) << "Request make and model from user";
+ // If it's not an IPP printer, the user must choose a PPD.
+ FireManuallyAddDiscoveredPrinter(printer);
+}
+
} // namespace settings
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
index 0362548c17a..7ab1f8e3ef1 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
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printer_event_tracker.h"
+#include "chrome/browser/local_discovery/endpoint_resolver.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "chromeos/printing/ppd_provider.h"
#include "chromeos/printing/printer_configuration.h"
@@ -38,7 +39,14 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
public ui::SelectFileDialog::Listener,
public CupsPrintersManager::Observer {
public:
- explicit CupsPrintersHandler(content::WebUI* webui);
+ static std::unique_ptr<CupsPrintersHandler> Create(content::WebUI* webui);
+
+ static std::unique_ptr<CupsPrintersHandler> CreateForTesting(
+ Profile* profile,
+ scoped_refptr<PpdProvider> ppd_provider,
+ std::unique_ptr<PrinterConfigurer> printer_configurer,
+ CupsPrintersManager* printers_manager);
+
~CupsPrintersHandler() override;
// SettingsPageUIHandler overrides:
@@ -46,7 +54,14 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
+ void SetWebUIForTest(content::WebUI* web_ui);
+
private:
+ CupsPrintersHandler(Profile* profile,
+ scoped_refptr<PpdProvider> ppd_provider,
+ std::unique_ptr<PrinterConfigurer> printer_configurer,
+ CupsPrintersManager* printers_manager);
+
// Gets all CUPS printers and return it to WebUI.
void HandleGetCupsPrintersList(const base::ListValue* args);
void HandleUpdateCupsPrinter(const base::ListValue* args);
@@ -73,7 +88,7 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
// Handles the callback for HandleGetPrinterInfo for a discovered printer.
void OnAutoconfQueriedDiscovered(
- std::unique_ptr<Printer> printer,
+ Printer printer,
bool success,
const std::string& make,
const std::string& model,
@@ -89,14 +104,20 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
void HandleAddCupsPrinter(const base::ListValue* args);
+ void HandleReconfigureCupsPrinter(const base::ListValue* args);
+
+ void AddOrReconfigurePrinter(const base::ListValue* args,
+ bool is_printer_edit);
+
// Handles the result of adding a printer which the user specified the
// location of (i.e. a printer that was not 'discovered' automatically).
- void OnAddedSpecifiedPrinter(const Printer& printer,
- PrinterSetupResult result);
+ void OnAddedOrEditedSpecifiedPrinter(const Printer& printer,
+ bool is_printer_edit,
+ PrinterSetupResult result);
// Handles the result of failure to add a printer. |result_code| is used to
// determine the reason for the failure.
- void OnAddPrinterError(PrinterSetupResult result_code);
+ void OnAddOrEditPrinterError(PrinterSetupResult result_code);
// Get a list of all manufacturers for which we have at least one model of
// printer supported. Takes one argument, the callback id for the result.
@@ -146,9 +167,9 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
PrinterSetupResult result_code);
// Code common between the discovered and manual add printer code paths.
- void OnAddedPrinterCommon(const Printer& printer,
- PrinterSetupResult result_code,
- bool is_automatic);
+ void OnAddedOrEditedPrinterCommon(const Printer& printer,
+ PrinterSetupResult result_code,
+ bool is_automatic);
// CupsPrintersManager::Observer override:
void OnPrintersChanged(CupsPrintersManager::PrinterClass printer_class,
@@ -170,6 +191,8 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
// parameters. See https://crbug.com/835476
void FireManuallyAddDiscoveredPrinter(const Printer& printer);
+ void OnIpResolved(const Printer& printer, const net::IPEndPoint& endpoint);
+
Profile* profile_;
// Discovery support. discovery_active_ tracks whether or not the UI
@@ -193,6 +216,7 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
std::string webui_callback_id_;
CupsPrintersManager* printers_manager_;
+ std::unique_ptr<local_discovery::EndpointResolver> endpoint_resolver_;
ScopedObserver<CupsPrintersManager, CupsPrintersManager::Observer>
printers_manager_observer_;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc
new file mode 100644
index 00000000000..1af82488177
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler_unittest.cc
@@ -0,0 +1,156 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h"
+
+#include <memory>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/json/json_string_value_serializer.h"
+#include "chrome/test/base/testing_profile.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/debug_daemon_client.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_web_ui.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+namespace settings {
+
+class CupsPrintersHandlerTest;
+
+namespace {
+
+// Converts JSON string to base::ListValue object.
+// On failure, returns NULL and fills |*error| string.
+std::unique_ptr<base::ListValue> GetJSONAsListValue(const std::string& json,
+ std::string* error) {
+ auto ret = base::ListValue::From(
+ JSONStringValueDeserializer(json).Deserialize(nullptr, error));
+ if (!ret)
+ *error = "Value is not a list.";
+ return ret;
+}
+
+} // namespace
+
+// Callback used for testing CupsAddAutoConfiguredPrinter().
+void AddedPrinter(int32_t status) {
+ ASSERT_EQ(status, 0);
+}
+
+// Callback used for testing CupsRemovePrinter().
+void RemovedPrinter(base::OnceClosure quit_closure,
+ bool* expected,
+ bool result) {
+ *expected = result;
+ std::move(quit_closure).Run();
+}
+
+class FakePrinterConfigurer : public PrinterConfigurer {
+ public:
+ void SetUpPrinter(const Printer& printer,
+ PrinterSetupCallback callback) override {}
+};
+
+class FakeCupsPrintersManager : public CupsPrintersManager {
+ public:
+ FakeCupsPrintersManager() = default;
+
+ std::vector<Printer> GetPrinters(PrinterClass printer_class) const override {
+ return {};
+ }
+
+ void RemoveUnavailablePrinters(std::vector<Printer>*) const override {}
+ void UpdateSavedPrinter(const Printer& printer) override {}
+ void RemoveSavedPrinter(const std::string& printer_id) override {}
+ void AddObserver(CupsPrintersManager::Observer* observer) override {}
+ void RemoveObserver(CupsPrintersManager::Observer* observer) override {}
+ void PrinterInstalled(const Printer& printer, bool is_automatic) override {}
+ void RecordSetupAbandoned(const Printer& printer) override {}
+
+ bool IsPrinterInstalled(const Printer& printer) const override {
+ return false;
+ }
+
+ base::Optional<Printer> GetPrinter(const std::string& id) const override {
+ return Printer();
+ }
+};
+
+class FakePpdProvider : public PpdProvider {
+ public:
+ FakePpdProvider() = default;
+
+ void ResolveManufacturers(ResolveManufacturersCallback cb) override {}
+ void ResolvePrinters(const std::string& manufacturer,
+ ResolvePrintersCallback cb) override {}
+ void ResolvePpdReference(const PrinterSearchData& search_data,
+ ResolvePpdReferenceCallback cb) override {}
+ void ResolvePpd(const Printer::PpdReference& reference,
+ ResolvePpdCallback cb) override {}
+ void ReverseLookup(const std::string& effective_make_and_model,
+ ReverseLookupCallback cb) override {}
+
+ private:
+ ~FakePpdProvider() override {}
+};
+
+class CupsPrintersHandlerTest : public testing::Test {
+ public:
+ CupsPrintersHandlerTest()
+ : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD),
+ profile_(),
+ web_ui_(),
+ printers_handler_() {}
+ ~CupsPrintersHandlerTest() override = default;
+
+ void SetUp() override {
+ printers_handler_ = CupsPrintersHandler::CreateForTesting(
+ &profile_, base::MakeRefCounted<FakePpdProvider>(),
+ std::make_unique<FakePrinterConfigurer>(), &printers_manager_);
+ printers_handler_->SetWebUIForTest(&web_ui_);
+ printers_handler_->RegisterMessages();
+ }
+
+ protected:
+ // Must outlive |profile_|.
+ content::TestBrowserThreadBundle thread_bundle_;
+ TestingProfile profile_;
+ content::TestWebUI web_ui_;
+ std::unique_ptr<CupsPrintersHandler> printers_handler_;
+ FakeCupsPrintersManager printers_manager_;
+};
+
+TEST_F(CupsPrintersHandlerTest, RemoveCorrectPrinter) {
+ DBusThreadManager::Initialize();
+ DebugDaemonClient* client = DBusThreadManager::Get()->GetDebugDaemonClient();
+ client->CupsAddAutoConfiguredPrinter("testprinter1", "fakeuri",
+ base::BindOnce(&AddedPrinter));
+
+ const std::string remove_list = R"(
+ ["testprinter1", "Test Printer 1"]
+ )";
+ std::string error;
+ std::unique_ptr<base::ListValue> remove_printers(
+ GetJSONAsListValue(remove_list, &error));
+ ASSERT_TRUE(remove_printers) << "Error deserializing list: " << error;
+
+ web_ui_.HandleReceivedMessage("removeCupsPrinter", remove_printers.get());
+
+ // We expect this printer removal to fail since the printer should have
+ // already been removed by the previous call to 'removeCupsPrinter'.
+ base::RunLoop run_loop;
+ bool expected = true;
+ client->CupsRemovePrinter(
+ "testprinter1",
+ base::BindRepeating(&RemovedPrinter, run_loop.QuitClosure(), &expected),
+ base::DoNothing());
+ run_loop.Run();
+ EXPECT_FALSE(expected);
+}
+
+} // namespace settings.
+} // namespace chromeos.
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
index 2423ebcd3dc..c3a3202bb1d 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/date_time_handler.cc
@@ -26,19 +26,9 @@ namespace settings {
namespace {
-// Returns whether the system time zone automatic detection policy is disabled
-// by a flag.
-bool IsSystemTimezoneAutomaticDetectionPolicyFlagDisabled() {
- return base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableSystemTimezoneAutomaticDetectionPolicy);
-}
-
// Returns whether the system's automatic time zone detection setting is
// managed, which may override the user's setting.
bool IsSystemTimezoneAutomaticDetectionManaged() {
- if (IsSystemTimezoneAutomaticDetectionPolicyFlagDisabled())
- return false;
-
return g_browser_process->local_state()->IsManagedPreference(
prefs::kSystemTimezoneAutomaticDetectionPolicy);
}
@@ -112,9 +102,6 @@ void DateTimeHandler::OnJavascriptAllowed() {
base::Bind(&DateTimeHandler::NotifyTimezoneAutomaticDetectionPolicy,
weak_ptr_factory_.GetWeakPtr()));
- if (IsSystemTimezoneAutomaticDetectionPolicyFlagDisabled())
- return;
-
// The auto-detection policy can force auto-detection on or off.
local_state_pref_change_registrar_.Init(g_browser_process->local_state());
local_state_pref_change_registrar_.Add(
@@ -126,9 +113,7 @@ void DateTimeHandler::OnJavascriptAllowed() {
void DateTimeHandler::OnJavascriptDisallowed() {
scoped_observer_.RemoveAll();
system_timezone_policy_subscription_.reset();
-
- if (!IsSystemTimezoneAutomaticDetectionPolicyFlagDisabled())
- local_state_pref_change_registrar_.RemoveAll();
+ local_state_pref_change_registrar_.RemoveAll();
}
void DateTimeHandler::HandleDateTimePageReady(const base::ListValue* args) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
index 5344ee81b74..78869c7978e 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
@@ -13,8 +13,8 @@
#include "base/scoped_observer.h"
#include "base/strings/string16.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
-#include "chromeos/dbus/power_manager_client.h"
-#include "chromeos/dbus/power_policy_controller.h"
+#include "chromeos/dbus/power/power_manager_client.h"
+#include "chromeos/dbus/power/power_policy_controller.h"
class PrefChangeRegistrar;
class PrefService;
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
index 9206cad0173..c27e55cb6d4 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc
@@ -14,8 +14,8 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/test/base/in_process_browser_test.h"
-#include "chromeos/dbus/fake_power_manager_client.h"
-#include "chromeos/dbus/power_policy_controller.h"
+#include "chromeos/dbus/power/fake_power_manager_client.h"
+#include "chromeos/dbus/power/power_policy_controller.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/policy_constants.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc
index 5ef78d58cdf..b565a9071b5 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
@@ -32,7 +32,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/cryptohome/cryptohome_util.h"
-#include "chromeos/dbus/cryptohome_client.h"
+#include "chromeos/dbus/cryptohome/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "components/arc/arc_util.h"
#include "components/browsing_data/content/conditional_cache_counting_helper.h"
@@ -249,7 +249,7 @@ void StorageHandler::UpdateBrowsingDataSize() {
new BrowsingDataCookieHelper(storage_partition),
new BrowsingDataDatabaseHelper(profile_),
new BrowsingDataLocalStorageHelper(profile_),
- new BrowsingDataAppCacheHelper(profile_),
+ new BrowsingDataAppCacheHelper(storage_partition->GetAppCacheService()),
new BrowsingDataIndexedDBHelper(
storage_partition->GetIndexedDBContext()),
BrowsingDataFileSystemHelper::Create(
@@ -363,7 +363,7 @@ void StorageHandler::UpdateOtherUsersSize() {
if (user->is_active())
continue;
other_users_.push_back(user);
- DBusThreadManager::Get()->GetCryptohomeClient()->GetAccountDiskUsage(
+ CryptohomeClient::Get()->GetAccountDiskUsage(
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 9b7cf3f1d55..3a383f4c89c 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
@@ -12,6 +12,9 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/chromeos/login/quick_unlock/auth_token.h"
+#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
+#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
@@ -228,6 +231,18 @@ void FingerprintHandler::HandleGetNumFingerprints(const base::ListValue* args) {
void FingerprintHandler::HandleStartEnroll(const base::ListValue* args) {
AllowJavascript();
+ std::string auth_token;
+ CHECK(args->GetString(0, &auth_token));
+
+ // Auth token expiration will trigger password prompt.
+ // Silently fail if auth token is incorrect.
+ quick_unlock::QuickUnlockStorage* quick_unlock_storage =
+ quick_unlock::QuickUnlockFactory::GetForProfile(profile_);
+ if (!quick_unlock_storage->GetAuthToken())
+ return;
+ if (auth_token != quick_unlock_storage->GetAuthToken()->Identifier())
+ return;
+
// Determines what the newly added fingerprint's name should be.
for (int i = 1; i <= kMaxAllowedFingerprints; ++i) {
std::string fingerprint_name = l10n_util::GetStringFUTF8(
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 4ea6720e436..f160f963bc3 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
@@ -14,6 +14,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h"
#include "chromeos/constants/chromeos_switches.h"
+#include "chromeos/services/assistant/public/mojom/constants.mojom.h"
#include "components/arc/arc_prefs.h"
#include "components/arc/arc_service_manager.h"
#include "content/public/browser/browser_context.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
index 7b5b6b021fa..6d0b2214df2 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
@@ -17,11 +17,11 @@
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
-#include "components/arc/arc_bridge_service.h"
#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/arc/session/arc_bridge_service.h"
+#include "components/arc/session/connection_holder.h"
#include "components/onc/onc_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
index 31a51283808..8d03f47642a 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc
@@ -10,6 +10,7 @@
#include "base/values.h"
#include "chrome/browser/chromeos/android_sms/android_sms_pairing_state_tracker_impl.h"
#include "chrome/browser/chromeos/android_sms/android_sms_urls.h"
+#include "chrome/browser/chromeos/login/quick_unlock/auth_token.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
#include "chrome/browser/profiles/profile.h"
@@ -410,8 +411,8 @@ bool MultideviceHandler::IsAuthTokenValid(const std::string& auth_token) {
Profile* profile = Profile::FromWebUI(web_ui());
quick_unlock::QuickUnlockStorage* quick_unlock_storage =
chromeos::quick_unlock::QuickUnlockFactory::GetForProfile(profile);
- return !quick_unlock_storage->GetAuthTokenExpired() &&
- auth_token == quick_unlock_storage->GetAuthToken();
+ return quick_unlock_storage->GetAuthToken() &&
+ auth_token == quick_unlock_storage->GetAuthToken()->Identifier();
}
multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc
new file mode 100644
index 00000000000..f5ae7950e4f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.cc
@@ -0,0 +1,245 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h"
+
+#include <stddef.h>
+
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
+#include "base/metrics/histogram_macros.h"
+#include "build/build_config.h"
+#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
+#include "chrome/browser/ui/webui/certificates_handler.h"
+#include "chrome/browser/ui/webui/dark_mode_handler.h"
+#include "chrome/browser/ui/webui/managed_ui_handler.h"
+#include "chrome/browser/ui/webui/metrics_handler.h"
+#include "chrome/browser/ui/webui/settings/about_handler.h"
+#include "chrome/browser/ui/webui/settings/accessibility_main_handler.h"
+#include "chrome/browser/ui/webui/settings/appearance_handler.h"
+#include "chrome/browser/ui/webui/settings/browser_lifetime_handler.h"
+#include "chrome/browser/ui/webui/settings/downloads_handler.h"
+#include "chrome/browser/ui/webui/settings/extension_control_handler.h"
+#include "chrome/browser/ui/webui/settings/font_handler.h"
+#include "chrome/browser/ui/webui/settings/languages_handler.h"
+#include "chrome/browser/ui/webui/settings/on_startup_handler.h"
+#include "chrome/browser/ui/webui/settings/people_handler.h"
+#include "chrome/browser/ui/webui/settings/profile_info_handler.h"
+#include "chrome/browser/ui/webui/settings/protocol_handlers_handler.h"
+#include "chrome/browser/ui/webui/settings/reset_settings_handler.h"
+#include "chrome/browser/ui/webui/settings/search_engines_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_cookies_view_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_import_data_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_localized_strings_provider.h"
+#include "chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_security_key_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_ui.h"
+#include "chrome/browser/ui/webui/settings/site_settings_handler.h"
+#include "chrome/browser/web_applications/system_web_app_manager.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/webui_url_constants.h"
+#include "chrome/grit/browser_resources.h"
+#include "chrome/grit/os_settings_resources.h"
+#include "chrome/grit/os_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_ui_data_source.h"
+#include "content/public/common/content_features.h"
+
+#if defined(FULL_SAFE_BROWSING)
+#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
+#include "chrome/browser/ui/webui/settings/change_password_handler.h"
+#endif
+
+namespace chromeos {
+namespace settings {
+
+// static
+void OSSettingsUI::RegisterProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(::prefs::kImportDialogAutofillFormData, true);
+ registry->RegisterBooleanPref(::prefs::kImportDialogBookmarks, true);
+ registry->RegisterBooleanPref(::prefs::kImportDialogHistory, true);
+ registry->RegisterBooleanPref(::prefs::kImportDialogSavedPasswords, true);
+ registry->RegisterBooleanPref(::prefs::kImportDialogSearchEngine, true);
+}
+
+OSSettingsUI::OSSettingsUI(content::WebUI* web_ui)
+ : content::WebUIController(web_ui),
+ WebContentsObserver(web_ui->GetWebContents()) {
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource* html_source =
+ content::WebUIDataSource::Create(chrome::kChromeUIOSSettingsHost);
+
+ ::settings::SettingsUI::InitOSWebUIHandlers(profile, web_ui, html_source);
+
+ // TODO(jamescook): Remove after basic_page.html is forked for OS settings.
+ html_source->AddBoolean("showOSSettings", true);
+
+#if BUILDFLAG(OPTIMIZE_WEBUI)
+ std::vector<std::string> exclude_from_gzip;
+#endif
+
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::AppearanceHandler>(web_ui));
+
+#if defined(USE_NSS_CERTS)
+ AddSettingsPageUIHandler(
+ std::make_unique<certificate_manager::CertificatesHandler>());
+#elif defined(OS_WIN) || defined(OS_MACOSX)
+ AddSettingsPageUIHandler(std::make_unique<NativeCertificatesHandler>());
+#endif // defined(USE_NSS_CERTS)
+
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::AccessibilityMainHandler>());
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::BrowserLifetimeHandler>());
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::ClearBrowsingDataHandler>(web_ui));
+ AddSettingsPageUIHandler(std::make_unique<::settings::CookiesViewHandler>());
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::DownloadsHandler>(profile));
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::ExtensionControlHandler>());
+ AddSettingsPageUIHandler(std::make_unique<::settings::FontHandler>(web_ui));
+ AddSettingsPageUIHandler(std::make_unique<::settings::ImportDataHandler>());
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::LanguagesHandler>(web_ui));
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::MediaDevicesSelectionHandler>(profile));
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::OnStartupHandler>(profile));
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::PeopleHandler>(profile));
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::ProfileInfoHandler>(profile));
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::ProtocolHandlersHandler>());
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::SearchEnginesHandler>(profile));
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::SiteSettingsHandler>(profile));
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::StartupPagesHandler>(web_ui));
+ AddSettingsPageUIHandler(std::make_unique<::settings::SecurityKeysHandler>());
+
+ bool password_protection_available = false;
+#if defined(FULL_SAFE_BROWSING)
+ safe_browsing::ChromePasswordProtectionService* password_protection =
+ safe_browsing::ChromePasswordProtectionService::
+ GetPasswordProtectionService(profile);
+ password_protection_available = !!password_protection;
+ if (password_protection) {
+ AddSettingsPageUIHandler(
+ std::make_unique<::settings::ChangePasswordHandler>(
+ profile, password_protection));
+ }
+#endif
+
+ html_source->AddBoolean("passwordProtectionAvailable",
+ password_protection_available);
+
+ html_source->AddBoolean("unifiedConsentEnabled",
+ unified_consent::IsUnifiedConsentFeatureEnabled());
+
+ html_source->AddBoolean(
+ "navigateToGooglePasswordManager",
+ ShouldManagePasswordsinGooglePasswordManager(profile));
+
+ html_source->AddBoolean("showImportPasswords",
+ base::FeatureList::IsEnabled(
+ password_manager::features::kPasswordImport));
+
+ AddSettingsPageUIHandler(
+ base::WrapUnique(::settings::AboutHandler::Create(html_source, profile)));
+ AddSettingsPageUIHandler(base::WrapUnique(
+ ::settings::ResetSettingsHandler::Create(html_source, profile)));
+
+ // Add the metrics handler to write uma stats.
+ web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
+
+ // Add the System Web App resources for Settings.
+ // TODO(jamescook|calamity): Migrate to chromeos::settings::OSSettingsUI.
+ if (web_app::SystemWebAppManager::IsEnabled()) {
+ html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192);
+ html_source->AddResourcePath("pwa.html", IDR_PWA_HTML);
+#if BUILDFLAG(OPTIMIZE_WEBUI)
+ exclude_from_gzip.push_back("icon-192.png");
+ exclude_from_gzip.push_back("pwa.html");
+#endif // BUILDFLAG(OPTIMIZE_WEBUI)
+ }
+
+#if BUILDFLAG(OPTIMIZE_WEBUI)
+ const bool use_polymer_2 =
+ base::FeatureList::IsEnabled(::features::kWebUIPolymer2);
+ html_source->AddResourcePath("crisper.js", IDR_OS_SETTINGS_CRISPER_JS);
+ html_source->AddResourcePath("lazy_load.crisper.js",
+ IDR_OS_SETTINGS_LAZY_LOAD_CRISPER_JS);
+ html_source->AddResourcePath(
+ "lazy_load.html", use_polymer_2
+ ? IDR_OS_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML
+ : IDR_OS_SETTINGS_LAZY_LOAD_VULCANIZED_HTML);
+ html_source->SetDefaultResource(use_polymer_2
+ ? IDR_OS_SETTINGS_VULCANIZED_P2_HTML
+ : IDR_OS_SETTINGS_VULCANIZED_HTML);
+ html_source->UseGzip(base::BindRepeating(
+ [](const std::vector<std::string>& excluded_paths,
+ const std::string& path) {
+ return !base::ContainsValue(excluded_paths, path);
+ },
+ std::move(exclude_from_gzip)));
+ html_source->AddResourcePath("manifest.json", IDR_OS_SETTINGS_MANIFEST);
+#else
+ // Add all settings resources.
+ for (size_t i = 0; i < kOsSettingsResourcesSize; ++i) {
+ html_source->AddResourcePath(kOsSettingsResources[i].name,
+ kOsSettingsResources[i].value);
+ }
+ html_source->SetDefaultResource(IDR_OS_SETTINGS_SETTINGS_HTML);
+#endif
+
+ ::settings::AddLocalizedStrings(html_source, profile);
+
+ DarkModeHandler::Initialize(web_ui, html_source);
+ ManagedUIHandler::Initialize(web_ui, html_source);
+
+ content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
+ html_source);
+}
+
+OSSettingsUI::~OSSettingsUI() {}
+
+void OSSettingsUI::AddSettingsPageUIHandler(
+ std::unique_ptr<content::WebUIMessageHandler> handler) {
+ DCHECK(handler);
+ web_ui()->AddMessageHandler(std::move(handler));
+}
+
+void OSSettingsUI::DidStartNavigation(
+ content::NavigationHandle* navigation_handle) {
+ if (navigation_handle->IsSameDocument())
+ return;
+
+ load_start_time_ = base::Time::Now();
+}
+
+void OSSettingsUI::DocumentLoadedInFrame(
+ content::RenderFrameHost* render_frame_host) {
+ // TODO(crbug/950007): Create new load histograms
+}
+
+void OSSettingsUI::DocumentOnLoadCompletedInMainFrame() {
+ // TODO(crbug/950007): Create new load histograms
+}
+
+} // namespace settings
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.h b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h
index f9182a0af66..d62bbfaee26 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h
@@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_MD_SETTINGS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_MD_SETTINGS_UI_H_
-
-#include <unordered_set>
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_UI_H_
#include "base/macros.h"
#include "base/time/time.h"
@@ -20,22 +18,23 @@ namespace user_prefs {
class PrefRegistrySyncable;
}
+namespace chromeos {
namespace settings {
// The WebUI handler for chrome://settings.
-class MdSettingsUI : public content::WebUIController,
+class OSSettingsUI : public content::WebUIController,
public content::WebContentsObserver {
public:
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
- explicit MdSettingsUI(content::WebUI* web_ui);
- ~MdSettingsUI() override;
+ explicit OSSettingsUI(content::WebUI* web_ui);
+ ~OSSettingsUI() override;
// content::WebContentsObserver:
void DidStartNavigation(
content::NavigationHandle* navigation_handle) override;
void DocumentLoadedInFrame(
- content::RenderFrameHost *render_frame_host) override;
+ content::RenderFrameHost* render_frame_host) override;
void DocumentOnLoadCompletedInMainFrame() override;
private:
@@ -44,9 +43,10 @@ class MdSettingsUI : public content::WebUIController,
base::Time load_start_time_;
- DISALLOW_COPY_AND_ASSIGN(MdSettingsUI);
+ DISALLOW_COPY_AND_ASSIGN(OSSettingsUI);
};
} // namespace settings
+} // namespace chromeos
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_MD_SETTINGS_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_OS_SETTINGS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
index eeeb1fa6ae0..4eada935afc 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
@@ -42,6 +42,7 @@
#include "components/signin/core/browser/signin_pref_names.h"
#include "components/strings/grit/components_strings.h"
#include "components/sync/base/passphrase_enums.h"
+#include "components/sync/base/user_selectable_type.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_service_utils.h"
#include "components/sync/driver/sync_user_settings.h"
@@ -84,7 +85,7 @@ struct SyncConfigInfo {
bool encrypt_all;
bool sync_everything;
- syncer::ModelTypeSet data_types;
+ syncer::UserSelectableTypeSet selected_types;
bool payments_integration_enabled;
std::string passphrase;
bool set_new_passphrase;
@@ -119,18 +120,16 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
return false;
}
- syncer::ModelTypeNameMap type_names = syncer::GetUserSelectableTypeNameMap();
-
- for (syncer::ModelTypeNameMap::const_iterator it = type_names.begin();
- it != type_names.end(); ++it) {
- std::string key_name = it->second + std::string("Synced");
+ for (syncer::UserSelectableType type : syncer::UserSelectableTypeSet::All()) {
+ std::string key_name =
+ syncer::GetUserSelectableTypeName(type) + std::string("Synced");
bool sync_value;
if (!result->GetBoolean(key_name, &sync_value)) {
DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name;
return false;
}
if (sync_value)
- config->data_types.Put(it->first);
+ config->selected_types.Put(type);
}
// Encryption settings.
@@ -195,6 +194,55 @@ base::Value GetAccountValue(const AccountInfo& account) {
}
#endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
+base::string16 GetEnterPassphraseBody(syncer::PassphraseType passphrase_type,
+ base::Time passphrase_time) {
+ DCHECK(syncer::IsExplicitPassphrase(passphrase_type));
+ switch (passphrase_type) {
+ case syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE:
+ if (passphrase_time.is_null()) {
+ return GetStringUTF16(IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY);
+ }
+ return GetStringFUTF16(IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY_WITH_DATE,
+ base::ASCIIToUTF16(chrome::kSyncErrorsHelpURL),
+ base::TimeFormatShortDate(passphrase_time));
+ case syncer::PassphraseType::CUSTOM_PASSPHRASE:
+ if (passphrase_time.is_null()) {
+ return GetStringUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY);
+ }
+ return GetStringFUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY_WITH_DATE,
+ base::ASCIIToUTF16(chrome::kSyncErrorsHelpURL),
+ base::TimeFormatShortDate(passphrase_time));
+ case syncer::PassphraseType::IMPLICIT_PASSPHRASE:
+ case syncer::PassphraseType::KEYSTORE_PASSPHRASE:
+ case syncer::PassphraseType::PASSPHRASE_TYPE_SIZE:
+ break;
+ }
+ NOTREACHED();
+ return base::string16();
+}
+
+base::string16 GetFullEncryptionBody(syncer::PassphraseType passphrase_type,
+ base::Time passphrase_time) {
+ DCHECK(syncer::IsExplicitPassphrase(passphrase_type));
+ if (passphrase_time.is_null()) {
+ return GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM);
+ }
+ switch (passphrase_type) {
+ case syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE:
+ return GetStringFUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_GOOGLE_WITH_DATE,
+ base::TimeFormatShortDate(passphrase_time));
+ case syncer::PassphraseType::CUSTOM_PASSPHRASE:
+ return GetStringFUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM_WITH_DATE,
+ base::TimeFormatShortDate(passphrase_time));
+ case syncer::PassphraseType::IMPLICIT_PASSPHRASE:
+ case syncer::PassphraseType::KEYSTORE_PASSPHRASE:
+ case syncer::PassphraseType::PASSPHRASE_TYPE_SIZE:
+ break;
+ }
+ NOTREACHED();
+ return base::string16();
+}
+
} // namespace
namespace settings {
@@ -448,8 +496,8 @@ void PeopleHandler::HandleSetDatatypes(const base::ListValue* args) {
return;
}
- service->GetUserSettings()->SetChosenDataTypes(configuration.sync_everything,
- configuration.data_types);
+ service->GetUserSettings()->SetSelectedTypes(configuration.sync_everything,
+ configuration.selected_types);
// Choosing data types to sync never fails.
ResolveJavascriptCallback(*callback_id, base::Value(kConfigurePageStatus));
@@ -620,8 +668,12 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) {
if (service && !sync_blocker_)
sync_blocker_ = service->GetSetupInProgressHandle();
- // TODO(treib): Should we also call SetSyncRequested(true) here? That's what
- // happens in the non-Unity code path.
+ // Mark Sync as requested by the user. It might already be requested, but
+ // it's not if this is either the first time the user is setting up Sync, or
+ // Sync was set up but then was reset via the dashboard. This also pokes the
+ // SyncService to start up immediately, i.e. bypass deferred startup.
+ if (service)
+ service->GetUserSettings()->SetSyncRequested(true);
GetLoginUIService()->SetLoginUI(this);
@@ -629,6 +681,11 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) {
Observe(web_ui()->GetWebContents());
PushSyncPrefs();
+
+ // Focus the web contents in case the location bar was focused before. This
+ // makes sure that page elements for resolving sync errors can be focused.
+ web_ui()->GetWebContents()->Focus();
+
// Always let the page open when unified consent is enabled.
return;
}
@@ -664,13 +721,10 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) {
if (!service->IsEngineInitialized() ||
!service->GetUserSettings()->IsSyncRequested()) {
- // 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_ = std::make_unique<SyncStartupTracker>(service, this);
// SetSyncRequested(true) does two things:
- // 1) If DISABLE_REASON_USER_CHOICE is set (meaning that Sync was reset via
- // the dashboard), clears it.
+ // 1) As the name says, it marks Sync as requested by the user (it might not
+ // be requested yet because either this is the first time they're setting
+ // it up, or Sync was reset via the dashboard).
// 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
@@ -689,6 +743,12 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) {
SyncStartupTracker::SYNC_STARTUP_ERROR) {
DisplaySpinner();
}
+
+ // Finally, wait for the Sync engine to get initialized. Note that if it is
+ // already initialized (probably because Sync-the-transport was already
+ // running), then this will call us back immediately.
+ sync_startup_tracker_ = std::make_unique<SyncStartupTracker>(service, this);
+
return;
}
@@ -767,14 +827,9 @@ void PeopleHandler::HandlePauseSync(const base::ListValue* args) {
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile_);
DCHECK(identity_manager->HasPrimaryAccount());
- CoreAccountInfo primary_account_info =
- identity_manager->GetPrimaryAccountInfo();
-
- identity_manager->GetAccountsMutator()->AddOrUpdateAccount(
- primary_account_info.gaia, primary_account_info.email,
- OAuth2TokenServiceDelegate::kInvalidRefreshToken,
- primary_account_info.is_under_advanced_protection,
- signin_metrics::SourceForRefreshTokenOperation::kSettings_PauseSync);
+ identity_manager->GetAccountsMutator()
+ ->InvalidateRefreshTokenForPrimaryAccount(
+ signin_metrics::SourceForRefreshTokenOperation::kSettings_PauseSync);
}
#endif
@@ -795,12 +850,12 @@ void PeopleHandler::CloseSyncSetup() {
// Clear the sync startup tracker, since the setup wizard is being closed.
sync_startup_tracker_.reset();
- syncer::SyncService* sync_service = GetSyncService();
-
// LoginUIService can be nullptr if page is brought up in incognito mode
// (i.e. if the user is running in guest mode in cros and brings up settings).
LoginUIService* service = GetLoginUIService();
if (service) {
+ syncer::SyncService* sync_service = GetSyncService();
+
// Don't log a cancel event if the sync setup dialog is being
// automatically closed due to an auth error.
if ((service->current_login_ui() == this) &&
@@ -823,7 +878,7 @@ void PeopleHandler::CloseSyncSetup() {
#if !defined(OS_CHROMEOS)
// Sign out the user on desktop Chrome if they click cancel during
// initial setup.
- if (sync_service->IsFirstSetupInProgress()) {
+ if (!sync_service->GetUserSettings()->IsFirstSetupComplete()) {
IdentityManagerFactory::GetForProfile(profile_)
->GetPrimaryAccountMutator()
->ClearPrimaryAccount(
@@ -852,8 +907,7 @@ void PeopleHandler::CloseSyncSetup() {
}
void PeopleHandler::InitializeSyncBlocker() {
- if (!web_ui())
- return;
+ DCHECK(web_ui());
WebContents* web_contents = web_ui()->GetWebContents();
if (web_contents) {
syncer::SyncService* service = GetSyncService();
@@ -877,11 +931,19 @@ void PeopleHandler::CloseUI() {
void PeopleHandler::OnPrimaryAccountSet(
const CoreAccountInfo& primary_account_info) {
+ // After a primary account was set, the Sync setup will start soon. Grab a
+ // SetupInProgressHandle right now to avoid a temporary "missing Sync
+ // confirmation" error in the avatar menu. See crbug.com/928696.
+ syncer::SyncService* service = GetSyncService();
+ if (service && !sync_blocker_)
+ sync_blocker_ = service->GetSetupInProgressHandle();
+
UpdateSyncStatus();
}
void PeopleHandler::OnPrimaryAccountCleared(
const CoreAccountInfo& previous_primary_account_info) {
+ sync_blocker_.reset();
UpdateSyncStatus();
}
@@ -897,14 +959,15 @@ void PeopleHandler::BeforeUnloadDialogCancelled() {
// The before unload dialog is only shown during the first sync setup.
DCHECK(IdentityManagerFactory::GetForProfile(profile_)->HasPrimaryAccount());
syncer::SyncService* service = GetSyncService();
- DCHECK(service && service->IsFirstSetupInProgress());
+ DCHECK(service && service->IsSetupInProgress() &&
+ !service->GetUserSettings()->IsFirstSetupComplete());
base::RecordAction(
base::UserMetricsAction("Signin_Signin_CancelAbortAdvancedSyncSettings"));
}
-std::unique_ptr<base::DictionaryValue>
-PeopleHandler::GetSyncStatusDictionary() {
+std::unique_ptr<base::DictionaryValue> PeopleHandler::GetSyncStatusDictionary()
+ const {
std::unique_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue);
if (profile_->IsGuestSession()) {
// Cannot display signin status when running in guest mode on chromeos
@@ -942,10 +1005,12 @@ PeopleHandler::GetSyncStatusDictionary() {
sync_status->SetBoolean(
"signinAllowed", profile_->GetPrefs()->GetBoolean(prefs::kSigninAllowed));
sync_status->SetBoolean("syncSystemEnabled", (service != nullptr));
- sync_status->SetBoolean("setupInProgress",
- service && !disallowed_by_policy &&
- service->IsFirstSetupInProgress() &&
- identity_manager->HasPrimaryAccount());
+ // TODO(crbug.com/953641): Rename "setupInProgress" to "firstSetupInProgress".
+ sync_status->SetBoolean(
+ "setupInProgress",
+ service && !disallowed_by_policy && service->IsSetupInProgress() &&
+ !service->GetUserSettings()->IsFirstSetupComplete() &&
+ identity_manager->HasPrimaryAccount());
base::string16 status_label;
base::string16 link_label;
@@ -986,8 +1051,6 @@ void PeopleHandler::PushSyncPrefs() {
}
configuring_sync_ = true;
- DCHECK(service->IsEngineInitialized())
- << "Cannot configure sync until the sync engine is initialized";
// Setup args for the sync configure screen:
// syncAllDataTypes: true if the user wants to sync everything
@@ -998,86 +1061,48 @@ void PeopleHandler::PushSyncPrefs() {
// encryptAllData: true if user wants to encrypt all data (not just
// passwords)
// passphraseRequired: true if a passphrase is needed to start sync
- // passphraseTypeIsCustom: true if the passphrase type is custom
//
base::DictionaryValue args;
+ syncer::SyncUserSettings* sync_user_settings = service->GetUserSettings();
// Tell the UI layer which data types are registered/enabled by the user.
- const syncer::ModelTypeSet registered_types =
- service->GetRegisteredDataTypes();
- const syncer::ModelTypeSet preferred_types = service->GetPreferredDataTypes();
- const syncer::ModelTypeSet enforced_types = service->GetForcedDataTypes();
- syncer::ModelTypeNameMap type_names = syncer::GetUserSelectableTypeNameMap();
- for (syncer::ModelTypeNameMap::const_iterator it = type_names.begin();
- it != type_names.end(); ++it) {
- syncer::ModelType sync_type = it->first;
- const std::string key_name = it->second;
- args.SetBoolean(key_name + "Registered", registered_types.Has(sync_type));
- args.SetBoolean(key_name + "Synced", preferred_types.Has(sync_type));
- args.SetBoolean(key_name + "Enforced", enforced_types.Has(sync_type));
- // TODO(treib): How do we want to handle pref groups, i.e. when only some of
- // the sync types behind a checkbox are force-enabled? crbug.com/403326
+ const syncer::UserSelectableTypeSet registered_types =
+ sync_user_settings->GetRegisteredSelectableTypes();
+ const syncer::UserSelectableTypeSet selected_types =
+ sync_user_settings->GetSelectedTypes();
+ const syncer::UserSelectableTypeSet enforced_types =
+ sync_user_settings->GetForcedTypes();
+ for (syncer::UserSelectableType type : syncer::UserSelectableTypeSet::All()) {
+ const std::string type_name = syncer::GetUserSelectableTypeName(type);
+ args.SetBoolean(type_name + "Registered", registered_types.Has(type));
+ args.SetBoolean(type_name + "Synced", selected_types.Has(type));
+ args.SetBoolean(type_name + "Enforced", enforced_types.Has(type));
}
args.SetBoolean("syncAllDataTypes",
- service->GetUserSettings()->IsSyncEverythingEnabled());
+ sync_user_settings->IsSyncEverythingEnabled());
args.SetBoolean(
"paymentsIntegrationEnabled",
autofill::prefs::IsPaymentsIntegrationEnabled(profile_->GetPrefs()));
args.SetBoolean("encryptAllData",
- service->GetUserSettings()->IsEncryptEverythingEnabled());
+ sync_user_settings->IsEncryptEverythingEnabled());
args.SetBoolean("encryptAllDataAllowed",
- service->GetUserSettings()->IsEncryptEverythingAllowed());
+ sync_user_settings->IsEncryptEverythingAllowed());
// We call IsPassphraseRequired() here, instead of calling
// IsPassphraseRequiredForDecryption(), because we want to show the passphrase
// UI even if no encrypted data types are enabled.
args.SetBoolean("passphraseRequired",
- service->GetUserSettings()->IsPassphraseRequired());
-
- // To distinguish between PassphraseType::FROZEN_IMPLICIT_PASSPHRASE and
- // PassphraseType::CUSTOM_PASSPHRASE
- // we only set passphraseTypeIsCustom for PassphraseType::CUSTOM_PASSPHRASE.
- args.SetBoolean("passphraseTypeIsCustom",
- service->GetUserSettings()->GetPassphraseType() ==
- syncer::PassphraseType::CUSTOM_PASSPHRASE);
- base::Time passphrase_time =
- service->GetUserSettings()->GetExplicitPassphraseTime();
+ sync_user_settings->IsPassphraseRequired());
+
syncer::PassphraseType passphrase_type =
- service->GetUserSettings()->GetPassphraseType();
- if (!passphrase_time.is_null()) {
- base::string16 passphrase_time_str =
- base::TimeFormatShortDate(passphrase_time);
- args.SetString(
- "enterPassphraseBody",
- GetStringFUTF16(IDS_SYNC_ENTER_PASSPHRASE_BODY_WITH_DATE,
- base::ASCIIToUTF16(chrome::kSyncErrorsHelpURL),
- passphrase_time_str));
- args.SetString(
- "enterGooglePassphraseBody",
- GetStringFUTF16(IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY_WITH_DATE,
- base::ASCIIToUTF16(chrome::kSyncErrorsHelpURL),
- passphrase_time_str));
- switch (passphrase_type) {
- case syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE:
- args.SetString(
- "fullEncryptionBody",
- GetStringFUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_GOOGLE_WITH_DATE,
- passphrase_time_str));
- break;
- case syncer::PassphraseType::CUSTOM_PASSPHRASE:
- args.SetString(
- "fullEncryptionBody",
- GetStringFUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM_WITH_DATE,
- passphrase_time_str));
- break;
- default:
- args.SetString("fullEncryptionBody",
- GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM));
- break;
- }
- } else if (passphrase_type == syncer::PassphraseType::CUSTOM_PASSPHRASE) {
+ sync_user_settings->GetPassphraseType();
+ if (syncer::IsExplicitPassphrase(passphrase_type)) {
+ base::Time passphrase_time =
+ sync_user_settings->GetExplicitPassphraseTime();
+ args.SetString("enterPassphraseBody",
+ GetEnterPassphraseBody(passphrase_type, passphrase_time));
args.SetString("fullEncryptionBody",
- GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM));
+ GetFullEncryptionBody(passphrase_type, passphrase_time));
}
FireWebUIListener("sync-prefs-changed", args);
@@ -1094,7 +1119,21 @@ void PeopleHandler::UpdateSyncStatus() {
void PeopleHandler::MarkFirstSetupComplete() {
syncer::SyncService* service = GetSyncService();
// The sync service may be nullptr if it has been just disabled by policy.
- if (!service || service->GetUserSettings()->IsFirstSetupComplete())
+ if (!service)
+ return;
+
+ // Sync is usually already requested at this point, but it might not be if
+ // Sync was reset from the dashboard while this page was open. (In most
+ // situations, resetting Sync also signs the user out of Chrome so this
+ // doesn't come up, but on ChromeOS or for managed (enterprise) accounts
+ // signout isn't possible.)
+ // Note that this has to happen *before* checking if first-time setup is
+ // already marked complete, because on some platforms (e.g. ChromeOS) that
+ // gets set automatically.
+ service->GetUserSettings()->SetSyncRequested(true);
+
+ // If the first-time setup is already complete, there's nothing else to do.
+ if (service->GetUserSettings()->IsFirstSetupComplete())
return;
unified_consent::metrics::RecordSyncSetupDataTypesHistrogam(
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.h b/chromium/chrome/browser/ui/webui/settings/people_handler.h
index 8c8774d54c3..010e9ed345f 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.h
@@ -60,25 +60,32 @@ class PeopleHandler : public SettingsPageUIHandler,
explicit PeopleHandler(Profile* profile);
~PeopleHandler() override;
+ protected:
// Terminates the sync setup flow.
void CloseSyncSetup();
- protected:
bool is_configuring_sync() const { return configuring_sync_; }
private:
friend class PeopleHandlerTest;
+ friend class PeopleHandlerTest_UnifiedConsentDisabled;
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
DisplayConfigureWithEngineDisabledAndCancel);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest_UnifiedConsentDisabled,
+ DisplayConfigureWithEngineDisabledAndCancel);
FRIEND_TEST_ALL_PREFIXES(
PeopleHandlerTest,
DisplayConfigureWithEngineDisabledAndCancelAfterSigninSuccess);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest_UnifiedConsentDisabled,
DisplayConfigureWithEngineDisabledAndSigninFailed);
FRIEND_TEST_ALL_PREFIXES(
PeopleHandlerTest,
DisplayConfigureWithEngineDisabledAndSyncStartupCompleted);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled);
+ FRIEND_TEST_ALL_PREFIXES(
+ PeopleHandlerTest_UnifiedConsentDisabled,
+ DisplayConfigureWithEngineDisabledAndSyncStartupCompleted);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest_UnifiedConsentDisabled,
+ HandleSetupUIWhenSyncDisabled);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
ShowSetupCustomPassphraseRequired);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSetupEncryptAll);
@@ -89,9 +96,11 @@ class PeopleHandler : public SettingsPageUIHandler,
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSetupSyncEverything);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
ShowSetupSyncForAllTypesIndividually);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSigninOnAuthError);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest_UnifiedConsentDisabled,
+ ShowSigninOnAuthError);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSyncSetup);
- FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest_UnifiedConsentDisabled,
+ DontShowSyncSetupWhenNotSignedIn);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncEverything);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestSyncAllManually);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, TestPassphraseStillRequired);
@@ -109,9 +118,15 @@ class PeopleHandler : public SettingsPageUIHandler,
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
AcquireSyncBlockerWhenLoadingSyncSettingsSubpage);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest, RestartSyncAfterDashboardClear);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest_UnifiedConsentDisabled,
+ RestartSyncAfterDashboardClear);
FRIEND_TEST_ALL_PREFIXES(
PeopleHandlerTest,
RestartSyncAfterDashboardClearWithStandaloneTransport);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
+ DashboardClearWhileSettingsOpen_ConfirmSoon);
+ FRIEND_TEST_ALL_PREFIXES(PeopleHandlerTest,
+ DashboardClearWhileSettingsOpen_ConfirmLater);
FRIEND_TEST_ALL_PREFIXES(PeopleHandlerDiceUnifiedConsentTest,
StoredAccountsList);
@@ -145,7 +160,7 @@ class PeopleHandler : public SettingsPageUIHandler,
// Returns a newly created dictionary with a number of properties that
// correspond to the status of sync.
- std::unique_ptr<base::DictionaryValue> GetSyncStatusDictionary();
+ std::unique_ptr<base::DictionaryValue> GetSyncStatusDictionary() const;
// Helper routine that gets the SyncService associated with the parent
// profile.
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 e4b50c4ef5f..a14675b46be 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc
@@ -15,11 +15,11 @@
#include "base/stl_util.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "chrome/browser/defaults.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/signin/scoped_account_consistency.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
-#include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
@@ -32,13 +32,15 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h"
-#include "components/sync_preferences/pref_service_syncable.h"
+#include "components/sync/base/passphrase_enums.h"
+#include "components/sync/driver/mock_sync_service.h"
+#include "components/sync/driver/sync_user_settings_impl.h"
+#include "components/sync/driver/sync_user_settings_mock.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"
#include "content/public/test/navigation_simulator.h"
-#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_web_ui.h"
#include "content/public/test/web_contents_tester.h"
@@ -48,27 +50,25 @@
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::_;
+using ::testing::ByMove;
+using ::testing::Const;
using ::testing::Invoke;
using ::testing::Mock;
using ::testing::Return;
using ::testing::Values;
-using browser_sync::ProfileSyncService;
-using browser_sync::ProfileSyncServiceMock;
-
-typedef GoogleServiceAuthError AuthError;
namespace {
-MATCHER_P(ModelTypeSetMatches, value, "") {
+MATCHER_P(UserSelectableTypeSetMatches, value, "") {
return arg == value;
}
const char kTestUser[] = "chrome.p13n.test@gmail.com";
const char kTestCallbackId[] = "test-callback-id";
-// Returns a ModelTypeSet with all user selectable types set.
-syncer::ModelTypeSet GetAllTypes() {
- return syncer::UserSelectableTypes();
+// Returns a UserSelectableTypeSet with all types set.
+syncer::UserSelectableTypeSet GetAllTypes() {
+ return syncer::UserSelectableTypeSet::All();
}
enum SyncAllDataConfig {
@@ -86,7 +86,7 @@ enum EncryptAllConfig {
// the passed dictionary are added to the json.
std::string GetConfiguration(const base::DictionaryValue* extra_values,
SyncAllDataConfig sync_all,
- syncer::ModelTypeSet types,
+ syncer::UserSelectableTypeSet types,
const std::string& passphrase,
EncryptAllConfig encrypt_all) {
base::DictionaryValue result;
@@ -97,15 +97,22 @@ std::string GetConfiguration(const base::DictionaryValue* extra_values,
if (!passphrase.empty())
result.SetString("passphrase", passphrase);
// Add all of our data types.
- result.SetBoolean("appsSynced", types.Has(syncer::APPS));
- result.SetBoolean("autofillSynced", types.Has(syncer::AUTOFILL));
- result.SetBoolean("bookmarksSynced", types.Has(syncer::BOOKMARKS));
- result.SetBoolean("extensionsSynced", types.Has(syncer::EXTENSIONS));
- result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS));
- result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES));
- result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS));
- result.SetBoolean("themesSynced", types.Has(syncer::THEMES));
- result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS));
+ result.SetBoolean("appsSynced", types.Has(syncer::UserSelectableType::kApps));
+ result.SetBoolean("autofillSynced",
+ types.Has(syncer::UserSelectableType::kAutofill));
+ result.SetBoolean("bookmarksSynced",
+ types.Has(syncer::UserSelectableType::kBookmarks));
+ result.SetBoolean("extensionsSynced",
+ types.Has(syncer::UserSelectableType::kExtensions));
+ result.SetBoolean("passwordsSynced",
+ types.Has(syncer::UserSelectableType::kPasswords));
+ result.SetBoolean("preferencesSynced",
+ types.Has(syncer::UserSelectableType::kPreferences));
+ result.SetBoolean("tabsSynced", types.Has(syncer::UserSelectableType::kTabs));
+ result.SetBoolean("themesSynced",
+ types.Has(syncer::UserSelectableType::kThemes));
+ result.SetBoolean("typedUrlsSynced",
+ types.Has(syncer::UserSelectableType::kHistory));
result.SetBoolean("paymentsIntegrationEnabled", false);
std::string args;
base::JSONWriter::Write(result, &args);
@@ -142,17 +149,31 @@ void CheckBool(const base::DictionaryValue* dictionary,
// types.
void CheckConfigDataTypeArguments(const base::DictionaryValue* dictionary,
SyncAllDataConfig config,
- syncer::ModelTypeSet types) {
+ syncer::UserSelectableTypeSet types) {
CheckBool(dictionary, "syncAllDataTypes", config == SYNC_ALL_DATA);
- CheckBool(dictionary, "appsSynced", types.Has(syncer::APPS));
- CheckBool(dictionary, "autofillSynced", types.Has(syncer::AUTOFILL));
- CheckBool(dictionary, "bookmarksSynced", types.Has(syncer::BOOKMARKS));
- CheckBool(dictionary, "extensionsSynced", types.Has(syncer::EXTENSIONS));
- CheckBool(dictionary, "passwordsSynced", types.Has(syncer::PASSWORDS));
- CheckBool(dictionary, "preferencesSynced", types.Has(syncer::PREFERENCES));
- CheckBool(dictionary, "tabsSynced", types.Has(syncer::PROXY_TABS));
- CheckBool(dictionary, "themesSynced", types.Has(syncer::THEMES));
- CheckBool(dictionary, "typedUrlsSynced", types.Has(syncer::TYPED_URLS));
+ CheckBool(dictionary, "appsSynced",
+ types.Has(syncer::UserSelectableType::kApps));
+ CheckBool(dictionary, "autofillSynced",
+ types.Has(syncer::UserSelectableType::kAutofill));
+ CheckBool(dictionary, "bookmarksSynced",
+ types.Has(syncer::UserSelectableType::kBookmarks));
+ CheckBool(dictionary, "extensionsSynced",
+ types.Has(syncer::UserSelectableType::kExtensions));
+ CheckBool(dictionary, "passwordsSynced",
+ types.Has(syncer::UserSelectableType::kPasswords));
+ CheckBool(dictionary, "preferencesSynced",
+ types.Has(syncer::UserSelectableType::kPreferences));
+ CheckBool(dictionary, "tabsSynced",
+ types.Has(syncer::UserSelectableType::kTabs));
+ CheckBool(dictionary, "themesSynced",
+ types.Has(syncer::UserSelectableType::kThemes));
+ CheckBool(dictionary, "typedUrlsSynced",
+ types.Has(syncer::UserSelectableType::kHistory));
+}
+
+std::unique_ptr<KeyedService> BuildMockSyncService(
+ content::BrowserContext* context) {
+ return std::make_unique<testing::NiceMock<syncer::MockSyncService>>();
}
} // namespace
@@ -186,12 +207,12 @@ class TestWebUIProvider
}
};
-// The boolean parameter indicates whether the test is run with ClientOAuth
-// or not. The test parameter is a bool: whether or not to test with/
-// /ClientLogin enabled or not.
class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
public:
- PeopleHandlerTest() = default;
+ PeopleHandlerTest(
+ unified_consent::UnifiedConsentFeatureState unified_consent_state =
+ unified_consent::UnifiedConsentFeatureState::kEnabled)
+ : scoped_unified_consent_(unified_consent_state) {}
void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp();
@@ -204,24 +225,30 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
if (!username.empty())
identity_test_env()->SetPrimaryAccount(username);
- mock_pss_ = static_cast<ProfileSyncServiceMock*>(
+ mock_sync_service_ = static_cast<syncer::MockSyncService*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile(), base::BindRepeating(&BuildMockProfileSyncService)));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), GetPassphraseType())
+ profile(), base::BindRepeating(&BuildMockSyncService)));
+
+ ON_CALL(*mock_sync_service_, IsAuthenticatedAccountPrimary())
+ .WillByDefault(Return(true));
+
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), GetPassphraseType())
.WillByDefault(Return(syncer::PassphraseType::IMPLICIT_PASSPHRASE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), GetExplicitPassphraseTime())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ GetExplicitPassphraseTime())
.WillByDefault(Return(base::Time()));
- ON_CALL(*mock_pss_, GetRegisteredDataTypes())
+ ON_CALL(*mock_sync_service_, GetRegisteredDataTypes())
.WillByDefault(Return(syncer::ModelTypeSet()));
- ON_CALL(*mock_pss_, GetSetupInProgressHandle())
+ ON_CALL(*mock_sync_service_, GetSetupInProgressHandle())
.WillByDefault(
- Invoke(mock_pss_,
- &ProfileSyncServiceMock::GetSetupInProgressHandleConcrete));
-
- mock_pss_->Initialize();
+ Return(ByMove(std::make_unique<syncer::SyncSetupInProgressHandle>(
+ base::BindRepeating(
+ &PeopleHandlerTest::OnSetupInProgressHandleDestroyed,
+ base::Unretained(this))))));
handler_.reset(new TestingPeopleHandler(&web_ui_, profile()));
handler_->AllowJavascript();
+ web_ui_.set_web_contents(web_contents());
}
void TearDown() override {
@@ -242,28 +269,30 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
// Setup the expectations for calls made when displaying the config page.
void SetDefaultExpectationsForConfigPage() {
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_, GetRegisteredDataTypes())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ GetRegisteredSelectableTypes())
.WillByDefault(Return(GetAllTypes()));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncEverythingEnabled())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsSyncEverythingEnabled())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), GetChosenDataTypes())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), GetSelectedTypes())
.WillByDefault(Return(GetAllTypes()));
- ON_CALL(*mock_pss_, GetActiveDataTypes())
- .WillByDefault(Return(GetAllTypes()));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingAllowed())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingEnabled())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingEnabled())
.WillByDefault(Return(false));
}
- void SetupInitializedProfileSyncService() {
- // An initialized ProfileSyncService will have already completed sync setup
- // and will have an initialized sync engine.
- ON_CALL(*mock_pss_, GetTransportState())
+ void SetupInitializedSyncService() {
+ // An initialized SyncService will have already completed sync setup and
+ // will have an initialized sync engine.
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
}
@@ -315,15 +344,17 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
return dictionary;
}
- // It's difficult to notify sync listeners when using a ProfileSyncServiceMock
+ // It's difficult to notify sync listeners when using a MockSyncService
// so this helper routine dispatches an OnStateChanged() notification to the
// SyncStartupTracker.
void NotifySyncListeners() {
if (handler_->sync_startup_tracker_)
- handler_->sync_startup_tracker_->OnStateChanged(mock_pss_);
+ handler_->sync_startup_tracker_->OnStateChanged(mock_sync_service_);
}
- void NotifySyncStateChanged() { handler_->OnStateChanged(mock_pss_); }
+ void NotifySyncStateChanged() {
+ handler_->OnStateChanged(mock_sync_service_);
+ }
virtual std::string GetTestUser() {
return std::string(kTestUser);
@@ -333,27 +364,42 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness {
return identity_test_env_adaptor_->identity_test_env();
}
- ProfileSyncServiceMock* mock_pss_;
+ MOCK_METHOD0(OnSetupInProgressHandleDestroyed, void());
+
+ unified_consent::ScopedUnifiedConsent scoped_unified_consent_;
+
+ syncer::MockSyncService* mock_sync_service_;
std::unique_ptr<IdentityTestEnvironmentProfileAdaptor>
identity_test_env_adaptor_;
content::TestWebUI web_ui_;
TestWebUIProvider test_provider_;
std::unique_ptr<TestChromeWebUIControllerFactory> test_factory_;
std::unique_ptr<TestingPeopleHandler> handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(PeopleHandlerTest);
};
class PeopleHandlerFirstSigninTest : public PeopleHandlerTest {
std::string GetTestUser() override { return std::string(); }
};
+class PeopleHandlerTest_UnifiedConsentDisabled : public PeopleHandlerTest {
+ public:
+ PeopleHandlerTest_UnifiedConsentDisabled()
+ : PeopleHandlerTest(
+ unified_consent::UnifiedConsentFeatureState::kDisabled) {}
+
+ DISALLOW_COPY_AND_ASSIGN(PeopleHandlerTest_UnifiedConsentDisabled);
+};
+
#if !defined(OS_CHROMEOS)
TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) {
// Test that the HandleStartSignin call enables JavaScript.
handler_->DisallowJavascript();
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
.WillByDefault(Return(false));
// Ensure that the user is not signed in before calling |HandleStartSignin()|.
identity_test_env()->ClearPrimaryAccount();
@@ -373,10 +419,11 @@ TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) {
LoginUIServiceFactory::GetForProfile(profile())->current_login_ui());
}
-TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) {
- ON_CALL(*mock_pss_, GetDisableReasons())
+TEST_F(PeopleHandlerTest_UnifiedConsentDisabled,
+ DontShowSyncSetupWhenNotSignedIn) {
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
.WillByDefault(Return(false));
handler_->HandleShowSetupUI(nullptr);
@@ -391,8 +438,9 @@ TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) {
// Verifies that the sync setup is terminated correctly when the
// sync is disabled.
-TEST_F(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled) {
- ON_CALL(*mock_pss_, GetDisableReasons())
+TEST_F(PeopleHandlerTest_UnifiedConsentDisabled,
+ HandleSetupUIWhenSyncDisabled) {
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(
Return(syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY));
handler_->HandleShowSetupUI(nullptr);
@@ -404,18 +452,51 @@ TEST_F(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled) {
ASSERT_FALSE(handler_->is_configuring_sync());
}
+TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndCancel) {
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true));
+
+ // We're simulating a user setting up sync, which would cause the engine to
+ // kick off initialization, but not download user data types. The sync
+ // engine will try to download control data types (e.g encryption info), but
+ // that won't finish for this test as we're simulating cancelling while the
+ // spinner is showing.
+ handler_->HandleShowSetupUI(nullptr);
+
+ EXPECT_EQ(
+ handler_.get(),
+ LoginUIServiceFactory::GetForProfile(profile())->current_login_ui());
+
+ EXPECT_EQ(0U, web_ui_.call_data().size());
+
+ handler_->CloseSyncSetup();
+ EXPECT_EQ(
+ NULL,
+ LoginUIServiceFactory::GetForProfile(profile())->current_login_ui());
+}
+
// Verifies that the handler correctly handles a cancellation when
// it is displaying the spinner to the user.
-TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndCancel) {
- ON_CALL(*mock_pss_, GetDisableReasons())
+TEST_F(PeopleHandlerTest_UnifiedConsentDisabled,
+ DisplayConfigureWithEngineDisabledAndCancel) {
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true));
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true));
// We're simulating a user setting up sync, which would cause the engine to
// kick off initialization, but not download user data types. The sync
@@ -431,21 +512,62 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndCancel) {
ExpectSpinnerAndClose();
}
+// Verifies that the handler only sends the sync pref updates once the engine is
+// initialized.
+TEST_F(PeopleHandlerTest,
+ DisplayConfigureWithEngineDisabledAndSyncStartupCompleted) {
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
+ .WillByDefault(Return(true));
+ // Sync engine is stopped initially, and will start up.
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::START_DEFERRED));
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true));
+ SetDefaultExpectationsForConfigPage();
+
+ handler_->HandleShowSetupUI(nullptr);
+
+ // No data is sent yet, because the engine is not initialized.
+ EXPECT_EQ(0U, web_ui_.call_data().size());
+
+ Mock::VerifyAndClearExpectations(mock_sync_service_);
+ // Now, act as if the SyncService has started up.
+ SetDefaultExpectationsForConfigPage();
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
+ NotifySyncStateChanged();
+
+ // Updates for the sync status and the sync prefs are sent.
+ EXPECT_EQ(2U, web_ui_.call_data().size());
+
+ const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
+ CheckBool(dictionary, "syncAllDataTypes", true);
+ CheckBool(dictionary, "encryptAllDataAllowed", true);
+ CheckBool(dictionary, "encryptAllData", false);
+ CheckBool(dictionary, "passphraseRequired", false);
+}
+
// Verifies that the handler correctly transitions from showing the spinner
// to showing a configuration page when sync setup completes successfully.
-TEST_F(PeopleHandlerTest,
+TEST_F(PeopleHandlerTest_UnifiedConsentDisabled,
DisplayConfigureWithEngineDisabledAndSyncStartupCompleted) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
.WillByDefault(Return(true));
// Sync engine is stopped initially, and will start up.
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(
Return(syncer::SyncService::TransportState::START_DEFERRED));
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true));
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true));
SetDefaultExpectationsForConfigPage();
handler_->HandleShowSetupUI(nullptr);
@@ -453,10 +575,10 @@ TEST_F(PeopleHandlerTest,
EXPECT_EQ(1U, web_ui_.call_data().size());
ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
- Mock::VerifyAndClearExpectations(mock_pss_);
- // Now, act as if the ProfileSyncService has started up.
+ Mock::VerifyAndClearExpectations(mock_sync_service_);
+ // Now, act as if the SyncService has started up.
SetDefaultExpectationsForConfigPage();
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
handler_->SyncStartupCompleted();
@@ -470,30 +592,31 @@ TEST_F(PeopleHandlerTest,
}
// Verifies the case where the user cancels after the sync engine has
-// initialized (meaning it already transitioned from the spinner to a proper
-// configuration page, tested by
-// DisplayConfigureWithEngineDisabledAndSyncStartupCompleted), but before the
-// user has continued on.
+// initialized.
TEST_F(PeopleHandlerTest,
DisplayConfigureWithEngineDisabledAndCancelAfterSigninSuccess) {
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
.WillByDefault(Return(false));
- EXPECT_CALL(*mock_pss_, GetTransportState())
+ EXPECT_CALL(*mock_sync_service_, GetTransportState())
.WillOnce(Return(syncer::SyncService::TransportState::INITIALIZING))
.WillRepeatedly(Return(syncer::SyncService::TransportState::ACTIVE));
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true));
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true));
SetDefaultExpectationsForConfigPage();
handler_->HandleShowSetupUI(nullptr);
+ // Sync engine becomes active, so |handler_| is notified.
+ NotifySyncStateChanged();
+
// It's important to tell sync the user cancelled the setup flow before we
// tell it we're through with the setup progress.
testing::InSequence seq;
- EXPECT_CALL(*mock_pss_, StopAndClear());
- EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed());
+ EXPECT_CALL(*mock_sync_service_, StopAndClear());
+ EXPECT_CALL(*this, OnSetupInProgressHandleDestroyed());
handler_->CloseSyncSetup();
EXPECT_EQ(
@@ -501,21 +624,23 @@ TEST_F(PeopleHandlerTest,
LoginUIServiceFactory::GetForProfile(profile())->current_login_ui());
}
-TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) {
- ON_CALL(*mock_pss_, GetDisableReasons())
+TEST_F(PeopleHandlerTest_UnifiedConsentDisabled,
+ DisplayConfigureWithEngineDisabledAndSigninFailed) {
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true));
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true));
handler_->HandleShowSetupUI(nullptr);
ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
- Mock::VerifyAndClearExpectations(mock_pss_);
- ON_CALL(*mock_pss_, GetAuthError())
+ Mock::VerifyAndClearExpectations(mock_sync_service_);
+ ON_CALL(*mock_sync_service_, GetAuthError())
.WillByDefault(Return(GoogleServiceAuthError(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)));
NotifySyncListeners();
@@ -529,28 +654,58 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithEngineDisabledAndSigninFailed) {
TEST_F(PeopleHandlerTest, RestartSyncAfterDashboardClear) {
// Clearing sync from the dashboard results in DISABLE_REASON_USER_CHOICE
// being set.
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_USER_CHOICE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
- .WillByDefault(Return(true));
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::DISABLED));
+
+ // Attempting to open the setup UI should restart sync.
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true))
+ .WillOnce([&](bool) {
+ // SetSyncRequested(true) clears DISABLE_REASON_USER_CHOICE, and
+ // immediately starts initializing the engine.
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::INITIALIZING));
+ });
+
+ handler_->HandleShowSetupUI(nullptr);
+
+ // Since the engine is not initialized yet, no data should be sent.
+ EXPECT_EQ(0U, web_ui_.call_data().size());
+}
+
+TEST_F(PeopleHandlerTest_UnifiedConsentDisabled,
+ RestartSyncAfterDashboardClear) {
+ // Clearing sync from the dashboard results in DISABLE_REASON_USER_CHOICE
+ // being set.
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_USER_CHOICE));
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::DISABLED));
// Attempting to open the setup UI should restart sync.
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true))
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true))
.WillOnce([&](bool) {
// SetSyncRequested(true) clears DISABLE_REASON_USER_CHOICE, and
- // immediately starts initialzing the engine.
- ON_CALL(*mock_pss_, GetDisableReasons())
+ // immediately starts initializing the engine.
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(
Return(syncer::SyncService::TransportState::INITIALIZING));
});
handler_->HandleShowSetupUI(nullptr);
+ // Since the engine is not initialized yet, we should get a spinner.
ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
}
@@ -559,45 +714,46 @@ TEST_F(PeopleHandlerTest,
// 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())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_USER_CHOICE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
- .WillByDefault(Return(true));
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
// Attempting to open the setup UI should re-enable sync-the-feature.
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true))
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true))
.WillOnce([&](bool) {
// SetSyncRequested(true) clears DISABLE_REASON_USER_CHOICE. Since the
// engine is already running, it just gets reconfigured.
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(
Return(syncer::SyncService::TransportState::CONFIGURING));
});
handler_->HandleShowSetupUI(nullptr);
- ExpectPageStatusChanged(PeopleHandler::kSpinnerPageStatus);
+ // Since the engine was already running, we should *not* get a spinner - all
+ // the necessary values are already available.
+ ExpectSyncPrefsChanged();
}
// Tests that signals not related to user intention to configure sync don't
// trigger sync engine start.
TEST_F(PeopleHandlerTest, OnlyStartEngineWhenConfiguringSync) {
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetSyncRequested(true))
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true))
.Times(0);
NotifySyncStateChanged();
}
TEST_F(PeopleHandlerTest, AcquireSyncBlockerWhenLoadingSyncSettingsSubpage) {
- /// We set up a factory override here to prevent a new web ui from being
- /// created when we navigate to a page that would normally create one.
- web_ui_.set_web_contents(web_contents());
+ // We set up a factory override here to prevent a new web ui from being
+ // created when we navigate to a page that would normally create one.
test_factory_ = std::make_unique<TestChromeWebUIControllerFactory>();
test_factory_->AddFactoryOverride(
chrome::GetSettingsUrl(chrome::kSyncSetupSubPage).host(),
@@ -625,10 +781,10 @@ class PeopleHandlerNonCrosTest : public PeopleHandlerTest {
// TODO(kochi): We need equivalent tests for ChromeOS.
TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) {
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(
Return(syncer::SyncService::DISABLE_REASON_UNRECOVERABLE_ERROR));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
.WillByDefault(Return(false));
// Open the web UI.
handler_->HandleShowSetupUI(nullptr);
@@ -637,9 +793,9 @@ TEST_F(PeopleHandlerNonCrosTest, UnrecoverableErrorInitializingSync) {
}
TEST_F(PeopleHandlerNonCrosTest, GaiaErrorInitializingSync) {
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NOT_SIGNED_IN));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsFirstSetupComplete())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
.WillByDefault(Return(false));
// Open the web UI.
handler_->HandleShowSetupUI(nullptr);
@@ -655,13 +811,14 @@ TEST_F(PeopleHandlerTest, TestSyncEverything) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetChosenDataTypes(true, _));
+ SetupInitializedSyncService();
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSelectedTypes(true, _));
handler_->HandleSetDatatypes(&list_args);
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
@@ -673,14 +830,15 @@ TEST_F(PeopleHandlerTest, TestPassphraseStillRequired) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
handler_->HandleSetEncryption(&list_args);
@@ -698,15 +856,17 @@ TEST_F(PeopleHandlerTest, EnterExistingFrozenImplicitPassword) {
list_args.AppendString(args);
// Act as if an encryption passphrase is required the first time, then never
// again after that.
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsPassphraseRequired())
.WillOnce(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(),
+ SetupInitializedSyncService();
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetDecryptionPassphrase("oldGaiaPassphrase"))
.WillOnce(Return(true));
@@ -722,17 +882,19 @@ TEST_F(PeopleHandlerTest, SetNewCustomPassphrase) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingAllowed())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(),
+ SetupInitializedSyncService();
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetEncryptionPassphrase("custom_passphrase"));
handler_->HandleSetEncryption(&list_args);
@@ -747,15 +909,16 @@ TEST_F(PeopleHandlerTest, EnterWrongExistingPassphrase) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(),
+ SetupInitializedSyncService();
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
SetDecryptionPassphrase("invalid_passphrase"))
.WillOnce(Return(false));
@@ -777,14 +940,15 @@ TEST_F(PeopleHandlerTest, EnterBlankExistingPassphrase) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
@@ -796,9 +960,8 @@ TEST_F(PeopleHandlerTest, EnterBlankExistingPassphrase) {
// Walks through each user selectable type, and tries to sync just that single
// data type.
TEST_F(PeopleHandlerTest, TestSyncIndividualTypes) {
- syncer::ModelTypeSet user_selectable_types = GetAllTypes();
- for (syncer::ModelType type : user_selectable_types) {
- syncer::ModelTypeSet type_to_set;
+ for (syncer::UserSelectableType type : GetAllTypes()) {
+ syncer::UserSelectableTypeSet type_to_set;
type_to_set.Put(type);
std::string args = GetConfiguration(NULL,
CHOOSE_WHAT_TO_SYNC,
@@ -808,18 +971,19 @@ TEST_F(PeopleHandlerTest, TestSyncIndividualTypes) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(),
- SetChosenDataTypes(false, ModelTypeSetMatches(type_to_set)));
+ SetupInitializedSyncService();
+ EXPECT_CALL(
+ *mock_sync_service_->GetMockUserSettings(),
+ SetSelectedTypes(false, UserSelectableTypeSetMatches(type_to_set)));
handler_->HandleSetDatatypes(&list_args);
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
- Mock::VerifyAndClearExpectations(mock_pss_);
+ Mock::VerifyAndClearExpectations(mock_sync_service_);
}
}
@@ -832,25 +996,27 @@ TEST_F(PeopleHandlerTest, TestSyncAllManually) {
base::ListValue list_args;
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(),
- SetChosenDataTypes(false, ModelTypeSetMatches(GetAllTypes())));
+ SetupInitializedSyncService();
+ EXPECT_CALL(
+ *mock_sync_service_->GetMockUserSettings(),
+ SetSelectedTypes(false, UserSelectableTypeSetMatches(GetAllTypes())));
handler_->HandleSetDatatypes(&list_args);
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
}
TEST_F(PeopleHandlerTest, ShowSyncSetup) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
// This should display the sync setup dialog (not login).
SetDefaultExpectationsForConfigPage();
handler_->HandleShowSetupUI(nullptr);
@@ -859,13 +1025,13 @@ TEST_F(PeopleHandlerTest, ShowSyncSetup) {
}
// We do not display signin on chromeos in the case of auth error.
-TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
+TEST_F(PeopleHandlerTest_UnifiedConsentDisabled, ShowSigninOnAuthError) {
// Initialize the system to a signed in state, but with an auth error.
- ON_CALL(*mock_pss_, GetAuthError())
+ ON_CALL(*mock_sync_service_, GetAuthError())
.WillByDefault(Return(GoogleServiceAuthError(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
auto* identity_manager = identity_test_env()->identity_manager();
CoreAccountInfo primary_account_info =
@@ -884,15 +1050,16 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
identity_manager, primary_account_info.account_id,
GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
- ON_CALL(*mock_pss_, GetDisableReasons())
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncRequested())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_, GetTransportState())
+ ON_CALL(*mock_sync_service_, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::INITIALIZING));
#if defined(OS_CHROMEOS)
@@ -920,11 +1087,12 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
}
TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
// This should display the sync setup dialog (not login).
handler_->HandleShowSetupUI(nullptr);
@@ -942,19 +1110,19 @@ TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) {
CheckBool(dictionary, "typedUrlsRegistered", true);
CheckBool(dictionary, "paymentsIntegrationEnabled", true);
CheckBool(dictionary, "passphraseRequired", false);
- CheckBool(dictionary, "passphraseTypeIsCustom", false);
CheckBool(dictionary, "encryptAllData", false);
CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes());
}
TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncEverythingEnabled())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncEverythingEnabled())
.WillByDefault(Return(false));
// This should display the sync setup dialog (not login).
handler_->HandleShowSetupUI(nullptr);
@@ -964,19 +1132,19 @@ TEST_F(PeopleHandlerTest, ShowSetupManuallySyncAll) {
}
TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) {
- syncer::ModelTypeSet user_selectable_types = GetAllTypes();
- for (syncer::ModelType type : user_selectable_types) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ for (syncer::UserSelectableType type : GetAllTypes()) {
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsSyncEverythingEnabled())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsSyncEverythingEnabled())
.WillByDefault(Return(false));
- syncer::ModelTypeSet types;
- types.Put(type);
- ON_CALL(*mock_pss_->GetUserSettingsMock(), GetChosenDataTypes())
+ syncer::UserSelectableTypeSet types(type);
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), GetSelectedTypes())
.WillByDefault(Return(types));
// This should display the sync setup dialog (not login).
@@ -988,19 +1156,19 @@ TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) {
const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types);
- Mock::VerifyAndClearExpectations(mock_pss_);
+ Mock::VerifyAndClearExpectations(mock_sync_service_);
// Clean up so we can loop back to display the dialog again.
web_ui_.ClearTrackedCalls();
}
}
TEST_F(PeopleHandlerTest, ShowSetupOldGaiaPassphraseRequired) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), GetPassphraseType())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), GetPassphraseType())
.WillByDefault(
Return(syncer::PassphraseType::FROZEN_IMPLICIT_PASSPHRASE));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
// This should display the sync setup dialog (not login).
@@ -1008,15 +1176,15 @@ TEST_F(PeopleHandlerTest, ShowSetupOldGaiaPassphraseRequired) {
const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
CheckBool(dictionary, "passphraseRequired", true);
- CheckBool(dictionary, "passphraseTypeIsCustom", false);
+ EXPECT_TRUE(dictionary->FindKey("enterPassphraseBody"));
}
TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(true));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), GetPassphraseType())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), GetPassphraseType())
.WillByDefault(Return(syncer::PassphraseType::CUSTOM_PASSPHRASE));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
// This should display the sync setup dialog (not login).
@@ -1024,17 +1192,19 @@ TEST_F(PeopleHandlerTest, ShowSetupCustomPassphraseRequired) {
const base::DictionaryValue* dictionary = ExpectSyncPrefsChanged();
CheckBool(dictionary, "passphraseRequired", true);
- CheckBool(dictionary, "passphraseTypeIsCustom", true);
+ EXPECT_TRUE(dictionary->FindKey("enterPassphraseBody"));
}
TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingEnabled())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingEnabled())
.WillByDefault(Return(true));
// This should display the sync setup dialog (not login).
@@ -1045,13 +1215,15 @@ TEST_F(PeopleHandlerTest, ShowSetupEncryptAll) {
}
TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsUsingSecondaryPassphrase())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsUsingSecondaryPassphrase())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
+ SetupInitializedSyncService();
SetDefaultExpectationsForConfigPage();
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingAllowed())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
.WillByDefault(Return(false));
// This should display the sync setup dialog (not login).
@@ -1063,13 +1235,14 @@ TEST_F(PeopleHandlerTest, ShowSetupEncryptAllDisallowed) {
}
TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) {
- ON_CALL(*mock_pss_->GetUserSettingsMock(),
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
IsPassphraseRequiredForDecryption())
.WillByDefault(Return(false));
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsPassphraseRequired())
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsPassphraseRequired())
.WillByDefault(Return(false));
- SetupInitializedProfileSyncService();
- ON_CALL(*mock_pss_->GetUserSettingsMock(), IsEncryptEverythingAllowed())
+ SetupInitializedSyncService();
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsEncryptEverythingAllowed())
.WillByDefault(Return(false));
base::DictionaryValue dict;
@@ -1080,9 +1253,11 @@ TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) {
list_args.AppendString(kTestCallbackId);
list_args.AppendString(args);
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), EnableEncryptEverything())
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ EnableEncryptEverything())
.Times(0);
- EXPECT_CALL(*mock_pss_->GetUserSettingsMock(), SetEncryptionPassphrase(_))
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetEncryptionPassphrase(_))
.Times(0);
handler_->HandleSetEncryption(&list_args);
@@ -1090,6 +1265,125 @@ TEST_F(PeopleHandlerTest, TurnOnEncryptAllDisallowed) {
ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus);
}
+TEST_F(PeopleHandlerTest, DashboardClearWhileSettingsOpen_ConfirmSoon) {
+ // Sync starts out fully enabled.
+ SetDefaultExpectationsForConfigPage();
+
+ handler_->HandleShowSetupUI(nullptr);
+
+ // Now sync gets reset from the dashboard (the user clicked the "Manage synced
+ // data" link), which results in the sync-requested and first-setup-complete
+ // bits being cleared.
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_USER_CHOICE));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
+ .WillByDefault(Return(false));
+ // Sync will eventually start again in transport mode.
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::START_DEFERRED));
+
+ NotifySyncStateChanged();
+
+ // Now the user confirms sync again. This should set both the sync-requested
+ // and the first-setup-complete bits.
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true))
+ .WillOnce([&](bool) {
+ // SetSyncRequested(true) clears DISABLE_REASON_USER_CHOICE, and
+ // immediately starts initializing the engine.
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::INITIALIZING));
+ NotifySyncStateChanged();
+ });
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetFirstSetupComplete())
+ .WillOnce([&]() {
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsFirstSetupComplete())
+ .WillByDefault(Return(true));
+ NotifySyncStateChanged();
+ });
+
+ base::ListValue did_abort;
+ did_abort.GetList().push_back(base::Value(false));
+ handler_->OnDidClosePage(&did_abort);
+}
+
+TEST_F(PeopleHandlerTest, DashboardClearWhileSettingsOpen_ConfirmLater) {
+ // Sync starts out fully enabled.
+ SetDefaultExpectationsForConfigPage();
+
+ handler_->HandleShowSetupUI(nullptr);
+
+ // Now sync gets reset from the dashboard (the user clicked the "Manage synced
+ // data" link), which results in the sync-requested and first-setup-complete
+ // bits being cleared.
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_USER_CHOICE));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
+ .WillByDefault(Return(false));
+ // Sync will eventually start again in transport mode.
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::START_DEFERRED));
+
+ NotifySyncStateChanged();
+
+ // The user waits a while before doing anything, so sync starts up in
+ // transport mode.
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
+ // On some platforms (e.g. ChromeOS), the first-setup-complete bit gets set
+ // automatically during engine startup.
+ if (browser_defaults::kSyncAutoStarts) {
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsFirstSetupComplete())
+ .WillByDefault(Return(true));
+ }
+ NotifySyncStateChanged();
+
+ // Now the user confirms sync again. This should set the sync-requested bit
+ // and (if it wasn't automatically set above already) also the
+ // first-setup-complete bit.
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetSyncRequested(true))
+ .WillOnce([&](bool) {
+ // SetSyncRequested(true) clears DISABLE_REASON_USER_CHOICE, and
+ // immediately starts initializing the engine.
+ ON_CALL(*mock_sync_service_, GetDisableReasons())
+ .WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(), IsSyncRequested())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_, GetTransportState())
+ .WillByDefault(
+ Return(syncer::SyncService::TransportState::INITIALIZING));
+ NotifySyncStateChanged();
+ });
+ if (!browser_defaults::kSyncAutoStarts) {
+ EXPECT_CALL(*mock_sync_service_->GetMockUserSettings(),
+ SetFirstSetupComplete())
+ .WillOnce([&]() {
+ ON_CALL(*mock_sync_service_->GetMockUserSettings(),
+ IsFirstSetupComplete())
+ .WillByDefault(Return(true));
+ NotifySyncStateChanged();
+ });
+ }
+
+ base::ListValue did_abort;
+ did_abort.GetList().push_back(base::Value(false));
+ handler_->OnDidClosePage(&did_abort);
+}
+
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
class PeopleHandlerDiceUnifiedConsentTest
: public ::testing::TestWithParam<std::tuple<bool, bool>> {};
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc
index 8c34895872b..f46e5ef15f1 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.cc
@@ -64,9 +64,12 @@ void DefaultBrowserHandler::OnJavascriptDisallowed() {
}
void DefaultBrowserHandler::RequestDefaultBrowserState(
- const base::ListValue* /*args*/) {
+ const base::ListValue* args) {
AllowJavascript();
+ CHECK_EQ(args->GetSize(), 1U);
+ CHECK(args->GetString(0, &check_default_callback_id_));
+
default_browser_worker_->StartCheckIsDefault();
}
@@ -103,7 +106,12 @@ void DefaultBrowserHandler::OnDefaultBrowserWorkerFinished(
state == shell_integration::UNKNOWN_DEFAULT);
dict.SetBoolean("isDisabledByPolicy", DefaultBrowserIsDisabledByPolicy());
- FireWebUIListener("browser-default-state-changed", dict);
+ if (!check_default_callback_id_.empty()) {
+ ResolveJavascriptCallback(base::Value(check_default_callback_id_), dict);
+ check_default_callback_id_.clear();
+ } else {
+ FireWebUIListener("browser-default-state-changed", dict);
+ }
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.h
index 81337dc40df..fe71f6526bf 100644
--- a/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_default_browser_handler.h
@@ -40,6 +40,8 @@ class DefaultBrowserHandler : public SettingsPageUIHandler {
virtual void RecordSetAsDefaultUMA();
private:
+ std::string check_default_callback_id_;
+
// Called from WebUI to request the current state.
void RequestDefaultBrowserState(const base::ListValue* args);
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc
index 7b0b41f9780..4349fe2ad14 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.h"
+#include "chrome/browser/ui/webui/settings/settings_localized_strings_provider.h"
#include <string>
@@ -17,13 +17,13 @@
#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/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/browser/ui/webui/localized_string.h"
+#include "chrome/browser/ui/webui/management_ui.h"
#include "chrome/browser/ui/webui/policy_indicator_localized_strings_provider.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
@@ -31,11 +31,14 @@
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
+#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/payments/payments_service_url.h"
#include "components/autofill/core/browser/payments/payments_util.h"
#include "components/autofill/core/browser/personal_data_manager.h"
+#include "components/autofill/core/browser/sync_utils.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
+#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/google/core/common/google_util.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/password_manager/core/browser/manage_passwords_referrer.h"
@@ -50,6 +53,8 @@
#include "components/unified_consent/feature.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/content_features.h"
+#include "content/public/common/content_switches.h"
+#include "device/fido/features.h"
#include "media/base/media_switches.h"
#include "services/device/public/cpp/device_features.h"
#include "ui/accessibility/accessibility_switches.h"
@@ -88,6 +93,7 @@
#if defined(OS_WIN)
#include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h"
+#include "device/fido/win/webauthn_api.h"
#if defined(GOOGLE_CHROME_BUILD)
#include "base/metrics/field_trial_params.h"
@@ -216,17 +222,9 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"delayBeforeClickShort", IDS_SETTINGS_DELAY_BEFORE_CLICK_SHORT},
{"delayBeforeClickLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_LONG},
{"delayBeforeClickVeryLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_VERY_LONG},
- {"autoclickEventTypeLabel", IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_LABEL},
- {"autoclickEventTypeLeftClick",
- IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_LEFT_CLICK},
- {"autoclickEventTypeRightClick",
- IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_RIGHT_CLICK},
- {"autoclickEventTypeDragAndDrop",
- IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_DRAG_AND_DROP},
- {"autoclickEventTypeDoubleClick",
- IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_DOUBLE_CLICK},
- {"autoclickEventTypeNoAction", IDS_SETTINGS_AUTOCLICK_EVENT_TYPE_NO_ACTION},
{"autoclickRevertToLeftClick", IDS_SETTINGS_AUTOCLICK_REVERT_TO_LEFT_CLICK},
+ {"autoclickStabilizeCursorPosition",
+ IDS_SETTINGS_AUTOCLICK_STABILIZE_CURSOR_POSITION},
{"autoclickMovementThresholdLabel",
IDS_SETTINGS_AUTOCLICK_MOVEMENT_THRESHOLD_LABEL},
{"autoclickMovementThresholdExtraSmall",
@@ -461,12 +459,15 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source,
{"crostiniExportLabel", IDS_SETTINGS_CROSTINI_EXPORT_LABEL},
{"crostiniImport", IDS_SETTINGS_CROSTINI_IMPORT},
{"crostiniImportLabel", IDS_SETTINGS_CROSTINI_IMPORT_LABEL},
+ {"crostiniRemoveButton", IDS_SETTINGS_CROSTINI_REMOVE_BUTTON},
{"crostiniSharedUsbDevicesLabel",
IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LABEL},
{"crostiniSharedUsbDevicesDescription",
IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_DESCRIPTION},
- {"crostiniSharedUsbDevicesListHeading",
- IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LIST_HEADING},
+ {"crostiniSharedUsbDevicesExtraDescription",
+ IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_EXTRA_DESCRIPTION},
+ {"crostiniSharedUsbDevicesListEmptyMessage",
+ IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LIST_EMPTY_MESSAGE},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings,
base::size(kLocalizedStrings));
@@ -492,6 +493,21 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source,
base::FeatureList::IsEnabled(chromeos::features::kCrostiniUsbSupport));
}
+void AddPluginVmStrings(content::WebUIDataSource* html_source,
+ Profile* profile) {
+ static constexpr LocalizedString kLocalizedStrings[] = {
+ {"pluginVmPageTitle", IDS_SETTINGS_PLUGIN_VM_PAGE_TITLE},
+ {"pluginVmPageLabel", IDS_SETTINGS_PLUGIN_VM_PAGE_LABEL},
+ {"pluginVmPrinterAccess", IDS_SETTINGS_PLUGIN_VM_PRINTER_ACCESS},
+ };
+ AddLocalizedStringsBulk(html_source, kLocalizedStrings,
+ base::size(kLocalizedStrings));
+ html_source->AddString(
+ "pluginVmPageSubtext",
+ l10n_util::GetStringFUTF16(IDS_SETTINGS_PLUGIN_VM_PAGE_SUBTEXT,
+ ui::GetChromeOSDeviceName()));
+}
+
void AddKioskNextShellStrings(content::WebUIDataSource* html_source) {
static constexpr LocalizedString kLocalizedStrings[] = {
{"kioskNextShellPageTitle", IDS_SETTINGS_KIOSK_NEXT_SHELL_TITLE},
@@ -1252,6 +1268,8 @@ void AddInternetStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_SETTINGS_NETWORK_ALLOW_DATA_ROAMING},
{"networkAlwaysOnVpn", IDS_SETTINGS_INTERNET_NETWORK_ALWAYS_ON_VPN},
{"networkAutoConnect", IDS_SETTINGS_INTERNET_NETWORK_AUTO_CONNECT},
+ {"networkAutoConnectCellular",
+ IDS_SETTINGS_INTERNET_NETWORK_AUTO_CONNECT_CELLULAR},
{"networkButtonActivate", IDS_SETTINGS_INTERNET_BUTTON_ACTIVATE},
{"networkButtonConfigure", IDS_SETTINGS_INTERNET_BUTTON_CONFIGURE},
{"networkButtonConnect", IDS_SETTINGS_INTERNET_BUTTON_CONNECT},
@@ -1370,18 +1388,15 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source) {
{"offerToEnableTranslate",
IDS_SETTINGS_LANGUAGES_OFFER_TO_ENABLE_TRANSLATE},
{"translateTargetLabel", IDS_SETTINGS_LANGUAGES_TRANSLATE_TARGET},
+ {"spellCheckTitle", IDS_SETTINGS_LANGUAGES_SPELL_CHECK_TITLE},
+ {"spellCheckBasicLabel", IDS_SETTINGS_LANGUAGES_SPELL_CHECK_BASIC_LABEL},
+ {"spellCheckEnhancedLabel",
+ IDS_SETTINGS_LANGUAGES_SPELL_CHECK_ENHANCED_LABEL},
+ {"spellCheckEnhancedDescription",
+ IDS_SETTINGS_LANGUAGES_SPELL_CHECK_ENHANCED_DESCRIPTION},
#if !defined(OS_MACOSX)
- {"spellCheckListTitle", IDS_SETTINGS_LANGUAGES_SPELL_CHECK_LIST_TITLE},
- {"spellCheckExpandA11yLabel",
- IDS_SETTINGS_LANGUAGES_SPELL_CHECK_EXPAND_ACCESSIBILITY_LABEL},
- {"spellCheckSummaryTwoLanguages",
- IDS_SETTINGS_LANGUAGES_SPELL_CHECK_SUMMARY_TWO_LANGUAGES},
- // TODO(michaelpg): Use ICU plural format when available to properly
- // translate "and [n] other(s)".
- {"spellCheckSummaryThreeLanguages",
- IDS_SETTINGS_LANGUAGES_SPELL_CHECK_SUMMARY_THREE_LANGUAGES},
- {"spellCheckSummaryMultipleLanguages",
- IDS_SETTINGS_LANGUAGES_SPELL_CHECK_SUMMARY_MULTIPLE_LANGUAGES},
+ {"spellCheckLanguagesListTitle",
+ IDS_SETTINGS_LANGUAGES_SPELL_CHECK_LANGUAGES_LIST_TITLE},
{"manageSpellCheck", IDS_SETTINGS_LANGUAGES_SPELL_CHECK_MANAGE},
{"editDictionaryPageTitle", IDS_SETTINGS_LANGUAGES_EDIT_DICTIONARY_TITLE},
{"addDictionaryWordLabel", IDS_SETTINGS_LANGUAGES_ADD_DICTIONARY_WORD},
@@ -1394,7 +1409,6 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source) {
{"customDictionaryWords", IDS_SETTINGS_LANGUAGES_DICTIONARY_WORDS},
{"noCustomDictionaryWordsFound",
IDS_SETTINGS_LANGUAGES_DICTIONARY_WORDS_NONE},
- {"spellCheckDisabled", IDS_SETTINGS_LANGUAGES_SPELL_CHECK_DISABLED},
{"languagesDictionaryDownloadError",
IDS_SETTINGS_LANGUAGES_DICTIONARY_DOWNLOAD_FAILED},
{"languagesDictionaryDownloadErrorHelp",
@@ -1557,47 +1571,15 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
html_source->AddString("passwordManagerLearnMoreURL",
chrome::kPasswordManagerLearnMoreURL);
html_source->AddString("manageAddressesUrl",
- autofill::payments::GetManageAddressesUrl(0).spec());
+ autofill::payments::GetManageAddressesUrl().spec());
html_source->AddString("manageCreditCardsLabel",
l10n_util::GetStringFUTF16(
IDS_SETTINGS_PAYMENTS_MANAGE_CREDIT_CARDS,
base::UTF8ToUTF16(chrome::kPaymentMethodsURL)));
html_source->AddString("manageCreditCardsUrl",
- autofill::payments::GetManageInstrumentsUrl(0).spec());
+ autofill::payments::GetManageInstrumentsUrl().spec());
html_source->AddString("paymentMethodsLearnMoreURL",
chrome::kPaymentMethodsLearnMoreURL);
- html_source->AddBoolean(
- "migrationEnabled",
- autofill::features::GetLocalCardMigrationExperimentalFlag() ==
- autofill::features::LocalCardMigrationExperimentalFlag::
- kMigrationIncludeSettingsPage);
- html_source->AddBoolean(
- "upstreamEnabled",
- base::FeatureList::IsEnabled(autofill::features::kAutofillUpstream));
-
- autofill::PersonalDataManager* personal_data_manager_ =
- autofill::PersonalDataManagerFactory::GetForProfile(profile);
- html_source->AddBoolean(
- "hasGooglePaymentsAccount",
- autofill::payments::GetBillingCustomerId(personal_data_manager_,
- profile->GetPrefs()) != 0);
-
- syncer::SyncService* sync_service =
- ProfileSyncServiceFactory::GetForProfile(profile);
- if (sync_service && sync_service->CanSyncFeatureStart() &&
- sync_service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE)) {
- html_source->AddBoolean(
- "isUsingSecondaryPassphrase",
- sync_service->GetUserSettings()->IsUsingSecondaryPassphrase());
- html_source->AddBoolean(
- "uploadToGoogleActive",
- syncer::GetUploadToGoogleState(
- sync_service, syncer::ModelType::AUTOFILL_WALLET_DATA) ==
- syncer::UploadState::ACTIVE);
- } else {
- html_source->AddBoolean("isUsingSecondaryPassphrase", false);
- html_source->AddBoolean("uploadToGoogleActive", false);
- }
bool is_guest_mode = false;
#if defined(OS_CHROMEOS)
@@ -1606,24 +1588,14 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
#else // !defined(OS_CHROMEOS)
is_guest_mode = profile->IsOffTheRecord();
#endif // defined(OS_CHROMEOS)
-
- if (is_guest_mode) {
- html_source->AddBoolean("userEmailDomainAllowed", false);
- } else {
- const std::string& user_email =
- personal_data_manager_->GetAccountInfoForPaymentsServer().email;
- if (user_email.empty()) {
- html_source->AddBoolean("userEmailDomainAllowed", false);
- } else {
- std::string domain = gaia::ExtractDomainName(user_email);
- html_source->AddBoolean(
- "userEmailDomainAllowed",
- base::FeatureList::IsEnabled(
- autofill::features::kAutofillUpstreamAllowAllEmailDomains) ||
- (domain == "googlemail.com" || domain == "gmail.com" ||
- domain == "google.com" || domain == "chromium.org"));
- }
- }
+ html_source->AddBoolean(
+ "migrationEnabled",
+ !is_guest_mode &&
+ autofill::IsCreditCardMigrationEnabled(
+ autofill::PersonalDataManagerFactory::GetForProfile(profile),
+ profile->GetPrefs(),
+ ProfileSyncServiceFactory::GetForProfile(profile),
+ /*is_test_mode=*/false));
AddLocalizedStringsBulk(html_source, kLocalizedStrings,
base::size(kLocalizedStrings));
@@ -1646,6 +1618,10 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
IDS_SETTINGS_ACCOUNT_MANAGER_SIGNED_OUT_ACCOUNT_PLACEHOLDER},
{"accountManagerReauthenticationLabel",
IDS_SETTINGS_ACCOUNT_MANAGER_REAUTHENTICATION_LABEL},
+ {"accountManagerManagedLabel",
+ IDS_SETTINGS_ACCOUNT_MANAGER_MANAGEMENT_STATUS_MANAGED_ACCOUNT},
+ {"accountManagerUnmanagedLabel",
+ IDS_SETTINGS_ACCOUNT_MANAGER_MANAGEMENT_STATUS_UNMANAGED_ACCOUNT},
{"configureFingerprintTitle", IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_TITLE},
{"configureFingerprintInstructionLocateScannerStep",
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER},
@@ -1843,6 +1819,8 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
};
AddLocalizedStringsBulk(html_source, localized_strings,
base::size(localized_strings));
+ html_source->AddString("managementPage",
+ ManagementUI::GetManagementPageSubtitle(profile));
// Format numbers to be used on the pin keyboard.
for (int j = 0; j <= 9; j++) {
@@ -2011,6 +1989,8 @@ void AddPrintingStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_PRINTING_CUPS_PRINTER_INVALID_DRIVER},
{"printerAddedSuccessfulMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_DONE_MESSAGE},
+ {"printerEditedSuccessfulMessage",
+ IDS_SETTINGS_PRINTING_CUPS_PRINTER_EDITED_PRINTER_DONE_MESSAGE},
{"noPrinterNearbyMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_NO_PRINTER_NEARBY},
{"searchingNearbyPrinters",
@@ -2253,7 +2233,8 @@ void AddSearchEnginesStrings(content::WebUIDataSource* html_source) {
}
#if defined(OS_CHROMEOS)
-void AddGoogleAssistantStrings(content::WebUIDataSource* html_source) {
+void AddGoogleAssistantStrings(content::WebUIDataSource* html_source,
+ Profile* profile) {
static constexpr LocalizedString kLocalizedStrings[] = {
{"googleAssistantPageTitle", IDS_SETTINGS_GOOGLE_ASSISTANT},
{"googleAssistantEnableContext",
@@ -2311,6 +2292,7 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
#if defined(OS_CHROMEOS)
{"androidSmsNote", IDS_SETTINGS_ANDROID_SMS_NOTE},
#endif
+ {"appCacheOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL},
{"cookieAppCache", IDS_SETTINGS_COOKIES_APPLICATION_CACHE},
{"cookieCacheStorage", IDS_SETTINGS_COOKIES_CACHE_STORAGE},
{"cookieChannelId", IDS_SETTINGS_COOKIES_CHANNEL_ID},
@@ -2335,7 +2317,6 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"channelIdExpires", IDS_SETTINGS_COOKIES_CHANNEL_ID_EXPIRES_LABEL},
{"cookieAccessibleToScript",
IDS_SETTINGS_COOKIES_COOKIE_ACCESSIBLE_TO_SCRIPT_LABEL},
- {"cookieLastAccessed", IDS_SETTINGS_COOKIES_LAST_ACCESSED_LABEL},
{"cookieContent", IDS_SETTINGS_COOKIES_COOKIE_CONTENT_LABEL},
{"cookieCreated", IDS_SETTINGS_COOKIES_COOKIE_CREATED_LABEL},
{"cookieDomain", IDS_SETTINGS_COOKIES_COOKIE_DOMAIN_LABEL},
@@ -2361,6 +2342,7 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"mediaLicenseSize", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL},
{"mediaLicenseLastModified",
IDS_SETTINGS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL},
+ {"noSerialPortsFound", IDS_SETTINGS_NO_SERIAL_PORTS_FOUND},
{"noUsbDevicesFound", IDS_SETTINGS_NO_USB_DEVICES_FOUND},
{"serviceWorkerOrigin", IDS_SETTINGS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL},
{"serviceWorkerSize",
@@ -2415,10 +2397,12 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsSoundAllowRecommended",
IDS_SETTINGS_SITE_SETTINGS_SOUND_ALLOW_RECOMMENDED},
{"siteSettingsSoundBlock", IDS_SETTINGS_SITE_SETTINGS_SOUND_BLOCK},
- {"siteSettingsSensors", IDS_SETTINGS_SITE_SETTINGS_SENSORS},
- {"siteSettingsSensorsAllow", IDS_SETTINGS_SITE_SETTINGS_SENSORS_ALLOW},
- {"siteSettingsSensorsBlock", IDS_SETTINGS_SITE_SETTINGS_SENSORS_BLOCK},
{"siteSettingsFlash", IDS_SETTINGS_SITE_SETTINGS_FLASH},
+ {"siteSettingsFlashAskFirst", IDS_SETTINGS_SITE_SETTINGS_ASK_FIRST},
+ {"siteSettingsFlashAskFirstRecommended",
+ IDS_SETTINGS_SITE_SETTINGS_ASK_FIRST_RECOMMENDED},
+ {"siteSettingsFlashPermissionsEphemeral",
+ IDS_SETTINGS_SITE_SETTINGS_FLASH_PERMISSIONS_ARE_EPHEMERAL},
{"siteSettingsPdfDocuments", IDS_SETTINGS_SITE_SETTINGS_PDF_DOCUMENTS},
{"siteSettingsPdfDownloadPdfs",
IDS_SETTINGS_SITE_SETTINGS_PDF_DOWNLOAD_PDFS},
@@ -2443,6 +2427,12 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_SITE_SETTINGS_MIDI_DEVICES_ASK_RECOMMENDED},
{"siteSettingsMidiDevicesBlock",
IDS_SETTINGS_SITE_SETTINGS_MIDI_DEVICES_BLOCK},
+ {"siteSettingsSerialPorts", IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS},
+ {"siteSettingsSerialPortsAsk", IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_ASK},
+ {"siteSettingsSerialPortsAskRecommended",
+ IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_ASK_RECOMMENDED},
+ {"siteSettingsSerialPortsBlock",
+ IDS_SETTINGS_SITE_SETTINGS_SERIAL_PORTS_BLOCK},
{"siteSettingsUsbDevices", IDS_SETTINGS_SITE_SETTINGS_USB_DEVICES},
{"siteSettingsUsbDevicesAsk", IDS_SETTINGS_SITE_SETTINGS_USB_DEVICES_ASK},
{"siteSettingsUsbDevicesAskRecommended",
@@ -2622,6 +2612,24 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
AddLocalizedStringsBulk(html_source, kLocalizedStrings,
base::size(kLocalizedStrings));
+ // These ones cannot be constexpr because we need to check base::FeatureList.
+ static LocalizedString kSensorsLocalizedStrings[] = {
+ {"siteSettingsSensors",
+ base::FeatureList::IsEnabled(features::kGenericSensorExtraClasses)
+ ? IDS_SETTINGS_SITE_SETTINGS_SENSORS
+ : IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS},
+ {"siteSettingsSensorsAllow",
+ base::FeatureList::IsEnabled(features::kGenericSensorExtraClasses)
+ ? IDS_SETTINGS_SITE_SETTINGS_SENSORS_ALLOW
+ : IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_ALLOW},
+ {"siteSettingsSensorsBlock",
+ base::FeatureList::IsEnabled(features::kGenericSensorExtraClasses)
+ ? IDS_SETTINGS_SITE_SETTINGS_SENSORS_BLOCK
+ : IDS_SETTINGS_SITE_SETTINGS_MOTION_SENSORS_BLOCK},
+ };
+ AddLocalizedStringsBulk(html_source, kSensorsLocalizedStrings,
+ base::size(kSensorsLocalizedStrings));
+
html_source->AddBoolean("enableSiteSettings", base::FeatureList::IsEnabled(
features::kSiteSettings));
html_source->AddBoolean(
@@ -2638,40 +2646,17 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
base::FeatureList::IsEnabled(media::kAutoplayWhitelistSettings));
html_source->AddBoolean(
- "enableClipboardContentSetting",
- base::FeatureList::IsEnabled(features::kClipboardContentSetting));
-
- html_source->AddBoolean(
"enableSensorsContentSetting",
- base::FeatureList::IsEnabled(features::kGenericSensorExtraClasses));
+ base::FeatureList::IsEnabled(features::kSensorContentSetting));
html_source->AddBoolean(
"enablePaymentHandlerContentSetting",
base::FeatureList::IsEnabled(features::kServiceWorkerPaymentApps));
- if (PluginUtils::ShouldPreferHtmlOverPlugins(
- HostContentSettingsMapFactory::GetForProfile(profile))) {
- static constexpr LocalizedString kFlashStrings[] = {
- {"siteSettingsFlashAskFirst", IDS_SETTINGS_SITE_SETTINGS_ASK_FIRST},
- {"siteSettingsFlashAskFirstRecommended",
- IDS_SETTINGS_SITE_SETTINGS_ASK_FIRST_RECOMMENDED},
- {"siteSettingsFlashPermissionsEphemeral",
- IDS_SETTINGS_SITE_SETTINGS_FLASH_PERMISSIONS_ARE_EPHEMERAL},
- };
- AddLocalizedStringsBulk(html_source, kFlashStrings,
- base::size(kFlashStrings));
- } else {
- static constexpr LocalizedString kFlashStrings[] = {
- {"siteSettingsFlashAskFirst",
- IDS_SETTINGS_SITE_SETTINGS_FLASH_DETECT_IMPORTANT},
- {"siteSettingsFlashAskFirstRecommended",
- IDS_SETTINGS_SITE_SETTINGS_FLASH_DETECT_IMPORTANT_RECOMMENDED},
- {"siteSettingsFlashPermissionsEphemeral",
- IDS_SETTINGS_SITE_SETTINGS_FLASH_PERMISSIONS_ARE_EPHEMERAL},
- };
- AddLocalizedStringsBulk(html_source, kFlashStrings,
- base::size(kFlashStrings));
- }
+ base::CommandLine& cmd = *base::CommandLine::ForCurrentProcess();
+ html_source->AddBoolean(
+ "enableExperimentalWebPlatformFeatures",
+ cmd.HasSwitch(::switches::kEnableExperimentalWebPlatformFeatures));
}
#if defined(OS_CHROMEOS)
@@ -2683,6 +2668,7 @@ void AddUsersStrings(content::WebUIDataSource* html_source) {
{"showOnSigninLabel", IDS_SETTINGS_USERS_SHOW_ON_SIGNIN_LABEL},
{"restrictSigninLabel", IDS_SETTINGS_USERS_RESTRICT_SIGNIN_LABEL},
{"deviceOwnerLabel", IDS_SETTINGS_USERS_DEVICE_OWNER_LABEL},
+ {"removeUserTooltip", IDS_SETTINGS_USERS_REMOVE_USER_TOOLTIP},
{"addUsers", IDS_SETTINGS_USERS_ADD_USERS},
{"addUsersEmail", IDS_SETTINGS_USERS_ADD_USERS_EMAIL},
};
@@ -2814,6 +2800,62 @@ void AddExtensionsStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_EXTENSIONS_CHECKBOX_LABEL);
}
+void AddSecurityKeysStrings(content::WebUIDataSource* html_source) {
+ static constexpr LocalizedString kSecurityKeysStrings[] = {
+ {"securityKeysConfirmPIN", IDS_SETTINGS_SECURITY_KEYS_CONFIRM_PIN},
+ {"securityKeysCurrentPIN", IDS_SETTINGS_SECURITY_KEYS_CURRENT_PIN},
+ {"securityKeysCurrentPINIntro",
+ IDS_SETTINGS_SECURITY_KEYS_CURRENT_PIN_INTRO},
+ {"securityKeysDesc", IDS_SETTINGS_SECURITY_KEYS_DESC},
+ {"securityKeysNewPIN", IDS_SETTINGS_SECURITY_KEYS_NEW_PIN},
+ {"securityKeysNoPIN", IDS_SETTINGS_SECURITY_KEYS_NO_PIN},
+ {"securityKeysNoReset", IDS_SETTINGS_SECURITY_KEYS_NO_RESET},
+ {"securityKeysPIN", IDS_SETTINGS_SECURITY_KEYS_PIN},
+ {"securityKeysPINError", IDS_SETTINGS_SECURITY_KEYS_PIN_ERROR},
+ {"securityKeysPINHardLock", IDS_SETTINGS_SECURITY_KEYS_PIN_HARD_LOCK},
+ {"securityKeysPINIncorrect", IDS_SETTINGS_SECURITY_KEYS_PIN_INCORRECT},
+ {"securityKeysPINIncorrectRetriesSin",
+ IDS_SETTINGS_SECURITY_KEYS_PIN_INCORRECT_RETRIES_SIN},
+ {"securityKeysPINIncorrectRetriesPl",
+ IDS_SETTINGS_SECURITY_KEYS_PIN_INCORRECT_RETRIES_PL},
+ {"securityKeysPINSoftLock", IDS_SETTINGS_SECURITY_KEYS_PIN_SOFT_LOCK},
+ {"securityKeysPINSuccess", IDS_SETTINGS_SECURITY_KEYS_PIN_SUCCESS},
+ {"securityKeysPINTouch", IDS_SETTINGS_SECURITY_KEYS_PIN_TOUCH},
+ {"securityKeysReset", IDS_SETTINGS_SECURITY_KEYS_RESET},
+ {"securityKeysResetConfirmTitle",
+ IDS_SETTINGS_SECURITY_KEYS_RESET_CONFIRM_TITLE},
+ {"securityKeysResetDesc", IDS_SETTINGS_SECURITY_KEYS_RESET_DESC},
+ {"securityKeysResetError", IDS_SETTINGS_SECURITY_KEYS_RESET_ERROR},
+ {"securityKeysResetNotAllowed",
+ IDS_SETTINGS_SECURITY_KEYS_RESET_NOTALLOWED},
+ {"securityKeysResetStep1", IDS_SETTINGS_SECURITY_KEYS_RESET_STEP1},
+ {"securityKeysResetStep2", IDS_SETTINGS_SECURITY_KEYS_RESET_STEP2},
+ {"securityKeysResetSuccess", IDS_SETTINGS_SECURITY_KEYS_RESET_SUCCESS},
+ {"securityKeysResetTitle", IDS_SETTINGS_SECURITY_KEYS_RESET_TITLE},
+ {"securityKeysSetPIN", IDS_SETTINGS_SECURITY_KEYS_SET_PIN},
+ {"securityKeysSetPINChangeTitle",
+ IDS_SETTINGS_SECURITY_KEYS_SET_PIN_CHANGE_TITLE},
+ {"securityKeysSetPINConfirm", IDS_SETTINGS_SECURITY_KEYS_SET_PIN_CONFIRM},
+ {"securityKeysSetPINCreateTitle",
+ IDS_SETTINGS_SECURITY_KEYS_SET_PIN_CREATE_TITLE},
+ {"securityKeysSetPINDesc", IDS_SETTINGS_SECURITY_KEYS_SET_PIN_DESC},
+ {"securityKeysSetPINInitialTitle",
+ IDS_SETTINGS_SECURITY_KEYS_SET_PIN_INITIAL_TITLE},
+ {"securityKeysTitle", IDS_SETTINGS_SECURITY_KEYS_TITLE},
+ };
+ AddLocalizedStringsBulk(html_source, kSecurityKeysStrings,
+ base::size(kSecurityKeysStrings));
+
+ html_source->AddBoolean(
+ "enableSecurityKeysSubpage",
+ base::FeatureList::IsEnabled(device::kWebAuthPINSupport)
+#if defined(OS_WIN)
+ && (!base::FeatureList::IsEnabled(device::kWebAuthUseNativeWinApi) ||
+ !device::WinWebAuthnApi::GetDefault()->IsAvailable())
+#endif
+ );
+}
+
} // namespace
void AddLocalizedStrings(content::WebUIDataSource* html_source,
@@ -2840,7 +2882,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
AddResetStrings(html_source);
AddSearchEnginesStrings(html_source);
#if defined(OS_CHROMEOS)
- AddGoogleAssistantStrings(html_source);
+ AddGoogleAssistantStrings(html_source, profile);
#endif
AddSearchInSettingsStrings(html_source);
AddSearchStrings(html_source, profile);
@@ -2849,6 +2891,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
#if defined(OS_CHROMEOS)
AddCrostiniStrings(html_source, profile);
+ AddPluginVmStrings(html_source, profile);
AddKioskNextShellStrings(html_source);
AddAndroidAppStrings(html_source);
AddBluetoothStrings(html_source);
@@ -2878,6 +2921,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
chromeos::network_element::AddErrorLocalizedStrings(html_source);
#endif
policy_indicator::AddLocalizedStrings(html_source);
+ AddSecurityKeysStrings(html_source);
html_source->SetJsonPath(kLocalizedStringsFile);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.h b/chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.h
index cfa37864dc0..1642eb7503a 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.h
+++ b/chromium/chrome/browser/ui/webui/settings/settings_localized_strings_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_MD_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
-#define CHROME_BROWSER_UI_WEBUI_SETTINGS_MD_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
class Profile;
@@ -21,4 +21,4 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
} // namespace settings
-#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_MD_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_LOCALIZED_STRINGS_PROVIDER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc
new file mode 100644
index 00000000000..834603aa371
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.cc
@@ -0,0 +1,251 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <utility>
+
+#include "base/callback.h"
+#include "base/optional.h"
+#include "base/values.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_security_key_handler.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/common/service_manager_connection.h"
+#include "device/fido/pin.h"
+#include "device/fido/reset_request_handler.h"
+#include "device/fido/set_pin_request_handler.h"
+
+using content::BrowserThread;
+
+namespace {
+
+constexpr char kStartSetPIN[] = "securityKeyStartSetPIN";
+constexpr char kSetPIN[] = "securityKeySetPIN";
+constexpr char kClose[] = "securityKeyClose";
+constexpr char kReset[] = "securityKeyReset";
+constexpr char kCompleteReset[] = "securityKeyCompleteReset";
+
+base::flat_set<device::FidoTransportProtocol> supported_transports() {
+ // If we ever support BLE devices then additional thought will be required
+ // in the UI; therefore don't enable them here. NFC is not supported on
+ // desktop thus only USB devices remain to be enabled.
+ return {device::FidoTransportProtocol::kUsbHumanInterfaceDevice};
+}
+
+} // namespace
+
+namespace settings {
+
+SecurityKeysHandler::SecurityKeysHandler()
+ : state_(State::kNone),
+ weak_factory_(new base::WeakPtrFactory<SecurityKeysHandler>(this)) {}
+
+SecurityKeysHandler::~SecurityKeysHandler() = default;
+
+void SecurityKeysHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ kStartSetPIN, base::BindRepeating(&SecurityKeysHandler::HandleStartSetPIN,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kSetPIN, base::BindRepeating(&SecurityKeysHandler::HandleSetPIN,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kClose, base::BindRepeating(&SecurityKeysHandler::HandleClose,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kReset, base::BindRepeating(&SecurityKeysHandler::HandleReset,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ kCompleteReset,
+ base::BindRepeating(&SecurityKeysHandler::HandleCompleteReset,
+ base::Unretained(this)));
+}
+
+void SecurityKeysHandler::OnJavascriptAllowed() {}
+void SecurityKeysHandler::OnJavascriptDisallowed() {
+ // If Javascript is disallowed, |Close| will invalidate all current WeakPtrs
+ // and thus drop all pending callbacks. This means that
+ // |IsJavascriptAllowed| doesn't need to be tested before each callback
+ // because, if the callback into this object happened, then Javascript is
+ // allowed.
+ Close();
+}
+
+void SecurityKeysHandler::Close() {
+ // Invalidate all existing WeakPtrs so that no stale callbacks occur.
+ weak_factory_ =
+ std::make_unique<base::WeakPtrFactory<SecurityKeysHandler>>(this);
+ state_ = State::kNone;
+ set_pin_.reset();
+ reset_.reset();
+ callback_id_.clear();
+}
+
+void SecurityKeysHandler::HandleStartSetPIN(const base::ListValue* args) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(State::kNone, state_);
+ DCHECK_EQ(1u, args->GetSize());
+
+ AllowJavascript();
+ DCHECK(callback_id_.empty());
+ callback_id_ = args->GetList()[0].GetString();
+ state_ = State::kStartSetPIN;
+ set_pin_ = std::make_unique<device::SetPINRequestHandler>(
+ content::ServiceManagerConnection::GetForProcess()->GetConnector(),
+ supported_transports(),
+ base::BindOnce(&SecurityKeysHandler::OnGatherPIN,
+ weak_factory_->GetWeakPtr()),
+ base::BindRepeating(&SecurityKeysHandler::OnSetPINComplete,
+ weak_factory_->GetWeakPtr()));
+}
+
+void SecurityKeysHandler::OnGatherPIN(base::Optional<int64_t> num_retries) {
+ DCHECK_EQ(State::kStartSetPIN, state_);
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ base::Value::ListStorage list;
+ list.emplace_back(0 /* process not complete */);
+ if (num_retries) {
+ state_ = State::kGatherChangePIN;
+ list.emplace_back(static_cast<int>(*num_retries));
+ } else {
+ state_ = State::kGatherNewPIN;
+ list.emplace_back(base::Value::Type::NONE);
+ }
+
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
+ base::Value(std::move(list)));
+}
+
+void SecurityKeysHandler::OnSetPINComplete(
+ device::CtapDeviceResponseCode code) {
+ DCHECK(state_ == State::kStartSetPIN || state_ == State::kSettingPIN);
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (code == device::CtapDeviceResponseCode::kCtap2ErrPinInvalid) {
+ // In the event that the old PIN was incorrect, the UI may prompt again.
+ state_ = State::kGatherChangePIN;
+ } else {
+ state_ = State::kNone;
+ set_pin_.reset();
+ }
+
+ base::Value::ListStorage list;
+ list.emplace_back(1 /* process complete */);
+ list.emplace_back(static_cast<int>(code));
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
+ base::Value(std::move(list)));
+}
+
+void SecurityKeysHandler::HandleSetPIN(const base::ListValue* args) {
+ DCHECK(state_ == State::kGatherNewPIN || state_ == State::kGatherChangePIN);
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(3u, args->GetSize());
+
+ DCHECK(callback_id_.empty());
+ callback_id_ = args->GetList()[0].GetString();
+ const std::string old_pin = args->GetList()[1].GetString();
+ const std::string new_pin = args->GetList()[2].GetString();
+
+ DCHECK((state_ == State::kGatherNewPIN) == old_pin.empty());
+
+ CHECK(device::pin::IsValid(new_pin));
+ state_ = State::kSettingPIN;
+ set_pin_->ProvidePIN(old_pin, new_pin);
+}
+
+void SecurityKeysHandler::HandleReset(const base::ListValue* args) {
+ DCHECK_EQ(State::kNone, state_);
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(1u, args->GetSize());
+
+ AllowJavascript();
+ DCHECK(callback_id_.empty());
+ callback_id_ = args->GetList()[0].GetString();
+
+ state_ = State::kStartReset;
+ reset_ = std::make_unique<device::ResetRequestHandler>(
+ content::ServiceManagerConnection::GetForProcess()->GetConnector(),
+ supported_transports(),
+ base::BindOnce(&SecurityKeysHandler::OnResetSent,
+ weak_factory_->GetWeakPtr()),
+ base::BindOnce(&SecurityKeysHandler::OnResetFinished,
+ weak_factory_->GetWeakPtr()));
+}
+
+void SecurityKeysHandler::OnResetSent() {
+ DCHECK_EQ(State::kStartReset, state_);
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // A reset message has been sent to a security key and it may complete
+ // before Javascript asks for the result. Therefore |HandleCompleteReset|
+ // and |OnResetFinished| may be called in either order.
+ state_ = State::kWaitingForResetNoCallbackYet;
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
+ base::Value(0 /* success */));
+}
+
+void SecurityKeysHandler::HandleCompleteReset(const base::ListValue* args) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK_EQ(1u, args->GetSize());
+
+ DCHECK(callback_id_.empty());
+ callback_id_ = args->GetList()[0].GetString();
+
+ switch (state_) {
+ case State::kWaitingForResetNoCallbackYet:
+ // The reset operation hasn't completed. |callback_id_| will be used in
+ // |OnResetFinished| when it does.
+ state_ = State::kWaitingForResetHaveCallback;
+ break;
+
+ case State::kWaitingForCompleteReset:
+ // The reset operation has completed and we were waiting for this
+ // call from Javascript in order to provide the result.
+ state_ = State::kNone;
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
+ base::Value(static_cast<int>(*reset_result_)));
+ reset_.reset();
+ break;
+
+ default:
+ NOTREACHED();
+ }
+}
+
+void SecurityKeysHandler::OnResetFinished(
+ device::CtapDeviceResponseCode result) {
+ switch (state_) {
+ case State::kWaitingForResetNoCallbackYet:
+ // The reset operation has completed, but Javascript hasn't called
+ // |CompleteReset| so we cannot make the callback yet.
+ state_ = State::kWaitingForCompleteReset;
+ reset_result_ = result;
+ break;
+
+ case State::kStartReset:
+ // The reset operation failed immediately, probably because the user
+ // selected a U2F device. |callback_id_| has been set by |Reset|.
+ [[fallthrough]];
+
+ case State::kWaitingForResetHaveCallback:
+ // The |CompleteReset| call has already provided |callback_id_| so the
+ // reset can be completed immediately.
+ state_ = State::kNone;
+ ResolveJavascriptCallback(base::Value(std::move(callback_id_)),
+ base::Value(static_cast<int>(result)));
+ reset_.reset();
+ break;
+
+ default:
+ NOTREACHED();
+ }
+}
+
+void SecurityKeysHandler::HandleClose(const base::ListValue* args) {
+ DCHECK_EQ(0u, args->GetSize());
+ Close();
+}
+
+} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h
new file mode 100644
index 00000000000..353d85c6002
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/settings_security_key_handler.h
@@ -0,0 +1,78 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_SECURITY_KEY_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_SECURITY_KEY_HANDLER_H_
+
+#include <memory>
+#include <string>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/optional.h"
+#include "device/fido/fido_constants.h"
+
+namespace base {
+class ListValue;
+}
+
+namespace device {
+class SetPINRequestHandler;
+class ResetRequestHandler;
+} // namespace device
+
+namespace settings {
+
+// SecurityKeysHandler processes messages from the "Security Keys" section of a
+// settings page. An instance of this class is created for each settings tab and
+// is destroyed when the tab is closed. See the comments in
+// security_keys_browser_proxy.js about the interface.
+class SecurityKeysHandler : public SettingsPageUIHandler {
+ public:
+ SecurityKeysHandler();
+ ~SecurityKeysHandler() override;
+
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ private:
+ enum class State {
+ kNone,
+
+ kStartSetPIN,
+ kGatherNewPIN,
+ kGatherChangePIN,
+ kSettingPIN,
+
+ kStartReset,
+ kWaitingForResetNoCallbackYet,
+ kWaitingForResetHaveCallback,
+ kWaitingForCompleteReset,
+ };
+
+ void Close();
+ void HandleStartSetPIN(const base::ListValue* args);
+ void OnGatherPIN(base::Optional<int64_t> num_retries);
+ void OnSetPINComplete(device::CtapDeviceResponseCode code);
+ void HandleSetPIN(const base::ListValue* args);
+ void HandleReset(const base::ListValue* args);
+ void OnResetSent();
+ void HandleCompleteReset(const base::ListValue* args);
+ void OnResetFinished(device::CtapDeviceResponseCode result);
+ void HandleClose(const base::ListValue* args);
+
+ State state_;
+ std::unique_ptr<device::SetPINRequestHandler> set_pin_;
+ std::unique_ptr<device::ResetRequestHandler> reset_;
+ base::Optional<device::CtapDeviceResponseCode> reset_result_;
+ std::string callback_id_;
+ std::unique_ptr<base::WeakPtrFactory<SecurityKeysHandler>> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SecurityKeysHandler);
+};
+
+} // namespace settings
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_SECURITY_KEY_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
index 291fbdf27b6..3d8d9047c13 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_ui.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/settings/md_settings_ui.h"
+#include "chrome/browser/ui/webui/settings/settings_ui.h"
#include <stddef.h>
@@ -13,6 +13,7 @@
#include "ash/public/cpp/ash_features.h"
#include "base/bind.h"
+#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
@@ -30,7 +31,6 @@
#include "chrome/browser/ui/webui/settings/downloads_handler.h"
#include "chrome/browser/ui/webui/settings/extension_control_handler.h"
#include "chrome/browser/ui/webui/settings/font_handler.h"
-#include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/metrics_reporting_handler.h"
#include "chrome/browser/ui/webui/settings/on_startup_handler.h"
#include "chrome/browser/ui/webui/settings/people_handler.h"
@@ -41,8 +41,10 @@
#include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.h"
#include "chrome/browser/ui/webui/settings/settings_cookies_view_handler.h"
#include "chrome/browser/ui/webui/settings/settings_import_data_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_localized_strings_provider.h"
#include "chrome/browser/ui/webui/settings/settings_media_devices_selection_handler.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "chrome/browser/ui/webui/settings/settings_security_key_handler.h"
#include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h"
#include "chrome/browser/ui/webui/settings/site_settings_handler.h"
#include "chrome/common/pref_names.h"
@@ -79,6 +81,7 @@
#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
#include "ash/public/cpp/stylus_utils.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/account_manager/account_manager_util.h"
#include "chrome/browser/chromeos/android_sms/android_sms_app_manager.h"
#include "chrome/browser/chromeos/android_sms/android_sms_service_factory.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
@@ -86,6 +89,7 @@
#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/multidevice_setup_client_factory.h"
+#include "chrome/browser/chromeos/plugin_vm/plugin_vm_util.h"
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h"
@@ -106,12 +110,14 @@
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/browser_resources.h"
-#include "chromeos/account_manager/account_manager.h"
-#include "chromeos/account_manager/account_manager_factory.h"
+#include "chromeos/components/account_manager/account_manager.h"
+#include "chromeos/components/account_manager/account_manager_factory.h"
#include "chromeos/constants/chromeos_features.h"
+#include "chromeos/constants/chromeos_pref_names.h"
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/services/multidevice_setup/public/cpp/prefs.h"
#include "components/arc/arc_util.h"
+#include "components/prefs/pref_service.h"
#include "ui/base/ui_base_features.h"
#include "ui/chromeos/resources/grit/ui_chromeos_resources.h"
#else // !defined(OS_CHROMEOS)
@@ -131,7 +137,7 @@
#include "chrome/browser/ui/webui/settings/printing_handler.h"
#endif
-#if defined(SAFE_BROWSING_DB_LOCAL)
+#if defined(FULL_SAFE_BROWSING)
#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
#include "chrome/browser/ui/webui/settings/change_password_handler.h"
#endif
@@ -139,7 +145,7 @@
namespace settings {
// static
-void MdSettingsUI::RegisterProfilePrefs(
+void SettingsUI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kImportDialogAutofillFormData, true);
registry->RegisterBooleanPref(prefs::kImportDialogBookmarks, true);
@@ -148,7 +154,7 @@ void MdSettingsUI::RegisterProfilePrefs(
registry->RegisterBooleanPref(prefs::kImportDialogSearchEngine, true);
}
-MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
+SettingsUI::SettingsUI(content::WebUI* web_ui)
: content::WebUIController(web_ui),
WebContentsObserver(web_ui->GetWebContents()) {
#if BUILDFLAG(OPTIMIZE_WEBUI)
@@ -156,6 +162,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
#endif
Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource* html_source =
+ content::WebUIDataSource::Create(chrome::kChromeUISettingsHost);
+
AddSettingsPageUIHandler(std::make_unique<AppearanceHandler>(web_ui));
#if defined(USE_NSS_CERTS)
@@ -175,6 +184,8 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
AddSettingsPageUIHandler(std::make_unique<ImportDataHandler>());
#if defined(OS_WIN) || defined(OS_CHROMEOS)
+ // TODO(jamescook): Sort out how language is split between Chrome OS and
+ // and browser settings.
AddSettingsPageUIHandler(std::make_unique<LanguagesHandler>(web_ui));
#endif // defined(OS_WIN) || defined(OS_CHROMEOS)
@@ -190,14 +201,16 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
AddSettingsPageUIHandler(std::make_unique<SearchEnginesHandler>(profile));
AddSettingsPageUIHandler(std::make_unique<SiteSettingsHandler>(profile));
AddSettingsPageUIHandler(std::make_unique<StartupPagesHandler>(web_ui));
+ AddSettingsPageUIHandler(std::make_unique<SecurityKeysHandler>());
#if defined(OS_CHROMEOS)
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::AccessibilityHandler>(web_ui));
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::AndroidAppsHandler>(profile));
+ // TODO(950007): Remove this when SplitSettings is the default and there are
+ // no Chrome OS settings in the browser settings page.
+ InitOSWebUIHandlers(profile, web_ui, html_source);
- if (!profile->IsGuestSession()) {
+ // TODO(jamescook): Sort out how account management is split between Chrome OS
+ // and browser settings.
+ if (chromeos::IsAccountManagerAvailable(profile)) {
chromeos::AccountManagerFactory* factory =
g_browser_process->platform_part()->GetAccountManagerFactory();
chromeos::AccountManager* account_manager =
@@ -206,37 +219,14 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
AddSettingsPageUIHandler(
std::make_unique<chromeos::settings::AccountManagerUIHandler>(
- account_manager,
- IdentityManagerFactory::GetForProfile(profile)));
+ account_manager, IdentityManagerFactory::GetForProfile(profile)));
+ html_source->AddBoolean(
+ "secondaryGoogleAccountSigninAllowed",
+ profile->GetPrefs()->GetBoolean(
+ chromeos::prefs::kSecondaryGoogleAccountSigninAllowed));
}
AddSettingsPageUIHandler(
std::make_unique<chromeos::settings::ChangePictureHandler>());
- if (crostini::IsCrostiniUIAllowedForProfile(profile,
- false /* check_policy */)) {
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::CrostiniHandler>(profile));
- }
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::CupsPrintersHandler>(web_ui));
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::FingerprintHandler>(profile));
- if (chromeos::switches::IsAssistantEnabled()) {
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::GoogleAssistantHandler>(profile));
- }
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::KeyboardHandler>());
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::PointerHandler>());
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::StorageHandler>(profile));
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::StylusHandler>());
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::InternetHandler>(profile));
- AddSettingsPageUIHandler(std::make_unique<TtsHandler>());
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::smb_dialog::SmbHandler>(profile));
#else
AddSettingsPageUIHandler(std::make_unique<DefaultBrowserHandler>());
AddSettingsPageUIHandler(std::make_unique<ManageProfileHandler>(profile));
@@ -247,16 +237,12 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
AddSettingsPageUIHandler(std::make_unique<PrintingHandler>());
#endif
- content::WebUIDataSource* html_source =
- content::WebUIDataSource::Create(chrome::kChromeUISettingsHost);
-
#if defined(OS_WIN)
AddSettingsPageUIHandler(std::make_unique<ChromeCleanupHandler>(profile));
#endif // defined(OS_WIN)
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
bool has_incompatible_applications =
- IncompatibleApplicationsUpdater::IsWarningEnabled() &&
IncompatibleApplicationsUpdater::HasCachedApplications();
html_source->AddBoolean("showIncompatibleApplications",
has_incompatible_applications);
@@ -268,7 +254,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
#endif // OS_WIN && defined(GOOGLE_CHROME_BUILD)
bool password_protection_available = false;
-#if defined(SAFE_BROWSING_DB_LOCAL)
+#if defined(FULL_SAFE_BROWSING)
safe_browsing::ChromePasswordProtectionService* password_protection =
safe_browsing::ChromePasswordProtectionService::
GetPasswordProtectionService(profile);
@@ -281,97 +267,11 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source->AddBoolean("passwordProtectionAvailable",
password_protection_available);
-#if defined(OS_CHROMEOS)
- if (!profile->IsGuestSession()) {
- chromeos::android_sms::AndroidSmsService* android_sms_service =
- chromeos::android_sms::AndroidSmsServiceFactory::GetForBrowserContext(
- profile);
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::MultideviceHandler>(
- profile->GetPrefs(),
- chromeos::multidevice_setup::MultiDeviceSetupClientFactory::
- GetForProfile(profile),
- android_sms_service
- ? android_sms_service->android_sms_pairing_state_tracker()
- : nullptr,
- android_sms_service ? android_sms_service->android_sms_app_manager()
- : nullptr));
- }
- html_source->AddBoolean(
- "multideviceAllowedByPolicy",
- chromeos::multidevice_setup::AreAnyMultiDeviceFeaturesAllowed(
- profile->GetPrefs()));
-
- AddSettingsPageUIHandler(base::WrapUnique(
- chromeos::settings::DateTimeHandler::Create(html_source)));
-
- AddSettingsPageUIHandler(
- std::make_unique<chromeos::settings::StylusHandler>());
- html_source->AddBoolean(
- "quickUnlockEnabled",
- chromeos::quick_unlock::IsPinEnabled(profile->GetPrefs()));
- html_source->AddBoolean(
- "quickUnlockDisabledByPolicy",
- chromeos::quick_unlock::IsPinDisabledByPolicy(profile->GetPrefs()));
- const bool fingerprint_unlock_enabled =
- chromeos::quick_unlock::IsFingerprintEnabled(profile);
- html_source->AddBoolean("fingerprintUnlockEnabled",
- fingerprint_unlock_enabled);
- if (fingerprint_unlock_enabled) {
- html_source->AddBoolean(
- "isFingerprintReaderOnKeyboard",
- chromeos::quick_unlock::IsFingerprintReaderOnKeyboard());
- }
- html_source->AddBoolean("lockScreenNotificationsEnabled",
- ash::features::IsLockScreenNotificationsEnabled());
- html_source->AddBoolean(
- "lockScreenHideSensitiveNotificationsSupported",
- ash::features::IsLockScreenHideSensitiveNotificationsSupported());
- html_source->AddBoolean("showTechnologyBadge",
- !ash::features::IsSeparateNetworkIconsEnabled());
- html_source->AddBoolean("hasInternalStylus",
- ash::stylus_utils::HasInternalStylus());
-
- html_source->AddBoolean(
- "showKioskNextShell",
- base::FeatureList::IsEnabled(ash::features::kKioskNextShell));
-
- html_source->AddBoolean("showCrostini",
- crostini::IsCrostiniUIAllowedForProfile(
- profile, false /* check_policy */));
-
- html_source->AddBoolean("allowCrostini",
- crostini::IsCrostiniUIAllowedForProfile(profile));
-
- html_source->AddBoolean("isDemoSession",
- chromeos::DemoSession::IsDeviceInDemoMode());
-
- html_source->AddBoolean("assistantEnabled",
- chromeos::switches::IsAssistantEnabled());
-
- // 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
- // available once settings app is registered in the system.
- // For AOSP images we don't have the Play Store app. In last case we Android
- // apps settings consists only from root link to Android settings and only
- // visible once settings app is registered.
- html_source->AddBoolean("androidAppsVisible",
- arc::IsArcAllowedForProfile(profile));
- html_source->AddBoolean("havePlayStoreApp", arc::IsPlayStoreAvailable());
-
- // 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>(
- profile->GetPrefs()));
- }
-#else // !defined(OS_CHROMEOS)
+#if !defined(OS_CHROMEOS)
html_source->AddBoolean(
"diceEnabled",
AccountConsistencyModeManager::IsDiceEnabledForProfile(profile));
-#endif // defined(OS_CHROMEOS)
+#endif // !defined(OS_CHROMEOS)
html_source->AddBoolean("unifiedConsentEnabled",
unified_consent::IsUnifiedConsentFeatureEnabled());
@@ -383,6 +283,13 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source->AddBoolean("showImportPasswords",
base::FeatureList::IsEnabled(
password_manager::features::kPasswordImport));
+#if defined(OS_CHROMEOS)
+ html_source->AddBoolean(
+ "showOSSettings",
+ !base::FeatureList::IsEnabled(chromeos::features::kSplitSettings));
+#else
+ html_source->AddBoolean("showOSSettings", false);
+#endif
AddSettingsPageUIHandler(
base::WrapUnique(AboutHandler::Create(html_source, profile)));
@@ -394,6 +301,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
#if defined(OS_CHROMEOS)
// Add the System Web App resources for Settings.
+ // TODO(jamescook|calamity): Migrate to chromeos::settings::OSSettingsUI.
if (web_app::SystemWebAppManager::IsEnabled()) {
html_source->AddResourcePath("icon-192.png", IDR_SETTINGS_LOGO_192);
html_source->AddResourcePath("pwa.html", IDR_PWA_HTML);
@@ -407,16 +315,16 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
#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("crisper.js", IDR_SETTINGS_CRISPER_JS);
html_source->AddResourcePath("lazy_load.crisper.js",
- IDR_MD_SETTINGS_LAZY_LOAD_CRISPER_JS);
- html_source->AddResourcePath(
- "lazy_load.html", use_polymer_2
- ? IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML
- : IDR_MD_SETTINGS_LAZY_LOAD_VULCANIZED_HTML);
+ IDR_SETTINGS_LAZY_LOAD_CRISPER_JS);
+ html_source->AddResourcePath("lazy_load.html",
+ use_polymer_2
+ ? IDR_SETTINGS_LAZY_LOAD_VULCANIZED_P2_HTML
+ : IDR_SETTINGS_LAZY_LOAD_VULCANIZED_HTML);
html_source->SetDefaultResource(use_polymer_2
- ? IDR_MD_SETTINGS_VULCANIZED_P2_HTML
- : IDR_MD_SETTINGS_VULCANIZED_HTML);
+ ? IDR_SETTINGS_VULCANIZED_P2_HTML
+ : IDR_SETTINGS_VULCANIZED_HTML);
html_source->UseGzip(base::BindRepeating(
[](const std::vector<std::string>& excluded_paths,
const std::string& path) {
@@ -424,7 +332,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
},
std::move(exclude_from_gzip)));
#if defined(OS_CHROMEOS)
- html_source->AddResourcePath("manifest.json", IDR_MD_SETTINGS_MANIFEST);
+ html_source->AddResourcePath("manifest.json", IDR_SETTINGS_MANIFEST);
#endif // defined (OS_CHROMEOS)
#else
// Add all settings resources.
@@ -444,15 +352,15 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source);
}
-MdSettingsUI::~MdSettingsUI() {}
+SettingsUI::~SettingsUI() {}
-void MdSettingsUI::AddSettingsPageUIHandler(
+void SettingsUI::AddSettingsPageUIHandler(
std::unique_ptr<content::WebUIMessageHandler> handler) {
DCHECK(handler);
web_ui()->AddMessageHandler(std::move(handler));
}
-void MdSettingsUI::DidStartNavigation(
+void SettingsUI::DidStartNavigation(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsSameDocument())
return;
@@ -460,15 +368,140 @@ void MdSettingsUI::DidStartNavigation(
load_start_time_ = base::Time::Now();
}
-void MdSettingsUI::DocumentLoadedInFrame(
+void SettingsUI::DocumentLoadedInFrame(
content::RenderFrameHost* render_frame_host) {
UMA_HISTOGRAM_TIMES("Settings.LoadDocumentTime.MD",
base::Time::Now() - load_start_time_);
}
-void MdSettingsUI::DocumentOnLoadCompletedInMainFrame() {
+void SettingsUI::DocumentOnLoadCompletedInMainFrame() {
UMA_HISTOGRAM_TIMES("Settings.LoadCompletedTime.MD",
base::Time::Now() - load_start_time_);
}
+#if defined(OS_CHROMEOS)
+// static
+void SettingsUI::InitOSWebUIHandlers(Profile* profile,
+ content::WebUI* web_ui,
+ content::WebUIDataSource* html_source) {
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::AccessibilityHandler>(web_ui));
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::AndroidAppsHandler>(profile));
+ if (crostini::IsCrostiniUIAllowedForProfile(profile,
+ false /* check_policy */)) {
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::CrostiniHandler>(profile));
+ }
+ web_ui->AddMessageHandler(
+ chromeos::settings::CupsPrintersHandler::Create(web_ui));
+ web_ui->AddMessageHandler(base::WrapUnique(
+ chromeos::settings::DateTimeHandler::Create(html_source)));
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::FingerprintHandler>(profile));
+ if (chromeos::switches::IsAssistantEnabled()) {
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::GoogleAssistantHandler>(profile));
+ }
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::KeyboardHandler>());
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::PointerHandler>());
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::StorageHandler>(profile));
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::StylusHandler>());
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::InternetHandler>(profile));
+ web_ui->AddMessageHandler(std::make_unique<TtsHandler>());
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::smb_dialog::SmbHandler>(profile));
+
+ if (!profile->IsGuestSession()) {
+ chromeos::android_sms::AndroidSmsService* android_sms_service =
+ chromeos::android_sms::AndroidSmsServiceFactory::GetForBrowserContext(
+ profile);
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::MultideviceHandler>(
+ profile->GetPrefs(),
+ chromeos::multidevice_setup::MultiDeviceSetupClientFactory::
+ GetForProfile(profile),
+ android_sms_service
+ ? android_sms_service->android_sms_pairing_state_tracker()
+ : nullptr,
+ android_sms_service ? android_sms_service->android_sms_app_manager()
+ : nullptr));
+ }
+
+ html_source->AddBoolean(
+ "multideviceAllowedByPolicy",
+ chromeos::multidevice_setup::AreAnyMultiDeviceFeaturesAllowed(
+ profile->GetPrefs()));
+ html_source->AddBoolean(
+ "quickUnlockEnabled",
+ chromeos::quick_unlock::IsPinEnabled(profile->GetPrefs()));
+ html_source->AddBoolean(
+ "quickUnlockDisabledByPolicy",
+ chromeos::quick_unlock::IsPinDisabledByPolicy(profile->GetPrefs()));
+ const bool fingerprint_unlock_enabled =
+ chromeos::quick_unlock::IsFingerprintEnabled(profile);
+ html_source->AddBoolean("fingerprintUnlockEnabled",
+ fingerprint_unlock_enabled);
+ if (fingerprint_unlock_enabled) {
+ html_source->AddBoolean(
+ "isFingerprintReaderOnKeyboard",
+ chromeos::quick_unlock::IsFingerprintReaderOnKeyboard());
+ }
+ html_source->AddBoolean("lockScreenNotificationsEnabled",
+ ash::features::IsLockScreenNotificationsEnabled());
+ html_source->AddBoolean(
+ "lockScreenHideSensitiveNotificationsSupported",
+ ash::features::IsLockScreenHideSensitiveNotificationsSupported());
+ html_source->AddBoolean("showTechnologyBadge",
+ !ash::features::IsSeparateNetworkIconsEnabled());
+ html_source->AddBoolean("hasInternalStylus",
+ ash::stylus_utils::HasInternalStylus());
+
+ html_source->AddBoolean(
+ "showKioskNextShell",
+ base::FeatureList::IsEnabled(ash::features::kKioskNextShell));
+
+ html_source->AddBoolean("showCrostini",
+ crostini::IsCrostiniUIAllowedForProfile(
+ profile, false /* check_policy */));
+
+ html_source->AddBoolean("allowCrostini",
+ crostini::IsCrostiniUIAllowedForProfile(profile));
+
+ html_source->AddBoolean("showPluginVm",
+ plugin_vm::IsPluginVmEnabled(profile));
+
+ html_source->AddBoolean("isDemoSession",
+ chromeos::DemoSession::IsDeviceInDemoMode());
+
+ html_source->AddBoolean("assistantEnabled",
+ chromeos::switches::IsAssistantEnabled());
+
+ // 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
+ // available once settings app is registered in the system.
+ // For AOSP images we don't have the Play Store app. In last case we Android
+ // apps settings consists only from root link to Android settings and only
+ // visible once settings app is registered.
+ html_source->AddBoolean("androidAppsVisible",
+ arc::IsArcAllowedForProfile(profile));
+ html_source->AddBoolean("havePlayStoreApp", arc::IsPlayStoreAvailable());
+
+ // 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) {
+ web_ui->AddMessageHandler(
+ std::make_unique<chromeos::settings::PowerHandler>(
+ profile->GetPrefs()));
+ }
+}
+#endif // defined(OS_CHROMEOS)
+
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/settings_ui.h b/chromium/chrome/browser/ui/webui/settings/settings_ui.h
new file mode 100644
index 00000000000..c5c2fc9fa46
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/settings_ui.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_UI_H_
+
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_ui_controller.h"
+
+class Profile;
+
+namespace content {
+class WebUIDataSource;
+class WebUIMessageHandler;
+} // namespace content
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+namespace settings {
+
+// The WebUI handler for chrome://settings.
+class SettingsUI : public content::WebUIController,
+ public content::WebContentsObserver {
+ public:
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+
+ explicit SettingsUI(content::WebUI* web_ui);
+ ~SettingsUI() override;
+
+#if defined(OS_CHROMEOS)
+ // Initializes the WebUI message handlers for OS-specific settings.
+ static void InitOSWebUIHandlers(Profile* profile,
+ content::WebUI* web_ui,
+ content::WebUIDataSource* html_source);
+#endif // defined(OS_CHROMEOS)
+
+ // content::WebContentsObserver:
+ void DidStartNavigation(
+ content::NavigationHandle* navigation_handle) override;
+ void DocumentLoadedInFrame(
+ content::RenderFrameHost* render_frame_host) override;
+ void DocumentOnLoadCompletedInMainFrame() override;
+
+ private:
+ void AddSettingsPageUIHandler(
+ std::unique_ptr<content::WebUIMessageHandler> handler);
+
+ base::Time load_start_time_;
+
+ DISALLOW_COPY_AND_ASSIGN(SettingsUI);
+};
+
+} // namespace settings
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/settings/settings_ui_browsertest.cc
index da53ce1b369..459f2165900 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/settings/settings_ui_browsertest.cc
@@ -15,11 +15,11 @@
#include "content/public/common/url_constants.h"
#include "url/gurl.h"
-typedef InProcessBrowserTest MdSettingsUITest;
+typedef InProcessBrowserTest SettingsUITest;
using ui_test_utils::NavigateToURL;
-IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ViewSourceDoesntCrash) {
+IN_PROC_BROWSER_TEST_F(SettingsUITest, ViewSourceDoesntCrash) {
NavigateToURL(browser(),
GURL(content::kViewSourceScheme + std::string(":") +
chrome::kChromeUISettingsURL + std::string("strings.js")));
@@ -27,7 +27,7 @@ IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ViewSourceDoesntCrash) {
// Catch lifetime issues in message handlers. There was previously a problem
// with PrefMember calling Init again after Destroy.
-IN_PROC_BROWSER_TEST_F(MdSettingsUITest, ToggleJavaScript) {
+IN_PROC_BROWSER_TEST_F(SettingsUITest, ToggleJavaScript) {
NavigateToURL(browser(), GURL(chrome::kChromeUISettingsURL));
const auto& handlers = *browser()
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 3a6264360ce..ada32f07db7 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -29,6 +29,8 @@
#include "chrome/browser/permissions/permission_uma_util.h"
#include "chrome/browser/permissions/permission_util.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/serial/serial_chooser_context.h"
+#include "chrome/browser/serial/serial_chooser_context_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
@@ -207,8 +209,8 @@ void CreateOrAppendSiteGroupEntry(
// Update the storage data in |origin_size_map|.
void UpdateDataForOrigin(const GURL& url,
- const int size,
- std::map<std::string, int>* origin_size_map) {
+ const int64_t size,
+ std::map<std::string, int64_t>* origin_size_map) {
if (size > 0)
(*origin_size_map)[url.spec()] += size;
}
@@ -293,7 +295,7 @@ bool IsPatternValidForType(const std::string& pattern_string,
void UpdateDataFromCookiesTree(
std::map<std::string, std::set<std::string>>* all_sites_map,
- std::map<std::string, int>* origin_size_map,
+ std::map<std::string, int64_t>* origin_size_map,
const GURL& origin,
int64_t size) {
UpdateDataForOrigin(origin, size, origin_size_map);
@@ -762,7 +764,7 @@ void SiteSettingsHandler::HandleGetAllSites(const base::ListValue* args) {
}
base::Value SiteSettingsHandler::PopulateCookiesAndUsageData(Profile* profile) {
- std::map<std::string, int> origin_size_map;
+ std::map<std::string, int64_t> origin_size_map;
std::map<std::string, int> origin_cookie_map;
base::Value list_value(base::Value::Type::LIST);
@@ -787,7 +789,7 @@ base::Value SiteSettingsHandler::PopulateCookiesAndUsageData(Profile* profile) {
const std::string& origin = origin_info.FindKey("origin")->GetString();
const auto& size_info_it = origin_size_map.find(origin);
if (size_info_it != origin_size_map.end())
- origin_info.SetKey("usage", base::Value(size_info_it->second));
+ origin_info.SetKey("usage", base::Value(double(size_info_it->second)));
const auto& origin_cookie_num_it =
origin_cookie_map.find(GURL(origin).host());
if (origin_cookie_num_it != origin_cookie_map.end()) {
@@ -815,10 +817,10 @@ void SiteSettingsHandler::HandleGetFormattedBytes(const base::ListValue* args) {
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));
+ double num_bytes;
+ CHECK(args->GetDouble(1, &num_bytes));
- const base::string16 string = ui::FormatBytes(num_bytes);
+ const base::string16 string = ui::FormatBytes(int64_t(num_bytes));
ResolveJavascriptCallback(*callback_id, base::Value(string));
}
@@ -1370,6 +1372,10 @@ void SiteSettingsHandler::ObserveSourcesForProfile(Profile* profile) {
auto* usb_context = UsbChooserContextFactory::GetForProfile(profile);
if (!chooser_observer_.IsObserving(usb_context))
chooser_observer_.Add(usb_context);
+
+ auto* serial_context = SerialChooserContextFactory::GetForProfile(profile);
+ if (!chooser_observer_.IsObserving(serial_context))
+ chooser_observer_.Add(serial_context);
}
void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) {
@@ -1380,6 +1386,10 @@ void SiteSettingsHandler::StopObservingSourcesForProfile(Profile* profile) {
auto* usb_context = UsbChooserContextFactory::GetForProfile(profile);
if (chooser_observer_.IsObserving(usb_context))
chooser_observer_.Remove(usb_context);
+
+ auto* serial_context = SerialChooserContextFactory::GetForProfile(profile);
+ if (chooser_observer_.IsObserving(serial_context))
+ chooser_observer_.Remove(serial_context);
}
void SiteSettingsHandler::TreeNodesAdded(ui::TreeModel* model,
@@ -1409,7 +1419,7 @@ void SiteSettingsHandler::TreeModelEndBatch(CookiesTreeModel* model) {
void SiteSettingsHandler::GetOriginStorage(
std::map<std::string, std::set<std::string>>* all_sites_map,
- std::map<std::string, int>* origin_size_map) {
+ std::map<std::string, int64_t>* origin_size_map) {
CHECK(cookies_tree_model_.get());
const CookieTreeNode* root = cookies_tree_model_->GetRoot();
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 3bcce17eb02..862145c4de7 100644
--- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.h
@@ -121,6 +121,7 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, ZoomLevels);
FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest,
HandleClearEtldPlus1DataAndCookies);
+ FRIEND_TEST_ALL_PREFIXES(SiteSettingsHandlerTest, HandleGetFormattedBytes);
// Creates the CookiesTreeModel if necessary.
void EnsureCookiesTreeModelCreated();
@@ -134,7 +135,7 @@ class SiteSettingsHandler : public SettingsPageUIHandler,
// stores the information in the |all_sites_map| and |origin_size_map|.
void GetOriginStorage(
std::map<std::string, std::set<std::string>>* all_sites_map,
- std::map<std::string, int>* origin_size_map);
+ std::map<std::string, int64_t>* origin_size_map);
// Calculates the number of cookies for each etld+1 and each origin, and
// stores the information in the |all_sites_map| and |origin_cookie_map|.
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 9f481b1a55b..f728d26b1ec 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
@@ -11,6 +11,7 @@
#include "base/bind_helpers.h"
#include "base/json/json_reader.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/simple_test_clock.h"
#include "base/values.h"
@@ -50,6 +51,7 @@
#include "extensions/common/extension_builder.h"
#include "ppapi/buildflags/buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/text/bytes_formatting.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
@@ -423,7 +425,7 @@ class SiteSettingsHandlerTest : public testing::Test {
url::Origin::Create(GURL("https://www.example.com/")), 2);
mock_browsing_data_local_storage_helper->AddLocalStorageForOrigin(
- url::Origin::Create(GURL("https://www.google.com/")), 5);
+ url::Origin::Create(GURL("https://www.google.com/")), 50000000000);
mock_browsing_data_local_storage_helper->Notify();
mock_browsing_data_cookie_helper->AddCookieSamples(
@@ -760,7 +762,7 @@ TEST_F(SiteSettingsHandlerTest, OnStorageFetched) {
EXPECT_EQ("https://www.google.com/",
origin_info->FindKey("origin")->GetString());
EXPECT_EQ(0, origin_info->FindKey("engagement")->GetDouble());
- EXPECT_EQ(5, origin_info->FindKey("usage")->GetDouble());
+ EXPECT_EQ(50000000000, origin_info->FindKey("usage")->GetDouble());
EXPECT_EQ(0, origin_info->FindKey("numCookies")->GetDouble());
ASSERT_TRUE(storage_and_cookie_list->GetDictionary(2, &site_group));
@@ -1177,7 +1179,7 @@ class SiteSettingsHandlerInfobarTest : public BrowserWithTestWindowTest {
handler()->AllowJavascript();
web_ui()->ClearTrackedCalls();
- window2_ = base::WrapUnique(CreateBrowserWindow());
+ window2_ = CreateBrowserWindow();
browser2_ = base::WrapUnique(
CreateBrowser(profile(), browser()->type(), false, window2_.get()));
@@ -1868,4 +1870,20 @@ TEST_F(SiteSettingsHandlerTest, HandleClearEtldPlus1DataAndCookies) {
storage_and_cookie_list = GetOnStorageFetchedSentListValue();
EXPECT_EQ(0U, storage_and_cookie_list->GetSize());
}
+
+TEST_F(SiteSettingsHandlerTest, HandleGetFormattedBytes) {
+ const double size = 120000000000;
+ base::ListValue get_args;
+ get_args.AppendString(kCallbackId);
+ get_args.AppendDouble(size);
+ handler()->HandleGetFormattedBytes(&get_args);
+
+ // Validate that this method can handle large data.
+ 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());
+ EXPECT_EQ(base::UTF16ToUTF8(ui::FormatBytes(int64_t(size))),
+ data.arg3()->GetString());
+}
} // namespace settings
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 79535bb4a5f..8d4e51f12bd 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
@@ -35,7 +35,6 @@
#include "components/signin/core/browser/account_info.h"
#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/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h"
#include "components/unified_consent/feature.h"
@@ -281,11 +280,6 @@ void DiceTurnSyncOnHelper::OnEnterpriseAccountConfirmation(
}
void DiceTurnSyncOnHelper::TurnSyncOnWithProfileMode(ProfileMode profile_mode) {
- // Make sure the syncing is requested, otherwise the IdentityManager
- // will not be able to complete successfully.
- syncer::SyncPrefs sync_prefs(profile_->GetPrefs());
- sync_prefs.SetSyncRequested(true);
-
switch (profile_mode) {
case ProfileMode::CURRENT_PROFILE: {
// If this is a new signin (no account authenticated yet) try loading
@@ -443,6 +437,7 @@ void DiceTurnSyncOnHelper::SigninAndShowSyncConfirmationUI() {
// progress.
// TODO(https://crbug.com/811211): Remove this handle.
sync_blocker_ = sync_service->GetSetupInProgressHandle();
+ sync_service->GetUserSettings()->SetSyncRequested(true);
bool is_enterprise_user =
!policy::BrowserPolicyConnector::IsNonEnterpriseUser(
account_info_.email);
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 5c5288eb666..6450d648e88 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
@@ -10,7 +10,6 @@
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/run_loop.h"
-#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/policy/cloud/user_policy_signin_service.h"
#include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h"
@@ -23,15 +22,15 @@
#include "chrome/browser/signin/scoped_account_consistency.h"
#include "chrome/browser/signin/test_signin_client_builder.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
-#include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/account_id/account_id.h"
-#include "components/browser_sync/profile_sync_service_mock.h"
#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/signin_metrics.h"
#include "components/signin/core/browser/signin_pref_names.h"
+#include "components/sync/driver/mock_sync_service.h"
+#include "components/sync/driver/sync_user_settings_mock.h"
#include "components/unified_consent/feature.h"
#include "components/unified_consent/scoped_unified_consent.h"
#include "components/unified_consent/url_keyed_data_collection_consent_helper.h"
@@ -44,6 +43,7 @@
using ::testing::AtLeast;
using ::testing::Return;
+
using namespace unified_consent;
class DiceTurnSyncOnHelperTestBase;
@@ -169,6 +169,14 @@ class FakeUserPolicySigninService : public policy::UserPolicySigninService {
std::string email_;
};
+std::unique_ptr<KeyedService> BuildMockSyncService(
+ content::BrowserContext* context) {
+ auto service = std::make_unique<testing::NiceMock<syncer::MockSyncService>>();
+ ON_CALL(*service, IsAuthenticatedAccountPrimary())
+ .WillByDefault(Return(true));
+ return service;
+}
+
std::unique_ptr<TestingProfile> BuildTestingProfile(
const base::FilePath& path,
Profile::Delegate* delegate) {
@@ -176,9 +184,8 @@ std::unique_ptr<TestingProfile> BuildTestingProfile(
profile_builder.AddTestingFactory(
ChromeSigninClientFactory::GetInstance(),
base::BindRepeating(&signin::BuildTestSigninClient));
- profile_builder.AddTestingFactory(
- ProfileSyncServiceFactory::GetInstance(),
- base::BindRepeating(&BuildMockProfileSyncService));
+ profile_builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(),
+ base::BindRepeating(&BuildMockSyncService));
profile_builder.AddTestingFactory(
policy::UserPolicySigninServiceFactory::GetInstance(),
base::BindRepeating(&FakeUserPolicySigninService::Build));
@@ -243,9 +250,8 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test {
user_policy_signin_service_ = nullptr;
}
- // Gets the ProfileSyncServiceMock.
- browser_sync::ProfileSyncServiceMock* GetProfileSyncServiceMock() {
- return static_cast<browser_sync::ProfileSyncServiceMock*>(
+ syncer::MockSyncService* GetMockSyncService() {
+ return static_cast<syncer::MockSyncService*>(
ProfileSyncServiceFactory::GetForProfile(profile()));
}
@@ -266,22 +272,20 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test {
void UseInvalidAccount() { account_id_ = "invalid_account"; }
void SetExpectationsForSyncStartupCompleted() {
- browser_sync::ProfileSyncServiceMock* sync_service_mock =
- GetProfileSyncServiceMock();
- EXPECT_CALL(*sync_service_mock, GetSetupInProgressHandle()).Times(1);
- ON_CALL(*sync_service_mock, GetDisableReasons())
+ syncer::MockSyncService* mock_sync_service = GetMockSyncService();
+ EXPECT_CALL(*mock_sync_service, GetSetupInProgressHandle()).Times(1);
+ ON_CALL(*mock_sync_service, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*sync_service_mock, GetTransportState())
+ ON_CALL(*mock_sync_service, GetTransportState())
.WillByDefault(Return(syncer::SyncService::TransportState::ACTIVE));
}
void SetExpectationsForSyncStartupPending() {
- browser_sync::ProfileSyncServiceMock* sync_service_mock =
- GetProfileSyncServiceMock();
- EXPECT_CALL(*sync_service_mock, GetSetupInProgressHandle()).Times(1);
- ON_CALL(*sync_service_mock, GetDisableReasons())
+ syncer::MockSyncService* mock_sync_service = GetMockSyncService();
+ EXPECT_CALL(*mock_sync_service, GetSetupInProgressHandle()).Times(1);
+ ON_CALL(*mock_sync_service, GetDisableReasons())
.WillByDefault(Return(syncer::SyncService::DISABLE_REASON_NONE));
- ON_CALL(*sync_service_mock, GetTransportState())
+ ON_CALL(*mock_sync_service, GetTransportState())
.WillByDefault(
Return(syncer::SyncService::TransportState::INITIALIZING));
}
@@ -407,6 +411,7 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test {
identity_test_env_profile_adaptor_;
FakeUserPolicySigninService* user_policy_signin_service_ = nullptr;
std::string initial_device_id_;
+ testing::NiceMock<syncer::SyncUserSettingsMock> mock_sync_settings_;
// State of the delegate calls.
bool delegate_destroyed_ = false;
@@ -646,7 +651,7 @@ TEST_F(DiceTurnSyncOnHelperTest, UndoSync) {
// Set expectations.
expected_sync_confirmation_shown_ = true;
SetExpectationsForSyncStartupCompleted();
- EXPECT_CALL(*GetProfileSyncServiceMock()->GetUserSettingsMock(),
+ EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(),
SetFirstSetupComplete())
.Times(0);
@@ -666,7 +671,7 @@ TEST_F(DiceTurnSyncOnHelperTest, ConfigureSync) {
expected_sync_confirmation_shown_ = true;
expected_sync_settings_shown_ = true;
SetExpectationsForSyncStartupCompleted();
- EXPECT_CALL(*GetProfileSyncServiceMock()->GetUserSettingsMock(),
+ EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(),
SetFirstSetupComplete())
.Times(0);
@@ -688,7 +693,7 @@ TEST_F(DiceTurnSyncOnHelperTest, StartSync) {
// Set expectations.
expected_sync_confirmation_shown_ = true;
SetExpectationsForSyncStartupCompleted();
- EXPECT_CALL(*GetProfileSyncServiceMock()->GetUserSettingsMock(),
+ EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(),
SetFirstSetupComplete())
.Times(1);
// Configure the test.
@@ -712,7 +717,7 @@ TEST_F(DiceTurnSyncOnHelperTest, ShowSyncDialogForEndConsumerAccount) {
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
SYNC_WITH_DEFAULT_SETTINGS;
SetExpectationsForSyncStartupCompleted();
- EXPECT_CALL(*GetProfileSyncServiceMock()->GetUserSettingsMock(),
+ EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(),
SetFirstSetupComplete())
.Times(1);
@@ -736,7 +741,7 @@ TEST_F(DiceTurnSyncOnHelperTestWithUnifiedConsent,
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
SYNC_WITH_DEFAULT_SETTINGS;
SetExpectationsForSyncStartupCompleted();
- EXPECT_CALL(*GetProfileSyncServiceMock()->GetUserSettingsMock(),
+ EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(),
SetFirstSetupComplete())
.Times(1);
PrefService* pref_service = profile()->GetPrefs();
@@ -784,7 +789,7 @@ TEST_F(DiceTurnSyncOnHelperTest,
// Simulate that sync startup has completed.
expected_sync_confirmation_shown_ = true;
- EXPECT_CALL(*GetProfileSyncServiceMock()->GetUserSettingsMock(),
+ EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(),
SetFirstSetupComplete())
.Times(1);
sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult::
@@ -818,7 +823,7 @@ TEST_F(DiceTurnSyncOnHelperTest,
// Simulate that sync startup has failed.
expected_sync_confirmation_shown_ = true;
- EXPECT_CALL(*GetProfileSyncServiceMock()->GetUserSettingsMock(),
+ EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(),
SetFirstSetupComplete())
.Times(1);
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 d3bb605869e..b21e56639e3 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc
@@ -6,6 +6,7 @@
#include <limits.h>
#include <string>
+#include <vector>
#include "base/bind.h"
#include "base/metrics/user_metrics.h"
@@ -172,7 +173,8 @@ void InlineLoginHandler::HandleCompleteLoginMessage(
void InlineLoginHandler::HandleCompleteLoginMessageWithCookies(
const base::ListValue& args,
- const std::vector<net::CanonicalCookie>& cookies) {
+ const std::vector<net::CanonicalCookie>& cookies,
+ const net::CookieStatusList& excluded_cookies) {
const base::DictionaryValue* dict = nullptr;
args.GetDictionary(0, &dict);
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 053825a7427..4977139f011 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h
@@ -5,9 +5,12 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_H_
+#include <vector>
+
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "net/cookies/canonical_cookie.h"
namespace base {
class DictionaryValue;
@@ -62,7 +65,8 @@ class InlineLoginHandler : public content::WebUIMessageHandler {
// from the CookieManager.
void HandleCompleteLoginMessageWithCookies(
const base::ListValue& args,
- const std::vector<net::CanonicalCookie>& cookies);
+ const std::vector<net::CanonicalCookie>& cookies,
+ const net::CookieStatusList& excluded_cookies);
// JS callback to switch the UI from a constrainted dialog to a full tab.
void HandleSwitchToFullTabMessage(const base::ListValue* args);
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 8b85f1083f1..f5f0fe7ff8b 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
@@ -12,9 +12,10 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/webui/signin/inline_login_handler.h"
-#include "chromeos/account_manager/account_manager.h"
-#include "chromeos/account_manager/account_manager_factory.h"
+#include "chromeos/components/account_manager/account_manager.h"
+#include "chromeos/components/account_manager/account_manager_factory.h"
#include "components/signin/core/browser/account_info.h"
#include "google_apis/gaia/gaia_urls.h"
#include "services/identity/public/cpp/identity_manager.h"
@@ -56,10 +57,11 @@ class SigninHelper : public GaiaAuthConsumer {
void OnClientOAuthSuccess(const ClientOAuthResult& result) override {
// Flow of control after this call:
// |AccountManager::UpsertAccount| updates / inserts the account and calls
- // its |Observer|s, one of which is |ChromeOSOAuth2TokenServiceDelegate|.
- // |ChromeOSOAuth2TokenServiceDelegate::OnTokenUpserted| seeds the Gaia id
- // and email id for this account in |AccountTrackerService| and invokes
- // |FireRefreshTokenAvailable|. This causes the account to propagate
+ // its |Observer|s, one of which is
+ // |ProfileOAuth2TokenServiceDelegateChromeOS|.
+ // |ProfileOAuth2TokenServiceDelegateChromeOS::OnTokenUpserted| seeds the
+ // Gaia id and email id for this account in |AccountTrackerService| and
+ // invokes |FireRefreshTokenAvailable|. This causes the account to propagate
// throughout the Identity Service chain, including in
// |AccountFetcherService|. |AccountFetcherService::OnRefreshTokenAvailable|
// invokes |AccountTrackerService::StartTrackingAccount|, triggers a fetch
@@ -101,6 +103,16 @@ InlineLoginHandlerChromeOS::InlineLoginHandlerChromeOS(
InlineLoginHandlerChromeOS::~InlineLoginHandlerChromeOS() = default;
+void InlineLoginHandlerChromeOS::RegisterMessages() {
+ InlineLoginHandler::RegisterMessages();
+
+ web_ui()->RegisterMessageCallback(
+ "showIncognito",
+ base::BindRepeating(
+ &InlineLoginHandlerChromeOS::ShowIncognitoAndCloseDialog,
+ base::Unretained(this)));
+}
+
void InlineLoginHandlerChromeOS::SetExtraInitParams(
base::DictionaryValue& params) {
const GaiaUrls* const gaia_urls = GaiaUrls::GetInstance();
@@ -143,4 +155,10 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const std::string& email,
auth_code);
}
+void InlineLoginHandlerChromeOS::ShowIncognitoAndCloseDialog(
+ const base::ListValue* args) {
+ chrome::NewIncognitoWindow(Profile::FromWebUI(web_ui()));
+ close_dialog_closure_.Run();
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.h
index 70739fbeb89..415bf57ea09 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
@@ -5,9 +5,10 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_CHROMEOS_H_
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_CHROMEOS_H_
+#include <string>
+
#include "base/macros.h"
#include "chrome/browser/ui/webui/signin/inline_login_handler.h"
-#include "chromeos/account_manager/account_manager.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "google_apis/gaia/gaia_auth_fetcher.h"
@@ -20,6 +21,7 @@ class InlineLoginHandlerChromeOS : public InlineLoginHandler {
~InlineLoginHandlerChromeOS() override;
// InlineLoginHandler overrides.
+ void RegisterMessages() override;
void SetExtraInitParams(base::DictionaryValue& params) override;
void CompleteLogin(const std::string& email,
const std::string& password,
@@ -31,6 +33,8 @@ class InlineLoginHandlerChromeOS : public InlineLoginHandler {
bool choose_what_to_sync) override;
private:
+ void ShowIncognitoAndCloseDialog(const base::ListValue* args);
+
base::RepeatingClosure close_dialog_closure_;
DISALLOW_COPY_AND_ASSIGN(InlineLoginHandlerChromeOS);
};
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.cc
index a6dbae9d3f4..aaab6f09281 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.cc
@@ -4,14 +4,18 @@
#include "chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h"
+#include <algorithm>
#include <string>
#include "base/logging.h"
#include "base/macros.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
#include "chrome/common/webui_url_constants.h"
+#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "net/base/url_util.h"
#include "ui/aura/window.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
#include "url/gurl.h"
namespace chromeos {
@@ -19,6 +23,8 @@ namespace chromeos {
namespace {
InlineLoginHandlerDialogChromeOS* dialog = nullptr;
+constexpr int kSigninDialogWidth = 768;
+constexpr int kSigninDialogHeight = 640;
} // namespace
@@ -40,15 +46,47 @@ void InlineLoginHandlerDialogChromeOS::Show(const std::string& email) {
dialog->ShowSystemDialog();
}
+gfx::Size InlineLoginHandlerDialogChromeOS::GetMaximumDialogSize() {
+ gfx::Size size;
+ GetDialogSize(&size);
+ return size;
+}
+
+gfx::NativeView InlineLoginHandlerDialogChromeOS::GetHostView() const {
+ return dialog_window();
+}
+
+gfx::Point InlineLoginHandlerDialogChromeOS::GetDialogPosition(
+ const gfx::Size& size) {
+ gfx::Size host_size = GetHostView()->bounds().size();
+
+ // Show all sub-dialogs at center-top.
+ return gfx::Point(std::max(0, (host_size.width() - size.width()) / 2), 0);
+}
+
+void InlineLoginHandlerDialogChromeOS::AddObserver(
+ web_modal::ModalDialogHostObserver* observer) {}
+
+void InlineLoginHandlerDialogChromeOS::RemoveObserver(
+ web_modal::ModalDialogHostObserver* observer) {}
+
InlineLoginHandlerDialogChromeOS::InlineLoginHandlerDialogChromeOS(
const GURL& url)
- : SystemWebDialogDelegate(url, base::string16() /* title */) {}
+ : SystemWebDialogDelegate(url, base::string16() /* title */),
+ delegate_(this) {}
InlineLoginHandlerDialogChromeOS::~InlineLoginHandlerDialogChromeOS() {
DCHECK_EQ(this, dialog);
dialog = nullptr;
}
+void InlineLoginHandlerDialogChromeOS::GetDialogSize(gfx::Size* size) const {
+ const display::Display display =
+ display::Screen::GetScreen()->GetDisplayNearestWindow(dialog_window());
+ size->SetSize(std::min(kSigninDialogWidth, display.work_area().width()),
+ std::min(kSigninDialogHeight, display.work_area().height()));
+}
+
std::string InlineLoginHandlerDialogChromeOS::GetDialogArgs() const {
return std::string();
}
@@ -57,10 +95,15 @@ bool InlineLoginHandlerDialogChromeOS::ShouldShowDialogTitle() const {
return false;
}
-void InlineLoginHandlerDialogChromeOS::GetDialogSize(gfx::Size* size) const {
- constexpr int kSigninDialogWidth = 800;
- constexpr int kSigninDialogHeight = 700;
- size->SetSize(kSigninDialogWidth, kSigninDialogHeight);
+void InlineLoginHandlerDialogChromeOS::OnDialogShown(
+ content::WebUI* webui,
+ content::RenderViewHost* render_view_host) {
+ SystemWebDialogDelegate::OnDialogShown(webui, render_view_host);
+ web_modal::WebContentsModalDialogManager::CreateForWebContents(
+ webui->GetWebContents());
+ web_modal::WebContentsModalDialogManager::FromWebContents(
+ webui->GetWebContents())
+ ->SetDelegate(&delegate_);
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h
index 192f1bea66f..703e4a2f9f4 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.h
@@ -9,6 +9,8 @@
#include "base/macros.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+#include "chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.h"
+#include "components/web_modal/web_contents_modal_dialog_host.h"
class GURL;
@@ -17,13 +19,22 @@ namespace chromeos {
// Extends from |SystemWebDialogDelegate| to create an always-on-top but movable
// dialog. It is intentionally made movable so that users can copy-paste account
// passwords from password managers.
-class InlineLoginHandlerDialogChromeOS : public SystemWebDialogDelegate {
+class InlineLoginHandlerDialogChromeOS
+ : public SystemWebDialogDelegate,
+ public web_modal::WebContentsModalDialogHost {
public:
// Displays the dialog. |email| is an optional parameter that if provided,
// pre-fills the account email field in the sign-in dialog - useful for
// account re-authentication.
static void Show(const std::string& email = std::string());
+ // web_modal::WebContentsModalDialogHost overrides.
+ gfx::Size GetMaximumDialogSize() override;
+ gfx::NativeView GetHostView() const override;
+ gfx::Point GetDialogPosition(const gfx::Size& size) override;
+ void AddObserver(web_modal::ModalDialogHostObserver* observer) override;
+ void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override;
+
protected:
explicit InlineLoginHandlerDialogChromeOS(const GURL& url);
~InlineLoginHandlerDialogChromeOS() override;
@@ -32,8 +43,12 @@ class InlineLoginHandlerDialogChromeOS : public SystemWebDialogDelegate {
void GetDialogSize(gfx::Size* size) const override;
std::string GetDialogArgs() const override;
bool ShouldShowDialogTitle() const override;
+ void OnDialogShown(content::WebUI* webui,
+ content::RenderViewHost* render_view_host) override;
private:
+ InlineLoginHandlerModalDelegate delegate_;
+
DISALLOW_COPY_AND_ASSIGN(InlineLoginHandlerDialogChromeOS);
};
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 b7f731e557f..d1badaaf985 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
@@ -360,12 +360,6 @@ void InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened(
identity::IdentityManager* identity_manager =
IdentityManagerFactory::GetForProfile(profile_);
- // Seed the account with this combination of gaia id/display email.
- AccountInfo account_info;
- account_info.gaia = gaia_id_;
- account_info.email = email_;
- identity_manager->LegacySeedAccountInfo(account_info);
-
std::string primary_email = identity_manager->GetPrimaryAccountInfo().email;
if (gaia::AreEmailsSame(email_, primary_email) &&
reason == HandlerSigninReason::UNLOCK && !password_.empty() &&
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.cc
new file mode 100644
index 00000000000..c231c7b408f
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.cc
@@ -0,0 +1,23 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.h"
+
+#include "base/logging.h"
+#include "content/public/browser/web_contents.h"
+
+namespace chromeos {
+
+InlineLoginHandlerModalDelegate::InlineLoginHandlerModalDelegate(
+ web_modal::WebContentsModalDialogHost* host)
+ : host_(host) {}
+
+InlineLoginHandlerModalDelegate::~InlineLoginHandlerModalDelegate() = default;
+
+web_modal::WebContentsModalDialogHost*
+InlineLoginHandlerModalDelegate::GetWebContentsModalDialogHost() {
+ return host_;
+}
+
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.h
new file mode 100644
index 00000000000..8ca37afab8a
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_modal_delegate.h
@@ -0,0 +1,38 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_MODAL_DELEGATE_H_
+#define CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_MODAL_DELEGATE_H_
+
+#include "base/macros.h"
+#include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
+
+namespace chromeos {
+
+// Used to display sub-modals inside |InlineLoginHandlerDialogChromeOS| modal
+// dialog, e.g. displaying a dialog for accounts using 2FA with WebAuthn,
+// where users can select alternate 2FAs.
+class InlineLoginHandlerModalDelegate
+ : public ChromeWebModalDialogManagerDelegate {
+ public:
+ // |host| is a non owning pointer to the host dialog of this delegate
+ // (|InlineLoginHandlerDialogChromeOS|).
+ explicit InlineLoginHandlerModalDelegate(
+ web_modal::WebContentsModalDialogHost* host);
+ ~InlineLoginHandlerModalDelegate() override;
+
+ // web_modal::WebContentsModalDialogManagerDelegate overrides.
+ web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
+ override;
+
+ private:
+ // Non-owning pointer.
+ web_modal::WebContentsModalDialogHost* host_;
+
+ DISALLOW_COPY_AND_ASSIGN(InlineLoginHandlerModalDelegate);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_INLINE_LOGIN_HANDLER_MODAL_DELEGATE_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
index 6891b2cbe55..db04d07091f 100644
--- a/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/inline_login_ui.cc
@@ -46,8 +46,10 @@ content::WebUIDataSource* CreateWebUIDataSource() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
const bool is_running_test = command_line->HasSwitch(::switches::kTestName) ||
command_line->HasSwitch(::switches::kTestType);
- if (is_running_test)
- source->SetRequestFilter(test::GetTestFilesRequestFilter());
+ if (is_running_test) {
+ source->SetRequestFilter(test::GetTestShouldHandleRequest(),
+ test::GetTestFilesRequestFilter());
+ }
source->AddResourcePath("inline_login.css", IDR_INLINE_LOGIN_CSS);
source->AddResourcePath("inline_login.js", IDR_INLINE_LOGIN_JS);
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 71a622f4256..9913b9afa6d 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
@@ -54,7 +54,7 @@ class SignInObserver : public identity::IdentityManager::Observer {
}
// Blocks and waits until the user signs in. Wait() does not block if a
- // GoogleSigninSucceeded or a GoogleSigninFailed has already occurred.
+ // GoogleSigninSucceeded has already occurred.
void Wait() {
if (seen_)
return;
@@ -65,12 +65,6 @@ class SignInObserver : public identity::IdentityManager::Observer {
EXPECT_TRUE(seen_);
}
- void OnPrimaryAccountSigninFailed(
- const GoogleServiceAuthError& error) override {
- DVLOG(1) << "Google signin failed.";
- QuitLoopRunner();
- }
-
void OnPrimaryAccountSet(
const CoreAccountInfo& primary_account_info) override {
DVLOG(1) << "Google signin succeeded.";
@@ -199,11 +193,16 @@ class SigninViewControllerTestUtil {
content::WebContents* dialog_web_contents =
signin_view_controller->GetModalDialogWebContentsForTesting();
DCHECK_NE(dialog_web_contents, nullptr);
+ std::string confirm_button_selector =
+ "document.querySelector('sync-confirmation-app').shadowRoot."
+ "querySelector('#confirmButton')";
std::string message;
std::string find_button_js =
"if (document.readyState != 'complete') {"
" window.domAutomationController.send('DocumentNotReady');"
- "} else if (document.getElementById('confirmButton') == null) {"
+ "} else if (" +
+ confirm_button_selector +
+ " == null) {"
" window.domAutomationController.send('NotFound');"
"} else {"
" window.domAutomationController.send('Ok');"
@@ -215,9 +214,8 @@ class SigninViewControllerTestUtil {
// This cannot be a synchronous call, because it closes the window as a side
// effect, which may cause the javascript execution to never finish.
- content::ExecuteScriptAsync(
- dialog_web_contents,
- "document.getElementById('confirmButton').click();");
+ content::ExecuteScriptAsync(dialog_web_contents,
+ confirm_button_selector + ".click();");
return true;
#endif
}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc
index 051b16da16b..1f5e003de36 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/signin_error_handler_unittest.cc
@@ -102,8 +102,8 @@ class SigninErrorHandlerTest : public BrowserWithTestWindowTest {
content::TestWebUI* web_ui() { return web_ui_.get(); }
// BrowserWithTestWindowTest
- BrowserWindow* CreateBrowserWindow() override {
- return new DialogTestBrowserWindow;
+ std::unique_ptr<BrowserWindow> CreateBrowserWindow() override {
+ return std::make_unique<DialogTestBrowserWindow>();
}
private:
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 a72cddaef77..e1d569f56f3 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc
@@ -102,13 +102,16 @@ void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) {
void SyncConfirmationHandler::HandleAccountImageRequest(
const base::ListValue* args) {
- AccountInfo account_info = identity_manager_->GetPrimaryAccountInfo();
+ base::Optional<AccountInfo> primary_account_info =
+ identity_manager_->FindExtendedAccountInfoForAccount(
+ identity_manager_->GetPrimaryAccountInfo());
// Fire the "account-image-changed" listener from |SetUserImageURL()|.
// Note: If the account info is not available yet in the
// IdentityManager, i.e. account_info is empty, the listener will be
// fired again through |OnAccountUpdated()|.
- SetUserImageURL(account_info.picture_url);
+ if (primary_account_info)
+ SetUserImageURL(primary_account_info->picture_url);
}
void SyncConfirmationHandler::RecordConsent(const base::ListValue* args) {
@@ -222,18 +225,20 @@ void SyncConfirmationHandler::HandleInitializedWithSize(
if (!browser_)
return;
- if (!identity_manager_->HasPrimaryAccount()) {
+ base::Optional<AccountInfo> primary_account_info =
+ identity_manager_->FindExtendedAccountInfoForAccount(
+ identity_manager_->GetPrimaryAccountInfo());
+ if (!primary_account_info) {
// No account is signed in, so there is nothing to be displayed in the sync
// confirmation dialog.
return;
}
- AccountInfo account_info = identity_manager_->GetPrimaryAccountInfo();
- if (!account_info.IsValid()) {
+ if (!primary_account_info->IsValid()) {
SetUserImageURL(kNoPictureURLFound);
identity_manager_->AddObserver(this);
} else {
- SetUserImageURL(account_info.picture_url);
+ SetUserImageURL(primary_account_info->picture_url);
}
signin::SetInitializedModalHeight(browser_, web_ui(), args);
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
index 3b94cf31075..4e4a3a9bb6c 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc
@@ -129,8 +129,8 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
return identity_test_env_adaptor_->identity_test_env();
}
- BrowserWindow* CreateBrowserWindow() override {
- return new DialogTestBrowserWindow;
+ std::unique_ptr<BrowserWindow> CreateBrowserWindow() override {
+ return std::make_unique<DialogTestBrowserWindow>();
}
TestingProfile::TestingFactories GetTestingFactories() override {
@@ -167,10 +167,14 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
ASSERT_TRUE(call_data.arg1()->GetAsString(&event));
EXPECT_EQ("account-image-changed", event);
+ identity::IdentityManager* identity_manager =
+ IdentityManagerFactory::GetForProfile(profile());
+ base::Optional<AccountInfo> primary_account =
+ identity_manager->FindExtendedAccountInfoForAccount(
+ identity_manager->GetPrimaryAccountInfo());
+
std::string original_picture_url =
- IdentityManagerFactory::GetForProfile(profile())
- ->GetPrimaryAccountInfo()
- .picture_url;
+ primary_account ? primary_account->picture_url : std::string();
std::string expected_picture_url =
original_picture_url.empty()
? profiles::GetPlaceholderAvatarIconUrl()
@@ -206,13 +210,27 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest,
DISALLOW_COPY_AND_ASSIGN(SyncConfirmationHandlerTest);
};
+class SyncConfirmationHandlerTest_UnifiedConsentDisabled
+ : public SyncConfirmationHandlerTest {
+ public:
+ SyncConfirmationHandlerTest_UnifiedConsentDisabled()
+ : scoped_unified_consent_(
+ unified_consent::UnifiedConsentFeatureState::kDisabled) {}
+
+ private:
+ unified_consent::ScopedUnifiedConsent scoped_unified_consent_;
+
+ DISALLOW_COPY_AND_ASSIGN(SyncConfirmationHandlerTest_UnifiedConsentDisabled);
+};
+
const char SyncConfirmationHandlerTest::kConsentText1[] = "consentText1";
const char SyncConfirmationHandlerTest::kConsentText2[] = "consentText2";
const char SyncConfirmationHandlerTest::kConsentText3[] = "consentText3";
const char SyncConfirmationHandlerTest::kConsentText4[] = "consentText4";
const char SyncConfirmationHandlerTest::kConsentText5[] = "consentText5";
-TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReady) {
+TEST_F(SyncConfirmationHandlerTest_UnifiedConsentDisabled,
+ TestSetImageIfPrimaryAccountReady) {
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info_.account_id, account_info_.email, account_info_.gaia, "",
"full_name", "given_name", "locale",
@@ -235,21 +253,20 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReady) {
EXPECT_EQ("sync.confirmation.clearFocus",
web_ui()->call_data()[1]->function_name());
+ identity::IdentityManager* identity_manager =
+ IdentityManagerFactory::GetForProfile(profile());
+ base::Optional<AccountInfo> primary_account_info =
+ identity_manager->FindExtendedAccountInfoForAccount(
+ identity_manager->GetPrimaryAccountInfo());
std::string original_picture_url =
- IdentityManagerFactory::GetForProfile(profile())
- ->GetPrimaryAccountInfo()
- .picture_url;
+ primary_account_info ? primary_account_info->picture_url : std::string();
GURL picture_url_with_size = signin::GetAvatarImageURLWithOptions(
GURL(original_picture_url), kExpectedProfileImageSize,
false /* no_silhouette */);
EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url);
}
-TEST_F(SyncConfirmationHandlerTest,
- TestSetImageIfPrimaryAccountReady_UnifiedConsent) {
- unified_consent::ScopedUnifiedConsent scoped_unified_consent(
- unified_consent::UnifiedConsentFeatureState::kEnabled);
-
+TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReady) {
identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
account_info_.account_id, account_info_.email, account_info_.gaia, "",
"full_name", "given_name", "locale",
@@ -264,7 +281,8 @@ TEST_F(SyncConfirmationHandlerTest,
web_ui()->call_data()[1]->function_name());
}
-TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) {
+TEST_F(SyncConfirmationHandlerTest_UnifiedConsentDisabled,
+ TestSetImageIfPrimaryAccountReadyLater) {
base::ListValue args;
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
handler()->HandleInitializedWithSize(&args);
@@ -298,21 +316,21 @@ TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) {
EXPECT_TRUE(
web_ui()->call_data()[2]->arg1()->GetAsString(&passed_picture_url));
+ identity::IdentityManager* identity_manager =
+ IdentityManagerFactory::GetForProfile(profile());
+ base::Optional<AccountInfo> primary_account_info =
+ identity_manager->FindExtendedAccountInfoForAccount(
+ identity_manager->GetPrimaryAccountInfo());
+
std::string original_picture_url =
- IdentityManagerFactory::GetForProfile(profile())
- ->GetPrimaryAccountInfo()
- .picture_url;
+ primary_account_info ? primary_account_info->picture_url : std::string();
GURL picture_url_with_size = signin::GetAvatarImageURLWithOptions(
GURL(original_picture_url), kExpectedProfileImageSize,
false /* no_silhouette */);
EXPECT_EQ(picture_url_with_size.spec(), passed_picture_url);
}
-TEST_F(SyncConfirmationHandlerTest,
- TestSetImageIfPrimaryAccountReadyLater_UnifiedConsent) {
- unified_consent::ScopedUnifiedConsent scoped_unified_consent(
- unified_consent::UnifiedConsentFeatureState::kEnabled);
-
+TEST_F(SyncConfirmationHandlerTest, TestSetImageIfPrimaryAccountReadyLater) {
base::ListValue args;
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
handler()->HandleInitializedWithSize(&args);
@@ -331,7 +349,7 @@ TEST_F(SyncConfirmationHandlerTest,
ExpectAccountImageChanged(*web_ui()->call_data()[2]);
}
-TEST_F(SyncConfirmationHandlerTest,
+TEST_F(SyncConfirmationHandlerTest_UnifiedConsentDisabled,
TestSetImageIgnoredIfSecondaryAccountUpdated) {
base::ListValue args;
args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
@@ -361,6 +379,35 @@ TEST_F(SyncConfirmationHandlerTest,
web_ui()->call_data()[2]->function_name());
}
+TEST_F(SyncConfirmationHandlerTest,
+ TestSetImageIgnoredIfSecondaryAccountUpdated) {
+ base::ListValue args;
+ args.Set(0, std::make_unique<base::Value>(kDefaultDialogHeight));
+ handler()->HandleInitializedWithSize(&args);
+ EXPECT_EQ(2U, web_ui()->call_data().size());
+
+ AccountInfo account_info =
+ identity_test_env()->MakeAccountAvailable("bar@example.com");
+ identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
+ account_info.account_id, account_info.email, account_info.gaia, "",
+ "bar_full_name", "bar_given_name", "bar_locale",
+ "http://picture.example.com/bar_picture.jpg");
+
+ // Updating the account info of a secondary account should not update the
+ // image of the sync confirmation dialog.
+ EXPECT_EQ(2U, web_ui()->call_data().size());
+
+ identity_test_env()->SimulateSuccessfulFetchOfAccountInfo(
+ account_info_.account_id, account_info_.email, account_info_.gaia, "",
+ "full_name", "given_name", "locale",
+ "http://picture.example.com/picture.jpg");
+
+ // Updating the account info of the primary account should update the
+ // image of the sync confirmation dialog.
+ EXPECT_EQ(3U, web_ui()->call_data().size());
+ ExpectAccountImageChanged(*web_ui()->call_data()[2]);
+}
+
TEST_F(SyncConfirmationHandlerTest, TestHandleUndo) {
handler()->HandleUndo(nullptr);
did_user_explicitly_interact = true;
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 572e5cf4b78..81e3ec8ec9f 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/ui/webui/dark_mode_handler.h"
#include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -66,9 +67,14 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
constexpr int kAccountPictureSize = 68;
std::string custom_picture_url = profiles::GetPlaceholderAvatarIconUrl();
- GURL account_picture_url(IdentityManagerFactory::GetForProfile(profile)
- ->GetPrimaryAccountInfo()
- .picture_url);
+ identity::IdentityManager* identity_manager =
+ IdentityManagerFactory::GetForProfile(profile);
+ base::Optional<AccountInfo> primary_account_info =
+ identity_manager->FindExtendedAccountInfoForAccount(
+ identity_manager->GetPrimaryAccountInfo());
+ GURL account_picture_url(primary_account_info
+ ? primary_account_info->picture_url
+ : std::string());
if (account_picture_url.is_valid()) {
custom_picture_url = signin::GetAvatarImageURLWithOptions(
account_picture_url, kAccountPictureSize,
@@ -83,7 +89,6 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
consent_feature_ = consent_auditor::Feature::CHROME_UNIFIED_CONSENT;
} else {
source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML);
- source->AddResourcePath("sync_confirmation.css", IDR_SYNC_CONFIRMATION_CSS);
source->AddResourcePath("sync_confirmation.js", IDR_SYNC_CONFIRMATION_JS);
source->AddBoolean("isSyncAllowed", is_sync_allowed);
@@ -127,6 +132,7 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
g_browser_process->GetApplicationLocale(), &strings);
source->AddLocalizedStrings(strings);
+ DarkModeHandler::Initialize(web_ui, source);
content::WebUIDataSource::Add(profile, source);
}
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 b32dc6c2f64..91ffa6957bc 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
@@ -631,8 +631,6 @@ void UserManagerScreenHandler::GetLocalizedValues(
localized_strings->SetString("cancel", l10n_util::GetStringUTF16(IDS_CANCEL));
localized_strings->SetString(
"browseAsGuest", l10n_util::GetStringUTF16(IDS_BROWSE_AS_GUEST_BUTTON));
- localized_strings->SetString("signOutUser",
- l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_SIGN_OUT));
localized_strings->SetString("addSupervisedUser",
l10n_util::GetStringUTF16(IDS_CREATE_LEGACY_SUPERVISED_USER_MENU_LABEL));
@@ -733,7 +731,6 @@ void UserManagerScreenHandler::GetLocalizedValues(
localized_strings->SetString("publicSessionSelectLanguage", "");
localized_strings->SetString("publicSessionSelectKeyboard", "");
localized_strings->SetString("signinBannerText", "");
- localized_strings->SetString("launchAppButton", "");
localized_strings->SetString("multiProfilesRestrictedPolicyTitle", "");
localized_strings->SetString("multiProfilesNotAllowedPolicyMsg", "");
localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg", "");
diff --git a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc b/chromium/chrome/browser/ui/webui/signin/user_manager_ui.cc
index 7c65f834aaa..5b44baeee16 100644
--- a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/user_manager_ui.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/webui/signin/md_user_manager_ui.h"
+#include "chrome/browser/ui/webui/signin/user_manager_ui.h"
#include <memory>
#include <string>
@@ -27,8 +27,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
-MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui)
- : WebUIController(web_ui) {
+UserManagerUI::UserManagerUI(content::WebUI* web_ui) : WebUIController(web_ui) {
auto signin_create_profile_handler =
std::make_unique<SigninCreateProfileHandler>();
signin_create_profile_handler_ = signin_create_profile_handler.get();
@@ -44,17 +43,17 @@ MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui)
Profile* profile = Profile::FromWebUI(web_ui);
// Set up the chrome://md-user-manager/ source.
- auto* md_user_source = CreateUIDataSource(localized_strings);
- DarkModeHandler::Initialize(web_ui, md_user_source);
- content::WebUIDataSource::Add(profile, md_user_source);
+ auto* user_source = CreateUIDataSource(localized_strings);
+ DarkModeHandler::Initialize(web_ui, user_source);
+ content::WebUIDataSource::Add(profile, user_source);
// Set up the chrome://theme/ source
content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile));
}
-MDUserManagerUI::~MDUserManagerUI() {}
+UserManagerUI::~UserManagerUI() {}
-content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource(
+content::WebUIDataSource* UserManagerUI::CreateUIDataSource(
const base::DictionaryValue& localized_strings) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIMdUserManagerHost);
@@ -66,35 +65,34 @@ content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource(
source->SetJsonPath("strings.js");
- source->AddResourcePath("control_bar.html", IDR_MD_CONTROL_BAR_HTML);
- source->AddResourcePath("control_bar.js", IDR_MD_CONTROL_BAR_JS);
- source->AddResourcePath("create_profile.html", IDR_MD_CREATE_PROFILE_HTML);
- source->AddResourcePath("create_profile.js", IDR_MD_CREATE_PROFILE_JS);
- source->AddResourcePath("error_dialog.html", IDR_MD_ERROR_DIALOG_HTML);
- source->AddResourcePath("error_dialog.js", IDR_MD_ERROR_DIALOG_JS);
+ source->AddResourcePath("control_bar.html", IDR_CONTROL_BAR_HTML);
+ source->AddResourcePath("control_bar.js", IDR_CONTROL_BAR_JS);
+ source->AddResourcePath("create_profile.html", IDR_CREATE_PROFILE_HTML);
+ source->AddResourcePath("create_profile.js", IDR_CREATE_PROFILE_JS);
+ source->AddResourcePath("error_dialog.html", IDR_ERROR_DIALOG_HTML);
+ source->AddResourcePath("error_dialog.js", IDR_ERROR_DIALOG_JS);
source->AddResourcePath("profile_browser_proxy.html",
- IDR_MD_PROFILE_BROWSER_PROXY_HTML);
+ IDR_PROFILE_BROWSER_PROXY_HTML);
source->AddResourcePath("profile_browser_proxy.js",
- IDR_MD_PROFILE_BROWSER_PROXY_JS);
+ IDR_PROFILE_BROWSER_PROXY_JS);
source->AddResourcePath("shared_styles.html",
- IDR_MD_USER_MANAGER_SHARED_STYLES_HTML);
- source->AddResourcePath("strings.html", IDR_MD_USER_MANAGER_STRINGS_HTML);
- source->AddResourcePath("user_manager.js", IDR_MD_USER_MANAGER_JS);
+ IDR_USER_MANAGER_SHARED_STYLES_HTML);
+ source->AddResourcePath("strings.html", IDR_USER_MANAGER_STRINGS_HTML);
+ source->AddResourcePath("user_manager.js", IDR_USER_MANAGER_JS);
source->AddResourcePath("user_manager_pages.html",
- IDR_MD_USER_MANAGER_PAGES_HTML);
- source->AddResourcePath("user_manager_pages.js",
- IDR_MD_USER_MANAGER_PAGES_JS);
+ IDR_USER_MANAGER_PAGES_HTML);
+ source->AddResourcePath("user_manager_pages.js", IDR_USER_MANAGER_PAGES_JS);
source->AddResourcePath("user_manager_tutorial.html",
- IDR_MD_USER_MANAGER_TUTORIAL_HTML);
+ IDR_USER_MANAGER_TUTORIAL_HTML);
source->AddResourcePath("user_manager_tutorial.js",
- IDR_MD_USER_MANAGER_TUTORIAL_JS);
+ IDR_USER_MANAGER_TUTORIAL_JS);
- source->SetDefaultResource(IDR_MD_USER_MANAGER_HTML);
+ source->SetDefaultResource(IDR_USER_MANAGER_HTML);
return source;
}
-void MDUserManagerUI::GetLocalizedStrings(
+void UserManagerUI::GetLocalizedStrings(
base::DictionaryValue* localized_strings) {
user_manager_screen_handler_->GetLocalizedValues(localized_strings);
signin_create_profile_handler_->GetLocalizedValues(localized_strings);
diff --git a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.h b/chromium/chrome/browser/ui/webui/signin/user_manager_ui.h
index 14c875d1cd0..3a346cfd302 100644
--- a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.h
+++ b/chromium/chrome/browser/ui/webui/signin/user_manager_ui.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_MD_USER_MANAGER_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SIGNIN_MD_USER_MANAGER_UI_H_
+#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_UI_H_
#include "base/macros.h"
#include "content/public/browser/web_ui_controller.h"
@@ -19,10 +19,10 @@ class WebUIDataSource;
}
// A WebUI dialog to display available users.
-class MDUserManagerUI : public content::WebUIController {
+class UserManagerUI : public content::WebUIController {
public:
- explicit MDUserManagerUI(content::WebUI* web_ui);
- ~MDUserManagerUI() override;
+ explicit UserManagerUI(content::WebUI* web_ui);
+ ~UserManagerUI() override;
private:
content::WebUIDataSource* CreateUIDataSource(
@@ -32,7 +32,7 @@ class MDUserManagerUI : public content::WebUIController {
SigninCreateProfileHandler* signin_create_profile_handler_ = nullptr;
UserManagerScreenHandler* user_manager_screen_handler_ = nullptr;
- DISALLOW_COPY_AND_ASSIGN(MDUserManagerUI);
+ DISALLOW_COPY_AND_ASSIGN(UserManagerUI);
};
-#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_MD_USER_MANAGER_UI_H_
+#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
index d151d564554..decbaaf0e62 100644
--- a/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
@@ -86,7 +86,9 @@ IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, PageLoads) {
EXPECT_EQ(num_pods, static_cast<int>(profile_manager->GetNumberOfProfiles()));
}
-IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, PageRedirectsToAboutChrome) {
+// https://crbug.com/945795
+IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest,
+ DISABLED_PageRedirectsToAboutChrome) {
std::string user_manager_url = chrome::kChromeUIMdUserManagerUrl;
user_manager_url += profiles::kUserManagerSelectProfileAboutChrome;
diff --git a/chromium/chrome/browser/ui/webui/signin_internals_ui.cc b/chromium/chrome/browser/ui/webui/signin_internals_ui.cc
index 3ff768b7187..97820239ac8 100644
--- a/chromium/chrome/browser/ui/webui/signin_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin_internals_ui.cc
@@ -8,7 +8,7 @@
#include <string>
#include <vector>
-#include "base/hash.h"
+#include "base/hash/hash.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/about_signin_internals_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
diff --git a/chromium/chrome/browser/ui/webui/site_settings_helper.cc b/chromium/chrome/browser/ui/webui/site_settings_helper.cc
index 13ae60fb8b7..c0be6a6970d 100644
--- a/chromium/chrome/browser/ui/webui/site_settings_helper.cc
+++ b/chromium/chrome/browser/ui/webui/site_settings_helper.cc
@@ -17,6 +17,8 @@
#include "chrome/browser/permissions/permission_manager.h"
#include "chrome/browser/permissions/permission_result.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/serial/serial_chooser_context.h"
+#include "chrome/browser/serial/serial_chooser_context_factory.h"
#include "chrome/browser/usb/usb_chooser_context.h"
#include "chrome/browser/usb/usb_chooser_context_factory.h"
#include "chrome/common/pref_names.h"
@@ -50,6 +52,7 @@ typedef std::map<std::pair<GURL, std::string>, OneOriginObjects>
// Chooser data group names.
const char kUsbChooserDataGroupType[] = "usb-devices-data";
+const char kSerialChooserDataGroupType[] = "serial-ports-data";
const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
// The following ContentSettingsTypes have UI in Content Settings
@@ -79,6 +82,8 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
{CONTENT_SETTINGS_TYPE_USB_GUARD, "usb-devices"},
{CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, kUsbChooserDataGroupType},
{CONTENT_SETTINGS_TYPE_IDLE_DETECTION, "idle-detection"},
+ {CONTENT_SETTINGS_TYPE_SERIAL_GUARD, "serial-ports"},
+ {CONTENT_SETTINGS_TYPE_SERIAL_CHOOSER_DATA, kSerialChooserDataGroupType},
// Add new content settings here if a corresponding Javascript string
// representation for it is not required. Note some exceptions do have UI in
@@ -104,9 +109,6 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
{CONTENT_SETTINGS_TYPE_PLUGINS_DATA, nullptr},
{CONTENT_SETTINGS_TYPE_BACKGROUND_FETCH, nullptr},
{CONTENT_SETTINGS_TYPE_INTENT_PICKER_DISPLAY, nullptr},
- // TODO(crbug.com/908836): Add UI for setting this permission.
- {CONTENT_SETTINGS_TYPE_SERIAL_GUARD, nullptr},
- {CONTENT_SETTINGS_TYPE_SERIAL_CHOOSER_DATA, nullptr},
};
static_assert(base::size(kContentSettingsTypeGroupNames) ==
// ContentSettingsType starts at -1, so add 1 here.
@@ -240,8 +242,13 @@ ChooserContextBase* GetUsbChooserContext(Profile* profile) {
return UsbChooserContextFactory::GetForProfile(profile);
}
+ChooserContextBase* GetSerialChooserContext(Profile* profile) {
+ return SerialChooserContextFactory::GetForProfile(profile);
+}
+
const ChooserTypeNameEntry kChooserTypeGroupNames[] = {
{&GetUsbChooserContext, kUsbChooserDataGroupType},
+ {&GetSerialChooserContext, kSerialChooserDataGroupType},
};
} // namespace
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
index d7793d4a040..fc2b659f93f 100644
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
@@ -58,12 +58,6 @@ interface PageHandler {
// Fetch suggestions in background after the given delay.
FetchSuggestionsInBackground(int64 delaySeconds) => ();
- // Returns if it's possible to push a dummy suggestion.
- IsPushingDummySuggestionPossible() => (bool result);
-
- // Push dummy suggestion in background after the given delay.
- PushDummySuggestionInBackground(int64 delaySeconds) => ();
-
// Download the last suggestions in json form.
GetLastJson() => (string json);
@@ -80,4 +74,4 @@ interface PageHandler {
// Frontend interface.
interface Page {
OnSuggestionsChanged();
-}; \ No newline at end of file
+};
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
index 79ae30bb0b0..9102e5dd8d0 100644
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
@@ -11,9 +11,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/time/time_to_iso8601.h"
#include "chrome/browser/android/ntp/android_content_suggestions_notifier.h"
-#include "chrome/browser/ntp_snippets/dependent_features.h"
#include "chrome/common/pref_names.h"
#include "components/ntp_snippets/category_info.h"
#include "components/ntp_snippets/features.h"
@@ -25,13 +23,10 @@
#include "components/offline_pages/core/offline_page_feature.h"
#include "components/variations/variations_associated_data.h"
-using ntp_snippets::AreAssetDownloadsEnabled;
-using ntp_snippets::AreOfflinePageDownloadsEnabled;
using ntp_snippets::Category;
using ntp_snippets::CategoryInfo;
using ntp_snippets::CategoryStatus;
using ntp_snippets::ContentSuggestion;
-using ntp_snippets::IsBookmarkProviderEnabled;
using ntp_snippets::RemoteSuggestionsProvider;
using ntp_snippets::RemoteSuggestionsFetcher;
using ntp_snippets::UserClassifier;
@@ -66,16 +61,6 @@ std::string BooleanToString(bool value) {
return value ? "True" : "False";
}
-ntp_snippets::BreakingNewsListener* GetBreakingNewsListener(
- ntp_snippets::ContentSuggestionsService* service) {
- DCHECK(service);
- RemoteSuggestionsProvider* provider =
- service->remote_suggestions_provider_for_debugging();
- DCHECK(provider);
- return static_cast<ntp_snippets::RemoteSuggestionsProviderImpl*>(provider)
- ->breaking_news_listener_for_debugging();
-}
-
std::string GetCategoryStatusName(CategoryStatus status) {
switch (status) {
case CategoryStatus::INITIALIZING:
@@ -171,12 +156,6 @@ void SnippetsInternalsPageHandler::GetGeneralProperties(
properties["flag-offlining-recent-pages-feature"] =
BooleanToString(base::FeatureList::IsEnabled(
offline_pages::kOffliningRecentPagesFeature));
- properties["flag-asset-download-suggestions"] =
- BooleanToString(AreAssetDownloadsEnabled());
- properties["flag-offline-page-download-suggestions"] =
- BooleanToString(AreOfflinePageDownloadsEnabled());
- properties["flag-bookmark-suggestions"] =
- BooleanToString(IsBookmarkProviderEnabled());
if (remote_suggestions_provider_) {
const ntp_snippets::RemoteSuggestionsFetcher* fetcher =
@@ -288,67 +267,6 @@ void SnippetsInternalsPageHandler::FetchSuggestionsInBackgroundImpl(
std::move(callback).Run();
}
-void SnippetsInternalsPageHandler::IsPushingDummySuggestionPossible(
- IsPushingDummySuggestionPossibleCallback callback) {
- ntp_snippets::BreakingNewsListener* listener =
- GetBreakingNewsListener(content_suggestions_service_);
-
- std::move(callback).Run(listener != nullptr && listener->IsListening());
-}
-
-void SnippetsInternalsPageHandler::PushDummySuggestionInBackground(
- int64_t delaySeconds,
- PushDummySuggestionInBackgroundCallback callback) {
- DCHECK(delaySeconds >= 0);
- suggestion_push_timer_.Start(
- FROM_HERE, base::TimeDelta::FromSeconds(delaySeconds),
- base::BindRepeating(
- &SnippetsInternalsPageHandler::PushDummySuggestionInBackgroundImpl,
- weak_ptr_factory_.GetWeakPtr(), base::Passed(std::move(callback))));
-}
-
-void SnippetsInternalsPageHandler::PushDummySuggestionInBackgroundImpl(
- PushDummySuggestionInBackgroundCallback callback) {
- std::string json = R"(
- {"categories" : [{
- "id": 1,
- "localizedTitle": "section title",
- "suggestions" : [{
- "ids" : ["http://url.com"],
- "title" : "Pushed Dummy Title %s",
- "snippet" : "Pushed Dummy Snippet",
- "fullPageUrl" : "http://url.com",
- "creationTime" : "%s",
- "expirationTime" : "%s",
- "attribution" : "Pushed Dummy Publisher",
- "imageUrl" : "https://www.google.com/favicon.ico",
- "notificationInfo": {
- "shouldNotify": true,
- "deadline": "2100-01-01T00:00:01.000Z"
- }
- }]
- }]}
- )";
-
- const base::Time now = base::Time::Now();
- json = base::StringPrintf(
- json.c_str(), base::UTF16ToUTF8(base::TimeFormatTimeOfDay(now)).c_str(),
- base::TimeToISO8601(now).c_str(),
- base::TimeToISO8601(now + base::TimeDelta::FromMinutes(60)).c_str());
-
- gcm::IncomingMessage message;
- message.data["payload"] = json;
-
- ntp_snippets::BreakingNewsListener* listener =
- GetBreakingNewsListener(content_suggestions_service_);
- DCHECK(listener);
- DCHECK(listener->IsListening());
- static_cast<ntp_snippets::BreakingNewsGCMAppHandler*>(listener)->OnMessage(
- "com.google.breakingnews.gcm", message);
-
- std::move(callback).Run();
-}
-
void SnippetsInternalsPageHandler::GetLastJson(GetLastJsonCallback callback) {
std::string json = "";
if (remote_suggestions_provider_) {
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
index b134684f11b..ae81aa26980 100644
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
@@ -41,11 +41,6 @@ class SnippetsInternalsPageHandler
void FetchSuggestionsInBackground(
int64_t,
FetchSuggestionsInBackgroundCallback) override;
- void IsPushingDummySuggestionPossible(
- IsPushingDummySuggestionPossibleCallback) override;
- void PushDummySuggestionInBackground(
- int64_t,
- PushDummySuggestionInBackgroundCallback) override;
void GetLastJson(GetLastJsonCallback) override;
void ResetNotificationState() override;
void GetSuggestionsByCategory(GetSuggestionsByCategoryCallback) override;
@@ -64,8 +59,6 @@ class SnippetsInternalsPageHandler
void FetchSuggestionsInBackgroundImpl(FetchSuggestionsInBackgroundCallback);
void GetSuggestionsByCategoryImpl(GetSuggestionsByCategoryCallback);
- void PushDummySuggestionInBackgroundImpl(
- PushDummySuggestionInBackgroundCallback);
// Misc. methods.
void CollectDismissedSuggestions(
@@ -94,7 +87,6 @@ class SnippetsInternalsPageHandler
// Timers to delay actions.
base::OneShotTimer suggestion_fetch_timer_;
- base::OneShotTimer suggestion_push_timer_;
// Handle back to the page by which we can update.
snippets_internals::mojom::PagePtr page_;
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc
index 30018dba934..84543434b39 100644
--- a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc
@@ -24,8 +24,8 @@ SnippetsInternalsUI::SnippetsInternalsUI(content::WebUI* web_ui)
"script-src chrome://resources 'self' 'unsafe-eval';");
source->AddResourcePath("snippets_internals.css", IDR_SNIPPETS_INTERNALS_CSS);
source->AddResourcePath("snippets_internals.js", IDR_SNIPPETS_INTERNALS_JS);
- source->AddResourcePath("snippets_internals.mojom.js",
- IDR_SNIPPETS_INTERNALS_MOJO_JS);
+ source->AddResourcePath("snippets_internals.mojom-lite.js",
+ IDR_SNIPPETS_INTERNALS_MOJOM_LITE_JS);
source->SetDefaultResource(IDR_SNIPPETS_INTERNALS_HTML);
source->UseGzip();
diff --git a/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
index 005362663de..6416cb4247e 100644
--- a/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
@@ -242,10 +242,11 @@ void SupervisedUserInternalsMessageHandler::SendBasicInfo() {
// Trigger retrieval of the user settings
SupervisedUserSettingsService* settings_service =
- SupervisedUserSettingsServiceFactory::GetForProfile(profile);
- user_settings_subscription_ = settings_service->Subscribe(base::Bind(
- &SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings,
- weak_factory_.GetWeakPtr()));
+ SupervisedUserSettingsServiceFactory::GetForKey(profile->GetProfileKey());
+ user_settings_subscription_ =
+ settings_service->SubscribeForSettingsChange(base::Bind(
+ &SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings,
+ weak_factory_.GetWeakPtr()));
}
void SupervisedUserInternalsMessageHandler::SendSupervisedUserSettings(
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js b/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js
index 11b09eaecf9..ede567340a8 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js
+++ b/chromium/chrome/browser/ui/webui/sync_internals_browsertest.js
@@ -242,16 +242,31 @@ TEST_F('SyncInternalsWebUITest', 'Uninitialized', function() {
assertNotEquals(null, chrome.sync.aboutInfo);
});
-// TODO(crbug.com/814787): On ChromeOS, browser tests are signed in by default,
-// so the test expectations below should be different. However, the way the
-// account is set up for tests is broken (it happens much later than in real
-// life), so it doesn't make it to sync-internals.
-TEST_F('SyncInternalsWebUITest', 'SignedOut', function() {
+GEN('#if defined(OS_CHROMEOS)');
+
+// On ChromeOS, browser tests are signed in by default to mimic production,
+// so the sync transport layer should be enabled. Note that the sync *feature*
+// might still be disabled depending on how the test infrastructure is
+// configured.
+TEST_F('SyncInternalsWebUITest', 'SyncTransportEnabledByDefault', function() {
+ // The specific transport state is dependent on the timing of startup, but it
+ // should not be disabled.
+ expectFalse(this.hasInDetails(true, 'Transport State', 'Disabled'));
+});
+
+GEN('#else');
+
+// On non-ChromeOS, sync should be disabled if there was no primary account
+// set.
+TEST_F('SyncInternalsWebUITest', 'SyncDisabledByDefault', function() {
expectTrue(this.hasInDetails(true, 'Transport State', 'Disabled'));
- expectTrue(this.hasInDetails(true, 'Disable Reasons', 'Not signed in'));
+ expectTrue(
+ this.hasInDetails(true, 'Disable Reasons', 'Not signed in, User choice'));
expectTrue(this.hasInDetails(true, 'Username', ''));
});
+GEN('#endif // defined(OS_CHROMEOS)');
+
TEST_F('SyncInternalsWebUITest', 'LoadPastedAboutInfo', function() {
// Expose the text field.
$('import-status').click();
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 b7e652cf428..dbcae7e4057 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/command_line.h"
-#include "base/feature_list.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/profiles/profile.h"
@@ -253,7 +252,7 @@ void SyncInternalsMessageHandler::HandleGetAllNodes(const ListValue* args) {
// asynchronously, and potentially at times we're not allowed to call into
// the javascript side. We guard against this by invalidating this weak ptr
// should javascript become disallowed.
- service->GetAllNodes(
+ service->GetAllNodesForDebugging(
base::Bind(&SyncInternalsMessageHandler::OnReceivedAllNodes,
weak_ptr_factory_.GetWeakPtr(), request_id));
}
@@ -263,9 +262,10 @@ void SyncInternalsMessageHandler::HandleRequestUserEventsVisibility(
const base::ListValue* args) {
DCHECK(args->empty());
AllowJavascript();
- CallJavascriptFunction(
- syncer::sync_ui_util::kUserEventsVisibilityCallback,
- Value(base::FeatureList::IsEnabled(switches::kSyncUserEvents)));
+ // TODO(crbug.com/934333): Get rid of this callback now that user events are
+ // always enabled.
+ CallJavascriptFunction(syncer::sync_ui_util::kUserEventsVisibilityCallback,
+ Value(true));
}
void SyncInternalsMessageHandler::HandleSetIncludeSpecifics(
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc b/chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc
index 3b37b29bc14..86df2a387b3 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/sync/user_event_service_factory.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
-#include "components/browser_sync/browser_sync_switches.h"
#include "components/sync/driver/about_sync_util.h"
#include "components/sync/driver/fake_sync_service.h"
#include "components/sync/driver/sync_service.h"
@@ -66,8 +65,9 @@ class TestSyncService : public syncer::FakeSyncService {
return js_controller_.AsWeakPtr();
}
- void GetAllNodes(const base::Callback<void(std::unique_ptr<base::ListValue>)>&
- callback) override {
+ void GetAllNodesForDebugging(
+ const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback)
+ override {
get_all_nodes_callback_ = std::move(callback);
}
diff --git a/chromium/chrome/browser/ui/webui/test_files_request_filter.cc b/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
index e4cdc784e20..8255db505db 100644
--- a/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
+++ b/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
@@ -14,27 +14,37 @@
namespace {
-bool HandleTestFileRequestCallback(
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
- base::ScopedAllowBlockingForTesting allow_blocking;
+bool ShouldHandleTestFileRequestCallback(const std::string& path) {
std::vector<std::string> url_substr =
base::SplitString(path, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
if (url_substr.size() != 2 || url_substr[0] != "test")
return false;
+ base::ScopedAllowBlockingForTesting allow_blocking;
+ base::FilePath test_data_dir;
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
+ return base::PathExists(
+ test_data_dir.AppendASCII("webui").AppendASCII(url_substr[1]));
+}
+
+void HandleTestFileRequestCallback(
+ const std::string& path,
+ const content::WebUIDataSource::GotDataCallback& callback) {
+ DCHECK(ShouldHandleTestFileRequestCallback(path));
+ base::ScopedAllowBlockingForTesting allow_blocking;
+
+ std::vector<std::string> url_substr =
+ base::SplitString(path, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
std::string contents;
base::FilePath test_data_dir;
base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
- if (!base::ReadFileToString(
- test_data_dir.AppendASCII("webui").AppendASCII(url_substr[1]),
- &contents))
- return false;
+ CHECK(base::ReadFileToString(
+ test_data_dir.AppendASCII("webui").AppendASCII(url_substr[1]),
+ &contents));
base::RefCountedString* ref_contents = new base::RefCountedString();
ref_contents->data() = contents;
callback.Run(ref_contents);
- return true;
}
} // namespace
@@ -45,4 +55,9 @@ content::WebUIDataSource::HandleRequestCallback GetTestFilesRequestFilter() {
return base::Bind(&HandleTestFileRequestCallback);
}
+content::WebUIDataSource::ShouldHandleRequestCallback
+GetTestShouldHandleRequest() {
+ return base::BindRepeating(&ShouldHandleTestFileRequestCallback);
+}
+
} // namespace test
diff --git a/chromium/chrome/browser/ui/webui/test_files_request_filter.h b/chromium/chrome/browser/ui/webui/test_files_request_filter.h
index e6e49bd7e6c..b17b09a678f 100644
--- a/chromium/chrome/browser/ui/webui/test_files_request_filter.h
+++ b/chromium/chrome/browser/ui/webui/test_files_request_filter.h
@@ -14,6 +14,10 @@ namespace test {
// request path has "/test/<filename>" format.
content::WebUIDataSource::HandleRequestCallback GetTestFilesRequestFilter();
+// Returns a callback indicating which requests should be handled by the filter.
+content::WebUIDataSource::ShouldHandleRequestCallback
+GetTestShouldHandleRequest();
+
} // namespace test
#endif // CHROME_BROWSER_UI_WEBUI_TEST_FILES_REQUEST_FILTER_H_
diff --git a/chromium/chrome/browser/ui/webui/theme_handler.cc b/chromium/chrome/browser/ui/webui/theme_handler.cc
index d0696a73f7b..033a87dbafe 100644
--- a/chromium/chrome/browser/ui/webui/theme_handler.cc
+++ b/chromium/chrome/browser/ui/webui/theme_handler.cc
@@ -6,6 +6,7 @@
#include <memory>
+#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
@@ -15,38 +16,64 @@
#include "chrome/grit/theme_resources.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_ui.h"
+#include "ui/native_theme/native_theme.h"
///////////////////////////////////////////////////////////////////////////////
// ThemeHandler
-ThemeHandler::ThemeHandler() {
-}
+ThemeHandler::ThemeHandler() : theme_observer_(this) {}
-ThemeHandler::~ThemeHandler() {
-}
+ThemeHandler::~ThemeHandler() {}
void ThemeHandler::RegisterMessages() {
// These are not actual message registrations, but can't be done in the
// constructor since they need the web_ui value to be set, which is done
// post-construction, but before registering messages.
InitializeCSSCaches();
+ web_ui()->RegisterMessageCallback(
+ "observeThemeChanges",
+ base::BindRepeating(&ThemeHandler::HandleObserveThemeChanges,
+ base::Unretained(this)));
+}
+
+void ThemeHandler::OnJavascriptAllowed() {
// Listen for theme installation.
registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
content::Source<ThemeService>(
ThemeServiceFactory::GetForProfile(GetProfile())));
+ // Or native theme change.
+ theme_observer_.Add(ui::NativeTheme::GetInstanceForNativeUi());
+}
+
+void ThemeHandler::OnJavascriptDisallowed() {
+ registrar_.RemoveAll();
+ theme_observer_.RemoveAll();
}
void ThemeHandler::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type);
+ SendThemeChanged();
+}
+
+void ThemeHandler::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
+ DCHECK_EQ(observed_theme, ui::NativeTheme::GetInstanceForNativeUi());
+ SendThemeChanged();
+}
+
+void ThemeHandler::HandleObserveThemeChanges(const base::ListValue* /*args*/) {
+ AllowJavascript();
+}
+
+void ThemeHandler::SendThemeChanged() {
InitializeCSSCaches();
bool has_custom_bg = ThemeService::GetThemeProviderForProfile(GetProfile())
.HasCustomImage(IDR_THEME_NTP_BACKGROUND);
// TODO(dbeam): why does this need to be a dictionary?
base::DictionaryValue dictionary;
dictionary.SetBoolean("hasCustomBackground", has_custom_bg);
- web_ui()->CallJavascriptFunctionUnsafe("ntp.themeChanged", dictionary);
+ CallJavascriptFunction("ntp.themeChanged", dictionary);
}
void ThemeHandler::InitializeCSSCaches() {
diff --git a/chromium/chrome/browser/ui/webui/theme_handler.h b/chromium/chrome/browser/ui/webui/theme_handler.h
index 7c2b88b2514..5e52e81d1cd 100644
--- a/chromium/chrome/browser/ui/webui/theme_handler.h
+++ b/chromium/chrome/browser/ui/webui/theme_handler.h
@@ -6,22 +6,31 @@
#define CHROME_BROWSER_UI_WEBUI_THEME_HANDLER_H_
#include "base/macros.h"
+#include "base/scoped_observer.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "ui/native_theme/native_theme_observer.h"
class Profile;
+namespace ui {
+class NativeTheme;
+}
+
// A class to keep the ThemeSource up to date when theme changes.
class ThemeHandler : public content::WebUIMessageHandler,
- public content::NotificationObserver {
+ public content::NotificationObserver,
+ public ui::NativeThemeObserver {
public:
- explicit ThemeHandler();
+ ThemeHandler();
~ThemeHandler() override;
private:
- // content::WebUIMessageHandler implementation.
+ // content::WebUIMessageHandler:
void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
// Re/set the CSS caches.
void InitializeCSSCaches();
@@ -31,10 +40,21 @@ class ThemeHandler : public content::WebUIMessageHandler,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
+ // ui::NativeThemeObserver:
+ void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
+
+ // Handler for "observeThemeChanges" chrome.send() message. No arguments.
+ void HandleObserveThemeChanges(const base::ListValue* args);
+
+ // Notify the page (if allowed) that the theme has changed.
+ void SendThemeChanged();
+
Profile* GetProfile() const;
content::NotificationRegistrar registrar_;
+ ScopedObserver<ui::NativeTheme, ThemeHandler> theme_observer_;
+
DISALLOW_COPY_AND_ASSIGN(ThemeHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc b/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc
new file mode 100644
index 00000000000..79aa2f83dfa
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.cc
@@ -0,0 +1,88 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h"
+
+#include <map>
+#include <utility>
+#include <vector>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/values.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/translate/chrome_translate_client.h"
+#include "chrome/browser/translate/translate_service.h"
+#include "chrome/common/pref_names.h"
+#include "components/language/core/browser/pref_names.h"
+#include "components/prefs/pref_service.h"
+#include "components/translate/core/browser/translate_download_manager.h"
+#include "components/translate/core/browser/translate_error_details.h"
+#include "components/translate/core/browser/translate_event_details.h"
+#include "components/translate/core/browser/translate_pref_names.h"
+#include "components/translate/core/browser/translate_prefs.h"
+#include "components/translate/core/common/language_detection_details.h"
+#include "components/variations/service/variations_service.h"
+#include "content/public/browser/notification_details.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
+
+ChromeTranslateInternalsHandler::ChromeTranslateInternalsHandler() {
+ notification_registrar_.Add(this,
+ chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
+ content::NotificationService::AllSources());
+}
+
+ChromeTranslateInternalsHandler::~ChromeTranslateInternalsHandler() {}
+
+translate::TranslateClient*
+ChromeTranslateInternalsHandler::GetTranslateClient() {
+ return ChromeTranslateClient::FromWebContents(web_ui()->GetWebContents());
+}
+
+variations::VariationsService*
+ChromeTranslateInternalsHandler::GetVariationsService() {
+ return g_browser_process->variations_service();
+}
+
+void ChromeTranslateInternalsHandler::RegisterMessageCallback(
+ const std::string& message,
+ const MessageCallback& callback) {
+ web_ui()->RegisterMessageCallback(message, callback);
+}
+
+void ChromeTranslateInternalsHandler::CallJavascriptFunction(
+ const std::string& function_name,
+ const std::vector<const base::Value*>& args) {
+ web_ui()->CallJavascriptFunctionUnsafe(function_name, args);
+}
+
+void ChromeTranslateInternalsHandler::RegisterMessages() {
+ RegisterMessageCallbacks();
+}
+
+void ChromeTranslateInternalsHandler::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, type);
+
+ content::WebContents* web_contents =
+ content::Source<content::WebContents>(source).ptr();
+ const translate::LanguageDetectionDetails* language_detection_details =
+ content::Details<const translate::LanguageDetectionDetails>(details)
+ .ptr();
+ if (web_contents->GetBrowserContext()->IsOffTheRecord() ||
+ !GetTranslateClient()->IsTranslatableURL(
+ language_detection_details->url)) {
+ return;
+ }
+
+ AddLanguageDetectionDetails(*language_detection_details);
+}
diff --git a/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h b/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h
new file mode 100644
index 00000000000..0b5ea14feaf
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h
@@ -0,0 +1,48 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_CHROME_TRANSLATE_INTERNALS_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_CHROME_TRANSLATE_INTERNALS_HANDLER_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "components/translate/translate_internals/translate_internals_handler.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+// The handler for JavaScript messages for chrome://translate-internals.
+class ChromeTranslateInternalsHandler
+ : public translate::TranslateInternalsHandler,
+ public content::WebUIMessageHandler,
+ public content::NotificationObserver {
+ public:
+ ChromeTranslateInternalsHandler();
+ ~ChromeTranslateInternalsHandler() override;
+
+ // translate::TranslateInternalsHandler.
+ translate::TranslateClient* GetTranslateClient() override;
+ variations::VariationsService* GetVariationsService() override;
+ void RegisterMessageCallback(const std::string& message,
+ const MessageCallback& callback) override;
+ void CallJavascriptFunction(
+ const std::string& function_name,
+ const std::vector<const base::Value*>& args) override;
+
+ // content::WebUIMessageHandler methods:
+ void RegisterMessages() override;
+
+ // content::NotificationObserver implementation:
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+ private:
+ content::NotificationRegistrar notification_registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeTranslateInternalsHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_CHROME_TRANSLATE_INTERNALS_HANDLER_H_ \ No newline at end of file
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
deleted file mode 100644
index a6b217624a4..00000000000
--- a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc
+++ /dev/null
@@ -1,277 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/translate_internals/translate_internals_handler.h"
-
-#include <map>
-#include <utility>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/translate/chrome_translate_client.h"
-#include "chrome/browser/translate/translate_service.h"
-#include "chrome/common/pref_names.h"
-#include "components/language/core/browser/pref_names.h"
-#include "components/prefs/pref_service.h"
-#include "components/translate/core/browser/translate_download_manager.h"
-#include "components/translate/core/browser/translate_error_details.h"
-#include "components/translate/core/browser/translate_event_details.h"
-#include "components/translate/core/browser/translate_pref_names.h"
-#include "components/translate/core/browser/translate_prefs.h"
-#include "components/translate/core/common/language_detection_details.h"
-#include "components/variations/service/variations_service.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/notification_types.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-
-TranslateInternalsHandler::TranslateInternalsHandler() {
- notification_registrar_.Add(this,
- chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
- content::NotificationService::AllSources());
-
- error_subscription_ =
- translate::TranslateManager::RegisterTranslateErrorCallback(
- base::Bind(&TranslateInternalsHandler::OnTranslateError,
- base::Unretained(this)));
-
- translate::TranslateLanguageList* language_list =
- translate::TranslateDownloadManager::GetInstance()->language_list();
- if (!language_list) {
- NOTREACHED();
- return;
- }
-
- event_subscription_ = language_list->RegisterEventCallback(base::Bind(
- &TranslateInternalsHandler::OnTranslateEvent, base::Unretained(this)));
-}
-
-TranslateInternalsHandler::~TranslateInternalsHandler() {
- // |event_subscription_| and |error_subscription_| are deleted automatically
- // and un-register the callbacks automatically.
-}
-
-void TranslateInternalsHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "removePrefItem",
- base::BindRepeating(&TranslateInternalsHandler::OnRemovePrefItem,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "setRecentTargetLanguage",
- base::BindRepeating(&TranslateInternalsHandler::OnSetRecentTargetLanguage,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "requestInfo",
- base::BindRepeating(&TranslateInternalsHandler::OnRequestInfo,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "overrideCountry",
- base::BindRepeating(&TranslateInternalsHandler::OnOverrideCountry,
- base::Unretained(this)));
-}
-
-void TranslateInternalsHandler::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, type);
- const translate::LanguageDetectionDetails* language_detection_details =
- content::Details<const translate::LanguageDetectionDetails>(details)
- .ptr();
- content::WebContents* web_contents =
- content::Source<content::WebContents>(source).ptr();
-
- if (web_contents->GetBrowserContext()->IsOffTheRecord() ||
- !TranslateService::IsTranslatableURL(language_detection_details->url)) {
- return;
- }
-
- base::DictionaryValue dict;
- dict.SetDouble("time", language_detection_details->time.ToJsTime());
- dict.SetString("url", language_detection_details->url.spec());
- dict.SetString("content_language",
- language_detection_details->content_language);
- dict.SetString("cld_language", language_detection_details->cld_language);
- dict.SetBoolean("is_cld_reliable",
- language_detection_details->is_cld_reliable);
- dict.SetBoolean("has_notranslate",
- language_detection_details->has_notranslate);
- dict.SetString("html_root_language",
- language_detection_details->html_root_language);
- dict.SetString("adopted_language",
- language_detection_details->adopted_language);
- dict.SetString("content", language_detection_details->contents);
- SendMessageToJs("languageDetectionInfoAdded", dict);
-}
-
-void TranslateInternalsHandler::OnTranslateError(
- const translate::TranslateErrorDetails& details) {
- base::DictionaryValue dict;
- dict.SetDouble("time", details.time.ToJsTime());
- dict.SetString("url", details.url.spec());
- dict.SetInteger("error", details.error);
- SendMessageToJs("translateErrorDetailsAdded", dict);
-}
-
-void TranslateInternalsHandler::OnTranslateEvent(
- const translate::TranslateEventDetails& details) {
- base::DictionaryValue dict;
- dict.SetDouble("time", details.time.ToJsTime());
- dict.SetString("filename", details.filename);
- dict.SetInteger("line", details.line);
- dict.SetString("message", details.message);
- SendMessageToJs("translateEventDetailsAdded", dict);
-}
-
-void TranslateInternalsHandler::OnRemovePrefItem(const base::ListValue* args) {
- Profile* profile = Profile::FromWebUI(web_ui());
- PrefService* prefs = profile->GetOriginalProfile()->GetPrefs();
- std::unique_ptr<translate::TranslatePrefs> translate_prefs(
- ChromeTranslateClient::CreateTranslatePrefs(prefs));
-
- std::string pref_name;
- if (!args->GetString(0, &pref_name))
- return;
-
- if (pref_name == "blocked_languages") {
- std::string language;
- if (!args->GetString(1, &language))
- return;
- translate_prefs->UnblockLanguage(language);
- } else if (pref_name == "site_blacklist") {
- std::string site;
- if (!args->GetString(1, &site))
- return;
- translate_prefs->RemoveSiteFromBlacklist(site);
- } else if (pref_name == "whitelists") {
- std::string from, to;
- if (!args->GetString(1, &from))
- return;
- if (!args->GetString(2, &to))
- return;
- translate_prefs->RemoveLanguagePairFromWhitelist(from, to);
- } else if (pref_name == "too_often_denied") {
- translate_prefs->ResetDenialState();
- } else {
- return;
- }
-
- SendPrefsToJs();
-}
-
-void TranslateInternalsHandler::OnSetRecentTargetLanguage(
- const base::ListValue* args) {
- Profile* profile = Profile::FromWebUI(web_ui());
- PrefService* prefs = profile->GetOriginalProfile()->GetPrefs();
- std::unique_ptr<translate::TranslatePrefs> translate_prefs(
- ChromeTranslateClient::CreateTranslatePrefs(prefs));
-
- std::string new_value;
- if (!args->GetString(0, &new_value))
- return;
-
- translate_prefs->SetRecentTargetLanguage(new_value);
-
- SendPrefsToJs();
-}
-
-void TranslateInternalsHandler::OnOverrideCountry(const base::ListValue* args) {
- std::string country;
- if (args->GetString(0, &country)) {
- variations::VariationsService* variations_service =
- g_browser_process->variations_service();
- if (variations_service) {
- SendCountryToJs(
- variations_service->OverrideStoredPermanentCountry(country));
- }
- }
-}
-
-void TranslateInternalsHandler::OnRequestInfo(const base::ListValue* /*args*/) {
- SendPrefsToJs();
- SendSupportedLanguagesToJs();
- SendCountryToJs(false);
-}
-
-void TranslateInternalsHandler::SendMessageToJs(const std::string& message,
- const base::Value& value) {
- const char func[] = "cr.translateInternals.messageHandler";
- base::Value message_data(message);
- web_ui()->CallJavascriptFunctionUnsafe(func, message_data, value);
-}
-
-void TranslateInternalsHandler::SendPrefsToJs() {
- Profile* profile = Profile::FromWebUI(web_ui());
- PrefService* prefs = profile->GetOriginalProfile()->GetPrefs();
-
- base::DictionaryValue dict;
-
- static const char* const keys[] = {
- prefs::kOfferTranslateEnabled,
- translate::TranslatePrefs::kPrefTranslateRecentTarget,
- translate::TranslatePrefs::kPrefTranslateBlockedLanguages,
- translate::TranslatePrefs::kPrefTranslateSiteBlacklistDeprecated,
- translate::TranslatePrefs::kPrefTranslateSiteBlacklistWithTime,
- translate::TranslatePrefs::kPrefTranslateWhitelists,
- translate::TranslatePrefs::kPrefTranslateDeniedCount,
- translate::TranslatePrefs::kPrefTranslateIgnoredCount,
- translate::TranslatePrefs::kPrefTranslateAcceptedCount,
- translate::TranslatePrefs::kPrefTranslateLastDeniedTimeForLanguage,
- translate::TranslatePrefs::kPrefTranslateTooOftenDeniedForLanguage,
- language::prefs::kAcceptLanguages,
- };
- for (const char* key : keys) {
- const PrefService::Preference* pref = prefs->FindPreference(key);
- if (pref)
- dict.SetKey(key, pref->GetValue()->Clone());
- }
-
- SendMessageToJs("prefsUpdated", dict);
-}
-
-void TranslateInternalsHandler::SendSupportedLanguagesToJs() {
- // Create translate prefs.
- Profile* profile = Profile::FromWebUI(web_ui());
- PrefService* prefs = profile->GetOriginalProfile()->GetPrefs();
- std::unique_ptr<translate::TranslatePrefs> translate_prefs(
- ChromeTranslateClient::CreateTranslatePrefs(prefs));
-
- // Fetch supported language information.
- std::vector<std::string> languages;
- translate::TranslateDownloadManager::GetSupportedLanguages(
- translate_prefs->IsTranslateAllowedByPolicy(), &languages);
- base::Time last_updated =
- translate::TranslateDownloadManager::GetSupportedLanguagesLastUpdated();
-
- auto languages_list = std::make_unique<base::ListValue>();
- for (const std::string& lang : languages)
- languages_list->AppendString(lang);
-
- base::DictionaryValue dict;
- dict.Set("languages", std::move(languages_list));
- dict.SetDouble("last_updated", last_updated.ToJsTime());
- SendMessageToJs("supportedLanguagesUpdated", dict);
-}
-
-void TranslateInternalsHandler::SendCountryToJs(bool was_updated) {
- std::string country;
- variations::VariationsService* variations_service =
- g_browser_process->variations_service();
- if (variations_service)
- country = variations_service->GetStoredPermanentCountry();
-
- base::DictionaryValue dict;
- if (!country.empty()) {
- dict.SetString("country", country);
- dict.SetBoolean("update", was_updated);
- }
- SendMessageToJs("countryUpdated", dict);
-}
diff --git a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.h b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.h
deleted file mode 100644
index 5affaa27251..00000000000
--- a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_H_
-
-#include <memory>
-#include <string>
-
-#include "base/callback_list.h"
-#include "base/macros.h"
-#include "components/translate/core/browser/translate_language_list.h"
-#include "components/translate/core/browser/translate_manager.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-#include "content/public/browser/web_ui_message_handler.h"
-#include "content/public/common/webplugininfo.h"
-
-namespace translate {
-struct TranslateErrorDetails;
-struct TranslateEventDetails;
-}
-
-namespace base {
-class ListValue;
-class Value;
-}
-
-namespace content {
-class NotificationDetails;
-class NotificationSource;
-}
-
-// The handler class for TranslateInternals page operations.
-class TranslateInternalsHandler : public content::WebUIMessageHandler,
- public content::NotificationObserver {
- public:
- TranslateInternalsHandler();
- ~TranslateInternalsHandler() override;
-
- // content::WebUIMessageHandler methods:
- void RegisterMessages() override;
-
- private:
- // content::NotificationObserver implementation:
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
- // Callback for translate errors.
- void OnTranslateError(const translate::TranslateErrorDetails& details);
-
- // Callback for translate events.
- virtual void OnTranslateEvent(
- const translate::TranslateEventDetails& details);
-
- // Handles the Javascript message 'removePrefItem'. This message is sent
- // when UI requests to remove an item in the preference.
- void OnRemovePrefItem(const base::ListValue* args);
-
- // Handles the JavaScript message 'setRecentTargetLanguage'. This message is
- // sent when the UI requests to change the 'translate_recent_target'
- // preference.
- void OnSetRecentTargetLanguage(const base::ListValue* args);
-
- // Handles the Javascript message 'overrideCountry'. This message is sent
- // when UI requests to override the stored country.
- void OnOverrideCountry(const base::ListValue* country);
-
- // Handles the Javascript message 'requestInfo'. This message is sent
- // when UI needs to show information concerned with the translation.
- // For now, this returns only prefs to Javascript.
- // |args| is not used.
- void OnRequestInfo(const base::ListValue* args);
-
- // Sends a messsage to Javascript.
- void SendMessageToJs(const std::string& message, const base::Value& value);
-
- // Sends the current preference to Javascript.
- void SendPrefsToJs();
-
- // Sends the languages currently supported by the server to JavaScript.
- void SendSupportedLanguagesToJs();
-
- // Sends the stored permanent country to Javascript.
- // |was_updated| tells Javascript if the country has been updated or not.
- void SendCountryToJs(bool was_updated);
-
- // Subscription for translate events coming from the translate language list.
- std::unique_ptr<
- translate::TranslateLanguageList::EventCallbackList::Subscription>
- event_subscription_;
-
- // Subscription for translate errors coming from the translate manager.
- std::unique_ptr<
- translate::TranslateManager::TranslateErrorCallbackList::Subscription>
- error_subscription_;
-
- content::NotificationRegistrar notification_registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(TranslateInternalsHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc
index 7bacde2c268..34a98f03c31 100644
--- a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_ui.cc
@@ -12,10 +12,11 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/translate_internals/translate_internals_handler.h"
+#include "chrome/browser/ui/webui/translate_internals/chrome_translate_internals_handler.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
-#include "chrome/grit/translate_internals_resources.h"
+#include "chrome/grit/browser_resources.h"
+#include "components/translate/translate_internals/translate_internals_handler.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
@@ -23,35 +24,17 @@
namespace {
-// Sets the languages to |dict|. Each key is a language code and each value is
-// a language name in the locale.
-void GetLanguages(base::DictionaryValue* dict) {
- DCHECK(dict);
-
- const std::string app_locale = g_browser_process->GetApplicationLocale();
- std::vector<std::string> language_codes;
- l10n_util::GetAcceptLanguagesForLocale(app_locale, &language_codes);
-
- for (auto it = language_codes.begin(); it != language_codes.end(); ++it) {
- const std::string& lang_code = *it;
- base::string16 lang_name =
- l10n_util::GetDisplayNameForLocale(lang_code, app_locale, false);
- dict->SetString(lang_code, lang_name);
- }
-}
-
content::WebUIDataSource* CreateTranslateInternalsHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUITranslateInternalsHost);
- source->SetDefaultResource(IDR_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HTML);
+ source->SetDefaultResource(IDR_TRANSLATE_INTERNALS_HTML);
source->SetJsonPath("strings.js");
- source->AddResourcePath("translate_internals.js",
- IDR_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_JS);
+ source->AddResourcePath("translate_internals.js", IDR_TRANSLATE_INTERNALS_JS);
source->UseGzip();
base::DictionaryValue langs;
- GetLanguages(&langs);
+ translate::TranslateInternalsHandler::GetLanguages(&langs);
for (base::DictionaryValue::Iterator it(langs); !it.IsAtEnd(); it.Advance()) {
std::string key = "language-" + it.key();
std::string value;
@@ -69,7 +52,8 @@ content::WebUIDataSource* CreateTranslateInternalsHTMLSource() {
TranslateInternalsUI::TranslateInternalsUI(content::WebUI* web_ui)
: WebUIController(web_ui) {
- web_ui->AddMessageHandler(std::make_unique<TranslateInternalsHandler>());
+ web_ui->AddMessageHandler(
+ std::make_unique<ChromeTranslateInternalsHandler>());
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, CreateTranslateInternalsHTMLSource());
diff --git a/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc b/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
index efc72f63cc2..5f4916c4611 100644
--- a/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
@@ -21,6 +21,8 @@ UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui)
source->AddResourcePath("usb_internals.js", IDR_USB_INTERNALS_JS);
source->AddResourcePath("usb_internals.mojom-lite.js",
IDR_USB_INTERNALS_MOJOM_LITE_JS);
+ source->AddResourcePath("descriptor_panel.js",
+ IDR_USB_INTERNALS_DESCRIPTOR_PANEL_JS);
source->AddResourcePath("devices_page.js", IDR_USB_INTERNALS_DEVICES_PAGE_JS);
source->AddResourcePath("device.mojom-lite.js", IDR_USB_DEVICE_MOJOM_LITE_JS);
source->AddResourcePath("device_enumeration_options.mojom-lite.js",
diff --git a/chromium/chrome/browser/ui/webui/version_handler_win.cc b/chromium/chrome/browser/ui/webui/version_handler_win.cc
index 777c4ce2d9e..7f431234f23 100644
--- a/chromium/chrome/browser/ui/webui/version_handler_win.cc
+++ b/chromium/chrome/browser/ui/webui/version_handler_win.cc
@@ -61,10 +61,16 @@ std::string FullWindowsVersion() {
// unknown version
return base::StringPrintf("unknown version %d.%d", major, minor);
}
+
+ const std::string release_id = gi->release_id();
+
+ if (!release_id.empty())
+ version += " Version " + release_id;
+
if (patch > 0)
- version += base::StringPrintf(" Build %d.%d", build, patch);
+ version += base::StringPrintf(" (Build %d.%d)", build, patch);
else
- version += base::StringPrintf(" Build %d", build);
+ version += base::StringPrintf(" (Build %d)", build);
return version;
}
diff --git a/chromium/chrome/browser/ui/webui/version_handler_win_unittest.cc b/chromium/chrome/browser/ui/webui/version_handler_win_unittest.cc
index b054b576c44..9345bb0a240 100644
--- a/chromium/chrome/browser/ui/webui/version_handler_win_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/version_handler_win_unittest.cc
@@ -34,41 +34,54 @@ class WebUIWindowsVersion : public testing::Test {
TEST_F(WebUIWindowsVersion, Win10Pro) {
// set Windows Registry Key UBR
ubr_key.WriteValue(L"UBR", 555);
+ ubr_key.WriteValue(L"ReleaseId", L"1000");
// override base::win::OSInfo
base::test::ScopedOSInfoOverride os(
base::test::ScopedOSInfoOverride::Type::kWin10Pro);
EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(),
- "10 OS Build 15063.555");
+ "10 OS Version 1000 (Build 15063.555)");
}
TEST_F(WebUIWindowsVersion, WinServer2016) {
ubr_key.WriteValue(L"UBR", 1555);
+ ubr_key.WriteValue(L"ReleaseId", L"1001");
base::test::ScopedOSInfoOverride os(
base::test::ScopedOSInfoOverride::Type::kWinServer2016);
EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(),
- "Server OS Build 17134.1555");
+ "Server OS Version 1001 (Build 17134.1555)");
}
TEST_F(WebUIWindowsVersion, Win81Pro) {
ubr_key.WriteValue(L"UBR", 0UL);
+ ubr_key.WriteValue(L"ReleaseId", L"1001");
base::test::ScopedOSInfoOverride os(
base::test::ScopedOSInfoOverride::Type::kWin81Pro);
EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(),
- "8.1 Build 9600");
+ "8.1 Version 1001 (Build 9600)");
}
TEST_F(WebUIWindowsVersion, WinServer2012R2) {
ubr_key.WriteValue(L"UBR", 0UL);
+ ubr_key.WriteValue(L"ReleaseId", L"1001");
base::test::ScopedOSInfoOverride os(
base::test::ScopedOSInfoOverride::Type::kWinServer2012R2);
EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(),
- "Server 2012 R2 Build 9600");
+ "Server 2012 R2 Version 1001 (Build 9600)");
}
TEST_F(WebUIWindowsVersion, Win7ProSP1) {
ubr_key.WriteValue(L"UBR", 0UL);
+ ubr_key.WriteValue(L"ReleaseId", L"1001");
base::test::ScopedOSInfoOverride os(
base::test::ScopedOSInfoOverride::Type::kWin7ProSP1);
EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(),
- "7 Service Pack 1 Build 7601");
+ "7 Service Pack 1 Version 1001 (Build 7601)");
+}
+
+TEST_F(WebUIWindowsVersion, Win7ProSP1NoReleaseId) {
+ ubr_key.WriteValue(L"UBR", 0UL);
+ base::test::ScopedOSInfoOverride os(
+ base::test::ScopedOSInfoOverride::Type::kWin7ProSP1);
+ EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(),
+ "7 Service Pack 1 (Build 7601)");
}
diff --git a/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc b/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
index 41b659d1125..24e7b897e06 100644
--- a/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
+++ b/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
@@ -43,7 +43,7 @@ void WebUITestHandler::PreloadJavaScript(const base::string16& js_text,
void WebUITestHandler::RunJavaScript(const base::string16& js_text) {
GetWebUI()->GetWebContents()->GetMainFrame()->ExecuteJavaScriptForTests(
- js_text);
+ js_text, base::NullCallback());
}
bool WebUITestHandler::RunJavaScriptTestWithResult(
@@ -53,8 +53,8 @@ bool WebUITestHandler::RunJavaScriptTestWithResult(
content::RenderFrameHost* frame =
GetWebUI()->GetWebContents()->GetMainFrame();
frame->ExecuteJavaScriptForTests(
- js_text, base::Bind(&WebUITestHandler::JavaScriptComplete,
- base::Unretained(this)));
+ js_text, base::BindOnce(&WebUITestHandler::JavaScriptComplete,
+ base::Unretained(this)));
return WaitForResult();
}
@@ -76,7 +76,7 @@ void WebUITestHandler::RunQuitClosure() {
quit_closure_.Run();
}
-void WebUITestHandler::JavaScriptComplete(const base::Value* result) {
+void WebUITestHandler::JavaScriptComplete(base::Value result) {
// To ensure this gets done, do this before ASSERT* calls.
RunQuitClosure();
@@ -86,7 +86,7 @@ void WebUITestHandler::JavaScriptComplete(const base::Value* result) {
run_test_done_ = true;
run_test_succeeded_ = false;
- ASSERT_TRUE(result->GetAsBoolean(&run_test_succeeded_));
+ ASSERT_TRUE(result.GetAsBoolean(&run_test_succeeded_));
}
bool WebUITestHandler::WaitForResult() {
diff --git a/chromium/chrome/browser/ui/webui/web_ui_test_handler.h b/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
index 6a00d8c0b50..c91a2e6a456 100644
--- a/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
+++ b/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
@@ -50,7 +50,7 @@ class WebUITestHandler {
private:
// Gets the callback that Javascript execution is complete.
- void JavaScriptComplete(const base::Value* result);
+ void JavaScriptComplete(base::Value result);
// Runs a message loop until test finishes. Returns the result of the
// test.
diff --git a/chromium/chrome/browser/ui/webui/webapks_handler.cc b/chromium/chrome/browser/ui/webui/webapks_handler.cc
index f7f529ae6fc..73e48fff39a 100644
--- a/chromium/chrome/browser/ui/webui/webapks_handler.cc
+++ b/chromium/chrome/browser/ui/webui/webapks_handler.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/android/color_helpers.h"
#include "chrome/browser/android/shortcut_helper.h"
#include "content/public/browser/web_ui.h"
-#include "content/public/common/manifest_util.h"
+#include "third_party/blink/public/common/manifest/manifest_util.h"
#include "ui/gfx/color_utils.h"
WebApksHandler::WebApksHandler() : weak_ptr_factory_(this) {}
@@ -50,10 +50,10 @@ void WebApksHandler::OnWebApkInfoRetrieved(
result->SetString("manifestUrl", webapk_info.manifest_url);
result->SetString("manifestStartUrl", webapk_info.manifest_start_url);
result->SetString("displayMode",
- content::WebDisplayModeToString(webapk_info.display));
+ blink::WebDisplayModeToString(webapk_info.display));
result->SetString(
"orientation",
- content::WebScreenOrientationLockTypeToString(webapk_info.orientation));
+ blink::WebScreenOrientationLockTypeToString(webapk_info.orientation));
result->SetString("themeColor",
OptionalSkColorToString(webapk_info.theme_color));
result->SetString("backgroundColor",
diff --git a/chromium/chrome/browser/ui/webui/webui_browsertest.cc b/chromium/chrome/browser/ui/webui/webui_browsertest.cc
index 969ce238930..a48e98c93e6 100644
--- a/chromium/chrome/browser/ui/webui/webui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/webui_browsertest.cc
@@ -5,6 +5,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
@@ -94,7 +95,8 @@ class WebUIRequiringGestureBrowserTest : public InProcessBrowserTest {
void SendMessageAndWaitForFinish() {
main_rfh()->ExecuteJavaScriptForTests(
base::ASCIIToUTF16("chrome.send('messageRequiringGesture');"
- "chrome.send('notifyFinish');"));
+ "chrome.send('notifyFinish');"),
+ base::NullCallback());
base::RunLoop run_loop;
test_handler()->set_finish_closure(run_loop.QuitClosure());
run_loop.Run();
diff --git a/chromium/chrome/browser/ui/webui/welcome/OWNERS b/chromium/chrome/browser/ui/webui/welcome/OWNERS
index c497ef23d4a..a0bd3ec218b 100644
--- a/chromium/chrome/browser/ui/webui/welcome/OWNERS
+++ b/chromium/chrome/browser/ui/webui/welcome/OWNERS
@@ -1,4 +1,3 @@
hcarmona@chromium.org
-scottchen@chromium.org
# COMPONENT: UI>Browser>FirstRun
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/constants.cc b/chromium/chrome/browser/ui/webui/welcome/nux/constants.cc
index afb0fb82ff3..27d8dfcd186 100644
--- a/chromium/chrome/browser/ui/webui/welcome/nux/constants.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/nux/constants.cc
@@ -14,7 +14,7 @@ const base::Feature kNuxOnboardingFeature{"NuxOnboarding",
// nux-ntp-background should not be added here until we can guarantee that
// kUseGoogleLocalNtp is enabled
const char kDefaultNewUserModules[] =
- "nux-google-apps,nux-email,nux-set-as-default,signin-view";
+ "nux-google-apps,nux-set-as-default,signin-view";
const char kDefaultReturningUserModules[] = "nux-set-as-default";
// The value of these FeatureParam values should be a comma-delimited list
@@ -25,7 +25,8 @@ const base::FeatureParam<std::string> kNuxOnboardingNewUserModules{
const base::FeatureParam<std::string> kNuxOnboardingReturningUserModules{
&kNuxOnboardingFeature, "returning-user-modules",
kDefaultReturningUserModules};
-const base::FeatureParam<bool> kNuxOnboardingShowEmailInterstitial{
- &kNuxOnboardingFeature, "show-email-interstitial", false};
+
+const base::FeatureParam<bool> kNuxOnboardingShowGoogleApp{
+ &kNuxOnboardingFeature, "app-variation-enabled", false};
} // namespace nux
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/constants.h b/chromium/chrome/browser/ui/webui/welcome/nux/constants.h
index e79cd970cf3..de397b2f0d6 100644
--- a/chromium/chrome/browser/ui/webui/welcome/nux/constants.h
+++ b/chromium/chrome/browser/ui/webui/welcome/nux/constants.h
@@ -21,7 +21,7 @@ extern const char kDefaultReturningUserModules[];
extern const base::FeatureParam<std::string> kNuxOnboardingNewUserModules;
extern const base::FeatureParam<std::string> kNuxOnboardingReturningUserModules;
-extern const base::FeatureParam<bool> kNuxOnboardingShowEmailInterstitial;
+extern const base::FeatureParam<bool> kNuxOnboardingShowGoogleApp;
} // namespace nux
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.cc b/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.cc
deleted file mode 100644
index b88bcb954d4..00000000000
--- a/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.cc
+++ /dev/null
@@ -1,92 +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/welcome/nux/email_handler.h"
-
-#include "base/bind.h"
-#include "base/metrics/field_trial_params.h"
-#include "base/metrics/histogram_macros.h"
-#include "base/stl_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/favicon/favicon_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/welcome/nux/bookmark_item.h"
-#include "chrome/browser/ui/webui/welcome/nux/email_providers_list.h"
-#include "chrome/grit/generated_resources.h"
-#include "chrome/grit/onboarding_welcome_resources.h"
-#include "components/country_codes/country_codes.h"
-#include "components/favicon/core/favicon_service.h"
-#include "components/grit/components_resources.h"
-#include "components/grit/components_scaled_resources.h"
-#include "components/strings/grit/components_strings.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "ui/base/resource/resource_bundle.h"
-
-namespace nux {
-
-const char* kEmailInteractionHistogram =
- "FirstRun.NewUserExperience.EmailInteraction";
-
-constexpr const int kEmailIconSize = 48; // Pixels.
-
-EmailHandler::EmailHandler()
- : email_providers_(GetCurrentCountryEmailProviders()) {}
-
-EmailHandler::~EmailHandler() {}
-
-void EmailHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "cacheEmailIcon", base::BindRepeating(&EmailHandler::HandleCacheEmailIcon,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "getEmailList", base::BindRepeating(&EmailHandler::HandleGetEmailList,
- base::Unretained(this)));
-}
-
-void EmailHandler::HandleCacheEmailIcon(const base::ListValue* args) {
- int emailId;
- args->GetInteger(0, &emailId);
-
- const BookmarkItem* selectedEmail = NULL;
- for (const auto& provider : email_providers_) {
- if (provider.id == emailId) {
- selectedEmail = &provider;
- break;
- }
- }
- CHECK(selectedEmail); // WebUI should not be able to pass non-existent ID.
-
- // Preload the favicon cache with Chrome-bundled images. Otherwise, the
- // pre-populated bookmarks don't have favicons and look bad. Favicons are
- // updated automatically when a user visits a site.
- GURL app_url = GURL(selectedEmail->url);
- FaviconServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()),
- ServiceAccessType::EXPLICIT_ACCESS)
- ->MergeFavicon(
- app_url, app_url, favicon_base::IconType::kFavicon,
- ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
- selectedEmail->icon),
- gfx::Size(kEmailIconSize, kEmailIconSize));
-}
-
-void EmailHandler::HandleGetEmailList(const base::ListValue* args) {
- AllowJavascript();
- CHECK_EQ(1U, args->GetSize());
- const base::Value* callback_id;
- CHECK(args->Get(0, &callback_id));
- ResolveJavascriptCallback(*callback_id,
- BookmarkItemsToListValue(email_providers_));
-}
-
-void EmailHandler::AddSources(content::WebUIDataSource* html_source) {
- // Add constants to loadtime data
- html_source->AddInteger("email_providers_enum_count",
- GetNumberOfEmailProviders());
- html_source->SetJsonPath("strings.js");
-}
-
-} // namespace nux
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.h b/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.h
deleted file mode 100644
index 926790dd8e0..00000000000
--- a/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_HANDLER_H_
-
-#include <vector>
-
-#include "base/macros.h"
-#include "base/values.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace content {
-class WebUIDataSource;
-} // namespace content
-
-namespace nux {
-
-struct BookmarkItem;
-
-extern const char* kEmailInteractionHistogram;
-
-// These values are persisted to logs. Entries should not be renumbered and
-// numeric values should never be reused.
-enum class EmailInteraction {
- kPromptShown = 0,
- kNoThanks = 1,
- kGetStarted = 2,
- kCount,
-};
-
-class EmailHandler : public content::WebUIMessageHandler {
- public:
- EmailHandler();
- ~EmailHandler() override;
-
- // WebUIMessageHandler:
- void RegisterMessages() override;
-
- // Callbacks for JS APIs.
- void HandleCacheEmailIcon(const base::ListValue* args);
- void HandleGetEmailList(const base::ListValue* args);
-
- // Adds webui sources.
- static void AddSources(content::WebUIDataSource* html_source);
-
- private:
- const std::vector<BookmarkItem> email_providers_;
-
- DISALLOW_COPY_AND_ASSIGN(EmailHandler);
-};
-
-} // namespace nux
-
-#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/email_providers_list.cc b/chromium/chrome/browser/ui/webui/welcome/nux/email_providers_list.cc
deleted file mode 100644
index 329f878727d..00000000000
--- a/chromium/chrome/browser/ui/webui/welcome/nux/email_providers_list.cc
+++ /dev/null
@@ -1,67 +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/welcome/nux/email_providers_list.h"
-
-#include "chrome/browser/ui/webui/welcome/nux/bookmark_item.h"
-#include "chrome/grit/onboarding_welcome_resources.h"
-#include "components/country_codes/country_codes.h"
-
-namespace nux {
-
-// These values are persisted to logs. Entries should not be renumbered and
-// numeric values should never be reused.
-enum class EmailProviders {
- kGmail = 0,
- kYahoo = 1,
- kOutlook = 2,
- kAol = 3,
- kiCloud = 4,
- kCount,
-};
-
-std::vector<BookmarkItem> GetCurrentCountryEmailProviders() {
- switch (country_codes::GetCurrentCountryID()) {
- case country_codes::CountryCharsToCountryID('U', 'S'): {
- return {
- {static_cast<int>(EmailProviders::kGmail), "Gmail", "gmail",
- "https://accounts.google.com/b/0/AddMailService",
- IDR_NUX_EMAIL_GMAIL_1X},
- {static_cast<int>(EmailProviders::kYahoo), "Yahoo", "yahoo",
- "https://mail.yahoo.com", IDR_NUX_EMAIL_YAHOO_1X},
- {static_cast<int>(EmailProviders::kOutlook), "Outlook", "outlook",
- "https://login.live.com/login.srf?", IDR_NUX_EMAIL_OUTLOOK_1X},
- {static_cast<int>(EmailProviders::kAol), "AOL", "aol",
- "https://mail.aol.com", IDR_NUX_EMAIL_AOL_1X},
- {static_cast<int>(EmailProviders::kiCloud), "iCloud", "icloud",
- "https://www.icloud.com/mail", IDR_NUX_EMAIL_ICLOUD_1X},
- };
- }
-
- // TODO(scottchen): define all supported countries here.
-
- default: {
- // TODO(scottchen): examine if we want these US providers as default.
- return {
- {static_cast<int>(EmailProviders::kGmail), "Gmail", "gmail",
- "https://accounts.google.com/b/0/AddMailService",
- IDR_NUX_EMAIL_GMAIL_1X},
- {static_cast<int>(EmailProviders::kYahoo), "Yahoo", "yahoo",
- "https://mail.yahoo.com", IDR_NUX_EMAIL_YAHOO_1X},
- {static_cast<int>(EmailProviders::kOutlook), "Outlook", "outlook",
- "https://login.live.com/login.srf?", IDR_NUX_EMAIL_OUTLOOK_1X},
- {static_cast<int>(EmailProviders::kAol), "AOL", "aol",
- "https://mail.aol.com", IDR_NUX_EMAIL_AOL_1X},
- {static_cast<int>(EmailProviders::kiCloud), "iCloud", "icloud",
- "https://www.icloud.com/mail", IDR_NUX_EMAIL_ICLOUD_1X},
- };
- }
- }
-}
-
-int GetNumberOfEmailProviders() {
- return static_cast<int>(EmailProviders::kCount);
-}
-
-} // namespace nux
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/email_providers_list.h b/chromium/chrome/browser/ui/webui/welcome/nux/email_providers_list.h
deleted file mode 100644
index e50eed8dcd1..00000000000
--- a/chromium/chrome/browser/ui/webui/welcome/nux/email_providers_list.h
+++ /dev/null
@@ -1,21 +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_WELCOME_NUX_EMAIL_PROVIDERS_LIST_H_
-#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_PROVIDERS_LIST_H_
-
-#include <vector>
-
-#include "chrome/browser/ui/webui/welcome/nux/bookmark_item.h"
-
-namespace nux {
-
-std::vector<BookmarkItem> GetCurrentCountryEmailProviders();
-
-// Function to avoid exposing enum only for count.
-int GetNumberOfEmailProviders();
-
-} // namespace nux
-
-#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_PROVIDERS_LIST_H_
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.cc b/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.cc
index e8e17c049af..3669d984942 100644
--- a/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.cc
@@ -11,6 +11,8 @@
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/welcome/nux/bookmark_item.h"
+#include "chrome/browser/ui/webui/welcome/nux_helper.h"
+#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/onboarding_welcome_resources.h"
#include "components/favicon/core/favicon_service.h"
@@ -27,12 +29,13 @@ namespace nux {
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class GoogleApps {
- kGmailDoNotUse = 0, // Deprecated.
+ kGmail = 0,
kYouTube = 1,
kMaps = 2,
kTranslate = 3,
kNews = 4,
- kChromeWebStore = 5,
+ kChromeWebStoreDoNotUse = 5, // Deprecated.
+ kSearch = 6,
kCount,
};
@@ -41,33 +44,52 @@ const char* kGoogleAppsInteractionHistogram =
constexpr const int kGoogleAppIconSize = 48; // Pixels.
-GoogleAppsHandler::GoogleAppsHandler()
- : // Do not translate icon name as it is not human visible and needs to
- // match CSS.
- google_apps_{{
- {static_cast<int>(GoogleApps::kYouTube),
- l10n_util::GetStringUTF8(
- IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_YOUTUBE),
- "youtube", "https://youtube.com", IDR_NUX_GOOGLE_APPS_YOUTUBE_1X},
- {static_cast<int>(GoogleApps::kMaps),
- l10n_util::GetStringUTF8(
- IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_MAPS),
- "maps", "https://maps.google.com", IDR_NUX_GOOGLE_APPS_MAPS_1X},
- {static_cast<int>(GoogleApps::kNews),
- l10n_util::GetStringUTF8(
- IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_NEWS),
- "news", "https://news.google.com", IDR_NUX_GOOGLE_APPS_NEWS_1X},
- {static_cast<int>(GoogleApps::kTranslate),
- l10n_util::GetStringUTF8(
- IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_TRANSLATE),
- "translate", "https://translate.google.com",
- IDR_NUX_GOOGLE_APPS_TRANSLATE_1X},
- {static_cast<int>(GoogleApps::kChromeWebStore),
- l10n_util::GetStringUTF8(
- IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_WEB_STORE),
- "web-store", "https://chrome.google.com/webstore",
- IDR_NUX_GOOGLE_APPS_CHROME_STORE_1X},
- }} {}
+GoogleAppsHandler::GoogleAppsHandler() {
+ // Do not translate icon name as it is not human visible and needs to
+ // match CSS.
+
+ BookmarkItem gmail = {
+ static_cast<int>(GoogleApps::kGmail),
+ l10n_util::GetStringUTF8(IDS_ONBOARDING_WELCOME_NUX_GOOGLE_GMAIL),
+ "gmail", "https://accounts.google.com/b/0/AddMailService",
+ IDR_NUX_GOOGLE_APPS_GMAIL_1X};
+
+ if (IsAppVariationEnabled()) {
+#if defined(GOOGLE_CHROME_BUILD)
+ google_apps_.push_back(
+ {static_cast<int>(GoogleApps::kSearch),
+ l10n_util::GetStringUTF8(IDS_ONBOARDING_WELCOME_NUX_GOOGLE_SEARCH),
+ "search", "https://google.com", IDS_ONBOARDING_WELCOME_SEARCH});
+#endif // GOOGLE_CHROME_BUILD
+ } else {
+ google_apps_.push_back(gmail);
+ }
+
+ google_apps_.push_back(
+ {static_cast<int>(GoogleApps::kYouTube),
+ l10n_util::GetStringUTF8(IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_YOUTUBE),
+ "youtube", "https://youtube.com", IDR_NUX_GOOGLE_APPS_YOUTUBE_1X});
+
+ google_apps_.push_back(
+ {static_cast<int>(GoogleApps::kMaps),
+ l10n_util::GetStringUTF8(IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_MAPS),
+ "maps", "https://maps.google.com", IDR_NUX_GOOGLE_APPS_MAPS_1X});
+
+ if (IsAppVariationEnabled()) {
+ google_apps_.push_back(gmail);
+ } else {
+ google_apps_.push_back(
+ {static_cast<int>(GoogleApps::kNews),
+ l10n_util::GetStringUTF8(IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_NEWS),
+ "news", "https://news.google.com", IDR_NUX_GOOGLE_APPS_NEWS_1X});
+ }
+
+ google_apps_.push_back({static_cast<int>(GoogleApps::kTranslate),
+ l10n_util::GetStringUTF8(
+ IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_TRANSLATE),
+ "translate", "https://translate.google.com",
+ IDR_NUX_GOOGLE_APPS_TRANSLATE_1X});
+}
GoogleAppsHandler::~GoogleAppsHandler() {}
@@ -88,9 +110,9 @@ void GoogleAppsHandler::HandleCacheGoogleAppIcon(const base::ListValue* args) {
args->GetInteger(0, &appId);
const BookmarkItem* selectedApp = NULL;
- for (size_t i = 0; i < kGoogleAppCount; i++) {
- if (google_apps_[i].id == appId) {
- selectedApp = &google_apps_[i];
+ for (const auto& google_app : google_apps_) {
+ if (google_app.id == appId) {
+ selectedApp = &google_app;
break;
}
}
@@ -116,7 +138,7 @@ void GoogleAppsHandler::HandleGetGoogleAppsList(const base::ListValue* args) {
CHECK(args->Get(0, &callback_id));
ResolveJavascriptCallback(
*callback_id,
- BookmarkItemsToListValue(google_apps_.data(), kGoogleAppCount));
+ BookmarkItemsToListValue(google_apps_.data(), google_apps_.size()));
}
} // namespace nux
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.h b/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.h
index a3db5324e3e..f35e22d4cb3 100644
--- a/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.h
+++ b/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_GOOGLE_APPS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_GOOGLE_APPS_HANDLER_H_
-#include <array>
+#include <vector>
#include "base/macros.h"
#include "base/values.h"
@@ -25,8 +25,6 @@ enum class GoogleAppsInteraction {
kCount,
};
-const size_t kGoogleAppCount = 5;
-
class GoogleAppsHandler : public content::WebUIMessageHandler {
public:
GoogleAppsHandler();
@@ -40,7 +38,7 @@ class GoogleAppsHandler : public content::WebUIMessageHandler {
void HandleGetGoogleAppsList(const base::ListValue* args);
private:
- std::array<BookmarkItem, kGoogleAppCount> google_apps_;
+ std::vector<BookmarkItem> google_apps_;
DISALLOW_COPY_AND_ASSIGN(GoogleAppsHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.cc b/chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.cc
index 0bd0c361198..3d4f3387ec8 100644
--- a/chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.cc
@@ -12,7 +12,7 @@ SetAsDefaultHandler::SetAsDefaultHandler()
SetAsDefaultHandler::~SetAsDefaultHandler() {}
void SetAsDefaultHandler::RecordSetAsDefaultUMA() {
- // TODO(scottchen): Add UMA tracking.
+ // TODO(hcarmona): Add UMA tracking.
}
} // namespace nux
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux_helper.cc b/chromium/chrome/browser/ui/webui/welcome/nux_helper.cc
index 0a0adc7958b..a79c297bd7c 100644
--- a/chromium/chrome/browser/ui/webui/welcome/nux_helper.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/nux_helper.cc
@@ -5,19 +5,28 @@
#include "chrome/browser/ui/webui/welcome/nux_helper.h"
#include <string>
+#include <vector>
#include "base/feature_list.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_params.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_tokenizer.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
+#include "chrome/browser/policy/browser_signin_policy_handler.h"
+#include "chrome/browser/policy/profile_policy_connector.h"
+#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/ntp_features.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/ui/webui/welcome/nux/constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "components/policy/core/common/policy_map.h"
+#include "components/policy/core/common/policy_service.h"
+#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#if defined(OS_MACOSX)
@@ -25,6 +34,52 @@
#endif // defined(OS_MACOSX)
namespace nux {
+
+bool CanShowGoogleAppModule(const policy::PolicyMap& policies) {
+ const base::Value* bookmark_bar_enabled_value =
+ policies.GetValue(policy::key::kBookmarkBarEnabled);
+
+ if (bookmark_bar_enabled_value && !bookmark_bar_enabled_value->GetBool()) {
+ return false;
+ }
+
+ const base::Value* edit_bookmarks_value =
+ policies.GetValue(policy::key::kEditBookmarksEnabled);
+
+ if (edit_bookmarks_value && !edit_bookmarks_value->GetBool()) {
+ return false;
+ }
+
+ return true;
+}
+
+bool CanShowNTPBackgroundModule(const policy::PolicyMap& policies) {
+ // We shouldn't show this module if any policy is set that overrides the NTP.
+ return !policies.GetValue(policy::key::kNewTabPageLocation);
+}
+
+bool CanShowSetDefaultModule(const policy::PolicyMap& policies) {
+ const base::Value* set_default_value =
+ policies.GetValue(policy::key::kDefaultBrowserSettingEnabled);
+
+ return !set_default_value || set_default_value->GetBool();
+}
+
+bool CanShowSigninModule(const policy::PolicyMap& policies) {
+ const base::Value* browser_signin_value =
+ policies.GetValue(policy::key::kBrowserSignin);
+
+ if (!browser_signin_value)
+ return true;
+
+ int int_browser_signin_value;
+ bool success = browser_signin_value->GetAsInteger(&int_browser_signin_value);
+ DCHECK(success);
+
+ return static_cast<policy::BrowserSigninMode>(int_browser_signin_value) !=
+ policy::BrowserSigninMode::kDisabled;
+}
+
// This feature flag is used to force the feature to be turned on for non-win
// and non-branded builds, like with tests or development on other platforms.
const base::Feature kNuxOnboardingForceEnabled = {
@@ -35,15 +90,14 @@ const base::Feature kNuxOnboardingForceEnabled = {
// chrome/browser/resources/welcome/onboarding_welcome/welcome_app.js
const base::FeatureParam<std::string> kNuxOnboardingForceEnabledNewUserModules =
{&kNuxOnboardingForceEnabled, "new-user-modules",
- "nux-google-apps,nux-email,nux-ntp-background,nux-set-as-default,"
+ "nux-google-apps,nux-ntp-background,nux-set-as-default,"
"signin-view"};
const base::FeatureParam<std::string>
kNuxOnboardingForceEnabledReturningUserModules = {
&kNuxOnboardingForceEnabled, "returning-user-modules",
"nux-set-as-default"};
-// TODO(hcarmona): remove this flag and all code behind it.
-const base::FeatureParam<bool> kNuxOnboardingForceEnabledShowEmailInterstitial =
- {&kNuxOnboardingForceEnabled, "show-email-interstitial", true};
+const base::FeatureParam<bool> kNuxOnboardingForceEnabledShowGoogleApp = {
+ &kNuxOnboardingForceEnabled, "app-variation-enabled", false};
// Our current running experiment of testing the nux-ntp-background module
// depends on the Local NTP feature/experiment being enabled. To avoid polluting
@@ -120,32 +174,75 @@ bool IsNuxOnboardingEnabled(Profile* profile) {
return false;
}
+bool IsAppVariationEnabled() {
+ return kNuxOnboardingForceEnabledShowGoogleApp.Get() ||
+ kNuxOnboardingShowGoogleApp.Get();
+}
+
+const policy::PolicyMap& GetPoliciesFromProfile(Profile* profile) {
+ policy::ProfilePolicyConnector* profile_connector =
+ policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile);
+ DCHECK(profile_connector);
+ return profile_connector->policy_service()->GetPolicies(
+ policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()));
+}
+
+std::vector<std::string> GetAvailableModules(
+ const policy::PolicyMap& policies) {
+ std::vector<std::string> available_modules;
+
+ if (CanShowGoogleAppModule(policies))
+ available_modules.push_back("nux-google-apps");
+ if (CanShowNTPBackgroundModule(policies))
+ available_modules.push_back("nux-ntp-background");
+ if (CanShowSetDefaultModule(policies))
+ available_modules.push_back("nux-set-as-default");
+ if (CanShowSigninModule(policies))
+ available_modules.push_back("signin-view");
+
+ return available_modules;
+}
+
+std::string FilterModules(const std::string& requested_modules,
+ const std::vector<std::string>& available_modules) {
+ std::vector<std::string> requested_list = base::SplitString(
+ requested_modules, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
+ std::vector<std::string> filtered_modules;
+
+ std::copy_if(requested_list.begin(), requested_list.end(),
+ std::back_inserter(filtered_modules),
+ [available_modules](std::string module) {
+ return !module.empty() &&
+ base::ContainsValue(available_modules, module);
+ });
+
+ return base::JoinString(filtered_modules, ",");
+}
+
base::DictionaryValue GetNuxOnboardingModules(Profile* profile) {
// This function should not be called when nux onboarding feature is not on.
DCHECK(nux::IsNuxOnboardingEnabled(profile));
- base::DictionaryValue modules;
+ std::string new_user_modules = kDefaultNewUserModules;
+ std::string returning_user_modules = kDefaultReturningUserModules;
if (base::FeatureList::IsEnabled(nux::kNuxOnboardingForceEnabled)) {
- modules.SetString("new-user",
- kNuxOnboardingForceEnabledNewUserModules.Get());
- modules.SetString("returning-user",
- kNuxOnboardingForceEnabledReturningUserModules.Get());
- modules.SetBoolean("show-email-interstitial",
- kNuxOnboardingForceEnabledShowEmailInterstitial.Get());
+ new_user_modules = kNuxOnboardingForceEnabledNewUserModules.Get();
+ returning_user_modules =
+ kNuxOnboardingForceEnabledReturningUserModules.Get();
} else if (CanExperimentWithVariations(profile)) {
- modules.SetString("new-user", kNuxOnboardingNewUserModules.Get());
- modules.SetString("returning-user",
- kNuxOnboardingReturningUserModules.Get());
- modules.SetBoolean("show-email-interstitial",
- kNuxOnboardingShowEmailInterstitial.Get());
- } else {
- // Default behavior w/o checking feature flag.
- modules.SetString("new-user", kDefaultNewUserModules);
- modules.SetString("returning-user", kDefaultReturningUserModules);
- modules.SetBoolean("show-email-interstitial", false);
+ new_user_modules = kNuxOnboardingNewUserModules.Get();
+ returning_user_modules = kNuxOnboardingReturningUserModules.Get();
}
+ const policy::PolicyMap& policies = GetPoliciesFromProfile(profile);
+ std::vector<std::string> available_modules = GetAvailableModules(policies);
+
+ base::DictionaryValue modules;
+ modules.SetString("new-user",
+ FilterModules(new_user_modules, available_modules));
+ modules.SetString("returning-user",
+ FilterModules(returning_user_modules, available_modules));
return modules;
}
} // namespace nux
diff --git a/chromium/chrome/browser/ui/webui/welcome/nux_helper.h b/chromium/chrome/browser/ui/webui/welcome/nux_helper.h
index a56ae37d041..b11d2b3c257 100644
--- a/chromium/chrome/browser/ui/webui/welcome/nux_helper.h
+++ b/chromium/chrome/browser/ui/webui/welcome/nux_helper.h
@@ -24,8 +24,6 @@ extern const base::FeatureParam<std::string>
kNuxOnboardingForceEnabledNewUserModules;
extern const base::FeatureParam<std::string>
kNuxOnboardingForceEnabledReturningUserModules;
-extern const base::FeatureParam<bool>
- kNuxOnboardingForceEnabledShowEmailInterstitial;
// Get the group for users who onboard in this experiment.
// Groups are:
@@ -38,6 +36,8 @@ std::string GetOnboardingGroup(Profile* profile);
bool IsNuxOnboardingEnabled(Profile* profile);
+bool IsAppVariationEnabled();
+
base::DictionaryValue GetNuxOnboardingModules(Profile* profile);
} // namespace nux
diff --git a/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc
index 6a20288420f..e0d62ec0848 100644
--- a/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc
@@ -20,7 +20,6 @@
#include "ui/base/page_transition_types.h"
const char kWelcomeReturningUserUrl[] = "chrome://welcome/returning-user";
-const char kWelcomeEmailInterstitial[] = "chrome://welcome/email-interstitial";
WelcomeHandler::WelcomeHandler(content::WebUI* web_ui)
: profile_(Profile::FromWebUI(web_ui)),
@@ -53,9 +52,7 @@ WelcomeHandler::~WelcomeHandler() {
bool WelcomeHandler::isValidRedirectUrl() {
GURL current_url = web_ui()->GetWebContents()->GetVisibleURL();
- return current_url == kWelcomeReturningUserUrl ||
- current_url.spec().find(kWelcomeEmailInterstitial) !=
- std::string::npos;
+ return current_url == kWelcomeReturningUserUrl;
}
// Override from LoginUIService::Observer.
@@ -108,16 +105,7 @@ void WelcomeHandler::HandleUserDecline(const base::ListValue* args) {
? WelcomeResult::ATTEMPTED_DECLINED
: WelcomeResult::DECLINED;
- if (args->GetSize() == 1U) {
- std::string url_string;
- CHECK(args->GetString(0, &url_string));
- GURL redirect_url = GURL(url_string);
- DCHECK(redirect_url.is_valid());
-
- GoToURL(redirect_url);
- } else {
- GoToNewTabPage();
- }
+ GoToNewTabPage();
}
// Override from WebUIMessageHandler.
diff --git a/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
index 83251fbb5d6..8238a6c003c 100644
--- a/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc
@@ -4,14 +4,17 @@
#include "chrome/browser/ui/webui/welcome/welcome_ui.h"
+#include <map>
+
+#include "base/bind.h"
#include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
#include "build/build_config.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/ui/webui/dark_mode_handler.h"
#include "chrome/browser/ui/webui/localized_string.h"
#include "chrome/browser/ui/webui/welcome/nux/bookmark_handler.h"
#include "chrome/browser/ui/webui/welcome/nux/constants.h"
-#include "chrome/browser/ui/webui/welcome/nux/email_handler.h"
#include "chrome/browser/ui/webui/welcome/nux/google_apps_handler.h"
#include "chrome/browser/ui/webui/welcome/nux/ntp_background_handler.h"
#include "chrome/browser/ui/webui/welcome/nux/set_as_default_handler.h"
@@ -25,6 +28,7 @@
#include "chrome/grit/onboarding_welcome_resources.h"
#include "chrome/grit/onboarding_welcome_resources_map.h"
#include "components/prefs/pref_service.h"
+#include "components/signin/core/browser/signin_pref_names.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "net/base/url_util.h"
@@ -35,19 +39,19 @@
#endif
namespace {
+
const bool kIsBranded =
#if defined(GOOGLE_CHROME_BUILD)
true;
#else
false;
#endif
-} // namespace
-bool HandleRequestCallback(
- base::WeakPtr<WelcomeUI> weak_ptr,
- const std::string& path,
- const content::WebUIDataSource::GotDataCallback& callback) {
- if (!base::StartsWith(path, "preview-background.jpg",
+const char kPreviewBackgroundPath[] = "preview-background.jpg";
+
+bool ShouldHandleRequestCallback(base::WeakPtr<WelcomeUI> weak_ptr,
+ const std::string& path) {
+ if (!base::StartsWith(path, kPreviewBackgroundPath,
base::CompareCase::SENSITIVE)) {
return false;
}
@@ -59,12 +63,22 @@ bool HandleRequestCallback(
return false;
}
- if (weak_ptr) {
- weak_ptr->CreateBackgroundFetcher(background_index, callback);
- return true;
- }
+ return !weak_ptr ? false : true;
+}
+
+void HandleRequestCallback(
+ base::WeakPtr<WelcomeUI> weak_ptr,
+ const std::string& path,
+ const content::WebUIDataSource::GotDataCallback& callback) {
+ DCHECK(ShouldHandleRequestCallback(weak_ptr, path));
+
+ std::string index_param = path.substr(path.find_first_of("?") + 1);
+ int background_index = -1;
+ CHECK(base::StringToInt(index_param, &background_index) ||
+ background_index < 0);
- return false;
+ DCHECK(weak_ptr);
+ weak_ptr->CreateBackgroundFetcher(background_index, callback);
}
void AddOnboardingStrings(content::WebUIDataSource* html_source) {
@@ -76,6 +90,7 @@ void AddOnboardingStrings(content::WebUIDataSource* html_source) {
{"bookmarkRemoved", IDS_ONBOARDING_WELCOME_BOOKMARK_REMOVED},
{"bookmarksRemoved", IDS_ONBOARDING_WELCOME_BOOKMARKS_REMOVED},
{"bookmarkReplaced", IDS_ONBOARDING_WELCOME_BOOKMARK_REPLACED},
+ {"defaultBrowserChanged", IDS_ONBOARDING_DEFAULT_BROWSER_CHANGED},
{"getStarted", IDS_ONBOARDING_WELCOME_GET_STARTED},
{"headerText", IDS_WELCOME_HEADER},
{"next", IDS_ONBOARDING_WELCOME_NEXT},
@@ -87,9 +102,6 @@ void AddOnboardingStrings(content::WebUIDataSource* html_source) {
{"signInSubHeader", IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_SUB_HEADER},
{"signIn", IDS_ONBOARDING_WELCOME_SIGNIN_VIEW_SIGNIN},
- // Email provider module strings.
- {"emailProviderTitle", IDS_ONBOARDING_WELCOME_NUX_EMAIL_TITLE},
-
// Google apps module strings.
{"googleAppsDescription",
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_DESCRIPTION},
@@ -116,17 +128,26 @@ void AddOnboardingStrings(content::WebUIDataSource* html_source) {
{"landingDescription", IDS_ONBOARDING_WELCOME_LANDING_DESCRIPTION},
{"landingNewUser", IDS_ONBOARDING_WELCOME_LANDING_NEW_USER},
{"landingExistingUser", IDS_ONBOARDING_WELCOME_LANDING_EXISTING_USER},
-
- // Email interstitial strings.
- {"emailInterstitialTitle",
- IDS_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_TITLE},
- {"emailInterstitialContinue",
- IDS_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_CONTINUE},
};
AddLocalizedStringsBulk(html_source, kLocalizedStrings,
base::size(kLocalizedStrings));
}
+const std::map<std::string, bool>& GetGzipMap() {
+ static std::map<std::string, bool>* gzip_map = nullptr;
+ if (!gzip_map) {
+ gzip_map = new std::map<std::string, bool>();
+ for (size_t i = 0; i < kOnboardingWelcomeResourcesSize; ++i) {
+ (*gzip_map)[kOnboardingWelcomeResources[i].name] =
+ kOnboardingWelcomeResources[i].gzipped;
+ }
+ (*gzip_map)[kPreviewBackgroundPath] = false;
+ }
+ return *gzip_map;
+}
+
+} // namespace
+
WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
: content::WebUIController(web_ui), weak_ptr_factory_(this) {
Profile* profile = Profile::FromWebUI(web_ui);
@@ -147,9 +168,6 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
DarkModeHandler::Initialize(web_ui, html_source);
- bool is_dice =
- AccountConsistencyModeManager::IsDiceEnabledForProfile(profile);
-
// There are multiple possible configurations that affects the layout, but
// first add resources that are shared across all layouts.
html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128);
@@ -169,11 +187,6 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
html_source->SetDefaultResource(
IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_HTML);
- // chrome://welcome/email-interstitial
- html_source->AddResourcePath(
- "email-interstitial",
- IDR_WELCOME_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_HTML);
-
#if defined(OS_WIN)
html_source->AddBoolean(
"is_win10", base::win::GetVersion() >= base::win::VERSION_WIN10);
@@ -183,10 +196,6 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
web_ui->AddMessageHandler(
std::make_unique<nux::BookmarkHandler>(profile->GetPrefs()));
- // Add email provider bookmarking onboarding module.
- web_ui->AddMessageHandler(std::make_unique<nux::EmailHandler>());
- nux::EmailHandler::AddSources(html_source);
-
// Add google apps bookmarking onboarding module.
web_ui->AddMessageHandler(std::make_unique<nux::GoogleAppsHandler>());
@@ -203,13 +212,17 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
nux::GetNuxOnboardingModules(profile)
.FindKey("returning-user")
->GetString());
- html_source->AddBoolean("showEmailInterstitial",
- nux::GetNuxOnboardingModules(profile)
- .FindKey("show-email-interstitial")
- ->GetBool());
- html_source->SetRequestFilter(base::BindRepeating(
- &HandleRequestCallback, weak_ptr_factory_.GetWeakPtr()));
- } else if (kIsBranded && is_dice) {
+ html_source->AddBoolean("signinAllowed", profile->GetPrefs()->GetBoolean(
+ prefs::kSigninAllowed));
+ html_source->SetRequestFilter(
+ base::BindRepeating(&ShouldHandleRequestCallback,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::BindRepeating(&HandleRequestCallback,
+ weak_ptr_factory_.GetWeakPtr()));
+ html_source->UseGzip(base::BindRepeating(&WelcomeUI::IsGzipped));
+ html_source->SetJsonPath("strings.js");
+ } else if (kIsBranded &&
+ AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)) {
// Use special layout if the application is branded and DICE is enabled.
html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER);
html_source->AddLocalizedString("acceptText",
@@ -270,3 +283,9 @@ void WelcomeUI::StorePageSeen(Profile* profile) {
// Store that this profile has been shown the Welcome page.
profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
}
+
+bool WelcomeUI::IsGzipped(const std::string& path) {
+ const std::map<std::string, bool>& gzip_map = GetGzipMap();
+ const auto it = gzip_map.find(path);
+ return it == gzip_map.end() || it->second;
+}
diff --git a/chromium/chrome/browser/ui/webui/welcome/welcome_ui.h b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.h
index e74a6f92dfe..55896debd39 100644
--- a/chromium/chrome/browser/ui/webui/welcome/welcome_ui.h
+++ b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.h
@@ -28,6 +28,10 @@ class WelcomeUI : public content::WebUIController {
size_t background_index,
const content::WebUIDataSource::GotDataCallback& callback);
+ protected:
+ // Visible for testing.
+ static bool IsGzipped(const std::string& path);
+
private:
void StorePageSeen(Profile* profile);
std::unique_ptr<nux::NtpBackgroundFetcher> background_fetcher_;
diff --git a/chromium/chrome/browser/ui/webui/welcome/welcome_ui_unittest.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_ui_unittest.cc
new file mode 100644
index 00000000000..9f8592ed129
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/welcome/welcome_ui_unittest.cc
@@ -0,0 +1,27 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/welcome/welcome_ui.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+class TestWelcomeUI : public WelcomeUI {
+ public:
+ using WelcomeUI::IsGzipped;
+};
+
+TEST(WelcomeUITest, IsGzipped) {
+ // Default resource.
+ EXPECT_TRUE(TestWelcomeUI::IsGzipped(""));
+ EXPECT_TRUE(TestWelcomeUI::IsGzipped("welcome.html"));
+ EXPECT_TRUE(TestWelcomeUI::IsGzipped("new-user"));
+ EXPECT_TRUE(TestWelcomeUI::IsGzipped("returning-user"));
+
+ // Images are intentionally not gzipped.
+ EXPECT_FALSE(TestWelcomeUI::IsGzipped("images/youtube_1x.png"));
+
+ // This is a dynamic path that fetches from the network and should not be
+ // considered gzipped.
+ EXPECT_FALSE(TestWelcomeUI::IsGzipped("preview-background.jpg"));
+}
diff --git a/chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.cc
index f629bf36c28..954431fb0d8 100644
--- a/chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.cc
+++ b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.cc
@@ -12,6 +12,9 @@
#include "base/values.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/shell_integration_win.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
@@ -140,9 +143,12 @@ void WelcomeWin10Handler::HandleSetDefaultBrowser(const base::ListValue* args) {
}
void WelcomeWin10Handler::HandleContinue(const base::ListValue* args) {
- web_ui()->GetWebContents()->GetController().LoadURL(
- GURL(chrome::kChromeUINewTabURL), content::Referrer(),
- ui::PageTransition::PAGE_TRANSITION_LINK, std::string());
+ content::WebContents* contents = web_ui()->GetWebContents();
+ Browser* browser = chrome::FindBrowserWithWebContents(contents);
+ NavigateParams params(browser, GURL(chrome::kChromeUINewTabURL),
+ ui::PageTransition::PAGE_TRANSITION_LINK);
+ params.source_contents = web_ui()->GetWebContents();
+ Navigate(&params);
}
void WelcomeWin10Handler::StartIsPinnedToTaskbarCheck() {