diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:19:40 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-12-10 16:01:50 +0000 |
commit | 51f6c2793adab2d864b3d2b360000ef8db1d3e92 (patch) | |
tree | 835b3b4446b012c75e80177cef9fbe6972cc7dbe /chromium/chrome/browser/ui | |
parent | 6036726eb981b6c4b42047513b9d3f4ac865daac (diff) |
BASELINE: Update Chromium to 71.0.3578.93
Change-Id: I6a32086c33670e1b033f8b10e6bf1fd4da1d105d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/chrome/browser/ui')
232 files changed, 5530 insertions, 4496 deletions
diff --git a/chromium/chrome/browser/ui/BUILD.gn b/chromium/chrome/browser/ui/BUILD.gn index ea8b1a687eb..40fc10af525 100644 --- a/chromium/chrome/browser/ui/BUILD.gn +++ b/chromium/chrome/browser/ui/BUILD.gn @@ -10,6 +10,7 @@ import("//build/config/ui.gni") import("//build/split_static_library.gni") import("//chrome/common/features.gni") import("//chromeos/assistant/assistant.gni") +import("//components/feature_engagement/features.gni") import("//components/nacl/features.gni") import("//components/offline_pages/buildflags/features.gni") import("//components/signin/features.gni") @@ -40,469 +41,6 @@ jumbo_split_static_library("ui") { split_count = 1 } - # The cocoa browser (ie, primary ui) sources. These are in a separate - # variable temporarily to ease the work on https://crbug.com/804950 and - # https://crbug.com/802257. - # TODO(ellyjones): Remove this variable once 804950 and 802257 are fixed. - if (is_mac) { - cocoa_browser_sources = [ - "cocoa/animatable_image.h", - "cocoa/animatable_image.mm", - "cocoa/animatable_view.h", - "cocoa/animatable_view.mm", - "cocoa/app_menu/app_menu_button_cell.h", - "cocoa/app_menu/app_menu_button_cell.mm", - "cocoa/app_menu/app_menu_controller.h", - "cocoa/app_menu/app_menu_controller.mm", - "cocoa/app_menu/menu_tracked_button.h", - "cocoa/app_menu/menu_tracked_button.mm", - "cocoa/app_menu/menu_tracked_root_view.h", - "cocoa/app_menu/menu_tracked_root_view.mm", - "cocoa/app_menu/recent_tabs_menu_model_delegate.h", - "cocoa/app_menu/recent_tabs_menu_model_delegate.mm", - "cocoa/apps/chrome_app_window_client_views_cocoa.mm", - "cocoa/apps/native_app_window_cocoa.h", - "cocoa/apps/native_app_window_cocoa.mm", - "cocoa/autofill/autofill_bubble_controller.h", - "cocoa/autofill/autofill_bubble_controller.mm", - "cocoa/autofill/autofill_dialog_constants.h", - "cocoa/autofill/autofill_popup_base_view_cocoa.h", - "cocoa/autofill/autofill_popup_base_view_cocoa.mm", - "cocoa/autofill/autofill_popup_view_bridge.h", - "cocoa/autofill/autofill_popup_view_bridge.mm", - "cocoa/autofill/autofill_popup_view_cocoa.h", - "cocoa/autofill/autofill_popup_view_cocoa.mm", - "cocoa/autofill/autofill_tooltip_controller.h", - "cocoa/autofill/autofill_tooltip_controller.mm", - "cocoa/autofill/save_card_bubble_view_views.h", - "cocoa/autofill/save_card_bubble_view_views.mm", - "cocoa/background_gradient_view.h", - "cocoa/background_gradient_view.mm", - "cocoa/base_bubble_controller.h", - "cocoa/base_bubble_controller.mm", - "cocoa/bookmarks/bookmark_bar_bridge.h", - "cocoa/bookmarks/bookmark_bar_bridge.mm", - "cocoa/bookmarks/bookmark_bar_constants.h", - "cocoa/bookmarks/bookmark_bar_controller.h", - "cocoa/bookmarks/bookmark_bar_controller.mm", - "cocoa/bookmarks/bookmark_bar_folder_button_cell.h", - "cocoa/bookmarks/bookmark_bar_folder_button_cell.mm", - "cocoa/bookmarks/bookmark_bar_folder_controller.h", - "cocoa/bookmarks/bookmark_bar_folder_controller.mm", - "cocoa/bookmarks/bookmark_bar_folder_hover_state.h", - "cocoa/bookmarks/bookmark_bar_folder_hover_state.mm", - "cocoa/bookmarks/bookmark_bar_folder_view.h", - "cocoa/bookmarks/bookmark_bar_folder_view.mm", - "cocoa/bookmarks/bookmark_bar_folder_window.h", - "cocoa/bookmarks/bookmark_bar_folder_window.mm", - "cocoa/bookmarks/bookmark_bar_state.h", - "cocoa/bookmarks/bookmark_bar_toolbar_view.h", - "cocoa/bookmarks/bookmark_bar_toolbar_view.mm", - "cocoa/bookmarks/bookmark_bar_view_cocoa.h", - "cocoa/bookmarks/bookmark_bar_view_cocoa.mm", - "cocoa/bookmarks/bookmark_bubble_observer_cocoa.h", - "cocoa/bookmarks/bookmark_bubble_observer_cocoa.mm", - "cocoa/bookmarks/bookmark_bar_util.h", - "cocoa/bookmarks/bookmark_bar_util.mm", - "cocoa/bookmarks/bookmark_button.h", - "cocoa/bookmarks/bookmark_button.mm", - "cocoa/bookmarks/bookmark_button_cell.h", - "cocoa/bookmarks/bookmark_button_cell.mm", - "cocoa/bookmarks/bookmark_context_menu_cocoa_controller.h", - "cocoa/bookmarks/bookmark_context_menu_cocoa_controller.mm", - "cocoa/bookmarks/bookmark_drag_drop_cocoa.mm", - "cocoa/bookmarks/bookmark_folder_target.h", - "cocoa/bookmarks/bookmark_folder_target.mm", - "cocoa/bookmarks/bookmark_model_observer_for_cocoa.h", - "cocoa/bookmarks/bookmark_model_observer_for_cocoa.mm", - "cocoa/bookmarks/bookmark_tree_browser_cell.h", - "cocoa/bookmarks/bookmark_tree_browser_cell.mm", - "cocoa/browser/exclusive_access_controller_views.h", - "cocoa/browser/exclusive_access_controller_views.mm", - "cocoa/browser/zoom_bubble_controller.h", - "cocoa/browser/zoom_bubble_controller.mm", - "cocoa/browser_dialogs_views_mac.cc", - "cocoa/browser_dialogs_views_mac.h", - "cocoa/browser_window_cocoa.h", - "cocoa/browser_window_cocoa.mm", - "cocoa/browser_window_cocoa_views_mac.mm", - "cocoa/browser_window_controller.h", - "cocoa/browser_window_controller.mm", - "cocoa/browser_window_controller_private.h", - "cocoa/browser_window_controller_private.mm", - "cocoa/browser_window_factory_cocoa.mm", - "cocoa/browser_window_fullscreen_transition.h", - "cocoa/browser_window_fullscreen_transition.mm", - "cocoa/browser_window_layout.h", - "cocoa/browser_window_layout.mm", - "cocoa/browser_window_utils.h", - "cocoa/browser_window_utils.mm", - "cocoa/bubble_anchor_helper.h", - "cocoa/bubble_anchor_helper.mm", - "cocoa/bubble_anchor_helper_views.h", - "cocoa/bubble_anchor_helper_views.mm", - "cocoa/bubble_anchor_util_views_mac.mm", - "cocoa/bubble_combobox.h", - "cocoa/bubble_combobox.mm", - "cocoa/bubble_view.h", - "cocoa/bubble_view.mm", - "cocoa/certificate_viewer_mac_cocoa.h", - "cocoa/certificate_viewer_mac_cocoa.mm", - "cocoa/chrome_browser_window.h", - "cocoa/chrome_browser_window.mm", - "cocoa/chrome_event_processing_window.h", - "cocoa/chrome_event_processing_window.mm", - "cocoa/clickhold_button_cell.h", - "cocoa/clickhold_button_cell.mm", - "cocoa/cocoa_util.h", - "cocoa/cocoa_util.mm", - "cocoa/constrained_web_dialog_delegate_mac.mm", - "cocoa/constrained_window/constrained_window_alert.h", - "cocoa/constrained_window/constrained_window_alert.mm", - "cocoa/constrained_window/constrained_window_button.h", - "cocoa/constrained_window/constrained_window_button.mm", - "cocoa/constrained_window/constrained_window_control_utils.h", - "cocoa/constrained_window/constrained_window_control_utils.mm", - "cocoa/constrained_window/constrained_window_custom_sheet.h", - "cocoa/constrained_window/constrained_window_custom_sheet.mm", - "cocoa/constrained_window/constrained_window_custom_window.h", - "cocoa/constrained_window/constrained_window_custom_window.mm", - "cocoa/constrained_window/constrained_window_mac.h", - "cocoa/constrained_window/constrained_window_mac.mm", - "cocoa/constrained_window/constrained_window_sheet.h", - "cocoa/constrained_window/constrained_window_sheet_controller.h", - "cocoa/constrained_window/constrained_window_sheet_controller.mm", - "cocoa/constrained_window/constrained_window_sheet_info.h", - "cocoa/constrained_window/constrained_window_sheet_info.mm", - "cocoa/constrained_window/constrained_window_web_dialog_sheet.h", - "cocoa/constrained_window/constrained_window_web_dialog_sheet.mm", - "cocoa/create_native_web_modal_manager_cocoa.mm", - "cocoa/dev_tools_controller.h", - "cocoa/dev_tools_controller.mm", - "cocoa/device_chooser_content_view_cocoa.h", - "cocoa/device_chooser_content_view_cocoa.mm", - "cocoa/download/background_theme.h", - "cocoa/download/background_theme.mm", - "cocoa/download/download_item_button.h", - "cocoa/download/download_item_button.mm", - "cocoa/download/download_item_cell.h", - "cocoa/download/download_item_cell.mm", - "cocoa/download/download_item_controller.h", - "cocoa/download/download_item_controller.mm", - "cocoa/download/download_item_mac.h", - "cocoa/download/download_item_mac.mm", - "cocoa/download/download_item_view_protocol.h", - "cocoa/download/download_shelf_context_menu_controller.h", - "cocoa/download/download_shelf_context_menu_controller.mm", - "cocoa/download/download_shelf_controller.h", - "cocoa/download/download_shelf_controller.mm", - "cocoa/download/download_shelf_mac.h", - "cocoa/download/download_shelf_mac.mm", - "cocoa/download/download_shelf_view_cocoa.h", - "cocoa/download/download_shelf_view_cocoa.mm", - "cocoa/download/download_show_all_button.h", - "cocoa/download/download_show_all_button.mm", - "cocoa/download/download_show_all_cell.h", - "cocoa/download/download_show_all_cell.mm", - "cocoa/download/download_started_animation_mac.mm", - "cocoa/download/md_download_item_progress_indicator.h", - "cocoa/download/md_download_item_progress_indicator.mm", - "cocoa/download/md_download_item_view.h", - "cocoa/download/md_download_item_view.mm", - "cocoa/download/md_download_item_view_testing.h", - "cocoa/drag_util.h", - "cocoa/drag_util.mm", - "cocoa/draggable_button.h", - "cocoa/draggable_button.mm", - "cocoa/draggable_button_mixin.h", - "cocoa/draggable_button_mixin.mm", - "cocoa/extensions/browser_action_button.h", - "cocoa/extensions/browser_action_button.mm", - "cocoa/extensions/browser_actions_container_view.h", - "cocoa/extensions/browser_actions_container_view.mm", - "cocoa/extensions/browser_actions_controller.h", - "cocoa/extensions/browser_actions_controller.mm", - "cocoa/extensions/extension_action_platform_delegate_cocoa.h", - "cocoa/extensions/extension_action_platform_delegate_cocoa.mm", - "cocoa/extensions/extension_keybinding_registry_cocoa.h", - "cocoa/extensions/extension_keybinding_registry_cocoa.mm", - "cocoa/extensions/extension_popup_views_mac.h", - "cocoa/extensions/extension_popup_views_mac.mm", - "cocoa/extensions/media_galleries_dialog_cocoa.h", - "cocoa/extensions/media_galleries_dialog_cocoa.mm", - "cocoa/extensions/media_gallery_list_entry_view.h", - "cocoa/extensions/media_gallery_list_entry_view.mm", - "cocoa/extensions/toolbar_actions_bar_bubble_mac.h", - "cocoa/extensions/toolbar_actions_bar_bubble_mac.mm", - "cocoa/extensions/toolbar_actions_bar_bubble_views_presenter.h", - "cocoa/extensions/toolbar_actions_bar_bubble_views_presenter.mm", - "cocoa/fast_resize_view.h", - "cocoa/fast_resize_view.mm", - "cocoa/find_bar/find_bar_bridge.h", - "cocoa/find_bar/find_bar_bridge.mm", - "cocoa/find_bar/find_bar_cocoa_controller.h", - "cocoa/find_bar/find_bar_cocoa_controller.mm", - "cocoa/find_bar/find_bar_text_field.h", - "cocoa/find_bar/find_bar_text_field.mm", - "cocoa/find_bar/find_bar_text_field_cell.h", - "cocoa/find_bar/find_bar_text_field_cell.mm", - "cocoa/find_bar/find_bar_view_cocoa.h", - "cocoa/find_bar/find_bar_view_cocoa.mm", - "cocoa/floating_bar_backing_view.h", - "cocoa/floating_bar_backing_view.mm", - "cocoa/framed_browser_window.h", - "cocoa/framed_browser_window.mm", - "cocoa/fullscreen/fullscreen_menubar_tracker.h", - "cocoa/fullscreen/fullscreen_menubar_tracker.mm", - "cocoa/fullscreen/fullscreen_toolbar_animation_controller.h", - "cocoa/fullscreen/fullscreen_toolbar_animation_controller.mm", - "cocoa/fullscreen/fullscreen_toolbar_controller.h", - "cocoa/fullscreen/fullscreen_toolbar_controller.mm", - "cocoa/fullscreen/fullscreen_toolbar_controller_cocoa.h", - "cocoa/fullscreen/fullscreen_toolbar_controller_cocoa.mm", - "cocoa/fullscreen/fullscreen_toolbar_controller_views.h", - "cocoa/fullscreen/fullscreen_toolbar_controller_views.mm", - "cocoa/fullscreen/fullscreen_toolbar_mouse_tracker.h", - "cocoa/fullscreen/fullscreen_toolbar_mouse_tracker.mm", - "cocoa/fullscreen/fullscreen_toolbar_visibility_lock_controller.h", - "cocoa/fullscreen/fullscreen_toolbar_visibility_lock_controller.mm", - "cocoa/fullscreen/immersive_fullscreen_controller.h", - "cocoa/fullscreen/immersive_fullscreen_controller.mm", - "cocoa/fullscreen_placeholder_view.h", - "cocoa/fullscreen_placeholder_view.mm", - "cocoa/fullscreen_window.h", - "cocoa/fullscreen_window.mm", - "cocoa/gradient_button_cell.h", - "cocoa/gradient_button_cell.mm", - "cocoa/harmony_button.h", - "cocoa/harmony_button.mm", - "cocoa/has_weak_browser_pointer.h", - "cocoa/hover_close_button.h", - "cocoa/hover_close_button.mm", - "cocoa/hung_renderer_controller.h", - "cocoa/hung_renderer_controller.mm", - "cocoa/image_button_cell.h", - "cocoa/image_button_cell.mm", - "cocoa/importer/import_lock_dialog_cocoa.mm", - "cocoa/info_bubble_view.h", - "cocoa/info_bubble_view.mm", - "cocoa/info_bubble_window.h", - "cocoa/info_bubble_window.mm", - "cocoa/infobars/after_translate_infobar_controller.h", - "cocoa/infobars/after_translate_infobar_controller.mm", - "cocoa/infobars/alternate_nav_infobar_controller.h", - "cocoa/infobars/alternate_nav_infobar_controller.mm", - "cocoa/infobars/before_translate_infobar_controller.h", - "cocoa/infobars/before_translate_infobar_controller.mm", - "cocoa/infobars/confirm_infobar_controller.h", - "cocoa/infobars/confirm_infobar_controller.mm", - "cocoa/infobars/infobar_background_view.h", - "cocoa/infobars/infobar_background_view.mm", - "cocoa/infobars/infobar_cocoa.h", - "cocoa/infobars/infobar_cocoa.mm", - "cocoa/infobars/infobar_container_cocoa.h", - "cocoa/infobars/infobar_container_cocoa.mm", - "cocoa/infobars/infobar_container_controller.h", - "cocoa/infobars/infobar_container_controller.mm", - "cocoa/infobars/infobar_controller.h", - "cocoa/infobars/infobar_controller.mm", - "cocoa/infobars/infobar_utilities.h", - "cocoa/infobars/infobar_utilities.mm", - "cocoa/infobars/translate_infobar_base.h", - "cocoa/infobars/translate_infobar_base.mm", - "cocoa/infobars/translate_message_infobar_controller.h", - "cocoa/infobars/translate_message_infobar_controller.mm", - "cocoa/javascript_app_modal_dialog_cocoa.h", - "cocoa/javascript_app_modal_dialog_cocoa.mm", - "cocoa/location_bar/autocomplete_text_field.h", - "cocoa/location_bar/autocomplete_text_field.mm", - "cocoa/location_bar/autocomplete_text_field_cell.h", - "cocoa/location_bar/autocomplete_text_field_cell.mm", - "cocoa/location_bar/autocomplete_text_field_editor.h", - "cocoa/location_bar/autocomplete_text_field_editor.mm", - "cocoa/location_bar/bubble_decoration.h", - "cocoa/location_bar/bubble_decoration.mm", - "cocoa/location_bar/content_setting_decoration.h", - "cocoa/location_bar/content_setting_decoration.mm", - "cocoa/location_bar/image_decoration.h", - "cocoa/location_bar/image_decoration.mm", - "cocoa/location_bar/keyword_hint_decoration.h", - "cocoa/location_bar/keyword_hint_decoration.mm", - "cocoa/location_bar/location_bar_decoration.h", - "cocoa/location_bar/location_bar_decoration.mm", - "cocoa/location_bar/location_bar_view_mac.h", - "cocoa/location_bar/location_bar_view_mac.mm", - "cocoa/location_bar/manage_passwords_decoration.h", - "cocoa/location_bar/manage_passwords_decoration.mm", - "cocoa/location_bar/page_info_bubble_decoration.h", - "cocoa/location_bar/page_info_bubble_decoration.mm", - "cocoa/location_bar/save_credit_card_decoration.h", - "cocoa/location_bar/save_credit_card_decoration.mm", - "cocoa/location_bar/selected_keyword_decoration.h", - "cocoa/location_bar/selected_keyword_decoration.mm", - "cocoa/location_bar/star_decoration.h", - "cocoa/location_bar/star_decoration.mm", - "cocoa/location_bar/translate_decoration.h", - "cocoa/location_bar/translate_decoration.mm", - "cocoa/location_bar/zoom_decoration.h", - "cocoa/location_bar/zoom_decoration.mm", - "cocoa/login_handler_cocoa.h", - "cocoa/login_handler_cocoa.mm", - "cocoa/main_menu_item.h", - "cocoa/menu_button.h", - "cocoa/menu_button.mm", - "cocoa/multi_key_equivalent_button.h", - "cocoa/multi_key_equivalent_button.mm", - "cocoa/new_tab_button.h", - "cocoa/new_tab_button_cocoa.mm", - "cocoa/nsview_additions.h", - "cocoa/nsview_additions.mm", - "cocoa/omnibox/omnibox_popup_cell.h", - "cocoa/omnibox/omnibox_popup_cell.mm", - "cocoa/omnibox/omnibox_popup_matrix.h", - "cocoa/omnibox/omnibox_popup_matrix.mm", - "cocoa/omnibox/omnibox_popup_separator_view.h", - "cocoa/omnibox/omnibox_popup_separator_view.mm", - "cocoa/omnibox/omnibox_popup_view_mac.h", - "cocoa/omnibox/omnibox_popup_view_mac.mm", - "cocoa/omnibox/omnibox_view_mac.h", - "cocoa/omnibox/omnibox_view_mac.mm", - "cocoa/omnibox_decoration_bubble_controller.h", - "cocoa/omnibox_decoration_bubble_controller.mm", - "cocoa/one_click_signin_dialog_controller.h", - "cocoa/one_click_signin_dialog_controller.mm", - "cocoa/one_click_signin_view_controller.h", - "cocoa/one_click_signin_view_controller.mm", - "cocoa/permission_bubble/chooser_bubble_ui_cocoa.h", - "cocoa/permission_bubble/chooser_bubble_ui_cocoa.mm", - "cocoa/permission_bubble/chooser_bubble_ui_views_mac.mm", - "cocoa/permission_bubble/permission_prompt_impl_views_mac.mm", - "cocoa/profiles/avatar_base_controller.h", - "cocoa/profiles/avatar_base_controller.mm", - "cocoa/profiles/avatar_button.h", - "cocoa/profiles/avatar_button_cocoa.mm", - "cocoa/profiles/avatar_button_controller.h", - "cocoa/profiles/avatar_button_controller.mm", - "cocoa/profiles/avatar_icon_controller.h", - "cocoa/profiles/avatar_icon_controller.mm", - "cocoa/profiles/profile_chooser_bridge_views.h", - "cocoa/profiles/profile_chooser_bridge_views.mm", - "cocoa/profiles/profile_signin_confirmation_dialog_cocoa.h", - "cocoa/profiles/profile_signin_confirmation_dialog_cocoa.mm", - "cocoa/profiles/profile_signin_confirmation_view_controller.h", - "cocoa/profiles/profile_signin_confirmation_view_controller.mm", - "cocoa/profiles/signin_view_controller_delegate_mac.h", - "cocoa/profiles/signin_view_controller_delegate_mac.mm", - "cocoa/profiles/user_manager_mac.h", - "cocoa/profiles/user_manager_mac.mm", - "cocoa/rect_path_utils.h", - "cocoa/rect_path_utils.mm", - "cocoa/restart_browser.h", - "cocoa/restart_browser.mm", - "cocoa/screen_capture_notification_ui_cocoa.h", - "cocoa/screen_capture_notification_ui_cocoa.mm", - "cocoa/separate_fullscreen_window.h", - "cocoa/separate_fullscreen_window.mm", - "cocoa/simple_message_box_bridge_views.mm", - "cocoa/simple_message_box_cocoa.h", - "cocoa/simple_message_box_cocoa.mm", - "cocoa/single_web_contents_dialog_manager_cocoa.h", - "cocoa/single_web_contents_dialog_manager_cocoa.mm", - "cocoa/spinner_view.h", - "cocoa/spinner_view.mm", - "cocoa/ssl_client_certificate_selector_cocoa.h", - "cocoa/ssl_client_certificate_selector_cocoa.mm", - "cocoa/spinner_util.h", - "cocoa/status_bubble_mac.h", - "cocoa/status_bubble_mac.mm", - "cocoa/styled_text_field.h", - "cocoa/styled_text_field.mm", - "cocoa/styled_text_field_cell.h", - "cocoa/styled_text_field_cell.mm", - "cocoa/tab_contents/favicon_util_mac.h", - "cocoa/tab_contents/favicon_util_mac.mm", - "cocoa/tab_contents/overlayable_contents_controller.h", - "cocoa/tab_contents/overlayable_contents_controller.mm", - "cocoa/tab_contents/sad_tab_mac.mm", - "cocoa/tab_contents/sad_tab_view_cocoa.h", - "cocoa/tab_contents/sad_tab_view_cocoa.mm", - "cocoa/tab_contents/tab_contents_controller.h", - "cocoa/tab_contents/tab_contents_controller.mm", - "cocoa/tab_dialogs_cocoa.h", - "cocoa/tab_dialogs_cocoa.mm", - "cocoa/tab_dialogs_views_mac.h", - "cocoa/tab_dialogs_views_mac.mm", - "cocoa/tab_modal_confirm_dialog_mac.h", - "cocoa/tab_modal_confirm_dialog_mac.mm", - "cocoa/tabbed_browser_window.h", - "cocoa/tabbed_browser_window.mm", - "cocoa/tabs/alert_indicator_button_cocoa.h", - "cocoa/tabs/alert_indicator_button_cocoa.mm", - "cocoa/tabs/tab_controller.h", - "cocoa/tabs/tab_controller.mm", - "cocoa/tabs/tab_controller_target.h", - "cocoa/tabs/tab_favicon_view.h", - "cocoa/tabs/tab_favicon_view.mm", - "cocoa/tabs/tab_spinner_view.h", - "cocoa/tabs/tab_spinner_view.mm", - "cocoa/tabs/tab_strip_background_view.h", - "cocoa/tabs/tab_strip_background_view.mm", - "cocoa/tabs/tab_strip_controller.h", - "cocoa/tabs/tab_strip_controller.mm", - "cocoa/tabs/tab_strip_drag_controller.h", - "cocoa/tabs/tab_strip_drag_controller.mm", - "cocoa/tabs/tab_strip_model_observer_bridge.h", - "cocoa/tabs/tab_strip_model_observer_bridge.mm", - "cocoa/tabs/tab_strip_view.h", - "cocoa/tabs/tab_strip_view.mm", - "cocoa/tabs/tab_view.h", - "cocoa/tabs/tab_view.mm", - "cocoa/tabs/tab_window_controller.h", - "cocoa/tabs/tab_window_controller.mm", - "cocoa/themed_window.h", - "cocoa/themed_window.mm", - "cocoa/toolbar/app_toolbar_button.h", - "cocoa/toolbar/app_toolbar_button.mm", - "cocoa/toolbar/app_toolbar_button_cell.h", - "cocoa/toolbar/app_toolbar_button_cell.mm", - "cocoa/toolbar/back_forward_menu_controller.h", - "cocoa/toolbar/back_forward_menu_controller.mm", - "cocoa/toolbar/media_router_action_platform_delegate_cocoa.h", - "cocoa/toolbar/media_router_action_platform_delegate_cocoa.mm", - "cocoa/toolbar/reload_button_cocoa.h", - "cocoa/toolbar/reload_button_cocoa.mm", - "cocoa/toolbar/toolbar_button_cocoa.h", - "cocoa/toolbar/toolbar_button_cocoa.mm", - "cocoa/toolbar/toolbar_controller.h", - "cocoa/toolbar/toolbar_controller.mm", - "cocoa/toolbar/toolbar_view_cocoa.h", - "cocoa/toolbar/toolbar_view_cocoa.mm", - "cocoa/touchbar/credit_card_autofill_touch_bar_controller.h", - "cocoa/touchbar/credit_card_autofill_touch_bar_controller.mm", - "cocoa/touchbar/text_suggestions_touch_bar_controller.h", - "cocoa/touchbar/text_suggestions_touch_bar_controller.mm", - "cocoa/touchbar/web_textfield_touch_bar_controller.h", - "cocoa/touchbar/web_textfield_touch_bar_controller.mm", - "cocoa/translate/translate_bubble_bridge_views.h", - "cocoa/translate/translate_bubble_bridge_views.mm", - "cocoa/url_drop_target.h", - "cocoa/url_drop_target.mm", - "cocoa/view_id_util.h", - "cocoa/view_id_util.mm", - "cocoa/view_resizer.h", - "cocoa/web_contents_modal_dialog_manager_views_mac.h", - "cocoa/web_contents_modal_dialog_manager_views_mac.mm", - - # TODO(estade): this class should be deleted in favor of a combobox model. - # See crbug.com/590850 - "content_settings/content_setting_media_menu_model.cc", - "content_settings/content_setting_media_menu_model.h", - "proximity_auth/proximity_auth_error_bubble_stub.cc", - "startup/session_crashed_infobar_delegate.cc", - "startup/session_crashed_infobar_delegate.h", - ] - } - sources = [ "accelerator_utils.h", "app_list/app_list_util.cc", @@ -595,6 +133,8 @@ jumbo_split_static_library("ui") { "login/login_interstitial_delegate.h", "navigation_correction_tab_observer.cc", "navigation_correction_tab_observer.h", + "omnibox/query_in_omnibox_factory.cc", + "omnibox/query_in_omnibox_factory.h", "page_info/page_info.cc", "page_info/page_info.h", "page_info/page_info_ui.cc", @@ -875,7 +415,8 @@ jumbo_split_static_library("ui") { "//components/encrypted_messages:encrypted_message_proto", "//components/favicon/content", "//components/favicon/core", - "//components/feature_engagement:buildflags", + "//components/feature_engagement", + "//components/feed:feature_list", "//components/feedback", "//components/flags_ui", "//components/gcm_driver", @@ -900,7 +441,6 @@ jumbo_split_static_library("ui") { "//components/onc", "//components/password_manager/content/browser", "//components/password_manager/core/browser", - "//components/password_manager/sync/browser", "//components/payments/content:utils", "//components/pdf/browser", "//components/policy/core/browser", @@ -1105,6 +645,8 @@ jumbo_split_static_library("ui") { "android/infobars/permission_infobar.h", "android/infobars/previews_infobar.cc", "android/infobars/previews_infobar.h", + "android/infobars/previews_lite_page_infobar.cc", + "android/infobars/previews_lite_page_infobar.h", "android/infobars/reader_mode_infobar.cc", "android/infobars/reader_mode_infobar.h", "android/infobars/save_password_infobar.cc", @@ -1313,6 +855,12 @@ jumbo_split_static_library("ui") { "global_error/global_error_service.h", "global_error/global_error_service_factory.cc", "global_error/global_error_service_factory.h", + "hats/hats_helper.cc", + "hats/hats_helper.h", + "hats/hats_service.cc", + "hats/hats_service.h", + "hats/hats_service_factory.cc", + "hats/hats_service_factory.h", "hung_renderer/hung_renderer_core.cc", "hung_renderer/hung_renderer_core.h", "javascript_dialogs/javascript_dialog_views.cc", @@ -1347,7 +895,6 @@ jumbo_split_static_library("ui") { "media_router/presentation_receiver_window_controller.cc", "media_router/presentation_receiver_window_controller.h", "media_router/presentation_receiver_window_delegate.h", - "media_router/presentation_receiver_window_factory_mac.cc", "media_router/query_result_manager.cc", "media_router/query_result_manager.h", "media_router/ui_media_sink.cc", @@ -1488,7 +1035,6 @@ jumbo_split_static_library("ui") { "toolbar/media_router_action.h", "toolbar/media_router_action_controller.cc", "toolbar/media_router_action_controller.h", - "toolbar/media_router_action_platform_delegate.h", "toolbar/media_router_contextual_menu.cc", "toolbar/media_router_contextual_menu.h", "toolbar/recent_tabs_sub_menu_model.cc", @@ -1529,6 +1075,10 @@ jumbo_split_static_library("ui") { "webui/identity_internals_ui.h", "webui/inspect_ui.cc", "webui/inspect_ui.h", + "webui/management_ui.cc", + "webui/management_ui.h", + "webui/management_ui_handler.cc", + "webui/management_ui_handler.h", "webui/md_bookmarks/bookmarks_message_handler.cc", "webui/md_bookmarks/bookmarks_message_handler.h", "webui/md_bookmarks/md_bookmarks_ui.cc", @@ -1747,12 +1297,14 @@ jumbo_split_static_library("ui") { "ash/ash_shell_init.h", "ash/ash_util.cc", "ash/ash_util.h", - "ash/browser_image_registrar.cc", - "ash/browser_image_registrar.h", "ash/cast_config_client_media_router.cc", "ash/cast_config_client_media_router.h", + "ash/chrome_accessibility_delegate.cc", + "ash/chrome_accessibility_delegate.h", "ash/chrome_browser_main_extra_parts_ash.cc", "ash/chrome_browser_main_extra_parts_ash.h", + "ash/chrome_keyboard_controller_client.cc", + "ash/chrome_keyboard_controller_client.h", "ash/chrome_keyboard_ui.cc", "ash/chrome_keyboard_ui.h", "ash/chrome_keyboard_web_contents.cc", @@ -1768,8 +1320,6 @@ jumbo_split_static_library("ui") { "ash/chrome_shell_delegate.h", "ash/ime_controller_client.cc", "ash/ime_controller_client.h", - "ash/keyboard_ui_service.cc", - "ash/keyboard_ui_service.h", "ash/ksv/keyboard_shortcut_viewer_util.cc", "ash/ksv/keyboard_shortcut_viewer_util.h", "ash/launcher/app_shortcut_launcher_item_controller.cc", @@ -1880,6 +1430,8 @@ jumbo_split_static_library("ui") { "views/extensions/request_file_system_dialog_view.h", "views/frame/browser_frame_ash.cc", "views/frame/browser_frame_ash.h", + "views/frame/browser_frame_header_ash.cc", + "views/frame/browser_frame_header_ash.h", "views/frame/browser_frame_mash.cc", "views/frame/browser_frame_mash.h", "views/frame/browser_non_client_frame_view_ash.cc", @@ -1893,6 +1445,8 @@ jumbo_split_static_library("ui") { "views/frame/immersive_mode_controller_ash.cc", "views/frame/immersive_mode_controller_ash.h", "views/frame/native_browser_frame_factory_chromeos.cc", + "views/frame/top_controls_slide_controller_chromeos.cc", + "views/frame/top_controls_slide_controller_chromeos.h", "views/ime_driver/input_method_bridge_chromeos.cc", "views/ime_driver/input_method_bridge_chromeos.h", "views/intent_picker_bubble_view.cc", @@ -1901,26 +1455,18 @@ jumbo_split_static_library("ui") { "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", + "views/profiles/profile_indicator_icon.h", # On chromeos, file manager extension handles the file open/save dialog. "views/select_file_dialog_extension.cc", "views/select_file_dialog_extension.h", "views/select_file_dialog_extension_factory.cc", "views/select_file_dialog_extension_factory.h", - "webui/chromeos/assistant_optin/assistant_optin_handler.cc", - "webui/chromeos/assistant_optin/assistant_optin_handler.h", "webui/chromeos/assistant_optin/assistant_optin_ui.cc", "webui/chromeos/assistant_optin/assistant_optin_ui.h", "webui/chromeos/assistant_optin/assistant_optin_utils.cc", "webui/chromeos/assistant_optin/assistant_optin_utils.h", - "webui/chromeos/assistant_optin/get_more_screen_handler.cc", - "webui/chromeos/assistant_optin/get_more_screen_handler.h", - "webui/chromeos/assistant_optin/ready_screen_handler.cc", - "webui/chromeos/assistant_optin/ready_screen_handler.h", - "webui/chromeos/assistant_optin/third_party_screen_handler.cc", - "webui/chromeos/assistant_optin/third_party_screen_handler.h", - "webui/chromeos/assistant_optin/value_prop_screen_handler.cc", - "webui/chromeos/assistant_optin/value_prop_screen_handler.h", "webui/chromeos/bluetooth_dialog_localized_strings_provider.cc", "webui/chromeos/bluetooth_dialog_localized_strings_provider.h", "webui/chromeos/bluetooth_pairing_dialog.cc", @@ -1986,6 +1532,8 @@ jumbo_split_static_library("ui") { "webui/chromeos/login/discover/discover_window_manager_observer.h", "webui/chromeos/login/discover/modules/discover_module_launch_help_app.cc", "webui/chromeos/login/discover/modules/discover_module_launch_help_app.h", + "webui/chromeos/login/discover/modules/discover_module_pin_setup.cc", + "webui/chromeos/login/discover/modules/discover_module_pin_setup.h", "webui/chromeos/login/discover/modules/discover_module_redeem_offers.cc", "webui/chromeos/login/discover/modules/discover_module_redeem_offers.h", "webui/chromeos/login/discover/modules/discover_module_sync_files.cc", @@ -2022,6 +1570,8 @@ jumbo_split_static_library("ui") { "webui/chromeos/login/l10n_util.h", "webui/chromeos/login/marketing_opt_in_screen_handler.cc", "webui/chromeos/login/marketing_opt_in_screen_handler.h", + "webui/chromeos/login/multidevice_setup_screen_handler.cc", + "webui/chromeos/login/multidevice_setup_screen_handler.h", "webui/chromeos/login/native_window_delegate.h", "webui/chromeos/login/network_dropdown_handler.cc", "webui/chromeos/login/network_dropdown_handler.h", @@ -2043,8 +1593,6 @@ jumbo_split_static_library("ui") { "webui/chromeos/login/screenlock_icon_source.h", "webui/chromeos/login/signin_screen_handler.cc", "webui/chromeos/login/signin_screen_handler.h", - "webui/chromeos/login/supervised_user_creation_screen_handler.cc", - "webui/chromeos/login/supervised_user_creation_screen_handler.h", "webui/chromeos/login/sync_consent_screen_handler.cc", "webui/chromeos/login/sync_consent_screen_handler.h", "webui/chromeos/login/terms_of_service_screen_handler.cc", @@ -2073,6 +1621,8 @@ jumbo_split_static_library("ui") { "webui/chromeos/multidevice_setup/multidevice_setup_dialog.h", "webui/chromeos/multidevice_setup/multidevice_setup_handler.cc", "webui/chromeos/multidevice_setup/multidevice_setup_handler.h", + "webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc", + "webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h", "webui/chromeos/network_element_localized_strings_provider.cc", "webui/chromeos/network_element_localized_strings_provider.h", "webui/chromeos/network_ui.cc", @@ -2093,6 +1643,8 @@ jumbo_split_static_library("ui") { "webui/chromeos/system_web_dialog_delegate.h", "webui/chromeos/user_image_source.cc", "webui/chromeos/user_image_source.h", + "webui/chromeos/video_source.cc", + "webui/chromeos/video_source.h", "webui/extensions/chromeos/kiosk_apps_handler.cc", "webui/extensions/chromeos/kiosk_apps_handler.h", "webui/help/help_utils_chromeos.cc", @@ -2153,8 +1705,8 @@ jumbo_split_static_library("ui") { "//ash/public/cpp", "//ash/public/cpp/resources:ash_public_unscaled_resources", "//ash/public/cpp/vector_icons", - "//ash/strings", "//chrome/browser/chromeos", + "//chrome/browser/chromeos/android_sms:android_sms_urls", "//chromeos:cryptohome_proto", "//chromeos/components/proximity_auth", "//chromeos/components/proximity_auth/logging", @@ -2164,8 +1716,10 @@ jumbo_split_static_library("ui") { "//chromeos/services/assistant/public/mojom", "//chromeos/services/assistant/public/proto:proto", "//chromeos/services/multidevice_setup/public/cpp:cpp", + "//chromeos/services/multidevice_setup/public/cpp:prefs", "//chromeos/services/multidevice_setup/public/cpp:url_provider", "//chromeos/services/multidevice_setup/public/mojom", + "//chromeos/strings", "//components/arc", "//components/captive_portal", "//components/consent_auditor:consent_auditor", @@ -2205,10 +1759,16 @@ jumbo_split_static_library("ui") { if (is_win || is_mac || is_desktop_linux || is_chromeos) { sources += [ + "frame/window_frame_util.cc", + "frame/window_frame_util.h", "signin_view_controller.cc", "signin_view_controller.h", "signin_view_controller_delegate.cc", "signin_view_controller_delegate.h", + "views/close_bubble_on_tab_activation_helper.cc", + "views/close_bubble_on_tab_activation_helper.h", + "views/hats/hats_bubble_view.cc", + "views/hats/hats_bubble_view.h", "webui/discards/discards_ui.cc", "webui/discards/discards_ui.h", "webui/signin/inline_login_handler.cc", @@ -2239,8 +1799,6 @@ jumbo_split_static_library("ui") { "sync/one_click_signin_sync_starter.h", "user_manager.cc", "user_manager.h", - "views/close_bubble_on_tab_activation_helper.cc", - "views/close_bubble_on_tab_activation_helper.h", "views/external_protocol_dialog.cc", "views/external_protocol_dialog.h", "views/profiles/badged_profile_photo.cc", @@ -2249,6 +1807,8 @@ 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/user_manager_view.cc", + "views/profiles/user_manager_view.h", "webui/app_launcher_page_ui.cc", "webui/app_launcher_page_ui.h", "webui/profile_helper.cc", @@ -2283,18 +1843,29 @@ 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/welcome_handler.cc", - "webui/welcome_handler.h", - "webui/welcome_ui.cc", - "webui/welcome_ui.h", + + # TODO(scottchen): nux/set_as_default_handler is here because it depends + # on settings_default_browser_handler, but that deps currently can't + # be added in nux/BUILD.gn due to circular dependency. + # Should move back to nux/BUILD.gn once settings's build config is in + # a shareable location (e.g. ui/webui/settings/BUILD.gn). + "webui/welcome/nux/set_as_default_handler.cc", + "webui/welcome/nux/set_as_default_handler.h", + "webui/welcome/nux_helper.cc", + "webui/welcome/nux_helper.h", + "webui/welcome/welcome_handler.cc", + "webui/welcome/welcome_handler.h", + "webui/welcome/welcome_ui.cc", + "webui/welcome/welcome_ui.h", ] - if (!is_mac || mac_views_browser) { - sources += [ - "views/profiles/avatar_button.cc", - "views/profiles/avatar_button.h", - "views/profiles/user_manager_view.cc", - "views/profiles/user_manager_view.h", + # TODO(scottchen): Remove if-check once nux files are non-exclusive + # to windows. + if (is_win && is_chrome_branded) { + deps += [ + "//chrome/browser/ui/webui/welcome/nux:constants", + "//chrome/browser/ui/webui/welcome/nux:email_feature", + "//chrome/browser/ui/webui/welcome/nux:google_apps_feature", ] } @@ -2341,13 +1912,6 @@ jumbo_split_static_library("ui") { } } - if (is_mac || is_win || (is_linux && !is_chromeos)) { - sources += [ - "confirm_quit.cc", - "confirm_quit.h", - ] - } - if (is_mac) { sources += [ "browser_commands_mac.cc", @@ -2359,8 +1923,6 @@ jumbo_split_static_library("ui") { "cocoa/accelerator_utils_cocoa.mm", "cocoa/accelerators_cocoa.h", "cocoa/accelerators_cocoa.mm", - "cocoa/animated_icon.h", - "cocoa/animated_icon.mm", "cocoa/applescript/apple_event_util.h", "cocoa/applescript/apple_event_util.mm", "cocoa/applescript/bookmark_folder_applescript.h", @@ -2395,21 +1957,51 @@ jumbo_split_static_library("ui") { "cocoa/bookmarks/bookmark_menu_cocoa_controller.mm", "cocoa/browser_window_command_handler.h", "cocoa/browser_window_command_handler.mm", - "cocoa/browser_window_views_mac.h", + "cocoa/certificate_viewer_mac_cocoa.h", + "cocoa/certificate_viewer_mac_cocoa.mm", "cocoa/chrome_command_dispatcher_delegate.h", "cocoa/chrome_command_dispatcher_delegate.mm", - "cocoa/chrome_style.cc", - "cocoa/chrome_style.h", "cocoa/color_chooser_mac.h", "cocoa/color_chooser_mac.mm", + "cocoa/confirm_quit.cc", + "cocoa/confirm_quit.h", "cocoa/confirm_quit_panel_controller.h", "cocoa/confirm_quit_panel_controller.mm", + "cocoa/constrained_window/constrained_window_control_utils.h", + "cocoa/constrained_window/constrained_window_control_utils.mm", + "cocoa/constrained_window/constrained_window_custom_sheet.h", + "cocoa/constrained_window/constrained_window_custom_sheet.mm", + "cocoa/constrained_window/constrained_window_mac.h", + "cocoa/constrained_window/constrained_window_mac.mm", + "cocoa/constrained_window/constrained_window_sheet.h", + "cocoa/constrained_window/constrained_window_sheet_controller.h", + "cocoa/constrained_window/constrained_window_sheet_controller.mm", + "cocoa/constrained_window/constrained_window_sheet_info.h", + "cocoa/constrained_window/constrained_window_sheet_info.mm", + "cocoa/constrained_window/constrained_window_web_dialog_sheet.h", + "cocoa/constrained_window/constrained_window_web_dialog_sheet.mm", "cocoa/dock_icon.h", "cocoa/dock_icon.mm", + "cocoa/drag_util.h", + "cocoa/drag_util.mm", "cocoa/first_run_dialog.h", "cocoa/first_run_dialog.mm", "cocoa/first_run_dialog_controller.h", "cocoa/first_run_dialog_controller.mm", + "cocoa/fullscreen/fullscreen_menubar_tracker.h", + "cocoa/fullscreen/fullscreen_menubar_tracker.mm", + "cocoa/fullscreen/fullscreen_toolbar_animation_controller.h", + "cocoa/fullscreen/fullscreen_toolbar_animation_controller.mm", + "cocoa/fullscreen/fullscreen_toolbar_controller.h", + "cocoa/fullscreen/fullscreen_toolbar_controller.mm", + "cocoa/fullscreen/fullscreen_toolbar_controller_views.h", + "cocoa/fullscreen/fullscreen_toolbar_controller_views.mm", + "cocoa/fullscreen/fullscreen_toolbar_mouse_tracker.h", + "cocoa/fullscreen/fullscreen_toolbar_mouse_tracker.mm", + "cocoa/fullscreen/fullscreen_toolbar_visibility_lock_controller.h", + "cocoa/fullscreen/fullscreen_toolbar_visibility_lock_controller.mm", + "cocoa/fullscreen/immersive_fullscreen_controller.h", + "cocoa/fullscreen/immersive_fullscreen_controller.mm", "cocoa/handoff_active_url_observer.cc", "cocoa/handoff_active_url_observer.h", "cocoa/handoff_active_url_observer_bridge.h", @@ -2421,6 +2013,8 @@ jumbo_split_static_library("ui") { "cocoa/history_menu_cocoa_controller.mm", "cocoa/history_overlay_controller.h", "cocoa/history_overlay_controller.mm", + "cocoa/javascript_app_modal_dialog_cocoa.h", + "cocoa/javascript_app_modal_dialog_cocoa.mm", "cocoa/key_equivalent_constants.h", "cocoa/key_equivalent_constants.mm", "cocoa/keystone_infobar_delegate.h", @@ -2431,10 +2025,7 @@ jumbo_split_static_library("ui") { "cocoa/last_active_browser_cocoa.h", "cocoa/main_menu_builder.h", "cocoa/main_menu_builder.mm", - "cocoa/md_hover_button.h", - "cocoa/md_hover_button.mm", - "cocoa/md_util.h", - "cocoa/md_util.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", @@ -2457,10 +2048,18 @@ jumbo_split_static_library("ui") { "cocoa/renderer_context_menu/render_view_context_menu_mac_cocoa.mm", "cocoa/renderer_context_menu/render_view_context_menu_mac_views.h", "cocoa/renderer_context_menu/render_view_context_menu_mac_views.mm", + "cocoa/restart_browser.h", + "cocoa/restart_browser.mm", "cocoa/scoped_menu_bar_lock.h", "cocoa/scoped_menu_bar_lock.mm", "cocoa/share_menu_controller.h", "cocoa/share_menu_controller.mm", + "cocoa/simple_message_box_cocoa.h", + "cocoa/simple_message_box_cocoa.mm", + "cocoa/single_web_contents_dialog_manager_cocoa.h", + "cocoa/single_web_contents_dialog_manager_cocoa.mm", + "cocoa/ssl_client_certificate_selector_cocoa.h", + "cocoa/ssl_client_certificate_selector_cocoa.mm", "cocoa/status_icons/status_icon_mac.h", "cocoa/status_icons/status_icon_mac.mm", "cocoa/status_icons/status_tray_mac.h", @@ -2475,17 +2074,34 @@ jumbo_split_static_library("ui") { "cocoa/touchbar/browser_window_default_touch_bar.mm", "cocoa/touchbar/browser_window_touch_bar_controller.h", "cocoa/touchbar/browser_window_touch_bar_controller.mm", + "cocoa/touchbar/credit_card_autofill_touch_bar_controller.h", + "cocoa/touchbar/credit_card_autofill_touch_bar_controller.mm", + "cocoa/touchbar/text_suggestions_touch_bar_controller.h", + "cocoa/touchbar/text_suggestions_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/url_drop_target.h", + "cocoa/url_drop_target.mm", "cocoa/web_contents_modal_dialog_host_cocoa.h", "cocoa/web_contents_modal_dialog_host_cocoa.mm", "cocoa/window_size_autosaver.h", "cocoa/window_size_autosaver.mm", - - # TODO(estade): this class should be folded into - # manage_passwords_decoration.mm - "passwords/manage_passwords_icon.cc", - "passwords/manage_passwords_icon.h", + "views/apps/chrome_app_window_client_views_mac.mm", + "views/certificate_viewer_mac_views.mm", + "views/dropdown_bar_host_mac.mm", + "views/frame/browser_frame_mac.h", + "views/frame/browser_frame_mac.mm", + "views/frame/browser_native_widget_window_mac.h", + "views/frame/browser_native_widget_window_mac.mm", + "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/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", + "views/tabs/window_finder_mac.mm", "web_contents_sizer.mm", "webui/help/version_updater_mac.h", "webui/help/version_updater_mac.mm", @@ -2493,15 +2109,13 @@ jumbo_split_static_library("ui") { "window_sizer/window_sizer_mac.mm", ] - sources += cocoa_browser_sources - 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", - "//third_party/molokocacao", "//third_party/mozilla", "//ui/accelerated_widget_mac:accelerated_widget_mac", ] @@ -2510,41 +2124,6 @@ jumbo_split_static_library("ui") { "Carbon.framework", "Quartz.framework", ] - - if (mac_views_browser) { - # MacViews sources that we still want to keep behind a compile-time flag. - # TODO(jackhou): Move items to general views sources out of here. - sources += [ - "views/apps/chrome_app_window_client_views_mac.mm", - "views/certificate_viewer_mac_views.mm", - "views/dropdown_bar_host_mac.mm", - "views/frame/browser_frame_mac.h", - "views/frame/browser_frame_mac.mm", - "views/frame/browser_native_widget_window_mac.h", - "views/frame/browser_native_widget_window_mac.mm", - "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/native_browser_frame_factory_mac.mm", - "views/infobars/legacy_infobars_mac.cc", - "views/tab_contents/chrome_web_contents_view_delegate_views_mac.h", - "views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm", - "views/tabs/window_finder_mac.mm", - ] - - deps += [ "//extensions/components/native_app_window" ] - - # Truly cocoa-browser-specific sources. These are secondary UI pieces that - # are obsolete before mac_views_browser will ever ship, so they aren't - # linked in at all. - sources -= [ - "cocoa/constrained_web_dialog_delegate_mac.mm", - "cocoa/importer/import_lock_dialog_cocoa.mm", - "cocoa/login_handler_cocoa.h", - "cocoa/login_handler_cocoa.mm", - "cocoa/simple_message_box_bridge_views.mm", - ] - } } else { # non-Mac. sources += [ "web_contents_sizer.cc" ] } @@ -2621,10 +2200,10 @@ jumbo_split_static_library("ui") { "webui/settings/chrome_cleanup_handler.cc", "webui/settings/chrome_cleanup_handler.h", "webui/settings_utils_win.cc", - "webui/welcome_win10_handler.cc", - "webui/welcome_win10_handler.h", - "webui/welcome_win10_ui.cc", - "webui/welcome_win10_ui.h", + "webui/welcome/welcome_win10_handler.cc", + "webui/welcome/welcome_win10_handler.h", + "webui/welcome/welcome_win10_ui.cc", + "webui/welcome/welcome_win10_ui.h", ] public_deps += [ "//ui/views", @@ -2767,6 +2346,8 @@ jumbo_split_static_library("ui") { # This test header is included because it contains forward declarations # needed for "friend" statements for use in tests. "translate/translate_bubble_test_utils.h", + "views/accessibility/invert_bubble_view.cc", + "views/accessibility/invert_bubble_view.h", "views/accessibility/non_accessible_image_view.cc", "views/accessibility/non_accessible_image_view.h", "views/apps/app_info_dialog/app_info_dialog_container.cc", @@ -2797,10 +2378,14 @@ jumbo_split_static_library("ui") { "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_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", @@ -2809,31 +2394,48 @@ jumbo_split_static_library("ui") { "views/autofill/save_card_sign_in_promo_bubble_views.h", "views/autofill/view_util.cc", "views/autofill/view_util.h", + "views/bookmarks/bookmark_bar_instructions_view.cc", + "views/bookmarks/bookmark_bar_instructions_view.h", + "views/bookmarks/bookmark_bar_view.cc", + "views/bookmarks/bookmark_bar_view.h", + "views/bookmarks/bookmark_bar_view_observer.h", "views/bookmarks/bookmark_bubble_view.cc", "views/bookmarks/bookmark_bubble_view.h", + "views/bookmarks/bookmark_context_menu.cc", + "views/bookmarks/bookmark_context_menu.h", + "views/bookmarks/bookmark_drag_drop_views.cc", "views/bookmarks/bookmark_editor_view.cc", "views/bookmarks/bookmark_editor_view.h", + "views/bookmarks/bookmark_menu_controller_observer.h", + "views/bookmarks/bookmark_menu_controller_views.cc", + "views/bookmarks/bookmark_menu_controller_views.h", + "views/bookmarks/bookmark_menu_delegate.cc", + "views/bookmarks/bookmark_menu_delegate.h", + "views/browser_dialogs_views.cc", + "views/bubble_anchor_util_views.cc", "views/bubble_anchor_util_views.h", "views/bulleted_label_list_view.cc", "views/bulleted_label_list_view.h", + "views/certificate_selector.cc", + "views/certificate_selector.h", "views/chrome_browser_main_extra_parts_views.cc", "views/chrome_browser_main_extra_parts_views.h", "views/chrome_constrained_window_views_client.cc", "views/chrome_constrained_window_views_client.h", "views/chrome_layout_provider.cc", "views/chrome_layout_provider.h", - "views/chrome_platform_style.cc", - "views/chrome_platform_style.h", "views/chrome_typography.cc", "views/chrome_typography.h", "views/chrome_typography_provider.cc", "views/chrome_typography_provider.h", "views/chrome_views_delegate.cc", "views/chrome_views_delegate.h", + "views/chrome_web_dialog_view.cc", "views/collected_cookies_views.cc", "views/collected_cookies_views.h", "views/confirm_bubble_views.cc", "views/confirm_bubble_views.h", + "views/constrained_web_dialog_delegate_views.cc", "views/content_setting_bubble_contents.cc", "views/content_setting_bubble_contents.h", "views/content_setting_domain_list_view.cc", @@ -2843,6 +2445,18 @@ jumbo_split_static_library("ui") { "views/device_chooser_content_view.cc", "views/device_chooser_content_view.h", "views/download/download_danger_prompt_views.cc", + "views/download/download_in_progress_dialog_view.cc", + "views/download/download_in_progress_dialog_view.h", + "views/download/download_item_view.cc", + "views/download/download_item_view.h", + "views/download/download_shelf_context_menu_view.cc", + "views/download/download_shelf_context_menu_view.h", + "views/download/download_shelf_view.cc", + "views/download/download_shelf_view.h", + "views/download/download_started_animation_views.cc", + "views/dropdown_bar_host.cc", + "views/dropdown_bar_host.h", + "views/dropdown_bar_host_delegate.h", "views/elevation_icon_setter.cc", "views/elevation_icon_setter.h", "views/exclusive_access_bubble_views.cc", @@ -2863,8 +2477,66 @@ jumbo_split_static_library("ui") { "views/extensions/pwa_confirmation_view.h", "views/extensions/web_app_info_image_source.cc", "views/extensions/web_app_info_image_source.h", + "views/feature_promos/bookmark_promo_bubble_view.cc", + "views/feature_promos/bookmark_promo_bubble_view.h", + "views/feature_promos/feature_promo_bubble_view.cc", + "views/feature_promos/feature_promo_bubble_view.h", + "views/feature_promos/incognito_window_promo_bubble_view.cc", + "views/feature_promos/incognito_window_promo_bubble_view.h", + "views/feature_promos/new_tab_promo_bubble_view.cc", + "views/feature_promos/new_tab_promo_bubble_view.h", + "views/find_bar_host.cc", + "views/find_bar_host.h", + "views/find_bar_view.cc", + "views/find_bar_view.h", "views/folder_upload_confirmation_view.cc", "views/folder_upload_confirmation_view.h", + "views/frame/app_menu_button.cc", + "views/frame/app_menu_button.h", + "views/frame/browser_frame.cc", + "views/frame/browser_frame.h", + "views/frame/browser_non_client_frame_view.cc", + "views/frame/browser_non_client_frame_view.h", + "views/frame/browser_root_view.cc", + "views/frame/browser_root_view.h", + "views/frame/browser_view.cc", + "views/frame/browser_view.h", + "views/frame/browser_view_commands_mac.h", + "views/frame/browser_view_commands_mac.mm", + "views/frame/browser_view_layout.cc", + "views/frame/browser_view_layout.h", + "views/frame/browser_view_layout_delegate.h", + "views/frame/browser_window_factory.cc", + "views/frame/contents_layout_manager.cc", + "views/frame/contents_layout_manager.h", + "views/frame/contents_web_view.cc", + "views/frame/contents_web_view.h", + "views/frame/hosted_app_button_container.cc", + "views/frame/hosted_app_button_container.h", + "views/frame/hosted_app_menu_button.cc", + "views/frame/hosted_app_menu_button.h", + "views/frame/hosted_app_origin_text.cc", + "views/frame/hosted_app_origin_text.h", + "views/frame/immersive_mode_controller.cc", + "views/frame/immersive_mode_controller.h", + "views/frame/immersive_mode_controller_factory_views.cc", + "views/frame/immersive_mode_controller_stub.cc", + "views/frame/immersive_mode_controller_stub.h", + "views/frame/native_browser_frame.h", + "views/frame/native_browser_frame_factory.cc", + "views/frame/native_browser_frame_factory.h", + "views/frame/system_menu_model_builder.cc", + "views/frame/system_menu_model_builder.h", + "views/frame/system_menu_model_delegate.cc", + "views/frame/system_menu_model_delegate.h", + "views/frame/toolbar_button_provider.h", + "views/frame/top_container_view.cc", + "views/frame/top_container_view.h", + "views/frame/top_controls_slide_controller.cc", + "views/frame/top_controls_slide_controller.h", + "views/frame/web_contents_close_handler.cc", + "views/frame/web_contents_close_handler.h", + "views/frame/web_contents_close_handler_delegate.h", "views/fullscreen_control/fullscreen_control_host.cc", "views/fullscreen_control/fullscreen_control_host.h", "views/fullscreen_control/fullscreen_control_popup.cc", @@ -2875,10 +2547,42 @@ jumbo_split_static_library("ui") { "views/global_error_bubble_view.h", "views/hover_button.cc", "views/hover_button.h", + "views/hung_renderer_view.cc", + "views/hung_renderer_view.h", + "views/ime/ime_warning_bubble_view.cc", + "views/ime/ime_warning_bubble_view.h", "views/importer/import_lock_dialog_view.cc", "views/importer/import_lock_dialog_view.h", + "views/infobars/alternate_nav_infobar_view.cc", + "views/infobars/alternate_nav_infobar_view.h", + "views/infobars/confirm_infobar.cc", + "views/infobars/confirm_infobar.h", + "views/infobars/infobar_container_view.cc", + "views/infobars/infobar_container_view.h", + "views/infobars/infobar_view.cc", + "views/infobars/infobar_view.h", + "views/load_complete_listener.cc", + "views/load_complete_listener.h", + "views/location_bar/content_setting_image_view.cc", + "views/location_bar/content_setting_image_view.h", + "views/location_bar/find_bar_icon.cc", + "views/location_bar/find_bar_icon.h", + "views/location_bar/icon_label_bubble_view.cc", + "views/location_bar/icon_label_bubble_view.h", + "views/location_bar/keyword_hint_view.cc", + "views/location_bar/keyword_hint_view.h", "views/location_bar/location_bar_bubble_delegate_view.cc", "views/location_bar/location_bar_bubble_delegate_view.h", + "views/location_bar/location_bar_layout.cc", + "views/location_bar/location_bar_layout.h", + "views/location_bar/location_bar_view.cc", + "views/location_bar/location_bar_view.h", + "views/location_bar/location_icon_view.cc", + "views/location_bar/location_icon_view.h", + "views/location_bar/selected_keyword_view.cc", + "views/location_bar/selected_keyword_view.h", + "views/location_bar/star_view.cc", + "views/location_bar/star_view.h", "views/location_bar/zoom_bubble_view.cc", "views/location_bar/zoom_bubble_view.h", "views/login_handler_views.cc", @@ -2886,12 +2590,61 @@ jumbo_split_static_library("ui") { "views/login_view.h", "views/material_refresh_layout_provider.cc", "views/material_refresh_layout_provider.h", + "views/media_router/cast_dialog_helper.cc", + "views/media_router/cast_dialog_helper.h", + "views/media_router/cast_dialog_metrics.cc", + "views/media_router/cast_dialog_metrics.h", + "views/media_router/cast_dialog_no_sinks_view.cc", + "views/media_router/cast_dialog_no_sinks_view.h", + "views/media_router/cast_dialog_sink_button.cc", + "views/media_router/cast_dialog_sink_button.h", + "views/media_router/cast_dialog_view.cc", + "views/media_router/cast_dialog_view.h", + "views/media_router/cast_toolbar_button.cc", + "views/media_router/cast_toolbar_button.h", + "views/media_router/cloud_services_dialog_view.cc", + "views/media_router/cloud_services_dialog_view.h", + "views/media_router/media_remoting_dialog_view.cc", + "views/media_router/media_remoting_dialog_view.h", + "views/media_router/media_router_dialog_controller_views.cc", + "views/media_router/media_router_dialog_controller_views.h", + "views/media_router/media_router_views_ui.cc", + "views/media_router/media_router_views_ui.h", + "views/media_router/presentation_receiver_window_factory.cc", + "views/media_router/presentation_receiver_window_frame.cc", + "views/media_router/presentation_receiver_window_frame.h", + "views/media_router/presentation_receiver_window_view.cc", + "views/media_router/presentation_receiver_window_view.h", + "views/media_router/web_contents_display_observer_view.cc", + "views/media_router/web_contents_display_observer_view.h", + "views/omnibox/omnibox_match_cell_view.cc", + "views/omnibox/omnibox_match_cell_view.h", + "views/omnibox/omnibox_popup_contents_view.cc", + "views/omnibox/omnibox_popup_contents_view.h", + "views/omnibox/omnibox_result_view.cc", + "views/omnibox/omnibox_result_view.h", + "views/omnibox/omnibox_tab_switch_button.cc", + "views/omnibox/omnibox_tab_switch_button.h", + "views/omnibox/omnibox_text_view.cc", + "views/omnibox/omnibox_text_view.h", + "views/omnibox/omnibox_view_views.cc", + "views/omnibox/omnibox_view_views.h", + "views/omnibox/rounded_omnibox_results_frame.cc", + "views/omnibox/rounded_omnibox_results_frame.h", "views/overlay/close_image_button.cc", "views/overlay/close_image_button.h", "views/overlay/control_image_button.cc", "views/overlay/control_image_button.h", "views/overlay/overlay_window_views.cc", "views/overlay/overlay_window_views.h", + "views/overlay/resize_handle_button.cc", + "views/overlay/resize_handle_button.h", + "views/page_action/page_action_icon_container_view.cc", + "views/page_action/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/zoom_view.cc", + "views/page_action/zoom_view.h", "views/page_info/chosen_object_view.cc", "views/page_info/chosen_object_view.h", "views/page_info/chosen_object_view_observer.h", @@ -2908,10 +2661,14 @@ jumbo_split_static_library("ui") { "views/passwords/auto_signin_first_run_dialog_view.h", "views/passwords/credentials_item_view.cc", "views/passwords/credentials_item_view.h", + "views/passwords/manage_passwords_icon_views.cc", + "views/passwords/manage_passwords_icon_views.h", "views/passwords/password_auto_sign_in_view.cc", "views/passwords/password_auto_sign_in_view.h", "views/passwords/password_bubble_view_base.cc", "views/passwords/password_bubble_view_base.h", + "views/passwords/password_generation_popup_view_views.cc", + "views/passwords/password_generation_popup_view_views.h", "views/passwords/password_items_view.cc", "views/passwords/password_items_view.h", "views/passwords/password_pending_view.cc", @@ -2965,8 +2722,16 @@ jumbo_split_static_library("ui") { "views/payments/view_stack.h", "views/permission_bubble/chooser_bubble_ui.cc", "views/permission_bubble/chooser_bubble_ui.h", + "views/permission_bubble/chooser_bubble_ui_views.cc", "views/permission_bubble/permission_prompt_impl.cc", "views/permission_bubble/permission_prompt_impl.h", + "views/permission_bubble/permission_prompt_impl_views.cc", + "views/profiles/avatar_toolbar_button.cc", + "views/profiles/avatar_toolbar_button.h", + "views/profiles/signin_view_controller_delegate_views.cc", + "views/profiles/signin_view_controller_delegate_views.h", + "views/proximity_auth/proximity_auth_error_bubble_view.cc", + "views/proximity_auth/proximity_auth_error_bubble_view.h", "views/relaunch_notification/relaunch_notification_controller.cc", "views/relaunch_notification/relaunch_notification_controller.h", "views/relaunch_notification/relaunch_notification_metrics.cc", @@ -2977,28 +2742,95 @@ jumbo_split_static_library("ui") { "views/relaunch_notification/relaunch_required_timer.h", "views/relaunch_notification/relaunch_required_timer_internal.cc", "views/relaunch_notification/relaunch_required_timer_internal.h", + "views/sad_tab_view.cc", + "views/sad_tab_view.h", "views/safe_browsing/password_reuse_modal_warning_dialog.cc", "views/safe_browsing/password_reuse_modal_warning_dialog.h", "views/session_crashed_bubble_view.cc", "views/session_crashed_bubble_view.h", "views/simple_message_box_views.cc", "views/simple_message_box_views.h", + "views/ssl_client_certificate_selector.cc", + "views/ssl_client_certificate_selector.h", + "views/status_bubble_views.cc", + "views/status_bubble_views.h", "views/subtle_notification_view.cc", "views/subtle_notification_view.h", "views/sync/bubble_sync_promo_view.cc", "views/sync/bubble_sync_promo_view.h", "views/sync/profile_signin_confirmation_dialog_views.cc", "views/sync/profile_signin_confirmation_dialog_views.h", + "views/tab_contents/chrome_web_contents_view_focus_helper.cc", + "views/tab_contents/chrome_web_contents_view_focus_helper.h", + "views/tab_dialogs_views.cc", + "views/tab_dialogs_views.h", + "views/tab_icon_view.cc", + "views/tab_icon_view.h", + "views/tab_modal_confirm_dialog_views.cc", + "views/tab_modal_confirm_dialog_views.h", + "views/tabs/alert_indicator.cc", + "views/tabs/alert_indicator.h", + "views/tabs/browser_tab_strip_controller.cc", + "views/tabs/browser_tab_strip_controller.h", + "views/tabs/glow_hover_controller.cc", + "views/tabs/glow_hover_controller.h", + "views/tabs/new_tab_button.cc", + "views/tabs/new_tab_button.h", + "views/tabs/stacked_tab_strip_layout.cc", + "views/tabs/stacked_tab_strip_layout.h", + "views/tabs/tab.cc", + "views/tabs/tab.h", + "views/tabs/tab_close_button.cc", + "views/tabs/tab_close_button.h", + "views/tabs/tab_controller.h", + "views/tabs/tab_drag_controller.cc", + "views/tabs/tab_drag_controller.h", + "views/tabs/tab_icon.cc", + "views/tabs/tab_icon.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/window_finder.h", "views/task_manager_view.cc", "views/task_manager_view.h", "views/textfield_layout.cc", "views/textfield_layout.h", + "views/theme_copying_widget.cc", + "views/theme_copying_widget.h", + "views/toolbar/app_menu.cc", + "views/toolbar/app_menu.h", + "views/toolbar/app_menu_observer.h", + "views/toolbar/browser_actions_container.cc", + "views/toolbar/browser_actions_container.h", + "views/toolbar/browser_app_menu_button.cc", + "views/toolbar/browser_app_menu_button.h", + "views/toolbar/extension_toolbar_menu_view.cc", + "views/toolbar/extension_toolbar_menu_view.h", + "views/toolbar/home_button.cc", + "views/toolbar/home_button.h", + "views/toolbar/reload_button.cc", + "views/toolbar/reload_button.h", + "views/toolbar/toolbar_action_view.cc", + "views/toolbar/toolbar_action_view.h", + "views/toolbar/toolbar_action_view_delegate_views.h", "views/toolbar/toolbar_actions_bar_bubble_views.cc", "views/toolbar/toolbar_actions_bar_bubble_views.h", + "views/toolbar/toolbar_button.cc", + "views/toolbar/toolbar_button.h", + "views/toolbar/toolbar_ink_drop_util.cc", + "views/toolbar/toolbar_ink_drop_util.h", + "views/toolbar/toolbar_view.cc", + "views/toolbar/toolbar_view.h", "views/touch_uma/touch_uma.cc", "views/touch_uma/touch_uma.h", "views/translate/translate_bubble_view.cc", "views/translate/translate_bubble_view.h", + "views/translate/translate_icon_view.cc", + "views/translate/translate_icon_view.h", "views/update_recommended_message_box.cc", "views/update_recommended_message_box.h", "views/webauthn/authenticator_request_dialog_view.cc", @@ -3011,6 +2843,10 @@ jumbo_split_static_library("ui") { "views/webauthn/sheet_view_factory.h", "views/webauthn/transport_list_view.cc", "views/webauthn/transport_list_view.h", + "views/webshare/webshare_target_picker_view.cc", + "views/webshare/webshare_target_picker_view.h", + "views_mode_controller.cc", + "views_mode_controller.h", "webauthn/authenticator_request_sheet_model.h", "webauthn/other_transports_menu_model.cc", "webauthn/other_transports_menu_model.h", @@ -3025,40 +2861,11 @@ jumbo_split_static_library("ui") { "//components/payments/content", "//components/payments/core", "//services/ws/public/cpp/input_devices", + "//ui/views:features", ] allow_circular_includes_from += [ "//chrome/browser/ui/views" ] - if (is_mac) { - sources += [ - "views/apps/app_window_native_widget_mac.h", - "views/apps/app_window_native_widget_mac.mm", - "views/apps/chrome_native_app_window_views_mac.h", - "views/apps/chrome_native_app_window_views_mac.mm", - "views/apps/native_app_window_frame_view_mac.h", - "views/apps/native_app_window_frame_view_mac.mm", - "views/chrome_views_delegate_mac.cc", - "views/frame/native_widget_mac_frameless_nswindow.h", - "views/frame/native_widget_mac_frameless_nswindow.mm", - ] - } else { - sources += [ - "views/create_application_shortcut_view.cc", - "views/create_application_shortcut_view.h", - - # TODO(ellyjones): Mus is not supported on Mac (there is no ui::Window - # apart from aura::Window, which is also not supported). - "views/ime_driver/ime_driver_mus.cc", - "views/ime_driver/ime_driver_mus.h", - "views/ime_driver/remote_text_input_client.cc", - "views/ime_driver/remote_text_input_client.h", - "views/ime_driver/simple_input_method.cc", - "views/ime_driver/simple_input_method.h", - ] - - deps += [ "//ui/views/mus" ] - } - if (enable_dice_support) { sources += [ "views/sync/dice_bubble_sync_promo_view.cc", @@ -3068,317 +2875,6 @@ jumbo_split_static_library("ui") { ] } - if (!is_mac || mac_views_browser) { - sources += [ - "views/accessibility/invert_bubble_view.cc", - "views/accessibility/invert_bubble_view.h", - "views/autofill/local_card_migration_icon_view.cc", - "views/autofill/local_card_migration_icon_view.h", - "views/autofill/save_card_icon_view.cc", - "views/autofill/save_card_icon_view.h", - "views/bookmarks/bookmark_bar_instructions_view.cc", - "views/bookmarks/bookmark_bar_instructions_view.h", - "views/bookmarks/bookmark_bar_view.cc", - "views/bookmarks/bookmark_bar_view.h", - "views/bookmarks/bookmark_bar_view_observer.h", - "views/bookmarks/bookmark_context_menu.cc", - "views/bookmarks/bookmark_context_menu.h", - "views/bookmarks/bookmark_drag_drop_views.cc", - "views/bookmarks/bookmark_menu_controller_observer.h", - "views/bookmarks/bookmark_menu_controller_views.cc", - "views/bookmarks/bookmark_menu_controller_views.h", - "views/bookmarks/bookmark_menu_delegate.cc", - "views/bookmarks/bookmark_menu_delegate.h", - "views/browser_dialogs_views.cc", - "views/bubble_anchor_util_views.cc", - "views/certificate_selector.cc", - "views/certificate_selector.h", - "views/chrome_web_dialog_view.cc", - "views/constrained_web_dialog_delegate_views.cc", - "views/download/download_feedback_dialog_view.cc", - "views/download/download_feedback_dialog_view.h", - "views/download/download_in_progress_dialog_view.cc", - "views/download/download_in_progress_dialog_view.h", - "views/download/download_item_view.cc", - "views/download/download_item_view.h", - "views/download/download_shelf_context_menu_view.cc", - "views/download/download_shelf_context_menu_view.h", - "views/download/download_shelf_view.cc", - "views/download/download_shelf_view.h", - "views/download/download_started_animation_views.cc", - "views/dropdown_bar_host.cc", - "views/dropdown_bar_host.h", - "views/dropdown_bar_host_delegate.h", - "views/feature_promos/bookmark_promo_bubble_view.cc", - "views/feature_promos/bookmark_promo_bubble_view.h", - "views/feature_promos/feature_promo_bubble_view.cc", - "views/feature_promos/feature_promo_bubble_view.h", - "views/feature_promos/incognito_window_promo_bubble_view.cc", - "views/feature_promos/incognito_window_promo_bubble_view.h", - "views/feature_promos/new_tab_promo_bubble_view.cc", - "views/feature_promos/new_tab_promo_bubble_view.h", - "views/find_bar_host.cc", - "views/find_bar_host.h", - "views/find_bar_view.cc", - "views/find_bar_view.h", - "views/frame/app_menu_button.cc", - "views/frame/app_menu_button.h", - "views/frame/avatar_button_manager.cc", - "views/frame/avatar_button_manager.h", - "views/frame/browser_frame.cc", - "views/frame/browser_frame.h", - "views/frame/browser_non_client_frame_view.cc", - "views/frame/browser_non_client_frame_view.h", - "views/frame/browser_root_view.cc", - "views/frame/browser_root_view.h", - "views/frame/browser_view.cc", - "views/frame/browser_view.h", - "views/frame/browser_view_commands_mac.h", - "views/frame/browser_view_commands_mac.mm", - "views/frame/browser_view_layout.cc", - "views/frame/browser_view_layout.h", - "views/frame/browser_view_layout_delegate.h", - "views/frame/browser_window_factory.cc", - "views/frame/contents_layout_manager.cc", - "views/frame/contents_layout_manager.h", - "views/frame/contents_web_view.cc", - "views/frame/contents_web_view.h", - "views/frame/hosted_app_button_container.cc", - "views/frame/hosted_app_button_container.h", - "views/frame/hosted_app_menu_button.cc", - "views/frame/hosted_app_menu_button.h", - "views/frame/hosted_app_origin_text.cc", - "views/frame/hosted_app_origin_text.h", - "views/frame/immersive_mode_controller.cc", - "views/frame/immersive_mode_controller.h", - "views/frame/immersive_mode_controller_factory_views.cc", - "views/frame/immersive_mode_controller_stub.cc", - "views/frame/immersive_mode_controller_stub.h", - "views/frame/native_browser_frame.h", - "views/frame/native_browser_frame_factory.cc", - "views/frame/native_browser_frame_factory.h", - "views/frame/system_menu_model_builder.cc", - "views/frame/system_menu_model_builder.h", - "views/frame/system_menu_model_delegate.cc", - "views/frame/system_menu_model_delegate.h", - "views/frame/toolbar_button_provider.h", - "views/frame/top_container_view.cc", - "views/frame/top_container_view.h", - "views/frame/web_contents_close_handler.cc", - "views/frame/web_contents_close_handler.h", - "views/frame/web_contents_close_handler_delegate.h", - "views/hung_renderer_view.cc", - "views/hung_renderer_view.h", - "views/ime/ime_warning_bubble_view.cc", - "views/ime/ime_warning_bubble_view.h", - "views/infobars/alternate_nav_infobar_view.cc", - "views/infobars/alternate_nav_infobar_view.h", - "views/infobars/confirm_infobar.cc", - "views/infobars/confirm_infobar.h", - "views/infobars/infobar_container_view.cc", - "views/infobars/infobar_container_view.h", - "views/infobars/infobar_view.cc", - "views/infobars/infobar_view.h", - "views/load_complete_listener.cc", - "views/load_complete_listener.h", - "views/location_bar/background_with_1_px_border.cc", - "views/location_bar/background_with_1_px_border.h", - "views/location_bar/content_setting_image_view.cc", - "views/location_bar/content_setting_image_view.h", - "views/location_bar/find_bar_icon.cc", - "views/location_bar/find_bar_icon.h", - "views/location_bar/icon_label_bubble_view.cc", - "views/location_bar/icon_label_bubble_view.h", - "views/location_bar/keyword_hint_view.cc", - "views/location_bar/keyword_hint_view.h", - "views/location_bar/location_bar_layout.cc", - "views/location_bar/location_bar_layout.h", - "views/location_bar/location_bar_view.cc", - "views/location_bar/location_bar_view.h", - "views/location_bar/location_icon_view.cc", - "views/location_bar/location_icon_view.h", - "views/location_bar/selected_keyword_view.cc", - "views/location_bar/selected_keyword_view.h", - "views/location_bar/star_view.cc", - "views/location_bar/star_view.h", - "views/media_router/cast_dialog_metrics.cc", - "views/media_router/cast_dialog_metrics.h", - "views/media_router/cast_dialog_no_sinks_view.cc", - "views/media_router/cast_dialog_no_sinks_view.h", - "views/media_router/cast_dialog_sink_button.cc", - "views/media_router/cast_dialog_sink_button.h", - "views/media_router/cast_dialog_view.cc", - "views/media_router/cast_dialog_view.h", - "views/media_router/cast_toolbar_button.cc", - "views/media_router/cast_toolbar_button.h", - "views/media_router/cloud_services_dialog_view.cc", - "views/media_router/cloud_services_dialog_view.h", - "views/media_router/media_remoting_dialog_view.cc", - "views/media_router/media_remoting_dialog_view.h", - "views/media_router/media_router_dialog_controller_views.cc", - "views/media_router/media_router_dialog_controller_views.h", - "views/media_router/media_router_views_ui.cc", - "views/media_router/media_router_views_ui.h", - "views/media_router/presentation_receiver_window_factory.cc", - "views/media_router/presentation_receiver_window_frame.cc", - "views/media_router/presentation_receiver_window_frame.h", - "views/media_router/presentation_receiver_window_view.cc", - "views/media_router/presentation_receiver_window_view.h", - "views/media_router/web_contents_display_observer_view.cc", - "views/media_router/web_contents_display_observer_view.h", - "views/omnibox/omnibox_match_cell_view.cc", - "views/omnibox/omnibox_match_cell_view.h", - "views/omnibox/omnibox_popup_contents_view.cc", - "views/omnibox/omnibox_popup_contents_view.h", - "views/omnibox/omnibox_result_view.cc", - "views/omnibox/omnibox_result_view.h", - "views/omnibox/omnibox_tab_switch_button.cc", - "views/omnibox/omnibox_tab_switch_button.h", - "views/omnibox/omnibox_text_view.cc", - "views/omnibox/omnibox_text_view.h", - "views/omnibox/omnibox_view_views.cc", - "views/omnibox/omnibox_view_views.h", - "views/omnibox/rounded_omnibox_results_frame.cc", - "views/omnibox/rounded_omnibox_results_frame.h", - "views/page_action/page_action_icon_container_view.cc", - "views/page_action/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/zoom_view.cc", - "views/page_action/zoom_view.h", - "views/passwords/manage_passwords_icon_views.cc", - "views/passwords/manage_passwords_icon_views.h", - "views/passwords/password_generation_popup_view_views.cc", - "views/passwords/password_generation_popup_view_views.h", - "views/permission_bubble/chooser_bubble_ui_views.cc", - "views/permission_bubble/permission_prompt_impl_views.cc", - "views/profiles/avatar_button_style.h", - "views/profiles/avatar_toolbar_button.cc", - "views/profiles/avatar_toolbar_button.h", - "views/profiles/profile_indicator_icon.cc", - "views/profiles/profile_indicator_icon.h", - "views/profiles/signin_view_controller_delegate_views.cc", - "views/profiles/signin_view_controller_delegate_views.h", - "views/proximity_auth/proximity_auth_error_bubble_view.cc", - "views/proximity_auth/proximity_auth_error_bubble_view.h", - "views/sad_tab_view.cc", - "views/sad_tab_view.h", - "views/ssl_client_certificate_selector.cc", - "views/ssl_client_certificate_selector.h", - "views/status_bubble_views.cc", - "views/status_bubble_views.h", - "views/tab_contents/chrome_web_contents_view_focus_helper.cc", - "views/tab_contents/chrome_web_contents_view_focus_helper.h", - "views/tab_dialogs_views.cc", - "views/tab_dialogs_views.h", - "views/tab_icon_view.cc", - "views/tab_icon_view.h", - "views/tab_modal_confirm_dialog_views.cc", - "views/tab_modal_confirm_dialog_views.h", - "views/tabs/alert_indicator_button.cc", - "views/tabs/alert_indicator_button.h", - "views/tabs/browser_tab_strip_controller.cc", - "views/tabs/browser_tab_strip_controller.h", - "views/tabs/glow_hover_controller.cc", - "views/tabs/glow_hover_controller.h", - "views/tabs/new_tab_button.cc", - "views/tabs/new_tab_button.h", - "views/tabs/stacked_tab_strip_layout.cc", - "views/tabs/stacked_tab_strip_layout.h", - "views/tabs/tab.cc", - "views/tabs/tab.h", - "views/tabs/tab_close_button.cc", - "views/tabs/tab_close_button.h", - "views/tabs/tab_controller.h", - "views/tabs/tab_drag_controller.cc", - "views/tabs/tab_drag_controller.h", - "views/tabs/tab_icon.cc", - "views/tabs/tab_icon.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/window_finder.h", - "views/theme_copying_widget.cc", - "views/theme_copying_widget.h", - "views/toolbar/app_menu.cc", - "views/toolbar/app_menu.h", - "views/toolbar/app_menu_observer.h", - "views/toolbar/browser_actions_container.cc", - "views/toolbar/browser_actions_container.h", - "views/toolbar/browser_app_menu_button.cc", - "views/toolbar/browser_app_menu_button.h", - "views/toolbar/extension_toolbar_menu_view.cc", - "views/toolbar/extension_toolbar_menu_view.h", - "views/toolbar/home_button.cc", - "views/toolbar/home_button.h", - "views/toolbar/media_router_action_platform_delegate_views.cc", - "views/toolbar/media_router_action_platform_delegate_views.h", - "views/toolbar/reload_button.cc", - "views/toolbar/reload_button.h", - "views/toolbar/toolbar_action_view.cc", - "views/toolbar/toolbar_action_view.h", - "views/toolbar/toolbar_action_view_delegate_views.h", - "views/toolbar/toolbar_button.cc", - "views/toolbar/toolbar_button.h", - "views/toolbar/toolbar_ink_drop_util.cc", - "views/toolbar/toolbar_ink_drop_util.h", - "views/toolbar/toolbar_view.cc", - "views/toolbar/toolbar_view.h", - "views/translate/translate_icon_view.cc", - "views/translate/translate_icon_view.h", - "views/webshare/webshare_target_picker_view.cc", - "views/webshare/webshare_target_picker_view.h", - "views_mode_controller.cc", - "views_mode_controller.h", - ] - - deps += [ "//ui/views:features" ] - - if (is_mac) { - # This Mac-specific file is being removed in this case because it's only - # needed when Views isn't used on Mac. - sources -= - [ "media_router/presentation_receiver_window_factory_mac.cc" ] - - # This source file is compiled out on Mac because there is a - # Mac-specific implementation of it that works on mac_views_browser - # builds as well: - sources -= [ "views/permission_bubble/permission_prompt_impl_views.cc" ] - } - - if (!is_chromeos) { - sources += [ - "views/frame/opaque_browser_frame_view.cc", - "views/frame/opaque_browser_frame_view.h", - "views/frame/opaque_browser_frame_view_layout.cc", - "views/frame/opaque_browser_frame_view_layout.h", - "views/frame/opaque_browser_frame_view_layout_delegate.h", - "views/frame/opaque_browser_frame_view_linux.cc", - "views/frame/opaque_browser_frame_view_linux.h", - "views/frame/opaque_browser_frame_view_platform_specific.cc", - "views/frame/opaque_browser_frame_view_platform_specific.h", - "views/outdated_upgrade_bubble_view.cc", - "views/outdated_upgrade_bubble_view.h", - "views/policy/enterprise_startup_dialog_view.cc", - "views/policy/enterprise_startup_dialog_view.h", - "views/profiles/forced_reauthentication_dialog_view.cc", - "views/profiles/forced_reauthentication_dialog_view.h", - "views/sync/one_click_signin_dialog_view.cc", - "views/sync/one_click_signin_dialog_view.h", - "views/tabs/window_finder.cc", - ] - } - - if (use_aura) { - deps += [ - "//services/ws/public/cpp", - "//services/ws/public/mojom", - ] - } - } - if (enable_native_window_nav_buttons) { sources += [ "views/frame/desktop_linux_browser_frame_view.cc", @@ -3403,11 +2899,43 @@ jumbo_split_static_library("ui") { } if (is_mac) { - sources += [ "views/chrome_platform_style_mac.mm" ] + sources += [ + "views/apps/app_window_native_widget_mac.h", + "views/apps/app_window_native_widget_mac.mm", + "views/apps/chrome_native_app_window_views_mac.h", + "views/apps/chrome_native_app_window_views_mac.mm", + "views/apps/native_app_window_frame_view_mac.h", + "views/apps/native_app_window_frame_view_mac.mm", + "views/chrome_views_delegate_mac.cc", + "views/frame/native_widget_mac_frameless_nswindow.h", + "views/frame/native_widget_mac_frameless_nswindow.mm", + "views/policy/enterprise_startup_dialog_mac_util.h", + "views/policy/enterprise_startup_dialog_mac_util.mm", + ] + } else { + sources += [ + "views/create_application_shortcut_view.cc", + "views/create_application_shortcut_view.h", + + # TODO(ellyjones): Mus is not supported on Mac (there is no ui::Window + # apart from aura::Window, which is also not supported). + "views/ime_driver/ime_driver_mus.cc", + "views/ime_driver/ime_driver_mus.h", + "views/ime_driver/remote_text_input_client.cc", + "views/ime_driver/remote_text_input_client.h", + "views/ime_driver/simple_input_method.cc", + "views/ime_driver/simple_input_method.h", + ] + + deps += [ "//ui/views/mus" ] } if (is_win) { - sources += [ "views/chrome_views_delegate_win.cc" ] + sources += [ + "views/chrome_views_delegate_win.cc", + "views/feature_promos/bookmark_bar_promo_bubble_view.cc", + "views/feature_promos/bookmark_bar_promo_bubble_view.h", + ] } if (is_win || is_desktop_linux) { @@ -3418,7 +2946,11 @@ jumbo_split_static_library("ui") { } if (use_aura) { - deps += [ "//components/ui_devtools/views" ] + deps += [ + "//components/ui_devtools/views", + "//services/ws/public/cpp", + "//services/ws/public/mojom", + ] # These files do Gtk+-based theming, but Gtk+ is not available on # Ozone builds, or on common environments where Ozone will be used. @@ -3440,6 +2972,21 @@ jumbo_split_static_library("ui") { ] } else { sources += [ + "views/frame/opaque_browser_frame_view.cc", + "views/frame/opaque_browser_frame_view.h", + "views/frame/opaque_browser_frame_view_layout.cc", + "views/frame/opaque_browser_frame_view_layout.h", + "views/frame/opaque_browser_frame_view_layout_delegate.h", + "views/frame/opaque_browser_frame_view_linux.cc", + "views/frame/opaque_browser_frame_view_linux.h", + "views/frame/opaque_browser_frame_view_platform_specific.cc", + "views/frame/opaque_browser_frame_view_platform_specific.h", + "views/outdated_upgrade_bubble_view.cc", + "views/outdated_upgrade_bubble_view.h", + "views/policy/enterprise_startup_dialog_view.cc", + "views/policy/enterprise_startup_dialog_view.h", + "views/profiles/forced_reauthentication_dialog_view.cc", + "views/profiles/forced_reauthentication_dialog_view.h", "views/relaunch_notification/relaunch_notification_controller_platform_impl_desktop.cc", "views/relaunch_notification/relaunch_notification_controller_platform_impl_desktop.h", "views/relaunch_notification/relaunch_recommended_bubble_view.cc", @@ -3447,36 +2994,21 @@ jumbo_split_static_library("ui") { "views/relaunch_notification/relaunch_required_dialog_view.cc", "views/relaunch_notification/relaunch_required_dialog_view.h", "views/screen_capture_notification_ui_views.cc", - ] - } - - if (is_mac) { - sources += [ - "views/policy/enterprise_startup_dialog_mac_util.h", - "views/policy/enterprise_startup_dialog_mac_util.mm", - "views/relaunch_notification/get_app_menu_anchor_point.h", - "views/relaunch_notification/get_app_menu_anchor_point.mm", + "views/sync/one_click_signin_dialog_view.cc", + "views/sync/one_click_signin_dialog_view.h", + "views/tabs/window_finder.cc", ] } if (is_chrome_branded) { deps += [ "//chrome/browser/ui/media_router/internal/vector_icons" ] } - - if (is_win) { - sources += [ - "views/feature_promos/bookmark_bar_promo_bubble_view.cc", - "views/feature_promos/bookmark_bar_promo_bubble_view.h", - ] - } } if (use_aura) { sources += [ "aura/accessibility/automation_manager_aura.cc", "aura/accessibility/automation_manager_aura.h", - "aura/accessibility/ax_root_obj_wrapper.cc", - "aura/accessibility/ax_root_obj_wrapper.h", "aura/accessibility/ax_tree_source_aura.cc", "aura/accessibility/ax_tree_source_aura.h", "aura/native_window_tracker_aura.cc", @@ -3555,6 +3087,7 @@ jumbo_split_static_library("ui") { "app_list/app_list_controller_delegate.h", "app_list/app_list_model_builder.cc", "app_list/app_list_model_builder.h", + "app_list/app_list_model_updater.cc", "app_list/app_list_model_updater.h", "app_list/app_list_model_updater_delegate.h", "app_list/app_list_syncable_service.cc", @@ -3575,6 +3108,8 @@ jumbo_split_static_library("ui") { "app_list/extension_app_utils.h", "app_list/extension_uninstaller.cc", "app_list/extension_uninstaller.h", + "app_list/md_icon_normalizer.cc", + "app_list/md_icon_normalizer.h", "app_list/search/answer_card/answer_card_contents.cc", "app_list/search/answer_card/answer_card_contents.h", "app_list/search/answer_card/answer_card_result.cc", @@ -3656,6 +3191,7 @@ jumbo_split_static_library("ui") { "//ash/app_list", "//ash/public/cpp/app_list/vector_icons", "//ash/resources/vector_icons", + "//chrome/browser/ui/app_list/search/search_result_ranker:app_launch_predictor_proto", "//ui/views/mus/remote_view:remote_view_provider", ] @@ -3681,6 +3217,8 @@ jumbo_split_static_library("ui") { "app_list/arc/arc_app_list_prefs_factory.h", "app_list/arc/arc_app_model_builder.cc", "app_list/arc/arc_app_model_builder.h", + "app_list/arc/arc_app_scoped_pref_update.cc", + "app_list/arc/arc_app_scoped_pref_update.h", "app_list/arc/arc_app_utils.cc", "app_list/arc/arc_app_utils.h", "app_list/arc/arc_data_removal_dialog.h", @@ -3724,6 +3262,10 @@ jumbo_split_static_library("ui") { "app_list/internal_app/internal_app_metadata.h", "app_list/internal_app/internal_app_model_builder.cc", "app_list/internal_app/internal_app_model_builder.h", + "app_list/page_break_app_item.cc", + "app_list/page_break_app_item.h", + "app_list/page_break_constants.cc", + "app_list/page_break_constants.h", "app_list/search/arc_app_result.cc", "app_list/search/arc_app_result.h", "app_list/search/crostini_app_result.cc", @@ -3798,11 +3340,19 @@ jumbo_split_static_library("ui") { ] } + if (enable_desktop_in_product_help) { + sources += [ + "in_product_help/reopen_tab_iph_trigger.cc", + "in_product_help/reopen_tab_iph_trigger.h", + ] + } + if (enable_extensions) { deps += [ "//apps", "//chrome/browser/apps", "//chrome/browser/apps/platform_apps", # TODO(loyso): Remove this dep. + "//chrome/browser/apps/platform_apps/api", "//chrome/browser/extensions", "//chrome/common/extensions/api", "//components/drive", @@ -3814,6 +3364,7 @@ jumbo_split_static_library("ui") { ] allow_circular_includes_from += [ "//chrome/browser/apps/platform_apps", + "//chrome/browser/apps/platform_apps/api", "//chrome/browser/extensions", ] sources += [ @@ -3851,10 +3402,22 @@ jumbo_split_static_library("ui") { "extensions/installation_error_infobar_delegate.h", "extensions/settings_api_bubble_helpers.cc", "extensions/settings_api_bubble_helpers.h", + "views/extensions/browser_action_drag_data.cc", + "views/extensions/browser_action_drag_data.h", + "views/extensions/extension_action_platform_delegate_views.cc", + "views/extensions/extension_action_platform_delegate_views.h", + "views/extensions/extension_dialog.cc", + "views/extensions/extension_dialog.h", + "views/extensions/extension_dialog_observer.cc", + "views/extensions/extension_dialog_observer.h", "views/extensions/extension_popup.cc", "views/extensions/extension_popup.h", "views/extensions/extension_view_views.cc", "views/extensions/extension_view_views.h", + "views/extensions/media_galleries_dialog_views.cc", + "views/extensions/media_galleries_dialog_views.h", + "views/extensions/media_gallery_checkbox_view.cc", + "views/extensions/media_gallery_checkbox_view.h", "webui/extensions/extension_basic_info.cc", "webui/extensions/extension_basic_info.h", "webui/extensions/extension_icon_source.cc", @@ -3864,22 +3427,6 @@ jumbo_split_static_library("ui") { if (!is_mac) { deps += [ "//apps/ui/views" ] } - if (!is_mac || mac_views_browser) { - sources += [ - "views/extensions/browser_action_drag_data.cc", - "views/extensions/browser_action_drag_data.h", - "views/extensions/extension_action_platform_delegate_views.cc", - "views/extensions/extension_action_platform_delegate_views.h", - "views/extensions/extension_dialog.cc", - "views/extensions/extension_dialog.h", - "views/extensions/extension_dialog_observer.cc", - "views/extensions/extension_dialog_observer.h", - "views/extensions/media_galleries_dialog_views.cc", - "views/extensions/media_galleries_dialog_views.h", - "views/extensions/media_gallery_checkbox_view.cc", - "views/extensions/media_gallery_checkbox_view.h", - ] - } if (use_aura) { sources += [ "views/chrome_javascript_native_dialog_factory_views.cc", @@ -3898,14 +3445,6 @@ jumbo_split_static_library("ui") { deps += [ "//components/nacl/browser" ] } - if (is_win && is_chrome_branded) { - deps += [ - "//components/nux:constants", - "//components/nux:email_feature", - "//components/nux:google_apps_feature", - ] - } - if (enable_plugins) { sources += [ "hung_plugin_tab_helper.cc", @@ -3990,6 +3529,7 @@ jumbo_split_static_library("ui") { "//chrome/browser/ui/webui/reset_password:mojo_bindings", "//chrome/common/safe_browsing:proto", "//components/safe_browsing:csd_proto", + "//components/safe_browsing/password_protection:password_protection_metrics_util", ] } @@ -4036,8 +3576,6 @@ static_library("test_support") { "cocoa/test/cocoa_test_helper.mm", "cocoa/test/run_loop_testing.h", "cocoa/test/run_loop_testing.mm", - "cocoa/test/scoped_force_rtl_mac.h", - "cocoa/test/scoped_force_rtl_mac.mm", "content_settings/fake_owner.cc", "content_settings/fake_owner.h", "find_bar/find_bar_host_unittest_util.h", @@ -4081,27 +3619,15 @@ static_library("test_support") { "//ui/views:test_support", ] sources += [ - "../../test/views/scoped_macviews_browser_mode.cc", - "../../test/views/scoped_macviews_browser_mode.h", "extensions/browser_action_test_util.h", + "views/find_bar_host_unittest_util_views.cc", "views/payments/test_chrome_payment_request_delegate.cc", "views/payments/test_chrome_payment_request_delegate.h", + "views/toolbar/browser_action_test_util_views.cc", "views/toolbar/browser_action_test_util_views_mac.mm", "views/webauthn/authenticator_request_dialog_view_test_api.cc", "views/webauthn/authenticator_request_dialog_view_test_api.h", ] - if (is_mac) { - sources += [ - "cocoa/extensions/browser_action_test_util_views_cocoa.mm", - "cocoa/find_bar/find_bar_host_unittest_util_cocoa.mm", - ] - } - if (!is_mac || mac_views_browser) { - sources += [ - "views/find_bar_host_unittest_util_views.cc", - "views/toolbar/browser_action_test_util_views.cc", - ] - } if (use_aura) { sources += [ "views/toolbar/browser_action_test_util_views_aura.cc" ] deps += [ diff --git a/chromium/chrome/browser/ui/app_list/search/search_result_ranker/BUILD.gn b/chromium/chrome/browser/ui/app_list/search/search_result_ranker/BUILD.gn new file mode 100644 index 00000000000..c1dc58ce1ef --- /dev/null +++ b/chromium/chrome/browser/ui/app_list/search/search_result_ranker/BUILD.gn @@ -0,0 +1,11 @@ +# Copyright 2018 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//third_party/protobuf/proto_library.gni") + +proto_library("app_launch_predictor_proto") { + sources = [ + "app_launch_predictor.proto", + ] +} diff --git a/chromium/chrome/browser/ui/libgtkui/BUILD.gn b/chromium/chrome/browser/ui/libgtkui/BUILD.gn index 3932e0c8521..ffe7eb80840 100644 --- a/chromium/chrome/browser/ui/libgtkui/BUILD.gn +++ b/chromium/chrome/browser/ui/libgtkui/BUILD.gn @@ -22,7 +22,6 @@ component("libgtkui") { "gtk_event_loop.h", "gtk_key_bindings_handler.cc", "gtk_key_bindings_handler.h", - "gtk_signal.h", "gtk_ui.cc", "gtk_ui.h", "gtk_util.cc", diff --git a/chromium/chrome/browser/ui/webui/DEPS b/chromium/chrome/browser/ui/webui/DEPS index 1c49a311295..10bf6c8bbd0 100644 --- a/chromium/chrome/browser/ui/webui/DEPS +++ b/chromium/chrome/browser/ui/webui/DEPS @@ -1,6 +1,4 @@ include_rules = [ - # TODO(mash): Remove. http://crbug.com/628715 - "+ash/strings", "+device/bluetooth", "+extensions/strings/grit/extensions_strings.h", diff --git a/chromium/chrome/browser/ui/webui/OWNERS b/chromium/chrome/browser/ui/webui/OWNERS index 211ccfc88f3..3d2141d7685 100644 --- a/chromium/chrome/browser/ui/webui/OWNERS +++ b/chromium/chrome/browser/ui/webui/OWNERS @@ -22,4 +22,6 @@ per-file snippets_internals*=file://components/ntp_snippets/OWNERS per-file sync_internals*=file://components/sync/OWNERS +per-file invalidations_message_handler.*=file://components/invalidation/OWNERS + # COMPONENT: UI>Browser>WebUI diff --git a/chromium/chrome/browser/ui/webui/about_ui.cc b/chromium/chrome/browser/ui/webui/about_ui.cc index f17784247a4..6efb0ca7eb1 100644 --- a/chromium/chrome/browser/ui/webui/about_ui.cc +++ b/chromium/chrome/browser/ui/webui/about_ui.cc @@ -8,6 +8,7 @@ #include <stdint.h> #include <algorithm> +#include <memory> #include <string> #include <utility> #include <vector> @@ -39,7 +40,6 @@ #include "chrome/browser/about_flags.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/defaults.h" -#include "chrome/browser/net/predictor.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser_dialogs.h" @@ -76,8 +76,15 @@ #endif #if defined(OS_CHROMEOS) +#include <map> + +#include "base/base64.h" +#include "base/stl_util.h" +#include "base/strings/strcat.h" #include "chrome/browser/browser_process_platform_part_chromeos.h" #include "chrome/browser/chromeos/customization/customization_document.h" +#include "chromeos/system/statistics_provider.h" +#include "components/language/core/common/locale_util.h" #endif using content::BrowserThread; @@ -92,16 +99,80 @@ constexpr char kStringsJsPath[] = "strings.js"; constexpr char kKeyboardUtilsPath[] = "keyboard_utils.js"; -// Loads bundled Eula contents. The online version of Eula is fetched in Eula -// screen javascript. This is intentional because chrome://terms runs in a -// privileged webui context and should never load from untrusted places. +// APAC region name. +constexpr char kApac[] = "apac"; +// EMEA region name. +constexpr char kEmea[] = "emea"; +// EU region name. +constexpr char kEu[] = "eu"; + +// List of countries that belong to APAC. +const char* const kApacCountries[] = {"au", "bd", "cn", "hk", "id", "in", "jp", + "kh", "la", "lk", "mm", "mn", "my", "nz", + "np", "ph", "sg", "th", "tw", "vn"}; + +// List of countries that belong to EMEA. +const char* const kEmeaCountries[] = {"na", "za", "am", "az", "ch", "eg", "ge", + "il", "is", "ke", "kg", "li", "mk", "no", + "rs", "ru", "tr", "tz", "ua", "ug", "za"}; + +// List of countries that belong to EU. +const char* const kEuCountries[] = { + "at", "be", "bg", "cz", "dk", "es", "fi", "fr", "gb", "gr", "hr", "hu", + "ie", "it", "lt", "lu", "lv", "nl", "pl", "pt", "ro", "se", "si", "sk"}; + +// Maps country to one of 3 regions: APAC, EMEA, EU. +typedef std::map<std::string, std::string> CountryRegionMap; + +// Returns country to region map with EU, EMEA and APAC countries. +CountryRegionMap CreateCountryRegionMap() { + CountryRegionMap region_map; + for (size_t i = 0; i < base::size(kApacCountries); ++i) { + region_map.emplace(kApacCountries[i], kApac); + } + + for (size_t i = 0; i < base::size(kEmeaCountries); ++i) { + region_map.emplace(kEmeaCountries[i], kEmea); + } + + for (size_t i = 0; i < base::size(kEuCountries); ++i) { + region_map.emplace(kEuCountries[i], kEu); + } + return region_map; +} + +// Reads device region from VPD. Returns "us" in case of read or parsing errors. +std::string ReadDeviceRegionFromVpd() { + std::string region = "us"; + chromeos::system::StatisticsProvider* provider = + chromeos::system::StatisticsProvider::GetInstance(); + bool region_found = + provider->GetMachineStatistic(chromeos::system::kRegionKey, ®ion); + if (region_found) { + // We only need the first part of the complex region codes like ca.ansi. + std::vector<std::string> region_pieces = base::SplitString( + region, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + if (!region_pieces.empty()) + region = region_pieces[0]; + } else { + LOG(WARNING) << "Device region for Play Store ToS not found in VPD - " + "defaulting to US."; + } + return base::ToLowerASCII(region); +} + +// Loads bundled terms of service contents (Eula, OEM Eula, Play Store Terms). +// The online version of terms is fetched in OOBE screen javascript. This is +// intentional because chrome://terms runs in a privileged webui context and +// should never load from untrusted places. class ChromeOSTermsHandler : public base::RefCountedThreadSafe<ChromeOSTermsHandler> { public: static void Start(const std::string& path, - const content::URLDataSource::GotDataCallback& callback) { + const content::URLDataSource::GotDataCallback& callback, + const base::FilePath& chromeos_assets_path) { scoped_refptr<ChromeOSTermsHandler> handler( - new ChromeOSTermsHandler(path, callback)); + new ChromeOSTermsHandler(path, callback, chromeos_assets_path)); handler->StartOnUIThread(); } @@ -109,12 +180,13 @@ class ChromeOSTermsHandler friend class base::RefCountedThreadSafe<ChromeOSTermsHandler>; ChromeOSTermsHandler(const std::string& path, - const content::URLDataSource::GotDataCallback& callback) - : path_(path), - callback_(callback), - // Previously we were using "initial locale" http://crbug.com/145142 - locale_(g_browser_process->GetApplicationLocale()) { - } + const content::URLDataSource::GotDataCallback& callback, + const base::FilePath& chromeos_assets_path) + : path_(path), + callback_(callback), + // Previously we were using "initial locale" http://crbug.com/145142 + locale_(g_browser_process->GetApplicationLocale()), + chromeos_assets_path_(chromeos_assets_path) {} virtual ~ChromeOSTermsHandler() {} @@ -126,6 +198,19 @@ class ChromeOSTermsHandler FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, base::BindOnce(&ChromeOSTermsHandler::LoadOemEulaFileAsync, this), base::BindOnce(&ChromeOSTermsHandler::ResponseOnUIThread, this)); + } else if (path_ == chrome::kArcTermsURLPath) { + // Load ARC++ terms from the file. + base::PostTaskWithTraitsAndReply( + FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, + base::BindOnce(&ChromeOSTermsHandler::LoadArcTermsFileAsync, this), + base::BindOnce(&ChromeOSTermsHandler::ResponseOnUIThread, this)); + } else if (path_ == chrome::kArcPrivacyPolicyURLPath) { + // Load ARC++ privacy policy from the file. + base::PostTaskWithTraitsAndReply( + FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, + base::BindOnce(&ChromeOSTermsHandler::LoadArcPrivacyPolicyFileAsync, + this), + base::BindOnce(&ChromeOSTermsHandler::ResponseOnUIThread, this)); } else { // Load local ChromeOS terms from the file. base::PostTaskWithTraitsAndReply( @@ -170,11 +255,81 @@ class ChromeOSTermsHandler } } + void LoadArcPrivacyPolicyFileAsync() { + base::ScopedBlockingCall scoped_blocking_call( + base::BlockingType::MAY_BLOCK); + + for (const auto& locale : CreateArcLocaleLookupArray()) { + auto path = CreateArcPrivacyPolicyPath(locale.c_str()); + std::string contents; + if (base::ReadFileToString(path, &contents)) { + base::Base64Encode(contents, &contents_); + VLOG(1) << "Read offline Play Store privacy policy for: " << locale; + return; + } + LOG(WARNING) << "Could not find offline Play Store privacy policy for: " + << locale; + } + LOG(ERROR) << "Failed to load offline Play Store privacy policy"; + contents_.clear(); + } + + void LoadArcTermsFileAsync() { + base::ScopedBlockingCall scoped_blocking_call( + base::BlockingType::MAY_BLOCK); + + for (const auto& locale : CreateArcLocaleLookupArray()) { + auto path = CreateArcTermsPath(locale.c_str()); + std::string contents; + if (base::ReadFileToString(CreateArcTermsPath(locale), &contents_)) { + VLOG(1) << "Read offline Play Store terms for: " << locale; + return; + } + LOG(WARNING) << "Could not find offline Play Store terms for: " << locale; + } + LOG(ERROR) << "Failed to load offline Play Store ToS"; + contents_.clear(); + } + + std::vector<std::string> CreateArcLocaleLookupArray() { + // To get Play Store asset we look for the first locale match in the + // following order: + // * language and device region combination + // * default region (APAC, EMEA, EU) + // * en-US + // Note: AMERICAS region defaults to en-US and to simplify it is not + // included in the country region map. + std::vector<std::string> locale_lookup_array; + const std::string device_region = ReadDeviceRegionFromVpd(); + locale_lookup_array.push_back(base::StrCat( + {base::ToLowerASCII(language::ExtractBaseLanguage(locale_)), "-", + device_region})); + + const CountryRegionMap country_region_map = CreateCountryRegionMap(); + const auto region = country_region_map.find(device_region); + if (region != country_region_map.end()) { + locale_lookup_array.push_back(region->second.c_str()); + } + + locale_lookup_array.push_back("en-us"); + return locale_lookup_array; + } + + base::FilePath CreateArcTermsPath(const std::string& locale) const { + return chromeos_assets_path_.Append( + base::StringPrintf(chrome::kArcTermsPathFormat, locale.c_str())); + } + + base::FilePath CreateArcPrivacyPolicyPath(const std::string& locale) const { + return chromeos_assets_path_.Append(base::StringPrintf( + chrome::kArcPrivacyPolicyPathFormat, locale.c_str())); + } + void ResponseOnUIThread() { DCHECK_CURRENTLY_ON(BrowserThread::UI); // If we fail to load Chrome OS EULA from disk, load it from resources. - // Do nothing if OEM EULA load failed. - if (contents_.empty() && path_ != chrome::kOemEulaURLPath) + // Do nothing if OEM EULA or Play Store ToS load failed. + if (contents_.empty() && path_.empty()) contents_ = l10n_util::GetStringUTF8(IDS_TERMS_HTML); callback_.Run(base::RefCountedString::TakeString(&contents_)); } @@ -188,6 +343,9 @@ class ChromeOSTermsHandler // Locale of the EULA. const std::string locale_; + // Path to Chrome OS assets. + const base::FilePath chromeos_assets_path_; + // EULA contents that was loaded from file. std::string contents_; @@ -463,7 +621,10 @@ void AboutUIHTMLSource::StartDataRequest( #if !defined(OS_ANDROID) } else if (source_name_ == chrome::kChromeUITermsHost) { #if defined(OS_CHROMEOS) - ChromeOSTermsHandler::Start(path, callback); + std::string assets_dir = chromeos_assets_dir_for_tests_.empty() + ? chrome::kChromeOSAssetPath + : chromeos_assets_dir_for_tests_; + ChromeOSTermsHandler::Start(path, callback, base::FilePath(assets_dir)); return; #else response = l10n_util::GetStringUTF8(IDS_TERMS_HTML); @@ -522,9 +683,9 @@ AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) #if !defined(OS_ANDROID) // Set up the chrome://theme/ source. - ThemeSource* theme = new ThemeSource(profile); - content::URLDataSource::Add(profile, theme); + content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile)); #endif - content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); + content::URLDataSource::Add( + profile, std::make_unique<AboutUIHTMLSource>(name, profile)); } diff --git a/chromium/chrome/browser/ui/webui/about_ui.h b/chromium/chrome/browser/ui/webui/about_ui.h index a6e0a7f7356..a13d684ba71 100644 --- a/chromium/chrome/browser/ui/webui/about_ui.h +++ b/chromium/chrome/browser/ui/webui/about_ui.h @@ -20,6 +20,7 @@ class AboutUIHTMLSource : public content::URLDataSource { public: // Construct a data source for the specified |source_name|. AboutUIHTMLSource(const std::string& source_name, Profile* profile); + ~AboutUIHTMLSource() override; // content::URLDataSource implementation. std::string GetSource() const override; @@ -39,12 +40,19 @@ class AboutUIHTMLSource : public content::URLDataSource { Profile* profile() { return profile_; } - private: - ~AboutUIHTMLSource() override; + // Overrides Chrome OS assets location for tests. + void SetChromeOSAssetsDirForTests(const std::string& path) { + chromeos_assets_dir_for_tests_ = path; + } + private: std::string source_name_; Profile* profile_; + // Directory to be used as Chrome OS assets location in tests. If set, it + // overrides chrome::kChromeOSAssetPath. + std::string chromeos_assets_dir_for_tests_; + DISALLOW_COPY_AND_ASSIGN(AboutUIHTMLSource); }; diff --git a/chromium/chrome/browser/ui/webui/about_ui_unittest.cc b/chromium/chrome/browser/ui/webui/about_ui_unittest.cc new file mode 100644 index 00000000000..73b463269ed --- /dev/null +++ b/chromium/chrome/browser/ui/webui/about_ui_unittest.cc @@ -0,0 +1,435 @@ +// 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/about_ui.h" + +#include <memory> +#include <string> + +#include "base/base64.h" +#include "base/bind.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/files/scoped_temp_dir.h" +#include "base/macros.h" +#include "base/memory/ref_counted_memory.h" +#include "base/strings/string_piece.h" +#include "base/strings/string_util.h" +#include "base/task/post_task.h" +#include "base/test/scoped_task_environment.h" +#include "chrome/common/url_constants.h" +#include "chrome/common/webui_url_constants.h" +#include "chrome/test/base/scoped_browser_locale.h" +#include "chromeos/system/fake_statistics_provider.h" +#include "chromeos/system/statistics_provider.h" +#include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/resource_request_info.h" +#include "content/public/test/test_browser_thread_bundle.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +class TestDataReceiver { + public: + TestDataReceiver() = default; + virtual ~TestDataReceiver() = default; + + bool data_received() const { return data_received_; } + + std::string data() const { return data_; } + + std::string Base64DecodedData() const { + std::string decoded; + base::Base64Decode(data_, &decoded); + return decoded; + } + + void OnDataReceived(scoped_refptr<base::RefCountedMemory> bytes) { + data_received_ = true; + data_ = base::StringPiece(reinterpret_cast<const char*>(bytes->front()), + bytes->size()) + .as_string(); + } + + private: + bool data_received_ = false; + std::string data_; + + DISALLOW_COPY_AND_ASSIGN(TestDataReceiver); +}; + +} // namespace + +// Base class for ChromeOS offline terms tests. +class ChromeOSTermsTest : public testing::Test { + protected: + ChromeOSTermsTest() + : scoped_task_environment_( + base::test::ScopedTaskEnvironment::MainThreadType::UI) {} + ~ChromeOSTermsTest() override = default; + + void SetUp() override { + // Create root tmp directory for fake ARC ToS data. + base::FilePath root_path; + base::CreateNewTempDirectory(FILE_PATH_LITERAL(""), &root_path); + ASSERT_TRUE(root_dir_.Set(root_path)); + arc_tos_dir_ = root_dir_.GetPath().Append("arc_tos"); + ASSERT_TRUE(base::CreateDirectory(arc_tos_dir_)); + + tested_html_source_ = std::make_unique<AboutUIHTMLSource>( + chrome::kChromeUITermsHost, nullptr); + tested_html_source_->SetChromeOSAssetsDirForTests( + root_dir_.GetPath().value()); + } + + // Creates directory for the given |locale| that contains terms.html. Writes + // the |locale| string to the created file. + bool CreateTermsForLocale(const std::string& locale) { + base::FilePath dir = arc_tos_dir_.Append(base::ToLowerASCII(locale)); + if (!base::CreateDirectory(dir)) + return false; + + if (base::WriteFile(dir.AppendASCII("terms.html"), locale.c_str(), + locale.length()) != static_cast<int>(locale.length())) { + return false; + } + return true; + } + + // Creates directory for the given |locale| that contains privacy_policy.pdf. + // Writes the |locale| string to the created file. + bool CreatePrivacyPolicyForLocale(const std::string& locale) { + base::FilePath dir = arc_tos_dir_.Append(base::ToLowerASCII(locale)); + if (!base::CreateDirectory(dir)) + return false; + + if (base::WriteFile(dir.AppendASCII("privacy_policy.pdf"), locale.c_str(), + locale.length()) != static_cast<int>(locale.length())) { + return false; + } + return true; + } + + // Sets device region in VPD. + void SetRegion(const std::string& region) { + statistics_provider_.SetMachineStatistic(chromeos::system::kRegionKey, + region); + } + + // Starts data request with the |request_url|. + void StartRequest(const std::string& request_url, + TestDataReceiver* data_receiver) { + content::ResourceRequestInfo::WebContentsGetter wc_getter; + tested_html_source_->StartDataRequest( + request_url, std::move(wc_getter), + base::BindRepeating(&TestDataReceiver::OnDataReceived, + base::Unretained(data_receiver))); + scoped_task_environment_.RunUntilIdle(); + } + + private: + base::ScopedTempDir root_dir_; + base::FilePath arc_tos_dir_; + + base::test::ScopedTaskEnvironment scoped_task_environment_; + content::TestBrowserThreadBundle test_browser_thread_bundle_; + + chromeos::system::ScopedFakeStatisticsProvider statistics_provider_; + + std::unique_ptr<AboutUIHTMLSource> tested_html_source_; + + DISALLOW_COPY_AND_ASSIGN(ChromeOSTermsTest); +}; + +TEST_F(ChromeOSTermsTest, NoData) { + SetRegion("ca"); + ScopedBrowserLocale browser_locale("en-CA"); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("", terms_data_receiver.data()); + + TestDataReceiver privacy_policy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_policy_data_receiver); + + EXPECT_TRUE(privacy_policy_data_receiver.data_received()); + EXPECT_EQ("", privacy_policy_data_receiver.data()); +} + +// Demo mode ARC++ ToS and privacy policy test. +class DemoModeChromeOSTermsTest : public ChromeOSTermsTest { + protected: + DemoModeChromeOSTermsTest() = default; + ~DemoModeChromeOSTermsTest() override = default; + + void SetUp() override { + ChromeOSTermsTest::SetUp(); + AddDemoModeLocale(); + } + + // Adds locales supported by demo mode. + void AddDemoModeLocale() { + ASSERT_TRUE(CreateTermsForLocale("apac")); + ASSERT_TRUE(CreateTermsForLocale("da-DK")); + ASSERT_TRUE(CreateTermsForLocale("de-de")); + ASSERT_TRUE(CreateTermsForLocale("emea")); + ASSERT_TRUE(CreateTermsForLocale("en-CA")); + ASSERT_TRUE(CreateTermsForLocale("en-GB")); + ASSERT_TRUE(CreateTermsForLocale("en-IE")); + ASSERT_TRUE(CreateTermsForLocale("en-US")); + ASSERT_TRUE(CreateTermsForLocale("eu")); + ASSERT_TRUE(CreateTermsForLocale("fi-FI")); + ASSERT_TRUE(CreateTermsForLocale("fr-BE")); + ASSERT_TRUE(CreateTermsForLocale("fr-CA")); + ASSERT_TRUE(CreateTermsForLocale("fr-FR")); + ASSERT_TRUE(CreateTermsForLocale("ko-KR")); + ASSERT_TRUE(CreateTermsForLocale("nb-NO")); + ASSERT_TRUE(CreateTermsForLocale("nl-BE")); + ASSERT_TRUE(CreateTermsForLocale("nl-NL")); + ASSERT_TRUE(CreateTermsForLocale("sv-SE")); + + ASSERT_TRUE(CreatePrivacyPolicyForLocale("da-DK")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("de-de")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("en-US")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("eu")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("fi-FI")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("fr-BE")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("fr-CA")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("fr-FR")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("ko-KR")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("nb-NO")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("nl-BE")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("nl-NL")); + ASSERT_TRUE(CreatePrivacyPolicyForLocale("sv-SE")); + } + + private: + DISALLOW_COPY_AND_ASSIGN(DemoModeChromeOSTermsTest); +}; + +TEST_F(DemoModeChromeOSTermsTest, TermsSimpleRegion) { + SetRegion("ca"); + for (const char* locale : {"en-CA", "fr-CA"}) { + ScopedBrowserLocale browser_locale(locale); + + TestDataReceiver data_receiver; + StartRequest(chrome::kArcTermsURLPath, &data_receiver); + + EXPECT_TRUE(data_receiver.data_received()); + EXPECT_EQ(locale, data_receiver.data()); + } +} + +TEST_F(DemoModeChromeOSTermsTest, ComplexRegion) { + const std::string kLocale = "en-CA"; + ScopedBrowserLocale browser_locale(kLocale); + for (const char* region : + {"ca.hybridansi", "ca.ansi", "ca.multix", "ca.fr"}) { + SetRegion(region); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ(kLocale, terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + // Privacy policy for en-CA defaults to en-US. + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("en-US", privacy_data_receiver.Base64DecodedData()); + } +} + +TEST_F(DemoModeChromeOSTermsTest, NotCaseSensitive) { + SetRegion("CA"); + for (const char* locale : {"EN-CA", "en-CA", "EN-ca"}) { + ScopedBrowserLocale browser_locale(locale); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("en-CA", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + // Privacy policy for en-CA defaults to en-US. + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("en-US", privacy_data_receiver.Base64DecodedData()); + } +} + +TEST_F(DemoModeChromeOSTermsTest, DefaultsForEuRegion) { + const std::string kLocale = "pl-PL"; + ScopedBrowserLocale browser_locale(kLocale); + SetRegion("pl"); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("eu", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("eu", privacy_data_receiver.Base64DecodedData()); +} + +TEST_F(DemoModeChromeOSTermsTest, DefaultsForEmeaRegion) { + const std::string kLocale = "fr-CH"; + ScopedBrowserLocale browser_locale(kLocale); + SetRegion("ch"); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("emea", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + // Privacy policy for EMEA defaults to en-US. + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("en-US", privacy_data_receiver.Base64DecodedData()); +} + +TEST_F(DemoModeChromeOSTermsTest, DefaultsForApacRegion) { + const std::string kLocale = "en-PH"; + ScopedBrowserLocale browser_locale(kLocale); + SetRegion("ph"); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("apac", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + // Privacy policy for APAC defaults to en-US. + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("en-US", privacy_data_receiver.Base64DecodedData()); +} + +TEST_F(DemoModeChromeOSTermsTest, DefaultsForAmericasRegion) { + const std::string kLocale = "en-MX"; + ScopedBrowserLocale browser_locale(kLocale); + SetRegion("mx"); + + // Both ToS and privacy policy default to en-US for AMERICAS. + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("en-US", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("en-US", privacy_data_receiver.Base64DecodedData()); +} + +TEST_F(DemoModeChromeOSTermsTest, DefaultsToEnUs) { + const std::string kLocale = "en-SA"; + ScopedBrowserLocale browser_locale(kLocale); + SetRegion("sa"); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("en-US", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("en-US", privacy_data_receiver.Base64DecodedData()); +} + +TEST_F(DemoModeChromeOSTermsTest, NoLangCountryCombination) { + SetRegion("be"); + { + const std::string kLocale = "nl-BE"; + ScopedBrowserLocale browser_locale(kLocale); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ(kLocale, terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ(kLocale, privacy_data_receiver.Base64DecodedData()); + } + { + const std::string kLocale = "de-BE"; + ScopedBrowserLocale browser_locale(kLocale); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + // No language - country combination - defaults to region. + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("eu", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("eu", privacy_data_receiver.Base64DecodedData()); + } +} + +TEST_F(DemoModeChromeOSTermsTest, InvalidRegion) { + const std::string kLocale = "da-DK"; + ScopedBrowserLocale browser_locale(kLocale); + for (const char* region : {"", " ", ".", "..", "-", "xyz"}) { + SetRegion(region); + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("en-US", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("en-US", privacy_data_receiver.Base64DecodedData()); + } +} + +TEST_F(DemoModeChromeOSTermsTest, InvalidLocale) { + SetRegion("se"); + for (const char* locale : {"", " ", ".", "-", "-sv"}) { + ScopedBrowserLocale browser_locale(locale); + + TestDataReceiver terms_data_receiver; + StartRequest(chrome::kArcTermsURLPath, &terms_data_receiver); + + EXPECT_TRUE(terms_data_receiver.data_received()); + EXPECT_EQ("eu", terms_data_receiver.data()); + + TestDataReceiver privacy_data_receiver; + StartRequest(chrome::kArcPrivacyPolicyURLPath, &privacy_data_receiver); + + EXPECT_TRUE(privacy_data_receiver.data_received()); + EXPECT_EQ("eu", privacy_data_receiver.Base64DecodedData()); + } +} diff --git a/chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc b/chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc index 57d7d129909..cff5e1ec488 100644 --- a/chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc +++ b/chromium/chrome/browser/ui/webui/app_launcher_login_handler.cc @@ -22,7 +22,6 @@ #include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_promo_util.h" -#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_window.h" @@ -32,7 +31,6 @@ #include "chrome/common/url_constants.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" -#include "components/browser_sync/profile_sync_service.h" #include "components/prefs/pref_service.h" #include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_metrics.h" diff --git a/chromium/chrome/browser/ui/webui/browsing_history_handler.cc b/chromium/chrome/browser/ui/webui/browsing_history_handler.cc index 73a0891dcac..5b62926b295 100644 --- a/chromium/chrome/browser/ui/webui/browsing_history_handler.cc +++ b/chromium/chrome/browser/ui/webui/browsing_history_handler.cc @@ -300,8 +300,7 @@ void BrowsingHistoryHandler::HandleQueryHistoryContinuation( void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) { std::vector<BrowsingHistoryService::HistoryEntry> items_to_remove; items_to_remove.reserve(args->GetSize()); - for (base::ListValue::const_iterator it = args->begin(); - it != args->end(); ++it) { + for (auto it = args->begin(); it != args->end(); ++it) { const base::DictionaryValue* deletion = NULL; base::string16 url; const base::ListValue* timestamps = NULL; @@ -317,7 +316,7 @@ void BrowsingHistoryHandler::HandleRemoveVisits(const base::ListValue* args) { entry.url = GURL(url); double timestamp; - for (base::ListValue::const_iterator ts_iterator = timestamps->begin(); + for (auto ts_iterator = timestamps->begin(); ts_iterator != timestamps->end(); ++ts_iterator) { if (!ts_iterator->GetAsDouble(×tamp)) { NOTREACHED() << "Unable to extract visit timestamp."; diff --git a/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc b/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc index e73ade2e2e0..dc91141d72f 100644 --- a/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc @@ -9,6 +9,7 @@ #include <set> #include <utility> +#include "base/bind.h" #include "base/macros.h" #include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" @@ -107,14 +108,15 @@ class BrowsingHistoryHandlerTest : public ::testing::Test { public: void SetUp() override { TestingProfile::Builder builder; - builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - &BuildFakeProfileOAuth2TokenService); + builder.AddTestingFactory( + ProfileOAuth2TokenServiceFactory::GetInstance(), + base::BindRepeating(&BuildFakeProfileOAuth2TokenService)); builder.AddTestingFactory(SigninManagerFactory::GetInstance(), - &BuildFakeSigninManagerBase); + base::BindRepeating(&BuildFakeSigninManagerBase)); builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(), - &BuildFakeSyncService); + base::BindRepeating(&BuildFakeSyncService)); builder.AddTestingFactory(WebHistoryServiceFactory::GetInstance(), - &BuildFakeWebHistoryService); + base::BindRepeating(&BuildFakeWebHistoryService)); profile_ = builder.Build(); profile_->CreateBookmarkModel(false); diff --git a/chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc b/chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc index 156ffb83470..e817c047a56 100644 --- a/chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc +++ b/chromium/chrome/browser/ui/webui/certificate_viewer_webui.cc @@ -195,8 +195,7 @@ std::string CertificateViewerModalDialog::GetDialogArgs() const { std::vector<std::string> usages; x509_certificate_model::GetUsageStrings(cert_hnd, &usages); std::string usagestr; - for (std::vector<std::string>::iterator it = usages.begin(); - it != usages.end(); ++it) { + for (auto it = usages.begin(); it != usages.end(); ++it) { if (usagestr.length() > 0) { usagestr += "\n"; } @@ -253,8 +252,7 @@ std::string CertificateViewerModalDialog::GetDialogArgs() const { // Certificate hierarchy is constructed from bottom up. std::unique_ptr<base::ListValue> children; int index = 0; - for (net::ScopedCERTCertificateList::const_iterator i = nss_certs_.begin(); - i != nss_certs_.end(); ++i, ++index) { + for (auto i = nss_certs_.begin(); i != nss_certs_.end(); ++i, ++index) { std::unique_ptr<base::DictionaryValue> cert_node( new base::DictionaryValue()); base::ListValue cert_details; diff --git a/chromium/chrome/browser/ui/webui/certificates_handler.cc b/chromium/chrome/browser/ui/webui/certificates_handler.cc index 57ccbca195b..58f6be72e19 100644 --- a/chromium/chrome/browser/ui/webui/certificates_handler.cc +++ b/chromium/chrome/browser/ui/webui/certificates_handler.cc @@ -976,8 +976,10 @@ void CertificatesHandler::CertificateManagerModelReady() { certificate_manager_model_->is_user_db_available()); base::Value tpm_available_value( certificate_manager_model_->is_tpm_available()); - FireWebUIListener("certificates-model-ready", user_db_available_value, - tpm_available_value); + if (IsJavascriptAllowed()) { + FireWebUIListener("certificates-model-ready", user_db_available_value, + tpm_available_value); + } certificate_manager_model_->Refresh(); } @@ -1070,8 +1072,10 @@ void CertificatesHandler::PopulateTree(const std::string& tab_name, } std::sort(nodes.GetList().begin(), nodes.GetList().end(), comparator); - FireWebUIListener("certificates-changed", base::Value(tab_name), - std::move(nodes)); + if (IsJavascriptAllowed()) { + FireWebUIListener("certificates-changed", base::Value(tab_name), + std::move(nodes)); + } } void CertificatesHandler::ResolveCallback(const base::Value& response) { diff --git a/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index ce230a0a720..a1727f46d11 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 @@ -6,8 +6,6 @@ #include <stddef.h> -#include <vector> - #include "base/bind.h" #include "base/feature_list.h" #include "base/location.h" @@ -109,6 +107,7 @@ #if !defined(OS_ANDROID) #include "chrome/browser/media/router/media_router_feature.h" +#include "chrome/browser/ui/webui/management_ui.h" #include "chrome/browser/ui/webui/media_router/media_router_internals_ui.h" #include "chrome/browser/ui/webui/media_router/media_router_ui.h" #endif @@ -121,6 +120,7 @@ #include "chrome/browser/ui/webui/offline/offline_internals_ui.h" #include "chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h" #include "chrome/browser/ui/webui/webapks_ui.h" +#include "components/feed/feed_feature_list.h" #else #include "chrome/browser/ui/webui/devtools_ui.h" #include "chrome/browser/ui/webui/inspect_ui.h" @@ -178,13 +178,13 @@ #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/welcome_ui.h" +#include "chrome/browser/ui/webui/welcome/welcome_ui.h" #endif #if defined(OS_WIN) #include "chrome/browser/ui/webui/conflicts/conflicts_ui.h" #include "chrome/browser/ui/webui/set_as_default_browser_ui_win.h" -#include "chrome/browser/ui/webui/welcome_win10_ui.h" +#include "chrome/browser/ui/webui/welcome/welcome_win10_ui.h" #endif #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) @@ -528,7 +528,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, if (url.host_piece() == chrome::kChromeUIOfflineInternalsHost) return &NewWebUI<OfflineInternalsUI>; if (url.host_piece() == chrome::kChromeUISnippetsInternalsHost && - !profile->IsOffTheRecord()) + !profile->IsOffTheRecord() && + !base::FeatureList::IsEnabled(feed::kInterestFeedContentSuggestions)) return &NewWebUI<SnippetsInternalsUI>; if (url.host_piece() == chrome::kChromeUIWebApksHost) return &NewWebUI<WebApksUI>; @@ -592,6 +593,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, PolicyToolUI::IsEnabled()) { return &NewWebUI<PolicyToolUI>; } + if (url.host_piece() == chrome::kChromeUIManagementHost) + return &NewWebUI<ManagementUI>; #endif #if BUILDFLAG(ENABLE_EXTENSIONS) diff --git a/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h b/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h index b0a3fa7365b..74a21403b93 100644 --- a/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h +++ b/chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.h @@ -5,6 +5,9 @@ #ifndef CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_CONTROLLER_FACTORY_H_ #define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_UI_CONTROLLER_FACTORY_H_ +#include <memory> +#include <vector> + #include "base/macros.h" #include "base/memory/singleton.h" #include "components/favicon_base/favicon_callback.h" diff --git a/chromium/chrome/browser/ui/webui/chromeos/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/OWNERS index b63e5656fa7..0c7e289e51e 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/OWNERS +++ b/chromium/chrome/browser/ui/webui/chromeos/OWNERS @@ -3,7 +3,6 @@ michaelpg@chromium.org satorux@chromium.org stevenjb@chromium.org xiyuan@chromium.org -zelidrag@chromium.org per-file network*=stevenjb@chromium.org per-file drive_internals_ui.*=file://ui/file_manager/OWNERS diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc deleted file mode 100644 index c550b13ee46..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h" - -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h" -#include "chromeos/services/assistant/public/mojom/constants.mojom.h" -#include "chromeos/services/assistant/public/proto/settings_ui.pb.h" -#include "components/arc/arc_prefs.h" -#include "components/login/localized_values_builder.h" -#include "components/prefs/pref_service.h" -#include "services/service_manager/public/cpp/connector.h" - -namespace chromeos { - -namespace { - -constexpr char kJsScreenPath[] = "assistantOptInFlow"; - -} // namespace - -AssistantOptInHandler::AssistantOptInHandler( - JSCallsContainer* js_calls_container) - : BaseWebUIHandler(js_calls_container), weak_factory_(this) { - DCHECK(js_calls_container); - set_call_js_prefix(kJsScreenPath); -} - -AssistantOptInHandler::~AssistantOptInHandler() { - if (arc::VoiceInteractionControllerClient::Get()) { - arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this); - } -} - -void AssistantOptInHandler::DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) {} - -void AssistantOptInHandler::RegisterMessages() { - AddPrefixedCallback("initialized", &AssistantOptInHandler::HandleInitialized); - AddPrefixedCallback("hotwordResult", - &AssistantOptInHandler::HandleHotwordResult); - AddPrefixedCallback("flowFinished", - &AssistantOptInHandler::HandleFlowFinished); -} - -void AssistantOptInHandler::Initialize() { - if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() == - ash::mojom::VoiceInteractionState::NOT_READY) { - arc::VoiceInteractionControllerClient::Get()->AddObserver(this); - } else { - BindAssistantSettingsManager(); - } -} - -void AssistantOptInHandler::ShowNextScreen() { - CallJSOrDefer("showNextScreen"); -} - -void AssistantOptInHandler::OnActivityControlOptInResult(bool opted_in) { - Profile* profile = Profile::FromWebUI(web_ui()); - if (opted_in) { - RecordAssistantOptInStatus(ACTIVITY_CONTROL_ACCEPTED); - settings_manager_->UpdateSettings( - GetSettingsUiUpdate(consent_token_).SerializeAsString(), - base::BindOnce(&AssistantOptInHandler::OnUpdateSettingsResponse, - weak_factory_.GetWeakPtr())); - } else { - RecordAssistantOptInStatus(ACTIVITY_CONTROL_SKIPPED); - profile->GetPrefs()->SetBoolean( - arc::prefs::kVoiceInteractionActivityControlAccepted, false); - CallJSOrDefer("closeDialog"); - } - - RecordActivityControlConsent(profile, ui_audit_key_, opted_in); -} - -void AssistantOptInHandler::OnEmailOptInResult(bool opted_in) { - if (!email_optin_needed_) { - DCHECK(!opted_in); - ShowNextScreen(); - return; - } - - RecordAssistantOptInStatus(opted_in ? EMAIL_OPTED_IN : EMAIL_OPTED_OUT); - settings_manager_->UpdateSettings( - GetEmailOptInUpdate(opted_in).SerializeAsString(), - base::BindOnce(&AssistantOptInHandler::OnUpdateSettingsResponse, - weak_factory_.GetWeakPtr())); -} - -void AssistantOptInHandler::OnStateChanged( - ash::mojom::VoiceInteractionState state) { - if (state != ash::mojom::VoiceInteractionState::NOT_READY) { - BindAssistantSettingsManager(); - arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this); - } -} - -void AssistantOptInHandler::BindAssistantSettingsManager() { - if (settings_manager_.is_bound()) - return; - - // Set up settings mojom. - service_manager::Connector* connector = - content::BrowserContext::GetConnectorFor(Profile::FromWebUI(web_ui())); - connector->BindInterface(assistant::mojom::kServiceName, - mojo::MakeRequest(&settings_manager_)); - - SendGetSettingsRequest(); -} - -void AssistantOptInHandler::SendGetSettingsRequest() { - assistant::SettingsUiSelector selector = GetSettingsUiSelector(); - settings_manager_->GetSettings( - selector.SerializeAsString(), - base::BindOnce(&AssistantOptInHandler::OnGetSettingsResponse, - weak_factory_.GetWeakPtr())); -} - -void AssistantOptInHandler::ReloadContent(const base::Value& dict) { - CallJSOrDefer("reloadContent", dict); -} - -void AssistantOptInHandler::AddSettingZippy(const std::string& type, - const base::Value& data) { - CallJSOrDefer("addSettingZippy", type, data); -} - -void AssistantOptInHandler::OnGetSettingsResponse(const std::string& settings) { - assistant::SettingsUi settings_ui; - settings_ui.ParseFromString(settings); - - DCHECK(settings_ui.has_consent_flow_ui()); - - RecordAssistantOptInStatus(FLOW_STARTED); - auto consent_ui = settings_ui.consent_flow_ui().consent_ui(); - auto activity_control_ui = consent_ui.activity_control_ui(); - auto third_party_disclosure_ui = consent_ui.third_party_disclosure_ui(); - - consent_token_ = activity_control_ui.consent_token(); - ui_audit_key_ = activity_control_ui.ui_audit_key(); - - // Process activity control data. - if (!activity_control_ui.setting_zippy().size()) { - // No need to consent. Move to the next screen. - activity_control_needed_ = false; - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted, - true); - ShowNextScreen(); - } else { - AddSettingZippy("settings", - CreateZippyData(activity_control_ui.setting_zippy())); - } - - // Process third party disclosure data. - AddSettingZippy("disclosure", CreateDisclosureData( - third_party_disclosure_ui.disclosures())); - - // Process get more data. - email_optin_needed_ = settings_ui.has_email_opt_in_ui() && - settings_ui.email_opt_in_ui().has_title(); - AddSettingZippy("get-more", CreateGetMoreData(email_optin_needed_, - settings_ui.email_opt_in_ui())); - - // Pass string constants dictionary. - ReloadContent(GetSettingsUiStrings(settings_ui, activity_control_needed_)); -} - -void AssistantOptInHandler::OnUpdateSettingsResponse( - const std::string& result) { - assistant::SettingsUiUpdateResult ui_result; - ui_result.ParseFromString(result); - - if (ui_result.has_consent_flow_update_result()) { - if (ui_result.consent_flow_update_result().update_status() != - assistant::ConsentFlowUiUpdateResult::SUCCESS) { - // TODO(updowndta): Handle consent update failure. - LOG(ERROR) << "Consent udpate error."; - } else if (activity_control_needed_) { - activity_control_needed_ = false; - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted, - true); - } - } - - if (ui_result.has_email_opt_in_update_result()) { - if (ui_result.email_opt_in_update_result().update_status() != - assistant::EmailOptInUpdateResult::SUCCESS) { - // TODO(updowndta): Handle email optin update failure. - LOG(ERROR) << "Email OptIn udpate error."; - } - // Update hotword will cause Assistant restart. In order to make sure email - // optin request is successfully sent to server, update the hotword after - // email optin result has been received. - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, - enable_hotword_); - } - - ShowNextScreen(); -} - -void AssistantOptInHandler::HandleInitialized() { - ExecuteDeferredJSCalls(); -} - -void AssistantOptInHandler::HandleHotwordResult(bool enable_hotword) { - enable_hotword_ = enable_hotword; - - if (!email_optin_needed_) { - // No need to send email optin result. Safe to update hotword pref and - // restart Assistant here. - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, - enable_hotword); - } -} - -void AssistantOptInHandler::HandleFlowFinished() { - CallJSOrDefer("closeDialog"); -} - -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h deleted file mode 100644 index 833d94ccf03..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_HANDLER_H_ - -#include <memory> -#include <string> - -#include "base/macros.h" -#include "chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h" -#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" -#include "chromeos/services/assistant/public/mojom/settings.mojom.h" - -namespace chromeos { - -class AssistantOptInHandler - : public BaseWebUIHandler, - public arc::VoiceInteractionControllerClient::Observer { - public: - explicit AssistantOptInHandler(JSCallsContainer* js_calls_container); - ~AssistantOptInHandler() override; - - // BaseWebUIHandler: - void DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) override; - void RegisterMessages() override; - void Initialize() override; - - // Send messages to the page. - void ShowNextScreen(); - - // Handle user opt-in result. - void OnActivityControlOptInResult(bool opted_in); - void OnEmailOptInResult(bool opted_in); - - private: - // arc::VoiceInteractionControllerClient::Observer overrides - void OnStateChanged(ash::mojom::VoiceInteractionState state) override; - - // Connect to assistant settings manager. - void BindAssistantSettingsManager(); - - // Send GetSettings request for the opt-in UI. - void SendGetSettingsRequest(); - - // Send message and consent data to the page. - void ReloadContent(const base::Value& dict); - void AddSettingZippy(const std::string& type, const base::Value& data); - - // Handle response from the settings manager. - void OnGetSettingsResponse(const std::string& settings); - void OnUpdateSettingsResponse(const std::string& settings); - - // Handler for JS WebUI message. - void HandleInitialized(); - void HandleHotwordResult(bool enable_hotword); - void HandleFlowFinished(); - - // Consent token used to complete the opt-in. - std::string consent_token_; - - // An opaque token for audit record. - std::string ui_audit_key_; - - // Whether activity control is needed for user. - bool activity_control_needed_ = true; - - // Whether email optin is needed for user. - bool email_optin_needed_ = false; - - // Whether user chose to enable hotword. - bool enable_hotword_ = true; - - assistant::mojom::AssistantSettingsManagerPtr settings_manager_; - base::WeakPtrFactory<AssistantOptInHandler> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(AssistantOptInHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_ASSISTANT_OPTIN_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc index 16f3211e37d..d20d4ac5bad 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 @@ -12,15 +12,12 @@ #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/assistant_optin/get_more_screen_handler.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" #include "chrome/common/url_constants.h" #include "chrome/grit/browser_resources.h" #include "components/arc/arc_prefs.h" #include "components/prefs/pref_service.h" +#include "content/public/browser/host_zoom_map.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" @@ -41,72 +38,29 @@ AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui) content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUIAssistantOptInHost); - js_calls_container_ = std::make_unique<JSCallsContainer>(); - - auto assistant_handler = - std::make_unique<AssistantOptInHandler>(js_calls_container_.get()); - assistant_handler_ = assistant_handler.get(); - AddScreenHandler(std::move(assistant_handler)); - assistant_handler_->Initialize(); - - AddScreenHandler(std::make_unique<ValuePropScreenHandler>( - base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr()))); - AddScreenHandler(std::make_unique<ThirdPartyScreenHandler>( - base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr()))); - AddScreenHandler(std::make_unique<GetMoreScreenHandler>( - base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr()))); - AddScreenHandler(std::make_unique<ReadyScreenHandler>( - base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr()))); + auto assistant_handler = std::make_unique<AssistantOptInFlowScreenHandler>(); + auto* assistant_handler_ptr = assistant_handler.get(); + web_ui->AddMessageHandler(std::move(assistant_handler)); + assistant_handler_ptr->SetupAssistantConnection(); base::DictionaryValue localized_strings; - for (auto* handler : screen_handlers_) - handler->GetLocalizedStrings(&localized_strings); + assistant_handler_ptr->GetLocalizedStrings(&localized_strings); source->AddLocalizedStrings(localized_strings); - source->SetJsonPath("strings.js"); source->AddResourcePath("assistant_optin.js", IDR_ASSISTANT_OPTIN_JS); source->AddResourcePath("assistant_logo.png", IDR_ASSISTANT_LOGO_PNG); source->SetDefaultResource(IDR_ASSISTANT_OPTIN_HTML); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); - // Make sure enable Assistant service since we need it during the flow. - PrefService* prefs = Profile::FromWebUI(web_ui)->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true); + // Do not zoom for Assistant opt-in web contents. + content::HostZoomMap* zoom_map = + content::HostZoomMap::GetForWebContents(web_ui->GetWebContents()); + DCHECK(zoom_map); + zoom_map->SetZoomLevelForHost(web_ui->GetWebContents()->GetURL().host(), 0); } AssistantOptInUI::~AssistantOptInUI() = default; -void AssistantOptInUI::AddScreenHandler( - std::unique_ptr<BaseWebUIHandler> handler) { - screen_handlers_.push_back(handler.get()); - web_ui()->AddMessageHandler(std::move(handler)); -} - -void AssistantOptInUI::OnExit(AssistantOptInScreenExitCode exit_code) { - switch (exit_code) { - case AssistantOptInScreenExitCode::VALUE_PROP_SKIPPED: - assistant_handler_->OnActivityControlOptInResult(false); - break; - case AssistantOptInScreenExitCode::VALUE_PROP_ACCEPTED: - assistant_handler_->OnActivityControlOptInResult(true); - break; - case AssistantOptInScreenExitCode::THIRD_PARTY_CONTINUED: - assistant_handler_->ShowNextScreen(); - break; - case AssistantOptInScreenExitCode::EMAIL_OPTED_IN: - assistant_handler_->OnEmailOptInResult(true); - break; - case AssistantOptInScreenExitCode::EMAIL_OPTED_OUT: - assistant_handler_->OnEmailOptInResult(false); - break; - case AssistantOptInScreenExitCode::READY_SCREEN_CONTINUED: - CloseDialog(nullptr); - break; - default: - NOTREACHED(); - } -} - // AssistantOptInDialog // static diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h index 062cf1b49be..a4667347377 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h @@ -10,8 +10,8 @@ #include "ash/public/interfaces/assistant_controller.mojom.h" #include "base/callback.h" #include "base/macros.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h" #include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h" +#include "chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" #include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h" #include "content/public/browser/web_ui_controller.h" @@ -26,15 +26,6 @@ class AssistantOptInUI : public ui::WebDialogUI { ~AssistantOptInUI() override; private: - // Add message handler for optin screens. - void AddScreenHandler(std::unique_ptr<BaseWebUIHandler> handler); - - // Called by a screen when user's done with it. - void OnExit(AssistantOptInScreenExitCode exit_code); - - AssistantOptInHandler* assistant_handler_ = nullptr; - std::unique_ptr<JSCallsContainer> js_calls_container_; - std::vector<BaseWebUIHandler*> screen_handlers_; base::WeakPtrFactory<AssistantOptInUI> weak_factory_; DISALLOW_COPY_AND_ASSIGN(AssistantOptInUI); 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 fbce386db70..bfbed7e9d30 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 @@ -132,7 +132,7 @@ base::Value CreateGetMoreData(bool email_optin_needed, context_data.SetKey( "iconUri", base::Value("https://www.gstatic.com/images/icons/material/system/" - "2x/laptop_chromebook_grey600_24dp.png")); + "2x/screen_search_desktop_grey600_24dp.png")); get_more_data.GetList().push_back(std::move(context_data)); // Process email optin data. @@ -158,7 +158,7 @@ base::Value GetSettingsUiStrings(const assistant::SettingsUi& settings_ui, auto third_party_disclosure_ui = consent_ui.third_party_disclosure_ui(); base::Value dictionary(base::Value::Type::DICTIONARY); - // Add activity controll string constants. + // Add activity control string constants. if (activity_control_needed) { scoped_refptr<base::RefCountedMemory> image = chromeos::UserImageSource::GetUserImage( 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 b1d35c07ce5..01f918cbd65 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 @@ -16,16 +16,6 @@ namespace chromeos { -enum class AssistantOptInScreenExitCode { - VALUE_PROP_SKIPPED = 0, - VALUE_PROP_ACCEPTED = 1, - THIRD_PARTY_CONTINUED = 2, - EMAIL_OPTED_IN = 3, - EMAIL_OPTED_OUT = 4, - READY_SCREEN_CONTINUED = 5, - EXIT_CODES_COUNT -}; - // Type of Assistant opt-in flow status. This enum is used to back an UMA // histogram and should be treated as append-only. enum AssistantOptInFlowStatus { @@ -45,9 +35,6 @@ enum AssistantOptInFlowStatus { kMaxValue = READY_SCREEN_CONTINUED }; -using OnAssistantOptInScreenExitCallback = - base::OnceCallback<void(AssistantOptInScreenExitCode exit_code)>; - void RecordAssistantOptInStatus(AssistantOptInFlowStatus); // Construct SettingsUiSelector for the ConsentFlow UI. diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.cc deleted file mode 100644 index 2bfb15b9fe0..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.cc +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h" - -#include "chrome/browser/browser_process.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/grit/generated_resources.h" -#include "components/arc/arc_prefs.h" -#include "components/login/localized_values_builder.h" -#include "components/prefs/pref_service.h" - -namespace { - -constexpr char kJsScreenPath[] = "assistant.GetMoreScreen"; - -} // namespace - -namespace chromeos { - -GetMoreScreenHandler::GetMoreScreenHandler( - OnAssistantOptInScreenExitCallback callback) - : BaseWebUIHandler(), exit_callback_(std::move(callback)) { - set_call_js_prefix(kJsScreenPath); -} - -GetMoreScreenHandler::~GetMoreScreenHandler() = default; - -void GetMoreScreenHandler::DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) {} - -void GetMoreScreenHandler::RegisterMessages() { - AddPrefixedCallback("userActed", &GetMoreScreenHandler::HandleUserAction); - AddPrefixedCallback("screenShown", &GetMoreScreenHandler::HandleScreenShown); -} - -void GetMoreScreenHandler::Initialize() {} - -void GetMoreScreenHandler::HandleUserAction(const bool screen_context, - const bool email_opted_in) { - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionContextEnabled, - screen_context); - - RecordAssistantOptInStatus(GET_MORE_CONTINUED); - DCHECK(exit_callback_); - if (email_opted_in) { - std::move(exit_callback_).Run(AssistantOptInScreenExitCode::EMAIL_OPTED_IN); - } else { - std::move(exit_callback_) - .Run(AssistantOptInScreenExitCode::EMAIL_OPTED_OUT); - } -} - -void GetMoreScreenHandler::HandleScreenShown() { - RecordAssistantOptInStatus(GET_MORE_SHOWN); -} - -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h deleted file mode 100644 index 4429fc55184..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/get_more_screen_handler.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_GET_MORE_SCREEN_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_GET_MORE_SCREEN_HANDLER_H_ - -#include <memory> -#include <string> - -#include "base/macros.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h" -#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" - -namespace chromeos { - -class GetMoreScreenHandler : public BaseWebUIHandler { - public: - explicit GetMoreScreenHandler(OnAssistantOptInScreenExitCallback callback); - ~GetMoreScreenHandler() override; - - // BaseWebUIHandler: - void DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) override; - void RegisterMessages() override; - void Initialize() override; - - private: - void HandleUserAction(const bool screen_context, const bool email_opted_in); - void HandleScreenShown(); - - OnAssistantOptInScreenExitCallback exit_callback_; - - DISALLOW_COPY_AND_ASSIGN(GetMoreScreenHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_GET_MORE_SCREEN_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.cc deleted file mode 100644 index 1a1f4487bdc..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h" - -#include "chrome/browser/browser_process.h" -#include "chrome/grit/generated_resources.h" -#include "components/login/localized_values_builder.h" - -namespace { - -constexpr char kJsScreenPath[] = "assistant.ReadyScreen"; - -constexpr char kUserActionNextPressed[] = "next-pressed"; - -} // namespace - -namespace chromeos { - -ReadyScreenHandler::ReadyScreenHandler( - OnAssistantOptInScreenExitCallback callback) - : BaseWebUIHandler(), exit_callback_(std::move(callback)) { - set_call_js_prefix(kJsScreenPath); -} - -ReadyScreenHandler::~ReadyScreenHandler() = default; - -void ReadyScreenHandler::DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) { - builder->Add("assistantReadyTitle", IDS_ASSISTANT_READY_SCREEN_TITLE); - builder->Add("assistantReadyMessage", IDS_ASSISTANT_READY_SCREEN_MESSAGE); - builder->Add("assistantReadyButton", IDS_ASSISTANT_DONE_BUTTON); -} - -void ReadyScreenHandler::RegisterMessages() { - AddPrefixedCallback("userActed", &ReadyScreenHandler::HandleUserAction); - AddPrefixedCallback("screenShown", &ReadyScreenHandler::HandleScreenShown); -} - -void ReadyScreenHandler::Initialize() {} - -void ReadyScreenHandler::HandleUserAction(const std::string& action) { - DCHECK(exit_callback_); - if (action == kUserActionNextPressed) { - RecordAssistantOptInStatus(READY_SCREEN_CONTINUED); - std::move(exit_callback_) - .Run(AssistantOptInScreenExitCode::READY_SCREEN_CONTINUED); - } -} - -void ReadyScreenHandler::HandleScreenShown() { - RecordAssistantOptInStatus(READY_SCREEN_SHOWN); -} - -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h deleted file mode 100644 index 6e71856a97d..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/ready_screen_handler.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_READY_SCREEN_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_READY_SCREEN_HANDLER_H_ - -#include <memory> -#include <string> - -#include "base/macros.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h" -#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" - -namespace chromeos { - -class ReadyScreenHandler : public BaseWebUIHandler { - public: - explicit ReadyScreenHandler(OnAssistantOptInScreenExitCallback callback); - ~ReadyScreenHandler() override; - - // BaseWebUIHandler: - void DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) override; - void RegisterMessages() override; - void Initialize() override; - - private: - void HandleUserAction(const std::string& action); - void HandleScreenShown(); - - OnAssistantOptInScreenExitCallback exit_callback_; - - DISALLOW_COPY_AND_ASSIGN(ReadyScreenHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_READY_SCREEN_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.cc deleted file mode 100644 index cdaed48da8d..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h" - -#include "chrome/browser/browser_process.h" -#include "chrome/grit/generated_resources.h" -#include "components/login/localized_values_builder.h" - -namespace { - -constexpr char kJsScreenPath[] = "assistant.ThirdPartyScreen"; - -constexpr char kUserActionNextPressed[] = "next-pressed"; - -} // namespace - -namespace chromeos { - -ThirdPartyScreenHandler::ThirdPartyScreenHandler( - OnAssistantOptInScreenExitCallback callback) - : BaseWebUIHandler(), exit_callback_(std::move(callback)) { - set_call_js_prefix(kJsScreenPath); -} - -ThirdPartyScreenHandler::~ThirdPartyScreenHandler() = default; - -void ThirdPartyScreenHandler::DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) {} - -void ThirdPartyScreenHandler::RegisterMessages() { - AddPrefixedCallback("userActed", &ThirdPartyScreenHandler::HandleUserAction); - AddPrefixedCallback("screenShown", - &ThirdPartyScreenHandler::HandleScreenShown); -} - -void ThirdPartyScreenHandler::Initialize() {} - -void ThirdPartyScreenHandler::HandleUserAction(const std::string& action) { - DCHECK(exit_callback_); - if (action == kUserActionNextPressed) { - RecordAssistantOptInStatus(THIRD_PARTY_CONTINUED); - std::move(exit_callback_) - .Run(AssistantOptInScreenExitCode::THIRD_PARTY_CONTINUED); - } -} - -void ThirdPartyScreenHandler::HandleScreenShown() { - RecordAssistantOptInStatus(THIRD_PARTY_SHOWN); -} - -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h deleted file mode 100644 index 558b448709e..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/third_party_screen_handler.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_THIRD_PARTY_SCREEN_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_THIRD_PARTY_SCREEN_HANDLER_H_ - -#include <memory> -#include <string> - -#include "base/macros.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h" -#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" - -namespace chromeos { - -class ThirdPartyScreenHandler : public BaseWebUIHandler { - public: - explicit ThirdPartyScreenHandler(OnAssistantOptInScreenExitCallback callback); - ~ThirdPartyScreenHandler() override; - - // BaseWebUIHandler: - void DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) override; - void RegisterMessages() override; - void Initialize() override; - - private: - void HandleUserAction(const std::string& action); - void HandleScreenShown(); - - OnAssistantOptInScreenExitCallback exit_callback_; - - DISALLOW_COPY_AND_ASSIGN(ThirdPartyScreenHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_THIRD_PARTY_SCREEN_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc deleted file mode 100644 index 5f05a52abc7..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h" - -#include "chrome/browser/browser_process.h" -#include "chrome/grit/generated_resources.h" -#include "components/login/localized_values_builder.h" - -namespace { - -constexpr char kJsScreenPath[] = "assistant.ValuePropScreen"; - -constexpr char kUserActionSkipPressed[] = "skip-pressed"; -constexpr char kUserActionNextPressed[] = "next-pressed"; - -} // namespace - -namespace chromeos { - -ValuePropScreenHandler::ValuePropScreenHandler( - OnAssistantOptInScreenExitCallback callback) - : BaseWebUIHandler(), exit_callback_(std::move(callback)) { - set_call_js_prefix(kJsScreenPath); -} - -ValuePropScreenHandler::~ValuePropScreenHandler() = default; - -void ValuePropScreenHandler::DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) { - builder->Add("locale", g_browser_process->GetApplicationLocale()); - // TODO(updowndota) Replace this with new string constants. - // Use string constant for old flow for now before we have final UX. - builder->Add("assistantOptinLoading", - IDS_VOICE_INTERACTION_VALUE_PROP_LOADING); - builder->Add("assistantOptinLoadErrorTitle", - IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_TITLE); - builder->Add("assistantOptinLoadErrorMessage", - IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_MESSAGE); - builder->Add("assistantOptinSkipButton", - IDS_VOICE_INTERACTION_VALUE_PROP_SKIP_BUTTON); - builder->Add("assistantOptinRetryButton", - IDS_VOICE_INTERACTION_VALUE_PROP_RETRY_BUTTON); - builder->Add("assistantOptinOKButton", IDS_OOBE_OK_BUTTON_TEXT); - builder->Add("back", IDS_EULA_BACK_BUTTON); - builder->Add("next", IDS_EULA_NEXT_BUTTON); -} - -void ValuePropScreenHandler::RegisterMessages() { - AddPrefixedCallback("userActed", &ValuePropScreenHandler::HandleUserAction); - AddPrefixedCallback("screenShown", - &ValuePropScreenHandler::HandleScreenShown); -} - -void ValuePropScreenHandler::Initialize() {} - -void ValuePropScreenHandler::HandleUserAction(const std::string& action) { - DCHECK(exit_callback_); - if (action == kUserActionSkipPressed) - std::move(exit_callback_) - .Run(AssistantOptInScreenExitCode::VALUE_PROP_SKIPPED); - else if (action == kUserActionNextPressed) - std::move(exit_callback_) - .Run(AssistantOptInScreenExitCode::VALUE_PROP_ACCEPTED); -} - -void ValuePropScreenHandler::HandleScreenShown() { - RecordAssistantOptInStatus(ACTIVITY_CONTROL_SHOWN); -} - -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h deleted file mode 100644 index 65e13af43c6..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_VALUE_PROP_SCREEN_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_VALUE_PROP_SCREEN_HANDLER_H_ - -#include <memory> -#include <string> - -#include "base/macros.h" -#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h" -#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" - -namespace chromeos { - -class ValuePropScreenHandler : public BaseWebUIHandler { - public: - explicit ValuePropScreenHandler(OnAssistantOptInScreenExitCallback callback); - ~ValuePropScreenHandler() override; - - // BaseWebUIHandler: - void DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) override; - void RegisterMessages() override; - void Initialize() override; - - private: - void HandleUserAction(const std::string& action); - void HandleScreenShown(); - - OnAssistantOptInScreenExitCallback exit_callback_; - - DISALLOW_COPY_AND_ASSIGN(ValuePropScreenHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ASSISTANT_OPTIN_VALUE_PROP_SCREEN_HANDLER_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 40d8a1a021e..8878f366d91 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 @@ -5,9 +5,11 @@ #include "chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h" #include "base/bind.h" +#include "base/task/post_task.h" #include "base/values.h" #include "chromeos/dbus/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" #include "content/public/browser/web_ui.h" #include "crypto/nss_util.h" @@ -39,9 +41,8 @@ void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) { cryptohome_client->Pkcs11IsTpmTokenReady( GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready")); - BrowserThread::PostTaskAndReplyWithResult( - BrowserThread::IO, - FROM_HERE, + base::PostTaskWithTraitsAndReplyWithResult( + FROM_HERE, {BrowserThread::IO}, base::Bind(&crypto::IsTPMTokenReady, base::Closure()), base::Bind(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread, weak_ptr_factory_.GetWeakPtr())); 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 13c32f05652..0b288d0f111 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc @@ -225,10 +225,10 @@ void AppendKeyValue(base::ListValue* list, std::string value, std::string clazz = std::string()) { auto dict = std::make_unique<base::DictionaryValue>(); - dict->SetPath({kKey}, base::Value(std::move(key))); - dict->SetPath({kValue}, base::Value(std::move(value))); + dict->SetKey(kKey, base::Value(std::move(key))); + dict->SetKey(kValue, base::Value(std::move(value))); if (!clazz.empty()) - dict->SetPath({kClass}, base::Value(std::move(clazz))); + dict->SetKey(kClass, base::Value(std::move(clazz))); list->GetList().push_back(std::move(*dict)); } @@ -319,8 +319,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { drive::DriveServiceInterface* drive_service); void UpdateAboutResourceSection( drive::DriveServiceInterface* drive_service); - void UpdateAppListSection( - drive::DriveServiceInterface* drive_service); void UpdateDeltaUpdateStatusSection( drive::DebugInfoCollector* debug_info_collector); void UpdateInFlightOperationsSection(drive::JobListInterface* job_list); @@ -360,10 +358,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { google_apis::DriveApiErrorCode status, std::unique_ptr<google_apis::AboutResource> about_resource); - // Called when GetAppList() call to DriveService is complete. - void OnGetAppList(google_apis::DriveApiErrorCode status, - std::unique_ptr<google_apis::AppList> app_list); - // Callback for DebugInfoCollector::GetMetadata for delta update. void OnGetFilesystemMetadataForDeltaUpdate( const drive::FileSystemMetadata& metadata, @@ -425,36 +419,6 @@ void DriveInternalsWebUIHandler::OnGetAboutResource( web_ui()->CallJavascriptFunctionUnsafe("updateAboutResource", about_resource); } -void DriveInternalsWebUIHandler::OnGetAppList( - google_apis::DriveApiErrorCode status, - std::unique_ptr<google_apis::AppList> parsed_app_list) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - if (status != google_apis::HTTP_SUCCESS) { - LOG(ERROR) << "Failed to get app list"; - return; - } - DCHECK(parsed_app_list); - - base::DictionaryValue app_list; - app_list.SetString("etag", parsed_app_list->etag()); - - auto items = std::make_unique<base::ListValue>(); - for (size_t i = 0; i < parsed_app_list->items().size(); ++i) { - const google_apis::AppResource* app = parsed_app_list->items()[i].get(); - auto app_data = std::make_unique<base::DictionaryValue>(); - app_data->SetString("name", app->name()); - app_data->SetString("application_id", app->application_id()); - app_data->SetString("object_type", app->object_type()); - app_data->SetBoolean("supports_create", app->supports_create()); - - items->Append(std::move(app_data)); - } - app_list.Set("items", std::move(items)); - - web_ui()->CallJavascriptFunctionUnsafe("updateAppList", app_list); -} - void DriveInternalsWebUIHandler::RegisterMessages() { web_ui()->RegisterMessageCallback( "pageLoaded", @@ -528,7 +492,6 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) { if (drive_service) { UpdateConnectionStatusSection(drive_service); UpdateAboutResourceSection(drive_service); - UpdateAppListSection(drive_service); } drive::DebugInfoCollector* debug_info_collector = @@ -623,16 +586,6 @@ void DriveInternalsWebUIHandler::UpdateAboutResourceSection( weak_ptr_factory_.GetWeakPtr())); } -void DriveInternalsWebUIHandler::UpdateAppListSection( - drive::DriveServiceInterface* drive_service) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - DCHECK(drive_service); - - drive_service->GetAppList( - base::Bind(&DriveInternalsWebUIHandler::OnGetAppList, - weak_ptr_factory_.GetWeakPtr())); -} - void DriveInternalsWebUIHandler::ClearAccessToken(const base::ListValue* args) { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -912,7 +865,7 @@ void DriveInternalsWebUIHandler::UpdatePathConfigurationsSection() { &paths, "Downloads", file_manager::util::GetDownloadsFolderForProfile(profile).AsUTF8Unsafe()); const auto* integration_service = GetIntegrationService(); - if (integration_service && integration_service->IsMounted()) { + if (integration_service) { AppendKeyValue(&paths, "Drive", integration_service->GetMountPointPath().AsUTF8Unsafe()); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/image_source.cc b/chromium/chrome/browser/ui/webui/chromeos/image_source.cc index 9145713af6c..7abfddcb0d2 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/image_source.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/image_source.cc @@ -26,9 +26,7 @@ namespace chromeos { namespace { -const char* kWhitelistedDirectories[] = { - "regulatory_labels" -}; +const char* const kWhitelistedDirectories[] = {"regulatory_labels"}; // Callback for user_manager::UserImageLoader. void ImageLoaded( @@ -64,7 +62,7 @@ void ImageSource::StartDataRequest( return; } - const base::FilePath asset_dir(FILE_PATH_LITERAL(chrome::kChromeOSAssetPath)); + const base::FilePath asset_dir(chrome::kChromeOSAssetPath); const base::FilePath image_path = asset_dir.AppendASCII(path); base::PostTaskWithTraitsAndReplyWithResult( FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, 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 8b3d420b688..f1d7e7e852c 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 @@ -246,6 +246,8 @@ void ArcTermsOfServiceScreenHandler::DoShow() { Profile* profile = ProfileManager::GetActiveUserProfile(); CHECK(profile); + CallJS("clearDemoMode"); + // Enable ARC to match ArcSessionManager logic. ArcSessionManager expects that // ARC is enabled (prefs::kArcEnabled = true) on showing Terms of Service. If // user accepts ToS then prefs::kArcEnabled is left activated. If user skips 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 50203401165..9a63d3a5d32 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 @@ -4,12 +4,13 @@ #include "chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h" +#include "base/metrics/histogram_macros.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/login/oobe_screen.h" #include "chrome/browser/chromeos/login/screens/assistant_optin_flow_screen.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h" -#include "chrome/grit/browser_resources.h" #include "chrome/grit/generated_resources.h" #include "chromeos/services/assistant/public/mojom/constants.mojom.h" #include "chromeos/services/assistant/public/proto/settings_ui.pb.h" @@ -26,6 +27,7 @@ constexpr char kJsScreenPath[] = "login.AssistantOptInFlowScreen"; constexpr char kSkipPressed[] = "skip-pressed"; constexpr char kNextPressed[] = "next-pressed"; constexpr char kFlowFinished[] = "flow-finished"; +constexpr char kReloadRequested[] = "reload-requested"; } // namespace @@ -45,6 +47,7 @@ AssistantOptInFlowScreenHandler::~AssistantOptInFlowScreenHandler() { void AssistantOptInFlowScreenHandler::DeclareLocalizedValues( ::login::LocalizedValuesBuilder* builder) { + builder->Add("locale", g_browser_process->GetApplicationLocale()); builder->Add("assistantOptinLoading", IDS_VOICE_INTERACTION_VALUE_PROP_LOADING); builder->Add("assistantOptinLoadErrorTitle", @@ -59,33 +62,42 @@ void AssistantOptInFlowScreenHandler::DeclareLocalizedValues( builder->Add("assistantReadyTitle", IDS_ASSISTANT_READY_SCREEN_TITLE); builder->Add("assistantReadyMessage", IDS_ASSISTANT_READY_SCREEN_MESSAGE); builder->Add("assistantReadyButton", IDS_ASSISTANT_DONE_BUTTON); + builder->Add("back", IDS_EULA_BACK_BUTTON); + builder->Add("next", IDS_EULA_NEXT_BUTTON); } void AssistantOptInFlowScreenHandler::RegisterMessages() { - AddCallback( - "assistant.ValuePropScreen.userActed", + AddPrefixedCallback( + "ValuePropScreen.userActed", &AssistantOptInFlowScreenHandler::HandleValuePropScreenUserAction); - AddCallback( - "assistant.ThirdPartyScreen.userActed", + AddPrefixedCallback( + "ThirdPartyScreen.userActed", &AssistantOptInFlowScreenHandler::HandleThirdPartyScreenUserAction); - AddCallback("assistant.GetMoreScreen.userActed", - &AssistantOptInFlowScreenHandler::HandleGetMoreScreenUserAction); - AddCallback("assistant.ReadyScreen.userActed", - &AssistantOptInFlowScreenHandler::HandleReadyScreenUserAction); - AddCallback("assistant.ValuePropScreen.screenShown", - &AssistantOptInFlowScreenHandler::HandleValuePropScreenShown); - AddCallback("assistant.ThirdPartyScreen.screenShown", - &AssistantOptInFlowScreenHandler::HandleThirdPartyScreenShown); - AddCallback("assistant.GetMoreScreen.screenShown", - &AssistantOptInFlowScreenHandler::HandleGetMoreScreenShown); - AddCallback("assistant.ReadyScreen.screenShown", - &AssistantOptInFlowScreenHandler::HandleReadyScreenShown); - AddCallback("assistantOptInFlow.hotwordResult", - &AssistantOptInFlowScreenHandler::HandleHotwordResult); - AddCallback("assistantOptInFlow.flowFinished", - &AssistantOptInFlowScreenHandler::HandleFlowFinished); - AddCallback("assistantOptInFlow.initialized", - &AssistantOptInFlowScreenHandler::HandleFlowInitialized); + AddPrefixedCallback( + "GetMoreScreen.userActed", + &AssistantOptInFlowScreenHandler::HandleGetMoreScreenUserAction); + AddPrefixedCallback( + "ReadyScreen.userActed", + &AssistantOptInFlowScreenHandler::HandleReadyScreenUserAction); + AddPrefixedCallback( + "ValuePropScreen.screenShown", + &AssistantOptInFlowScreenHandler::HandleValuePropScreenShown); + AddPrefixedCallback( + "ThirdPartyScreen.screenShown", + &AssistantOptInFlowScreenHandler::HandleThirdPartyScreenShown); + AddPrefixedCallback( + "GetMoreScreen.screenShown", + &AssistantOptInFlowScreenHandler::HandleGetMoreScreenShown); + AddPrefixedCallback("ReadyScreen.screenShown", + &AssistantOptInFlowScreenHandler::HandleReadyScreenShown); + AddPrefixedCallback("LoadingScreen.timeout", + &AssistantOptInFlowScreenHandler::HandleLoadingTimeout); + AddPrefixedCallback("hotwordResult", + &AssistantOptInFlowScreenHandler::HandleHotwordResult); + AddPrefixedCallback("flowFinished", + &AssistantOptInFlowScreenHandler::HandleFlowFinished); + AddPrefixedCallback("initialized", + &AssistantOptInFlowScreenHandler::HandleFlowInitialized); } void AssistantOptInFlowScreenHandler::Bind(AssistantOptInFlowScreen* screen) { @@ -101,22 +113,13 @@ void AssistantOptInFlowScreenHandler::Unbind() { } void AssistantOptInFlowScreenHandler::Show() { - // Make sure enable Assistant service since we need it during the flow. - PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true); - - if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() == - ash::mojom::VoiceInteractionState::NOT_READY) { - arc::VoiceInteractionControllerClient::Get()->AddObserver(this); - } else { - BindAssistantSettingsManager(); - } - if (!page_is_ready() || !screen_) { show_on_init_ = true; return; } + SetupAssistantConnection(); + ShowScreen(kScreenId); } @@ -130,6 +133,19 @@ void AssistantOptInFlowScreenHandler::Initialize() { show_on_init_ = false; } +void AssistantOptInFlowScreenHandler::SetupAssistantConnection() { + // Make sure enable Assistant service since we need it during the flow. + PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); + prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true); + + if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() == + ash::mojom::VoiceInteractionState::NOT_READY) { + arc::VoiceInteractionControllerClient::Get()->AddObserver(this); + } else { + BindAssistantSettingsManager(); + } +} + void AssistantOptInFlowScreenHandler::ShowNextScreen() { CallJS("showNextScreen"); } @@ -137,6 +153,7 @@ void AssistantOptInFlowScreenHandler::ShowNextScreen() { void AssistantOptInFlowScreenHandler::OnActivityControlOptInResult( bool opted_in) { Profile* profile = ProfileManager::GetActiveUserProfile(); + RecordActivityControlConsent(profile, ui_audit_key_, opted_in); if (opted_in) { RecordAssistantOptInStatus(ACTIVITY_CONTROL_ACCEPTED); settings_manager_->UpdateSettings( @@ -148,10 +165,8 @@ void AssistantOptInFlowScreenHandler::OnActivityControlOptInResult( RecordAssistantOptInStatus(ACTIVITY_CONTROL_SKIPPED); profile->GetPrefs()->SetBoolean( arc::prefs::kVoiceInteractionActivityControlAccepted, false); - screen_->OnUserAction(kFlowFinished); + HandleFlowFinished(); } - - RecordActivityControlConsent(profile, ui_audit_key_, opted_in); } void AssistantOptInFlowScreenHandler::OnEmailOptInResult(bool opted_in) { @@ -196,6 +211,7 @@ void AssistantOptInFlowScreenHandler::SendGetSettingsRequest() { selector.SerializeAsString(), base::BindOnce(&AssistantOptInFlowScreenHandler::OnGetSettingsResponse, weak_factory_.GetWeakPtr())); + send_request_time_ = base::TimeTicks::Now(); } void AssistantOptInFlowScreenHandler::ReloadContent(const base::Value& dict) { @@ -209,6 +225,11 @@ void AssistantOptInFlowScreenHandler::AddSettingZippy(const std::string& type, void AssistantOptInFlowScreenHandler::OnGetSettingsResponse( const std::string& settings) { + const base::TimeDelta time_since_request_sent = + base::TimeTicks::Now() - send_request_time_; + UMA_HISTOGRAM_TIMES("Assistant.OptInFlow.GetSettingsRequestTime", + time_since_request_sent); + assistant::SettingsUi settings_ui; settings_ui.ParseFromString(settings); @@ -223,12 +244,18 @@ void AssistantOptInFlowScreenHandler::OnGetSettingsResponse( ui_audit_key_ = activity_control_ui.ui_audit_key(); // Process activity control data. - if (!activity_control_ui.setting_zippy().size()) { + bool skip_activity_control = !activity_control_ui.setting_zippy().size(); + if (skip_activity_control) { // No need to consent. Move to the next screen. activity_control_needed_ = false; PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionActivityControlAccepted, - true); + prefs->SetBoolean( + arc::prefs::kVoiceInteractionActivityControlAccepted, + (settings_ui.consent_flow_ui().consent_status() == + assistant::ConsentFlowUi_ConsentStatus_ALREADY_CONSENTED || + settings_ui.consent_flow_ui().consent_status() == + assistant::ConsentFlowUi_ConsentStatus_ASK_FOR_CONSENT)); + // Skip activity control and users will be in opted out mode. ShowNextScreen(); } else { AddSettingZippy("settings", @@ -236,14 +263,36 @@ void AssistantOptInFlowScreenHandler::OnGetSettingsResponse( } // Process third party disclosure data. - AddSettingZippy("disclosure", CreateDisclosureData( - third_party_disclosure_ui.disclosures())); + bool skip_third_party_disclosure = + skip_activity_control && !third_party_disclosure_ui.disclosures().size(); + if (third_party_disclosure_ui.disclosures().size()) { + AddSettingZippy("disclosure", CreateDisclosureData( + third_party_disclosure_ui.disclosures())); + } else if (skip_third_party_disclosure) { + ShowNextScreen(); + } else { + // TODO(llin): Show an error message and log it properly. + LOG(ERROR) << "Missing third Party disclosure data."; + return; + } // Process get more data. email_optin_needed_ = settings_ui.has_email_opt_in_ui() && settings_ui.email_opt_in_ui().has_title(); - AddSettingZippy("get-more", CreateGetMoreData(email_optin_needed_, - settings_ui.email_opt_in_ui())); + auto get_more_data = + CreateGetMoreData(email_optin_needed_, settings_ui.email_opt_in_ui()); + + bool skip_get_more = + skip_third_party_disclosure && !get_more_data.GetList().size(); + if (get_more_data.GetList().size()) { + AddSettingZippy("get-more", get_more_data); + } else if (skip_get_more) { + ShowNextScreen(); + } else { + // TODO(llin): Show an error message and log it properly. + LOG(ERROR) << "Missing get more data."; + return; + } // Pass string constants dictionary. ReloadContent(GetSettingsUiStrings(settings_ui, activity_control_needed_)); @@ -284,31 +333,18 @@ void AssistantOptInFlowScreenHandler::OnUpdateSettingsResponse( ShowNextScreen(); } -void AssistantOptInFlowScreenHandler::HandleHotwordResult(bool enable_hotword) { - enable_hotword_ = enable_hotword; - - if (!email_optin_needed_) { - // No need to send email optin result. Safe to update hotword pref and - // restart Assistant here. - PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); - prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, - enable_hotword); - } -} - -void AssistantOptInFlowScreenHandler::HandleLoadingScreenUserAction( - const std::string& action) { - if (action == kSkipPressed) { - screen_->OnUserAction(kFlowFinished); - } -} - void AssistantOptInFlowScreenHandler::HandleValuePropScreenUserAction( const std::string& action) { if (action == kSkipPressed) { OnActivityControlOptInResult(false); } else if (action == kNextPressed) { OnActivityControlOptInResult(true); + } else if (action == kReloadRequested) { + if (settings_manager_.is_bound()) { + SendGetSettingsRequest(); + } else { + LOG(ERROR) << "Settings mojom failed to setup. Check Assistant service."; + } } } @@ -334,7 +370,7 @@ void AssistantOptInFlowScreenHandler::HandleReadyScreenUserAction( const std::string& action) { if (action == kNextPressed) { RecordAssistantOptInStatus(READY_SCREEN_CONTINUED); - screen_->OnUserAction(kFlowFinished); + HandleFlowFinished(); } } @@ -354,8 +390,29 @@ void AssistantOptInFlowScreenHandler::HandleReadyScreenShown() { RecordAssistantOptInStatus(READY_SCREEN_SHOWN); } +void AssistantOptInFlowScreenHandler::HandleLoadingTimeout() { + ++loading_timeout_counter_; +} + +void AssistantOptInFlowScreenHandler::HandleHotwordResult(bool enable_hotword) { + enable_hotword_ = enable_hotword; + + if (!email_optin_needed_) { + // No need to send email optin result. Safe to update hotword pref and + // restart Assistant here. + PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); + prefs->SetBoolean(arc::prefs::kVoiceInteractionHotwordEnabled, + enable_hotword); + } +} + void AssistantOptInFlowScreenHandler::HandleFlowFinished() { - screen_->OnUserAction(kFlowFinished); + UMA_HISTOGRAM_EXACT_LINEAR("Assistant.OptInFlow.LoadingTimeoutCount", + loading_timeout_counter_, 10); + if (screen_) + screen_->OnUserAction(kFlowFinished); + else + CallJS("closeDialog"); } void AssistantOptInFlowScreenHandler::HandleFlowInitialized() {} diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h index bcd0ff69667..6ddc11065a2 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h @@ -36,6 +36,9 @@ class AssistantOptInFlowScreenHandler void Show() override; void Hide() override; + // Setup Assistant settings manager connection. + void SetupAssistantConnection(); + // Send messages to the page. void ShowNextScreen(); @@ -65,7 +68,6 @@ class AssistantOptInFlowScreenHandler void OnUpdateSettingsResponse(const std::string& settings); // Handler for JS WebUI message. - void HandleLoadingScreenUserAction(const std::string& action); void HandleValuePropScreenUserAction(const std::string& action); void HandleThirdPartyScreenUserAction(const std::string& action); void HandleGetMoreScreenUserAction(const bool screen_context, @@ -75,6 +77,7 @@ class AssistantOptInFlowScreenHandler void HandleThirdPartyScreenShown(); void HandleGetMoreScreenShown(); void HandleReadyScreenShown(); + void HandleLoadingTimeout(); void HandleHotwordResult(bool enable_hotword); void HandleFlowFinished(); void HandleFlowInitialized(); @@ -99,6 +102,12 @@ class AssistantOptInFlowScreenHandler // Whether user chose to enable hotword. bool enable_hotword_ = true; + // Time that get settings request is sent. + base::TimeTicks send_request_time_; + + // Counter for the number of loading timeout happens. + int loading_timeout_counter_ = 0; + assistant::mojom::AssistantSettingsManagerPtr settings_manager_; base::WeakPtrFactory<AssistantOptInFlowScreenHandler> weak_factory_; 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 6137e9ad4e4..d0842f5a8fc 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 @@ -16,6 +16,8 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/chromeos/accessibility/magnification_manager.h" +#include "chrome/browser/chromeos/login/configuration_keys.h" +#include "chrome/browser/chromeos/login/demo_mode/demo_session.h" #include "chrome/browser/chromeos/login/demo_mode/demo_setup_controller.h" #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" #include "chrome/browser/chromeos/login/helper.h" @@ -103,14 +105,13 @@ CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui, TabletModeClient* tablet_mode_client = TabletModeClient::Get(); tablet_mode_client->AddObserver(this); - OobeConfiguration::Get()->AddObserver(this); - // |connector| may be null in tests. auto* connector = ash_util::GetServiceManagerConnector(); if (connector) { connector->BindInterface(ash::mojom::kServiceName, &cros_display_config_ptr_); } + OobeConfiguration::Get()->AddAndFireObserver(this); } CoreOobeHandler::~CoreOobeHandler() { @@ -177,7 +178,6 @@ void CoreOobeHandler::Initialize() { UpdateDeviceRequisition(); UpdateKeyboardState(); UpdateClientAreaSize(); - UpdateOobeConfiguration(); } void CoreOobeHandler::GetAdditionalParameters(base::DictionaryValue* dict) { @@ -226,6 +226,8 @@ void CoreOobeHandler::RegisterMessages() { AddRawCallback("getPrimaryDisplayNameForTesting", &CoreOobeHandler::HandleGetPrimaryDisplayNameForTesting); AddCallback("setupDemoMode", &CoreOobeHandler::HandleSetupDemoMode); + AddCallback("startDemoModeSetupForTesting", + &CoreOobeHandler::HandleStartDemoModeSetupForTesting); } void CoreOobeHandler::ShowSignInError( @@ -583,11 +585,9 @@ void CoreOobeHandler::UpdateKeyboardState() { // KeyboardController in the browser process under MASH. if (!features::IsUsingWindowService()) { auto* keyboard_controller = keyboard::KeyboardController::Get(); - if (keyboard_controller->enabled()) { - const bool is_keyboard_shown = keyboard_controller->IsKeyboardVisible(); - ShowControlBar(!is_keyboard_shown); - SetVirtualKeyboardShown(is_keyboard_shown); - } + const bool is_keyboard_shown = keyboard_controller->IsKeyboardVisible(); + ShowControlBar(!is_keyboard_shown); + SetVirtualKeyboardShown(is_keyboard_shown); } } @@ -602,14 +602,12 @@ void CoreOobeHandler::UpdateClientAreaSize() { } void CoreOobeHandler::OnOobeConfigurationChanged() { - UpdateOobeConfiguration(); -} - -void CoreOobeHandler::UpdateOobeConfiguration() { - if (OobeConfiguration::Get()) { - CallJSOrDefer("updateOobeConfiguration", - OobeConfiguration::Get()->GetConfiguration()); - } + base::Value configuration(base::Value::Type::DICTIONARY); + chromeos::configuration::FilterConfiguration( + OobeConfiguration::Get()->GetConfiguration(), + chromeos::configuration::ConfigurationHandlerSide::HANDLER_JS, + configuration); + CallJSOrDefer("updateOobeConfiguration", configuration); } void CoreOobeHandler::OnAccessibilityStatusChanged( @@ -686,6 +684,24 @@ void CoreOobeHandler::HandleSetupDemoMode() { } } +void CoreOobeHandler::HandleStartDemoModeSetupForTesting( + const std::string& demo_config) { + DemoSession::DemoModeConfig config; + if (demo_config == "online") { + config = DemoSession::DemoModeConfig::kOnline; + } else if (demo_config == "offline") { + config = DemoSession::DemoModeConfig::kOffline; + } else { + NOTREACHED() << "Unknown demo config passed for tests"; + } + + WizardController* wizard_controller = WizardController::default_controller(); + if (wizard_controller && !wizard_controller->login_screen_started()) { + wizard_controller->SimulateDemoModeSetupForTesting(config); + wizard_controller->AdvanceToScreen(OobeScreen::SCREEN_OOBE_DEMO_SETUP); + } +} + void CoreOobeHandler::InitDemoModeDetection() { demo_mode_detector_.InitDetection(); } 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 933dd72f91f..981e5cf5fa6 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 @@ -149,6 +149,9 @@ class CoreOobeHandler : public BaseWebUIHandler, const base::Value& callback_id, std::vector<ash::mojom::DisplayUnitInfoPtr> info_list); void HandleSetupDemoMode(); + // Handles demo mode setup for tests. Accepts 'online' and 'offline' as + // |demo_config|. + void HandleStartDemoModeSetupForTesting(const std::string& demo_config); // When keyboard_utils.js arrow key down event is reached, raise it // to tab/shift-tab event. @@ -169,9 +172,6 @@ class CoreOobeHandler : public BaseWebUIHandler, // Updates client area size based on the primary screen size. void UpdateClientAreaSize(); - // Updates OOBE configuration. - void UpdateOobeConfiguration(); - // Notification of a change in the accessibility settings. void OnAccessibilityStatusChanged( const AccessibilityStatusEventDetails& details); diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc index 0a205aa2534..636546f33ad 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.cc @@ -7,8 +7,10 @@ #include <algorithm> #include "base/logging.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h" #include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h" +#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h" #include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h" #include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h" #include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.h" @@ -21,6 +23,11 @@ DiscoverManager::DiscoverManager() { DiscoverManager::~DiscoverManager() = default; +// static +DiscoverManager* DiscoverManager::Get() { + return g_browser_process->platform_part()->GetDiscoverManager(); +} + bool DiscoverManager::IsCompleted() const { // Returns true if all of the modules are completed. return std::all_of(modules_.begin(), modules_.end(), @@ -38,6 +45,8 @@ void DiscoverManager::CreateModules() { std::make_unique<DiscoverModuleSyncFiles>(); modules_[DiscoverModuleWelcome::kModuleName] = std::make_unique<DiscoverModuleWelcome>(); + modules_[DiscoverModulePinSetup::kModuleName] = + std::make_unique<DiscoverModulePinSetup>(); } std::vector<std::unique_ptr<DiscoverHandler>> @@ -49,4 +58,10 @@ DiscoverManager::CreateWebUIHandlers() const { return handlers; } +DiscoverModule* DiscoverManager::GetModuleByName( + const std::string& module_name) const { + const auto it = modules_.find(module_name); + return it == modules_.end() ? nullptr : it->second.get(); +} + } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h index bd0fa047ce8..8ac51beb854 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h @@ -25,17 +25,29 @@ class DiscoverManager { DiscoverManager(); ~DiscoverManager(); + // Returns object instance from platform_parts. + static DiscoverManager* Get(); + // Returns true if there are no modules to be displayed. bool IsCompleted() const; // Returns vector of WebUI message handlers for visible modules. std::vector<std::unique_ptr<DiscoverHandler>> CreateWebUIHandlers() const; + template <typename T> + T* GetModule() { + return static_cast<T*>(GetModuleByName(T::kModuleName)); + } + const ModulesMap& get_modules() const { return modules_; } private: // Creates all needed modules. void CreateModules(); + + // Returns module by name. + DiscoverModule* GetModuleByName(const std::string& module_name) const; + ModulesMap modules_; DISALLOW_COPY_AND_ASSIGN(DiscoverManager); diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_module.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_module.h index add727f7049..e97a5ad6811 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_module.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_module.h @@ -24,7 +24,7 @@ class DiscoverModule { virtual bool IsCompleted() const = 0; // Creates and returns WebUI handler for the module. - virtual std::unique_ptr<DiscoverHandler> CreateWebUIHandler() const = 0; + virtual std::unique_ptr<DiscoverHandler> CreateWebUIHandler() = 0; // Module is also expected to provide static method: // static const char* kModuleName; 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 553853e4189..426e67820a7 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 @@ -4,7 +4,6 @@ #include "chrome/browser/ui/webui/chromeos/login/discover/discover_ui.h" -#include "chrome/browser/browser_process.h" #include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h" #include "chrome/browser/ui/webui/chromeos/login/discover/discover_manager.h" #include "content/public/browser/web_ui.h" @@ -17,9 +16,7 @@ DiscoverUI::~DiscoverUI() {} void DiscoverUI::RegisterMessages(content::WebUI* web_ui) { std::vector<std::unique_ptr<DiscoverHandler>> handlers = - g_browser_process->platform_part() - ->GetDiscoverManager() - ->CreateWebUIHandlers(); + DiscoverManager::Get()->CreateWebUIHandlers(); for (auto& handler : handlers) { handlers_.push_back(handler.get()); web_ui->AddMessageHandler(std::move(handler)); diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.cc index 8f8fcbf6a6b..986898a589b 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.cc @@ -4,7 +4,10 @@ #include "chrome/browser/ui/webui/chromeos/login/discover/discover_window_manager.h" +#include "ash/public/cpp/app_types.h" +#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/ash/window_properties.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator_params.h" @@ -15,6 +18,7 @@ #include "chrome/common/webui_url_constants.h" #include "chrome/grit/generated_resources.h" #include "content/public/browser/web_contents.h" +#include "ui/aura/client/aura_constants.h" #include "ui/gfx/geometry/rect.h" #include "url/gurl.h" @@ -79,6 +83,11 @@ void DiscoverWindowManager::ShowChromeDiscoverPageForProfile(Profile* profile) { .first->second = params.browser->session_id(); DCHECK(params.browser->is_trusted_source()); + auto* window = params.browser->window()->GetNativeWindow(); + window->SetProperty(kOverrideWindowIconResourceIdKey, IDR_DISCOVER_APP_192); + window->SetProperty(aura::client::kAppType, + static_cast<int>(ash::AppType::CHROME_APP)); + for (DiscoverWindowManagerObserver& observer : observers_) observer.OnNewDiscoverWindow(params.browser); } 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 cd3e89c41f8..37ea54dd760 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 @@ -70,7 +70,7 @@ bool DiscoverModuleLaunchHelpApp::IsCompleted() const { } std::unique_ptr<DiscoverHandler> -DiscoverModuleLaunchHelpApp::CreateWebUIHandler() const { +DiscoverModuleLaunchHelpApp::CreateWebUIHandler() { return std::make_unique<DiscoverModuleLaunchHelpAppHandler>(); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h index 7a386aba397..78774b34cdc 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_launch_help_app.h @@ -19,7 +19,7 @@ class DiscoverModuleLaunchHelpApp : public DiscoverModule { // DiscoverModule: bool IsCompleted() const override; - std::unique_ptr<DiscoverHandler> CreateWebUIHandler() const override; + std::unique_ptr<DiscoverHandler> CreateWebUIHandler() override; // Module name. static const char kModuleName[]; 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 new file mode 100644 index 00000000000..35863208b57 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.cc @@ -0,0 +1,137 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h" + +#include <vector> + +#include "base/i18n/number_formatting.h" +#include "base/values.h" +#include "chrome/browser/ui/webui/chromeos/login/discover/discover_handler.h" +#include "chrome/grit/browser_resources.h" +#include "chrome/grit/generated_resources.h" +#include "components/login/localized_values_builder.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" + +namespace chromeos { + +namespace { + +class DiscoverModulePinSetupHandler : public DiscoverHandler { + public: + explicit DiscoverModulePinSetupHandler( + base::WeakPtr<DiscoverModulePinSetup> module); + ~DiscoverModulePinSetupHandler() override = default; + + // BaseWebUIHandler + void DeclareLocalizedValues( + ::login::LocalizedValuesBuilder* builder) override; + void Initialize() override; + void RegisterMessages() override; + + private: + // Message handlers. + void HandleGetUserPassword(const std::string& callbackId); + + base::WeakPtr<DiscoverModulePinSetup> module_; + + DISALLOW_COPY_AND_ASSIGN(DiscoverModulePinSetupHandler); +}; + +DiscoverModulePinSetupHandler::DiscoverModulePinSetupHandler( + base::WeakPtr<DiscoverModulePinSetup> module) + : DiscoverHandler(DiscoverModulePinSetup::kModuleName), module_(module) {} + +void DiscoverModulePinSetupHandler::DeclareLocalizedValues( + ::login::LocalizedValuesBuilder* builder) { + builder->Add("discoverPinSetup", IDS_DISCOVER_PIN_SETUP); + + builder->Add("back", IDS_EULA_BACK_BUTTON); + builder->Add("next", IDS_EULA_NEXT_BUTTON); + builder->Add("discoverPinSetupDone", IDS_DISCOVER_PIN_SETUP_DONE); + + builder->Add("discoverPinSetupTitle1", IDS_DISCOVER_PIN_SETUP_TITLE1); + builder->Add("discoverPinSetupSubtitle1", IDS_DISCOVER_PIN_SETUP_SUBTITLE1); + builder->Add("discoverPinSetupSkip", IDS_DISCOVER_PIN_SETUP_SKIP); + builder->Add("discoverPinSetupTitle2", IDS_DISCOVER_PIN_SETUP_TITLE2); + builder->Add("discoverPinSetupTitle3", IDS_DISCOVER_PIN_SETUP_TITLE3); + builder->Add("discoverPinSetupSubtitle3", IDS_DISCOVER_PIN_SETUP_SUBTITLE3); + builder->Add("discoverPinSetupPasswordTitle", + IDS_DISCOVER_PIN_SETUP_PASSWORD_TITLE); + builder->Add("discoverPinSetupPasswordSubTitle", + IDS_DISCOVER_PIN_SETUP_PASSWORD_SUBTITLE); + + builder->Add("passwordPromptInvalidPassword", + IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_INVALID_PASSWORD); + builder->Add("passwordPromptPasswordLabel", + IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_PASSWORD_LABEL); + + // Format numbers to be used on the pin keyboard. + for (int j = 0; j <= 9; j++) { + builder->Add("pinKeyboard" + base::IntToString(j), + base::FormatNumber(int64_t{j})); + } + builder->Add("pinKeyboardPlaceholderPin", IDS_PIN_KEYBOARD_HINT_TEXT_PIN); + builder->Add("pinKeyboardPlaceholderPinPassword", + IDS_PIN_KEYBOARD_HINT_TEXT_PIN_PASSWORD); + builder->Add("pinKeyboardDeleteAccessibleName", + IDS_PIN_KEYBOARD_DELETE_ACCESSIBLE_NAME); + builder->Add("configurePinMismatched", + IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_MISMATCHED); + builder->Add("configurePinTooShort", + IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_TOO_SHORT); + builder->Add("configurePinTooLong", + IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_TOO_LONG); + builder->Add("configurePinWeakPin", + IDS_SETTINGS_PEOPLE_CONFIGURE_PIN_WEAK_PIN); +} + +void DiscoverModulePinSetupHandler::Initialize() {} + +void DiscoverModulePinSetupHandler::RegisterMessages() { + AddCallback("discover.pinSetup.getUserPassword", + &DiscoverModulePinSetupHandler::HandleGetUserPassword); +} + +void DiscoverModulePinSetupHandler::HandleGetUserPassword( + const std::string& callbackId) { + web_ui()->CallJavascriptFunctionUnsafe( + "window.discoverReturn", base::Value(callbackId), + base::Value(module_->ConsumePrimaryUserPassword())); + return; +} + +} // anonymous namespace + +/* ***************************************************************** */ +/* Discover PinSetup module implementation below. */ + +const char DiscoverModulePinSetup::kModuleName[] = "pinSetup"; + +DiscoverModulePinSetup::DiscoverModulePinSetup() {} + +DiscoverModulePinSetup::~DiscoverModulePinSetup() = default; + +bool DiscoverModulePinSetup::IsCompleted() const { + return false; +} + +std::unique_ptr<DiscoverHandler> DiscoverModulePinSetup::CreateWebUIHandler() { + return std::make_unique<DiscoverModulePinSetupHandler>( + weak_ptr_factory_.GetWeakPtr()); +} + +std::string DiscoverModulePinSetup::ConsumePrimaryUserPassword() { + std::string result; + std::swap(primary_user_password_, result); + return result; +} + +void DiscoverModulePinSetup::SetPrimaryUserPassword( + const std::string& password) { + primary_user_password_ = password; +} + +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h new file mode 100644 index 00000000000..e0e942162c7 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_pin_setup.h @@ -0,0 +1,43 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_PIN_SETUP_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_PIN_SETUP_H_ + +#include <memory> + +#include "base/containers/flat_map.h" +#include "base/macros.h" +#include "base/memory/weak_ptr.h" +#include "chrome/browser/ui/webui/chromeos/login/discover/discover_module.h" + +namespace chromeos { + +class DiscoverModulePinSetup : public DiscoverModule { + public: + // Module name. + static const char kModuleName[]; + + DiscoverModulePinSetup(); + ~DiscoverModulePinSetup() override; + + // Returns primary user password, or empty string if not known. + // Password is kept for newly created user only, and is returned only once. + // (Empty string will be returned for subsequent calls.) + std::string ConsumePrimaryUserPassword(); + void SetPrimaryUserPassword(const std::string& password); + + // DiscoverModule: + bool IsCompleted() const override; + std::unique_ptr<DiscoverHandler> CreateWebUIHandler() override; + + private: + std::string primary_user_password_; + + base::WeakPtrFactory<DiscoverModulePinSetup> weak_ptr_factory_{this}; + DISALLOW_COPY_AND_ASSIGN(DiscoverModulePinSetup); +}; + +} // namespace chromeos +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DISCOVER_MODULES_DISCOVER_MODULE_PIN_SETUP_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.cc b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.cc index 300586ee25d..cf44c2760b9 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 @@ -56,7 +56,7 @@ bool DiscoverModuleRedeemOffers::IsCompleted() const { } std::unique_ptr<DiscoverHandler> -DiscoverModuleRedeemOffers::CreateWebUIHandler() const { +DiscoverModuleRedeemOffers::CreateWebUIHandler() { return std::make_unique<DiscoverModuleRedeemOffersHandler>(); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h index ac4d91b82fb..7060b556434 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_redeem_offers.h @@ -19,7 +19,7 @@ class DiscoverModuleRedeemOffers : public DiscoverModule { // DiscoverModule: bool IsCompleted() const override; - std::unique_ptr<DiscoverHandler> CreateWebUIHandler() const override; + std::unique_ptr<DiscoverHandler> CreateWebUIHandler() override; // Module name. static const char kModuleName[]; 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 cb910b79fc2..00e8d236293 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 @@ -55,8 +55,7 @@ bool DiscoverModuleSyncFiles::IsCompleted() const { return false; } -std::unique_ptr<DiscoverHandler> DiscoverModuleSyncFiles::CreateWebUIHandler() - const { +std::unique_ptr<DiscoverHandler> DiscoverModuleSyncFiles::CreateWebUIHandler() { return std::make_unique<DiscoverModuleSyncFilesHandler>(); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h index 2eccb231799..d1efcc50934 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_sync_files.h @@ -19,7 +19,7 @@ class DiscoverModuleSyncFiles : public DiscoverModule { // DiscoverModule: bool IsCompleted() const override; - std::unique_ptr<DiscoverHandler> CreateWebUIHandler() const override; + std::unique_ptr<DiscoverHandler> CreateWebUIHandler() override; // Module name. static const char kModuleName[]; 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 c5c8cb6ec14..b5f75cdcd27 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 @@ -57,8 +57,7 @@ bool DiscoverModuleWelcome::IsCompleted() const { return false; } -std::unique_ptr<DiscoverHandler> DiscoverModuleWelcome::CreateWebUIHandler() - const { +std::unique_ptr<DiscoverHandler> DiscoverModuleWelcome::CreateWebUIHandler() { return std::make_unique<DiscoverModuleWelcomeHandler>(); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.h b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.h index bdde6246ce2..dcb1d6680e3 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/discover/modules/discover_module_welcome.h @@ -19,7 +19,7 @@ class DiscoverModuleWelcome : public DiscoverModule { // DiscoverModule: bool IsCompleted() const override; - std::unique_ptr<DiscoverHandler> CreateWebUIHandler() const override; + std::unique_ptr<DiscoverHandler> CreateWebUIHandler() override; // Module name. static const char kModuleName[]; 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 50ea95bae58..7fc1bc3d1ff 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 @@ -562,28 +562,32 @@ void EnrollmentScreenHandler::DeclareLocalizedValues( builder->Add("oauthEnrollWorking", IDS_ENTERPRISE_ENROLLMENT_WORKING_MESSAGE); // Do not use AddF for this string as it will be rendered by the JS code. builder->Add("oauthEnrollAbeSuccess", IDS_ENTERPRISE_ENROLLMENT_ABE_SUCCESS); + + /* Active Directory strings */ builder->Add("oauthEnrollAdMachineNameInput", IDS_AD_DEVICE_NAME_INPUT_LABEL); - builder->Add("oauthEnrollAdMachineNameInputRegex", - IDS_AD_DEVICE_NAME_REGEX_INPUT_LABEL); builder->Add("oauthEnrollAdDomainJoinWelcomeMessage", IDS_AD_DOMAIN_JOIN_WELCOME_MESSAGE); - builder->Add("adEnrollmentLoginUsername", IDS_AD_ENROLLMENT_LOGIN_USER); + builder->Add("adAuthLoginUsername", IDS_AD_AUTH_LOGIN_USER); builder->Add("adLoginInvalidUsername", IDS_AD_INVALID_USERNAME); builder->Add("adLoginPassword", IDS_AD_LOGIN_PASSWORD); builder->Add("adLoginInvalidPassword", IDS_AD_INVALID_PASSWORD); builder->Add("adJoinErrorMachineNameInvalid", IDS_AD_DEVICE_NAME_INVALID); builder->Add("adJoinErrorMachineNameTooLong", IDS_AD_DEVICE_NAME_TOO_LONG); - builder->Add("adJoinErrorMachineNameDoesntMatchRegex", - IDS_AD_DEVICE_NAME_DOESNT_MATCH_REGEX); + builder->Add("adJoinErrorMachineNameInvalidFormat", + IDS_AD_DEVICE_NAME_INVALID_FORMAT); builder->Add("adJoinMoreOptions", IDS_AD_MORE_OPTIONS_BUTTON); - builder->Add("adUnlockConfig", IDS_AD_UNLOCK_CONFIG); - builder->Add("adUnlockButton", IDS_AD_UNLOCK_CONFIG_UNLOCK_BUTTON); + builder->Add("adUnlockTitle", IDS_AD_UNLOCK_TITLE_MESSAGE); + builder->Add("adUnlockSubtitle", IDS_AD_UNLOCK_SUBTITLE_MESSAGE); builder->Add("adUnlockPassword", IDS_AD_UNLOCK_CONFIG_PASSWORD); builder->Add("adUnlockIncorrectPassword", IDS_AD_UNLOCK_INCORRECT_PASSWORD); builder->Add("adUnlockPasswordSkip", IDS_AD_UNLOCK_PASSWORD_SKIP); builder->Add("adJoinOrgUnit", IDS_AD_ORG_UNIT_HINT); builder->Add("adJoinCancel", IDS_AD_CANCEL_BUTTON); - builder->Add("adJoinConfirm", IDS_AD_CONFIRM_BUTTON); + builder->Add("adJoinSave", IDS_AD_SAVE_BUTTON); + builder->Add("selectEncryption", IDS_AD_ENCRYPTION_SELECTION_SELECT); + builder->Add("selectConfiguration", IDS_AD_CONFIG_SELECTION_SELECT); + /* End of Active Directory strings */ + builder->Add("licenseSelectionCardTitle", IDS_ENTERPRISE_ENROLLMENT_LICENSE_SELECTION); builder->Add("licenseSelectionCardExplanation", @@ -596,8 +600,6 @@ void EnrollmentScreenHandler::DeclareLocalizedValues( IDS_ENTERPRISE_ENROLLMENT_KIOSK_LICENSE_TYPE); builder->Add("licenseCountTemplate", IDS_ENTERPRISE_ENROLLMENT_LICENSES_REMAINING_TEMPLATE); - builder->Add("selectEncryption", IDS_AD_ENCRYPTION_SELECTION_SELECT); - builder->Add("selectConfiguration", IDS_AD_CONFIG_SELECTION_SELECT); } void EnrollmentScreenHandler::GetAdditionalParameters( 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 6b1a1887c5e..cd4fd7f4593 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 @@ -82,8 +82,6 @@ void FingerprintSetupScreenHandler::DeclareLocalizedValues( IDS_OOBE_FINGERPINT_SETUP_SCREEN_SENSOR_LOCATION_TITLE); builder->Add("enrollmentProgressScreenTitle", IDS_OOBE_FINGERPINT_SETUP_SCREEN_ENROLLMENT_PROGRESS_TITLE); - builder->Add("fingerprintSetupAddFingerprint", - IDS_OOBE_FINGERPINT_SETUP_SCREEN_BUTTON_ADD_FINGERPRINT); builder->Add("setupFingerprintEnrollmentSuccessTitle", IDS_OOBE_FINGERPINT_SETUP_SCREEN_ENROLLMENT_SUCCESS_TITLE); builder->Add("setupFingerprintEnrollmentSuccessDescription", 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 e3c2649b0a2..951eb55889b 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 @@ -177,9 +177,8 @@ void UpdateAuthParams(base::DictionaryValue* params, CrosSettings* cros_settings = CrosSettings::Get(); bool allow_new_user = true; cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); - params->SetBoolean( - "guestSignin", - chrome_user_manager_util::IsGuestSessionAllowed(cros_settings)); + params->SetBoolean("guestSignin", + user_manager::UserManager::Get()->IsGuestSessionAllowed()); // nosignup flow if new users are not allowed. if (!allow_new_user || is_restrictive_proxy) 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 new file mode 100644 index 00000000000..fb86a45d1b3 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.cc @@ -0,0 +1,46 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h" + +#include "chrome/browser/chromeos/login/screens/multidevice_setup_screen.h" +#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h" +#include "chrome/grit/generated_resources.h" +#include "components/login/localized_values_builder.h" + +namespace { + +const char kJsScreenPath[] = "login.MultiDeviceSetupScreen"; + +} // namespace + +namespace chromeos { + +MultiDeviceSetupScreenHandler::MultiDeviceSetupScreenHandler() + : BaseScreenHandler(kScreenId) { + set_call_js_prefix(kJsScreenPath); +} + +MultiDeviceSetupScreenHandler::~MultiDeviceSetupScreenHandler() = default; + +void MultiDeviceSetupScreenHandler::DeclareLocalizedValues( + ::login::LocalizedValuesBuilder* builder) { + multidevice_setup::AddLocalizedValuesToBuilder(builder); +} + +void MultiDeviceSetupScreenHandler::Bind(MultiDeviceSetupScreen* screen) { + BaseScreenHandler::SetBaseScreen(screen); +} + +void MultiDeviceSetupScreenHandler::Show() { + AllowJavascript(); + ShowScreen(kScreenId); + FireWebUIListener("multidevice_setup.initializeSetupFlow"); +} + +void MultiDeviceSetupScreenHandler::Hide() {} + +void MultiDeviceSetupScreenHandler::Initialize() {} + +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h new file mode 100644 index 00000000000..7df6c393032 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h @@ -0,0 +1,41 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MULTIDEVICE_SETUP_SCREEN_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MULTIDEVICE_SETUP_SCREEN_HANDLER_H_ + +#include "base/macros.h" +#include "chrome/browser/chromeos/login/screens/multidevice_setup_screen_view.h" +#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" + +namespace chromeos { + +class MultiDeviceSetupScreen; + +// Concrete MultiDeviceSetupScreenView WebUI-based implementation. +class MultiDeviceSetupScreenHandler : public BaseScreenHandler, + public MultiDeviceSetupScreenView { + public: + MultiDeviceSetupScreenHandler(); + ~MultiDeviceSetupScreenHandler() override; + + // BaseScreenHandler: + void DeclareLocalizedValues( + ::login::LocalizedValuesBuilder* builder) override; + + // MultiDeviceSetupScreenView: + void Bind(MultiDeviceSetupScreen* screen) override; + void Show() override; + void Hide() override; + + private: + // BaseScreenHandler: + void Initialize() override; + + DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupScreenHandler); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_MULTIDEVICE_SETUP_SCREEN_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc index 939f64a69a9..fd7e20a72fc 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 @@ -8,7 +8,9 @@ #include "ash/public/interfaces/constants.mojom.h" #include "base/strings/string_number_conversions.h" +#include "base/task/post_task.h" #include "chrome/browser/ui/ash/ash_util.h" +#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/service_manager_connection.h" #include "services/service_manager/public/cpp/connector.h" @@ -62,8 +64,8 @@ void OobeDisplayChooser::TryToPlaceUiOnTouchDisplay() { display::Screen::GetScreen()->GetPrimaryDisplay(); if (primary_display.is_valid() && !TouchSupportAvailable(primary_display)) { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, + base::PostTaskWithTraits( + FROM_HERE, {BrowserThread::UI}, base::BindOnce(&OobeDisplayChooser::MaybeMoveToTouchDisplay, weak_ptr_factory_.GetWeakPtr())); } 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 eb08cdc2e10..01d482a0c47 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 @@ -121,7 +121,7 @@ TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) { // Setup corresponding TouchscreenDevice object ui::TouchscreenDevice touchscreen = - ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_USB, "Touchscreen", gfx::Size(800, 600), 1); touchscreen.vendor_id = kWhitelistedId; ws::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen}); @@ -164,7 +164,7 @@ TEST_F(OobeDisplayChooserTest, DontSwitchFromTouch) { // Setup corresponding TouchscreenDevice object ui::TouchscreenDevice touchscreen = - ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, + ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_USB, "Touchscreen", gfx::Size(800, 600), 1); touchscreen.vendor_id = kWhitelistedId; ws::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen}); 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 b3a45be6728..6d29d83b006 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc @@ -10,6 +10,7 @@ #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_switches.h" +#include "base/bind.h" #include "base/command_line.h" #include "base/logging.h" #include "base/macros.h" @@ -32,6 +33,7 @@ #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/webui/about_ui.h" #include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h" @@ -59,6 +61,7 @@ #include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/marketing_opt_in_screen_handler.h" +#include "chrome/browser/ui/webui/chromeos/login/multidevice_setup_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h" #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" @@ -66,7 +69,6 @@ #include "chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" -#include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/update_required_screen_handler.h" @@ -78,6 +80,7 @@ #include "chrome/browser/ui/webui/chromeos/login/welcome_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/user_image_source.h" +#include "chrome/browser/ui/webui/chromeos/video_source.h" #include "chrome/browser/ui/webui/test_files_request_filter.h" #include "chrome/browser/ui/webui/theme_source.h" #include "chrome/common/chrome_constants.h" @@ -89,11 +92,14 @@ #include "chrome/grit/chrome_unscaled_resources.h" #include "chrome/grit/component_extension_resources.h" #include "chromeos/chromeos_switches.h" +#include "chromeos/services/multidevice_setup/public/mojom/constants.mojom.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "components/prefs/pref_service.h" +#include "content/public/browser/browser_context.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/common/content_switches.h" +#include "services/service_manager/public/cpp/connector.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_features.h" #include "ui/base/webui/web_ui_util.h" @@ -335,12 +341,6 @@ void OobeUI::ConfigureOobeDisplay() { AddScreenHandler(std::make_unique<KioskEnableScreenHandler>()); - auto supervised_user_creation_screen_handler = - std::make_unique<SupervisedUserCreationScreenHandler>(); - supervised_user_creation_screen_view_ = - supervised_user_creation_screen_handler.get(); - AddScreenHandler(std::move(supervised_user_creation_screen_handler)); - AddScreenHandler(std::make_unique<WrongHWIDScreenHandler>()); AddScreenHandler(std::make_unique<AutoEnrollmentCheckScreenHandler>()); @@ -426,6 +426,8 @@ void OobeUI::ConfigureOobeDisplay() { AddScreenHandler(std::make_unique<AssistantOptInFlowScreenHandler>()); + AddScreenHandler(std::make_unique<MultiDeviceSetupScreenHandler>()); + // Initialize KioskAppMenuHandler. Note that it is NOT a screen handler. auto kiosk_app_menu_handler = std::make_unique<KioskAppMenuHandler>(network_state_informer_); @@ -434,28 +436,51 @@ void OobeUI::ConfigureOobeDisplay() { Profile* profile = Profile::FromWebUI(web_ui()); // Set up the chrome://theme/ source, for Chrome logo. - ThemeSource* theme = new ThemeSource(profile); - content::URLDataSource::Add(profile, theme); + content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile)); // Set up the chrome://terms/ data source, for EULA content. - AboutUIHTMLSource* about_source = - new AboutUIHTMLSource(chrome::kChromeUITermsHost, profile); - content::URLDataSource::Add(profile, about_source); + content::URLDataSource::Add( + profile, + std::make_unique<AboutUIHTMLSource>(chrome::kChromeUITermsHost, profile)); // Set up the chrome://userimage/ source. - UserImageSource* user_image_source = new UserImageSource(); - content::URLDataSource::Add(profile, user_image_source); + content::URLDataSource::Add(profile, std::make_unique<UserImageSource>()); // TabHelper is required for OOBE webui to make webview working on it. content::WebContents* contents = web_ui()->GetWebContents(); extensions::TabHelper::CreateForWebContents(contents); + // // Handler for the oobe video assets which will be shown if available. + content::URLDataSource::Add(profile, + std::make_unique<chromeos::VideoSource>()); + if (IsRemoraRequisitioned()) oobe_display_chooser_ = std::make_unique<OobeDisplayChooser>(); } +service_manager::Connector* OobeUI::GetLoggedInUserMojoConnector() { + // This function should only be called after the user has logged in. + DCHECK( + user_manager::UserManager::Get()->IsUserLoggedIn() && + user_manager::UserManager::Get()->GetActiveUser()->is_profile_created()); + return content::BrowserContext::GetConnectorFor( + ProfileManager::GetActiveUserProfile()); +} + +void OobeUI::BindMultiDeviceSetup( + multidevice_setup::mojom::MultiDeviceSetupRequest request) { + GetLoggedInUserMojoConnector()->BindInterface( + multidevice_setup::mojom::kServiceName, std::move(request)); +} + +void OobeUI::BindPrivilegedHostDeviceSetter( + multidevice_setup::mojom::PrivilegedHostDeviceSetterRequest request) { + GetLoggedInUserMojoConnector()->BindInterface( + multidevice_setup::mojom::kServiceName, std::move(request)); +} + OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url) - : WebUIController(web_ui) { + : ui::MojoWebUIController(web_ui, true /* enable_chrome_send */) { display_type_ = GetDisplayType(url); js_calls_container = std::make_unique<JSCallsContainer>(); @@ -480,11 +505,15 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url) content::WebUIDataSource* html_source = CreateOobeUIDataSource(localized_strings, display_type_); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); -} -OobeUI::~OobeUI() { + AddHandlerToRegistry(base::BindRepeating(&OobeUI::BindMultiDeviceSetup, + base::Unretained(this))); + AddHandlerToRegistry(base::BindRepeating( + &OobeUI::BindPrivilegedHostDeviceSetter, base::Unretained(this))); } +OobeUI::~OobeUI() {} + CoreOobeView* OobeUI::GetCoreOobeView() { return core_handler_; } @@ -602,6 +631,10 @@ AssistantOptInFlowScreenView* OobeUI::GetAssistantOptInFlowScreenView() { return GetView<AssistantOptInFlowScreenHandler>(); } +MultiDeviceSetupScreenView* OobeUI::GetMultiDeviceSetupScreenView() { + return GetView<MultiDeviceSetupScreenHandler>(); +} + UserImageView* OobeUI::GetUserImageView() { return GetView<UserImageScreenHandler>(); } @@ -610,11 +643,6 @@ ErrorScreen* OobeUI::GetErrorScreen() { return error_screen_.get(); } -SupervisedUserCreationScreenHandler* -OobeUI::GetSupervisedUserCreationScreenView() { - return supervised_user_creation_screen_view_; -} - GaiaView* OobeUI::GetGaiaScreenView() { return GetView<GaiaScreenHandler>(); } 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 d40fbf186a4..6ae64eac3b9 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h @@ -18,12 +18,17 @@ #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 "content/public/browser/web_ui_controller.h" +#include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h" +#include "ui/webui/mojo_web_ui_controller.h" namespace base { class DictionaryValue; } // namespace base +namespace service_manager { +class Connector; +} // namespace service_manager + namespace chromeos { class AppDownloadingScreenView; class AppLaunchSplashScreenView; @@ -52,6 +57,7 @@ class KioskAutolaunchScreenView; class KioskEnableScreenView; class LoginScreenContext; class MarketingOptInScreenView; +class MultiDeviceSetupScreenView; class NativeWindowDelegate; class NetworkScreenView; class NetworkStateInformer; @@ -60,7 +66,6 @@ class RecommendAppsScreenView; class ResetView; class SigninScreenHandler; class SigninScreenHandlerDelegate; -class SupervisedUserCreationScreenHandler; class SyncConsentScreenView; class TermsOfServiceScreenView; class UserBoardView; @@ -76,7 +81,7 @@ class WrongHWIDScreenView; // - welcome screen (setup language/keyboard/network). // - eula screen (CrOS (+ OEM) EULA content/TPM password/crash reporting). // - update screen. -class OobeUI : public content::WebUIController, +class OobeUI : public ui::MojoWebUIController, public ShutdownPolicyHandler::Delegate { public: // List of known types of OobeUI. Type added as path in chrome://oobe url, for @@ -127,7 +132,6 @@ class OobeUI : public content::WebUIController, ErrorScreen* GetErrorScreen(); WrongHWIDScreenView* GetWrongHWIDScreenView(); AutoEnrollmentCheckScreenView* GetAutoEnrollmentCheckScreenView(); - SupervisedUserCreationScreenHandler* GetSupervisedUserCreationScreenView(); AppLaunchSplashScreenView* GetAppLaunchSplashScreenView(); ArcKioskSplashScreenView* GetArcKioskSplashScreenView(); HIDDetectionView* GetHIDDetectionView(); @@ -139,6 +143,7 @@ class OobeUI : public content::WebUIController, WaitForContainerReadyScreenView* GetWaitForContainerReadyScreenView(); UpdateRequiredView* GetUpdateRequiredScreenView(); AssistantOptInFlowScreenView* GetAssistantOptInFlowScreenView(); + MultiDeviceSetupScreenView* GetMultiDeviceSetupScreenView(); GaiaView* GetGaiaScreenView(); UserBoardView* GetUserBoardView(); DiscoverScreenView* GetDiscoverScreenView(); @@ -228,6 +233,13 @@ class OobeUI : public content::WebUIController, // display type. void ConfigureOobeDisplay(); + // Adds Mojo bindings for this WebUIController. + service_manager::Connector* GetLoggedInUserMojoConnector(); + void BindMultiDeviceSetup( + multidevice_setup::mojom::MultiDeviceSetupRequest request); + void BindPrivilegedHostDeviceSetter( + multidevice_setup::mojom::PrivilegedHostDeviceSetterRequest request); + // Type of UI. std::string display_type_; @@ -238,8 +250,6 @@ class OobeUI : public content::WebUIController, // Reference to CoreOobeHandler that handles common requests of Oobe page. CoreOobeHandler* core_handler_ = nullptr; - SupervisedUserCreationScreenHandler* supervised_user_creation_screen_view_ = - nullptr; // Reference to SigninScreenHandler that handles sign-in screen requests and // forwards calls from native code to JS side. SigninScreenHandler* signin_screen_handler_ = nullptr; 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 75924f17d03..df7748287f1 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 @@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h" +#include "base/metrics/histogram_macros.h" #include "chrome/browser/chromeos/arc/arc_session_manager.h" #include "chrome/browser/chromeos/login/screens/recommend_apps_screen.h" #include "chrome/browser/profiles/profile.h" @@ -23,6 +24,51 @@ constexpr const char kUserActionSkip[] = "recommendAppsSkip"; constexpr const char kUserActionRetry[] = "recommendAppsRetry"; constexpr const char kUserActionInstall[] = "recommendAppsInstall"; +constexpr const int kMaxAppCount = 21; + +enum class RecommendAppsScreenState { + // These values are persisted to logs. Entries should not be renumbered and + // numeric values should never be reused. This should be kept in sync with + // RecommendAppsScreenState in enums.xml. + SHOW = 0, + NO_SHOW = 1, + ERROR = 2, + + kMaxValue = ERROR +}; + +enum class RecommendAppsScreenAction { + // These values are persisted to logs. Entries should not be renumbered and + // numeric values should never be reused. This should be kept in sync with + // RecommendAppsScreenAction in enums.xml. + SKIPPED = 0, + RETRIED = 1, + SELECTED_NONE = 2, + APP_SELECTED = 3, + + kMaxValue = APP_SELECTED +}; + +void RecordUmaUserSelectionAppCount(int app_count) { + UMA_HISTOGRAM_EXACT_LINEAR("OOBE.RecommendApps.Screen.SelectedAppCount", + app_count, kMaxAppCount); +} + +void RecordUmaSelectedRecommendedPercentage( + int selected_recommended_percentage) { + UMA_HISTOGRAM_PERCENTAGE( + "OOBE.RecommendApps.Screen.SelectedRecommendedPercentage", + selected_recommended_percentage); +} + +void RecordUmaScreenState(RecommendAppsScreenState state) { + UMA_HISTOGRAM_ENUMERATION("OOBE.RecommendApps.Screen.State", state); +} + +void RecordUmaScreenAction(RecommendAppsScreenAction action) { + UMA_HISTOGRAM_ENUMERATION("OOBE.RecommendApps.Screen.Action", action); +} + } // namespace namespace chromeos { @@ -52,7 +98,7 @@ void RecommendAppsScreenHandler::DeclareLocalizedValues( void RecommendAppsScreenHandler::RegisterMessages() { BaseScreenHandler::RegisterMessages(); - AddCallback(kUserActionSkip, &RecommendAppsScreenHandler::HandleSkip); + AddCallback(kUserActionSkip, &RecommendAppsScreenHandler::OnUserSkip); AddCallback(kUserActionRetry, &RecommendAppsScreenHandler::HandleRetry); AddRawCallback(kUserActionInstall, &RecommendAppsScreenHandler::HandleInstall); @@ -86,9 +132,12 @@ void RecommendAppsScreenHandler::Initialize() {} void RecommendAppsScreenHandler::LoadAppListInUI(const base::Value& app_list) { if (!page_is_ready()) { + RecordUmaScreenState(RecommendAppsScreenState::ERROR); CallJS("showError"); return; } + + RecordUmaScreenState(RecommendAppsScreenState::SHOW); const ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); base::StringPiece app_list_webview = resource_bundle.GetRawDataResource( @@ -98,35 +147,58 @@ void RecommendAppsScreenHandler::LoadAppListInUI(const base::Value& app_list) { } void RecommendAppsScreenHandler::OnLoadError() { + RecordUmaScreenState(RecommendAppsScreenState::ERROR); CallJS("showError"); } void RecommendAppsScreenHandler::OnLoadSuccess(const base::Value& app_list) { + recommended_app_count_ = static_cast<int>(app_list.GetList().size()); LoadAppListInUI(app_list); } void RecommendAppsScreenHandler::OnParseResponseError() { + RecordUmaScreenState(RecommendAppsScreenState::NO_SHOW); + HandleSkip(); +} +void RecommendAppsScreenHandler::OnUserSkip() { + RecordUmaScreenAction(RecommendAppsScreenAction::SKIPPED); HandleSkip(); } +// There are three scenarios that HandleSkip() is called: +// 1. The user clicks the Skip button. +// 2. The user doesn't select any apps and click the Install button. +// 3. The response from the fetcher cannot be parsed. +// Each case has its own entry point to be logged. void RecommendAppsScreenHandler::HandleSkip() { for (auto& observer : observer_list_) observer.OnSkip(); } void RecommendAppsScreenHandler::HandleRetry() { + RecordUmaScreenAction(RecommendAppsScreenAction::RETRIED); for (auto& observer : observer_list_) observer.OnRetry(); } void RecommendAppsScreenHandler::HandleInstall(const base::ListValue* args) { + if (recommended_app_count_ != 0) { + int selected_app_count = static_cast<int>(args->GetSize()); + int selected_recommended_percentage = + 100 * selected_app_count / recommended_app_count_; + RecordUmaUserSelectionAppCount(selected_app_count); + RecordUmaSelectedRecommendedPercentage(selected_recommended_percentage); + } + // If the user does not select any apps, we should skip the app downloading // screen. if (args->GetList().empty()) { + RecordUmaScreenAction(RecommendAppsScreenAction::SELECTED_NONE); HandleSkip(); return; } + RecordUmaScreenAction(RecommendAppsScreenAction::APP_SELECTED); pref_service_->Set(arc::prefs::kArcFastAppReinstallPackages, *args); arc::ArcFastAppReinstallStarter* fast_app_reinstall_starter = diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h index 723c44bfc42..f935f3cd83c 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h @@ -43,6 +43,8 @@ class RecommendAppsScreenHandler : public BaseScreenHandler, void OnLoadSuccess(const base::Value& app_list) override; void OnParseResponseError() override; + void OnUserSkip(); + // Call the JS function to load the list of apps in the WebView. void LoadAppListInUI(const base::Value& app_list); @@ -57,6 +59,8 @@ class RecommendAppsScreenHandler : public BaseScreenHandler, base::ObserverList<RecommendAppsScreenViewObserver, true>::Unchecked observer_list_; + int recommended_app_count_ = 0; + DISALLOW_COPY_AND_ASSIGN(RecommendAppsScreenHandler); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h b/chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h index 98e86f8d8d2..d6715f1afa8 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h +++ b/chromium/chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h @@ -18,6 +18,7 @@ class ScreenlockIconSource : public content::URLDataSource { public: explicit ScreenlockIconSource( base::WeakPtr<ScreenlockIconProvider> icon_provider); + ~ScreenlockIconSource() override; // content::URLDataSource implementation. std::string GetSource() const override; @@ -32,8 +33,6 @@ class ScreenlockIconSource : public content::URLDataSource { static std::string GetIconURLForUser(const std::string& username); private: - ~ScreenlockIconSource() override; - base::WeakPtr<ScreenlockIconProvider> icon_provider_; DISALLOW_COPY_AND_ASSIGN(ScreenlockIconSource); 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 3ba24b7fc48..e7d6e4c5de3 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 @@ -17,7 +17,6 @@ #include "ash/public/interfaces/shutdown.mojom.h" #include "ash/public/interfaces/tray_action.mojom.h" #include "ash/shell.h" -#include "ash/strings/grit/ash_strings.h" #include "base/bind.h" #include "base/i18n/number_formatting.h" #include "base/location.h" @@ -93,6 +92,7 @@ #include "chromeos/login/auth/user_context.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" +#include "chromeos/strings/grit/chromeos_strings.h" #include "components/login/localized_values_builder.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" @@ -376,8 +376,6 @@ void SigninScreenHandler::DeclareLocalizedValues( 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("addSupervisedUser", - IDS_CREATE_LEGACY_SUPERVISED_USER_MENU_LABEL); builder->Add("cancel", IDS_ASH_SHELF_CANCEL_BUTTON); builder->Add("signOutUser", IDS_ASH_SHELF_SIGN_OUT_BUTTON); builder->Add("unlockUser", IDS_ASH_SHELF_UNLOCK_BUTTON); @@ -506,8 +504,6 @@ void SigninScreenHandler::RegisterMessages() { AddCallback("completeOfflineAuthentication", &SigninScreenHandler::HandleCompleteOfflineAuthentication); AddCallback("launchIncognito", &SigninScreenHandler::HandleLaunchIncognito); - AddCallback("showSupervisedUserCreationScreen", - &SigninScreenHandler::HandleShowSupervisedUserCreationScreen); AddCallback("launchPublicSession", &SigninScreenHandler::HandleLaunchPublicSession); AddRawCallback("offlineLogin", &SigninScreenHandler::HandleOfflineLogin); @@ -854,15 +850,15 @@ void SigninScreenHandler::SetupAndShowOfflineMessage( std::string()); } - const bool guest_signin_allowed = - chrome_user_manager_util::IsGuestSessionAllowed(CrosSettings::Get()) && - IsSigninScreenError(error_screen_->GetErrorState()); + bool guest_signin_allowed = false; + bool offline_login_allowed = false; + if (IsSigninScreenError(error_screen_->GetErrorState())) { + guest_signin_allowed = + user_manager::UserManager::Get()->IsGuestSessionAllowed(); + offline_login_allowed = error_screen_->GetErrorState() != + NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT; + } error_screen_->AllowGuestSignin(guest_signin_allowed); - - const bool offline_login_allowed = - IsSigninScreenError(error_screen_->GetErrorState()) && - error_screen_->GetErrorState() != - NetworkError::ERROR_STATE_AUTH_EXT_TIMEOUT; error_screen_->AllowOfflineLogin(offline_login_allowed); if (GetCurrentScreen() != OobeScreen::SCREEN_ERROR_MESSAGE) { @@ -1265,15 +1261,6 @@ void SigninScreenHandler::HandleLaunchIncognito() { delegate_->Login(context, SigninSpecifics()); } -void SigninScreenHandler::HandleShowSupervisedUserCreationScreen() { - if (!user_manager::UserManager::Get()->AreSupervisedUsersAllowed()) { - LOG(ERROR) << "Managed users not allowed."; - return; - } - LoginDisplayHost::default_host()->StartWizard( - OobeScreen::SCREEN_CREATE_SUPERVISED_USER_FLOW); -} - void SigninScreenHandler::HandleLaunchPublicSession( const AccountId& account_id, const std::string& locale, @@ -1629,6 +1616,11 @@ void SigninScreenHandler::HandleMaxIncorrectPasswordAttempts( } void SigninScreenHandler::HandleSendFeedback() { + if (!LoginFeedback::IsEnabled()) { + OnFeedbackFinished(); + return; + } + login_feedback_ = std::make_unique<LoginFeedback>(Profile::FromWebUI(web_ui())); login_feedback_->Request( @@ -1637,6 +1629,11 @@ void SigninScreenHandler::HandleSendFeedback() { } void SigninScreenHandler::HandleSendFeedbackAndResyncUserData() { + if (!LoginFeedback::IsEnabled()) { + OnUnrecoverableCryptohomeFeedbackFinished(); + return; + } + const std::string description = base::StringPrintf( "Auto generated feedback for http://crbug.com/547857.\n" "(uniquifier:%s)", 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 9c3a788ca45..c8e234bf48d 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 @@ -73,7 +73,6 @@ class ErrorScreensHistogramHelper; class GaiaScreenHandler; class LoginFeedback; class NativeWindowDelegate; -class SupervisedUserCreationScreenHandler; class User; class UserContext; @@ -280,7 +279,6 @@ class SigninScreenHandler friend class GaiaScreenHandler; friend class ReportDnsCacheClearedOnUIThread; - friend class SupervisedUserCreationScreenHandler; friend class LoginDisplayHostMojo; void ShowImpl(); @@ -391,7 +389,6 @@ class SigninScreenHandler void HandleUnlockOnLoginSuccess(); void HandleLoginScreenUpdate(); void HandleShowLoadingTimeoutError(); - void HandleShowSupervisedUserCreationScreen(); void HandleFocusPod(const AccountId& account_id, bool is_large_pod); void HandleNoPodFocused(); void HandleHardlockPod(const std::string& user_id); diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc deleted file mode 100644 index a6e4906ac6c..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc +++ /dev/null @@ -1,461 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.h" - -#include <memory> -#include <utility> - -#include "base/strings/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/accessibility/accessibility_manager.h" -#include "chrome/browser/chromeos/login/oobe_screen.h" -#include "chrome/browser/chromeos/login/screens/user_selection_screen.h" -#include "chrome/browser/chromeos/login/supervised/supervised_user_creation_flow.h" -#include "chrome/browser/chromeos/login/users/chrome_user_manager.h" -#include "chrome/browser/chromeos/login/users/supervised_user_manager.h" -#include "chrome/browser/chromeos/settings/cros_settings.h" -#include "chrome/browser/ui/ash/wallpaper_controller_client.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/account_id/account_id.h" -#include "components/login/localized_values_builder.h" -#include "components/user_manager/user_manager.h" -#include "components/user_manager/user_type.h" -#include "google_apis/gaia/gaia_auth_util.h" -#include "media/audio/sounds/sounds_manager.h" -#include "net/base/data_url.h" -#include "net/base/escape.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" - -const char kJsScreenPath[] = "login.SupervisedUserCreationScreen"; - -namespace chromeos { - -SupervisedUserCreationScreenHandler::SupervisedUserCreationScreenHandler() - : BaseScreenHandler(OobeScreen::SCREEN_CREATE_SUPERVISED_USER_FLOW) { - 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)); -} - -SupervisedUserCreationScreenHandler::~SupervisedUserCreationScreenHandler() { - if (delegate_) { - delegate_->OnViewDestroyed(this); - } -} - -void SupervisedUserCreationScreenHandler::DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) { - builder->Add( - "supervisedUserCreationFlowRetryButtonTitle", - IDS_CREATE_SUPERVISED_USER_CREATION_ERROR_RETRY_BUTTON_TITLE); - builder->Add( - "supervisedUserCreationFlowCancelButtonTitle", - IDS_CREATE_SUPERVISED_USER_CREATION_ERROR_CANCEL_BUTTON_TITLE); - builder->Add( - "supervisedUserCreationFlowGotitButtonTitle", - IDS_CREATE_SUPERVISED_USER_CREATION_GOT_IT_BUTTON_TITLE); - - builder->Add("createSupervisedUserIntroTextTitle", - IDS_CREATE_SUPERVISED_INTRO_TEXT_TITLE); - builder->Add("createSupervisedUserIntroAlternateText", - IDS_CREATE_SUPERVISED_INTRO_ALTERNATE_TEXT); - builder->Add("createSupervisedUserIntroText1", - IDS_CREATE_SUPERVISED_INTRO_TEXT_1); - builder->Add("createSupervisedUserIntroManagerItem1", - IDS_CREATE_SUPERVISED_INTRO_MANAGER_ITEM_1); - builder->Add("createSupervisedUserIntroManagerItem2", - IDS_CREATE_SUPERVISED_INTRO_MANAGER_ITEM_2); - builder->Add("createSupervisedUserIntroManagerItem3", - IDS_CREATE_SUPERVISED_INTRO_MANAGER_ITEM_3); - builder->Add("createSupervisedUserIntroText2", - IDS_CREATE_SUPERVISED_INTRO_TEXT_2); - builder->AddF("createSupervisedUserIntroText3", - IDS_CREATE_SUPERVISED_INTRO_TEXT_3, - base::UTF8ToUTF16( - chrome::kLegacySupervisedUserManagementDisplayURL)); - - builder->Add("createSupervisedUserPickManagerTitle", - IDS_CREATE_SUPERVISED_USER_CREATE_PICK_MANAGER_TITLE); - builder->AddF("createSupervisedUserPickManagerTitleExplanation", - IDS_CREATE_SUPERVISED_USER_CREATE_PICK_MANAGER_EXPLANATION, - base::UTF8ToUTF16( - chrome::kLegacySupervisedUserManagementDisplayURL)); - builder->Add("createSupervisedUserManagerPasswordHint", - IDS_CREATE_SUPERVISED_USER_CREATE_MANAGER_PASSWORD_HINT); - builder->Add("createSupervisedUserWrongManagerPasswordText", - IDS_CREATE_SUPERVISED_USER_MANAGER_PASSWORD_ERROR); - - builder->Add("createSupervisedUserNameTitle", - IDS_CREATE_SUPERVISED_USER_CREATE_ACCOUNT_NAME_TITLE); - builder->Add("createSupervisedUserNameAccessibleTitle", - IDS_CREATE_SUPERVISED_USER_SETUP_ACCESSIBLE_TITLE); - builder->Add("createSupervisedUserNameExplanation", - IDS_CREATE_SUPERVISED_USER_CREATE_ACCOUNT_NAME_EXPLANATION); - builder->Add("createSupervisedUserNameHint", - IDS_CREATE_SUPERVISED_USER_CREATE_ACCOUNT_NAME_HINT); - builder->Add("createSupervisedUserPasswordTitle", - IDS_CREATE_SUPERVISED_USER_CREATE_PASSWORD_TITLE); - builder->Add("createSupervisedUserPasswordExplanation", - IDS_CREATE_SUPERVISED_USER_CREATE_PASSWORD_EXPLANATION); - builder->Add("createSupervisedUserPasswordHint", - IDS_CREATE_SUPERVISED_USER_CREATE_PASSWORD_HINT); - builder->Add("createSupervisedUserPasswordConfirmHint", - IDS_CREATE_SUPERVISED_USER_CREATE_PASSWORD_CONFIRM_HINT); - builder->Add("supervisedUserCreationFlowProceedButtonTitle", - IDS_CREATE_SUPERVISED_USER_CREATE_CONTINUE_BUTTON_TEXT); - builder->Add("supervisedUserCreationFlowStartButtonTitle", - IDS_CREATE_SUPERVISED_USER_CREATE_START_BUTTON_TEXT); - builder->Add("supervisedUserCreationFlowPrevButtonTitle", - IDS_CREATE_SUPERVISED_USER_CREATE_PREVIOUS_BUTTON_TEXT); - builder->Add("supervisedUserCreationFlowNextButtonTitle", - IDS_CREATE_SUPERVISED_USER_CREATE_NEXT_BUTTON_TEXT); - builder->Add("supervisedUserCreationFlowHandleErrorButtonTitle", - IDS_CREATE_SUPERVISED_USER_CREATE_HANDLE_ERROR_BUTTON_TEXT); - builder->Add("createSupervisedUserPasswordMismatchError", - IDS_CREATE_SUPERVISED_USER_CREATE_PASSWORD_MISMATCH_ERROR); - - builder->Add("createSupervisedUserCreatedText1", - IDS_CREATE_SUPERVISED_USER_CREATED_1_TEXT_1); - builder->Add("createSupervisedUserCreatedText2", - IDS_CREATE_SUPERVISED_USER_CREATED_1_TEXT_2); - builder->Add("createSupervisedUserCreatedText3", - IDS_CREATE_SUPERVISED_USER_CREATED_1_TEXT_3); - - builder->Add("importExistingSupervisedUserTitle", - IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TITLE); - builder->Add("importSupervisedUserLink", - IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TITLE); - builder->Add("importExistingSupervisedUserText", - IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TEXT); - builder->Add("supervisedUserCreationFlowImportButtonTitle", - IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_OK); - builder->Add("createSupervisedUserLink", - IDS_CREATE_NEW_LEGACY_SUPERVISED_USER_LINK); - builder->Add("importBubbleText", - IDS_SUPERVISED_USER_IMPORT_BUBBLE_TEXT); - builder->Add("importUserExists", - IDS_SUPERVISED_USER_IMPORT_USER_EXIST); - builder->Add("importUsernameExists", - IDS_SUPERVISED_USER_IMPORT_USERNAME_EXIST); - - builder->Add("managementURL", - chrome::kLegacySupervisedUserManagementDisplayURL); - - // TODO(antrim) : this is an explicit code duplications with UserImageScreen. - // It should be removed by issue 251179. - builder->Add("takePhoto", IDS_OPTIONS_CHANGE_PICTURE_TAKE_PHOTO); - builder->Add("discardPhoto", IDS_OPTIONS_CHANGE_PICTURE_DISCARD_PHOTO); - builder->Add("photoCaptureAccessibleText", - IDS_OPTIONS_PHOTO_CAPTURE_ACCESSIBLE_TEXT); - builder->Add("photoDiscardAccessibleText", - IDS_OPTIONS_PHOTO_DISCARD_ACCESSIBLE_TEXT); -} - -void SupervisedUserCreationScreenHandler::Initialize() {} - -void SupervisedUserCreationScreenHandler::RegisterMessages() { - AddCallback("finishLocalSupervisedUserCreation", - &SupervisedUserCreationScreenHandler:: - HandleFinishLocalSupervisedUserCreation); - AddCallback("abortLocalSupervisedUserCreation", - &SupervisedUserCreationScreenHandler:: - HandleAbortLocalSupervisedUserCreation); - AddCallback("hideLocalSupervisedUserCreation", - &SupervisedUserCreationScreenHandler:: - HandleHideLocalSupervisedUserCreation); - AddCallback("checkSupervisedUserName", - &SupervisedUserCreationScreenHandler:: - HandleCheckSupervisedUserName); - AddCallback("authenticateManagerInSupervisedUserCreationFlow", - &SupervisedUserCreationScreenHandler:: - HandleAuthenticateManager); - AddCallback("specifySupervisedUserCreationFlowUserData", - &SupervisedUserCreationScreenHandler:: - HandleCreateSupervisedUser); - AddCallback("managerSelectedOnSupervisedUserCreationFlow", - &SupervisedUserCreationScreenHandler:: - HandleManagerSelected); - AddCallback("userSelectedForImportInSupervisedUserCreationFlow", - &SupervisedUserCreationScreenHandler:: - HandleImportUserSelected); - AddCallback("importSupervisedUser", - &SupervisedUserCreationScreenHandler:: - HandleImportSupervisedUser); - AddCallback("importSupervisedUserWithPassword", - &SupervisedUserCreationScreenHandler:: - HandleImportSupervisedUserWithPassword); - - - // TODO(antrim) : this is an explicit code duplications with UserImageScreen. - // It should be removed by issue 251179. - AddCallback("supervisedUserGetImages", - &SupervisedUserCreationScreenHandler::HandleGetImages); - - AddCallback("supervisedUserPhotoTaken", - &SupervisedUserCreationScreenHandler::HandlePhotoTaken); - AddCallback("supervisedUserTakePhoto", - &SupervisedUserCreationScreenHandler::HandleTakePhoto); - AddCallback("supervisedUserDiscardPhoto", - &SupervisedUserCreationScreenHandler::HandleDiscardPhoto); - AddCallback("supervisedUserSelectImage", - &SupervisedUserCreationScreenHandler::HandleSelectImage); - AddCallback("currentSupervisedUserPage", - &SupervisedUserCreationScreenHandler:: - HandleCurrentSupervisedUserPage); -} - -void SupervisedUserCreationScreenHandler::Show() { - std::unique_ptr<base::DictionaryValue> data(new base::DictionaryValue()); - std::unique_ptr<base::ListValue> users_list(new base::ListValue()); - const user_manager::UserList& users = - ChromeUserManager::Get()->GetUsersAllowedForSupervisedUsersCreation(); - std::string owner; - chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); - - for (user_manager::UserList::const_iterator it = users.begin(); - it != users.end(); - ++it) { - bool is_owner = ((*it)->GetAccountId().GetUserEmail() == owner); - auto user_dict = std::make_unique<base::DictionaryValue>(); - UserSelectionScreen::FillUserDictionary( - *it, is_owner, false, /* is_signin_to_add */ - proximity_auth::mojom::AuthType::OFFLINE_PASSWORD, - NULL, /* public_session_recommended_locales */ - user_dict.get()); - users_list->Append(std::move(user_dict)); - } - data->Set("managers", std::move(users_list)); - ShowScreenWithData(OobeScreen::SCREEN_CREATE_SUPERVISED_USER_FLOW, - data.get()); - - if (!delegate_) - return; -} - -void SupervisedUserCreationScreenHandler::Hide() { -} - -void SupervisedUserCreationScreenHandler::ShowIntroPage() { - CallJS("showIntroPage"); -} - -void SupervisedUserCreationScreenHandler::ShowManagerPasswordError() { - CallJS("showManagerPasswordError"); -} - -void SupervisedUserCreationScreenHandler::ShowStatusMessage( - bool is_progress, - const base::string16& message) { - if (is_progress) - CallJS("showProgress", message); - else - CallJS("showStatusError", message); -} - -void SupervisedUserCreationScreenHandler::ShowUsernamePage() { - CallJS("showUsernamePage"); -} - -void SupervisedUserCreationScreenHandler::ShowTutorialPage() { - CallJS("showTutorialPage"); -} - -void SupervisedUserCreationScreenHandler::ShowErrorPage( - const base::string16& title, - const base::string16& message, - const base::string16& button_text) { - CallJS("showErrorPage", title, message, button_text); -} - -void SupervisedUserCreationScreenHandler::SetDelegate(Delegate* delegate) { - delegate_ = delegate; -} - -void SupervisedUserCreationScreenHandler:: - HandleFinishLocalSupervisedUserCreation() { - delegate_->FinishFlow(); -} - -void SupervisedUserCreationScreenHandler:: - HandleAbortLocalSupervisedUserCreation() { - delegate_->AbortFlow(); -} - -void SupervisedUserCreationScreenHandler:: - HandleHideLocalSupervisedUserCreation() { - delegate_->HideFlow(); -} - -void SupervisedUserCreationScreenHandler::HandleManagerSelected( - const AccountId& manager_id) { - if (!delegate_) - return; - WallpaperControllerClient::Get()->ShowUserWallpaper(manager_id); -} - -void SupervisedUserCreationScreenHandler::HandleImportUserSelected( - const AccountId& account_id) { - if (!delegate_) - return; -} - -void SupervisedUserCreationScreenHandler::HandleCheckSupervisedUserName( - const base::string16& name) { - std::string user_id; - if (NULL != - ChromeUserManager::Get()->GetSupervisedUserManager()->FindByDisplayName( - base::CollapseWhitespace(name, true))) { - CallJS("supervisedUserNameError", name, - l10n_util::GetStringUTF16( - IDS_CREATE_SUPERVISED_USER_CREATE_USERNAME_ALREADY_EXISTS)); - } else if (net::EscapeForHTML(name) != name) { - CallJS("supervisedUserNameError", name, - l10n_util::GetStringUTF16( - IDS_CREATE_SUPERVISED_USER_CREATE_ILLEGAL_USERNAME)); - } else if (delegate_ && delegate_->FindUserByDisplayName( - base::CollapseWhitespace(name, true), &user_id)) { - CallJS("supervisedUserSuggestImport", name, user_id); - } else { - CallJS("supervisedUserNameOk", name); - } -} - -void SupervisedUserCreationScreenHandler::HandleCreateSupervisedUser( - const base::string16& new_raw_user_name, - const std::string& new_user_password) { - if (!delegate_) - return; - const base::string16 new_user_name = - base::CollapseWhitespace(new_raw_user_name, true); - if (NULL != - ChromeUserManager::Get()->GetSupervisedUserManager()->FindByDisplayName( - new_user_name)) { - CallJS("supervisedUserNameError", new_user_name, - l10n_util::GetStringFUTF16( - IDS_CREATE_SUPERVISED_USER_CREATE_USERNAME_ALREADY_EXISTS, - new_user_name)); - return; - } - if (net::EscapeForHTML(new_user_name) != new_user_name) { - CallJS("supervisedUserNameError", new_user_name, - l10n_util::GetStringUTF16( - IDS_CREATE_SUPERVISED_USER_CREATE_ILLEGAL_USERNAME)); - return; - } - - if (new_user_password.length() == 0) { - CallJS("showPasswordError", - l10n_util::GetStringUTF16( - IDS_CREATE_SUPERVISED_USER_CREATE_PASSWORD_TOO_SHORT)); - return; - } - - ShowStatusMessage(true /* progress */, l10n_util::GetStringUTF16( - IDS_CREATE_SUPERVISED_USER_CREATION_CREATION_PROGRESS_MESSAGE)); - - delegate_->CreateSupervisedUser(new_user_name, new_user_password); -} - -void SupervisedUserCreationScreenHandler::HandleImportSupervisedUser( - const AccountId& account_id) { - if (!delegate_) - return; - - ShowStatusMessage(true /* progress */, l10n_util::GetStringUTF16( - IDS_CREATE_SUPERVISED_USER_CREATION_CREATION_PROGRESS_MESSAGE)); - - delegate_->ImportSupervisedUser(account_id.GetUserEmail()); -} - -void SupervisedUserCreationScreenHandler:: - HandleImportSupervisedUserWithPassword(const AccountId& account_id, - const std::string& password) { - if (!delegate_) - return; - - ShowStatusMessage(true /* progress */, l10n_util::GetStringUTF16( - IDS_CREATE_SUPERVISED_USER_CREATION_CREATION_PROGRESS_MESSAGE)); - - delegate_->ImportSupervisedUserWithPassword(account_id.GetUserEmail(), - password); -} - -void SupervisedUserCreationScreenHandler::HandleAuthenticateManager( - const AccountId& manager_raw_account_id, - const std::string& manager_password) { - const AccountId manager_account_id = AccountId::FromUserEmailGaiaId( - gaia::SanitizeEmail(manager_raw_account_id.GetUserEmail()), - manager_raw_account_id.GetGaiaId()); - delegate_->AuthenticateManager(manager_account_id, manager_password); -} - -// TODO(antrim) : this is an explicit code duplications with UserImageScreen. -// It should be removed by issue 251179. -void SupervisedUserCreationScreenHandler::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("setDefaultImages", result); -} - -void SupervisedUserCreationScreenHandler::HandlePhotoTaken - (const std::string& image_url) { - std::string mime_type, charset, raw_data; - if (!net::DataURL::Parse(GURL(image_url), &mime_type, &charset, &raw_data)) - NOTREACHED(); - DCHECK_EQ("image/png", mime_type); - - if (delegate_) - delegate_->OnPhotoTaken(raw_data); -} - -void SupervisedUserCreationScreenHandler::HandleTakePhoto() { - AccessibilityManager::Get()->PlayEarcon( - SOUND_CAMERA_SNAP, PlaySoundOption::ONLY_IF_SPOKEN_FEEDBACK_ENABLED); -} - -void SupervisedUserCreationScreenHandler::HandleDiscardPhoto() { - AccessibilityManager::Get()->PlayEarcon( - SOUND_OBJECT_DELETE, PlaySoundOption::ONLY_IF_SPOKEN_FEEDBACK_ENABLED); -} - -void SupervisedUserCreationScreenHandler::HandleSelectImage( - const std::string& image_type, - const std::string& image_url) { - if (delegate_) - delegate_->OnImageSelected(image_type, image_url); -} - -void SupervisedUserCreationScreenHandler::HandleCurrentSupervisedUserPage( - const std::string& page) { - if (delegate_) - delegate_->OnPageSelected(page); -} - -void SupervisedUserCreationScreenHandler::ShowPage( - const std::string& page) { - CallJS("showPage", page); -} - -void SupervisedUserCreationScreenHandler::SetCameraPresent(bool present) { - CallJS("setCameraPresent", present); -} - -void SupervisedUserCreationScreenHandler::ShowExistingSupervisedUsers( - const base::ListValue* users) { - CallJS("setExistingSupervisedUsers", *users); -} - -} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.h deleted file mode 100644 index d81551add56..00000000000 --- a/chromium/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SUPERVISED_USER_CREATION_SCREEN_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SUPERVISED_USER_CREATION_SCREEN_HANDLER_H_ - -#include <string> - -#include "base/compiler_specific.h" -#include "base/macros.h" -#include "base/strings/string16.h" -#include "chrome/browser/chromeos/login/users/default_user_image/default_user_images.h" -#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" -#include "content/public/browser/web_ui.h" - -namespace base { -class ListValue; -} - -namespace chromeos { - -class SupervisedUserCreationScreenHandler : public BaseScreenHandler { - public: - class Delegate { - public: - virtual ~Delegate() {} - - // This method is called, when view is being destroyed. Note, if Delegate - // is destroyed earlier then it has to call SetDelegate(nullptr). - virtual void OnViewDestroyed(SupervisedUserCreationScreenHandler* view) = 0; - - // Starts supervised user creation flow, with manager identified by - // |manager_id| and |manager_password|. - virtual void AuthenticateManager(const AccountId& manager_account_id, - const std::string& manager_password) = 0; - - // Starts supervised user creation flow, with supervised user that would - // have |display_name| and authenticated by the |supervised_user_password|. - virtual void CreateSupervisedUser( - const base::string16& display_name, - const std::string& supervised_user_password) = 0; - - // Look up if user with name |display_name| already exist and can be - // imported. Returns user ID in |out_id|. Returns true if user was found, - // false otherwise. - virtual bool FindUserByDisplayName(const base::string16& display_name, - std::string *out_id) const = 0; - - // Starts supervised user import flow for user identified with |user_id|. - virtual void ImportSupervisedUser(const std::string& user_id) = 0; - // Starts supervised user import flow for user identified with |user_id| and - // additional |password|. - virtual void ImportSupervisedUserWithPassword( - const std::string& user_id, const std::string& password) = 0; - - virtual void AbortFlow() = 0; - virtual void FinishFlow() = 0; - virtual void HideFlow() = 0; - - virtual void OnPhotoTaken(const std::string& raw_data) = 0; - virtual void OnImageSelected(const std::string& image_type, - const std::string& image_url) = 0; - virtual void OnImageAccepted() = 0; - virtual void OnPageSelected(const std::string& page) = 0; - }; - - SupervisedUserCreationScreenHandler(); - ~SupervisedUserCreationScreenHandler() override; - - virtual void Show(); - virtual void Hide(); - virtual void SetDelegate(Delegate* delegate); - - void ShowManagerPasswordError(); - - void ShowIntroPage(); - void ShowUsernamePage(); - - // Shows progress or error message close in the button area. |is_progress| is - // true for progress messages and false for error messages. - void ShowStatusMessage(bool is_progress, const base::string16& message); - void ShowTutorialPage(); - - void ShowErrorPage(const base::string16& title, - const base::string16& message, - const base::string16& button_text); - - // Navigates to specified page. - void ShowPage(const std::string& page); - - void SetCameraPresent(bool enabled); - - void ShowExistingSupervisedUsers(const base::ListValue* users); - - // BaseScreenHandler implementation: - void DeclareLocalizedValues( - ::login::LocalizedValuesBuilder* builder) override; - void Initialize() override; - - // WebUIMessageHandler implementation: - void RegisterMessages() override; - - private: - // WebUI message handlers. - void HandleCheckSupervisedUserName(const base::string16& name); - - void HandleManagerSelected(const AccountId& manager_id); - void HandleImportUserSelected(const AccountId& account_id); - - void HandleFinishLocalSupervisedUserCreation(); - void HandleAbortLocalSupervisedUserCreation(); - void HandleHideLocalSupervisedUserCreation(); - void HandleRetryLocalSupervisedUserCreation(const base::ListValue* args); - void HandleCurrentSupervisedUserPage(const std::string& current_page); - - void HandleAuthenticateManager(const AccountId& manager_account_id, - const std::string& manager_password); - void HandleCreateSupervisedUser(const base::string16& new_raw_user_name, - const std::string& new_user_password); - void HandleImportSupervisedUser(const AccountId& account_id); - void HandleImportSupervisedUserWithPassword(const AccountId& account_id, - const std::string& password); - - void HandleGetImages(); - void HandlePhotoTaken(const std::string& image_url); - void HandleTakePhoto(); - void HandleDiscardPhoto(); - void HandleSelectImage(const std::string& image_url, - const std::string& image_type); - - void UpdateText(const std::string& element_id, const base::string16& text); - - Delegate* delegate_ = nullptr; - - DISALLOW_COPY_AND_ASSIGN(SupervisedUserCreationScreenHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SUPERVISED_USER_CREATION_SCREEN_HANDLER_H_ 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 cec38d8690f..973fea5dfa4 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 @@ -55,6 +55,11 @@ void UpdateScreenHandler::DeclareLocalizedValues( builder->Add("cancelledUpdateMessage", IDS_EMPTY_STRING); #endif + builder->Add("updateOverCellularPromptTitle", + IDS_UPDATE_OVER_CELLULAR_PROMPT_TITLE); + builder->Add("updateOverCellularPromptMessage", + IDS_UPDATE_OVER_CELLULAR_PROMPT_MESSAGE); + // For Material Design OOBE builder->Add("updatingScreenTitle", IDS_UPDATING_SCREEN_TITLE); } 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 b5b0c3fa9fd..98e01775b7c 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 @@ -147,18 +147,11 @@ void WelcomeScreenHandler::DeclareLocalizedValues( builder->Add("keyboardDropdownTitle", IDS_KEYBOARD_DROPDOWN_TITLE); builder->Add("keyboardDropdownLabel", IDS_KEYBOARD_DROPDOWN_LABEL); - builder->Add("highContrastOptionOff", IDS_HIGH_CONTRAST_OPTION_OFF); - builder->Add("highContrastOptionOn", IDS_HIGH_CONTRAST_OPTION_ON); + builder->Add("a11ySettingToggleOptionOff", + IDS_A11Y_SETTING_TOGGLE_OPTION_OFF); + builder->Add("a11ySettingToggleOptionOn", IDS_A11Y_SETTING_TOGGLE_OPTION_ON); builder->Add("largeCursorOptionOff", IDS_LARGE_CURSOR_OPTION_OFF); builder->Add("largeCursorOptionOn", IDS_LARGE_CURSOR_OPTION_ON); - builder->Add("screenMagnifierOptionOff", IDS_SCREEN_MAGNIFIER_OPTION_OFF); - builder->Add("screenMagnifierOptionOn", IDS_SCREEN_MAGNIFIER_OPTION_ON); - builder->Add("spokenFeedbackOptionOff", IDS_SPOKEN_FEEDBACK_OPTION_OFF); - builder->Add("spokenFeedbackOptionOn", IDS_SPOKEN_FEEDBACK_OPTION_ON); - builder->Add("selectToSpeakOptionOff", IDS_SELECT_TO_SPEAK_OPTION_OFF); - builder->Add("selectToSpeakOptionOn", IDS_SELECT_TO_SPEAK_OPTION_ON); - builder->Add("virtualKeyboardOptionOff", IDS_VIRTUAL_KEYBOARD_OPTION_OFF); - builder->Add("virtualKeyboardOptionOn", IDS_VIRTUAL_KEYBOARD_OPTION_ON); builder->Add("timezoneDropdownTitle", IDS_TIMEZONE_DROPDOWN_TITLE); builder->Add("timezoneButtonText", IDS_TIMEZONE_BUTTON_TEXT); diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc index 1307ed94223..fddcf6302d9 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc @@ -163,6 +163,7 @@ void SetActivationStateAndError(MobileActivator::PlanActivationState state, class MobileSetupUIHTMLSource : public content::URLDataSource { public: MobileSetupUIHTMLSource(); + ~MobileSetupUIHTMLSource() override {} // content::URLDataSource implementation. std::string GetSource() const override; @@ -181,8 +182,6 @@ class MobileSetupUIHTMLSource : public content::URLDataSource { } private: - ~MobileSetupUIHTMLSource() override {} - void GetPropertiesAndStartDataRequest( const content::URLDataSource::GotDataCallback& callback, const std::string& service_path, @@ -628,11 +627,10 @@ void MobileSetupHandler::UpdatePortalReachability(const NetworkState* network, MobileSetupUI::MobileSetupUI(content::WebUI* web_ui) : ui::WebDialogUI(web_ui) { web_ui->AddMessageHandler(std::make_unique<MobileSetupHandler>()); - MobileSetupUIHTMLSource* html_source = new MobileSetupUIHTMLSource(); // Set up the chrome://mobilesetup/ source. - Profile* profile = Profile::FromWebUI(web_ui); - content::URLDataSource::Add(profile, html_source); + content::URLDataSource::Add(Profile::FromWebUI(web_ui), + std::make_unique<MobileSetupUIHTMLSource>()); content::WebContentsObserver::Observe(web_ui->GetWebContents()); } diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc index 3f43b8aa4c7..6c7b76a6e7e 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc @@ -4,10 +4,14 @@ #include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h" +#include "ash/public/cpp/shell_window_ids.h" #include "base/strings/utf_string_conversions.h" #include "base/sys_info.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/multidevice_setup/multidevice_setup_handler.h" +#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h" #include "chrome/common/url_constants.h" #include "chrome/common/webui_url_constants.h" #include "chrome/grit/generated_resources.h" @@ -28,67 +32,9 @@ namespace multidevice_setup { namespace { -// TODO(khorimoto): Localize footnote marker if necessary. -const char kFootnoteMarker[] = "*"; - constexpr int kDialogHeightPx = 640; constexpr int kDialogWidthPx = 768; -void AddMultiDeviceSetupStrings(content::WebUIDataSource* html_source) { - static constexpr struct { - const char* name; - int id; - } kLocalizedStringsWithoutPlaceholders[] = { - {"accept", IDS_MULTIDEVICE_SETUP_ACCEPT_LABEL}, - {"cancel", IDS_CANCEL}, - {"done", IDS_DONE}, - {"passwordPageHeader", IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_HEADER}, - {"enterPassword", - IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_ENTER_PASSWORD_LABEL}, - {"wrongPassword", - IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_WRONG_PASSWORD_LABEL}, - {"startSetupPageMultipleDeviceHeader", - IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MULTIPLE_DEVICE_HEADER}, - {"startSetupPageSingleDeviceHeader", - IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_SINGLE_DEVICE_HEADER}, - {"startSetupPageFeatureListHeader", - IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_FEATURE_LIST_HEADER}, - {"startSetupPageFeatureListAwm", - IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_AWM_DESCRIPTION}, - {"startSetupPageFeatureListInstallApps", - IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_INSTALL_APPS_DESCRIPTION}, - {"startSetupPageFeatureListAddFeatures", - IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_ADD_FEATURES}, - {"setupFailedPageHeader", IDS_MULTIDEVICE_SETUP_SETUP_FAILED_PAGE_HEADER}, - {"setupFailedPageMessage", - IDS_MULTIDEVICE_SETUP_SETUP_FAILED_PAGE_MESSAGE}, - {"setupSucceededPageHeader", - IDS_MULTIDEVICE_SETUP_SETUP_SUCCEEDED_PAGE_HEADER}, - {"setupSucceededPageMessage", - IDS_MULTIDEVICE_SETUP_SETUP_SUCCEEDED_PAGE_MESSAGE}, - {"startSetupPageHeader", IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_HEADER}, - {"title", IDS_MULTIDEVICE_SETUP_DIALOG_TITLE}, - {"tryAgain", IDS_MULTIDEVICE_SETUP_TRY_AGAIN_LABEL}, - }; - - for (const auto& entry : kLocalizedStringsWithoutPlaceholders) - html_source->AddLocalizedString(entry.name, entry.id); - - html_source->AddString( - "startSetupPageMessage", - l10n_util::GetStringFUTF16( - IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MESSAGE, - base::ASCIIToUTF16(kFootnoteMarker), - base::UTF8ToUTF16( - chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl() - .spec()))); - html_source->AddString( - "startSetupPageFootnote", - l10n_util::GetStringFUTF16( - IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_FOOTNOTE, - base::ASCIIToUTF16(kFootnoteMarker))); -} - } // namespace // static @@ -101,15 +47,34 @@ void MultiDeviceSetupDialog::Show() { return; current_instance_ = new MultiDeviceSetupDialog(); - current_instance_->ShowSystemDialog(); + + // TODO(crbug.com/888629): In order to remove the X button on the top right of + // of the dialog, passing |is_minimal_style| == true is required, but as of + // now, that will prevent the dialog from presenting in full screen if tablet + // mode is on. See bug for more details. + chrome::ShowWebDialogInContainer( + ash::kShellWindowId_DefaultContainer /* container_id */, + ProfileManager::GetActiveUserProfile(), current_instance_, + false /* is_minimal_style */); +} + +// static +MultiDeviceSetupDialog* MultiDeviceSetupDialog::Get() { + return current_instance_; +} + +void MultiDeviceSetupDialog::AddOnCloseCallback(base::OnceClosure callback) { + on_close_callbacks_.push_back(std::move(callback)); } MultiDeviceSetupDialog::MultiDeviceSetupDialog() - : SystemWebDialogDelegate( - GURL(chrome::kChromeUIMultiDeviceSetupUrl), - l10n_util::GetStringUTF16(IDS_MULTIDEVICE_SETUP_DIALOG_TITLE)) {} + : SystemWebDialogDelegate(GURL(chrome::kChromeUIMultiDeviceSetupUrl), + base::string16()) {} -MultiDeviceSetupDialog::~MultiDeviceSetupDialog() = default; +MultiDeviceSetupDialog::~MultiDeviceSetupDialog() { + for (auto& callback : on_close_callbacks_) + std::move(callback).Run(); +} void MultiDeviceSetupDialog::GetDialogSize(gfx::Size* size) const { size->SetSize(kDialogWidthPx, kDialogHeightPx); @@ -129,23 +94,10 @@ MultiDeviceSetupDialogUI::MultiDeviceSetupDialogUI(content::WebUI* web_ui) content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUIMultiDeviceSetupHost); - AddMultiDeviceSetupStrings(source); + chromeos::multidevice_setup::AddLocalizedStrings(source); source->SetJsonPath("strings.js"); source->SetDefaultResource( IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_DIALOG_HTML); - source->AddResourcePath("mojo/public/mojom/base/time.mojom.js", - IDR_TIME_MOJOM_JS); - source->AddResourcePath( - "chromeos/services/device_sync/public/mojom/device_sync.mojom.js", - IDR_DEVICE_SYNC_MOJOM_JS); - source->AddResourcePath( - "chromeos/services/multidevice_setup/public/mojom/" - "multidevice_setup.mojom.js", - IDR_MULTIDEVICE_SETUP_MOJOM_JS); - source->AddResourcePath( - "chromeos/services/multidevice_setup/public/mojom/" - "multidevice_setup_constants.mojom.js", - IDR_MULTIDEVICE_SETUP_CONSTANTS_MOJOM_JS); // Note: The |kMultiDeviceSetupResourcesSize| and |kMultideviceSetupResources| // fields are defined in the generated file diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h index cd79039b1f2..422b8feeeac 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h +++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h @@ -6,7 +6,9 @@ #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_DIALOG_H_ #include <string> +#include <vector> +#include "base/callback.h" #include "base/macros.h" #include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h" #include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h" @@ -25,6 +27,13 @@ class MultiDeviceSetupDialog : public SystemWebDialogDelegate { // no-op. static void Show(); + // Returns the currently displayed dialog. If no dialog exists, returns + // nullptr. + static MultiDeviceSetupDialog* Get(); + + // Registers a callback which will be called when the dialog is closed. + void AddOnCloseCallback(base::OnceClosure callback); + protected: MultiDeviceSetupDialog(); ~MultiDeviceSetupDialog() override; @@ -36,6 +45,10 @@ class MultiDeviceSetupDialog : public SystemWebDialogDelegate { private: static MultiDeviceSetupDialog* current_instance_; + // List of callbacks that have registered themselves to be invoked once this + // dialog is closed. + std::vector<base::OnceClosure> on_close_callbacks_; + DISALLOW_COPY_AND_ASSIGN(MultiDeviceSetupDialog); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc new file mode 100644 index 00000000000..fa840645971 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.cc @@ -0,0 +1,132 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h" + +#include "base/no_destructor.h" +#include "base/strings/utf_string_conversions.h" +#include "base/sys_info.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_handler.h" +#include "chrome/common/url_constants.h" +#include "chrome/common/webui_url_constants.h" +#include "chrome/grit/generated_resources.h" +#include "chrome/grit/multidevice_setup_resources.h" +#include "chrome/grit/multidevice_setup_resources_map.h" +#include "chromeos/grit/chromeos_resources.h" +#include "chromeos/services/multidevice_setup/public/cpp/url_provider.h" +#include "chromeos/services/multidevice_setup/public/mojom/constants.mojom.h" +#include "components/login/localized_values_builder.h" +#include "components/strings/grit/components_strings.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_data_source.h" +#include "services/service_manager/public/cpp/connector.h" +#include "ui/base/l10n/l10n_util.h" + +namespace chromeos { + +namespace multidevice_setup { + +namespace { + +const char kFootnoteMarker[] = "*"; + +constexpr struct { + const char* name; + int id; +} const kLocalizedStringsWithoutPlaceholders[] = { + {"accept", IDS_MULTIDEVICE_SETUP_ACCEPT_LABEL}, + {"back", IDS_MULTIDEVICE_SETUP_BACK_LABEL}, + {"cancel", IDS_CANCEL}, + {"done", IDS_DONE}, + {"noThanks", IDS_NO_THANKS}, + {"passwordPageHeader", IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_HEADER}, + {"enterPassword", IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_ENTER_PASSWORD_LABEL}, + {"wrongPassword", IDS_MULTIDEVICE_SETUP_PASSWORD_PAGE_WRONG_PASSWORD_LABEL}, + {"startSetupPageMultipleDeviceHeader", + IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MULTIPLE_DEVICE_HEADER}, + {"startSetupPageSingleDeviceHeader", + IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_SINGLE_DEVICE_HEADER}, + {"startSetupPageFeatureListHeader", + IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_FEATURE_LIST_HEADER}, + {"startSetupPageFeatureListInstallApps", + IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_INSTALL_APPS_DESCRIPTION}, + {"startSetupPageFeatureListAddFeatures", + IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_ADD_FEATURES}, + {"setupFailedPageHeader", IDS_MULTIDEVICE_SETUP_SETUP_FAILED_PAGE_HEADER}, + {"setupFailedPageMessage", IDS_MULTIDEVICE_SETUP_SETUP_FAILED_PAGE_MESSAGE}, + {"setupSucceededPageHeader", + IDS_MULTIDEVICE_SETUP_SETUP_SUCCEEDED_PAGE_HEADER}, + {"setupSucceededPageMessage", + IDS_MULTIDEVICE_SETUP_SETUP_SUCCEEDED_PAGE_MESSAGE}, + {"startSetupPageHeader", IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_HEADER}, + {"tryAgain", IDS_MULTIDEVICE_SETUP_TRY_AGAIN_LABEL}, +}; + +struct LocalizedStringWithName { + LocalizedStringWithName(const char* name, + const base::string16& localized_string) + : name(name), localized_string(localized_string) {} + + const char* name; + base::string16 localized_string; +}; + +const std::vector<LocalizedStringWithName>& +GetLocalizedStringsWithPlaceholders() { + static const base::NoDestructor<std::vector<LocalizedStringWithName>> + localized_strings([] { + std::vector<LocalizedStringWithName> localized_strings; + + localized_strings.emplace_back( + "startSetupPageMessage", + l10n_util::GetStringFUTF16( + IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MESSAGE, + base::ASCIIToUTF16(kFootnoteMarker), + base::UTF8ToUTF16( + chromeos::multidevice_setup:: + GetBoardSpecificBetterTogetherSuiteLearnMoreUrl() + .spec()))); + + localized_strings.emplace_back( + "startSetupPageFootnote", + l10n_util::GetStringFUTF16( + IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_FOOTNOTE, + base::ASCIIToUTF16(kFootnoteMarker))); + + localized_strings.emplace_back( + "startSetupPageFeatureListAwm", + l10n_util::GetStringFUTF16( + IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_AWM_DESCRIPTION, + base::UTF8ToUTF16(chromeos::multidevice_setup:: + GetBoardSpecificMessagesLearnMoreUrl() + .spec()))); + + return localized_strings; + }()); + + return *localized_strings; +} + +} // namespace + +void AddLocalizedStrings(content::WebUIDataSource* html_source) { + for (const auto& entry : kLocalizedStringsWithoutPlaceholders) + html_source->AddLocalizedString(entry.name, entry.id); + + for (const auto& entry : GetLocalizedStringsWithPlaceholders()) + html_source->AddString(entry.name, entry.localized_string); +} + +void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder) { + for (const auto& entry : kLocalizedStringsWithoutPlaceholders) + builder->Add(entry.name, entry.id); + + for (const auto& entry : GetLocalizedStringsWithPlaceholders()) + builder->Add(entry.name, entry.localized_string); +} + +} // namespace multidevice_setup + +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h new file mode 100644 index 00000000000..dd84d5fcb4c --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_localized_strings_provider.h @@ -0,0 +1,30 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_LOCALIZED_STRINGS_PROVIDER_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_LOCALIZED_STRINGS_PROVIDER_H_ + +namespace login { +class LocalizedValuesBuilder; +} + +namespace content { +class WebUIDataSource; +} + +namespace chromeos { + +namespace multidevice_setup { + +// Adds the strings needed for the MultiDevice setup flow to |html_source|. +void AddLocalizedStrings(content::WebUIDataSource* html_source); + +// Same as AddLocalizedStrings but for a LocalizedValuesBuilder. +void AddLocalizedValuesToBuilder(::login::LocalizedValuesBuilder* builder); + +} // namespace multidevice_setup + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_LOCALIZED_STRINGS_PROVIDER_H_ diff --git a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc index 6b8b576444a..cafa6b84151 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc @@ -6,6 +6,8 @@ #include <stddef.h> +#include <memory> + #include "base/bind.h" #include "base/memory/ref_counted_memory.h" #include "base/strings/string_number_conversions.h" @@ -75,11 +77,10 @@ bool SlowTraceSource::AllowCaching() const { SlowTraceController::SlowTraceController(content::WebUI* web_ui) : WebUIController(web_ui) { - SlowTraceSource* html_source = new SlowTraceSource(); // Set up the chrome://slow_trace/ source. - Profile* profile = Profile::FromWebUI(web_ui); - content::URLDataSource::Add(profile, html_source); + content::URLDataSource::Add(Profile::FromWebUI(web_ui), + std::make_unique<SlowTraceSource>()); } -} // namespace chromeos +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h index 94ff66ebcd2..495b05c3091 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h +++ b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.h @@ -26,6 +26,7 @@ namespace chromeos { class SlowTraceSource : public content::URLDataSource { public: SlowTraceSource(); + ~SlowTraceSource() override; // content::URLDataSource implementation. std::string GetSource() const override; @@ -37,8 +38,6 @@ class SlowTraceSource : public content::URLDataSource { bool AllowCaching() const override; private: - ~SlowTraceSource() override; - void OnGetTraceData(const content::URLDataSource::GotDataCallback& callback, scoped_refptr<base::RefCountedString> trace_data); diff --git a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc index 53d279a4866..fe42d3944ed 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc @@ -39,7 +39,8 @@ bool IsSystemModalWindowOpen() { class SystemWebDialogTest : public chromeos::LoginManagerTest { public: - SystemWebDialogTest() : LoginManagerTest(false) {} + SystemWebDialogTest() + : LoginManagerTest(false, true /* should_initialize_webui */) {} ~SystemWebDialogTest() override = default; private: diff --git a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc index dc12be08195..1702ebc2bef 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc +++ b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc @@ -80,7 +80,7 @@ scoped_refptr<base::RefCountedMemory> LoadUserImageFrameForScaleFactor( ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); float scale = ui::GetScaleForScaleFactor(scale_factor); scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes); - gfx::PNGCodec::EncodeBGRASkBitmap(image->GetRepresentation(scale).sk_bitmap(), + gfx::PNGCodec::EncodeBGRASkBitmap(image->GetRepresentation(scale).GetBitmap(), false /* discard transparency */, &data->data()); return data; diff --git a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.h b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.h index aabfe10cc17..287a21bb130 100644 --- a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.h +++ b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.h @@ -27,6 +27,7 @@ namespace chromeos { class UserImageSource : public content::URLDataSource { public: UserImageSource(); + ~UserImageSource() override; // content::URLDataSource implementation. std::string GetSource() const override; @@ -43,8 +44,6 @@ class UserImageSource : public content::URLDataSource { const AccountId& account_id); private: - ~UserImageSource() override; - DISALLOW_COPY_AND_ASSIGN(UserImageSource); }; diff --git a/chromium/chrome/browser/ui/webui/chromeos/video_source.cc b/chromium/chrome/browser/ui/webui/chromeos/video_source.cc new file mode 100644 index 00000000000..c269329efd6 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/video_source.cc @@ -0,0 +1,113 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/chromeos/video_source.h" + +#include <vector> + +#include "base/bind.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/location.h" +#include "base/memory/ref_counted_memory.h" +#include "base/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_runner_util.h" +#include "base/threading/thread_task_runner_handle.h" +#include "chrome/common/url_constants.h" +#include "net/base/mime_util.h" + +namespace chromeos { +namespace { + +const char kWhitelistedDirectory[] = "oobe_videos"; + +bool IsWhitelisted(const std::string& path) { + base::FilePath file_path(path); + if (file_path.ReferencesParent()) + return false; + + // Check if the path starts with a whitelisted directory. + std::vector<std::string> components; + file_path.GetComponents(&components); + if (components.empty()) + return false; + return components[0] == kWhitelistedDirectory; +} + +// Callback for user_manager::UserImageLoader. +void VideoLoaded( + const content::URLDataSource::GotDataCallback& got_data_callback, + std::unique_ptr<std::string> video_data, + bool did_load_file) { + if (video_data->size() && did_load_file) { + got_data_callback.Run(new base::RefCountedBytes( + reinterpret_cast<const unsigned char*>(video_data->data()), + video_data->size())); + } else { + got_data_callback.Run(nullptr); + } +} + +} // namespace + +VideoSource::VideoSource() : weak_factory_(this) { + task_runner_ = base::CreateSequencedTaskRunnerWithTraits( + {base::MayBlock(), base::TaskPriority::USER_VISIBLE, + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}); +} + +VideoSource::~VideoSource() {} + +std::string VideoSource::GetSource() const { + return chrome::kChromeOSAssetHost; +} + +void VideoSource::StartDataRequest( + const std::string& path, + const content::ResourceRequestInfo::WebContentsGetter& wc_getter, + const content::URLDataSource::GotDataCallback& got_data_callback) { + if (!IsWhitelisted(path)) { + got_data_callback.Run(nullptr); + return; + } + + const base::FilePath asset_dir(chrome::kChromeOSAssetPath); + const base::FilePath video_path = asset_dir.AppendASCII(path); + base::PostTaskWithTraitsAndReplyWithResult( + FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, + base::BindOnce(&base::PathExists, video_path), + base::BindOnce(&VideoSource::StartDataRequestAfterPathExists, + weak_factory_.GetWeakPtr(), video_path, + got_data_callback)); +} + +std::string VideoSource::GetMimeType(const std::string& path) const { + std::string mime_type; + std::string ext = base::FilePath(path).Extension(); + if (!ext.empty()) + net::GetWellKnownMimeTypeFromExtension(ext.substr(1), &mime_type); + return mime_type; +} + +void VideoSource::StartDataRequestAfterPathExists( + const base::FilePath& video_path, + const content::URLDataSource::GotDataCallback& got_data_callback, + bool path_exists) { + if (path_exists) { + auto video_data = std::make_unique<std::string>(); + std::string* data = video_data.get(); + base::PostTaskAndReplyWithResult( + task_runner_.get(), FROM_HERE, + base::BindOnce(&base::ReadFileToString, video_path, data), + base::BindOnce(&VideoLoaded, got_data_callback, std::move(video_data))); + + } else { + got_data_callback.Run(nullptr); + } +} + +} // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/chromeos/video_source.h b/chromium/chrome/browser/ui/webui/chromeos/video_source.h new file mode 100644 index 00000000000..12a1a884896 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/chromeos/video_source.h @@ -0,0 +1,56 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_VIDEO_SOURCE_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_VIDEO_SOURCE_H_ + +#include <string> + +#include "base/macros.h" +#include "base/memory/scoped_refptr.h" +#include "base/memory/weak_ptr.h" +#include "content/public/browser/url_data_source.h" + +namespace base { +class FilePath; +class SequencedTaskRunner; +} // namespace base + +namespace chromeos { + +// Data source that reads videos from the file system. +// It provides resources from chrome urls of type: +// chrome://chromeos-asset/<whitelisted directories>/*.webm +class VideoSource : public content::URLDataSource { + public: + VideoSource(); + ~VideoSource() override; + + // content::URLDataSource: + std::string GetSource() const override; + void StartDataRequest( + const std::string& path, + const content::ResourceRequestInfo::WebContentsGetter& wc_getter, + const content::URLDataSource::GotDataCallback& got_data_callback) + override; + std::string GetMimeType(const std::string& path) const override; + + private: + // Continuation from StartDataRequest(). + void StartDataRequestAfterPathExists( + const base::FilePath& video_path, + const content::URLDataSource::GotDataCallback& got_data_callback, + bool path_exists); + + // The background task runner on which file I/O is performed. + scoped_refptr<base::SequencedTaskRunner> task_runner_; + + base::WeakPtrFactory<VideoSource> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(VideoSource); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_VIDEO_SOURCE_H_ diff --git a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc index c09a674dd44..1261f6ffb9d 100644 --- a/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc @@ -11,7 +11,6 @@ #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" -#include "build/buildflag.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -24,7 +23,6 @@ #include "content/public/browser/web_contents_observer.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/test_navigation_observer.h" -#include "ui/base/ui_features.h" #include "ui/web_dialogs/test/test_web_dialog_delegate.h" using content::WebContents; @@ -198,11 +196,6 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, gfx::Size max_size = gfx::Size(200, 200); gfx::Size initial_dialog_size; -// When using Cocoa windows, the initial dimensions must be nonzero. -#if defined(OS_MACOSX) && !BUILDFLAG(MAC_VIEWS_BROWSER) - initial_dialog_size = gfx::Size(1, 1); -#endif - delegate->GetDialogSize(&initial_dialog_size); ConstrainedWebDialogDelegate* dialog_delegate = diff --git a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc index 5dc7e8a55e9..169792b7339 100644 --- a/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc +++ b/chromium/chrome/browser/ui/webui/cookies_tree_model_util.cc @@ -256,10 +256,8 @@ bool CookiesTreeModelUtil::GetCookieTreeNodeDictionary( dict->SetString(kKeySize, ui::FormatBytes(service_worker_info.total_size_bytes)); auto scopes = std::make_unique<base::ListValue>(); - for (std::vector<GURL>::const_iterator it = - service_worker_info.scopes.begin(); - it != service_worker_info.scopes.end(); - ++it) { + for (auto it = service_worker_info.scopes.begin(); + it != service_worker_info.scopes.end(); ++it) { scopes->AppendString(it->spec()); } dict->Set(kKeyScopes, std::move(scopes)); diff --git a/chromium/chrome/browser/ui/webui/devtools_ui.cc b/chromium/chrome/browser/ui/webui/devtools_ui.cc index 1d45948ef09..a99cea43073 100644 --- a/chromium/chrome/browser/ui/webui/devtools_ui.cc +++ b/chromium/chrome/browser/ui/webui/devtools_ui.cc @@ -8,11 +8,15 @@ #include <utility> #include "base/command_line.h" +#include "base/files/file_util.h" #include "base/macros.h" #include "base/memory/ref_counted_memory.h" +#include "base/path_service.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "base/task/post_task.h" #include "chrome/browser/devtools/url_constants.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "content/public/browser/browser_context.h" @@ -87,6 +91,7 @@ class DevToolsDataSource : public content::URLDataSource { explicit DevToolsDataSource( scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) : url_loader_factory_(std::move(url_loader_factory)) {} + ~DevToolsDataSource() override = default; // content::URLDataSource implementation. std::string GetSource() const override; @@ -99,8 +104,6 @@ class DevToolsDataSource : public content::URLDataSource { private: struct PendingRequest; - ~DevToolsDataSource() override = default; - // content::URLDataSource overrides. std::string GetMimeType(const std::string& path) const override; bool ShouldAddContentSecurityPolicy() const override; @@ -128,6 +131,11 @@ class DevToolsDataSource : public content::URLDataSource { int load_flags, const GotDataCallback& callback); +#if BUILDFLAG(DEBUG_DEVTOOLS) + void StartFileRequestForDebugDevtools(const std::string& path, + const GotDataCallback& callback); +#endif + struct PendingRequest { PendingRequest() = default; PendingRequest(PendingRequest&& other) = default; @@ -163,8 +171,17 @@ void DevToolsDataSource::StartDataRequest( bundled_path_prefix += "/"; if (base::StartsWith(path, bundled_path_prefix, base::CompareCase::INSENSITIVE_ASCII)) { - StartBundledDataRequest(path.substr(bundled_path_prefix.length()), - callback); + std::string path_without_params = PathWithoutParams(path); + + DCHECK(base::StartsWith(path_without_params, bundled_path_prefix, + base::CompareCase::INSENSITIVE_ASCII)); + std::string path_under_bundled = + path_without_params.substr(bundled_path_prefix.length()); +#if BUILDFLAG(DEBUG_DEVTOOLS) + StartFileRequestForDebugDevtools(path_under_bundled, callback); +#else + StartBundledDataRequest(path_under_bundled, callback); +#endif return; } @@ -237,12 +254,11 @@ bool DevToolsDataSource::ShouldServeMimeTypeAsContentTypeHeader() const { void DevToolsDataSource::StartBundledDataRequest( const std::string& path, const content::URLDataSource::GotDataCallback& callback) { - std::string filename = PathWithoutParams(path); base::StringPiece resource = - content::DevToolsFrontendHost::GetFrontendResource(filename); + content::DevToolsFrontendHost::GetFrontendResource(path); DLOG_IF(WARNING, resource.empty()) - << "Unable to find dev tool resource: " << filename + << "Unable to find dev tool resource: " << path << ". If you compiled with debug_devtools=1, try running with " "--debug-devtools."; scoped_refptr<base::RefCountedStaticMemory> bytes( @@ -340,6 +356,42 @@ void DevToolsDataSource::StartNetworkRequest( base::Unretained(this), request_iter)); } +#if BUILDFLAG(DEBUG_DEVTOOLS) +scoped_refptr<base::RefCountedMemory> ReadFile(const base::FilePath& path) { + std::string buffer; + if (!base::ReadFileToString(path, &buffer)) { + LOG(ERROR) << "Failed to read " << path; + return CreateNotFoundResponse(); + } + return base::RefCountedString::TakeString(&buffer); +} + +void DevToolsDataSource::StartFileRequestForDebugDevtools( + const std::string& path, + const GotDataCallback& callback) { + base::FilePath inspector_debug_dir; + if (!base::PathService::Get(chrome::DIR_INSPECTOR_DEBUG, + &inspector_debug_dir)) { + callback.Run(CreateNotFoundResponse()); + return; + } + + DCHECK(!inspector_debug_dir.empty()); + + base::FilePath full_path = inspector_debug_dir.AppendASCII(path); + + base::PostTaskWithTraitsAndReplyWithResult( + FROM_HERE, + {base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN, + base::TaskPriority::USER_VISIBLE}, + // The usage of BindRepeating below is only because the type of + // task callback needs to match that of response callback, which + // is currently a repeating callback. + base::BindRepeating(ReadFile, std::move(full_path)), callback); +} + +#endif // BUILDFLAG(DEBUG_DEVTOOLS) + void DevToolsDataSource::OnLoadComplete( std::list<PendingRequest>::iterator request_iter, std::unique_ptr<std::string> response_body) { @@ -405,8 +457,9 @@ DevToolsUI::DevToolsUI(content::WebUI* web_ui) auto factory = content::BrowserContext::GetDefaultStoragePartition( web_ui->GetWebContents()->GetBrowserContext()) ->GetURLLoaderFactoryForBrowserProcess(); - content::URLDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), - new DevToolsDataSource(std::move(factory))); + content::URLDataSource::Add( + web_ui->GetWebContents()->GetBrowserContext(), + std::make_unique<DevToolsDataSource>(std::move(factory))); } DevToolsUI::~DevToolsUI() = default; diff --git a/chromium/chrome/browser/ui/webui/discards/discards.mojom b/chromium/chrome/browser/ui/webui/discards/discards.mojom index b9c02585a7d..a6f17da98f3 100644 --- a/chromium/chrome/browser/ui/webui/discards/discards.mojom +++ b/chromium/chrome/browser/ui/webui/discards/discards.mojom @@ -13,6 +13,72 @@ enum LifecycleUnitVisibility { VISIBLE = 2, }; +struct SiteCharacteristicsFeature { + // The cumulative observation time for this feature in seconds, set to 0 once + // this feature has been observed. + int64 observation_duration; + // The time at which this feature has been used (set to 0 if it hasn't been + // used), in seconds since epoch. + int64 use_timestamp; +}; + +struct SiteCharacteristicsPerformanceMeasurement { + // A decaying average of the CPU usage measurements. Units: microseconds. + float avg_cpu_usage_us; + // A decaying average of the process footprint measurements. Units: kilobytes. + float avg_footprint_kb; + // A decaying average of the wall-clock load time duration of the tab. + // Units: microseconds. + float avg_load_duration_us; +}; + +struct SiteCharacteristicsDatabaseSize { + // The total number of rows in the database, or -1 if the value is not + // available. + int64 num_rows; + + // The total size of the database on disk in kilobytes, or -1 if the value + // is not available. + int64 on_disk_size_kb; +}; + +// The data stored for a given origin, this should mirror the +// SiteCharacteristicsProto structure in site_characteristics.proto. +struct SiteCharacteristicsDatabaseValue { + // The last time this site has been in the loaded state, in seconds since + // epoch. + uint32 last_loaded; + + SiteCharacteristicsFeature updates_favicon_in_background; + SiteCharacteristicsFeature updates_title_in_background; + SiteCharacteristicsFeature uses_audio_in_background; + SiteCharacteristicsFeature uses_notifications_in_background; + + // Load time performance measurement estimates. This maintains a decaying + // average of the resource usage of a page until shortly after it becomes + // idle. + SiteCharacteristicsPerformanceMeasurement? load_time_estimates; +}; + +// Provides the key and miscellaneous in-memory only data pertaining to a +// row that potentially exists in a database. +struct SiteCharacteristicsDatabaseEntry { + // The origin associated with this row. + string origin; + + // This row is pending flush to disk. + bool is_dirty; + + // NULL if the database entry doesn't exist on disk or in memory. + SiteCharacteristicsDatabaseValue? value; +}; + +// Contains information about a specific DB instance. +struct SiteCharacteristicsDatabase { + // Contains the entries requested. + array<SiteCharacteristicsDatabaseEntry> db_rows; +}; + // Discard related information about a single tab in a browser. struct TabDiscardsInfo { // The URL associated with the tab. This corresponds to GetLastCommittedURL, @@ -70,6 +136,20 @@ interface DiscardsDetailsProvider { // each tab currently open in the browser, across all profiles. GetTabDiscardsInfo() => (array<TabDiscardsInfo> infos); + // Returns the in-memory entries and the entries for the requested origins. + // Note that any entry may take some time to load from disk, and so there may + // not be any data for a given entry until on the second or subsequent + // requests. + GetSiteCharacteristicsDatabase( + array<string> explicitly_requested_origins) => + (SiteCharacteristicsDatabase? result); + + // Returns the size of the database in number of rows and kilobytes. + // Note that this may be fairly expensive to acquire, and so shouldn't be + // called frequently. + GetSiteCharacteristicsDatabaseSize() => + (SiteCharacteristicsDatabaseSize? db_size); + // Sets the auto-discardable state of a tab, as specified by its stable // |tab_id|, earlier returned by GetTabDiscardsInfo. Invokes a callback when // the change has been made. diff --git a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc index 8c321454cac..8717e81f821 100644 --- a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc +++ b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc @@ -7,6 +7,7 @@ #include <utility> #include <vector> +#include "base/containers/flat_map.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" @@ -15,6 +16,9 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/resource_coordinator/lifecycle_unit.h" #include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h" +#include "chrome/browser/resource_coordinator/local_site_characteristics_data_reader.h" +#include "chrome/browser/resource_coordinator/local_site_characteristics_data_store.h" +#include "chrome/browser/resource_coordinator/local_site_characteristics_data_store_inspector.h" #include "chrome/browser/resource_coordinator/tab_activity_watcher.h" #include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h" #include "chrome/browser/resource_coordinator/tab_manager.h" @@ -28,8 +32,13 @@ #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 "content/public/common/service_manager_connection.h" #include "mojo/public/cpp/bindings/binding.h" +#include "services/resource_coordinator/public/mojom/service_constants.mojom.h" +#include "services/service_manager/public/cpp/connector.h" #include "ui/resources/grit/ui_resources.h" +#include "url/gurl.h" +#include "url/origin.h" namespace { @@ -80,12 +89,83 @@ double GetSiteEngagementScore(content::WebContents* contents) { return engagement_svc->GetDetails(nav_entry->GetURL()).total_score; } +mojom::SiteCharacteristicsFeaturePtr ConvertFeatureFromProto( + const SiteCharacteristicsFeatureProto& proto) { + mojom::SiteCharacteristicsFeaturePtr feature = + mojom::SiteCharacteristicsFeature::New(); + + if (proto.has_observation_duration()) { + feature->observation_duration = proto.observation_duration(); + } else { + feature->observation_duration = 0; + } + + if (proto.has_use_timestamp()) { + feature->use_timestamp = proto.use_timestamp(); + } else { + feature->use_timestamp = 0; + } + + return feature; +} + +mojom::SiteCharacteristicsDatabaseEntryPtr ConvertEntryFromProto( + SiteCharacteristicsProto* proto) { + mojom::SiteCharacteristicsDatabaseValuePtr value = + mojom::SiteCharacteristicsDatabaseValue::New(); + + if (proto->has_last_loaded()) { + value->last_loaded = proto->last_loaded(); + } else { + value->last_loaded = 0; + } + value->updates_favicon_in_background = + ConvertFeatureFromProto(proto->updates_favicon_in_background()); + value->updates_title_in_background = + ConvertFeatureFromProto(proto->updates_title_in_background()); + value->uses_audio_in_background = + ConvertFeatureFromProto(proto->uses_audio_in_background()); + value->uses_notifications_in_background = + ConvertFeatureFromProto(proto->uses_notifications_in_background()); + + if (proto->has_load_time_estimates()) { + const auto& load_time_estimates_proto = proto->load_time_estimates(); + DCHECK(load_time_estimates_proto.has_avg_cpu_usage_us()); + DCHECK(load_time_estimates_proto.has_avg_footprint_kb()); + + mojom::SiteCharacteristicsPerformanceMeasurementPtr load_time_estimates = + mojom::SiteCharacteristicsPerformanceMeasurement::New(); + if (load_time_estimates_proto.has_avg_cpu_usage_us()) { + load_time_estimates->avg_cpu_usage_us = + load_time_estimates_proto.avg_cpu_usage_us(); + } + if (load_time_estimates_proto.has_avg_footprint_kb()) { + load_time_estimates->avg_footprint_kb = + load_time_estimates_proto.avg_footprint_kb(); + } + if (load_time_estimates_proto.has_avg_load_duration_us()) { + load_time_estimates->avg_load_duration_us = + load_time_estimates_proto.avg_load_duration_us(); + } + + value->load_time_estimates = std::move(load_time_estimates); + } + + mojom::SiteCharacteristicsDatabaseEntryPtr entry = + mojom::SiteCharacteristicsDatabaseEntry::New(); + entry->value = std::move(value); + return entry; +} + class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider { public: // This instance is deleted when the supplied pipe is destroyed. DiscardsDetailsProviderImpl( + resource_coordinator::LocalSiteCharacteristicsDataStoreInspector* + data_store_inspector, mojo::InterfaceRequest<mojom::DiscardsDetailsProvider> request) - : binding_(this, std::move(request)) {} + : data_store_inspector_(data_store_inspector), + binding_(this, std::move(request)) {} ~DiscardsDetailsProviderImpl() override {} @@ -158,6 +238,11 @@ class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider { std::move(callback).Run(std::move(infos)); } + void GetSiteCharacteristicsDatabase( + const std::vector<std::string>& explicitly_requested_origins, + GetSiteCharacteristicsDatabaseCallback callback) override; + void GetSiteCharacteristicsDatabaseSize( + GetSiteCharacteristicsDatabaseSizeCallback callback) override; void SetAutoDiscardable(int32_t id, bool is_auto_discardable, @@ -201,11 +286,105 @@ class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider { } private: + using LocalSiteCharacteristicsDataStoreInspector = + resource_coordinator::LocalSiteCharacteristicsDataStoreInspector; + using SiteCharacteristicsDataReader = + resource_coordinator::SiteCharacteristicsDataReader; + using SiteCharacteristicsDataStore = + resource_coordinator::SiteCharacteristicsDataStore; + using OriginToReaderMap = + base::flat_map<std::string, + std::unique_ptr<SiteCharacteristicsDataReader>>; + + // This map pins requested readers and their associated data in memory until + // after the next read finishes. This is necessary to allow the database reads + // to go through and populate the requested entries. + OriginToReaderMap requested_origins_; + + LocalSiteCharacteristicsDataStoreInspector* data_store_inspector_; mojo::Binding<mojom::DiscardsDetailsProvider> binding_; DISALLOW_COPY_AND_ASSIGN(DiscardsDetailsProviderImpl); }; +void DiscardsDetailsProviderImpl::GetSiteCharacteristicsDatabase( + const std::vector<std::string>& explicitly_requested_origins, + GetSiteCharacteristicsDatabaseCallback callback) { + if (!data_store_inspector_) { + // Early return with a nullptr if there's no inspector. + std::move(callback).Run(nullptr); + return; + } + + // Move all previously explicitly requested origins to this local map. + // Move any currently requested origins over to the member variable, or + // populate them if they weren't previously requested. + // The difference will remain in this map and go out of scope at the end of + // this function. + OriginToReaderMap prev_requested_origins; + prev_requested_origins.swap(requested_origins_); + SiteCharacteristicsDataStore* data_store = + data_store_inspector_->GetDataStore(); + DCHECK(data_store); + for (const std::string& origin : explicitly_requested_origins) { + auto it = prev_requested_origins.find(origin); + if (it == prev_requested_origins.end()) { + GURL url(origin); + requested_origins_[origin] = + data_store->GetReaderForOrigin(url::Origin::Create(url)); + } else { + requested_origins_[origin] = std::move(it->second); + prev_requested_origins.erase(it); + } + } + + mojom::SiteCharacteristicsDatabasePtr result = + mojom::SiteCharacteristicsDatabase::New(); + std::vector<url::Origin> in_memory_origins = + data_store_inspector_->GetAllInMemoryOrigins(); + for (const url::Origin& origin : in_memory_origins) { + // Get the data for this origin and convert it from proto to the + // corresponding mojo structure. + std::unique_ptr<SiteCharacteristicsProto> proto; + bool is_dirty = false; + if (data_store_inspector_->GetDataForOrigin(origin, &is_dirty, &proto)) { + auto entry = ConvertEntryFromProto(proto.get()); + entry->origin = origin.Serialize(); + entry->is_dirty = is_dirty; + result->db_rows.push_back(std::move(entry)); + } + } + + // Return the result. + std::move(callback).Run(std::move(result)); +} + +void DiscardsDetailsProviderImpl::GetSiteCharacteristicsDatabaseSize( + GetSiteCharacteristicsDatabaseSizeCallback callback) { + if (!data_store_inspector_) { + // Early return with a nullptr if there's no inspector. + std::move(callback).Run(nullptr); + return; + } + + // Adapt the inspector callback to the mojom callback with this lambda. + auto inspector_callback = base::BindOnce( + [](GetSiteCharacteristicsDatabaseSizeCallback callback, + base::Optional<int64_t> num_rows, + base::Optional<int64_t> on_disk_size_kb) { + mojom::SiteCharacteristicsDatabaseSizePtr result = + mojom::SiteCharacteristicsDatabaseSize::New(); + result->num_rows = num_rows.has_value() ? num_rows.value() : -1; + result->on_disk_size_kb = + on_disk_size_kb.has_value() ? on_disk_size_kb.value() : -1; + + std::move(callback).Run(std::move(result)); + }, + std::move(callback)); + + data_store_inspector_->GetDatabaseSize(std::move(inspector_callback)); +} + } // namespace DiscardsUI::DiscardsUI(content::WebUI* web_ui) @@ -213,26 +392,64 @@ DiscardsUI::DiscardsUI(content::WebUI* web_ui) std::unique_ptr<content::WebUIDataSource> source( content::WebUIDataSource::Create(chrome::kChromeUIDiscardsHost)); - source->AddResourcePath("discards.css", IDR_ABOUT_DISCARDS_CSS); - source->AddResourcePath("discards.js", IDR_ABOUT_DISCARDS_JS); + source->AddResourcePath("discards.js", IDR_DISCARDS_JS); + + source->AddResourcePath("discards_main.html", + IDR_DISCARDS_DISCARDS_MAIN_HTML); + source->AddResourcePath("discards_main.js", IDR_DISCARDS_DISCARDS_MAIN_JS); + + source->AddResourcePath("database_tab.html", IDR_DISCARDS_DATABASE_TAB_HTML); + source->AddResourcePath("database_tab.js", IDR_DISCARDS_DATABASE_TAB_JS); + source->AddResourcePath("discards_tab.html", IDR_DISCARDS_DISCARDS_TAB_HTML); + source->AddResourcePath("discards_tab.js", IDR_DISCARDS_DISCARDS_TAB_JS); + source->AddResourcePath("sorted_table_behavior.html", + IDR_DISCARDS_SORTED_TABLE_BEHAVIOR_HTML); + source->AddResourcePath("sorted_table_behavior.js", + IDR_DISCARDS_SORTED_TABLE_BEHAVIOR_JS); + // Full paths (relative to src) are important for Mojom generated files. source->AddResourcePath("chrome/browser/ui/webui/discards/discards.mojom.js", - IDR_ABOUT_DISCARDS_MOJO_JS); + IDR_DISCARDS_MOJO_JS); source->AddResourcePath( "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.js", - IDR_ABOUT_DISCARDS_LIFECYCLE_UNIT_STATE_MOJO_JS); - source->SetDefaultResource(IDR_ABOUT_DISCARDS_HTML); + IDR_DISCARDS_LIFECYCLE_UNIT_STATE_MOJO_JS); + source->AddResourcePath("mojom/webui_graph_dump.mojom.js", + IDR_DISCARDS_WEBUI_GRAPH_DUMP_MOJO_JS); + + // Add the mojo base dependency for the WebUI Graph Dump. + source->AddResourcePath("mojo/public/mojom/base/process_id.mojom.js", + IDR_DISCARDS_MOJO_PUBLIC_BASE_PROCESS_ID_MOJOM_JS); + + source->SetDefaultResource(IDR_DISCARDS_HTML); Profile* profile = Profile::FromWebUI(web_ui); content::WebUIDataSource::Add(profile, source.release()); + AddHandlerToRegistry(base::BindRepeating( &DiscardsUI::BindDiscardsDetailsProvider, base::Unretained(this))); + AddHandlerToRegistry(base::BindRepeating( + &DiscardsUI::BindWebUIGraphDumpProvider, base::Unretained(this))); + + data_store_inspector_ = resource_coordinator:: + LocalSiteCharacteristicsDataStoreInspector::GetForProfile(profile); } DiscardsUI::~DiscardsUI() {} void DiscardsUI::BindDiscardsDetailsProvider( mojom::DiscardsDetailsProviderRequest request) { - ui_handler_ = - std::make_unique<DiscardsDetailsProviderImpl>(std::move(request)); + ui_handler_ = std::make_unique<DiscardsDetailsProviderImpl>( + data_store_inspector_, std::move(request)); +} + +void DiscardsUI::BindWebUIGraphDumpProvider( + resource_coordinator::mojom::WebUIGraphDumpRequest request) { + service_manager::Connector* connector = + content::ServiceManagerConnection::GetForProcess()->GetConnector(); + + if (connector) { + // Forward the interface request directly to the service. + connector->BindInterface(resource_coordinator::mojom::kServiceName, + std::move(request)); + } } diff --git a/chromium/chrome/browser/ui/webui/discards/discards_ui.h b/chromium/chrome/browser/ui/webui/discards/discards_ui.h index e4719d4ed2c..4ba70c8e6c9 100644 --- a/chromium/chrome/browser/ui/webui/discards/discards_ui.h +++ b/chromium/chrome/browser/ui/webui/discards/discards_ui.h @@ -9,8 +9,13 @@ #include "base/macros.h" #include "chrome/browser/ui/webui/discards/discards.mojom.h" +#include "services/resource_coordinator/public/mojom/webui_graph_dump.mojom.h" #include "ui/webui/mojo_web_ui_controller.h" +namespace resource_coordinator { +class LocalSiteCharacteristicsDataStoreInspector; +} // namespace resource_coordinator + // Controller for chrome://discards. Corresponding resources are in // file://chrome/browser/resources/discards. class DiscardsUI : public ui::MojoWebUIController { @@ -21,8 +26,12 @@ class DiscardsUI : public ui::MojoWebUIController { private: void BindDiscardsDetailsProvider( mojom::DiscardsDetailsProviderRequest request); + void BindWebUIGraphDumpProvider( + resource_coordinator::mojom::WebUIGraphDumpRequest request); std::unique_ptr<mojom::DiscardsDetailsProvider> ui_handler_; + resource_coordinator::LocalSiteCharacteristicsDataStoreInspector* + data_store_inspector_; DISALLOW_COPY_AND_ASSIGN(DiscardsUI); }; diff --git a/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc index 771a37085e2..6c810e3dc6c 100644 --- a/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc +++ b/chromium/chrome/browser/ui/webui/eoc_internals/eoc_internals_page_handler.cc @@ -22,8 +22,6 @@ using contextual_suggestions::ContextualSuggestionsResult; namespace { bool AreChromeFlagsSetup() { return base::FeatureList::IsEnabled( - contextual_suggestions::kContextualSuggestionsBottomSheet) || - base::FeatureList::IsEnabled( contextual_suggestions::kContextualSuggestionsButton); } diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_basic_info.cc b/chromium/chrome/browser/ui/webui/extensions/extension_basic_info.cc index 3a0c247cd65..2e2737baeba 100644 --- a/chromium/chrome/browser/ui/webui/extensions/extension_basic_info.cc +++ b/chromium/chrome/browser/ui/webui/extensions/extension_basic_info.cc @@ -15,16 +15,16 @@ namespace { // Keys in the dictionary returned by GetExtensionBasicInfo(). const char kDescriptionKey[] = "description"; +const char kDetailsUrlKey[] = "detailsUrl"; const char kEnabledKey[] = "enabled"; const char kHomepageUrlKey[] = "homepageUrl"; -const char kIdKey[] = "id"; -const char kNameKey[] = "name"; +const char kInfoIdKey[] = "id"; +const char kInfoNameKey[] = "name"; +const char kInfoVersionKey[] = "version"; const char kKioskEnabledKey[] = "kioskEnabled"; const char kKioskOnlyKey[] = "kioskOnly"; const char kOfflineEnabledKey[] = "offlineEnabled"; const char kOptionsUrlKey[] = "optionsUrl"; -const char kDetailsUrlKey[] = "detailsUrl"; -const char kVersionKey[] = "version"; const char kPackagedAppKey[] = "packagedApp"; } // namespace @@ -34,8 +34,8 @@ namespace extensions { void GetExtensionBasicInfo(const Extension* extension, bool enabled, base::DictionaryValue* info) { - info->SetString(kIdKey, extension->id()); - info->SetString(kNameKey, extension->name()); + info->SetString(kInfoIdKey, extension->id()); + info->SetString(kInfoNameKey, extension->name()); info->SetBoolean(kEnabledKey, enabled); info->SetBoolean(kKioskEnabledKey, KioskModeInfo::IsKioskEnabled(extension)); @@ -43,7 +43,7 @@ void GetExtensionBasicInfo(const Extension* extension, KioskModeInfo::IsKioskOnly(extension)); info->SetBoolean(kOfflineEnabledKey, OfflineEnabledInfo::IsOfflineEnabled(extension)); - info->SetString(kVersionKey, extension->GetVersionForDisplay()); + info->SetString(kInfoVersionKey, extension->GetVersionForDisplay()); info->SetString(kDescriptionKey, extension->description()); info->SetString( kOptionsUrlKey, diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h b/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h index 5b905318f32..62cee4a823f 100644 --- a/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h +++ b/chromium/chrome/browser/ui/webui/extensions/extension_icon_source.h @@ -53,6 +53,7 @@ class ExtensionIconSource : public content::URLDataSource, public base::SupportsWeakPtr<ExtensionIconSource> { public: explicit ExtensionIconSource(Profile* profile); + ~ExtensionIconSource() override; // Gets the URL of the |extension| icon in the given |icon_size|, falling back // based on the |match| type. If |grayscale|, the URL will be for the @@ -79,8 +80,6 @@ class ExtensionIconSource : public content::URLDataSource, // Encapsulates the request parameters for |request_id|. struct ExtensionIconRequest; - ~ExtensionIconSource() override; - // Returns the bitmap for the default app image. const SkBitmap* GetDefaultAppImage(); diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc index 669c2553a84..6b410ca2d28 100644 --- a/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc +++ b/chromium/chrome/browser/ui/webui/extensions/extensions_internals_source.cc @@ -5,17 +5,22 @@ #include "chrome/browser/ui/webui/extensions/extensions_internals_source.h" #include <string> +#include <unordered_map> #include <utility> #include "base/json/json_writer.h" #include "base/logging.h" #include "base/memory/ref_counted_memory.h" +#include "base/numerics/safe_conversions.h" +#include "base/strings/string_piece.h" #include "base/values.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/webui_url_constants.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_thread.h" #include "extensions/browser/activity.h" +#include "extensions/browser/event_listener_map.h" +#include "extensions/browser/event_router.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/process_manager.h" @@ -77,11 +82,78 @@ const char* LocationToString(extensions::Manifest::Location loc) { return ""; } +// The JSON we generate looks like this: +// +// [ { +// "event_listeners": { +// "count": 2, +// "events": [ { +// "name": "runtime.onInstalled" +// }, { +// "name": "runtime.onSuspend" +// } ] +// }, +// "id": "bhloflhklmhfpedakmangadcdofhnnoh", +// "keepalive": { +// "activities": [ { +// "extra_data": "render-frame", +// "type": "PROCESS_MANAGER" +// } ], +// "count": 1 +// }, +// "location": "INTERNAL", +// "manifest_version": 2, +// "name": "Earth View from Google Earth", +// "path": "/user/Extensions/bhloflhklmhfpedakmangadcdofhnnoh/2.18.5_0", +// "type": "TYPE_EXTENSION", +// "version": "2.18.5" +// } ] +// +// Which is: +// +// LIST +// DICT +// "event_listeners": DICT +// "count": INT +// "events": LIST +// DICT +// "name": STRING +// "filter": DICT +// "id": STRING +// "keepalive": DICT +// "activities": LIST +// DICT +// "extra_data": STRING +// "type": STRING +// "count": INT +// "location": STRING +// "manifest_version": INT +// "name": STRING +// "path": STRING +// "type": STRING +// "version": STRING + +constexpr base::StringPiece kActivitesKey = "activites"; +constexpr base::StringPiece kCountKey = "count"; +constexpr base::StringPiece kEventsKey = "events"; +constexpr base::StringPiece kEventsListenersKey = "event_listeners"; +constexpr base::StringPiece kExtraDataKey = "extra_data"; +constexpr base::StringPiece kFilterKey = "filter"; +constexpr base::StringPiece kInternalsIdKey = "id"; +constexpr base::StringPiece kInternalsNameKey = "name"; +constexpr base::StringPiece kInternalsVersionKey = "version"; +constexpr base::StringPiece kKeepaliveKey = "keepalive"; +constexpr base::StringPiece kLocationKey = "location"; +constexpr base::StringPiece kManifestVersionKey = "manifest_version"; +constexpr base::StringPiece kPathKey = "path"; +constexpr base::StringPiece kTypeKey = "type"; + base::Value FormatKeepaliveData(extensions::ProcessManager* process_manager, const extensions::Extension* extension) { base::Value keepalive_data(base::Value::Type::DICTIONARY); keepalive_data.SetKey( - "count", base::Value(process_manager->GetLazyKeepaliveCount(extension))); + kCountKey, + base::Value(process_manager->GetLazyKeepaliveCount(extension))); const extensions::ProcessManager::ActivitiesMultiset activities = process_manager->GetLazyKeepaliveActivities(extension); base::Value activities_data(base::Value::Type::LIST); @@ -89,14 +161,65 @@ base::Value FormatKeepaliveData(extensions::ProcessManager* process_manager, for (const auto& activity : activities) { base::Value activities_entry(base::Value::Type::DICTIONARY); activities_entry.SetKey( - "type", base::Value(extensions::Activity::ToString(activity.first))); - activities_entry.SetKey("extra_data", base::Value(activity.second)); + kTypeKey, base::Value(extensions::Activity::ToString(activity.first))); + activities_entry.SetKey(kExtraDataKey, base::Value(activity.second)); activities_data.GetList().push_back(std::move(activities_entry)); } - keepalive_data.SetKey("activites", std::move(activities_data)); + keepalive_data.SetKey(kActivitesKey, std::move(activities_data)); return keepalive_data; } +void AddEventListenerData(extensions::EventRouter* event_router, + base::Value* data) { + CHECK(data->is_list()); + // A map of extension ID to the event data for that extension, + // which is of type LIST of DICTIONARY. + std::unordered_map<base::StringPiece, base::Value, base::StringPieceHash> + events_map; + + // Build the map of extension IDs to the list of events. + for (const auto& entry : event_router->listeners().listeners()) { + for (const auto& listener_entry : entry.second) { + auto& events_list = events_map[listener_entry->extension_id()]; + if (events_list.is_none()) { + // Not there, so make it a LIST. + events_list = base::Value(base::Value::Type::LIST); + } + // The data for each event is a dictionary, with a name and a + // filter. + base::Value event_data(base::Value::Type::DICTIONARY); + event_data.SetKey(kInternalsNameKey, + base::Value(listener_entry->event_name())); + // Add the filter if one exists. + base::Value* const filter = listener_entry->filter(); + if (filter != nullptr) { + event_data.SetKey(kFilterKey, filter->Clone()); + } + events_list.GetList().push_back(std::move(event_data)); + } + } + + // Move all of the entries from the map into the output data. + for (auto& output_entry : data->GetList()) { + const base::Value* const value = output_entry.FindKey(kInternalsIdKey); + CHECK(value && value->is_string()); + const auto it = events_map.find(value->GetString()); + base::Value listeners(base::Value::Type::DICTIONARY); + if (it == events_map.end()) { + // We didn't find any events, so initialize an empty dictionary. + listeners.SetKey(kCountKey, base::Value(0)); + listeners.SetKey(kEventsKey, base::Value(base::Value::Type::LIST)); + } else { + // Set the count and the events values. + listeners.SetKey( + kCountKey, + base::Value(base::checked_cast<int>(it->second.GetList().size()))); + listeners.SetKey(kEventsKey, std::move(it->second)); + } + output_entry.SetKey(kEventsListenersKey, std::move(listeners)); + } +} + } // namespace ExtensionsInternalsSource::ExtensionsInternalsSource(Profile* profile) @@ -131,23 +254,26 @@ std::string ExtensionsInternalsSource::WriteToString() const { base::Value data(base::Value::Type::LIST); for (const auto& extension : *extensions) { base::Value extension_data(base::Value::Type::DICTIONARY); - extension_data.SetKey("id", base::Value(extension->id())); + extension_data.SetKey(kInternalsIdKey, base::Value(extension->id())); extension_data.SetKey( - "keepalive", FormatKeepaliveData(process_manager, extension.get())); - extension_data.SetKey("location", + kKeepaliveKey, FormatKeepaliveData(process_manager, extension.get())); + extension_data.SetKey(kLocationKey, base::Value(LocationToString(extension->location()))); - extension_data.SetKey("manifest_version", + extension_data.SetKey(kManifestVersionKey, base::Value(extension->manifest_version())); - extension_data.SetKey("name", base::Value(extension->name())); - extension_data.SetKey("path", + extension_data.SetKey(kInternalsNameKey, base::Value(extension->name())); + extension_data.SetKey(kPathKey, base::Value(extension->path().LossyDisplayName())); - extension_data.SetKey("type", + extension_data.SetKey(kTypeKey, base::Value(TypeToString(extension->GetType()))); - extension_data.SetKey("version", + extension_data.SetKey(kInternalsVersionKey, base::Value(extension->GetVersionForDisplay())); data.GetList().push_back(std::move(extension_data)); } + // Aggregate and add the data for the registered event listeners. + AddEventListenerData(extensions::EventRouter::Get(profile_), &data); + std::string json; base::JSONWriter::WriteWithOptions( data, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); diff --git a/chromium/chrome/browser/ui/webui/fileicon_source.cc b/chromium/chrome/browser/ui/webui/fileicon_source.cc index da3b8a64b3e..a7d16dd47cb 100644 --- a/chromium/chrome/browser/ui/webui/fileicon_source.cc +++ b/chromium/chrome/browser/ui/webui/fileicon_source.cc @@ -103,8 +103,7 @@ void FileIconSource::FetchFileIcon( if (icon) { scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); gfx::PNGCodec::EncodeBGRASkBitmap( - icon->ToImageSkia()->GetRepresentation(scale_factor).sk_bitmap(), - false, + icon->ToImageSkia()->GetRepresentation(scale_factor).GetBitmap(), false, &icon_data->data()); callback.Run(icon_data.get()); @@ -154,10 +153,10 @@ void FileIconSource::OnFileIconDataAvailable(const IconRequestDetails& details, if (icon) { scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); gfx::PNGCodec::EncodeBGRASkBitmap( - icon->ToImageSkia()->GetRepresentation( - details.scale_factor).sk_bitmap(), - false, - &icon_data->data()); + icon->ToImageSkia() + ->GetRepresentation(details.scale_factor) + .GetBitmap(), + false, &icon_data->data()); details.callback.Run(icon_data.get()); } else { diff --git a/chromium/chrome/browser/ui/webui/fileicon_source.h b/chromium/chrome/browser/ui/webui/fileicon_source.h index 6b404673c7c..a79f2c28ae4 100644 --- a/chromium/chrome/browser/ui/webui/fileicon_source.h +++ b/chromium/chrome/browser/ui/webui/fileicon_source.h @@ -22,6 +22,7 @@ class Image; class FileIconSource : public content::URLDataSource { public: FileIconSource(); + ~FileIconSource() override; // content::URLDataSource implementation. std::string GetSource() const override; @@ -33,8 +34,6 @@ class FileIconSource : public content::URLDataSource { bool AllowCaching() const override; protected: - ~FileIconSource() override; - // Once the |path| and |icon_size| has been determined from the request, this // function is called to perform the actual fetch. Declared as virtual for // testing. diff --git a/chromium/chrome/browser/ui/webui/flags_ui.cc b/chromium/chrome/browser/ui/webui/flags_ui.cc index e79e5fcc715..571f79fad3f 100644 --- a/chromium/chrome/browser/ui/webui/flags_ui.cc +++ b/chromium/chrome/browser/ui/webui/flags_ui.cc @@ -284,6 +284,7 @@ void FinishInitialization(base::WeakPtr<FlagsUI> flags_ui, Profile* profile, FlagsDOMHandler* dom_handler, bool current_user_is_owner) { + DCHECK(!profile->IsOffTheRecord()); // If the flags_ui has gone away, there's nothing to do. if (!flags_ui) return; @@ -325,16 +326,19 @@ FlagsUI::FlagsUI(content::WebUI* web_ui) web_ui->AddMessageHandler(std::move(handler_owner)); #if defined(OS_CHROMEOS) + // Bypass possible incognito profile. + Profile* original_profile = profile->GetOriginalProfile(); if (base::SysInfo::IsRunningOnChromeOS() && chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( - profile)) { + original_profile)) { chromeos::OwnerSettingsServiceChromeOS* service = chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( - profile); - service->IsOwnerAsync(base::Bind( - &FinishInitialization, weak_factory_.GetWeakPtr(), profile, handler)); + original_profile); + service->IsOwnerAsync(base::Bind(&FinishInitialization, + weak_factory_.GetWeakPtr(), + original_profile, handler)); } else { - FinishInitialization(weak_factory_.GetWeakPtr(), profile, handler, + FinishInitialization(weak_factory_.GetWeakPtr(), original_profile, handler, false /* current_user_is_owner */); } #else diff --git a/chromium/chrome/browser/ui/webui/flash_ui.cc b/chromium/chrome/browser/ui/webui/flash_ui.cc index 2fdf9142f2a..aabc15919e9 100644 --- a/chromium/chrome/browser/ui/webui/flash_ui.cc +++ b/chromium/chrome/browser/ui/webui/flash_ui.cc @@ -310,8 +310,7 @@ void FlashDOMHandler::MaybeRespondToPage() { std::vector<UploadList::UploadInfo> crashes; upload_list_->GetUploads(10, &crashes); - for (std::vector<UploadList::UploadInfo>::iterator i = crashes.begin(); - i != crashes.end(); ++i) { + for (auto i = crashes.begin(); i != crashes.end(); ++i) { base::string16 crash_string(ASCIIToUTF16(i->upload_id)); crash_string += ASCIIToUTF16(" "); crash_string += base::TimeFormatFriendlyDateAndTime(i->upload_time); diff --git a/chromium/chrome/browser/ui/webui/foreign_session_handler.cc b/chromium/chrome/browser/ui/webui/foreign_session_handler.cc index 67f9a2e08dc..3ca3252a1c9 100644 --- a/chromium/chrome/browser/ui/webui/foreign_session_handler.cc +++ b/chromium/chrome/browser/ui/webui/foreign_session_handler.cc @@ -198,7 +198,7 @@ void ForeignSessionHandler::OpenForeignSessionWindows( } std::vector<const ::sessions::SessionWindow*>::const_iterator iter_begin = windows.begin() + (window_num < 0 ? 0 : window_num); - std::vector<const ::sessions::SessionWindow*>::const_iterator iter_end = + auto iter_end = window_num < 0 ? std::vector<const ::sessions::SessionWindow*>::const_iterator( windows.end()) @@ -215,7 +215,7 @@ sync_sessions::OpenTabsUIDelegate* ForeignSessionHandler::GetOpenTabsUIDelegate( ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); // Only return the delegate if it exists and it is done syncing sessions. - if (service && service->IsSyncActive()) + if (service && service->IsSyncFeatureActive()) return service->GetOpenTabsUIDelegate(); return NULL; diff --git a/chromium/chrome/browser/ui/webui/identity_internals_ui.cc b/chromium/chrome/browser/ui/webui/identity_internals_ui.cc index 5e0382505cc..8b699ca4cfb 100644 --- a/chromium/chrome/browser/ui/webui/identity_internals_ui.cc +++ b/chromium/chrome/browser/ui/webui/identity_internals_ui.cc @@ -184,8 +184,7 @@ const std::string IdentityInternalsUIMessageHandler::GetExtensionName( std::unique_ptr<base::ListValue> IdentityInternalsUIMessageHandler::GetScopes( const extensions::ExtensionTokenKey& token_cache_key) { auto scopes_value = std::make_unique<base::ListValue>(); - for (std::set<std::string>::const_iterator - iter = token_cache_key.scopes.begin(); + for (auto iter = token_cache_key.scopes.begin(); iter != token_cache_key.scopes.end(); ++iter) { scopes_value->AppendString(*iter); } diff --git a/chromium/chrome/browser/ui/webui/inspect_ui.cc b/chromium/chrome/browser/ui/webui/inspect_ui.cc index 151d8f14559..2b234cd745b 100644 --- a/chromium/chrome/browser/ui/webui/inspect_ui.cc +++ b/chromium/chrome/browser/ui/webui/inspect_ui.cc @@ -363,8 +363,7 @@ InspectUI::InspectUI(content::WebUI* web_ui) content::WebUIDataSource::Add(profile, CreateInspectUIHTMLSource()); // Set up the chrome://theme/ source. - ThemeSource* theme = new ThemeSource(profile); - content::URLDataSource::Add(profile, theme); + content::URLDataSource::Add(profile, std::make_unique<ThemeSource>(profile)); } InspectUI::~InspectUI() { diff --git a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc index f539aa124a9..d37ffb06772 100644 --- a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc +++ b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc @@ -330,6 +330,8 @@ TestSafeBrowsingBlockingPageQuiet* CreateSafeBrowsingQuietBlockingPage( threat_type = safe_browsing::SB_THREAT_TYPE_URL_PHISHING; } else if (type_param == "unwanted") { threat_type = safe_browsing::SB_THREAT_TYPE_URL_UNWANTED; + } else if (type_param == "billing") { + threat_type = safe_browsing::SB_THREAT_TYPE_BILLING; } else if (type_param == "giant") { threat_type = safe_browsing::SB_THREAT_TYPE_URL_MALWARE; is_giant_webview = true; @@ -407,8 +409,7 @@ CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage( InterstitialUI::InterstitialUI(content::WebUI* web_ui) : WebUIController(web_ui) { - Profile* profile = Profile::FromWebUI(web_ui); - content::URLDataSource::Add(profile, + content::URLDataSource::Add(Profile::FromWebUI(web_ui), std::make_unique<InterstitialHTMLSource>()); } diff --git a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc index 22fdd471443..0543042cbd9 100644 --- a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc @@ -124,6 +124,12 @@ IN_PROC_BROWSER_TEST_F(InterstitialUITest, UnwantedSoftwareInterstitialQuiet) { "Security error"); } +IN_PROC_BROWSER_TEST_F(InterstitialUITest, BillingInterstitialQuiet) { + TestInterstitial( + GURL("chrome://interstitials/quietsafebrowsing?type=billing"), + "Security error"); +} + IN_PROC_BROWSER_TEST_F(InterstitialUITest, ClientsideMalwareInterstitial) { TestInterstitial( GURL("chrome://interstitials/safebrowsing?type=clientside_malware"), 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 ae7afceea0e..5227b2379df 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 @@ -28,17 +28,20 @@ namespace { const char kPreviewsAllowedHtmlId[] = "previews-allowed-status"; const char kClientLoFiPreviewsHtmlId[] = "client-lofi-preview-status"; const char kNoScriptPreviewsHtmlId[] = "noscript-preview-status"; +const char kResourceLoadingHintsHtmlId[] = "resource-loading-hints-status"; const char kOfflinePreviewsHtmlId[] = "offline-preview-status"; // Descriptions for previews. const char kPreviewsAllowedDescription[] = "Previews Allowed"; const char kClientLoFiDescription[] = "Client LoFi Previews"; const char kNoScriptDescription[] = "NoScript Previews"; +const char kResourceLoadingHintsDescription[] = "ResourceLoadingHints Previews"; const char kOfflineDesciption[] = "Offline Previews"; // Flag feature name. const char kPreviewsAllowedFeatureName[] = "Previews"; const char kNoScriptFeatureName[] = "NoScriptPreviews"; +const char kResourceLoadingHintsFeatureName[] = "ResourceLoadingHints"; #if defined(OS_ANDROID) const char kOfflinePageFeatureName[] = "OfflinePreviews"; #endif // OS_ANDROID @@ -48,6 +51,7 @@ const char kOfflinePageFeatureName[] = "OfflinePreviews"; const char kPreviewsAllowedFlagHtmlId[] = "previews-flag"; const char kEctFlagHtmlId[] = "ect-flag"; const char kNoScriptFlagHtmlId[] = "noscript-flag"; +const char kResourceLoadingHintsFlagHtmlId[] = "resource-loading-hints-flag"; const char kOfflinePageFlagHtmlId[] = "offline-page-flag"; const char kIgnorePreviewsBlacklistFlagHtmlId[] = "ignore-previews-blacklist"; @@ -56,6 +60,8 @@ const char kIgnorePreviewsBlacklistFlagHtmlId[] = "ignore-previews-blacklist"; const char kPreviewsAllowedFlagLink[] = "chrome://flags/#allow-previews"; const char kEctFlagLink[] = "chrome://flags/#force-effective-connection-type"; const char kNoScriptFlagLink[] = "chrome://flags/#enable-noscript-previews"; +const char kResourceLoadingHintsFlagLink[] = + "chrome://flags/#enable-resource-loading-hints"; const char kOfflinePageFlagLink[] = "chrome://flags/#enable-offline-previews"; const char kIgnorePreviewsBlacklistLink[] = "chrome://flags/#ignore-previews-blacklist"; @@ -209,6 +215,13 @@ void InterventionsInternalsPageHandler::GetPreviewsEnabled( noscript_status->htmlId = kNoScriptPreviewsHtmlId; statuses.push_back(std::move(noscript_status)); + auto resource_loading_hints_status = mojom::PreviewsStatus::New(); + resource_loading_hints_status->description = kResourceLoadingHintsDescription; + resource_loading_hints_status->enabled = + previews::params::IsResourceLoadingHintsEnabled(); + resource_loading_hints_status->htmlId = kResourceLoadingHintsHtmlId; + statuses.push_back(std::move(resource_loading_hints_status)); + auto offline_status = mojom::PreviewsStatus::New(); offline_status->description = kOfflineDesciption; offline_status->enabled = previews::params::IsOfflinePreviewsEnabled(); @@ -258,6 +271,15 @@ void InterventionsInternalsPageHandler::GetPreviewsFlagsDetails( noscript_status->htmlId = kNoScriptFlagHtmlId; flags.push_back(std::move(noscript_status)); + auto resource_loading_hints_status = mojom::PreviewsFlag::New(); + resource_loading_hints_status->description = + flag_descriptions::kEnableResourceLoadingHintsName; + resource_loading_hints_status->link = kResourceLoadingHintsFlagLink; + resource_loading_hints_status->value = + GetFeatureFlagStatus(kResourceLoadingHintsFeatureName); + resource_loading_hints_status->htmlId = kResourceLoadingHintsFlagHtmlId; + flags.push_back(std::move(resource_loading_hints_status)); + auto offline_page_status = mojom::PreviewsFlag::New(); #if defined(OS_ANDROID) offline_page_status->description = 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 46c92a66784..24fb1d91319 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 @@ -41,6 +41,7 @@ #include "net/nqe/effective_connection_type.h" #include "net/nqe/network_quality_estimator_params.h" #include "services/network/public/cpp/network_switches.h" +#include "services/network/test/test_network_quality_tracker.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -49,12 +50,15 @@ namespace { constexpr char kPreviewsAllowedHtmlId[] = "previews-allowed-status"; constexpr char kClientLoFiPreviewsHtmlId[] = "client-lofi-preview-status"; constexpr char kNoScriptPreviewsHtmlId[] = "noscript-preview-status"; +constexpr char kResourceLoadingHintsHtmlId[] = "resource-loading-hints-status"; constexpr char kOfflinePreviewsHtmlId[] = "offline-preview-status"; // Descriptions for previews. constexpr char kPreviewsAllowedDescription[] = "Previews Allowed"; constexpr char kClientLoFiDescription[] = "Client LoFi Previews"; constexpr char kNoScriptDescription[] = "NoScript Previews"; +constexpr char kResourceLoadingHintsDescription[] = + "ResourceLoadingHints Previews"; constexpr char kOfflineDesciption[] = "Offline Previews"; // The HTML DOM ID used in Javascript. @@ -62,10 +66,14 @@ constexpr char kEctFlagHtmlId[] = "ect-flag"; constexpr char kIgnorePreviewsBlacklistFlagHtmlId[] = "ignore-previews-blacklist"; constexpr char kNoScriptFlagHtmlId[] = "noscript-flag"; +constexpr char kResourceLoadingHintsFlagHtmlId[] = + "resource-loading-hints-flag"; constexpr char kOfflinePageFlagHtmlId[] = "offline-page-flag"; // Links to flags in chrome://flags. constexpr char kNoScriptFlagLink[] = "chrome://flags/#enable-noscript-previews"; +constexpr char kResourceLoadingHintsFlagLink[] = + "chrome://flags/#enable-resource-loading-hints"; constexpr char kEctFlagLink[] = "chrome://flags/#force-effective-connection-type"; constexpr char kIgnorePreviewsBlacklistLink[] = @@ -75,6 +83,7 @@ constexpr char kOfflinePageFlagLink[] = // Flag features names. constexpr char kNoScriptFeatureName[] = "NoScriptPreviews"; +constexpr char kResourceLoadingHintsFeatureName[] = "ResourceLoadingHints"; constexpr char kOfflinePageFeatureName[] = "OfflinePreviews"; constexpr char kDefaultFlagValue[] = "Default"; @@ -213,15 +222,18 @@ class TestPreviewsDeciderImpl : public previews::PreviewsDeciderImpl { // Mocked TestPreviewsService for testing InterventionsInternalsPageHandler. class TestPreviewsUIService : public previews::PreviewsUIService { public: - TestPreviewsUIService(TestPreviewsDeciderImpl* previews_decider_impl, - std::unique_ptr<previews::PreviewsLogger> logger) + TestPreviewsUIService( + TestPreviewsDeciderImpl* previews_decider_impl, + std::unique_ptr<previews::PreviewsLogger> logger, + network::TestNetworkQualityTracker* test_network_quality_tracker) : PreviewsUIService(previews_decider_impl, nullptr, /* io_task_runner */ nullptr, /* previews_opt_out_store */ nullptr, /* previews_opt_guide */ base::Bind(&MockedPreviewsIsEnabled), std::move(logger), - blacklist::BlacklistData::AllowedTypesAndVersions()), + blacklist::BlacklistData::AllowedTypesAndVersions(), + test_network_quality_tracker), blacklist_ignored_(false) {} ~TestPreviewsUIService() override {} @@ -250,8 +262,8 @@ class InterventionsInternalsPageHandlerTest : public testing::Test { std::unique_ptr<TestPreviewsLogger> logger = std::make_unique<TestPreviewsLogger>(); logger_ = logger.get(); - previews_ui_service_ = - std::make_unique<TestPreviewsUIService>(&io_data, std::move(logger)); + previews_ui_service_ = std::make_unique<TestPreviewsUIService>( + &io_data, std::move(logger), &test_network_quality_tracker_); ASSERT_TRUE(profile_manager_.SetUp()); @@ -278,6 +290,7 @@ class InterventionsInternalsPageHandlerTest : public testing::Test { TestingProfileManager profile_manager_; TestPreviewsLogger* logger_; + network::TestNetworkQualityTracker test_network_quality_tracker_; std::unique_ptr<TestPreviewsUIService> previews_ui_service_; // InterventionsInternalPageHandler's variables. @@ -295,7 +308,7 @@ TEST_F(InterventionsInternalsPageHandlerTest, GetPreviewsEnabledCount) { page_handler_->GetPreviewsEnabled( base::BindOnce(&MockGetPreviewsEnabledCallback)); - constexpr size_t expected = 4; + constexpr size_t expected = 5; EXPECT_EQ(expected, passed_in_modes.size()); } @@ -373,6 +386,36 @@ TEST_F(InterventionsInternalsPageHandlerTest, NoScriptEnabled) { EXPECT_TRUE(noscript->second->enabled); } +TEST_F(InterventionsInternalsPageHandlerTest, ResourceLoadingHintsDisabled) { + // Init with kResourceLoadingHints disabled. + scoped_feature_list_->InitWithFeatures( + {}, {previews::features::kResourceLoadingHints}); + + page_handler_->GetPreviewsEnabled( + base::BindOnce(&MockGetPreviewsEnabledCallback)); + auto resource_loading_hints = + passed_in_modes.find(kResourceLoadingHintsHtmlId); + ASSERT_NE(passed_in_modes.end(), resource_loading_hints); + EXPECT_EQ(kResourceLoadingHintsDescription, + resource_loading_hints->second->description); + EXPECT_FALSE(resource_loading_hints->second->enabled); +} + +TEST_F(InterventionsInternalsPageHandlerTest, ResourceLoadingHintsEnabled) { + // Init with kResourceLoadingHints enabled. + scoped_feature_list_->InitWithFeatures( + {previews::features::kResourceLoadingHints}, {}); + + page_handler_->GetPreviewsEnabled( + base::BindOnce(&MockGetPreviewsEnabledCallback)); + auto resource_loading_hints = + passed_in_modes.find(kResourceLoadingHintsHtmlId); + ASSERT_NE(passed_in_modes.end(), resource_loading_hints); + EXPECT_EQ(kResourceLoadingHintsDescription, + resource_loading_hints->second->description); + EXPECT_TRUE(resource_loading_hints->second->enabled); +} + TEST_F(InterventionsInternalsPageHandlerTest, OfflinePreviewsDisabled) { // Init with kOfflinePreviews disabled. scoped_feature_list_->InitWithFeatures( @@ -404,7 +447,7 @@ TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsCount) { page_handler_->GetPreviewsFlagsDetails( base::BindOnce(&MockGetPreviewsFlagsCallback)); - constexpr size_t expected = 5; + constexpr size_t expected = 6; EXPECT_EQ(expected, passed_in_flags.size()); } @@ -544,6 +587,61 @@ TEST_F(InterventionsInternalsPageHandlerTest, GetFlagsNoScriptDisabled) { EXPECT_EQ(kNoScriptFlagLink, noscript_flag->second->link); } +TEST_F(InterventionsInternalsPageHandlerTest, + GetFlagsResourceLoadingHintsDefaultValue) { + page_handler_->GetPreviewsFlagsDetails( + base::BindOnce(&MockGetPreviewsFlagsCallback)); + auto resource_loading_hints_flag = + passed_in_flags.find(kResourceLoadingHintsFlagHtmlId); + + ASSERT_NE(passed_in_flags.end(), resource_loading_hints_flag); + EXPECT_EQ(flag_descriptions::kEnableResourceLoadingHintsName, + resource_loading_hints_flag->second->description); + EXPECT_EQ(kDefaultFlagValue, resource_loading_hints_flag->second->value); + EXPECT_EQ(kResourceLoadingHintsFlagLink, + resource_loading_hints_flag->second->link); +} + +TEST_F(InterventionsInternalsPageHandlerTest, + GetFlagsResourceLoadingHintsEnabled) { + base::test::ScopedCommandLine scoped_command_line; + base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine(); + command_line->AppendSwitchASCII(switches::kEnableFeatures, + kResourceLoadingHintsFeatureName); + + page_handler_->GetPreviewsFlagsDetails( + base::BindOnce(&MockGetPreviewsFlagsCallback)); + auto resource_loading_hints_flag = + passed_in_flags.find(kResourceLoadingHintsFlagHtmlId); + + ASSERT_NE(passed_in_flags.end(), resource_loading_hints_flag); + EXPECT_EQ(flag_descriptions::kEnableResourceLoadingHintsName, + resource_loading_hints_flag->second->description); + EXPECT_EQ(kEnabledFlagValue, resource_loading_hints_flag->second->value); + EXPECT_EQ(kResourceLoadingHintsFlagLink, + resource_loading_hints_flag->second->link); +} + +TEST_F(InterventionsInternalsPageHandlerTest, + GetFlagsResourceLoadingHintsDisabled) { + base::test::ScopedCommandLine scoped_command_line; + base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine(); + command_line->AppendSwitchASCII(switches::kDisableFeatures, + kResourceLoadingHintsFeatureName); + + page_handler_->GetPreviewsFlagsDetails( + base::BindOnce(&MockGetPreviewsFlagsCallback)); + auto resource_loading_hints_flag = + passed_in_flags.find(kResourceLoadingHintsFlagHtmlId); + + ASSERT_NE(passed_in_flags.end(), resource_loading_hints_flag); + EXPECT_EQ(flag_descriptions::kEnableResourceLoadingHintsName, + resource_loading_hints_flag->second->description); + EXPECT_EQ(kDisabledFlagValue, resource_loading_hints_flag->second->value); + EXPECT_EQ(kResourceLoadingHintsFlagLink, + resource_loading_hints_flag->second->link); +} + #if defined(OS_ANDROID) #define TestAndroid(x) x #else diff --git a/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc b/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc index ef2380b3429..b05bcaf08cc 100644 --- a/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc +++ b/chromium/chrome/browser/ui/webui/invalidations_message_handler.cc @@ -8,8 +8,10 @@ #include "base/bind.h" #include "chrome/browser/invalidation/deprecated_profile_invalidation_provider_factory.h" +#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" #include "chrome/browser/profiles/profile.h" #include "components/invalidation/impl/invalidation_logger.h" +#include "components/invalidation/impl/invalidation_switches.h" #include "components/invalidation/impl/profile_invalidation_provider.h" #include "components/invalidation/public/invalidation_handler.h" #include "components/invalidation/public/invalidation_service.h" @@ -43,9 +45,16 @@ void InvalidationsMessageHandler::RegisterMessages() { } void InvalidationsMessageHandler::UIReady(const base::ListValue* args) { - invalidation::ProfileInvalidationProvider* invalidation_provider = - invalidation::DeprecatedProfileInvalidationProviderFactory::GetForProfile( - Profile::FromWebUI(web_ui())); + invalidation::ProfileInvalidationProvider* invalidation_provider; + Profile* profile = Profile::FromWebUI(web_ui()); + if (base::FeatureList::IsEnabled(invalidation::switches::kFCMInvalidations)) { + invalidation_provider = + invalidation::ProfileInvalidationProviderFactory::GetForProfile( + profile); + } else { + invalidation_provider = invalidation:: + DeprecatedProfileInvalidationProviderFactory::GetForProfile(profile); + } if (invalidation_provider) { logger_ = invalidation_provider->GetInvalidationService()-> GetInvalidationLogger(); @@ -75,9 +84,8 @@ void InvalidationsMessageHandler::UpdateContent(const base::ListValue* args) { void InvalidationsMessageHandler::OnRegistrationChange( const std::multiset<std::string>& registered_handlers) { base::ListValue list_of_handlers; - for (std::multiset<std::string>::const_iterator it = - registered_handlers.begin(); - it != registered_handlers.end(); ++it) { + for (auto it = registered_handlers.begin(); it != registered_handlers.end(); + ++it) { list_of_handlers.AppendString(*it); } web_ui()->CallJavascriptFunctionUnsafe("chrome.invalidations.updateHandlers", @@ -97,9 +105,7 @@ void InvalidationsMessageHandler::OnUpdateIds( const std::string& handler_name, const syncer::ObjectIdCountMap& ids) { base::ListValue list_of_objects; - for (syncer::ObjectIdCountMap::const_iterator it = ids.begin(); - it != ids.end(); - ++it) { + for (auto it = ids.begin(); it != ids.end(); ++it) { std::unique_ptr<base::DictionaryValue> dic(new base::DictionaryValue()); dic->SetString("name", (it->first).name()); dic->SetInteger("source", (it->first).source()); diff --git a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc index 3edcc57d67a..187bee04cb4 100644 --- a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc +++ b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc @@ -8,8 +8,6 @@ #include "build/build_config.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" #include "chrome/browser/ui/webui/metrics_handler.h" #include "chrome/common/pref_names.h" @@ -44,7 +42,6 @@ content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() { IDS_LOCAL_DISCOVERY_CONFIRM_REGISTRATION); source->AddLocalizedString("addingPrinter", IDS_LOCAL_DISCOVERY_ADDING_PRINTER); - source->AddLocalizedString("addingDevice", IDS_LOCAL_DISCOVERY_ADDING_DEVICE); source->AddLocalizedString("addingError", IDS_LOCAL_DISCOVERY_ERROR_OCURRED); source->AddLocalizedString("addingErrorMessage", @@ -57,15 +54,8 @@ content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() { IDS_LOCAL_DISCOVERY_ADDING_PRINTER_MESSAGE1); source->AddLocalizedString("addingPrinterMessage2", IDS_LOCAL_DISCOVERY_ADDING_PRINTER_MESSAGE2); - source->AddLocalizedString("addingDeviceMessage1", - IDS_LOCAL_DISCOVERY_ADDING_DEVICE_MESSAGE1); - source->AddLocalizedString("addingDeviceConfirmCodeMessage", - IDS_LOCAL_DISCOVERY_CONFIRM_CODE_MESSAGE); - source->AddLocalizedString("confirmCode", IDS_LOCAL_DISCOVERY_CONFIRM_CODE); source->AddLocalizedString("devicesTitle", IDS_LOCAL_DISCOVERY_DEVICES_PAGE_TITLE); - source->AddLocalizedString("noDescriptionDevice", - IDS_LOCAL_DISCOVERY_NO_DESCRIPTION_DEVICE); source->AddLocalizedString("noDescriptionPrinter", IDS_LOCAL_DISCOVERY_NO_DESCRIPTION_PRINTER); source->AddLocalizedString("printersOnNetworkZero", @@ -96,7 +86,6 @@ content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() { IDS_LOCAL_DISCOVERY_AVAILABLE_DEVICES); source->AddLocalizedString("myDevicesTitle", IDS_LOCAL_DISCOVERY_MY_DEVICES); - source->AddLocalizedString("backButton", IDS_SETTINGS_TITLE); // Cloud print connector-related strings. #if BUILDFLAG(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS) @@ -125,11 +114,6 @@ LocalDiscoveryUI::LocalDiscoveryUI(content::WebUI* web_ui) : WebUIController(web_ui) { // Set up the chrome://devices/ source. content::WebUIDataSource* source = CreateLocalDiscoveryHTMLSource(); - Browser* browser = - chrome::FindBrowserWithWebContents(web_ui->GetWebContents()); - // Show a back button pointing to Settings if the browser has no location bar. - if (browser && browser->is_trusted_source()) - source->AddString("backButtonURL", chrome::kChromeUISettingsURL); content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source); // TODO(gene): Use LocalDiscoveryUIHandler to send updated to the devices diff --git a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc index 1fa7b8a58cb..114872dbd4d 100644 --- a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc +++ b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc @@ -55,8 +55,6 @@ namespace { const char kDictionaryKeyServiceName[] = "service_name"; const char kDictionaryKeyDisplayName[] = "display_name"; const char kDictionaryKeyDescription[] = "description"; -const char kDictionaryKeyType[] = "type"; -const char kDictionaryKeyIsWifi[] = "is_wifi"; const char kDictionaryKeyID[] = "id"; const char kKeyPrefixMDns[] = "MDns:"; @@ -73,7 +71,6 @@ std::unique_ptr<base::DictionaryValue> CreateDeviceInfo( return_value->SetString(kDictionaryKeyID, description.id); return_value->SetString(kDictionaryKeyDisplayName, description.display_name); return_value->SetString(kDictionaryKeyDescription, description.description); - return_value->SetString(kDictionaryKeyType, "printer"); return return_value; } @@ -116,9 +113,8 @@ LocalDiscoveryUIHandler::SetURLLoaderFactoryForTesting:: } LocalDiscoveryUIHandler::LocalDiscoveryUIHandler() - : is_visible_(false), - failed_list_count_(0), - succeded_list_count_(0) { + : failed_list_count_(0), succeded_list_count_(0) { + g_num_visible++; } LocalDiscoveryUIHandler::~LocalDiscoveryUIHandler() { @@ -128,7 +124,7 @@ LocalDiscoveryUIHandler::~LocalDiscoveryUIHandler() { if (identity_manager) identity_manager->RemoveObserver(this); ResetCurrentRegistration(); - SetIsVisible(false); + g_num_visible--; } // static @@ -141,10 +137,6 @@ void LocalDiscoveryUIHandler::RegisterMessages() { "start", base::BindRepeating(&LocalDiscoveryUIHandler::HandleStart, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "isVisible", - base::BindRepeating(&LocalDiscoveryUIHandler::HandleIsVisible, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( "registerDevice", base::BindRepeating(&LocalDiscoveryUIHandler::HandleRegisterDevice, base::Unretained(this))); @@ -215,20 +207,13 @@ void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) { CheckUserLoggedIn(); } -void LocalDiscoveryUIHandler::HandleIsVisible(const base::ListValue* args) { - bool is_visible = false; - bool rv = args->GetBoolean(0, &is_visible); - DCHECK(rv); - SetIsVisible(is_visible); -} - void LocalDiscoveryUIHandler::HandleRegisterDevice( const base::ListValue* args) { std::string device; bool rv = args->GetString(0, &device); DCHECK(rv); - DeviceDescriptionMap::iterator it = device_descriptions_.find(device); + auto it = device_descriptions_.find(device); if (it == device_descriptions_.end()) { OnSetupError(); return; @@ -388,8 +373,6 @@ void LocalDiscoveryUIHandler::DeviceChanged( info.SetString(kDictionaryKeyServiceName, name); info.SetString(kDictionaryKeyDisplayName, description.name); info.SetString(kDictionaryKeyDescription, description.description); - info.SetString(kDictionaryKeyType, description.type); - info.SetBoolean(kDictionaryKeyIsWifi, false); web_ui()->CallJavascriptFunctionUnsafe( "local_discovery.onUnregisteredDeviceUpdate", service_key, info); @@ -449,7 +432,7 @@ void LocalDiscoveryUIHandler::SendRegisterDone( // block the printer's announcement. privet_lister_->DiscoverNewDevices(); - DeviceDescriptionMap::iterator it = device_descriptions_.find(service_name); + auto it = device_descriptions_.find(service_name); if (it == device_descriptions_.end()) { // TODO(noamsml): Handle the case where a printer's record is not present at @@ -461,7 +444,6 @@ void LocalDiscoveryUIHandler::SendRegisterDone( const DeviceDescription& device = it->second; base::DictionaryValue device_value; - device_value.SetString(kDictionaryKeyType, device.type); device_value.SetString(kDictionaryKeyID, device.id); device_value.SetString(kDictionaryKeyDisplayName, device.name); device_value.SetString(kDictionaryKeyDescription, device.description); @@ -471,14 +453,6 @@ void LocalDiscoveryUIHandler::SendRegisterDone( "local_discovery.onRegistrationSuccess", device_value); } -void LocalDiscoveryUIHandler::SetIsVisible(bool visible) { - if (visible == is_visible_) - return; - - g_num_visible += visible ? 1 : -1; - is_visible_ = visible; -} - std::string LocalDiscoveryUIHandler::GetSyncAccount() const { Profile* profile = Profile::FromWebUI(web_ui()); identity::IdentityManager* identity_manager = diff --git a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h index 440c6465cce..072beb15505 100644 --- a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h +++ b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h @@ -104,9 +104,6 @@ class LocalDiscoveryUIHandler // For when the page is ready to receive device notifications. void HandleStart(const base::ListValue* args); - // For when a visibility change occurs. - void HandleIsVisible(const base::ListValue* args); - // For when a user choice is made. void HandleRegisterDevice(const base::ListValue* args); @@ -137,9 +134,6 @@ class LocalDiscoveryUIHandler // Singal to the web interface that registration has finished. void SendRegisterDone(const std::string& service_name); - // Set the visibility of the page. - void SetIsVisible(bool visible); - // Get the sync account email. std::string GetSyncAccount() const; @@ -196,9 +190,6 @@ class LocalDiscoveryUIHandler // The device lister used to list devices on the local network. std::unique_ptr<cloud_print::PrivetDeviceLister> privet_lister_; - // Whether or not the page is marked as visible. - bool is_visible_; - // List of printers from cloud print. std::unique_ptr<cloud_print::GCDApiFlow> cloud_print_printer_list_; std::vector<cloud_print::CloudPrintPrinterList::Device> cloud_devices_; diff --git a/chromium/chrome/browser/ui/webui/management_ui.cc b/chromium/chrome/browser/ui/webui/management_ui.cc new file mode 100644 index 00000000000..5ca91a1dade --- /dev/null +++ b/chromium/chrome/browser/ui/webui/management_ui.cc @@ -0,0 +1,60 @@ +// 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/management_ui.h" + +#include <memory> + +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/webui/management_ui_handler.h" +#include "chrome/common/url_constants.h" +#include "chrome/grit/browser_resources.h" +#include "components/strings/grit/components_strings.h" +#include "content/public/browser/web_ui.h" + +namespace { + +content::WebUIDataSource* CreateManagementUIHtmlSource() { + content::WebUIDataSource* source = + content::WebUIDataSource::Create(chrome::kChromeUIManagementHost); + source->AddLocalizedString("title", IDS_MANAGEMENT_TITLE); + source->AddLocalizedString("deviceReporting", + IDS_MANAGEMENT_DEVICE_REPORTING); + source->AddLocalizedString("deviceConfiguration", + IDS_MANAGEMENT_DEVICE_CONFIGURATION); + source->AddLocalizedString("extensionReporting", + IDS_MANAGEMENT_EXTENSION_REPORTING); + source->AddLocalizedString("extensionsInstalled", + IDS_MANAGEMENT_EXTENSIONS_INSTALLED); + source->AddLocalizedString("extensionName", IDS_MANAGEMENT_EXTENSIONS_NAME); + source->AddLocalizedString("extensionPermissions", + IDS_MANAGEMENT_EXTENSIONS_PERMISSIONS); + source->AddLocalizedString(kManagementLogUploadEnabled, + IDS_MANAGEMENT_LOG_UPLOAD_ENABLED); + source->AddLocalizedString(kManagementReportActivityTimes, + IDS_MANAGEMENT_REPORT_DEVICE_ACTIVITY_TIMES); + source->AddLocalizedString(kManagementReportHardwareStatus, + IDS_MANAGEMENT_REPORT_DEVICE_HARDWARE_STATUS); + source->AddLocalizedString(kManagementReportNetworkInterfaces, + IDS_MANAGEMENT_REPORT_DEVICE_NETWORK_INTERFACES); + source->AddLocalizedString(kManagementReportUsers, + IDS_MANAGEMENT_REPORT_DEVICE_USERS); + source->SetJsonPath("strings.js"); + // Add required resources. + source->AddResourcePath("management.css", IDR_MANAGEMENT_CSS); + source->AddResourcePath("management.js", IDR_MANAGEMENT_JS); + source->SetDefaultResource(IDR_MANAGEMENT_HTML); + source->UseGzip(); + return source; +} + +} // namespace + +ManagementUI::ManagementUI(content::WebUI* web_ui) : WebUIController(web_ui) { + web_ui->AddMessageHandler(std::make_unique<ManagementUIHandler>()); + content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), + CreateManagementUIHtmlSource()); +} + +ManagementUI::~ManagementUI() {} diff --git a/chromium/chrome/browser/ui/webui/management_ui.h b/chromium/chrome/browser/ui/webui/management_ui.h new file mode 100644 index 00000000000..4d30b78e049 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/management_ui.h @@ -0,0 +1,25 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_H_ + +#include "base/macros.h" +#include "content/public/browser/web_ui_controller.h" + +namespace content { +class WebUI; +} + +// The Web UI controller for the chrome://management page. +class ManagementUI : public content::WebUIController { + public: + explicit ManagementUI(content::WebUI* web_ui); + ~ManagementUI() override; + + private: + DISALLOW_COPY_AND_ASSIGN(ManagementUI); +}; + +#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_H_ diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler.cc b/chromium/chrome/browser/ui/webui/management_ui_handler.cc new file mode 100644 index 00000000000..494590b0dd1 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/management_ui_handler.cc @@ -0,0 +1,227 @@ +// 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/management_ui_handler.h" + +#include <algorithm> +#include <memory> +#include <string> +#include <utility> +#include <vector> + +#include "base/bind.h" +#include "base/bind_helpers.h" +#include "base/callback.h" +#include "base/metrics/user_metrics.h" +#include "base/strings/utf_string_conversions.h" +#include "base/values.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/profiles/profile.h" +#include "components/strings/grit/components_strings.h" +#include "content/public/browser/web_contents.h" +#include "extensions/buildflags/buildflags.h" +#include "ui/base/l10n/l10n_util.h" + +#if defined(OS_CHROMEOS) +#include "chrome/browser/browser_process_platform_part.h" +#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" +#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" +#include "chrome/browser/chromeos/policy/device_status_collector.h" +#include "chrome/browser/chromeos/policy/status_uploader.h" +#include "chrome/browser/chromeos/policy/system_log_uploader.h" +#endif // defined(OS_CHROMEOS) + +#if BUILDFLAG(ENABLE_EXTENSIONS) +#include "chrome/common/extensions/permissions/chrome_permission_message_provider.h" +#include "extensions/browser/extension_registry.h" +#include "extensions/common/extension.h" +#include "extensions/common/extension_set.h" +#include "extensions/common/manifest.h" +#include "extensions/common/permissions/permission_message_provider.h" +#include "extensions/common/permissions/permissions_data.h" +#endif // BUILDFLAG(ENABLE_EXTENSIONS) + +const char kManagementLogUploadEnabled[] = "managementLogUploadEnabled"; +const char kManagementReportActivityTimes[] = "managementReportActivityTimes"; +const char kManagementReportHardwareStatus[] = "managementReportHardwareStatus"; +const char kManagementReportNetworkInterfaces[] = + "managementReportNetworkInterfaces"; +const char kManagementReportUsers[] = "managementReportUsers"; + +namespace { + +#if defined(OS_CHROMEOS) +base::string16 GetEnterpriseDisplayDomain( + policy::BrowserPolicyConnectorChromeOS* connector) { + if (!connector->IsEnterpriseManaged()) + return l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_NOT_MANAGED); + + std::string display_domain = connector->GetEnterpriseDisplayDomain(); + + if (display_domain.empty()) { + if (!connector->IsActiveDirectoryManaged()) + return l10n_util::GetStringUTF16(IDS_MANAGEMENT_DEVICE_MANAGED); + + display_domain = connector->GetRealm(); + } + + return l10n_util::GetStringFUTF16(IDS_MANAGEMENT_DEVICE_MANAGED_BY, + base::UTF8ToUTF16(display_domain)); +} + +void AddChromeOSReportingInfo(base::Value* report_sources) { + policy::BrowserPolicyConnectorChromeOS* connector = + g_browser_process->platform_part()->browser_policy_connector_chromeos(); + + // Only check for report status in managed environment. + if (!connector->IsEnterpriseManaged()) + return; + + policy::DeviceCloudPolicyManagerChromeOS* manager = + connector->GetDeviceCloudPolicyManager(); + + if (!manager) + return; + + if (manager->GetSystemLogUploader()->upload_enabled()) { + report_sources->GetList().push_back( + base::Value(kManagementLogUploadEnabled)); + } + + const policy::DeviceStatusCollector* collector = + manager->GetStatusUploader()->device_status_collector(); + + if (collector->report_activity_times()) { + report_sources->GetList().push_back( + base::Value(kManagementReportActivityTimes)); + } + if (collector->report_hardware_status()) { + report_sources->GetList().push_back( + base::Value(kManagementReportHardwareStatus)); + } + if (collector->report_network_interfaces()) { + report_sources->GetList().push_back( + base::Value(kManagementReportNetworkInterfaces)); + } + if (collector->report_users()) { + report_sources->GetList().push_back(base::Value(kManagementReportUsers)); + } +} +#endif // defined(OS_CHROMEOS) + +#if BUILDFLAG(ENABLE_EXTENSIONS) + +std::vector<base::Value> GetPermissionsForExtension( + scoped_refptr<const extensions::Extension> extension) { + std::vector<base::Value> permission_messages; + // Only consider force installed extensions + if (!extensions::Manifest::IsPolicyLocation(extension->location())) + return permission_messages; + + extensions::PermissionIDSet permissions = + extensions::PermissionMessageProvider::Get()->GetAllPermissionIDs( + extension->permissions_data()->active_permissions(), + extension->GetType()); + + const extensions::PermissionMessages messages = + extensions::PermissionMessageProvider::Get() + ->GetPowerfulPermissionMessages(permissions); + + for (const auto& message : messages) + permission_messages.push_back(base::Value(message.message())); + + return permission_messages; +} + +base::Value GetPowerfulExtensions(const extensions::ExtensionSet& extensions) { + base::Value powerful_extensions(base::Value::Type::LIST); + + for (const auto& extension : extensions) { + std::vector<base::Value> permission_messages = + GetPermissionsForExtension(extension); + + // Only show extension on page if there is at least one permission + // message to show. + if (!permission_messages.empty()) { + base::Value extension_to_add(base::Value::Type::DICTIONARY); + extension_to_add.SetKey("name", base::Value(extension->name())); + extension_to_add.SetKey("permissions", + base::Value(std::move(permission_messages))); + powerful_extensions.GetList().push_back(std::move(extension_to_add)); + } + } + + return powerful_extensions; +} + +#endif // BUILDFLAG(ENABLE_EXTENSIONS) + +} // namespace + +ManagementUIHandler::ManagementUIHandler() {} + +ManagementUIHandler::~ManagementUIHandler() {} + +void ManagementUIHandler::RegisterMessages() { + web_ui()->RegisterMessageCallback( + "getDeviceManagementStatus", + base::BindRepeating(&ManagementUIHandler::HandleGetDeviceManagementStatus, + base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "getReportingInfo", + base::BindRepeating(&ManagementUIHandler::HandleGetReportingInfo, + base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "getExtensions", + base::BindRepeating(&ManagementUIHandler::HandleGetExtensions, + base::Unretained(this))); +} + +void ManagementUIHandler::HandleGetDeviceManagementStatus( + const base::ListValue* args) { + AllowJavascript(); + base::RecordAction(base::UserMetricsAction("ManagementPageViewed")); + +#if defined(OS_CHROMEOS) + policy::BrowserPolicyConnectorChromeOS* connector = + g_browser_process->platform_part()->browser_policy_connector_chromeos(); + + base::Value managed_string(GetEnterpriseDisplayDomain(connector)); + ResolveJavascriptCallback(args->GetList()[0] /* callback_id */, + managed_string); +#else + RejectJavascriptCallback( + args->GetList()[0] /* callback_id */, + base::Value("No device management status on Chrome desktop")); +#endif // defined(OS_CHROMEOS) +} + +void ManagementUIHandler::HandleGetReportingInfo(const base::ListValue* args) { + base::Value report_sources(base::Value::Type::LIST); + +// Only Chrome OS devices report status. +#if defined(OS_CHROMEOS) + AddChromeOSReportingInfo(&report_sources); +#endif // defined(OS_CHROMEOS) + + ResolveJavascriptCallback(args->GetList()[0] /* callback_id */, + report_sources); +} + +void ManagementUIHandler::HandleGetExtensions(const base::ListValue* args) { +#if BUILDFLAG(ENABLE_EXTENSIONS) + // List of all enabled extensions + const extensions::ExtensionSet& extensions = + extensions::ExtensionRegistry::Get(Profile::FromWebUI(web_ui())) + ->enabled_extensions(); + + base::Value powerful_extensions = GetPowerfulExtensions(extensions); + + ResolveJavascriptCallback(args->GetList()[0] /* callback_id */, + powerful_extensions); +#else + ResolveJavascriptCallback(args->GetList()[0] /* callback_id */, + base::Value(base::Value::Type::LIST)); +#endif // BUILDFLAG(ENABLE_EXTENSIONS) +} diff --git a/chromium/chrome/browser/ui/webui/management_ui_handler.h b/chromium/chrome/browser/ui/webui/management_ui_handler.h new file mode 100644 index 00000000000..b132ce721f5 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/management_ui_handler.h @@ -0,0 +1,45 @@ +// 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_MANAGEMENT_UI_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_HANDLER_H_ + +#include "base/macros.h" +#include "base/strings/string16.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_data_source.h" +#include "content/public/browser/web_ui_message_handler.h" + +// Constants defining the IDs for the localized strings sent to the page as +// load time data. +extern const char kManagementLogUploadEnabled[]; +extern const char kManagementReportActivityTimes[]; +extern const char kManagementReportHardwareStatus[]; +extern const char kManagementReportNetworkInterfaces[]; +extern const char kManagementReportUsers[]; + +namespace base { +class ListValue; +} // namespace base + +// The JavaScript message handler for the chrome://management page. +class ManagementUIHandler : public content::WebUIMessageHandler { + public: + ManagementUIHandler(); + ~ManagementUIHandler() override; + + // content::WebUIMessageHandler implementation. + void RegisterMessages() override; + + private: + void HandleGetDeviceManagementStatus(const base::ListValue* args); + + void HandleGetReportingInfo(const base::ListValue* args); + + void HandleGetExtensions(const base::ListValue* args); + + DISALLOW_COPY_AND_ASSIGN(ManagementUIHandler); +}; + +#endif // CHROME_BROWSER_UI_WEBUI_MANAGEMENT_UI_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc b/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc index 403a5f4ac3c..fea64cc980d 100644 --- a/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc +++ b/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc @@ -9,6 +9,7 @@ #include <string> #include <utility> +#include "base/stl_util.h" #include "base/strings/string16.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/md_bookmarks/bookmarks_message_handler.h" @@ -23,6 +24,7 @@ #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" @@ -32,7 +34,7 @@ void AddLocalizedString(content::WebUIDataSource* source, const std::string& message, int id) { base::string16 str = l10n_util::GetStringUTF16(id); - str.erase(std::remove(str.begin(), str.end(), '&'), str.end()); + base::Erase(str, '&'); source->AddString(message, str); } @@ -40,6 +42,15 @@ content::WebUIDataSource* CreateMdBookmarksUIHTMLSource(Profile* profile) { content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUIBookmarksHost); + // Build an Accelerator to describe undo shortcut + // NOTE: the undo shortcut is also defined in md_bookmarks/command_manager.js + // TODO(b/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, + undoAccelerator.GetShortcutText())); + // Localized strings (alphabetical order). AddLocalizedString(source, "addBookmarkTitle", IDS_MD_BOOKMARK_MANAGER_ADD_BOOKMARK_TITLE); @@ -161,8 +172,6 @@ content::WebUIDataSource* CreateMdBookmarksUIHTMLSource(Profile* profile) { IDR_MD_BOOKMARKS_DIALOG_FOCUS_MANAGER_HTML); source->AddResourcePath("dialog_focus_manager.js", IDR_MD_BOOKMARKS_DIALOG_FOCUS_MANAGER_JS); - source->AddResourcePath("dnd_chip.html", IDR_MD_BOOKMARKS_DND_CHIP_HTML); - source->AddResourcePath("dnd_chip.js", IDR_MD_BOOKMARKS_DND_CHIP_JS); source->AddResourcePath("dnd_manager.html", IDR_MD_BOOKMARKS_DND_MANAGER_HTML); source->AddResourcePath("dnd_manager.js", IDR_MD_BOOKMARKS_DND_MANAGER_JS); diff --git a/chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc b/chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc index 7d7ddfca942..a8f734942e6 100644 --- a/chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc +++ b/chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc @@ -119,7 +119,7 @@ void DownloadsListTracker::StartAndSendChunk() { CHECK_LE(sent_to_page_, sorted_items_.size()); - SortedSet::iterator it = sorted_items_.begin(); + auto it = sorted_items_.begin(); std::advance(it, sent_to_page_); base::ListValue list; @@ -330,7 +330,7 @@ const DownloadItem* DownloadsListTracker::GetItemForTesting(size_t index) if (index >= sorted_items_.size()) return nullptr; - SortedSet::iterator it = sorted_items_.begin(); + auto it = sorted_items_.begin(); std::advance(it, index); return *it; } diff --git a/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc b/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc index e67023efae2..a231a3f9753 100644 --- a/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc +++ b/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <functional> +#include <memory> #include "base/bind.h" #include "base/bind_helpers.h" @@ -39,7 +40,6 @@ #include "content/public/browser/download_manager.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" -#include "content/public/browser/storage_partition.h" #include "content/public/browser/url_data_source.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" @@ -80,9 +80,9 @@ MdDownloadsDOMHandler::MdDownloadsDOMHandler( content::DownloadManager* download_manager, content::WebUI* web_ui) : list_tracker_(download_manager, web_ui) { // Create our fileicon data source. - Profile* profile = - Profile::FromBrowserContext(download_manager->GetBrowserContext()); - content::URLDataSource::Add(profile, new FileIconSource()); + content::URLDataSource::Add( + Profile::FromBrowserContext(download_manager->GetBrowserContext()), + std::make_unique<FileIconSource>()); CheckForRemovedFiles(); } @@ -460,11 +460,6 @@ void MdDownloadsDOMHandler::RetryDownload(const base::ListValue* args) { content::RenderFrameHost* render_frame_host = web_contents->GetMainFrame(); const GURL url = file->GetURL(); - content::StoragePartition* storage_partition = - content::BrowserContext::GetStoragePartition( - web_contents->GetBrowserContext(), - render_frame_host->GetSiteInstance()); - net::NetworkTrafficAnnotationTag traffic_annotation = net::DefineNetworkTrafficAnnotation("md_downloads_dom_handler", R"( semantics { @@ -488,8 +483,7 @@ void MdDownloadsDOMHandler::RetryDownload(const base::ListValue* args) { auto dl_params = std::make_unique<download::DownloadUrlParameters>( url, render_frame_host->GetProcess()->GetID(), render_frame_host->GetRenderViewHost()->GetRoutingID(), - render_frame_host->GetRoutingID(), - storage_partition->GetURLRequestContext(), traffic_annotation); + render_frame_host->GetRoutingID(), traffic_annotation); dl_params->set_content_initiated(true); dl_params->set_initiator(url::Origin::Create(GURL("chrome://downloads"))); dl_params->set_download_source(download::DownloadSource::FROM_RENDERER); diff --git a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc index 16bf36021df..4a8a58c2d0c 100644 --- a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc +++ b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc @@ -77,7 +77,8 @@ class MediaEngagementScoreDetailsProviderImpl base::FeatureList::IsEnabled( media::kMediaEngagementBypassAutoplayPolicies), base::FeatureList::IsEnabled(media::kPreloadMediaEngagementData), - base::FeatureList::IsEnabled(media::kAutoplaySoundSettings), + base::FeatureList::IsEnabled(media::kAutoplayDisableSettings), + base::FeatureList::IsEnabled(media::kAutoplayWhitelistSettings), GetBlockAutoplayPref(), base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kAutoplayPolicy), 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 bea416db65b..cf1891051ff 100644 --- a/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc +++ b/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc @@ -259,9 +259,7 @@ void WebRtcLogsDOMHandler::UpdateUIWithTextLogs( std::vector<UploadList::UploadInfo> uploads; text_log_upload_list_->GetUploads(50, &uploads); - for (std::vector<UploadList::UploadInfo>::iterator i = uploads.begin(); - i != uploads.end(); - ++i) { + for (auto i = uploads.begin(); i != uploads.end(); ++i) { std::unique_ptr<base::DictionaryValue> upload(new base::DictionaryValue()); upload->SetString("id", i->upload_id); diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc index 4aba966ad9f..5c6001c2537 100644 --- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc +++ b/chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc @@ -20,6 +20,7 @@ #include "chrome/browser/media/router/media_router_factory.h" #include "chrome/browser/media/router/media_router_metrics.h" #include "chrome/browser/media/router/media_sinks_observer.h" +#include "chrome/browser/media/router/providers/wired_display/wired_display_media_route_provider.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/browser_finder.h" @@ -52,14 +53,10 @@ #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/display/display.h" #include "ui/web_dialogs/web_dialog_delegate.h" #include "url/origin.h" -#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) -#include "chrome/browser/media/router/providers/wired_display/wired_display_media_route_provider.h" -#include "ui/display/display.h" -#endif - namespace media_router { MediaRouterUI::MediaRouterUI(content::WebUI* web_ui) @@ -326,6 +323,11 @@ void MediaRouterUI::OnRouteResponseReceived( SendIssueForRouteTimeout(cast_mode, presentation_request_source_name); } +void MediaRouterUI::HandleCreateSessionRequestRouteResponse( + const RouteRequestResult&) { + Close(); +} + void MediaRouterUI::OnSearchSinkResponseReceived( MediaCastMode cast_mode, const MediaSink::Id& found_sink_id) { diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui.h b/chromium/chrome/browser/ui/webui/media_router/media_router_ui.h index bc1b0bbf1e1..acf5fe70e64 100644 --- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui.h +++ b/chromium/chrome/browser/ui/webui/media_router/media_router_ui.h @@ -27,8 +27,8 @@ class MediaRouterUI : public MediaRouterUIBase, public ConstrainedWebDialogUI { explicit MediaRouterUI(content::WebUI* web_ui); ~MediaRouterUI() override; - // MediaRouterUIBase: - void Close() override; + // Closes the media router UI. + void Close(); // Notifies this instance that the UI has been initialized. virtual void OnUIInitialized(); @@ -160,6 +160,9 @@ class MediaRouterUI : public MediaRouterUIBase, public ConstrainedWebDialogUI { const base::string16& presentation_request_source_name, const RouteRequestResult& result) override; + void HandleCreateSessionRequestRouteResponse( + const RouteRequestResult&) override; + // Callback passed to MediaRouter to receive the sink ID of the sink found by // SearchSinksAndCreateRoute(). void OnSearchSinkResponseReceived(MediaCastMode cast_mode, diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc index 6847cd75354..4db9b29b5ef 100644 --- a/chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc +++ b/chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc @@ -11,12 +11,14 @@ #include "base/test/scoped_feature_list.h" #include "build/build_config.h" #include "chrome/browser/media/router/media_router_factory.h" +#include "chrome/browser/media/router/providers/wired_display/wired_display_media_route_provider.h" #include "chrome/browser/media/router/test/media_router_mojo_test.h" #include "chrome/browser/media/router/test/mock_media_router.h" #include "chrome/browser/media/router/test/test_helper.h" #include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/ui/media_router/media_router_ui_helper.h" #include "chrome/browser/ui/webui/media_router/media_router_webui_message_handler.h" +#include "chrome/browser/ui/webui/media_router/web_contents_display_observer.h" #include "chrome/common/media_router/media_route.h" #include "chrome/common/media_router/media_source_helper.h" #include "chrome/common/media_router/mojo/media_router.mojom.h" @@ -33,12 +35,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h" - -#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) -#include "chrome/browser/media/router/providers/wired_display/wired_display_media_route_provider.h" -#include "chrome/browser/ui/webui/media_router/web_contents_display_observer.h" #include "ui/display/display.h" -#endif using content::WebContents; using testing::_; @@ -82,7 +79,6 @@ class MockMediaRouterFileDialog : public MediaRouterFileDialog { MOCK_METHOD1(OpenFileDialog, void(Browser* browser)); }; -#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) class TestWebContentsDisplayObserver : public WebContentsDisplayObserver { public: explicit TestWebContentsDisplayObserver(const display::Display& display) @@ -98,7 +94,6 @@ class TestWebContentsDisplayObserver : public WebContentsDisplayObserver { private: display::Display display_; }; -#endif // !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) class PresentationRequestCallbacks { public: @@ -801,7 +796,6 @@ TEST_F(MediaRouterUITest, SetsForcedCastModeWithPresentationURLs) { media_router_ui_.reset(); } -#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) // A wired display sink should not be on the sinks list when the dialog is on // that display, to prevent showing a fullscreen presentation window over the // controlling window. @@ -862,6 +856,5 @@ TEST_F(MediaRouterUITest, UpdateSinksWhenDialogMovesToAnotherDisplay) { display_observer->set_display(display2); media_router_ui_->UpdateSinks(); } -#endif // !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER) } // namespace media_router 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 b15b9927ece..a9af36aab49 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 @@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/media_router/media_router_web_ui_test.h" +#include "base/bind.h" #include "chrome/browser/media/router/media_router_factory.h" #include "chrome/browser/media/router/test/mock_media_router.h" #include "chrome/browser/ui/media_router/media_router_ui_service.h" @@ -49,13 +50,13 @@ MediaRouterWebUITest::~MediaRouterWebUITest() {} TestingProfile::TestingFactories MediaRouterWebUITest::GetTestingFactories() { TestingProfile::TestingFactories factories = { {media_router::MediaRouterFactory::GetInstance(), - &media_router::MockMediaRouter::Create}}; + base::BindRepeating(&media_router::MockMediaRouter::Create)}}; if (require_mock_ui_service_) { factories.emplace_back( media_router::MediaRouterUIServiceFactory::GetInstance(), - BuildMockMediaRouterUIService); + base::BindRepeating(&BuildMockMediaRouterUIService)); factories.emplace_back(ToolbarActionsModelFactory::GetInstance(), - BuildToolbarActionsModel); + base::BindRepeating(&BuildToolbarActionsModel)); } return factories; 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 c3e43a9ef84..3f8d6b069df 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 @@ -1080,7 +1080,8 @@ void MediaRouterWebUIMessageHandler::MaybeUpdateFirstRunFlowData() { // being shown the cloud services option, and is now logged in with sync // enabled, turn on cloud services. if (first_run_flow_acknowledged && - ProfileSyncServiceFactory::GetForProfile(profile)->IsSyncActive()) { + ProfileSyncServiceFactory::GetForProfile(profile) + ->IsSyncFeatureActive()) { pref_service->SetBoolean(::prefs::kMediaRouterEnableCloudServices, true); pref_service->SetBoolean(::prefs::kMediaRouterCloudServicesPrefSet, diff --git a/chromium/chrome/browser/ui/webui/memory_internals_ui.cc b/chromium/chrome/browser/ui/webui/memory_internals_ui.cc index 17636bd8c31..a6ba9903433 100644 --- a/chromium/chrome/browser/ui/webui/memory_internals_ui.cc +++ b/chromium/chrome/browser/ui/webui/memory_internals_ui.cc @@ -17,6 +17,7 @@ #include "base/process/process_handle.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/task/post_task.h" #include "build/build_config.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiling_host/profiling_process_host.h" @@ -28,6 +29,7 @@ #include "components/heap_profiling/supervisor.h" #include "components/services/heap_profiling/public/cpp/settings.h" #include "content/public/browser/browser_child_process_host_iterator.h" +#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_data.h" #include "content/public/browser/render_process_host.h" @@ -204,8 +206,8 @@ void MemoryInternalsDOMHandler::HandleRequestProcessList( const base::ListValue* args) { // This is called on the UI thread, the child process iterator must run on // the IO thread, while the render process iterator must run on the UI thread. - content::BrowserThread::PostTask( - content::BrowserThread::IO, FROM_HERE, + base::PostTaskWithTraits( + FROM_HERE, {content::BrowserThread::IO}, base::Bind(&MemoryInternalsDOMHandler::GetChildProcessesOnIOThread, weak_factory_.GetWeakPtr())); } @@ -291,8 +293,8 @@ void MemoryInternalsDOMHandler::GetChildProcessesOnIOThread( } } - content::BrowserThread::PostTask( - content::BrowserThread::UI, FROM_HERE, + base::PostTaskWithTraits( + FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&MemoryInternalsDOMHandler::GetProfiledPids, dom_handler, std::move(result))); } @@ -305,8 +307,8 @@ void MemoryInternalsDOMHandler::GetProfiledPids( // The supervisor hasn't started, so return an empty list. if (!supervisor->HasStarted()) { - content::BrowserThread::PostTask( - content::BrowserThread::UI, FROM_HERE, + base::PostTaskWithTraits( + FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&MemoryInternalsDOMHandler::ReturnProcessListOnUIThread, weak_factory_.GetWeakPtr(), std::move(children), std::vector<base::ProcessId>())); diff --git a/chromium/chrome/browser/ui/webui/net_export_ui.cc b/chromium/chrome/browser/ui/webui/net_export_ui.cc index 0aac4e4a1bc..38c8ac0ed0e 100644 --- a/chromium/chrome/browser/ui/webui/net_export_ui.cc +++ b/chromium/chrome/browser/ui/webui/net_export_ui.cc @@ -4,13 +4,17 @@ #include "chrome/browser/ui/webui/net_export_ui.h" +#include <stdint.h> + #include <memory> #include <string> #include <vector> #include "base/bind.h" +#include "base/command_line.h" #include "base/lazy_instance.h" #include "base/macros.h" +#include "base/memory/ref_counted.h" #include "base/scoped_observer.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" @@ -20,13 +24,13 @@ #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/net/net_export_helper.h" +#include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/chrome_select_file_policy.h" #include "chrome/common/channel_info.h" #include "chrome/common/url_constants.h" #include "components/grit/components_resources.h" -#include "components/net_log/chrome_net_log.h" #include "components/net_log/net_export_file_writer.h" #include "components/net_log/net_export_ui_constants.h" #include "content/public/browser/browser_thread.h" @@ -38,7 +42,6 @@ #include "content/public/browser/web_ui_message_handler.h" #include "extensions/buildflags/buildflags.h" #include "net/log/net_log_capture_mode.h" -#include "net/url_request/url_request_context_getter.h" #include "ui/shell_dialogs/select_file_dialog.h" #if defined(OS_ANDROID) @@ -106,9 +109,6 @@ class NetExportMessageHandler void OnNewState(const base::DictionaryValue& state) override; private: - using URLRequestContextGetterList = - std::vector<scoped_refptr<net::URLRequestContextGetter>>; - // Send NetLog data via email. static void SendEmail(const base::FilePath& file_to_send); @@ -137,8 +137,7 @@ class NetExportMessageHandler // NetLog file. void ShowSelectFileDialog(const base::FilePath& default_path); - // Cache of g_browser_process->net_log()->net_export_file_writer(). This - // is owned by ChromeNetLog which is owned by BrowserProcessImpl. + // Cached pointer to SystemNetworkContextManager's NetExportFileWriter. net_log::NetExportFileWriter* file_writer_; ScopedObserver<net_log::NetExportFileWriter, @@ -160,7 +159,8 @@ class NetExportMessageHandler }; NetExportMessageHandler::NetExportMessageHandler() - : file_writer_(g_browser_process->net_log()->net_export_file_writer()), + : file_writer_(g_browser_process->system_network_context_manager() + ->GetNetExportFileWriter()), state_observer_manager_(this), weak_ptr_factory_(this) { file_writer_->Initialize(); 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 76652731b92..43a9238a240 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 @@ -4,74 +4,34 @@ #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" -#include <stddef.h> - -#include <algorithm> #include <memory> #include <string> #include <utility> -#include <vector> -#include "base/base64.h" #include "base/bind.h" -#include "base/bind_helpers.h" #include "base/command_line.h" -#include "base/files/file.h" #include "base/files/file_path.h" -#include "base/files/file_util.h" -#include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/sequenced_task_runner_helpers.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_piece.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "base/strings/utf_string_conversions.h" +#include "base/task/post_task.h" #include "base/values.h" -#include "build/build_config.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/browsing_data/browsing_data_helper.h" -#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" -#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/download/download_prefs.h" -#include "chrome/browser/io_thread.h" -#include "chrome/browser/net/chrome_network_delegate.h" #include "chrome/browser/net/net_export_helper.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/common/channel_info.h" -#include "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" +#include "chrome/common/webui_url_constants.h" #include "chrome/grit/net_internals_resources.h" -#include "components/net_log/chrome_net_log.h" #include "components/onc/onc_constants.h" #include "components/prefs/pref_member.h" -#include "components/url_formatter/url_fixer.h" -#include "components/version_info/version_info.h" +#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/browsing_data_remover.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_message_handler.h" -#include "net/base/net_errors.h" -#include "net/disk_cache/disk_cache.h" -#include "net/dns/host_cache.h" -#include "net/dns/host_resolver.h" -#include "net/http/http_cache.h" -#include "net/http/http_network_layer.h" -#include "net/http/http_network_session.h" -#include "net/http/http_stream_factory.h" -#include "net/http/transport_security_state.h" -#include "net/log/net_log.h" -#include "net/log/net_log_capture_mode.h" -#include "net/log/net_log_entry.h" #include "net/log/net_log_util.h" -#include "net/proxy_resolution/proxy_resolution_service.h" -#include "net/url_request/url_request_context.h" -#include "net/url_request/url_request_context_getter.h" #include "services/network/expect_ct_reporter.h" #if defined(OS_CHROMEOS) @@ -86,68 +46,10 @@ #include "chromeos/network/onc/onc_utils.h" #endif -using base::Value; using content::BrowserThread; -using content::WebContents; -using content::WebUIMessageHandler; namespace { -// Delay between when an event occurs and when it is passed to the Javascript -// page. All events that occur during this period are grouped together and -// sent to the page at once, which reduces context switching and CPU usage. -const int kNetLogEventDelayMilliseconds = 100; - -// A Base-64 encoded DER certificate for use in test Expect-CT reports. The -// contents of the certificate don't matter. -const char kTestReportCert[] = - "MIIDvzCCAqegAwIBAgIBAzANBgkqhkiG9w0BAQsFADBjMQswCQYDVQQGEwJVUzET" - "MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G" - "A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTE3MDYwNTE3" - "MTA0NloXDTI3MDYwMzE3MTA0NlowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh" - "bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg" - "Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC" - "AQoCggEBALS/0pcz5RNbd2W9cxp1KJtHWea3MOhGM21YW9ofCv/k5C3yHfiJ6GQu" - "9sPN16OO1/fN59gOEMPnVtL85ebTTuL/gk0YY4ewo97a7wo3e6y1t0PO8gc53xTp" - "w6RBPn5oRzSbe2HEGOYTzrO0puC6A+7k6+eq9G2+l1uqBpdQAdB4uNaSsOTiuUOI" - "ta4UZH1ScNQFHAkl1eJPyaiC20Exw75EbwvU/b/B7tlivzuPtQDI0d9dShOtceRL" - "X9HZckyD2JNAv2zNL2YOBNa5QygkySX9WXD+PfKpCk7Cm8TenldeXRYl5ni2REkp" - "nfa/dPuF1g3xZVjyK9aPEEnIAC2I4i0CAwEAAaOBgDB+MAwGA1UdEwEB/wQCMAAw" - "HQYDVR0OBBYEFODc4C8HiHQ6n9Mwo3GK+dal5aZTMB8GA1UdIwQYMBaAFJsmC4qY" - "qbsduR8c4xpAM+2OF4irMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAP" - "BgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQB6FEQuUDRcC5jkX3aZ" - "uuTeZEqMVL7JXgvgFqzXsPb8zIdmxr/tEDfwXx2qDf2Dpxts7Fq4vqUwimK4qV3K" - "7heLnWV2+FBvV1eeSfZ7AQj+SURkdlyo42r41+t13QUf+Z0ftR9266LSWLKrukeI" - "Mxk73hOkm/u8enhTd00dy/FN9dOFBFHseVMspWNxIkdRILgOmiyfQNRgxNYdOf0e" - "EfELR8Hn6WjZ8wAbvO4p7RTrzu1c/RZ0M+NLkID56Brbl70GC2h5681LPwAOaZ7/" - "mWQ5kekSyJjmLfF12b+h9RVAt5MrXZgk2vNujssgGf4nbWh4KZyQ6qrs778ZdDLm" - "yfUn"; - -// Returns the HostCache for |context|'s primary HostResolver, or NULL if -// there is none. -net::HostCache* GetHostResolverCache(net::URLRequestContext* context) { - return context->host_resolver()->GetHostCache(); -} - -std::string HashesToBase64String(const net::HashValueVector& hashes) { - std::string str; - for (size_t i = 0; i != hashes.size(); ++i) { - if (i != 0) - str += ","; - str += hashes[i].ToString(); - } - return str; -} - -// Returns the http network session for |context| if there is one. -// Otherwise, returns NULL. -net::HttpNetworkSession* GetHttpNetworkSession( - net::URLRequestContext* context) { - if (!context->http_transaction_factory()) - return nullptr; - return context->http_transaction_factory()->GetSession(); -} - content::WebUIDataSource* CreateNetInternalsHTMLSource() { content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUINetInternalsHost); @@ -161,47 +63,30 @@ content::WebUIDataSource* CreateNetInternalsHTMLSource() { return source; } +void IgnoreBoolCallback(bool result) {} + // This class receives javascript messages from the renderer. // Note that the WebUI infrastructure runs on the UI thread, therefore all of // this class's methods are expected to run on the UI thread. -// -// Since the network code we want to run lives on the IO thread, we proxy -// almost everything over to NetInternalsMessageHandler::IOThreadImpl, which -// runs on the IO thread. -// -// TODO(eroman): Can we start on the IO thread to begin with? class NetInternalsMessageHandler - : public WebUIMessageHandler, + : public content::WebUIMessageHandler, public base::SupportsWeakPtr<NetInternalsMessageHandler> { public: - NetInternalsMessageHandler(); - ~NetInternalsMessageHandler() override; + explicit NetInternalsMessageHandler(content::WebUI* web_ui); + ~NetInternalsMessageHandler() override = default; - // WebUIMessageHandler implementation. + protected: + // WebUIMessageHandler implementation: void RegisterMessages() override; + private: + network::mojom::NetworkContext* GetNetworkContext() const; + // Calls g_browser.receive in the renderer, passing in |command| and |arg|. // If the renderer is displaying a log file, the message will be ignored. - void SendJavascriptCommand(const std::string& command, - std::unique_ptr<base::Value> arg); + void SendJavascriptCommand(const std::string& command, base::Value arg); - // Javascript message handlers. - void OnRendererReady(const base::ListValue* list); - void OnClearBrowserCache(const base::ListValue* list); - void OnGetPrerenderInfo(const base::ListValue* list); - void OnGetHistoricNetworkStats(const base::ListValue* list); - void OnGetSessionNetworkStats(const base::ListValue* list); - void OnGetExtensionInfo(const base::ListValue* list); - void OnGetDataReductionProxyInfo(const base::ListValue* list); #if defined(OS_CHROMEOS) - void OnImportONCFile(const base::ListValue* list); - void OnStoreDebugLogs(const base::ListValue* list); - void OnStoreDebugLogsCompleted(const base::FilePath& log_path, - bool succeeded); - void OnSetNetworkDebugMode(const base::ListValue* list); - void OnSetNetworkDebugModeCompleted(const std::string& subsystem, - bool succeeded); - // Callback to |GetNSSCertDatabaseForProfile| used to retrieve the database // to which user's ONC defined certificates should be imported. // It parses and imports |onc_blob|. @@ -215,63 +100,12 @@ class NetInternalsMessageHandler bool cert_import_success); #endif - private: - class IOThreadImpl; - - // This is the "real" message handler, which lives on the IO thread. - scoped_refptr<IOThreadImpl> proxy_; - - DISALLOW_COPY_AND_ASSIGN(NetInternalsMessageHandler); -}; - -// This class is the "real" message handler. It is allocated and destroyed on -// the UI thread. With the exception of OnAddEntry, OnWebUIDeleted, and -// SendJavascriptCommand, its methods are all expected to be called from the IO -// thread. OnAddEntry and SendJavascriptCommand can be called from any thread, -// and OnWebUIDeleted can only be called from the UI thread. -class NetInternalsMessageHandler::IOThreadImpl - : public base::RefCountedThreadSafe< - NetInternalsMessageHandler::IOThreadImpl, - BrowserThread::DeleteOnUIThread>, - public net::NetLog::ThreadSafeObserver { - public: - // Type for methods that can be used as MessageHandler callbacks. - typedef void (IOThreadImpl::*MessageHandler)(const base::ListValue*); - - // Creates a proxy for |handler| that will live on the IO thread. - // |handler| is a weak pointer, since it is possible for the - // WebUIMessageHandler to be deleted on the UI thread while we were executing - // on the IO thread. |io_thread| is the global IOThread (it is passed in as - // an argument since we need to grab it from the UI thread). - IOThreadImpl( - const base::WeakPtr<NetInternalsMessageHandler>& handler, - IOThread* io_thread, - net::URLRequestContextGetter* main_context_getter); - - // Called on UI thread just after creation, to add a ContextGetter to - // |context_getters_|. - void AddRequestContextGetter(net::URLRequestContextGetter* context_getter); - - // Helper method to enable a callback that will be executed on the IO thread. - static void CallbackHelper(MessageHandler method, - scoped_refptr<IOThreadImpl> io_thread, - const base::ListValue* list); - - // Called once the WebUI has been deleted (i.e. renderer went away), on the - // IO thread. - void Detach(); - - // Called when the WebUI is deleted. Prevents calling Javascript functions - // afterwards. Called on UI thread. - void OnWebUIDeleted(); + void OnExpectCTTestReportCallback(bool success); //-------------------------------- // Javascript message handlers: //-------------------------------- - void OnRendererReady(const base::ListValue* list); - - void OnGetNetInfo(const base::ListValue* list); void OnReloadProxySettings(const base::ListValue* list); void OnClearBadProxies(const base::ListValue* list); void OnClearHostResolverCache(const base::ListValue* list); @@ -283,203 +117,70 @@ class NetInternalsMessageHandler::IOThreadImpl void OnExpectCTTestReport(const base::ListValue* list); void OnCloseIdleSockets(const base::ListValue* list); void OnFlushSocketPools(const base::ListValue* list); -#if defined(OS_WIN) - void OnGetServiceProviders(const base::ListValue* list); +#if defined(OS_CHROMEOS) + void OnImportONCFile(const base::ListValue* list); + void OnStoreDebugLogs(const base::ListValue* list); + void OnStoreDebugLogsCompleted(const base::FilePath& log_path, + bool succeeded); + void OnSetNetworkDebugMode(const base::ListValue* list); + void OnSetNetworkDebugModeCompleted(const std::string& subsystem, + bool succeeded); #endif - void OnSetCaptureMode(const base::ListValue* list); - - // NetLog::ThreadSafeObserver implementation: - void OnAddEntry(const net::NetLogEntry& entry) override; - - // Helper that calls g_browser.receive in the renderer, passing in |command| - // and |arg|. If the renderer is displaying a log file, the message will be - // ignored. Note that this can be called from any thread. - void SendJavascriptCommand(const std::string& command, - std::unique_ptr<base::Value> arg); - - private: - friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; - friend class base::DeleteHelper<IOThreadImpl>; - - using ContextGetterList = - std::vector<scoped_refptr<net::URLRequestContextGetter>>; - - ~IOThreadImpl() override; - - // Adds |entry| to the queue of pending log entries to be sent to the page via - // Javascript. Must be called on the IO Thread. Also creates a delayed task - // that will call PostPendingEntries, if there isn't one already. - void AddEntryToQueue(std::unique_ptr<base::Value> entry); - - // Sends all pending entries to the page via Javascript, and clears the list - // of pending entries. Sending multiple entries at once results in a - // significant reduction of CPU usage when a lot of events are happening. - // Must be called on the IO Thread. - void PostPendingEntries(); - - // Adds entries with the states of ongoing URL requests. - void PrePopulateEventList(); - - net::URLRequestContext* GetMainContext() { - return main_context_getter_->GetURLRequestContext(); - } - - // |info_sources| is an or'd together list of the net::NetInfoSources to - // send information about. Information is sent to Javascript in the form of - // a single dictionary with information about all requests sources. - void SendNetInfo(int info_sources); - - // Pointer to the UI-thread message handler. Only access this from - // the UI thread. - base::WeakPtr<NetInternalsMessageHandler> handler_; - - // The global IOThread, which contains the global NetLog to observer. - IOThread* io_thread_; - // The main URLRequestContextGetter for the tab's profile. - scoped_refptr<net::URLRequestContextGetter> main_context_getter_; + const content::WebUI* web_ui_; - // True if the Web UI has been deleted. This is used to prevent calling - // Javascript functions after the Web UI is destroyed. On refresh, the - // messages can end up being sent to the refreshed page, causing duplicate - // or partial entries. - // - // This is only read and written to on the UI thread. - bool was_webui_deleted_; - - // Log entries that have yet to be passed along to Javascript page. Non-NULL - // when and only when there is a pending delayed task to call - // PostPendingEntries. Read and written to exclusively on the IO Thread. - std::unique_ptr<base::ListValue> pending_entries_; - - // Used for getting current status of URLRequests when net-internals is - // opened. |main_context_getter_| is automatically added on construction. - // Duplicates are allowed. - ContextGetterList context_getters_; - - // Used to send test Expect-CT reports. Lazily initialized when the first - // Expect-CT test report is sent. This is a member variable rather than a - // local variable so that it lives long enough to receive the result of - // sending a report, which is delivered to the JavaScript via a JavaScript - // command. - std::unique_ptr<network::ExpectCTReporter> expect_ct_reporter_; - - DISALLOW_COPY_AND_ASSIGN(IOThreadImpl); + DISALLOW_COPY_AND_ASSIGN(NetInternalsMessageHandler); }; -//////////////////////////////////////////////////////////////////////////////// -// -// NetInternalsMessageHandler -// -//////////////////////////////////////////////////////////////////////////////// - -NetInternalsMessageHandler::NetInternalsMessageHandler() {} - -NetInternalsMessageHandler::~NetInternalsMessageHandler() { - if (proxy_) { - proxy_->OnWebUIDeleted(); - // Notify the handler on the IO thread that the renderer is gone. - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::BindOnce(&IOThreadImpl::Detach, proxy_)); - } -} +NetInternalsMessageHandler::NetInternalsMessageHandler(content::WebUI* web_ui) + : web_ui_(web_ui) {} void NetInternalsMessageHandler::RegisterMessages() { DCHECK_CURRENTLY_ON(BrowserThread::UI); - Profile* profile = Profile::FromWebUI(web_ui()); - - proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), - profile->GetRequestContext()); - proxy_->AddRequestContextGetter( - content::BrowserContext::GetDefaultStoragePartition(profile)-> - GetMediaURLRequestContext()); - - web_ui()->RegisterMessageCallback( - "notifyReady", - base::BindRepeating(&NetInternalsMessageHandler::OnRendererReady, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getNetInfo", base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnGetNetInfo, proxy_)); web_ui()->RegisterMessageCallback( "reloadProxySettings", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnReloadProxySettings, proxy_)); + base::BindRepeating(&NetInternalsMessageHandler::OnReloadProxySettings, + base::Unretained(this))); web_ui()->RegisterMessageCallback( "clearBadProxies", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnClearBadProxies, proxy_)); + base::BindRepeating(&NetInternalsMessageHandler::OnClearBadProxies, + base::Unretained(this))); web_ui()->RegisterMessageCallback( "clearHostResolverCache", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnClearHostResolverCache, proxy_)); + base::BindRepeating(&NetInternalsMessageHandler::OnClearHostResolverCache, + base::Unretained(this))); web_ui()->RegisterMessageCallback( "domainSecurityPolicyDelete", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnDomainSecurityPolicyDelete, proxy_)); + base::BindRepeating( + &NetInternalsMessageHandler::OnDomainSecurityPolicyDelete, + base::Unretained(this))); web_ui()->RegisterMessageCallback( - "hstsQuery", base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnHSTSQuery, proxy_)); + "hstsQuery", base::BindRepeating(&NetInternalsMessageHandler::OnHSTSQuery, + base::Unretained(this))); web_ui()->RegisterMessageCallback( - "hstsAdd", base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnHSTSAdd, proxy_)); + "hstsAdd", base::BindRepeating(&NetInternalsMessageHandler::OnHSTSAdd, + base::Unretained(this))); web_ui()->RegisterMessageCallback( "expectCTQuery", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnExpectCTQuery, proxy_)); - web_ui()->RegisterMessageCallback( - "expectCTAdd", base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnExpectCTAdd, proxy_)); - web_ui()->RegisterMessageCallback( - "expectCTTestReport", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnExpectCTTestReport, proxy_)); - web_ui()->RegisterMessageCallback( - "closeIdleSockets", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnCloseIdleSockets, proxy_)); - web_ui()->RegisterMessageCallback( - "flushSocketPools", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnFlushSocketPools, proxy_)); -#if defined(OS_WIN) - web_ui()->RegisterMessageCallback( - "getServiceProviders", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnGetServiceProviders, proxy_)); -#endif - - web_ui()->RegisterMessageCallback( - "setCaptureMode", - base::BindRepeating(&IOThreadImpl::CallbackHelper, - &IOThreadImpl::OnSetCaptureMode, proxy_)); - web_ui()->RegisterMessageCallback( - "clearBrowserCache", - base::BindRepeating(&NetInternalsMessageHandler::OnClearBrowserCache, + base::BindRepeating(&NetInternalsMessageHandler::OnExpectCTQuery, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "getPrerenderInfo", - base::BindRepeating(&NetInternalsMessageHandler::OnGetPrerenderInfo, + "expectCTAdd", + base::BindRepeating(&NetInternalsMessageHandler::OnExpectCTAdd, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "getHistoricNetworkStats", - base::BindRepeating( - &NetInternalsMessageHandler::OnGetHistoricNetworkStats, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "getSessionNetworkStats", - base::BindRepeating(&NetInternalsMessageHandler::OnGetSessionNetworkStats, + "expectCTTestReport", + base::BindRepeating(&NetInternalsMessageHandler::OnExpectCTTestReport, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "getExtensionInfo", - base::BindRepeating(&NetInternalsMessageHandler::OnGetExtensionInfo, + "closeIdleSockets", + base::BindRepeating(&NetInternalsMessageHandler::OnCloseIdleSockets, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "getDataReductionProxyInfo", - base::BindRepeating( - &NetInternalsMessageHandler::OnGetDataReductionProxyInfo, - base::Unretained(this))); + "flushSocketPools", + base::BindRepeating(&NetInternalsMessageHandler::OnFlushSocketPools, + base::Unretained(this))); #if defined(OS_CHROMEOS) web_ui()->RegisterMessageCallback( "importONCFile", @@ -498,194 +199,29 @@ void NetInternalsMessageHandler::RegisterMessages() { void NetInternalsMessageHandler::SendJavascriptCommand( const std::string& command, - std::unique_ptr<base::Value> arg) { + base::Value arg) { std::unique_ptr<base::Value> command_value(new base::Value(command)); DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (arg) { - web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", - *command_value.get(), *arg.get()); - } else { - web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", - *command_value.get()); - } -} - -void NetInternalsMessageHandler::OnRendererReady(const base::ListValue* list) { - IOThreadImpl::CallbackHelper(&IOThreadImpl::OnRendererReady, proxy_, list); -} - -void NetInternalsMessageHandler::OnClearBrowserCache( - const base::ListValue* list) { - content::BrowsingDataRemover* remover = - Profile::GetBrowsingDataRemover(Profile::FromWebUI(web_ui())); - remover->Remove(base::Time(), base::Time::Max(), - content::BrowsingDataRemover::DATA_TYPE_CACHE, - content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB); - // BrowsingDataRemover deletes itself. -} - -void NetInternalsMessageHandler::OnGetPrerenderInfo( - const base::ListValue* list) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - SendJavascriptCommand( - "receivedPrerenderInfo", - chrome_browser_net::GetPrerenderInfo(Profile::FromWebUI(web_ui()))); -} - -void NetInternalsMessageHandler::OnGetHistoricNetworkStats( - const base::ListValue* list) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - SendJavascriptCommand("receivedHistoricNetworkStats", - chrome_browser_net::GetHistoricNetworkStats( - Profile::FromWebUI(web_ui()))); -} - -void NetInternalsMessageHandler::OnGetSessionNetworkStats( - const base::ListValue* list) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - SendJavascriptCommand( - "receivedSessionNetworkStats", - chrome_browser_net::GetSessionNetworkStats(Profile::FromWebUI(web_ui()))); -} - -void NetInternalsMessageHandler::OnGetExtensionInfo( - const base::ListValue* list) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - SendJavascriptCommand( - "receivedExtensionInfo", - chrome_browser_net::GetExtensionInfo(Profile::FromWebUI(web_ui()))); -} - -void NetInternalsMessageHandler::OnGetDataReductionProxyInfo( - const base::ListValue* list) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - SendJavascriptCommand("receivedDataReductionProxyInfo", - chrome_browser_net::GetDataReductionProxyInfo( - Profile::FromWebUI(web_ui()))); -} - -//////////////////////////////////////////////////////////////////////////////// -// -// NetInternalsMessageHandler::IOThreadImpl -// -//////////////////////////////////////////////////////////////////////////////// - -NetInternalsMessageHandler::IOThreadImpl::IOThreadImpl( - const base::WeakPtr<NetInternalsMessageHandler>& handler, - IOThread* io_thread, - net::URLRequestContextGetter* main_context_getter) - : handler_(handler), - io_thread_(io_thread), - main_context_getter_(main_context_getter), - was_webui_deleted_(false) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - AddRequestContextGetter(main_context_getter); -} - -NetInternalsMessageHandler::IOThreadImpl::~IOThreadImpl() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); -} - -void NetInternalsMessageHandler::IOThreadImpl::AddRequestContextGetter( - net::URLRequestContextGetter* context_getter) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - context_getters_.push_back(context_getter); + web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", + *command_value.get(), arg); } -void NetInternalsMessageHandler::IOThreadImpl::CallbackHelper( - MessageHandler method, - scoped_refptr<IOThreadImpl> io_thread, +void NetInternalsMessageHandler::OnReloadProxySettings( const base::ListValue* list) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - // We need to make a copy of the value in order to pass it over to the IO - // thread. |list_copy| will be deleted when the task is destroyed. The called - // |method| cannot take ownership of |list_copy|. - base::ListValue* list_copy = - (list && list->GetSize()) ? list->DeepCopy() : nullptr; - - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::BindOnce(method, io_thread, base::Owned(list_copy))); -} - -void NetInternalsMessageHandler::IOThreadImpl::Detach() { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - // Unregister with network stack to observe events. - if (net_log()) - net_log()->RemoveObserver(this); + GetNetworkContext()->ForceReloadProxyConfig(base::NullCallback()); } -void NetInternalsMessageHandler::IOThreadImpl::OnWebUIDeleted() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - was_webui_deleted_ = true; -} - -void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( +void NetInternalsMessageHandler::OnClearBadProxies( const base::ListValue* list) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - - // If currently watching the NetLog, temporarily stop watching it and flush - // pending events, so they won't appear before the status events created for - // currently active network objects below. - if (net_log()) { - net_log()->RemoveObserver(this); - PostPendingEntries(); - } - - SendJavascriptCommand( - "receivedConstants", - net_log::ChromeNetLog::GetConstants( - base::CommandLine::ForCurrentProcess()->GetCommandLineString(), - chrome::GetChannelName())); - - PrePopulateEventList(); - - // Register with network stack to observe events. - io_thread_->net_log()->AddObserver( - this, net::NetLogCaptureMode::IncludeCookiesAndCredentials()); -} - -void NetInternalsMessageHandler::IOThreadImpl::OnGetNetInfo( - const base::ListValue* list) { - DCHECK(list); - int info_sources; - if (!list->GetInteger(0, &info_sources)) - return; - SendNetInfo(info_sources); -} - -void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( - const base::ListValue* list) { - DCHECK(!list); - GetMainContext()->proxy_resolution_service()->ForceReloadProxyConfig(); - - // Cause the renderer to be notified of the new values. - SendNetInfo(net::NET_INFO_PROXY_SETTINGS); + GetNetworkContext()->ClearBadProxiesCache(base::NullCallback()); } -void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( +void NetInternalsMessageHandler::OnClearHostResolverCache( const base::ListValue* list) { - DCHECK(!list); - GetMainContext()->proxy_resolution_service()->ClearBadProxiesCache(); - - // Cause the renderer to be notified of the new values. - SendNetInfo(net::NET_INFO_BAD_PROXIES); + GetNetworkContext()->ClearHostCache(/*filter=*/nullptr, base::NullCallback()); } -void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( - const base::ListValue* list) { - DCHECK(!list); - net::HostCache* cache = GetHostResolverCache(GetMainContext()); - - if (cache) - cache->clear(); - - // Cause the renderer to be notified of the new values. - SendNetInfo(net::NET_INFO_HOST_RESOLVER); -} - -void NetInternalsMessageHandler::IOThreadImpl::OnDomainSecurityPolicyDelete( +void NetInternalsMessageHandler::OnDomainSecurityPolicyDelete( const base::ListValue* list) { // |list| should be: [<domain to query>]. std::string domain; @@ -695,96 +231,22 @@ void NetInternalsMessageHandler::IOThreadImpl::OnDomainSecurityPolicyDelete( // There cannot be a unicode entry in the HSTS set. return; } - net::TransportSecurityState* transport_security_state = - GetMainContext()->transport_security_state(); - if (!transport_security_state) - return; - - transport_security_state->DeleteDynamicDataForHost(domain); + GetNetworkContext()->DeleteDynamicDataForHost( + domain, base::BindOnce(&IgnoreBoolCallback)); } -void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( - const base::ListValue* list) { +void NetInternalsMessageHandler::OnHSTSQuery(const base::ListValue* list) { // |list| should be: [<domain to query>]. std::string domain; bool get_domain_result = list->GetString(0, &domain); DCHECK(get_domain_result); - auto result = std::make_unique<base::DictionaryValue>(); - - if (base::IsStringASCII(domain)) { - net::TransportSecurityState* transport_security_state = - GetMainContext()->transport_security_state(); - if (transport_security_state) { - net::TransportSecurityState::STSState static_sts_state; - net::TransportSecurityState::PKPState static_pkp_state; - bool found_static = transport_security_state->GetStaticDomainState( - domain, &static_sts_state, &static_pkp_state); - if (found_static) { - result->SetInteger("static_upgrade_mode", - static_cast<int>(static_sts_state.upgrade_mode)); - result->SetBoolean("static_sts_include_subdomains", - static_sts_state.include_subdomains); - result->SetDouble("static_sts_observed", - static_sts_state.last_observed.ToDoubleT()); - result->SetDouble("static_sts_expiry", - static_sts_state.expiry.ToDoubleT()); - result->SetBoolean("static_pkp_include_subdomains", - static_pkp_state.include_subdomains); - result->SetDouble("static_pkp_observed", - static_pkp_state.last_observed.ToDoubleT()); - result->SetDouble("static_pkp_expiry", - static_pkp_state.expiry.ToDoubleT()); - result->SetString("static_spki_hashes", - HashesToBase64String(static_pkp_state.spki_hashes)); - result->SetString("static_sts_domain", static_sts_state.domain); - result->SetString("static_pkp_domain", static_pkp_state.domain); - } - - net::TransportSecurityState::STSState dynamic_sts_state; - net::TransportSecurityState::PKPState dynamic_pkp_state; - bool found_sts_dynamic = transport_security_state->GetDynamicSTSState( - domain, &dynamic_sts_state); - - bool found_pkp_dynamic = transport_security_state->GetDynamicPKPState( - domain, &dynamic_pkp_state); - if (found_sts_dynamic) { - result->SetInteger("dynamic_upgrade_mode", - static_cast<int>(dynamic_sts_state.upgrade_mode)); - result->SetBoolean("dynamic_sts_include_subdomains", - dynamic_sts_state.include_subdomains); - result->SetDouble("dynamic_sts_observed", - dynamic_sts_state.last_observed.ToDoubleT()); - result->SetDouble("dynamic_sts_expiry", - dynamic_sts_state.expiry.ToDoubleT()); - result->SetString("dynamic_sts_domain", dynamic_sts_state.domain); - } - if (found_pkp_dynamic) { - result->SetBoolean("dynamic_pkp_include_subdomains", - dynamic_pkp_state.include_subdomains); - result->SetDouble("dynamic_pkp_observed", - dynamic_pkp_state.last_observed.ToDoubleT()); - result->SetDouble("dynamic_pkp_expiry", - dynamic_pkp_state.expiry.ToDoubleT()); - result->SetString("dynamic_spki_hashes", - HashesToBase64String(dynamic_pkp_state.spki_hashes)); - result->SetString("dynamic_pkp_domain", dynamic_pkp_state.domain); - } - - result->SetBoolean( - "result", found_static || found_sts_dynamic || found_pkp_dynamic); - } else { - result->SetString("error", "no TransportSecurityState active"); - } - } else { - result->SetString("error", "non-ASCII domain name"); - } - - SendJavascriptCommand("receivedHSTSResult", std::move(result)); + GetNetworkContext()->GetHSTSState( + domain, base::BindOnce(&NetInternalsMessageHandler::SendJavascriptCommand, + this->AsWeakPtr(), "receivedHSTSResult")); } -void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( - const base::ListValue* list) { +void NetInternalsMessageHandler::OnHSTSAdd(const base::ListValue* list) { // |list| should be: [<domain to query>, <STS include subdomains>] std::string domain; bool result = list->GetString(0, &domain); @@ -798,57 +260,23 @@ void NetInternalsMessageHandler::IOThreadImpl::OnHSTSAdd( result = list->GetBoolean(1, &sts_include_subdomains); DCHECK(result); - net::TransportSecurityState* transport_security_state = - GetMainContext()->transport_security_state(); - if (!transport_security_state) - return; - base::Time expiry = base::Time::Now() + base::TimeDelta::FromDays(1000); - transport_security_state->AddHSTS(domain, expiry, sts_include_subdomains); + GetNetworkContext()->AddHSTS(domain, expiry, sts_include_subdomains, + base::DoNothing()); } -void NetInternalsMessageHandler::IOThreadImpl::OnExpectCTQuery( - const base::ListValue* list) { +void NetInternalsMessageHandler::OnExpectCTQuery(const base::ListValue* list) { // |list| should be: [<domain to query>]. std::string domain; bool domain_result = list->GetString(0, &domain); DCHECK(domain_result); - auto result = std::make_unique<base::DictionaryValue>(); - if (base::IsStringASCII(domain)) { - net::TransportSecurityState* transport_security_state = - GetMainContext()->transport_security_state(); - if (transport_security_state) { - net::TransportSecurityState::ExpectCTState dynamic_expect_ct_state; - bool found = transport_security_state->GetDynamicExpectCTState( - domain, &dynamic_expect_ct_state); - - // TODO(estark): query static Expect-CT state as well. - if (found) { - result->SetString("dynamic_expect_ct_domain", domain); - result->SetDouble("dynamic_expect_ct_observed", - dynamic_expect_ct_state.last_observed.ToDoubleT()); - result->SetDouble("dynamic_expect_ct_expiry", - dynamic_expect_ct_state.expiry.ToDoubleT()); - result->SetBoolean("dynamic_expect_ct_enforce", - dynamic_expect_ct_state.enforce); - result->SetString("dynamic_expect_ct_report_uri", - dynamic_expect_ct_state.report_uri.spec()); - } - - result->SetBoolean("result", found); - } else { - result->SetString("error", "no Expect-CT state active"); - } - } else { - result->SetString("error", "non-ASCII domain name"); - } - - SendJavascriptCommand("receivedExpectCTResult", std::move(result)); + GetNetworkContext()->GetExpectCTState( + domain, base::BindOnce(&NetInternalsMessageHandler::SendJavascriptCommand, + this->AsWeakPtr(), "receivedExpectCTResult")); } -void NetInternalsMessageHandler::IOThreadImpl::OnExpectCTAdd( - const base::ListValue* list) { +void NetInternalsMessageHandler::OnExpectCTAdd(const base::ListValue* list) { // |list| should be: [<domain to add>, <report URI>, <enforce>]. std::string domain; bool result = list->GetString(0, &domain); @@ -865,17 +293,12 @@ void NetInternalsMessageHandler::IOThreadImpl::OnExpectCTAdd( result = list->GetBoolean(2, &enforce); DCHECK(result); - net::TransportSecurityState* transport_security_state = - GetMainContext()->transport_security_state(); - if (!transport_security_state) - return; - base::Time expiry = base::Time::Now() + base::TimeDelta::FromDays(1000); - transport_security_state->AddExpectCT(domain, expiry, enforce, - GURL(report_uri_str)); + GetNetworkContext()->AddExpectCT(domain, expiry, enforce, + GURL(report_uri_str), base::DoNothing()); } -void NetInternalsMessageHandler::IOThreadImpl::OnExpectCTTestReport( +void NetInternalsMessageHandler::OnExpectCTTestReport( const base::ListValue* list) { // |list| should be: [<report URI>]. std::string report_uri_str; @@ -885,62 +308,27 @@ void NetInternalsMessageHandler::IOThreadImpl::OnExpectCTTestReport( if (!report_uri.is_valid()) return; - std::string decoded_dummy_cert; - DCHECK(base::Base64Decode(kTestReportCert, &decoded_dummy_cert)); - scoped_refptr<net::X509Certificate> dummy_cert = - net::X509Certificate::CreateFromBytes(decoded_dummy_cert.data(), - decoded_dummy_cert.size()); - net::SignedCertificateTimestampAndStatusList dummy_sct_list; - - if (!expect_ct_reporter_) { - std::unique_ptr<base::Value> success = - std::make_unique<base::Value>("success"); - std::unique_ptr<base::Value> failure = - std::make_unique<base::Value>("failure"); - expect_ct_reporter_ = std::make_unique<network::ExpectCTReporter>( - GetMainContext(), - base::Bind( - &NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand, - this, "receivedExpectCTTestReportResult", base::Passed(&success)), - base::Bind( - &NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand, - this, "receivedExpectCTTestReportResult", base::Passed(&failure))); - } - - // Send a test report with dummy data. - expect_ct_reporter_->OnExpectCTFailed( - net::HostPortPair("expect-ct-report.test", 443), report_uri, - base::Time::Now(), dummy_cert.get(), dummy_cert.get(), dummy_sct_list); + GetNetworkContext()->SetExpectCTTestReport( + report_uri, + base::BindOnce(&NetInternalsMessageHandler::OnExpectCTTestReportCallback, + this->AsWeakPtr())); } -void NetInternalsMessageHandler::IOThreadImpl::OnFlushSocketPools( - const base::ListValue* list) { - DCHECK(!list); - net::HttpNetworkSession* http_network_session = - GetHttpNetworkSession(GetMainContext()); - - if (http_network_session) - http_network_session->CloseAllConnections(); +void NetInternalsMessageHandler::OnExpectCTTestReportCallback(bool success) { + SendJavascriptCommand( + "receivedExpectCTTestReportResult", + success ? base::Value("success") : base::Value("failure")); } -void NetInternalsMessageHandler::IOThreadImpl::OnCloseIdleSockets( +void NetInternalsMessageHandler::OnFlushSocketPools( const base::ListValue* list) { - DCHECK(!list); - net::HttpNetworkSession* http_network_session = - GetHttpNetworkSession(GetMainContext()); - - if (http_network_session) - http_network_session->CloseIdleConnections(); + GetNetworkContext()->CloseAllConnections(base::NullCallback()); } -#if defined(OS_WIN) -void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( +void NetInternalsMessageHandler::OnCloseIdleSockets( const base::ListValue* list) { - DCHECK(!list); - SendJavascriptCommand("receivedServiceProviders", - chrome_browser_net::GetWindowsServiceProviders()); + GetNetworkContext()->CloseIdleConnections(base::NullCallback()); } -#endif #if defined(OS_CHROMEOS) void NetInternalsMessageHandler::ImportONCFileToNSSDB( @@ -953,8 +341,7 @@ void NetInternalsMessageHandler::ImportONCFileToNSSDB( if (!user) { std::string error = "User not found."; - SendJavascriptCommand("receivedONCFileParse", - std::make_unique<base::Value>(error)); + SendJavascriptCommand("receivedONCFileParse", base::Value(error)); return; } @@ -978,7 +365,7 @@ void NetInternalsMessageHandler::ImportONCFileToNSSDB( error += network_error; chromeos::onc::CertificateImporterImpl cert_importer( - BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), nssdb); + base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}), nssdb); auto certs = std::make_unique<chromeos::onc::OncParsedCertificates>(certificates); if (certs->has_error()) @@ -996,8 +383,7 @@ void NetInternalsMessageHandler::OnCertificatesImported( if (!cert_import_success) error += "Some certificates couldn't be imported. "; - SendJavascriptCommand("receivedONCFileParse", - std::make_unique<base::Value>(error)); + SendJavascriptCommand("receivedONCFileParse", base::Value(error)); } void NetInternalsMessageHandler::OnImportONCFile( @@ -1020,7 +406,7 @@ void NetInternalsMessageHandler::OnStoreDebugLogs(const base::ListValue* list) { DCHECK(list); SendJavascriptCommand("receivedStoreDebugLogs", - std::make_unique<base::Value>("Creating log file...")); + base::Value("Creating log file...")); Profile* profile = Profile::FromWebUI(web_ui()); const DownloadPrefs* const prefs = DownloadPrefs::FromBrowserContext(profile); base::FilePath path = prefs->DownloadPath(); @@ -1040,8 +426,7 @@ void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe(); else status = "Failed to create log file"; - SendJavascriptCommand("receivedStoreDebugLogs", - std::make_unique<base::Value>(status)); + SendJavascriptCommand("receivedStoreDebugLogs", base::Value(status)); } void NetInternalsMessageHandler::OnSetNetworkDebugMode( @@ -1064,93 +449,15 @@ void NetInternalsMessageHandler::OnSetNetworkDebugModeCompleted( std::string status = succeeded ? "Debug mode is changed to " : "Failed to change debug mode to "; status += subsystem; - SendJavascriptCommand("receivedSetNetworkDebugMode", - std::make_unique<base::Value>(status)); + SendJavascriptCommand("receivedSetNetworkDebugMode", base::Value(status)); } #endif // defined(OS_CHROMEOS) -void NetInternalsMessageHandler::IOThreadImpl::OnSetCaptureMode( - const base::ListValue* list) { - std::string capture_mode_string; - if (!list->GetString(0, &capture_mode_string)) { - NOTREACHED(); - return; - } - - // Convert the string to a NetLogCaptureMode. - net::NetLogCaptureMode mode; - if (capture_mode_string == "IncludeSocketBytes") { - mode = net::NetLogCaptureMode::IncludeSocketBytes(); - } else if (capture_mode_string == "IncludeCookiesAndCredentials") { - mode = net::NetLogCaptureMode::IncludeCookiesAndCredentials(); - } else { - NOTREACHED(); - } - - net_log()->SetObserverCaptureMode(this, mode); -} - -// Note that unlike other methods of IOThreadImpl, this function -// can be called from ANY THREAD. -void NetInternalsMessageHandler::IOThreadImpl::OnAddEntry( - const net::NetLogEntry& entry) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::BindOnce(&IOThreadImpl::AddEntryToQueue, this, entry.ToValue())); -} - -// Note that this can be called from ANY THREAD. -void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand( - const std::string& command, - std::unique_ptr<base::Value> arg) { - if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { - if (handler_ && !was_webui_deleted_) { - // We check |handler_| in case it was deleted on the UI thread earlier - // while we were running on the IO thread. - handler_->SendJavascriptCommand(command, std::move(arg)); - } - return; - } - - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::BindOnce(&IOThreadImpl::SendJavascriptCommand, - this, command, std::move(arg))); -} - -void NetInternalsMessageHandler::IOThreadImpl::AddEntryToQueue( - std::unique_ptr<base::Value> entry) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - if (!pending_entries_) { - pending_entries_.reset(new base::ListValue()); - BrowserThread::PostDelayedTask( - BrowserThread::IO, FROM_HERE, - base::BindOnce(&IOThreadImpl::PostPendingEntries, this), - base::TimeDelta::FromMilliseconds(kNetLogEventDelayMilliseconds)); - } - pending_entries_->Append(std::move(entry)); -} - -void NetInternalsMessageHandler::IOThreadImpl::PostPendingEntries() { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - if (pending_entries_) - SendJavascriptCommand("receivedLogEntries", std::move(pending_entries_)); -} - -void NetInternalsMessageHandler::IOThreadImpl::PrePopulateEventList() { - // Using a set removes any duplicates. - std::set<net::URLRequestContext*> contexts; - for (const auto& getter : context_getters_) - contexts.insert(getter->GetURLRequestContext()); - contexts.insert(io_thread_->globals()->system_request_context); - - // Add entries for ongoing network objects. - CreateNetLogEntriesForActiveObjects(contexts, this); -} - -void NetInternalsMessageHandler::IOThreadImpl::SendNetInfo(int info_sources) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - SendJavascriptCommand("receivedNetInfo", - net::GetNetInfo(GetMainContext(), info_sources)); +network::mojom::NetworkContext* NetInternalsMessageHandler::GetNetworkContext() + const { + return content::BrowserContext::GetDefaultStoragePartition( + web_ui_->GetWebContents()->GetBrowserContext()) + ->GetNetworkContext(); } } // namespace @@ -1164,7 +471,8 @@ void NetInternalsMessageHandler::IOThreadImpl::SendNetInfo(int info_sources) { NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) : WebUIController(web_ui) { - web_ui->AddMessageHandler(std::make_unique<NetInternalsMessageHandler>()); + web_ui->AddMessageHandler( + std::make_unique<NetInternalsMessageHandler>(web_ui)); // Set up the chrome://net-internals/ source. Profile* profile = Profile::FromWebUI(web_ui); diff --git a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc index 1cee0ce0600..ad7a9071c3b 100644 --- a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc @@ -16,38 +16,30 @@ #include "base/strings/string_split.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/task/post_task.h" #include "base/threading/thread_restrictions.h" #include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/io_thread.h" -#include "chrome/browser/prerender/prerender_manager.h" -#include "chrome/browser/prerender/prerender_manager_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" #include "chrome/common/channel_info.h" #include "chrome/common/pref_names.h" -#include "chrome/test/base/ui_test_utils.h" -#include "components/net_log/chrome_net_log.h" #include "components/prefs/pref_service.h" +#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui_message_handler.h" #include "net/base/address_list.h" #include "net/base/net_errors.h" -#include "net/base/network_change_notifier.h" #include "net/dns/host_cache.h" #include "net/dns/host_resolver.h" #include "net/dns/mock_host_resolver.h" #include "net/http/http_network_session.h" #include "net/http/http_transaction_factory.h" -#include "net/log/file_net_log_observer.h" -#include "net/log/net_log.h" -#include "net/log/net_log_event_type.h" -#include "net/log/net_log_source_type.h" -#include "net/log/net_log_with_source.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/request_handler_util.h" #include "net/url_request/url_request_context.h" @@ -104,11 +96,6 @@ void AddCacheEntryOnIOThread(net::URLRequestContextGetter* context_getter, base::TimeTicks::Now(), ttl); } -struct WriteNetLogState { - base::ScopedTempDir temp_directory; - base::FilePath log_path; -}; - } // namespace //////////////////////////////////////////////////////////////////////////////// @@ -143,55 +130,20 @@ class NetInternalsTest::MessageHandler : public content::WebUIMessageHandler { // must be an empty string. void AddCacheEntry(const base::ListValue* list_value); - // Simulates a network change. - void ChangeNetwork(const base::ListValue* list_value); - - // Opens the given URL in a new tab. - void LoadPage(const base::ListValue* list_value); - - // Opens a page in a new tab that prerenders the given URL. - void PrerenderPage(const base::ListValue* list_value); - - // Navigates to the prerender in the background tab. This assumes that - // there is a "Click()" function in the background tab which will navigate - // there, and that the background tab exists at slot 1. - void NavigateToPrerender(const base::ListValue* list_value); - - // Creates an incognito browser. Once creation is complete, passes a - // message to the Javascript test harness. - void CreateIncognitoBrowser(const base::ListValue* list_value); - - // Closes an incognito browser created with CreateIncognitoBrowser. - void CloseIncognitoBrowser(const base::ListValue* list_value); - - // Creates a simple NetLog and returns it to the Javascript callback. - void GetNetLogFileContents(const base::ListValue* list_value); - // Sets up the test server to receive test Expect-CT reports. Calls the // Javascript callback to return the test server URI. void SetUpTestReportURI(const base::ListValue* list_value); - // Changes the data reduction proxy mode. A boolean is assumed to exist at - // index 0 which enables the proxy is set to true. - void EnableDataReductionProxy(const base::ListValue* list_value); - - // Called after the NetLog started by GetNetLogFileContents() has been written - // to disk. Responds to the Javascript caller with the log contents. - void OnFinishedWritingNetLog(std::unique_ptr<WriteNetLogState> state); - Browser* browser() { return net_internals_test_->browser(); } NetInternalsTest* net_internals_test_; - Browser* incognito_browser_; DISALLOW_COPY_AND_ASSIGN(MessageHandler); }; NetInternalsTest::MessageHandler::MessageHandler( NetInternalsTest* net_internals_test) - : net_internals_test_(net_internals_test), - incognito_browser_(NULL) { -} + : net_internals_test_(net_internals_test) {} void NetInternalsTest::MessageHandler::RegisterMessages() { RegisterMessage( @@ -203,41 +155,9 @@ void NetInternalsTest::MessageHandler::RegisterMessages() { base::BindRepeating(&NetInternalsTest::MessageHandler::AddCacheEntry, base::Unretained(this))); RegisterMessage( - "changeNetwork", - base::BindRepeating(&NetInternalsTest::MessageHandler::ChangeNetwork, - base::Unretained(this))); - RegisterMessage("loadPage", base::BindRepeating( - &NetInternalsTest::MessageHandler::LoadPage, - base::Unretained(this))); - RegisterMessage( - "prerenderPage", - base::BindRepeating(&NetInternalsTest::MessageHandler::PrerenderPage, - base::Unretained(this))); - RegisterMessage("navigateToPrerender", - base::BindRepeating( - &NetInternalsTest::MessageHandler::NavigateToPrerender, - base::Unretained(this))); - RegisterMessage("createIncognitoBrowser", - base::BindRepeating( - &NetInternalsTest::MessageHandler::CreateIncognitoBrowser, - base::Unretained(this))); - RegisterMessage("closeIncognitoBrowser", - base::BindRepeating( - &NetInternalsTest::MessageHandler::CloseIncognitoBrowser, - base::Unretained(this))); - RegisterMessage("getNetLogFileContents", - base::BindRepeating( - &NetInternalsTest::MessageHandler::GetNetLogFileContents, - base::Unretained(this))); - RegisterMessage( "setUpTestReportURI", base::BindRepeating(&NetInternalsTest::MessageHandler::SetUpTestReportURI, base::Unretained(this))); - RegisterMessage( - "enableDataReductionProxy", - base::BindRepeating( - &NetInternalsTest::MessageHandler::EnableDataReductionProxy, - base::Unretained(this))); } void NetInternalsTest::MessageHandler::RegisterMessage( @@ -284,8 +204,8 @@ void NetInternalsTest::MessageHandler::AddCacheEntry( ASSERT_TRUE(list_value->GetDouble(3, &expire_days_from_now)); ASSERT_TRUE(browser()); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, + base::PostTaskWithTraits( + FROM_HERE, {BrowserThread::IO}, base::BindOnce( &AddCacheEntryOnIOThread, base::RetainedRef(browser()->profile()->GetRequestContext()), @@ -293,97 +213,6 @@ void NetInternalsTest::MessageHandler::AddCacheEntry( static_cast<int>(expire_days_from_now))); } -void NetInternalsTest::MessageHandler::ChangeNetwork( - const base::ListValue* list_value) { - net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); -} - -void NetInternalsTest::MessageHandler::LoadPage( - const base::ListValue* list_value) { - std::string url; - ASSERT_TRUE(list_value->GetString(0, &url)); - LOG(WARNING) << "url: [" << url << "]"; - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(url), WindowOpenDisposition::NEW_BACKGROUND_TAB, - ui_test_utils::BROWSER_TEST_NONE); -} - -void NetInternalsTest::MessageHandler::PrerenderPage( - const base::ListValue* list_value) { - std::string prerender_url; - ASSERT_TRUE(list_value->GetString(0, &prerender_url)); - GURL loader_url = - net_internals_test_->CreatePrerenderLoaderUrl(GURL(prerender_url)); - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL(loader_url), WindowOpenDisposition::NEW_BACKGROUND_TAB, - ui_test_utils::BROWSER_TEST_NONE); -} - -void NetInternalsTest::MessageHandler::NavigateToPrerender( - const base::ListValue* list_value) { - std::string url; - ASSERT_TRUE(list_value->GetString(0, &url)); - content::RenderFrameHost* frame = - browser()->tab_strip_model()->GetWebContentsAt(1)->GetMainFrame(); - frame->ExecuteJavaScriptForTests( - base::ASCIIToUTF16(base::StringPrintf("Click('%s')", url.c_str()))); -} - -void NetInternalsTest::MessageHandler::CreateIncognitoBrowser( - const base::ListValue* list_value) { - ASSERT_FALSE(incognito_browser_); - incognito_browser_ = net_internals_test_->CreateIncognitoBrowser(); - - // Tell the test harness that creation is complete. - base::Value command_value("onIncognitoBrowserCreatedForTest"); - web_ui()->CallJavascriptFunctionUnsafe("g_browser.receive", command_value); -} - -void NetInternalsTest::MessageHandler::CloseIncognitoBrowser( - const base::ListValue* list_value) { - ASSERT_TRUE(incognito_browser_); - incognito_browser_->tab_strip_model()->CloseAllTabs(); - // Closing all a Browser's tabs will ultimately result in its destruction, - // thought it may not have been destroyed yet. - incognito_browser_ = NULL; -} - -void NetInternalsTest::MessageHandler::GetNetLogFileContents( - const base::ListValue* list_value) { - base::ScopedAllowBlockingForTesting allow_blocking; - - std::unique_ptr<WriteNetLogState> state = - std::make_unique<WriteNetLogState>(); - - ASSERT_TRUE(state->temp_directory.CreateUniqueTempDir()); - ASSERT_TRUE(base::CreateTemporaryFileInDir(state->temp_directory.GetPath(), - &state->log_path)); - - std::unique_ptr<base::Value> constants(net_log::ChromeNetLog::GetConstants( - base::CommandLine::ForCurrentProcess()->GetCommandLineString(), - chrome::GetChannelName())); - - std::unique_ptr<net::FileNetLogObserver> net_log_logger = - net::FileNetLogObserver::CreateUnbounded(state->log_path, - std::move(constants)); - - net_log_logger->StartObserving(g_browser_process->net_log(), - net::NetLogCaptureMode::Default()); - - g_browser_process->net_log()->AddGlobalEntry( - net::NetLogEventType::NETWORK_IP_ADDRESSES_CHANGED); - net::NetLogWithSource net_log_with_source = net::NetLogWithSource::Make( - g_browser_process->net_log(), net::NetLogSourceType::URL_REQUEST); - net_log_with_source.BeginEvent(net::NetLogEventType::REQUEST_ALIVE); - - // Call OnFinishedWritingNetLog() once net_log_logger has completed writing it - // to disk. - net_log_logger->StopObserving( - nullptr, - base::Bind(&NetInternalsTest::MessageHandler::OnFinishedWritingNetLog, - base::Unretained(this), base::Passed(std::move(state)))); -} - void NetInternalsTest::MessageHandler::SetUpTestReportURI( const base::ListValue* list_value) { net_internals_test_->embedded_test_server()->RegisterRequestHandler( @@ -394,29 +223,6 @@ void NetInternalsTest::MessageHandler::SetUpTestReportURI( RunJavascriptCallback(&report_uri_value); } -void NetInternalsTest::MessageHandler::EnableDataReductionProxy( - const base::ListValue* list_value) { - bool enable; - ASSERT_TRUE(list_value->GetBoolean(0, &enable)); - browser()->profile()->GetPrefs()->SetBoolean( - prefs::kDataSaverEnabled, enable); -} - -void NetInternalsTest::MessageHandler::OnFinishedWritingNetLog( - std::unique_ptr<WriteNetLogState> state) { - base::ScopedAllowBlockingForTesting allow_blocking; - - std::string log_contents; - ASSERT_TRUE(base::ReadFileToString(state->log_path, &log_contents)); - ASSERT_GT(log_contents.length(), 0u); - - std::unique_ptr<base::Value> log_contents_value( - new base::Value(log_contents)); - RunJavascriptCallback(log_contents_value.get()); - - state.reset(); -} - //////////////////////////////////////////////////////////////////////////////// // NetInternalsTest //////////////////////////////////////////////////////////////////////////////// @@ -429,36 +235,10 @@ NetInternalsTest::NetInternalsTest() NetInternalsTest::~NetInternalsTest() { } -void NetInternalsTest::SetUpOnMainThread() { - WebUIBrowserTest::SetUpOnMainThread(); - // Needed to test the prerender view. - prerender::PrerenderManager::SetMode( - prerender::PrerenderManager::PRERENDER_MODE_ENABLED); - // Increase the memory allowed in a prerendered page above normal settings, - // as debug builds use more memory and often go over the usual limit. - Profile* profile = browser()->profile(); - prerender::PrerenderManager* prerender_manager = - prerender::PrerenderManagerFactory::GetForBrowserContext(profile); - prerender_manager->mutable_config().max_bytes = 1000 * 1024 * 1024; -} - content::WebUIMessageHandler* NetInternalsTest::GetMockMessageHandler() { return message_handler_.get(); } -GURL NetInternalsTest::CreatePrerenderLoaderUrl( - const GURL& prerender_url) { - EXPECT_TRUE(StartTestServer()); - base::StringPairs replacement_text; - replacement_text.push_back( - make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec())); - std::string replacement_path; - net::test_server::GetFilePathWithReplacements( - "/prerender/prerender_loader.html", replacement_text, &replacement_path); - GURL url_loader = embedded_test_server()->GetURL(replacement_path); - return url_loader; -} - bool NetInternalsTest::StartTestServer() { if (test_server_started_) return true; diff --git a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h index fcae5dae948..86d996e6b8e 100644 --- a/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h +++ b/chromium/chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h @@ -10,8 +10,6 @@ #include "base/macros.h" #include "chrome/test/base/web_ui_browser_test.h" -class GURL; - class NetInternalsTest : public WebUIBrowserTest { protected: NetInternalsTest(); @@ -20,14 +18,9 @@ class NetInternalsTest : public WebUIBrowserTest { private: class MessageHandler; - // InProcessBrowserTest overrides. - void SetUpOnMainThread() override; - // WebUIBrowserTest implementation. content::WebUIMessageHandler* GetMockMessageHandler() override; - GURL CreatePrerenderLoaderUrl(const GURL& prerender_url); - // Attempts to start the test server. Returns true on success or if the // TestServer is already started. bool StartTestServer(); 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 ff6cec6de2f..0b7649345f5 100644 --- a/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chromium/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -376,8 +376,7 @@ void AppLauncherHandler::FillAppDictionary(base::DictionaryValue* dictionary) { Profile* profile = Profile::FromWebUI(web_ui()); PrefService* prefs = profile->GetPrefs(); - for (std::set<std::string>::iterator it = visible_apps_.begin(); - it != visible_apps_.end(); ++it) { + for (auto it = visible_apps_.begin(); it != visible_apps_.end(); ++it) { const Extension* extension = extension_service_->GetInstalledExtension(*it); if (extension && extensions::ui_util::ShouldDisplayInNewTabPage( extension, profile)) { 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 fdc50989ef1..b99f2360879 100644 --- a/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc +++ b/chromium/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc @@ -7,6 +7,7 @@ #include <string> #include "base/memory/ref_counted_memory.h" +#include "base/stl_util.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" @@ -51,8 +52,8 @@ #include "ui/gfx/color_utils.h" #if defined(OS_CHROMEOS) -#include "ash/strings/grit/ash_strings.h" #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" +#include "chromeos/strings/grit/chromeos_strings.h" #endif #if defined(OS_MACOSX) @@ -357,7 +358,7 @@ void NTPResourceCache::CreateNewTabGuestHTML() { // keys. This functionality is not implemented for NTP. static base::string16 GetLocalizedString(int message_id) { base::string16 result = l10n_util::GetStringUTF16(message_id); - result.erase(std::remove(result.begin(), result.end(), '&'), result.end()); + base::Erase(result, '&'); return result; } 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 9c5f03fa560..597a280ee27 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 @@ -183,26 +183,21 @@ void OfflineInternalsUIMessageHandler::HandleStoredPagesCallback( void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback( std::string callback_id, - offline_pages::GetRequestsResult result, std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests) { base::ListValue save_page_requests; - if (result == offline_pages::GetRequestsResult::SUCCESS) { - for (const auto& request : requests) { - auto save_page_request = std::make_unique<base::DictionaryValue>(); - save_page_request->SetString("onlineUrl", request->url().spec()); - save_page_request->SetDouble("creationTime", - request->creation_time().ToJsTime()); - save_page_request->SetString("status", GetStringFromSavePageStatus()); - save_page_request->SetString("namespace", - request->client_id().name_space); - save_page_request->SetDouble("lastAttemptTime", - request->last_attempt_time().ToJsTime()); - save_page_request->SetString("id", std::to_string(request->request_id())); - save_page_request->SetString("originalUrl", - request->original_url().spec()); - save_page_request->SetString("requestOrigin", request->request_origin()); - save_page_requests.Append(std::move(save_page_request)); - } + for (const auto& request : requests) { + auto save_page_request = std::make_unique<base::DictionaryValue>(); + save_page_request->SetString("onlineUrl", request->url().spec()); + save_page_request->SetDouble("creationTime", + request->creation_time().ToJsTime()); + save_page_request->SetString("status", GetStringFromSavePageStatus()); + save_page_request->SetString("namespace", request->client_id().name_space); + save_page_request->SetDouble("lastAttemptTime", + request->last_attempt_time().ToJsTime()); + save_page_request->SetString("id", std::to_string(request->request_id())); + save_page_request->SetString("originalUrl", request->original_url().spec()); + save_page_request->SetString("requestOrigin", request->request_origin()); + save_page_requests.Append(std::move(save_page_request)); } ResolveJavascriptCallback(base::Value(callback_id), save_page_requests); } @@ -214,7 +209,7 @@ void OfflineInternalsUIMessageHandler::HandleGetRequestQueue( CHECK(args->GetString(0, &callback_id)); if (request_coordinator_) { - request_coordinator_->queue()->GetRequests(base::Bind( + request_coordinator_->GetAllRequests(base::BindOnce( &OfflineInternalsUIMessageHandler::HandleRequestQueueCallback, weak_ptr_factory_.GetWeakPtr(), callback_id)); } else { 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 6092fd83a5e..9450df7ece7 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 @@ -95,7 +95,6 @@ class OfflineInternalsUIMessageHandler : public content::WebUIMessageHandler { // Callback for async GetRequests calls. void HandleRequestQueueCallback( std::string callback_id, - offline_pages::GetRequestsResult result, std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests); // Callback for DeletePage/DeleteAllPages calls. 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 d6c5b06681c..232082ae80e 100644 --- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc +++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc @@ -44,8 +44,7 @@ struct TypeConverter<std::vector<mojom::AutocompleteAdditionalInfoPtr>, const AutocompleteMatch::AdditionalInfo& input) { std::vector<mojom::AutocompleteAdditionalInfoPtr> array(input.size()); size_t index = 0; - for (AutocompleteMatch::AdditionalInfo::const_iterator i = input.begin(); - i != input.end(); ++i, index++) { + for (auto i = input.begin(); i != input.end(); ++i, index++) { mojom::AutocompleteAdditionalInfoPtr item( mojom::AutocompleteAdditionalInfo::New()); item->key = i->first; diff --git a/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc index c1f1a36df59..e9721c93a32 100644 --- a/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc +++ b/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc @@ -4,6 +4,13 @@ #include "chrome/browser/ui/webui/policy_tool_ui_handler.h" +#include <algorithm> +#include <functional> +#include <limits> +#include <memory> +#include <utility> +#include <vector> + #include "base/files/file_enumerator.h" #include "base/files/file_util.h" #include "base/json/json_reader.h" diff --git a/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.h b/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.h index 49f9e2ccf00..bcc2e3d0288 100644 --- a/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.h +++ b/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_UI_WEBUI_POLICY_TOOL_UI_HANDLER_H_ #define CHROME_BROWSER_UI_WEBUI_POLICY_TOOL_UI_HANDLER_H_ +#include <string> + #include "base/files/file_path.h" #include "chrome/browser/ui/webui/policy_ui_handler.h" diff --git a/chromium/chrome/browser/ui/webui/policy_ui.cc b/chromium/chrome/browser/ui/webui/policy_ui.cc index 4eadc72116a..a3bb09c805f 100644 --- a/chromium/chrome/browser/ui/webui/policy_ui.cc +++ b/chromium/chrome/browser/ui/webui/policy_ui.cc @@ -27,10 +27,19 @@ content::WebUIDataSource* CreatePolicyUIHtmlSource() { source->AddLocalizedString("status", IDS_POLICY_STATUS); source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); + source->AddLocalizedString("statusMachine", IDS_POLICY_STATUS_MACHINE); source->AddLocalizedString("labelEnterpriseEnrollmentDomain", IDS_POLICY_LABEL_ENTERPRISE_ENROLLMENT_DOMAIN); source->AddLocalizedString("labelEnterpriseDisplayDomain", IDS_POLICY_LABEL_ENTERPRISE_DISPLAY_DOMAIN); + source->AddLocalizedString("labelMachineEnrollmentDomain", + IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DOMAIN); + source->AddLocalizedString("labelMachineEnrollmentToken", + IDS_POLICY_LABEL_MACHINE_ENROLLMENT_TOKEN); + source->AddLocalizedString("labelMachineEntrollmentDeviceId", + IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DEVICE_ID); + source->AddLocalizedString("labelMachineEnrollmentMachineName", + IDS_POLICY_LABEL_MACHINE_ENROLLMENT_MACHINE_NAME); source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME); source->AddLocalizedString("labelGaiaId", IDS_POLICY_LABEL_GAIA_ID); source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID); diff --git a/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc index 933bab52f6d..251dfd387c1 100644 --- a/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/policy_ui_browsertest.cc @@ -585,7 +585,7 @@ IN_PROC_BROWSER_TEST_F(PolicyUITest, ExtensionLoadAndSendPolicy) { extensions::ExtensionService* service = extensions::ExtensionSystem::Get(browser()->profile()) ->extension_service(); - scoped_refptr<extensions::Extension> extension = builder.Build(); + scoped_refptr<const extensions::Extension> extension = builder.Build(); service->OnExtensionInstalled(extension.get(), syncer::StringOrdinal(), 0); const policy::PolicyNamespace extension_policy_namespace( policy::POLICY_DOMAIN_EXTENSIONS, extension->id()); diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc index db5f1afedda..1e70ce18dc3 100644 --- a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc +++ b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc @@ -25,6 +25,8 @@ #include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_prefs.h" +#include "chrome/browser/policy/browser_dm_token_storage.h" +#include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "chrome/browser/policy/policy_conversions.h" #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/policy/profile_policy_connector_factory.h" @@ -40,7 +42,10 @@ #include "components/policy/core/common/cloud/cloud_policy_manager.h" #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" #include "components/policy/core/common/cloud/cloud_policy_store.h" +#include "components/policy/core/common/cloud/cloud_policy_util.h" #include "components/policy/core/common/cloud/cloud_policy_validator.h" +#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_manager.h" +#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_store.h" #include "components/policy/core/common/policy_details.h" #include "components/policy/core/common/policy_scheduler.h" #include "components/policy/core/common/policy_types.h" @@ -239,6 +244,28 @@ class UserCloudPolicyStatusProvider : public CloudPolicyCoreStatusProvider { DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStatusProvider); }; +#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) +class MachineLevelUserCloudPolicyStatusProvider + : public PolicyStatusProvider, + public policy::CloudPolicyStore::Observer { + public: + explicit MachineLevelUserCloudPolicyStatusProvider( + policy::MachineLevelUserCloudPolicyStore* store); + ~MachineLevelUserCloudPolicyStatusProvider() override; + + void GetStatus(base::DictionaryValue* dict) override; + + // policy::CloudPolicyStore::Observer implementation. + void OnStoreLoaded(policy::CloudPolicyStore* store) override; + void OnStoreError(policy::CloudPolicyStore* store) override; + + private: + policy::MachineLevelUserCloudPolicyStore* store_; + + DISALLOW_COPY_AND_ASSIGN(MachineLevelUserCloudPolicyStatusProvider); +}; +#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) + #if defined(OS_CHROMEOS) // A cloud policy status provider for device policy. class DeviceCloudPolicyStatusProvider : public CloudPolicyCoreStatusProvider { @@ -382,6 +409,72 @@ void UserCloudPolicyStatusProvider::GetStatus(base::DictionaryValue* dict) { ExtractDomainFromUsername(dict); } +#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) + +MachineLevelUserCloudPolicyStatusProvider:: + MachineLevelUserCloudPolicyStatusProvider( + policy::MachineLevelUserCloudPolicyStore* store) { + store_ = store; + if (store_) + store_->AddObserver(this); +} + +MachineLevelUserCloudPolicyStatusProvider:: + ~MachineLevelUserCloudPolicyStatusProvider() { + if (store_) + store_->RemoveObserver(this); +} + +void MachineLevelUserCloudPolicyStatusProvider::GetStatus( + base::DictionaryValue* dict) { + policy::BrowserDMTokenStorage* dmTokenStorage = + policy::BrowserDMTokenStorage::Get(); + + dict->SetString( + "refreshInterval", + ui::TimeFormat::Simple( + ui::TimeFormat::FORMAT_DURATION, ui::TimeFormat::LENGTH_SHORT, + base::TimeDelta::FromMilliseconds( + policy::CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs))); + + if (dmTokenStorage) { + dict->SetString("enrollmentToken", + dmTokenStorage->RetrieveEnrollmentToken()); + + dict->SetString("deviceId", dmTokenStorage->RetrieveClientId()); + } + if (store_) { + base::string16 status = policy::FormatStoreStatus( + store_->status(), store_->validation_status()); + + dict->SetString("status", status); + const em::PolicyData* policy = store_->policy(); + if (policy) { + dict->SetString( + "timeSinceLastRefresh", + ui::TimeFormat::Simple( + ui::TimeFormat::FORMAT_ELAPSED, ui::TimeFormat::LENGTH_SHORT, + base::Time::NowFromSystemTime() - + base::Time::FromJavaTime(policy->timestamp()))); + std::string username = policy->username(); + dict->SetString("domain", gaia::ExtractDomainName(username)); + } + } + dict->SetString("machine", policy::GetMachineName()); +} + +void MachineLevelUserCloudPolicyStatusProvider::OnStoreLoaded( + policy::CloudPolicyStore* store) { + NotifyStatusChange(); +} + +void MachineLevelUserCloudPolicyStatusProvider::OnStoreError( + policy::CloudPolicyStore* store) { + NotifyStatusChange(); +} + +#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) + #if defined(OS_CHROMEOS) DeviceCloudPolicyStatusProvider::DeviceCloudPolicyStatusProvider( policy::BrowserPolicyConnectorChromeOS* connector) @@ -610,17 +703,32 @@ void PolicyUIHandler::RegisterMessages() { user_status_provider_ = std::make_unique<UserCloudPolicyStatusProvider>( user_cloud_policy_manager->core()); } -#endif + +#if !defined(OS_ANDROID) + policy::MachineLevelUserCloudPolicyManager* manager = + g_browser_process->browser_policy_connector() + ->machine_level_user_cloud_policy_manager(); + + if (manager) { + machine_status_provider_ = + std::make_unique<MachineLevelUserCloudPolicyStatusProvider>( + manager->store()); + } +#endif // !defined(OS_ANDROID) +#endif // defined(OS_CHROMEOS) if (!user_status_provider_.get()) user_status_provider_ = std::make_unique<PolicyStatusProvider>(); if (!device_status_provider_.get()) device_status_provider_ = std::make_unique<PolicyStatusProvider>(); + if (!machine_status_provider_.get()) + machine_status_provider_ = std::make_unique<PolicyStatusProvider>(); base::Closure update_callback(base::Bind(&PolicyUIHandler::SendStatus, base::Unretained(this))); user_status_provider_->SetStatusChangeCallback(update_callback); device_status_provider_->SetStatusChangeCallback(update_callback); + machine_status_provider_->SetStatusChangeCallback(update_callback); GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_CHROME, this); GetPolicyService()->AddObserver(policy::POLICY_DOMAIN_EXTENSIONS, this); @@ -748,6 +856,7 @@ void PolicyUIHandler::SendStatus() const { device_status_provider_->GetStatus(device_status.get()); if (!device_domain_.empty()) device_status->SetString("domain", device_domain_); + std::string domain = device_domain_; std::unique_ptr<base::DictionaryValue> user_status(new base::DictionaryValue); user_status_provider_->GetStatus(user_status.get()); std::string username; @@ -755,9 +864,15 @@ void PolicyUIHandler::SendStatus() const { if (!username.empty()) user_status->SetString("domain", gaia::ExtractDomainName(username)); + std::unique_ptr<base::DictionaryValue> machine_status( + new base::DictionaryValue); + machine_status_provider_->GetStatus(machine_status.get()); + base::DictionaryValue status; if (!device_status->empty()) status.Set("device", std::move(device_status)); + if (!machine_status->empty()) + status.Set("machine", std::move(machine_status)); if (!user_status->empty()) status.Set("user", std::move(user_status)); diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.h b/chromium/chrome/browser/ui/webui/policy_ui_handler.h index 025f7704cf8..4a3d8dc6c8a 100644 --- a/chromium/chrome/browser/ui/webui/policy_ui_handler.h +++ b/chromium/chrome/browser/ui/webui/policy_ui_handler.h @@ -117,6 +117,7 @@ class PolicyUIHandler : public content::WebUIMessageHandler, // the platform (Chrome OS / desktop) and type of policy that is in effect. std::unique_ptr<PolicyStatusProvider> user_status_provider_; std::unique_ptr<PolicyStatusProvider> device_status_provider_; + std::unique_ptr<PolicyStatusProvider> machine_status_provider_; base::WeakPtrFactory<PolicyUIHandler> weak_factory_; 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 e1f1803d1f7..668ae76ed2d 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 @@ -452,7 +452,7 @@ class ExtensionPrinterHandlerTest : public testing::Test { void SetUp() override { extensions::PrinterProviderAPIFactory::GetInstance()->SetTestingFactory( - env_.profile(), &BuildTestingPrinterProviderAPI); + env_.profile(), base::BindRepeating(&BuildTestingPrinterProviderAPI)); extension_printer_handler_ = std::make_unique<ExtensionPrinterHandler>(env_.profile()); 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 40f83cbaa42..c8fbaecf194 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 @@ -27,6 +27,7 @@ #include "chromeos/printing/ppd_provider.h" #include "chromeos/printing/printer_configuration.h" #include "components/printing/common/printer_capabilities.h" +#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "printing/backend/print_backend_consts.h" #include "printing/backend/printing_restrictions.h" @@ -110,8 +111,8 @@ void LocalPrinterHandlerChromeos::GetDefaultPrinter(DefaultPrinterCallback cb) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // TODO(crbug.com/660898): Add default printers to ChromeOS. - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, - base::BindOnce(std::move(cb), "")); + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(std::move(cb), "")); } void LocalPrinterHandlerChromeos::StartGetPrinters( @@ -145,8 +146,8 @@ void LocalPrinterHandlerChromeos::StartGetCapability( printers_manager_->GetPrinter(printer_name); if (!printer) { // If the printer was removed, the lookup will fail. - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, - base::BindOnce(std::move(cb), nullptr)); + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(std::move(cb), nullptr)); return; } @@ -186,6 +187,9 @@ void LocalPrinterHandlerChromeos::HandlePrinterSetup( policies.SetInteger( printing::kAllowedColorModes, profile_->GetPrefs()->GetInteger(prefs::kPrintingAllowedColorModes)); + policies.SetInteger( + printing::kAllowedDuplexModes, + profile_->GetPrefs()->GetInteger(prefs::kPrintingAllowedDuplexModes)); // fetch settings on the blocking pool and invoke callback. FetchCapabilities(std::move(printer), std::move(policies), std::move(cb)); return; @@ -227,6 +231,9 @@ void LocalPrinterHandlerChromeos::StartPrint( const gfx::Size& page_size, const scoped_refptr<base::RefCountedMemory>& print_data, PrintCallback callback) { + size_t size_in_kb = print_data->size() / 1024; + UMA_HISTOGRAM_MEMORY_KB("Printing.CUPS.PrintDocumentSize", size_in_kb); + printing::StartLocalPrint(ticket_json, print_data, preview_web_contents_, std::move(callback)); } 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 8e8a5ed48ba..84859e4e29a 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 @@ -186,29 +186,31 @@ void ReportPrintDocumentTypeAndSizeHistograms(PrintDocumentTypeBuckets doctype, bool ReportPageCountHistogram(UserActionBuckets user_action, int page_count) { switch (user_action) { case PRINT_TO_PRINTER: - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.PageCount.PrintToPrinter", + page_count); return true; case PRINT_TO_PDF: - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPDF", page_count); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.PageCount.PrintToPDF", page_count); return true; case FALLBACK_TO_ADVANCED_SETTINGS_DIALOG: - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.PageCount.SystemDialog", + page_count); return true; case PRINT_WITH_CLOUD_PRINT: - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint", - page_count); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.PageCount.PrintToCloudPrint", + page_count); return true; case PRINT_WITH_PRIVET: - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintWithPrivet", - page_count); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.PageCount.PrintWithPrivet", + page_count); return true; case PRINT_WITH_EXTENSION: - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintWithExtension", - page_count); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.PageCount.PrintWithExtension", + page_count); return true; case OPEN_IN_MAC_PREVIEW: - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.OpenInMacPreview", - page_count); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.PageCount.OpenInMacPreview", + page_count); return true; default: return false; @@ -553,8 +555,8 @@ PrintPreviewHandler::PrintPreviewHandler() } PrintPreviewHandler::~PrintPreviewHandler() { - UMA_HISTOGRAM_COUNTS("PrintPreview.ManagePrinters", - manage_printers_dialog_request_count_); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.ManagePrinters", + manage_printers_dialog_request_count_); UnregisterForGaiaCookieChanges(); } @@ -814,8 +816,8 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) { void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { // Record the number of times the user requests to regenerate preview data // before printing. - UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", - regenerate_preview_request_count_); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.RegeneratePreviewRequest.BeforePrint", + regenerate_preview_request_count_); std::string callback_id; CHECK(args->GetString(0, &callback_id)); CHECK(!callback_id.empty()); @@ -1008,8 +1010,8 @@ void PrintPreviewHandler::HandleClosePreviewDialog( // Record the number of times the user requests to regenerate preview data // before cancelling. - UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforeCancel", - regenerate_preview_request_count_); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.RegeneratePreviewRequest.BeforeCancel", + regenerate_preview_request_count_); } void PrintPreviewHandler::GetNumberFormatAndMeasurementSystem( @@ -1141,32 +1143,29 @@ void PrintPreviewHandler::SendPrinterSetup( const std::string& callback_id, const std::string& printer_name, std::unique_ptr<base::DictionaryValue> destination_info) { - auto response = std::make_unique<base::DictionaryValue>(); - bool success = true; - auto caps_value = std::make_unique<base::Value>(); - auto caps = std::make_unique<base::DictionaryValue>(); - if (destination_info && - destination_info->Remove(printing::kSettingCapabilities, &caps_value) && - caps_value->is_dict()) { - caps = base::DictionaryValue::From(std::move(caps_value)); + base::DictionaryValue response; + base::Value* caps_value = + destination_info + ? destination_info->FindKeyOfType(printing::kSettingCapabilities, + base::Value::Type::DICTIONARY) + : nullptr; + response.SetString("printerId", printer_name); + response.SetBoolean("success", !!caps_value); + response.SetKey("capabilities", caps_value ? std::move(*caps_value) + : base::DictionaryValue()); + if (caps_value) { base::Value* printer = destination_info->FindKeyOfType( printing::kPrinter, base::Value::Type::DICTIONARY); if (printer) { base::Value* policies_value = printer->FindKeyOfType( printing::kSettingPolicies, base::Value::Type::DICTIONARY); if (policies_value) - response->SetKey("policies", std::move(*policies_value)); + response.SetKey("policies", std::move(*policies_value)); } } else { LOG(WARNING) << "Printer setup failed"; - success = false; } - - response->SetString("printerId", printer_name); - response->SetBoolean("success", success); - response->Set("capabilities", std::move(caps)); - - ResolveJavascriptCallback(base::Value(callback_id), *response); + ResolveJavascriptCallback(base::Value(callback_id), response); } void PrintPreviewHandler::SendCloudPrintEnabled() { @@ -1379,7 +1378,8 @@ void PrintPreviewHandler::OnAddedPrinters(printing::PrinterType printer_type, if (printer_type == PrinterType::kLocalPrinter && !has_logged_printers_count_) { - UMA_HISTOGRAM_COUNTS("PrintPreview.NumberOfPrinters", printers.GetSize()); + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.NumberOfPrinters", + printers.GetSize()); has_logged_printers_count_ = true; } } 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 8ecdea6626f..24f69d8e8b2 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 @@ -201,6 +201,8 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { source->AddLocalizedString("layoutLabel", IDS_PRINT_PREVIEW_LAYOUT_LABEL); source->AddLocalizedString("optionAllPages", IDS_PRINT_PREVIEW_OPTION_ALL_PAGES); + source->AddLocalizedString("optionCustomPages", + IDS_PRINT_PREVIEW_OPTION_CUSTOM_PAGES); source->AddLocalizedString("optionBw", IDS_PRINT_PREVIEW_OPTION_BW); source->AddLocalizedString("optionCollate", IDS_PRINT_PREVIEW_OPTION_COLLATE); source->AddLocalizedString("optionColor", IDS_PRINT_PREVIEW_OPTION_COLOR); @@ -233,6 +235,9 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { source->AddLocalizedString("goBackButton", IDS_PRINT_PREVIEW_BUTTON_GO_BACK); source->AddLocalizedString( + "resolveExtensionUSBDialogTitle", + IDS_PRINT_PREVIEW_RESOLVE_EXTENSION_USB_DIALOG_TITLE); + source->AddLocalizedString( "resolveExtensionUSBPermissionMessage", IDS_PRINT_PREVIEW_RESOLVE_EXTENSION_USB_PERMISSION_MESSAGE); source->AddLocalizedString( @@ -347,6 +352,8 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { IDS_PRINT_PREVIEW_ADVANCED_OPTIONS_LABEL); source->AddLocalizedString("showAdvancedOptions", IDS_PRINT_PREVIEW_SHOW_ADVANCED_OPTIONS); + source->AddLocalizedString("newShowAdvancedOptions", + IDS_PRINT_PREVIEW_NEW_SHOW_ADVANCED_OPTIONS); source->AddLocalizedString("accept", IDS_PRINT_PREVIEW_ACCEPT_INVITE); source->AddLocalizedString( @@ -360,6 +367,8 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { IDS_CLOUD_PRINT_REGISTER_PRINTER_INFORMATION); source->AddLocalizedString("moreOptionsLabel", IDS_MORE_OPTIONS_LABEL); source->AddLocalizedString("lessOptionsLabel", IDS_LESS_OPTIONS_LABEL); + source->AddLocalizedString("managedOption", + IDS_PRINT_PREVIEW_MANAGED_OPTION_TEXT); #if defined(OS_CHROMEOS) source->AddLocalizedString("configuringInProgressText", IDS_PRINT_CONFIGURING_IN_PROGRESS_TEXT); @@ -630,6 +639,31 @@ void PrintPreviewUI::SetInitiatorTitle( initiator_title_ = job_title; } +bool PrintPreviewUI::LastPageComposited(int page_number) const { + if (pages_to_render_.empty()) + return false; + + return page_number == pages_to_render_.back(); +} + +int PrintPreviewUI::GetPageToNupConvertIndex(int page_number) const { + for (size_t index = 0; index < pages_to_render_.size(); ++index) { + if (page_number == pages_to_render_[index]) + return index; + } + return -1; +} + +std::vector<base::ReadOnlySharedMemoryRegion> +PrintPreviewUI::TakePagesForNupConvert() { + return std::move(pages_for_nup_convert_); +} + +void PrintPreviewUI::AddPdfPageForNupConversion( + base::ReadOnlySharedMemoryRegion pdf_page) { + pages_for_nup_convert_.push_back(std::move(pdf_page)); +} + // static void PrintPreviewUI::SetInitialParams( content::WebContents* print_preview_dialog, @@ -697,6 +731,14 @@ void PrintPreviewUI::OnDidStartPreview( const PrintHostMsg_DidStartPreview_Params& params, int request_id) { DCHECK_GT(params.page_count, 0); + DCHECK(!params.pages_to_render.empty()); + + pages_to_render_ = params.pages_to_render; + pages_to_render_index_ = 0; + pages_per_sheet_ = params.pages_per_sheet; + page_size_ = params.page_size; + ClearAllPreviewData(); + if (g_testing_delegate) g_testing_delegate->DidGetPreviewPageCount(params.page_count); handler_->SendPageCountReady(params.page_count, params.fit_to_page_scaling, @@ -715,6 +757,8 @@ void PrintPreviewUI::OnDidGetDefaultPageLayout( NOTREACHED(); return; } + // Save printable_area information for N-up conversion. + printable_area_ = printable_area; base::DictionaryValue layout; layout.SetDouble(printing::kSettingMarginTop, page_layout.margin_top); @@ -732,29 +776,49 @@ void PrintPreviewUI::OnDidGetDefaultPageLayout( handler_->SendPageLayoutReady(layout, has_custom_page_size_style, request_id); } -void PrintPreviewUI::OnDidPreviewPage(int page_number, - int preview_request_id) { +bool PrintPreviewUI::OnPendingPreviewPage(int page_number) { + if (pages_to_render_index_ >= pages_to_render_.size()) + return false; + + bool matched = page_number == pages_to_render_[pages_to_render_index_]; + ++pages_to_render_index_; + return matched; +} + +void PrintPreviewUI::OnDidPreviewPage( + int page_number, + scoped_refptr<base::RefCountedMemory> data, + int preview_request_id) { DCHECK_GE(page_number, 0); + + SetPrintPreviewDataForIndex(page_number, std::move(data)); + if (g_testing_delegate) g_testing_delegate->DidRenderPreviewPage(web_ui()->GetWebContents()); handler_->SendPagePreviewReady(page_number, id_, preview_request_id); } -void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, - int preview_request_id) { +void PrintPreviewUI::OnPreviewDataIsAvailable( + int expected_pages_count, + scoped_refptr<base::RefCountedMemory> data, + int preview_request_id) { VLOG(1) << "Print preview request finished with " << expected_pages_count << " pages"; if (!initial_preview_start_time_.is_null()) { UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", base::TimeTicks::Now() - initial_preview_start_time_); - UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", - expected_pages_count); - UMA_HISTOGRAM_COUNTS( + UMA_HISTOGRAM_COUNTS_1M("PrintPreview.PageCount.Initial", + expected_pages_count); + UMA_HISTOGRAM_COUNTS_1M( "PrintPreview.RegeneratePreviewRequest.BeforeFirstData", handler_->regenerate_preview_request_count()); initial_preview_start_time_ = base::TimeTicks(); } + + SetPrintPreviewDataForIndex(printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, + std::move(data)); + handler_->OnPrintPreviewReady(id_, preview_request_id); } @@ -828,3 +892,13 @@ void PrintPreviewUI::SendManipulateSettingsForTest( const base::DictionaryValue& settings) { handler_->SendManipulateSettingsForTest(settings); } + +void PrintPreviewUI::SetPrintPreviewDataForIndexForTest( + int index, + scoped_refptr<base::RefCountedMemory> data) { + SetPrintPreviewDataForIndex(index, data); +} + +void PrintPreviewUI::ClearAllPreviewDataForTest() { + ClearAllPreviewData(); +} 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 6fc3581f8a8..5135daaa6e4 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,13 +8,17 @@ #include <stdint.h> #include <memory> +#include <vector> #include "base/callback_forward.h" #include "base/gtest_prod_util.h" #include "base/macros.h" +#include "base/memory/read_only_shared_memory_region.h" #include "base/memory/ref_counted.h" #include "base/time/time.h" #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/size.h" class PrintPreviewHandler; struct PrintHostMsg_DidStartPreview_Params; @@ -49,15 +53,6 @@ class PrintPreviewUI : public ConstrainedWebDialogUI { int index, scoped_refptr<base::RefCountedMemory>* data) const; - // Sets the print preview |data|. |index| is zero-based, and can be - // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview - // document. - void SetPrintPreviewDataForIndex(int index, - scoped_refptr<base::RefCountedMemory> data); - - // Clear the existing print preview data. - void ClearAllPreviewData(); - // Setters void SetInitiatorTitle(const base::string16& initiator_title); @@ -69,6 +64,25 @@ class PrintPreviewUI : public ConstrainedWebDialogUI { bool print_selection_only() const { return print_selection_only_; } + int pages_per_sheet() const { return pages_per_sheet_; } + + const gfx::Rect& printable_area() const { return printable_area_; } + + const gfx::Size& page_size() const { return page_size_; } + + // Returns true if |page_number| is the last page in |pages_to_render_|. + // |page_number| is a 0-based number. + bool LastPageComposited(int page_number) const; + + // Get the 0-based index of the |page_number| in |pages_to_render_|. + // Same as above, |page_number| is a 0-based number. + int GetPageToNupConvertIndex(int page_number) const; + + std::vector<base::ReadOnlySharedMemoryRegion> TakePagesForNupConvert(); + + // Save pdf pages temporarily before ready to do N-up conversion. + void AddPdfPageForNupConversion(base::ReadOnlySharedMemoryRegion pdf_page); + // Set initial settings for PrintPreviewUI. static void SetInitialParams( content::WebContents* print_preview_dialog, @@ -96,14 +110,22 @@ class PrintPreviewUI : public ConstrainedWebDialogUI { bool has_custom_page_size_style, int request_id); + // Notifies the Web UI that the 0-based page |page_number| rendering is being + // processed and an OnPendingPreviewPage() call is imminent. Returns whether + // |page_number| is the expected page. + bool OnPendingPreviewPage(int page_number); + // Notifies the Web UI that the 0-based page |page_number| has been rendered. - // |preview_request_id| indicates wich request resulted in this response. - void OnDidPreviewPage(int page_number, int preview_request_id); + // |preview_request_id| indicates which request resulted in this response. + void OnDidPreviewPage(int page_number, + scoped_refptr<base::RefCountedMemory> data, + int preview_request_id); // Notifies the Web UI renderer that preview data is available. // |expected_pages_count| specifies the total number of pages. // |preview_request_id| indicates which request resulted in this response. void OnPreviewDataIsAvailable(int expected_pages_count, + scoped_refptr<base::RefCountedMemory> data, int preview_request_id); // Notifies the Web UI that the print preview failed to render for the request @@ -164,6 +186,14 @@ class PrintPreviewUI : public ConstrainedWebDialogUI { // to set the print preview settings contained in |settings|. void SendManipulateSettingsForTest(const base::DictionaryValue& settings); + // See SetPrintPreviewDataForIndex(). + void SetPrintPreviewDataForIndexForTest( + int index, + scoped_refptr<base::RefCountedMemory> data); + + // See ClearAllPreviewData(). + void ClearAllPreviewDataForTest(); + protected: // Alternate constructor for tests PrintPreviewUI(content::WebUI* web_ui, @@ -174,6 +204,15 @@ class PrintPreviewUI : public ConstrainedWebDialogUI { TitleAfterReload); friend class FakePrintPreviewUI; + // Sets the print preview |data|. |index| is zero-based, and can be + // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview + // document. + void SetPrintPreviewDataForIndex(int index, + scoped_refptr<base::RefCountedMemory> data); + + // Clear the existing print preview data. + void ClearAllPreviewData(); + base::TimeTicks initial_preview_start_time_; // The unique ID for this class instance. Stored here to avoid calling @@ -199,6 +238,24 @@ class PrintPreviewUI : public ConstrainedWebDialogUI { // title. base::string16 initiator_title_; + // The list of 0-based page numbers that will be rendered. + std::vector<int> pages_to_render_; + + // The list of pages to be converted. + std::vector<base::ReadOnlySharedMemoryRegion> pages_for_nup_convert_; + + // Index into |pages_to_render_| for the page number to expect. + size_t pages_to_render_index_ = 0; + + // number of pages per sheet and should be greater or equal to 1. + int pages_per_sheet_ = 1; + + // Physical size of the page, including non-printable margins. + gfx::Size page_size_; + + // The printable area of the printed document pages. + gfx::Rect printable_area_; + DISALLOW_COPY_AND_ASSIGN(PrintPreviewUI); }; diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc index b06ab2b7aa0..eca93878206 100644 --- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc +++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc @@ -96,9 +96,8 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewData) { scoped_refptr<base::RefCountedBytes> dummy_data = CreateTestData(); - preview_ui->SetPrintPreviewDataForIndex( - printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, - dummy_data.get()); + preview_ui->SetPrintPreviewDataForIndexForTest( + printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, dummy_data.get()); preview_ui->GetPrintPreviewDataForIndex( printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); @@ -106,7 +105,7 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewData) { EXPECT_EQ(dummy_data.get(), data.get()); // Clear the preview data. - preview_ui->ClearAllPreviewData(); + preview_ui->ClearAllPreviewDataForTest(); preview_ui->GetPrintPreviewDataForIndex( printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, @@ -142,15 +141,15 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewDraftPages) { scoped_refptr<base::RefCountedBytes> dummy_data = CreateTestData(); - preview_ui->SetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, - dummy_data.get()); + preview_ui->SetPrintPreviewDataForIndexForTest(printing::FIRST_PAGE_INDEX, + dummy_data.get()); preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data); EXPECT_EQ(dummy_data->size(), data->size()); EXPECT_EQ(dummy_data.get(), data.get()); // Set and get the third page data. - preview_ui->SetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX + 2, - dummy_data.get()); + preview_ui->SetPrintPreviewDataForIndexForTest(printing::FIRST_PAGE_INDEX + 2, + dummy_data.get()); preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX + 2, &data); EXPECT_EQ(dummy_data->size(), data->size()); @@ -161,15 +160,15 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewDraftPages) { &data); EXPECT_FALSE(data); - preview_ui->SetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX + 1, - dummy_data.get()); + preview_ui->SetPrintPreviewDataForIndexForTest(printing::FIRST_PAGE_INDEX + 1, + dummy_data.get()); preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX + 1, &data); EXPECT_EQ(dummy_data->size(), data->size()); EXPECT_EQ(dummy_data.get(), data.get()); // Clear the preview data. - preview_ui->ClearAllPreviewData(); + preview_ui->ClearAllPreviewDataForTest(); preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data); EXPECT_FALSE(data); } diff --git a/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_handler.cc b/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_handler.cc index 8c70d1bccbd..6d2752f9c00 100644 --- a/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_handler.cc +++ b/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_handler.cc @@ -45,8 +45,7 @@ void QuotaInternalsHandler::ReportGlobalInfo(const GlobalStorageInfo& data) { void QuotaInternalsHandler::ReportPerHostInfo( const std::vector<PerHostStorageInfo>& hosts) { base::ListValue values; - typedef std::vector<PerHostStorageInfo>::const_iterator iterator; - for (iterator itr(hosts.begin()); itr != hosts.end(); ++itr) { + for (auto itr(hosts.begin()); itr != hosts.end(); ++itr) { values.Append(itr->NewValue()); } @@ -56,8 +55,7 @@ void QuotaInternalsHandler::ReportPerHostInfo( void QuotaInternalsHandler::ReportPerOriginInfo( const std::vector<PerOriginStorageInfo>& origins) { base::ListValue origins_value; - typedef std::vector<PerOriginStorageInfo>::const_iterator iterator; - for (iterator itr(origins.begin()); itr != origins.end(); ++itr) { + for (auto itr(origins.begin()); itr != origins.end(); ++itr) { origins_value.Append(itr->NewValue()); } @@ -66,8 +64,7 @@ void QuotaInternalsHandler::ReportPerOriginInfo( void QuotaInternalsHandler::ReportStatistics(const Statistics& stats) { base::DictionaryValue dict; - typedef Statistics::const_iterator iterator; - for (iterator itr(stats.begin()); itr != stats.end(); ++itr) { + for (auto itr(stats.begin()); itr != stats.end(); ++itr) { dict.SetString(itr->first, itr->second); } diff --git a/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_proxy.cc b/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_proxy.cc index a5648eea2a1..4e6b381086d 100644 --- a/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_proxy.cc +++ b/chromium/chrome/browser/ui/webui/quota_internals/quota_internals_proxy.cc @@ -8,10 +8,13 @@ #include <string> #include "base/bind.h" +#include "base/task/post_task.h" #include "base/trace_event/trace_event.h" #include "chrome/browser/ui/webui/quota_internals/quota_internals_handler.h" #include "chrome/browser/ui/webui/quota_internals/quota_internals_types.h" +#include "content/public/browser/browser_task_traits.h" #include "net/base/url_util.h" +#include "url/origin.h" using blink::mojom::StorageType; using content::BrowserThread; @@ -27,8 +30,8 @@ void QuotaInternalsProxy::RequestInfo( scoped_refptr<storage::QuotaManager> quota_manager) { DCHECK(quota_manager.get()); if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, + base::PostTaskWithTraits( + FROM_HERE, {BrowserThread::IO}, base::BindOnce(&QuotaInternalsProxy::RequestInfo, this, quota_manager)); return; } @@ -63,8 +66,7 @@ void QuotaInternalsProxy::RequestInfo( base::Bind(&QuotaInternalsProxy::DidDumpOriginInfoTable, weak_factory_.GetWeakPtr())); - std::map<std::string, std::string> stats; - quota_manager_->GetStatistics(&stats); + std::map<std::string, std::string> stats = quota_manager_->GetStatistics(); ReportStatistics(stats); } @@ -75,8 +77,8 @@ QuotaInternalsProxy::~QuotaInternalsProxy() {} if (!handler_) \ return; \ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { \ - BrowserThread::PostTask( \ - BrowserThread::UI, FROM_HERE, \ + base::PostTaskWithTraits( \ + FROM_HERE, {BrowserThread::UI}, \ base::BindOnce(&QuotaInternalsProxy::func, this, arg)); \ return; \ } \ @@ -121,8 +123,7 @@ void QuotaInternalsProxy::DidDumpQuotaTable(const QuotaTableEntries& entries) { std::vector<PerHostStorageInfo> host_info; host_info.reserve(entries.size()); - typedef QuotaTableEntries::const_iterator iterator; - for (iterator itr(entries.begin()); itr != entries.end(); ++itr) { + for (auto itr(entries.begin()); itr != entries.end(); ++itr) { PerHostStorageInfo info(itr->host, itr->type); info.set_quota(itr->quota); host_info.push_back(info); @@ -136,12 +137,11 @@ void QuotaInternalsProxy::DidDumpOriginInfoTable( std::vector<PerOriginStorageInfo> origin_info; origin_info.reserve(entries.size()); - typedef OriginInfoTableEntries::const_iterator iterator; - for (iterator itr(entries.begin()); itr != entries.end(); ++itr) { - PerOriginStorageInfo info(itr->origin, itr->type); - info.set_used_count(itr->used_count); - info.set_last_access_time(itr->last_access_time); - info.set_last_modified_time(itr->last_modified_time); + for (const auto& entry : entries) { + PerOriginStorageInfo info(entry.origin.GetURL(), entry.type); + info.set_used_count(entry.used_count); + info.set_last_access_time(entry.last_access_time); + info.set_last_modified_time(entry.last_modified_time); origin_info.push_back(info); } @@ -173,7 +173,7 @@ void QuotaInternalsProxy::DidGetHostUsage(const std::string& host, void QuotaInternalsProxy::RequestPerOriginInfo(StorageType type) { DCHECK(quota_manager_.get()); - std::set<GURL> origins; + std::set<url::Origin> origins; quota_manager_->GetCachedOrigins(type, &origins); std::vector<PerOriginStorageInfo> origin_info; @@ -182,13 +182,12 @@ void QuotaInternalsProxy::RequestPerOriginInfo(StorageType type) { std::set<std::string> hosts; std::vector<PerHostStorageInfo> host_info; - for (std::set<GURL>::iterator itr(origins.begin()); - itr != origins.end(); ++itr) { - PerOriginStorageInfo info(*itr, type); - info.set_in_use(quota_manager_->IsOriginInUse(*itr)); + for (const url::Origin& origin : origins) { + PerOriginStorageInfo info(origin.GetURL(), type); + info.set_in_use(quota_manager_->IsOriginInUse(origin)); origin_info.push_back(info); - std::string host(net::GetHostOrSpecFromURL(*itr)); + std::string host(net::GetHostOrSpecFromURL(origin.GetURL())); if (hosts.insert(host).second) { PerHostStorageInfo info(host, type); host_info.push_back(info); diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc index 06c2c95e34e..2486208d075 100644 --- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc @@ -96,6 +96,13 @@ struct RegulatoryLabel { const std::string image_url; }; +bool ShouldShowSafetyInfo() { + const std::vector<std::string> board = + base::SplitString(base::SysInfo::GetLsbReleaseBoard(), "-", + base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + return board[0] == "nocturne"; +} + // Returns message that informs user that for update it's better to // connect to a network of one of the allowed types. base::string16 GetAllowedConnectionTypesMessage() { @@ -316,6 +323,15 @@ AboutHandler* AboutHandler::Create(content::WebUIDataSource* html_source, #endif #if defined(OS_CHROMEOS) + html_source->AddBoolean("shouldShowSafetyInfo", ShouldShowSafetyInfo()); +#if defined(GOOGLE_CHROME_BUILD) + html_source->AddString( + "aboutProductSafety", + l10n_util::GetStringUTF16(IDS_ABOUT_SAFETY_INFORMATION)); + html_source->AddString("aboutProductSafetyURL", + base::UTF8ToUTF16(chrome::kChromeUISafetyURL)); +#endif + base::string16 os_license = l10n_util::GetStringFUTF16( IDS_ABOUT_CROS_VERSION_LICENSE, base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); @@ -402,7 +418,7 @@ void AboutHandler::RegisterMessages() { #if defined(OS_CHROMEOS) // Handler for the product label image, which will be shown if available. content::URLDataSource::Add(Profile::FromWebUI(web_ui()), - new chromeos::ImageSource()); + std::make_unique<chromeos::ImageSource>()); #endif } diff --git a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc index 5d5acfd7aed..a3562e851d2 100644 --- a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc @@ -102,11 +102,14 @@ void BrowserLifetimeHandler::HandleFactoryReset( return; } + // TODO(crbug.com/891905): Centralize powerwash restriction checks. policy::BrowserPolicyConnectorChromeOS* connector = g_browser_process->platform_part()->browser_policy_connector_chromeos(); - bool allow_powerwash = !connector->IsEnterpriseManaged() && + bool allow_powerwash = + !connector->IsEnterpriseManaged() && !user_manager::UserManager::Get()->IsLoggedInAsGuest() && - !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser(); + !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser() && + !user_manager::UserManager::Get()->IsLoggedInAsChildUser(); if (!allow_powerwash) return; diff --git a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc index 271e31ac2b6..95f0eff69a1 100644 --- a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc @@ -6,6 +6,7 @@ #include <memory> #include <string> +#include <utility> #include "base/command_line.h" #include "base/feature_list.h" @@ -17,6 +18,7 @@ #include "base/values.h" #include "build/build_config.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h" #include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h" @@ -26,6 +28,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_message_handler.h" +#include "extensions/browser/extension_system.h" #include "ui/base/l10n/l10n_util.h" using safe_browsing::ChromeCleanerController; @@ -38,9 +41,12 @@ namespace { std::unique_ptr<base::ListValue> GetFilesAsListStorage( const std::set<base::FilePath>& files) { auto value = std::make_unique<base::ListValue>(); - for (const base::FilePath& path : files) - value->AppendString(path.value()); - + for (const base::FilePath& path : files) { + auto item = std::make_unique<base::DictionaryValue>(); + item->SetString("dirname", path.DirName().AsEndingWithSeparator().value()); + item->SetString("basename", path.BaseName().value()); + value->Append(std::move(item)); + } return value; } @@ -280,8 +286,11 @@ void ChromeCleanupHandler::HandleStartCleanup(const base::ListValue* args) { base::RecordAction( base::UserMetricsAction("SoftwareReporter.CleanupWebui_StartCleanup")); + extensions::ExtensionService* extension_service = + extensions::ExtensionSystem::Get(profile_)->extension_service(); + controller_->ReplyWithUserResponse( - profile_, + profile_, extension_service, allow_logs_upload ? ChromeCleanerController::UserResponse::kAcceptedWithLogs : ChromeCleanerController::UserResponse::kAcceptedWithoutLogs); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS b/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS new file mode 100644 index 00000000000..a74cbcbbbe0 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/OWNERS @@ -0,0 +1,3 @@ +per-file multidevice_handler*=file://chromeos/services/multidevice_setup/OWNERS + +# COMPONENT: UI>Settings diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc index 125e1427992..ba2d1822086 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 @@ -55,18 +55,14 @@ AccountManagerUIHandler::AccountManagerUIHandler( : account_manager_(account_manager), account_tracker_service_(account_tracker_service), account_mapper_util_(account_tracker_service_), + account_manager_observer_(this), + account_tracker_service_observer_(this), weak_factory_(this) { DCHECK(account_manager_); DCHECK(account_tracker_service_); - - account_manager_->AddObserver(this); - account_tracker_service_->AddObserver(this); } -AccountManagerUIHandler::~AccountManagerUIHandler() { - account_manager_->RemoveObserver(this); - account_tracker_service_->RemoveObserver(this); -} +AccountManagerUIHandler::~AccountManagerUIHandler() = default; void AccountManagerUIHandler::RegisterMessages() { web_ui()->RegisterMessageCallback( @@ -173,9 +169,15 @@ void AccountManagerUIHandler::HandleRemoveAccount(const base::ListValue* args) { account_manager_->RemoveAccount(account_key); } -void AccountManagerUIHandler::OnJavascriptAllowed() {} +void AccountManagerUIHandler::OnJavascriptAllowed() { + account_manager_observer_.Add(account_manager_); + account_tracker_service_observer_.Add(account_tracker_service_); +} -void AccountManagerUIHandler::OnJavascriptDisallowed() {} +void AccountManagerUIHandler::OnJavascriptDisallowed() { + account_manager_observer_.RemoveAll(); + account_tracker_service_observer_.RemoveAll(); +} // |AccountManager::Observer| overrides. // Note: We need to listen on |AccountManager| in addition to @@ -212,10 +214,6 @@ void AccountManagerUIHandler::OnAccountRemoved(const AccountInfo& account_key) { } void AccountManagerUIHandler::RefreshUI() { - if (!IsJavascriptAllowed()) { - return; - } - FireWebUIListener("accounts-changed"); } 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 b1b0b4a6a00..ce57798fd97 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h @@ -10,6 +10,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" +#include "base/scoped_observer.h" #include "chrome/browser/chromeos/account_mapper_util.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" #include "chromeos/account_manager/account_manager.h" @@ -71,6 +72,16 @@ class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler, chromeos::AccountMapperUtil account_mapper_util_; + // An observer for |AccountManager|. Automatically deregisters when |this| is + // destructed. + ScopedObserver<AccountManager, AccountManager::Observer> + account_manager_observer_; + + // An observer for |AccountTrackerService|. Automatically deregisters when + // |this| is destructed. + ScopedObserver<AccountTrackerService, AccountTrackerService::Observer> + account_tracker_service_observer_; + base::WeakPtrFactory<AccountManagerUIHandler> weak_factory_; DISALLOW_COPY_AND_ASSIGN(AccountManagerUIHandler); }; 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 d62f3fb16bb..fc2a1758546 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 @@ -12,6 +12,7 @@ #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/metrics/histogram_macros.h" +#include "base/no_destructor.h" #include "base/path_service.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -155,13 +156,13 @@ void ChangePictureHandler::HandleChooseFile(const base::ListValue* args) { } // Static so we initialize it only once. - CR_DEFINE_STATIC_LOCAL(ui::SelectFileDialog::FileTypeInfo, file_type_info, - (GetUserImageFileTypeInfo())); + static base::NoDestructor<ui::SelectFileDialog::FileTypeInfo> file_type_info( + GetUserImageFileTypeInfo()); select_file_dialog_->SelectFile( ui::SelectFileDialog::SELECT_OPEN_FILE, l10n_util::GetStringUTF16(IDS_DOWNLOAD_TITLE), downloads_path, - &file_type_info, 0, FILE_PATH_LITERAL(""), GetBrowserWindow(), NULL); + file_type_info.get(), 0, FILE_PATH_LITERAL(""), GetBrowserWindow(), NULL); } void ChangePictureHandler::HandleDiscardPhoto(const base::ListValue* args) { 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 4b100018022..63783ab71f7 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc @@ -6,14 +6,17 @@ #include "base/bind_helpers.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h" +#include "chrome/browser/chromeos/crostini/crostini_share_path.h" #include "chrome/browser/chromeos/crostini/crostini_util.h" +#include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/profiles/profile.h" #include "content/public/browser/browser_thread.h" namespace chromeos { namespace settings { -CrostiniHandler::CrostiniHandler() : weak_ptr_factory_(this) {} +CrostiniHandler::CrostiniHandler(Profile* profile) + : profile_(profile), weak_ptr_factory_(this) {} CrostiniHandler::~CrostiniHandler() = default; @@ -26,19 +29,55 @@ void CrostiniHandler::RegisterMessages() { "requestRemoveCrostini", base::BindRepeating(&CrostiniHandler::HandleRequestRemoveCrostini, weak_ptr_factory_.GetWeakPtr())); + web_ui()->RegisterMessageCallback( + "getCrostiniSharedPathsDisplayText", + base::BindRepeating( + &CrostiniHandler::HandleGetCrostiniSharedPathsDisplayText, + weak_ptr_factory_.GetWeakPtr())); + web_ui()->RegisterMessageCallback( + "removeCrostiniSharedPath", + base::BindRepeating(&CrostiniHandler::HandleRemoveCrostiniSharedPath, + weak_ptr_factory_.GetWeakPtr())); } void CrostiniHandler::HandleRequestCrostiniInstallerView( const base::ListValue* args) { AllowJavascript(); ShowCrostiniInstallerView(Profile::FromWebUI(web_ui()), - CrostiniUISurface::kSettings); + crostini::CrostiniUISurface::kSettings); } void CrostiniHandler::HandleRequestRemoveCrostini(const base::ListValue* args) { AllowJavascript(); ShowCrostiniUninstallerView(Profile::FromWebUI(web_ui()), - CrostiniUISurface::kSettings); + crostini::CrostiniUISurface::kSettings); +} + +void CrostiniHandler::HandleGetCrostiniSharedPathsDisplayText( + const base::ListValue* args) { + AllowJavascript(); + CHECK_EQ(2U, args->GetSize()); + std::string callback_id; + const base::ListValue* paths; + CHECK(args->GetString(0, &callback_id)); + CHECK(args->GetList(1, &paths)); + + base::ListValue texts; + for (auto it = paths->begin(); it != paths->end(); ++it) { + texts.AppendString(file_manager::util::GetPathDisplayTextForSettings( + profile_, it->GetString())); + } + ResolveJavascriptCallback(base::Value(callback_id), texts); +} + +void CrostiniHandler::HandleRemoveCrostiniSharedPath( + const base::ListValue* args) { + CHECK_EQ(1U, args->GetSize()); + std::string path; + CHECK(args->GetString(0, &path)); + + crostini::UnsharePath(profile_, crostini::kCrostiniDefaultVmName, + base::FilePath(path), base::DoNothing()); } } // namespace settings 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 1229a331bf4..a43ff984077 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h @@ -8,6 +8,8 @@ #include "base/memory/weak_ptr.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" +class Profile; + namespace crostini { enum class ConciergeClientResult; } @@ -17,7 +19,7 @@ namespace settings { class CrostiniHandler : public ::settings::SettingsPageUIHandler { public: - CrostiniHandler(); + explicit CrostiniHandler(Profile* profile); ~CrostiniHandler() override; // SettingsPageUIHandler @@ -28,7 +30,14 @@ class CrostiniHandler : public ::settings::SettingsPageUIHandler { private: void HandleRequestCrostiniInstallerView(const base::ListValue* args); void HandleRequestRemoveCrostini(const base::ListValue* args); - + // Callback for the "getSharedPathsDisplayText" message. Converts actual + // paths in chromeos to values suitable to display to users. + // E.g. /home/chronos/u-<hash>/Downloads/foo => "Downloads > foo". + void HandleGetCrostiniSharedPathsDisplayText(const base::ListValue* args); + // Remove a specified path from being shared. + void HandleRemoveCrostiniSharedPath(const base::ListValue* args); + + Profile* profile_; // weak_ptr_factory_ should always be last member. base::WeakPtrFactory<CrostiniHandler> weak_ptr_factory_; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc index be85dd83362..7556aa92135 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc @@ -20,6 +20,7 @@ namespace { struct KeyboardsStateResult { + bool has_internal_keyboard = false; bool has_external_non_apple_keyboard = false; bool has_apple_keyboard = false; }; @@ -28,6 +29,9 @@ KeyboardsStateResult GetKeyboardsState() { KeyboardsStateResult result; for (const ui::InputDevice& keyboard : ui::InputDeviceManager::GetInstance()->GetKeyboardDevices()) { + result.has_internal_keyboard |= + (keyboard.type == ui::INPUT_DEVICE_INTERNAL); + const ui::EventRewriterChromeOS::DeviceType type = ui::EventRewriterChromeOS::GetDeviceType(keyboard); if (type == ui::EventRewriterChromeOS::kDeviceAppleKeyboard) { @@ -146,6 +150,8 @@ void KeyboardHandler::UpdateShowKeys() { base::Value(keyboards_state.has_external_non_apple_keyboard)); keyboard_params.SetKey("showAppleCommandKey", base::Value(keyboards_state.has_apple_keyboard)); + keyboard_params.SetKey("hasInternalKeyboard", + base::Value(keyboards_state.has_internal_keyboard)); FireWebUIListener(kShowKeysChangedName, keyboard_params); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc index 7fd0854ab0a..6c907c084c2 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc @@ -47,7 +47,8 @@ class KeyboardHandlerTest : public testing::Test { bool GetLastShowKeysChangedMessage(bool* has_caps_lock_out, bool* has_diamond_key_out, bool* has_external_meta_key_out, - bool* has_apple_command_key_out) + bool* has_apple_command_key_out, + bool* has_internal_search_out) WARN_UNUSED_RESULT { for (auto it = web_ui_.call_data().rbegin(); it != web_ui_.call_data().rend(); ++it) { @@ -70,6 +71,7 @@ class KeyboardHandlerTest : public testing::Test { {"showDiamondKey", has_diamond_key_out}, {"showExternalMetaKey", has_external_meta_key_out}, {"showAppleCommandKey", has_apple_command_key_out}, + {"hasInternalKeyboard", has_internal_search_out}, }; for (const auto& pair : path_to_out_param) { @@ -92,7 +94,7 @@ class KeyboardHandlerTest : public testing::Test { bool has_caps_lock = false; bool ignored = false; if (!GetLastShowKeysChangedMessage(&has_caps_lock, &ignored, &ignored, - &ignored)) { + &ignored, &ignored)) { ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; return false; } @@ -106,7 +108,7 @@ class KeyboardHandlerTest : public testing::Test { bool has_diamond_key = false; bool ignored = false; if (!GetLastShowKeysChangedMessage(&ignored, &has_diamond_key, &ignored, - &ignored)) { + &ignored, &ignored)) { ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; return false; } @@ -120,7 +122,7 @@ class KeyboardHandlerTest : public testing::Test { bool has_external_meta = false; bool ignored = false; if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &has_external_meta, - &ignored)) { + &ignored, &ignored)) { ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; return false; } @@ -134,13 +136,27 @@ class KeyboardHandlerTest : public testing::Test { bool has_apple_command_key = false; bool ignored = false; if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored, - &has_apple_command_key)) { + &has_apple_command_key, &ignored)) { ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; return false; } return has_apple_command_key; } + // Returns true if the last keys-changed message reported that the device has + // an internal keyboard and hence an internal Search key remap option. + // A failure is added if a message wasn't found. + bool HasInternalSearchKey() { + bool has_internal_search_key = false; + bool ignored = false; + if (!GetLastShowKeysChangedMessage(&ignored, &ignored, &ignored, &ignored, + &has_internal_search_key)) { + ADD_FAILURE() << "Didn't get " << KeyboardHandler::kShowKeysChangedName; + return false; + } + return has_internal_search_key; + } + ws::InputDeviceClientTestApi input_device_client_test_api_; content::TestWebUI web_ui_; TestKeyboardHandler handler_; @@ -154,6 +170,7 @@ TEST_F(KeyboardHandlerTest, DefaultKeys) { base::CommandLine::ForCurrentProcess()->AppendSwitch( chromeos::switches::kHasChromeOSKeyboard); handler_test_api_.Initialize(); + EXPECT_FALSE(HasInternalSearchKey()); EXPECT_FALSE(HasCapsLock()); EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasExternalMetaKey()); @@ -164,6 +181,7 @@ TEST_F(KeyboardHandlerTest, NonChromeOSKeyboard) { // If kHasChromeOSKeyboard isn't passed, we should assume there's a Caps Lock // key. handler_test_api_.Initialize(); + EXPECT_FALSE(HasInternalSearchKey()); EXPECT_TRUE(HasCapsLock()); EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasExternalMetaKey()); @@ -177,6 +195,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ {1, ui::INPUT_DEVICE_INTERNAL, "internal keyboard"}}); handler_test_api_.Initialize(); + EXPECT_TRUE(HasInternalSearchKey()); EXPECT_FALSE(HasCapsLock()); EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasExternalMetaKey()); @@ -185,7 +204,9 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { // Simulate an external keyboard being connected. We should assume there's a // Caps Lock and Meta keys now. input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ - {2, ui::INPUT_DEVICE_EXTERNAL, "external keyboard"}}); + {1, ui::INPUT_DEVICE_INTERNAL, "internal keyboard"}, + {2, ui::INPUT_DEVICE_USB, "external keyboard"}}); + EXPECT_TRUE(HasInternalSearchKey()); EXPECT_TRUE(HasCapsLock()); EXPECT_FALSE(HasDiamondKey()); EXPECT_TRUE(HasExternalMetaKey()); @@ -194,7 +215,9 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { // Simulate an external Apple keyboard being connected. Now users can remap // the command key. input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ - {3, ui::INPUT_DEVICE_EXTERNAL, "Apple Inc. Apple Keyboard"}}); + {1, ui::INPUT_DEVICE_INTERNAL, "internal keyboard"}, + {3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}}); + EXPECT_TRUE(HasInternalSearchKey()); EXPECT_TRUE(HasCapsLock()); EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasExternalMetaKey()); @@ -203,8 +226,9 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { // Simulate two external keyboards (Apple and non-Apple) are connected at the // same time. input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ - {2, ui::INPUT_DEVICE_EXTERNAL, "external keyboard"}, - {3, ui::INPUT_DEVICE_EXTERNAL, "Apple Inc. Apple Keyboard"}}); + {2, ui::INPUT_DEVICE_USB, "external keyboard"}, + {3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}}); + EXPECT_FALSE(HasInternalSearchKey()); EXPECT_TRUE(HasCapsLock()); EXPECT_FALSE(HasDiamondKey()); EXPECT_TRUE(HasExternalMetaKey()); @@ -215,7 +239,8 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { // should show the capslock and external meta remapping. // https://crbug.com/834594. input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{ - {4, ui::INPUT_DEVICE_EXTERNAL, "Topre Corporation Realforce 87"}}); + {4, ui::INPUT_DEVICE_USB, "Topre Corporation Realforce 87"}}); + EXPECT_FALSE(HasInternalSearchKey()); EXPECT_TRUE(HasCapsLock()); EXPECT_FALSE(HasDiamondKey()); EXPECT_TRUE(HasExternalMetaKey()); @@ -223,6 +248,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) { // Disconnect the external keyboard and check that the key goes away. input_device_client_test_api_.SetKeyboardDevices({}); + EXPECT_FALSE(HasInternalSearchKey()); EXPECT_FALSE(HasCapsLock()); EXPECT_FALSE(HasDiamondKey()); EXPECT_FALSE(HasExternalMetaKey()); diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc index c11fa3d9e8b..e7a3a9f34fa 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc @@ -47,6 +47,36 @@ base::string16 GetBatteryTimeText(base::TimeDelta time_left) { time_left); } +int PowerSourceToDisplayId( + const power_manager::PowerSupplyProperties_PowerSource& source) { + switch (source.port()) { + case power_manager::PowerSupplyProperties_PowerSource_Port_UNKNOWN: + return IDS_POWER_SOURCE_PORT_UNKNOWN; + case power_manager::PowerSupplyProperties_PowerSource_Port_LEFT: + return IDS_POWER_SOURCE_PORT_LEFT; + case power_manager::PowerSupplyProperties_PowerSource_Port_RIGHT: + return IDS_POWER_SOURCE_PORT_RIGHT; + case power_manager::PowerSupplyProperties_PowerSource_Port_BACK: + return IDS_POWER_SOURCE_PORT_BACK; + case power_manager::PowerSupplyProperties_PowerSource_Port_FRONT: + return IDS_POWER_SOURCE_PORT_FRONT; + case power_manager::PowerSupplyProperties_PowerSource_Port_LEFT_FRONT: + return IDS_POWER_SOURCE_PORT_LEFT_FRONT; + case power_manager::PowerSupplyProperties_PowerSource_Port_LEFT_BACK: + return IDS_POWER_SOURCE_PORT_LEFT_BACK; + case power_manager::PowerSupplyProperties_PowerSource_Port_RIGHT_FRONT: + return IDS_POWER_SOURCE_PORT_RIGHT_FRONT; + case power_manager::PowerSupplyProperties_PowerSource_Port_RIGHT_BACK: + return IDS_POWER_SOURCE_PORT_RIGHT_BACK; + case power_manager::PowerSupplyProperties_PowerSource_Port_BACK_LEFT: + return IDS_POWER_SOURCE_PORT_BACK_LEFT; + case power_manager::PowerSupplyProperties_PowerSource_Port_BACK_RIGHT: + return IDS_POWER_SOURCE_PORT_BACK_RIGHT; + } + NOTREACHED(); + return 0; +} + } // namespace const char PowerHandler::kPowerManagementSettingsChangedName[] = @@ -302,7 +332,7 @@ void PowerHandler::SendPowerSources() { dict->SetString("id", source.id()); dict->SetBoolean("is_dedicated_charger", source.active_by_default()); dict->SetString("description", - ash::power_utils::PowerSourceToDisplayString(source)); + l10n_util::GetStringUTF16(PowerSourceToDisplayId(source))); sources_list.Append(std::move(dict)); } 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 cf29c548765..e2b4af37067 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 @@ -328,7 +328,7 @@ void StorageHandler::OnGetAndroidSize(bool succeeded, } void StorageHandler::UpdateCrostiniSize() { - if (!IsCrostiniEnabled(profile_)) { + if (!crostini::IsCrostiniEnabled(profile_)) { return; } @@ -336,8 +336,7 @@ void StorageHandler::UpdateCrostiniSize() { return; updating_crostini_size_ = true; - crostini::CrostiniManager::GetInstance()->ListVmDisks( - CryptohomeIdForProfile(profile_), + crostini::CrostiniManager::GetForProfile(profile_)->ListVmDisks( base::BindOnce(&StorageHandler::OnGetCrostiniSize, weak_ptr_factory_.GetWeakPtr())); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.cc index 2735420c270..371edb36ef3 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler.cc @@ -41,6 +41,10 @@ EasyUnlockSettingsHandler* EasyUnlockSettingsHandler::Create( html_source->AddBoolean("easyUnlockAllowed", allowed); html_source->AddBoolean("easyUnlockEnabled", allowed ? easy_unlock_service->IsEnabled() : false); + // TODO(crbug.com/894585): Remove this legacy special case after M71. + html_source->AddBoolean("easyUnlockInLegacyHostMode", + allowed && easy_unlock_service->IsInLegacyHostMode()); + if (!allowed) return nullptr; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc index f30ce4ca6d8..f69e29ce1a1 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc @@ -6,6 +6,7 @@ #include <memory> +#include "base/bind.h" #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h" #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_factory.h" #include "chrome/test/base/testing_profile.h" @@ -105,8 +106,9 @@ class EasyUnlockSettingsHandlerTest : public testing::Test { void SetUp() override { TestingProfile::Builder builder; - builder.AddTestingFactory(EasyUnlockServiceFactory::GetInstance(), - &CreateEasyUnlockServiceForTest); + builder.AddTestingFactory( + EasyUnlockServiceFactory::GetInstance(), + base::BindRepeating(&CreateEasyUnlockServiceForTest)); profile_ = builder.Build(); } @@ -119,8 +121,9 @@ class EasyUnlockSettingsHandlerTest : public testing::Test { void MakeEasyUnlockServiceNull() { TestingProfile::Builder builder; - builder.AddTestingFactory(EasyUnlockServiceFactory::GetInstance(), - &CreateNullEasyUnlockServiceForTest); + builder.AddTestingFactory( + EasyUnlockServiceFactory::GetInstance(), + base::BindRepeating(&CreateNullEasyUnlockServiceForTest)); profile_ = builder.Build(); } 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 36ef94d7f31..c9f32d271f2 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.cc @@ -7,10 +7,20 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/logging.h" +#include "base/values.h" +#include "chrome/browser/chromeos/android_sms/android_sms_urls.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/multidevice_setup/android_sms_app_helper_delegate_impl.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h" #include "chromeos/components/proximity_auth/logging/logging.h" +#include "chromeos/components/proximity_auth/proximity_auth_pref_names.h" +#include "chromeos/services/multidevice_setup/public/cpp/prefs.h" +#include "components/content_settings/core/common/content_settings_pattern.h" +#include "components/prefs/pref_service.h" #include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_message_handler.h" namespace chromeos { @@ -25,6 +35,9 @@ const char kPageContentDataInstantTetheringStateKey[] = "instantTetheringState"; const char kPageContentDataMessagesStateKey[] = "messagesState"; const char kPageContentDataSmartLockStateKey[] = "smartLockState"; +constexpr char kAndroidSmsInfoOriginKey[] = "origin"; +constexpr char kAndroidSmsInfoEnabledKey[] = "enabled"; + void OnRetrySetHostNowResult(bool success) { if (success) return; @@ -36,13 +49,17 @@ void OnRetrySetHostNowResult(bool success) { } // namespace MultideviceHandler::MultideviceHandler( + PrefService* prefs, multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client, std::unique_ptr<multidevice_setup::AndroidSmsAppHelperDelegate> android_sms_app_helper) - : multidevice_setup_client_(multidevice_setup_client), + : prefs_(prefs), + multidevice_setup_client_(multidevice_setup_client), android_sms_app_helper_(std::move(android_sms_app_helper)), multidevice_setup_observer_(this), - callback_weak_ptr_factory_(this) {} + callback_weak_ptr_factory_(this) { + RegisterPrefChangeListeners(); +} MultideviceHandler::~MultideviceHandler() {} @@ -71,14 +88,32 @@ void MultideviceHandler::RegisterMessages() { "setUpAndroidSms", base::BindRepeating(&MultideviceHandler::HandleSetUpAndroidSms, base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "getSmartLockSignInEnabled", + base::BindRepeating(&MultideviceHandler::HandleGetSmartLockSignInEnabled, + base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "setSmartLockSignInEnabled", + base::BindRepeating(&MultideviceHandler::HandleSetSmartLockSignInEnabled, + base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "getSmartLockSignInAllowed", + base::BindRepeating(&MultideviceHandler::HandleGetSmartLockSignInAllowed, + base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "getAndroidSmsInfo", + base::BindRepeating(&MultideviceHandler::HandleGetAndroidSmsInfo, + base::Unretained(this))); } void MultideviceHandler::OnJavascriptAllowed() { - multidevice_setup_observer_.Add(multidevice_setup_client_); + if (multidevice_setup_client_) + multidevice_setup_observer_.Add(multidevice_setup_client_); } void MultideviceHandler::OnJavascriptDisallowed() { - multidevice_setup_observer_.Remove(multidevice_setup_client_); + if (multidevice_setup_client_) + multidevice_setup_observer_.Remove(multidevice_setup_client_); // Ensure that pending callbacks do not complete and cause JS to be evaluated. callback_weak_ptr_factory_.InvalidateWeakPtrs(); @@ -88,22 +123,31 @@ void MultideviceHandler::OnHostStatusChanged( const multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice& host_status_with_device) { UpdatePageContent(); + NotifyAndroidSmsInfoChange(); } void MultideviceHandler::OnFeatureStatesChanged( const multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap& feature_states_map) { UpdatePageContent(); + NotifyAndroidSmsInfoChange(); } void MultideviceHandler::UpdatePageContent() { std::unique_ptr<base::DictionaryValue> page_content_dictionary = GeneratePageContentDataDictionary(); DCHECK(page_content_dictionary); + PA_LOG(INFO) << "Updating MultiDevice settings page content with: " + << *page_content_dictionary << "."; FireWebUIListener("settings.updateMultidevicePageContentData", *page_content_dictionary); } +void MultideviceHandler::NotifyAndroidSmsInfoChange() { + auto android_sms_info = GenerateAndroidSmsInfo(); + FireWebUIListener("settings.onAndroidSmsInfoChange", *android_sms_info); +} + void MultideviceHandler::HandleShowMultiDeviceSetupDialog( const base::ListValue* args) { DCHECK(args->empty()); @@ -122,6 +166,8 @@ void MultideviceHandler::HandleGetPageContent(const base::ListValue* args) { std::unique_ptr<base::DictionaryValue> page_content_dictionary = GeneratePageContentDataDictionary(); DCHECK(page_content_dictionary); + PA_LOG(INFO) << "Responding to getPageContentData() request with: " + << *page_content_dictionary << "."; ResolveJavascriptCallback(base::Value(callback_id), *page_content_dictionary); } @@ -167,9 +213,82 @@ void MultideviceHandler::HandleRetryPendingHostSetup( } void MultideviceHandler::HandleSetUpAndroidSms(const base::ListValue* args) { - PA_LOG(WARNING) << "HandlingSetupSms"; + PA_LOG(INFO) << "SetUpSMS triggered."; DCHECK(args->empty()); - android_sms_app_helper_->LaunchAndroidSmsApp(); + android_sms_app_helper_->InstallAndLaunchAndroidSmsApp(); +} + +void MultideviceHandler::HandleGetSmartLockSignInEnabled( + const base::ListValue* args) { + std::string callback_id; + CHECK(args->GetString(0, &callback_id)); + + bool signInEnabled = prefs_->GetBoolean( + proximity_auth::prefs::kProximityAuthIsChromeOSLoginEnabled); + ResolveJavascriptCallback(base::Value(callback_id), + base::Value(signInEnabled)); +} + +void MultideviceHandler::HandleSetSmartLockSignInEnabled( + const base::ListValue* args) { + bool enabled = false; + CHECK(args->GetBoolean(0, &enabled)); + + std::string auth_token; + bool auth_token_present = args->GetString(1, &auth_token); + + // Either the user is disabling sign-in, or they are enabling it and the auth + // token must be present. + CHECK(!enabled || auth_token_present); + + // Only check auth token if the user is attempting to enable sign-in. + if (enabled && !IsAuthTokenValid(auth_token)) + return; + + prefs_->SetBoolean( + proximity_auth::prefs::kProximityAuthIsChromeOSLoginEnabled, enabled); +} + +void MultideviceHandler::HandleGetSmartLockSignInAllowed( + const base::ListValue* args) { + std::string callback_id; + CHECK(args->GetString(0, &callback_id)); + + bool sign_in_allowed = + prefs_->GetBoolean(multidevice_setup::kSmartLockSigninAllowedPrefName); + ResolveJavascriptCallback(base::Value(callback_id), + base::Value(sign_in_allowed)); +} + +std::unique_ptr<base::DictionaryValue> +MultideviceHandler::GenerateAndroidSmsInfo() { + auto android_sms_info = std::make_unique<base::DictionaryValue>(); + android_sms_info->SetString( + kAndroidSmsInfoOriginKey, + ContentSettingsPattern::FromURLNoWildcard( + chromeos::android_sms::GetAndroidMessagesURL()) + .ToString()); + + chromeos::multidevice_setup::mojom::FeatureState messages_state = + multidevice_setup_client_->GetFeatureState( + chromeos::multidevice_setup::mojom::Feature::kMessages); + bool enabled_state = + messages_state == + chromeos::multidevice_setup::mojom::FeatureState::kEnabledByUser || + messages_state == chromeos::multidevice_setup::mojom::FeatureState:: + kFurtherSetupRequired; + android_sms_info->SetBoolean(kAndroidSmsInfoEnabledKey, enabled_state); + + return android_sms_info; +} + +void MultideviceHandler::HandleGetAndroidSmsInfo(const base::ListValue* args) { + AllowJavascript(); + CHECK_EQ(1U, args->GetSize()); + const base::Value* callback_id; + CHECK(args->Get(0, &callback_id)); + + ResolveJavascriptCallback(*callback_id, *GenerateAndroidSmsInfo()); } void MultideviceHandler::OnSetFeatureStateEnabledResult( @@ -183,9 +302,9 @@ MultideviceHandler::GeneratePageContentDataDictionary() { auto page_content_dictionary = std::make_unique<base::DictionaryValue>(); multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice - host_status_with_device = multidevice_setup_client_->GetHostStatus(); + host_status_with_device = GetHostStatusWithDevice(); multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap feature_states = - multidevice_setup_client_->GetFeatureStates(); + GetFeatureStatesMap(); page_content_dictionary->SetInteger( kPageContentDataModeKey, @@ -217,6 +336,62 @@ MultideviceHandler::GeneratePageContentDataDictionary() { return page_content_dictionary; } +void MultideviceHandler::RegisterPrefChangeListeners() { + pref_change_registrar_.Init(prefs_); + pref_change_registrar_.Add( + proximity_auth::prefs::kProximityAuthIsChromeOSLoginEnabled, + base::BindRepeating( + &MultideviceHandler::NotifySmartLockSignInEnabledChanged, + base::Unretained(this))); + pref_change_registrar_.Add( + multidevice_setup::kSmartLockSigninAllowedPrefName, + base::BindRepeating( + &MultideviceHandler::NotifySmartLockSignInAllowedChanged, + base::Unretained(this))); +} + +void MultideviceHandler::NotifySmartLockSignInEnabledChanged() { + AllowJavascript(); + + bool sign_in_enabled = prefs_->GetBoolean( + proximity_auth::prefs::kProximityAuthIsChromeOSLoginEnabled); + FireWebUIListener("smart-lock-signin-enabled-changed", + base::Value(sign_in_enabled)); +} + +void MultideviceHandler::NotifySmartLockSignInAllowedChanged() { + bool sign_in_allowed = + prefs_->GetBoolean(multidevice_setup::kSmartLockSigninAllowedPrefName); + FireWebUIListener("smart-lock-signin-allowed-changed", + base::Value(sign_in_allowed)); +} + +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(); +} + +multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice +MultideviceHandler::GetHostStatusWithDevice() { + if (multidevice_setup_client_) + return multidevice_setup_client_->GetHostStatus(); + + return multidevice_setup::MultiDeviceSetupClient:: + GenerateDefaultHostStatusWithDevice(); +} + +multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap +MultideviceHandler::GetFeatureStatesMap() { + if (multidevice_setup_client_) + return multidevice_setup_client_->GetFeatureStates(); + + return multidevice_setup::MultiDeviceSetupClient:: + GenerateDefaultFeatureStatesMap(); +} + } // namespace settings } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h index cc5e9037e95..f585da37302 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h @@ -12,6 +12,13 @@ #include "chromeos/services/multidevice_setup/public/cpp/multidevice_setup_client.h" #include "chromeos/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h" #include "components/cryptauth/remote_device_ref.h" +#include "components/prefs/pref_change_registrar.h" + +class PrefService; + +namespace base { +class DictionaryValue; +} // namespace base namespace chromeos { @@ -26,7 +33,8 @@ class MultideviceHandler : public ::settings::SettingsPageUIHandler, public multidevice_setup::MultiDeviceSetupClient::Observer { public: - explicit MultideviceHandler( + MultideviceHandler( + PrefService* prefs, multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client, std::unique_ptr<multidevice_setup::AndroidSmsAppHelperDelegate> android_sms_app_helper); @@ -59,15 +67,42 @@ class MultideviceHandler void HandleRemoveHostDevice(const base::ListValue* args); void HandleRetryPendingHostSetup(const base::ListValue* args); void HandleSetUpAndroidSms(const base::ListValue* args); + void HandleGetSmartLockSignInEnabled(const base::ListValue* args); + void HandleSetSmartLockSignInEnabled(const base::ListValue* args); + void HandleGetSmartLockSignInAllowed(const base::ListValue* args); + void HandleGetAndroidSmsInfo(const base::ListValue* args); void OnSetFeatureStateEnabledResult(const std::string& js_callback_id, bool success); + void RegisterPrefChangeListeners(); + void NotifySmartLockSignInEnabledChanged(); + void NotifySmartLockSignInAllowedChanged(); + // Generate android sms info dictionary containing the messages for web + // content settings origin url and messages feature state. + std::unique_ptr<base::DictionaryValue> GenerateAndroidSmsInfo(); + void NotifyAndroidSmsInfoChange(); + + // Returns true if |auth_token| matches the current auth token stored in + // QuickUnlockStorage, i.e., the user has successfully authenticated recently. + bool IsAuthTokenValid(const std::string& auth_token); + + // Unowned pointer to the preferences service. + PrefService* prefs_; + + // Registers preference value change listeners. + PrefChangeRegistrar pref_change_registrar_; + // Returns null if requisite data has not yet been fetched (i.e., if one or // both of |last_host_status_update_| and |last_feature_states_update_| is // null). std::unique_ptr<base::DictionaryValue> GeneratePageContentDataDictionary(); + multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice + GetHostStatusWithDevice(); + multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap + GetFeatureStatesMap(); + multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client_; std::unique_ptr<multidevice_setup::AndroidSmsAppHelperDelegate> android_sms_app_helper_; diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc index 658795d6c18..82e27cd59e4 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/multidevice_handler_unittest.cc @@ -7,9 +7,12 @@ #include <memory> #include "base/macros.h" +#include "chrome/browser/chromeos/android_sms/android_sms_urls.h" #include "chromeos/services/multidevice_setup/public/cpp/fake_android_sms_app_helper_delegate.h" #include "chromeos/services/multidevice_setup/public/cpp/fake_multidevice_setup_client.h" +#include "components/content_settings/core/common/content_settings_pattern.h" #include "components/cryptauth/remote_device_test_util.h" +#include "components/prefs/testing_pref_service.h" #include "content/public/test/test_web_ui.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,10 +25,12 @@ namespace { class TestMultideviceHandler : public MultideviceHandler { public: TestMultideviceHandler( + PrefService* prefs, multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client, std::unique_ptr<multidevice_setup::AndroidSmsAppHelperDelegate> android_sms_app_helper) - : MultideviceHandler(multidevice_setup_client, + : MultideviceHandler(prefs, + multidevice_setup_client, std::move(android_sms_app_helper)) {} ~TestMultideviceHandler() override = default; @@ -116,8 +121,10 @@ class MultideviceHandlerTest : public testing::Test { fake_android_sms_app_helper_delegate_ = fake_android_sms_app_helper_delegate.get(); + prefs_.reset(new TestingPrefServiceSimple()); + handler_ = std::make_unique<TestMultideviceHandler>( - fake_multidevice_setup_client_.get(), + prefs_.get(), fake_multidevice_setup_client_.get(), std::move(fake_android_sms_app_helper_delegate)); handler_->set_web_ui(test_web_ui_.get()); handler_->RegisterMessages(); @@ -151,6 +158,27 @@ class MultideviceHandlerTest : public testing::Test { fake_multidevice_setup_client()->num_remove_host_device_called()); } + void CallGetAndroidSmsInfo(bool enabled) { + size_t call_data_count_before_call = test_web_ui()->call_data().size(); + + base::ListValue args; + args.AppendString("handlerFunctionName"); + test_web_ui()->HandleReceivedMessage("getAndroidSmsInfo", &args); + + ASSERT_EQ(call_data_count_before_call + 1u, + test_web_ui()->call_data().size()); + const content::TestWebUI::CallData& call_data = + CallDataAtIndex(call_data_count_before_call); + EXPECT_EQ("cr.webUIResponse", call_data.function_name()); + EXPECT_EQ("handlerFunctionName", call_data.arg1()->GetString()); + ASSERT_TRUE(call_data.arg2()->GetBool()); + EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard( + chromeos::android_sms::GetAndroidMessagesURL()) + .ToString(), + call_data.arg3()->FindKey("origin")->GetString()); + EXPECT_EQ(enabled, call_data.arg3()->FindKey("enabled")->GetBool()); + } + void SimulateHostStatusUpdate( multidevice_setup::mojom::HostStatus host_status, const base::Optional<cryptauth::RemoteDeviceRef>& host_device) { @@ -158,7 +186,7 @@ class MultideviceHandlerTest : public testing::Test { fake_multidevice_setup_client_->SetHostStatusWithDevice( std::make_pair(host_status, host_device)); - EXPECT_EQ(call_data_count_before_call + 1u, + EXPECT_EQ(call_data_count_before_call + 2u, test_web_ui()->call_data().size()); const content::TestWebUI::CallData& call_data = @@ -175,7 +203,7 @@ class MultideviceHandlerTest : public testing::Test { size_t call_data_count_before_call = test_web_ui()->call_data().size(); fake_multidevice_setup_client_->SetFeatureStates(feature_states_map); - EXPECT_EQ(call_data_count_before_call + 1u, + EXPECT_EQ(call_data_count_before_call + 2u, test_web_ui()->call_data().size()); const content::TestWebUI::CallData& call_data = @@ -254,6 +282,7 @@ class MultideviceHandlerTest : public testing::Test { fake_multidevice_setup_client_->GetFeatureStates()); } + std::unique_ptr<TestingPrefServiceSimple> prefs_; std::unique_ptr<content::TestWebUI> test_web_ui_; std::unique_ptr<multidevice_setup::FakeMultiDeviceSetupClient> fake_multidevice_setup_client_; @@ -302,8 +331,10 @@ TEST_F(MultideviceHandlerTest, RetryPendingHostSetup) { } TEST_F(MultideviceHandlerTest, SetUpAndroidSms) { + EXPECT_FALSE(fake_android_sms_app_helper_delegate()->HasInstalledApp()); EXPECT_FALSE(fake_android_sms_app_helper_delegate()->HasLaunchedApp()); CallSetUpAndroidSms(); + EXPECT_TRUE(fake_android_sms_app_helper_delegate()->HasInstalledApp()); EXPECT_TRUE(fake_android_sms_app_helper_delegate()->HasLaunchedApp()); } @@ -325,6 +356,28 @@ TEST_F(MultideviceHandlerTest, RemoveHostDevice) { CallRemoveHostDevice(); } +TEST_F(MultideviceHandlerTest, GetAndroidSmsInfo) { + // Check that getAndroidSmsInfo returns correct value. + CallGetAndroidSmsInfo(false /* enabled */); + + // Change messages feature state and assert that the change + // callback is fired. + multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap + feature_states_map = GenerateDefaultFeatureStatesMap(); + feature_states_map[multidevice_setup::mojom::Feature::kMessages] = + multidevice_setup::mojom::FeatureState::kEnabledByUser; + + size_t call_data_count_before_call = test_web_ui()->call_data().size(); + SimulateFeatureStatesUpdate(feature_states_map); + const content::TestWebUI::CallData& call_data = + CallDataAtIndex(call_data_count_before_call + 1); + EXPECT_EQ("cr.webUIListenerCallback", call_data.function_name()); + EXPECT_EQ("settings.onAndroidSmsInfoChange", call_data.arg1()->GetString()); + + // Check that getAndroidSmsInfo returns update value. + CallGetAndroidSmsInfo(true /* enabled */); +} + } // namespace settings } // namespace chromeos diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc index ff52076ee4e..fe499876eb0 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc @@ -26,7 +26,7 @@ smb_client::SmbService* GetSmbService(Profile* profile) { base::Value BuildShareList(const std::vector<smb_client::SmbUrl>& shares) { base::Value shares_list(base::Value::Type::LIST); for (const auto& share : shares) { - shares_list.GetList().push_back(base::Value(share.ToString())); + shares_list.GetList().push_back(base::Value(share.GetWindowsUNCString())); } return shares_list; } @@ -49,15 +49,17 @@ void SmbHandler::RegisterMessages() { } void SmbHandler::HandleSmbMount(const base::ListValue* args) { - CHECK_EQ(4U, args->GetSize()); + CHECK_EQ(5U, args->GetSize()); std::string mount_url; std::string mount_name; std::string username; std::string password; + bool use_kerberos; CHECK(args->GetString(0, &mount_url)); CHECK(args->GetString(1, &mount_name)); CHECK(args->GetString(2, &username)); CHECK(args->GetString(3, &password)); + CHECK(args->GetBoolean(4, &use_kerberos)); smb_client::SmbService* const service = GetSmbService(profile_); if (!service) { @@ -70,9 +72,10 @@ void SmbHandler::HandleSmbMount(const base::ListValue* args) { auto mount_response = base::BindOnce(&SmbHandler::HandleSmbMountResponse, weak_ptr_factory_.GetWeakPtr()); - auto mount_call = base::BindOnce( - &smb_client::SmbService::Mount, base::Unretained(service), mo, - base::FilePath(mount_url), username, password, std::move(mount_response)); + auto mount_call = + base::BindOnce(&smb_client::SmbService::Mount, base::Unretained(service), + mo, base::FilePath(mount_url), username, password, + use_kerberos, std::move(mount_response)); if (host_discovery_done_) { std::move(mount_call).Run(); @@ -92,17 +95,22 @@ void SmbHandler::HandleStartDiscovery(const base::ListValue* args) { return; } - service->GatherSharesInNetwork(base::BindRepeating( - &SmbHandler::HandleGatherSharesResponse, weak_ptr_factory_.GetWeakPtr())); + service->GatherSharesInNetwork( + base::BindOnce(&SmbHandler::HandleDiscoveryDone, + weak_ptr_factory_.GetWeakPtr()), + base::BindRepeating(&SmbHandler::HandleGatherSharesResponse, + weak_ptr_factory_.GetWeakPtr())); } -void SmbHandler::HandleGatherSharesResponse( - const std::vector<smb_client::SmbUrl>& shares_gathered) { +void SmbHandler::HandleDiscoveryDone() { host_discovery_done_ = true; if (!stored_mount_call_.is_null()) { std::move(stored_mount_call_).Run(); } +} +void SmbHandler::HandleGatherSharesResponse( + const std::vector<smb_client::SmbUrl>& shares_gathered) { AllowJavascript(); FireWebUIListener("on-shares-found", BuildShareList(shares_gathered)); } diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h index fe6c85db64f..42a5602d593 100644 --- a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h +++ b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h @@ -42,6 +42,9 @@ class SmbHandler : public ::settings::SettingsPageUIHandler { void HandleGatherSharesResponse( const std::vector<smb_client::SmbUrl>& shares_gathered); + // Callback handler that indicates discovery is complete. + void HandleDiscoveryDone(); + bool host_discovery_done_ = false; base::OnceClosure stored_mount_call_; Profile* const profile_; diff --git a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc index 61d21286ab9..de780d05a34 100644 --- a/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/downloads_handler.cc @@ -127,7 +127,8 @@ void DownloadsHandler::HandleGetDownloadLocationText( ResolveJavascriptCallback( base::Value(callback_id), - base::Value(file_manager::util::GetDownloadLocationText(profile_, path))); + base::Value( + file_manager::util::GetPathDisplayTextForSettings(profile_, path))); } #endif diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc index 2c30e7fc48e..c235469b5f0 100644 --- a/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc +++ b/chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc @@ -20,6 +20,7 @@ #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/webui/policy_indicator_localized_strings_provider.h" #include "chrome/common/chrome_features.h" #include "chrome/common/chrome_switches.h" @@ -29,9 +30,10 @@ #include "chrome/grit/locale_settings.h" #include "components/autofill/core/browser/payments/payments_service_url.h" #include "components/autofill/core/browser/payments/payments_util.h" +#include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/common/autofill_constants.h" #include "components/autofill/core/common/autofill_features.h" -#include "components/content_settings/core/common/features.h" +#include "components/browser_sync/profile_sync_service.h" #include "components/google/core/common/google_util.h" #include "components/omnibox/browser/omnibox_field_trial.h" #include "components/password_manager/core/common/password_manager_features.h" @@ -39,6 +41,7 @@ #include "components/signin/core/browser/signin_buildflags.h" #include "components/strings/grit/components_strings.h" #include "components/subresource_filter/core/browser/subresource_filter_features.h" +#include "components/sync/driver/sync_service_utils.h" #include "components/unified_consent/feature.h" #include "content/public/browser/web_ui_data_source.h" #include "content/public/common/content_features.h" @@ -50,7 +53,6 @@ #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_switches.h" #include "ash/public/interfaces/voice_interaction_controller.mojom.h" -#include "ash/strings/grit/ash_strings.h" #include "base/sys_info.h" #include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" @@ -62,7 +64,7 @@ #include "chromeos/chromeos_features.h" #include "chromeos/chromeos_switches.h" #include "chromeos/services/multidevice_setup/public/cpp/url_provider.h" -#include "components/arc/arc_util.h" +#include "chromeos/strings/grit/chromeos_strings.h" #include "components/user_manager/user_manager.h" #include "ui/chromeos/devicetype_utils.h" #include "ui/chromeos/events/keyboard_layout_util.h" @@ -406,6 +408,7 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source) { {"crostiniPageLabel", IDS_SETTINGS_CROSTINI_LABEL}, {"crostiniEnable", IDS_SETTINGS_TURN_ON}, {"crostiniRemove", IDS_SETTINGS_CROSTINI_REMOVE}, + {"crostiniSharedPaths", IDS_SETTINGS_CROSTINI_SHARED_PATHS}, }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); @@ -534,8 +537,6 @@ void AddClearBrowsingDataStrings(content::WebUIDataSource* html_source, {"clearBrowsingHistory", IDS_SETTINGS_CLEAR_BROWSING_HISTORY}, {"clearBrowsingHistorySummary", IDS_SETTINGS_CLEAR_BROWSING_HISTORY_SUMMARY}, - {"clearBrowsingHistorySummarySignedIn", - IDS_SETTINGS_CLEAR_BROWSING_HISTORY_SUMMARY_SYNC_ERROR}, {"clearDownloadHistory", IDS_SETTINGS_CLEAR_DOWNLOAD_HISTORY}, {"clearCache", IDS_SETTINGS_CLEAR_CACHE}, {"clearCookies", IDS_SETTINGS_CLEAR_COOKIES}, @@ -561,6 +562,11 @@ void AddClearBrowsingDataStrings(content::WebUIDataSource* html_source, }; html_source->AddString( + "clearBrowsingHistorySummarySignedIn", + l10n_util::GetStringFUTF16( + IDS_SETTINGS_CLEAR_BROWSING_HISTORY_SUMMARY_SIGNED_IN, + base::ASCIIToUTF16(chrome::kMyActivityUrlInClearBrowsingData))); + html_source->AddString( "clearBrowsingHistorySummarySynced", l10n_util::GetStringFUTF16( IDS_SETTINGS_CLEAR_BROWSING_HISTORY_SUMMARY_SYNCED, @@ -628,6 +634,7 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) { {"keyboardKeyCtrl", IDS_SETTINGS_KEYBOARD_KEY_LEFT_CTRL}, {"keyboardKeyAlt", IDS_SETTINGS_KEYBOARD_KEY_LEFT_ALT}, {"keyboardKeyCapsLock", IDS_SETTINGS_KEYBOARD_KEY_CAPS_LOCK}, + {"keyboardKeyCommand", IDS_SETTINGS_KEYBOARD_KEY_COMMAND}, {"keyboardKeyDiamond", IDS_SETTINGS_KEYBOARD_KEY_DIAMOND}, {"keyboardKeyEscape", IDS_SETTINGS_KEYBOARD_KEY_ESCAPE}, {"keyboardKeyBackspace", IDS_SETTINGS_KEYBOARD_KEY_BACKSPACE}, @@ -635,6 +642,7 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) { {"keyboardKeyExternalCommand", IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_COMMAND}, {"keyboardKeyExternalMeta", IDS_SETTINGS_KEYBOARD_KEY_EXTERNAL_META}, + {"keyboardKeyMeta", IDS_SETTINGS_KEYBOARD_KEY_META}, {"keyboardSendFunctionKeys", IDS_SETTINGS_KEYBOARD_SEND_FUNCTION_KEYS}, {"keyboardSendFunctionKeysDescription", ui::DeviceUsesKeyboardLayout2() @@ -849,6 +857,12 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE}, {"smbShareAddedInvalidURLMessage", IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_INVALID_URL_MESSAGE}, + {"smbShareAuthenticationMethod", + IDS_SETTINGS_DOWNLOADS_ADD_SHARE_AUTHENTICATION_METHOD}, + {"smbShareStandardAuthentication", + IDS_SETTINGS_DOWNLOADS_ADD_SHARE_STANDARD_AUTHENTICATION}, + {"smbShareKerberosAuthentication", + IDS_SETTINGS_DOWNLOADS_ADD_SHARE_KERBEROS_AUTHENTICATION}, #endif }; AddLocalizedStringsBulk(html_source, localized_strings, @@ -1112,6 +1126,10 @@ void AddEasyUnlockStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_EASY_UNLOCK_PROXIMITY_THRESHOLD_FAR}, {"easyUnlockProximityThresholdVeryFar", IDS_SETTINGS_EASY_UNLOCK_PROXIMITY_THRESHOLD_VERY_FAR}, + {"easyUnlockUnlockDeviceOnly", + IDS_SETTINGS_EASY_UNLOCK_UNLOCK_DEVICE_ONLY}, + {"easyUnlockUnlockDeviceAndAllowSignin", + IDS_SETTINGS_EASY_UNLOCK_UNLOCK_DEVICE_AND_ALLOW_SIGNIN}, }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); @@ -1253,7 +1271,7 @@ void AddInternetStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_INTERNET_TETHER_CONNECTION_NOT_NOW_BUTTON}, {"tetherConnectionConnectButton", IDS_SETTINGS_INTERNET_TETHER_CONNECTION_CONNECT_BUTTON}, - {"tetherEnableBluetooth", IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH}, + {"tetherEnableBluetooth", IDS_ENABLE_BLUETOOTH}, }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); @@ -1364,6 +1382,8 @@ void AddChromeOSUserStrings(content::WebUIDataSource* html_source, "secondaryUserBannerText", l10n_util::GetStringFUTF16(IDS_SETTINGS_SECONDARY_USER_BANNER, base::ASCIIToUTF16(primary_user_email))); + html_source->AddBoolean("isActiveDirectoryUser", + user && user->IsActiveDirectoryUser()); policy::BrowserPolicyConnectorChromeOS* connector = g_browser_process->platform_part()->browser_policy_connector_chromeos(); @@ -1508,11 +1528,16 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, autofill::payments::GetManageAddressesUrl(0).spec()); html_source->AddString("manageCreditCardsUrl", autofill::payments::GetManageInstrumentsUrl(0).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); @@ -1521,6 +1546,51 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source, autofill::payments::GetBillingCustomerId(personal_data_manager_, profile->GetPrefs()) != 0); + syncer::SyncService* sync_service = + ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); + if (sync_service && sync_service->CanSyncFeatureStart() && + sync_service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE)) { + html_source->AddBoolean("isUsingSecondaryPassphrase", + sync_service->IsUsingSecondaryPassphrase()); + html_source->AddBoolean( + "uploadToGoogleActive", + base::FeatureList::IsEnabled( + autofill::features:: + kAutofillEnablePaymentsInteractionsOnAuthError) || + syncer::GetUploadToGoogleState( + sync_service, syncer::ModelType::AUTOFILL_WALLET_DATA) == + syncer::UploadState::ACTIVE); + } else { + html_source->AddBoolean("isUsingSecondaryPassphrase", false); + html_source->AddBoolean("uploadToGoogleActive", false); + } + + bool isGuestMode = false; +#if defined(OS_CHROMEOS) + isGuestMode = user_manager::UserManager::Get()->IsLoggedInAsGuest() || + user_manager::UserManager::Get()->IsLoggedInAsPublicAccount(); +#else // !defined(OS_CHROMEOS) + isGuestMode = profile->IsOffTheRecord(); +#endif // defined(OS_CHROMEOS) + + if (isGuestMode) { + 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")); + } + } + AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); @@ -1543,6 +1613,8 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { {"configureFingerprintTitle", IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_TITLE}, {"configureFingerprintInstructionLocateScannerStep", IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER}, + {"configureFingerprintScannerStepAriaLabel", + IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER_ARIA_LABEL}, {"configureFingerprintInstructionReadyStep", IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_READY}, {"configureFingerprintLiftFinger", @@ -1583,6 +1655,8 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) { IDS_SETTINGS_PEOPLE_LOCK_SCREEN_FINGERPRINT_SUBPAGE_TITLE}, {"lockScreenFingerprintWarning", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_FINGERPRINT_LESS_SECURE}, + {"lockScreenDeleteFingerprintLabel", + IDS_SETTINGS_PEOPLE_LOCK_SCREEN_DELETE_FINGERPRINT_ARIA_LABEL}, {"lockScreenNotificationHide", IDS_ASH_SETTINGS_LOCK_SCREEN_NOTIFICATION_HIDE}, {"lockScreenNotificationHideSensitive", @@ -2182,6 +2256,10 @@ void AddGoogleAssistantStrings(content::WebUIDataSource* html_source) { IDS_SETTINGS_GOOGLE_ASSISTANT_ENABLE_NOTIFICATION}, {"googleAssistantEnableNotificationDescription", IDS_SETTINGS_GOOGLE_ASSISTANT_ENABLE_NOTIFICATION_DESCRIPTION}, + {"googleAssistantLaunchWithMicOpen", + IDS_SETTINGS_GOOGLE_ASSISTANT_LAUNCH_WITH_MIC_OPEN}, + {"googleAssistantLaunchWithMicOpenDescription", + IDS_SETTINGS_GOOGLE_ASSISTANT_LAUNCH_WITH_MIC_OPEN_DESCRIPTION}, {"googleAssistantSettings", IDS_SETTINGS_GOOGLE_ASSISTANT_SETTINGS}, }; AddLocalizedStringsBulk(html_source, localized_strings, @@ -2196,6 +2274,9 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, {"addSiteExceptionPlaceholder", IDS_SETTINGS_ADD_SITE_EXCEPTION_PLACEHOLDER}, {"addSiteTitle", IDS_SETTINGS_ADD_SITE_TITLE}, +#if defined(OS_CHROMEOS) + {"androidSmsNote", IDS_SETTINGS_ANDROID_SMS_NOTE}, +#endif {"cookieAppCache", IDS_SETTINGS_COOKIES_APPLICATION_CACHE}, {"cookieCacheStorage", IDS_SETTINGS_COOKIES_CACHE_STORAGE}, {"cookieChannelId", IDS_SETTINGS_COOKIES_CHANNEL_ID}, @@ -2425,9 +2506,10 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, {"siteSettingsSourcePolicyBlock", IDS_PAGE_INFO_PERMISSION_BLOCKED_BY_POLICY}, {"siteSettingsSourcePolicyAsk", IDS_PAGE_INFO_PERMISSION_ASK_BY_POLICY}, - {"siteSettingsAdsBlockSingular", - IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK_SINGULAR}, - {"siteSettingsSourceAdsBlacklist", IDS_PAGE_INFO_PERMISSION_ADS_SUBTITLE}, + {"siteSettingsAdsBlockNotBlacklistedSingular", + IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK_NOT_BLACKLISTED_SINGULAR}, + {"siteSettingsAdsBlockBlacklistedSingular", + IDS_SETTINGS_SITE_SETTINGS_ADS_BLOCK_BLACKLISTED_SINGULAR}, {"siteSettingsSourceDrmDisabled", IDS_SETTINGS_SITE_SETTINGS_SOURCE_DRM_DISABLED}, {"siteSettingsSourceEmbargo", @@ -2512,7 +2594,11 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, html_source->AddBoolean( "enableBlockAutoplayContentSetting", - base::FeatureList::IsEnabled(media::kAutoplaySoundSettings)); + base::FeatureList::IsEnabled(media::kAutoplayDisableSettings)); + + html_source->AddBoolean( + "enableAutoplayWhitelistContentSetting", + base::FeatureList::IsEnabled(media::kAutoplayWhitelistSettings)); html_source->AddBoolean( "enableClipboardContentSetting", @@ -2526,11 +2612,6 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source, "enablePaymentHandlerContentSetting", base::FeatureList::IsEnabled(features::kServiceWorkerPaymentApps)); - html_source->AddBoolean( - "enableEphemeralFlashPermission", - base::FeatureList::IsEnabled( - content_settings::features::kEnableEphemeralFlashPermission)); - if (PluginUtils::ShouldPreferHtmlOverPlugins( HostContentSettingsMapFactory::GetForProfile(profile))) { LocalizedString flash_strings[] = { @@ -2638,15 +2719,17 @@ void AddMultideviceStrings(content::WebUIDataSource* html_source) { {"multideviceSmartLockItemTitle", IDS_SETTINGS_EASY_UNLOCK_SECTION_TITLE}, {"multideviceInstantTetheringItemTitle", IDS_SETTINGS_MULTIDEVICE_INSTANT_TETHERING}, + {"multideviceInstantTetheringItemSummary", + IDS_SETTINGS_MULTIDEVICE_INSTANT_TETHERING_SUMMARY}, {"multideviceAndroidMessagesItemTitle", IDS_SETTINGS_MULTIDEVICE_ANDROID_MESSAGES}, {"multideviceForgetDevice", IDS_SETTINGS_MULTIDEVICE_FORGET_THIS_DEVICE}, {"multideviceForgetDeviceSummary", IDS_SETTINGS_MULTIDEVICE_FORGET_THIS_DEVICE_EXPLANATION}, - {"multideviceForgetDeviceDialogHeading", - IDS_SETTINGS_MULTIDEVICE_FORGET_DEVICE_DIALOG_HEADING}, {"multideviceForgetDeviceDialogMessage", IDS_SETTINGS_MULTIDEVICE_FORGET_DEVICE_DIALOG_MESSAGE}, + {"multideviceSmartLockOptions", + IDS_SETTINGS_PEOPLE_LOCK_SCREEN_OPTIONS_LOCK}, }; AddLocalizedStringsBulk(html_source, localized_strings, arraysize(localized_strings)); @@ -2660,39 +2743,37 @@ void AddMultideviceStrings(content::WebUIDataSource* html_source) { l10n_util::GetStringFUTF16( IDS_SETTINGS_MULTIDEVICE_VERIFICATION_TEXT, base::UTF8ToUTF16( - chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl() - .spec()))); - html_source->AddString( - "multideviceCouldNotConnect", - l10n_util::GetStringFUTF16( - IDS_SETTINGS_MULTIDEVICE_COULD_NOT_CONNECT, - base::UTF8ToUTF16( - chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl() - .spec()))); + chromeos::multidevice_setup:: + GetBoardSpecificBetterTogetherSuiteLearnMoreUrl() + .spec()))); html_source->AddString( "multideviceSetupSummary", l10n_util::GetStringFUTF16( IDS_SETTINGS_MULTIDEVICE_SETUP_SUMMARY, base::UTF8ToUTF16( - chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl() - .spec()))); + chromeos::multidevice_setup:: + GetBoardSpecificBetterTogetherSuiteLearnMoreUrl() + .spec()))); html_source->AddString( "multideviceNoHostText", l10n_util::GetStringFUTF16( IDS_SETTINGS_MULTIDEVICE_NO_ELIGIBLE_HOSTS, base::UTF8ToUTF16( - chromeos::multidevice_setup::GetBoardSpecificLearnMoreUrl() - .spec()))); + chromeos::multidevice_setup:: + GetBoardSpecificBetterTogetherSuiteLearnMoreUrl() + .spec()))); + html_source->AddString( + "multideviceAndroidMessagesItemSummary", + l10n_util::GetStringFUTF16( + IDS_SETTINGS_MULTIDEVICE_ANDROID_MESSAGES_SUMMARY, + base::UTF8ToUTF16(chromeos::multidevice_setup:: + GetBoardSpecificMessagesLearnMoreUrl() + .spec()))); html_source->AddString( "multideviceSmartLockItemSummary", l10n_util::GetStringFUTF16( IDS_SETTINGS_MULTIDEVICE_SMART_LOCK_SUMMARY, GetHelpUrlWithBoard(chrome::kEasyUnlockLearnMoreUrl))); - html_source->AddString( - "multideviceAndroidMessagesItemSummary", - l10n_util::GetStringFUTF16( - IDS_SETTINGS_MULTIDEVICE_ANDROID_MESSAGES_SUMMARY, - GetHelpUrlWithBoard(chrome::kAndroidMessagesLearnMoreURL))); } #endif diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc index fa6dd8d8b36..051c36122b7 100644 --- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc +++ b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc @@ -204,9 +204,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) } AddSettingsPageUIHandler( std::make_unique<chromeos::settings::ChangePictureHandler>()); - if (IsCrostiniUIAllowedForProfile(profile)) { + if (crostini::IsCrostiniUIAllowedForProfile(profile)) { AddSettingsPageUIHandler( - std::make_unique<chromeos::settings::CrostiniHandler>()); + std::make_unique<chromeos::settings::CrostiniHandler>(profile)); } AddSettingsPageUIHandler( std::make_unique<chromeos::settings::CupsPrintersHandler>(web_ui)); @@ -219,13 +219,15 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) } AddSettingsPageUIHandler( std::make_unique<chromeos::settings::KeyboardHandler>()); - if (base::FeatureList::IsEnabled( + if (!profile->IsGuestSession() && + base::FeatureList::IsEnabled( chromeos::features::kEnableUnifiedMultiDeviceSetup) && base::FeatureList::IsEnabled( chromeos::features::kEnableUnifiedMultiDeviceSettings) && base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi)) { AddSettingsPageUIHandler( std::make_unique<chromeos::settings::MultideviceHandler>( + profile->GetPrefs(), chromeos::multidevice_setup::MultiDeviceSetupClientFactory:: GetForProfile(profile), std::make_unique< @@ -244,7 +246,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) std::make_unique<chromeos::settings::InternetHandler>(profile)); AddSettingsPageUIHandler(std::make_unique<TtsHandler>()); #else - AddSettingsPageUIHandler(std::make_unique<DefaultBrowserHandler>(web_ui)); + AddSettingsPageUIHandler(std::make_unique<DefaultBrowserHandler>()); AddSettingsPageUIHandler(std::make_unique<ManageProfileHandler>(profile)); AddSettingsPageUIHandler(std::make_unique<SystemHandler>()); #endif @@ -323,7 +325,7 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) ash::stylus_utils::HasInternalStylus()); html_source->AddBoolean("showCrostini", - IsCrostiniUIAllowedForProfile(profile)); + crostini::IsCrostiniUIAllowedForProfile(profile)); // TODO(crbug.com/868747): Show an explanatory message instead of hiding the // storage management info. diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc index 57fe25578d1..7d6abb49ada 100644 --- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc @@ -65,6 +65,7 @@ #include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h" #include "components/signin/core/browser/signin_manager_base.h" #else +#include "chrome/browser/signin/signin_util.h" #include "chrome/browser/ui/user_manager.h" #include "chrome/browser/ui/webui/profile_helper.h" #include "components/signin/core/browser/signin_manager.h" @@ -778,11 +779,12 @@ void PeopleHandler::HandleSignout(const base::ListValue* args) { bool delete_profile = false; args->GetBoolean(0, &delete_profile); - SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_); - if (signin_manager->IsSignoutProhibited()) { + if (!signin_util::IsUserSignoutAllowedForProfile(profile_)) { // If the user cannot signout, the profile must be destroyed. DCHECK(delete_profile); } else { + SigninManager* signin_manager = + SigninManagerFactory::GetForProfile(profile_); if (signin_manager->IsAuthenticated()) { if (GetSyncService()) ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); @@ -957,7 +959,7 @@ PeopleHandler::GetSyncStatusDictionary() { DCHECK(signin); #if !defined(OS_CHROMEOS) // Signout is not allowed if the user has policy (crbug.com/172204). - if (SigninManagerFactory::GetForProfile(profile_)->IsSignoutProhibited()) { + if (!signin_util::IsUserSignoutAllowedForProfile(profile_)) { std::string username = signin->GetAuthenticatedAccountInfo().email; // If there is no one logged in or if the profile name is empty then the 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 d2f47257478..02cc8300a10 100644 --- a/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/settings/people_handler_unittest.cc @@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/bind.h" #include "base/command_line.h" #include "base/json/json_writer.h" #include "base/macros.h" @@ -212,7 +213,7 @@ class PeopleHandlerTest : public ChromeRenderViewHostTestHarness { mock_pss_ = static_cast<ProfileSyncServiceMock*>( ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( - profile(), BuildMockProfileSyncService)); + profile(), base::BindRepeating(&BuildMockProfileSyncService))); ON_CALL(*mock_pss_, GetAuthError()).WillByDefault(ReturnRef(error_)); ON_CALL(*mock_pss_, GetPassphraseType()) .WillByDefault(Return(syncer::PassphraseType::IMPLICIT_PASSPHRASE)); diff --git a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc index 894c4e05cbd..0d63bac8567 100644 --- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc @@ -44,7 +44,8 @@ ProfileInfoHandler::ProfileInfoHandler(Profile* profile) callback_weak_ptr_factory_(this) { #if defined(OS_CHROMEOS) // Set up the chrome://userimage/ source. - content::URLDataSource::Add(profile, new chromeos::UserImageSource()); + content::URLDataSource::Add(profile, + std::make_unique<chromeos::UserImageSource>()); #endif } diff --git a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc index e91b7de825c..b5adcb26fb4 100644 --- a/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/protocol_handlers_handler.cc @@ -114,8 +114,8 @@ void ProtocolHandlersHandler::UpdateHandlerList() { registry->GetRegisteredProtocols(&protocols); base::ListValue handlers; - for (std::vector<std::string>::iterator protocol = protocols.begin(); - protocol != protocols.end(); protocol++) { + for (auto protocol = protocols.begin(); protocol != protocols.end(); + protocol++) { std::unique_ptr<base::DictionaryValue> handler_value( new base::DictionaryValue()); GetHandlersForProtocol(*protocol, handler_value.get()); diff --git a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc index ea77a494627..6de08a763d3 100644 --- a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc @@ -82,12 +82,15 @@ ResetSettingsHandler::~ResetSettingsHandler() {} ResetSettingsHandler* ResetSettingsHandler::Create( content::WebUIDataSource* html_source, Profile* profile) { #if defined(OS_CHROMEOS) + // TODO(crbug.com/891905): Centralize powerwash restriction checks. bool allow_powerwash = false; policy::BrowserPolicyConnectorChromeOS* connector = g_browser_process->platform_part()->browser_policy_connector_chromeos(); - allow_powerwash = !connector->IsEnterpriseManaged() && + allow_powerwash = + !connector->IsEnterpriseManaged() && !user_manager::UserManager::Get()->IsLoggedInAsGuest() && - !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser(); + !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser() && + !user_manager::UserManager::Get()->IsLoggedInAsChildUser(); html_source->AddBoolean("allowPowerwash", allow_powerwash); #endif // defined(OS_CHROMEOS) diff --git a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc index 908a8d324a7..88ecd47d81d 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc @@ -348,7 +348,7 @@ void ClearBrowsingDataHandler::UpdateSyncState() { CallJavascriptFunction( "cr.webUIListenerCallback", base::Value("update-sync-state"), base::Value(identity_manager && identity_manager->HasPrimaryAccount()), - base::Value(sync_service_ && sync_service_->IsSyncActive() && + base::Value(sync_service_ && sync_service_->IsSyncFeatureActive() && sync_service_->GetActiveDataTypes().Has( syncer::HISTORY_DELETE_DIRECTIVES)), base::Value(ShouldShowCookieException(profile_))); 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 bc66616f991..8c34895872b 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 @@ -30,19 +30,17 @@ bool DefaultBrowserIsDisabledByPolicy() { } // namespace -DefaultBrowserHandler::DefaultBrowserHandler(content::WebUI* webui) - : weak_ptr_factory_(this) { -} +DefaultBrowserHandler::DefaultBrowserHandler() : weak_ptr_factory_(this) {} DefaultBrowserHandler::~DefaultBrowserHandler() {} void DefaultBrowserHandler::RegisterMessages() { web_ui()->RegisterMessageCallback( - "SettingsDefaultBrowser.requestDefaultBrowserState", + "requestDefaultBrowserState", base::BindRepeating(&DefaultBrowserHandler::RequestDefaultBrowserState, base::Unretained(this))); web_ui()->RegisterMessageCallback( - "SettingsDefaultBrowser.setAsDefaultBrowser", + "setAsDefaultBrowser", base::BindRepeating(&DefaultBrowserHandler::SetAsDefaultBrowser, base::Unretained(this))); } @@ -74,9 +72,8 @@ void DefaultBrowserHandler::RequestDefaultBrowserState( void DefaultBrowserHandler::SetAsDefaultBrowser(const base::ListValue* args) { CHECK(!DefaultBrowserIsDisabledByPolicy()); - - base::RecordAction(base::UserMetricsAction("Options_SetAsDefaultBrowser")); - UMA_HISTOGRAM_COUNTS("Settings.StartSetAsDefault", true); + AllowJavascript(); + RecordSetAsDefaultUMA(); default_browser_worker_->StartSetAsDefault(); @@ -85,6 +82,11 @@ void DefaultBrowserHandler::SetAsDefaultBrowser(const base::ListValue* args) { ResetDefaultBrowserPrompt(Profile::FromWebUI(web_ui())); } +void DefaultBrowserHandler::RecordSetAsDefaultUMA() { + base::RecordAction(base::UserMetricsAction("Options_SetAsDefaultBrowser")); + UMA_HISTOGRAM_COUNTS("Settings.StartSetAsDefault", true); +} + void DefaultBrowserHandler::OnDefaultBrowserWorkerFinished( shell_integration::DefaultWebClientState state) { if (state == shell_integration::IS_DEFAULT) { @@ -101,7 +103,7 @@ void DefaultBrowserHandler::OnDefaultBrowserWorkerFinished( state == shell_integration::UNKNOWN_DEFAULT); dict.SetBoolean("isDisabledByPolicy", DefaultBrowserIsDisabledByPolicy()); - FireWebUIListener("settings.updateDefaultBrowserState", dict); + 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 cc2f4ec1e10..81337dc40df 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 @@ -27,7 +27,7 @@ namespace settings { // settings code to change the default browser settings. class DefaultBrowserHandler : public SettingsPageUIHandler { public: - explicit DefaultBrowserHandler(content::WebUI* webui); + DefaultBrowserHandler(); ~DefaultBrowserHandler() override; // SettingsPageUIHandler implementation. @@ -35,6 +35,10 @@ class DefaultBrowserHandler : public SettingsPageUIHandler { void OnJavascriptAllowed() override; void OnJavascriptDisallowed() override; + protected: + // Subclasses should override this method. + virtual void RecordSetAsDefaultUMA(); + private: // Called from WebUI to request the current state. void RequestDefaultBrowserState(const base::ListValue* args); diff --git a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc index 1ea37913233..721518a1f17 100644 --- a/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc @@ -192,7 +192,6 @@ void ManageProfileHandler::HandleSetProfileIconToDefaultAvatar( PrefService* pref_service = profile_->GetPrefs(); pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); - pref_service->SetInteger(prefs::kProfileLocalAvatarIndex, new_icon_index); pref_service->SetBoolean(prefs::kProfileUsingDefaultAvatar, false); pref_service->SetBoolean(prefs::kProfileUsingGAIAAvatar, false); diff --git a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc index 04422c787f8..76a7f5baab6 100644 --- a/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/site_settings_handler.cc @@ -102,8 +102,8 @@ void AddExceptionsGrantedByHostedApps(content::BrowserContext* context, const extensions::URLPatternSet& web_extent = (*extension)->web_extent(); // Add patterns from web extent. - for (extensions::URLPatternSet::const_iterator pattern = web_extent.begin(); - pattern != web_extent.end(); ++pattern) { + for (auto pattern = web_extent.begin(); pattern != web_extent.end(); + ++pattern) { std::string url_pattern = pattern->GetAsString(); site_settings::AddExceptionForHostedApp( url_pattern, *extension->get(), exceptions); @@ -123,7 +123,7 @@ void AddExceptionsGrantedByHostedApps(content::BrowserContext* context, bool PatternAppliesToSingleOrigin(const ContentSettingPatternSource& pattern) { const GURL url(pattern.primary_pattern.ToString()); // Default settings and other patterns apply to multiple origins. - if (url::Origin::Create(url).unique()) + if (url::Origin::Create(url).opaque()) return false; // Embedded content settings only when |url| is embedded in another origin, so // ignore non-wildcard secondary patterns that are different to the primary. diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc index d4298910124..4a02d3dc710 100644 --- a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc +++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc @@ -177,8 +177,8 @@ void TtsHandler::WakeTtsEngine(const base::ListValue* args) { TtsExtensionEngine::GetInstance()->LoadBuiltInTtsExtension(profile); extensions::ProcessManager::Get(profile)->WakeEventPage( extension_misc::kSpeechSynthesisExtensionId, - base::BindRepeating(&TtsHandler::OnTtsEngineAwake, - weak_factory_.GetWeakPtr())); + base::BindOnce(&TtsHandler::OnTtsEngineAwake, + weak_factory_.GetWeakPtr())); } void TtsHandler::OnTtsEngineAwake(bool success) { diff --git a/chromium/chrome/browser/ui/webui/settings_utils_linux.cc b/chromium/chrome/browser/ui/webui/settings_utils_linux.cc index 638dc467cbe..5d01e91ec70 100644 --- a/chromium/chrome/browser/ui/webui/settings_utils_linux.cc +++ b/chromium/chrome/browser/ui/webui/settings_utils_linux.cc @@ -15,6 +15,7 @@ #include "base/threading/scoped_blocking_call.h" #include "build/build_config.h" #include "chrome/browser/tab_contents/tab_util.h" +#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" @@ -130,9 +131,9 @@ void DetectAndStartProxyConfigUtil(int render_process_id, if (launched) return; - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::BindOnce(&ShowLinuxProxyConfigUrl, - render_process_id, render_view_id)); + base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, + base::BindOnce(&ShowLinuxProxyConfigUrl, + render_process_id, render_view_id)); } } // namespace diff --git a/chromium/chrome/browser/ui/webui/settings_utils_win.cc b/chromium/chrome/browser/ui/webui/settings_utils_win.cc index 46a7ca83fcd..5261c2dfe55 100644 --- a/chromium/chrome/browser/ui/webui/settings_utils_win.cc +++ b/chromium/chrome/browser/ui/webui/settings_utils_win.cc @@ -42,9 +42,10 @@ class ManageCertificatesDialog : public ui::BaseShellDialogImpl { } RunState run_state = BeginRun(parent); - run_state.dialog_thread->task_runner()->PostTaskAndReply( - FROM_HERE, base::Bind(&ManageCertificatesDialog::ShowOnDialogThread, - base::Unretained(this), run_state), + run_state.dialog_task_runner->PostTaskAndReply( + FROM_HERE, + base::Bind(&ManageCertificatesDialog::ShowOnDialogThread, + base::Unretained(this), run_state), base::Bind(&ManageCertificatesDialog::OnDialogClosed, base::Unretained(this), run_state, callback)); } 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 d962685badd..0ab30779fd0 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 @@ -189,19 +189,22 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test { TestingProfile::Builder profile_builder; profile_builder.AddTestingFactory( ProfileOAuth2TokenServiceFactory::GetInstance(), - BuildFakeProfileOAuth2TokenService); - profile_builder.AddTestingFactory(SigninManagerFactory::GetInstance(), - BuildFakeSigninManagerBase); - profile_builder.AddTestingFactory(ChromeSigninClientFactory::GetInstance(), - signin::BuildTestSigninClient); - profile_builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(), - &BuildMockProfileSyncService); + base::BindRepeating(&BuildFakeProfileOAuth2TokenService)); + profile_builder.AddTestingFactory( + SigninManagerFactory::GetInstance(), + base::BindRepeating(&BuildFakeSigninManagerBase)); + profile_builder.AddTestingFactory( + ChromeSigninClientFactory::GetInstance(), + base::BindRepeating(&signin::BuildTestSigninClient)); + profile_builder.AddTestingFactory( + ProfileSyncServiceFactory::GetInstance(), + base::BindRepeating(&BuildMockProfileSyncService)); profile_builder.AddTestingFactory( policy::UserPolicySigninServiceFactory::GetInstance(), - &FakeUserPolicySigninService::Build); + base::BindRepeating(&FakeUserPolicySigninService::Build)); profile_builder.AddTestingFactory( UnifiedConsentServiceFactory::GetInstance(), - &BuildUnifiedConsentServiceForTesting); + base::BindRepeating(&BuildUnifiedConsentServiceForTesting)); profile_ = profile_builder.Build(); account_tracker_service_ = AccountTrackerServiceFactory::GetForProfile(profile()); 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 c50be63d5fa..6657d8fa3fa 100644 --- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc +++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.cc @@ -137,11 +137,10 @@ void InlineLoginHandler::ContinueHandleInitializeMessage() { if (!default_email.empty()) params.SetString("email", default_email); - std::string is_constrained; - net::GetValueForKeyInQuery( - current_url, signin::kSignInPromoQueryKeyConstrained, &is_constrained); - if (!is_constrained.empty()) - params.SetString(signin::kSignInPromoQueryKeyConstrained, is_constrained); + // The legacy full-tab Chrome sign-in page is no longer used as it was relying + // on exchanging cookies for refresh tokens and that endpoint is no longer + // supported. + params.SetString("constrained", "1"); // TODO(rogerta): this needs to be passed on to gaia somehow. std::string read_only_email; @@ -196,12 +195,8 @@ void InlineLoginHandler::HandleCompleteLoginMessageWithCookies( bool choose_what_to_sync = false; dict->GetBoolean("chooseWhatToSync", &choose_what_to_sync); - base::string16 session_index_string16; - dict->GetString("sessionIndex", &session_index_string16); - std::string session_index = base::UTF16ToASCII(session_index_string16); - CompleteLogin(email, password, gaia_id, auth_code, skip_for_now, trusted, - trusted_found, choose_what_to_sync, session_index); + trusted_found, choose_what_to_sync); } void InlineLoginHandler::HandleSwitchToFullTabMessage( @@ -227,14 +222,6 @@ void InlineLoginHandler::HandleSwitchToFullTabMessage( main_frame_url, kSignInPromoQueryKeyShowAccountManagement, "1"); main_frame_url = net::AppendOrReplaceQueryParameter( main_frame_url, signin::kSignInPromoQueryKeyForceKeepData, "1"); - if (base::FeatureList::IsEnabled( - features::kRemoveUsageOfDeprecatedGaiaSigninEndpoint)) { - main_frame_url = net::AppendOrReplaceQueryParameter( - main_frame_url, signin::kSignInPromoQueryKeyConstrained, "1"); - } else { - main_frame_url = net::AppendOrReplaceQueryParameter( - main_frame_url, signin::kSignInPromoQueryKeyConstrained, "0"); - } NavigateParams params(profile, main_frame_url, ui::PAGE_TRANSITION_AUTO_TOPLEVEL); 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 51e7508ae88..053825a7427 100644 --- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h +++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler.h @@ -82,8 +82,7 @@ class InlineLoginHandler : public content::WebUIMessageHandler { bool skip_for_now, bool trusted, bool trusted_found, - bool choose_what_to_sync, - const std::string& session_index) = 0; + bool choose_what_to_sync) = 0; base::WeakPtrFactory<InlineLoginHandler> weak_ptr_factory_; diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_chromeos.cc index 233761c741d..d729f382c40 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 @@ -125,8 +125,7 @@ void InlineLoginHandlerChromeOS::CompleteLogin(const std::string& email, bool skip_for_now, bool trusted, bool trusted_found, - bool choose_what_to_sync, - const std::string& session_index) { + bool choose_what_to_sync) { CHECK(!auth_code.empty()); CHECK(!gaia_id.empty()); CHECK(!email.empty()); 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 18ea95dfc62..70739fbeb89 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 @@ -28,8 +28,7 @@ class InlineLoginHandlerChromeOS : public InlineLoginHandler { bool skip_for_now, bool trusted, bool trusted_found, - bool choose_what_to_sync, - const std::string& session_index) override; + bool choose_what_to_sync) override; private: base::RepeatingClosure close_dialog_closure_; diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc index 57223ddd6f1..9c3e2817ff1 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 @@ -166,7 +166,6 @@ InlineSigninHelper::InlineSigninHelper( const std::string& email, const std::string& gaia_id, const std::string& password, - const std::string& session_index, const std::string& auth_code, const std::string& signin_scoped_device_id, bool choose_what_to_sync, @@ -182,22 +181,16 @@ InlineSigninHelper::InlineSigninHelper( email_(email), gaia_id_(gaia_id), password_(password), - session_index_(session_index), auth_code_(auth_code), choose_what_to_sync_(choose_what_to_sync), confirm_untrusted_signin_(confirm_untrusted_signin), is_force_sign_in_with_usermanager_(is_force_sign_in_with_usermanager) { DCHECK(profile_); DCHECK(!email_.empty()); - if (!auth_code_.empty()) { - gaia_auth_fetcher_.StartAuthCodeForOAuth2TokenExchangeWithDeviceId( - auth_code, signin_scoped_device_id); - } else { - DCHECK(!session_index_.empty()); - gaia_auth_fetcher_ - .DeprecatedStartCookieForOAuthLoginTokenExchangeWithDeviceId( - session_index_, signin_scoped_device_id); - } + DCHECK(!auth_code_.empty()); + + gaia_auth_fetcher_.StartAuthCodeForOAuth2TokenExchangeWithDeviceId( + auth_code_, signin_scoped_device_id); } InlineSigninHelper::~InlineSigninHelper() {} @@ -206,10 +199,11 @@ void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) { if (is_force_sign_in_with_usermanager_) { // If user sign in in UserManager with force sign in enabled, the browser // window won't be opened until now. + UnlockProfileAndHideLoginUI(profile_->GetPath(), handler_.get()); profiles::OpenBrowserWindowForProfile( base::Bind(&InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened, base::Unretained(this), result), - true, false, profile_, create_status_); + true, false, true, profile_, create_status_); } else { OnClientOAuthSuccessAndBrowserOpened(result, profile_, create_status_); } @@ -219,8 +213,6 @@ void InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened( const ClientOAuthResult& result, Profile* profile, Profile::CreateStatus status) { - if (is_force_sign_in_with_usermanager_) - UnlockProfileAndHideLoginUI(profile_->GetPath(), handler_.get()); Browser* browser = NULL; if (handler_) { browser = handler_->GetDesktopBrowser(); @@ -463,11 +455,6 @@ void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { signin_metrics::Reason reason = signin::GetSigninReasonForPromoURL(current_url); - std::string is_constrained; - net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); - - // Use new embedded flow if in constrained window. - if (is_constrained == "1") { const GURL& url = GaiaUrls::GetInstance()->embedded_signin_url(); params.SetBoolean("isNewGaiaFlow", true); params.SetString("clientId", @@ -491,12 +478,9 @@ void InlineLoginHandlerImpl::SetExtraInitParams(base::DictionaryValue& params) { break; } params.SetString("flow", flow); - } content::WebContentsObserver::Observe(contents); LogHistogramValue(signin_metrics::HISTOGRAM_SHOWN); - UMA_HISTOGRAM_BOOLEAN("Signin.UseDeprecatedGaiaSigninEndpoint", - is_constrained == "1"); } void InlineLoginHandlerImpl::CompleteLogin(const std::string& email, @@ -506,8 +490,7 @@ void InlineLoginHandlerImpl::CompleteLogin(const std::string& email, bool skip_for_now, bool trusted, bool trusted_found, - bool choose_what_to_sync, - const std::string& session_index) { + bool choose_what_to_sync) { content::WebContents* contents = web_ui()->GetWebContents(); const GURL& current_url = contents->GetURL(); @@ -521,14 +504,9 @@ void InlineLoginHandlerImpl::CompleteLogin(const std::string& email, if (trusted_found) confirm_untrusted_signin_ = !trusted; - std::string is_constrained; - net::GetValueForKeyInQuery(current_url, "constrained", &is_constrained); - DCHECK(!email.empty()); DCHECK(!gaia_id.empty()); - const bool is_password_separated_signin_flow = is_constrained == "1"; - DCHECK(is_password_separated_signin_flow || !session_index.empty()); - DCHECK(!is_password_separated_signin_flow || !auth_code.empty()); + DCHECK(!auth_code.empty()); content::StoragePartition* partition = content::BrowserContext::GetStoragePartitionForSite( @@ -553,8 +531,8 @@ void InlineLoginHandlerImpl::CompleteLogin(const std::string& email, if (reason == signin_metrics::Reason::REASON_REAUTHENTICATION) { FinishCompleteLoginParams params( this, partition, current_url, base::FilePath(), - confirm_untrusted_signin_, email, gaia_id, password, session_index, - auth_code, choose_what_to_sync, false); + confirm_untrusted_signin_, email, gaia_id, password, auth_code, + choose_what_to_sync, false); ProfileManager::CreateCallback callback = base::Bind(&InlineLoginHandlerImpl::FinishCompleteLogin, params); profiles::LoadProfileAsync(path, callback); @@ -568,8 +546,8 @@ void InlineLoginHandlerImpl::CompleteLogin(const std::string& email, handler = this; FinishCompleteLoginParams params( handler, partition, current_url, path, confirm_untrusted_signin_, - email, gaia_id, password, session_index, auth_code, - choose_what_to_sync, is_force_signin_enabled); + email, gaia_id, password, auth_code, choose_what_to_sync, + is_force_signin_enabled); ProfileManager::CreateCallback callback = base::Bind(&InlineLoginHandlerImpl::FinishCompleteLogin, params); if (is_force_signin_enabled) { @@ -582,12 +560,11 @@ void InlineLoginHandlerImpl::CompleteLogin(const std::string& email, } } } else { - FinishCompleteLogin( - FinishCompleteLoginParams(this, partition, current_url, - base::FilePath(), confirm_untrusted_signin_, - email, gaia_id, password, session_index, - auth_code, choose_what_to_sync, false), - profile, Profile::CREATE_STATUS_CREATED); + FinishCompleteLogin(FinishCompleteLoginParams( + this, partition, current_url, base::FilePath(), + confirm_untrusted_signin_, email, gaia_id, password, + auth_code, choose_what_to_sync, false), + profile, Profile::CREATE_STATUS_CREATED); } } @@ -600,7 +577,6 @@ InlineLoginHandlerImpl::FinishCompleteLoginParams::FinishCompleteLoginParams( const std::string& email, const std::string& gaia_id, const std::string& password, - const std::string& session_index, const std::string& auth_code, bool choose_what_to_sync, bool is_force_sign_in_with_usermanager) @@ -612,7 +588,6 @@ InlineLoginHandlerImpl::FinishCompleteLoginParams::FinishCompleteLoginParams( email(email), gaia_id(gaia_id), password(password), - session_index(session_index), auth_code(auth_code), choose_what_to_sync(choose_what_to_sync), is_force_sign_in_with_usermanager(is_force_sign_in_with_usermanager) {} @@ -707,8 +682,8 @@ void InlineLoginHandlerImpl::FinishCompleteLogin( handler_weak_ptr, params.partition->GetURLLoaderFactoryForBrowserProcess(), profile, status, params.url, params.email, params.gaia_id, params.password, - params.session_index, params.auth_code, signin_scoped_device_id, - params.choose_what_to_sync, params.confirm_untrusted_signin, + params.auth_code, signin_scoped_device_id, params.choose_what_to_sync, + params.confirm_untrusted_signin, params.is_force_sign_in_with_usermanager); // If opened from user manager to unlock a profile, make sure the user manager diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h index 1e95466923c..8234ded1ed7 100644 --- a/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h +++ b/chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.h @@ -57,8 +57,7 @@ class InlineLoginHandlerImpl : public InlineLoginHandler, bool skip_for_now, bool trusted, bool trusted_found, - bool choose_what_to_sync, - const std::string& session_index) override; + bool choose_what_to_sync) override; // This struct exists to pass paramters to the FinishCompleteLogin() method, // since the base::Bind() call does not support this many template args. @@ -72,7 +71,6 @@ class InlineLoginHandlerImpl : public InlineLoginHandler, const std::string& email, const std::string& gaia_id, const std::string& password, - const std::string& session_index, const std::string& auth_code, bool choose_what_to_sync, bool is_force_sign_in_with_usermanager); @@ -97,9 +95,6 @@ class InlineLoginHandlerImpl : public InlineLoginHandler, std::string gaia_id; // Password of the account used to sign in. std::string password; - // Index within gaia cookie of the account used to sign in. Used only - // with password combined signin flow. - std::string session_index; // Authentication code used to exchange for a login scoped refresh token // for the account used to sign in. Used only with password separated // signin flow. @@ -144,7 +139,6 @@ class InlineSigninHelper : public GaiaAuthConsumer { const std::string& email, const std::string& gaia_id, const std::string& password, - const std::string& session_index, const std::string& auth_code, const std::string& signin_scoped_device_id, bool choose_what_to_sync, @@ -200,7 +194,6 @@ class InlineSigninHelper : public GaiaAuthConsumer { std::string email_; std::string gaia_id_; std::string password_; - std::string session_index_; std::string auth_code_; bool choose_what_to_sync_; bool confirm_untrusted_signin_; diff --git a/chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc index 0fd4b89993f..e6ead2da79a 100644 --- a/chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/signin/inline_login_ui_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/bind.h" #include "base/command_line.h" #include "base/macros.h" #include "base/memory/ref_counted.h" @@ -161,7 +162,6 @@ class MockInlineSigninHelper : public InlineSigninHelper { const std::string& email, const std::string& gaia_id, const std::string& password, - const std::string& session_index, const std::string& auth_code, const std::string& signin_scoped_device_id, bool choose_what_to_sync, @@ -191,7 +191,6 @@ MockInlineSigninHelper::MockInlineSigninHelper( const std::string& email, const std::string& gaia_id, const std::string& password, - const std::string& session_index, const std::string& auth_code, const std::string& signin_scoped_device_id, bool choose_what_to_sync, @@ -204,7 +203,6 @@ MockInlineSigninHelper::MockInlineSigninHelper( email, gaia_id, password, - session_index, auth_code, signin_scoped_device_id, choose_what_to_sync, @@ -223,7 +221,6 @@ class MockSyncStarterInlineSigninHelper : public InlineSigninHelper { const std::string& email, const std::string& gaia_id, const std::string& password, - const std::string& session_index, const std::string& auth_code, const std::string& signin_scoped_device_id, bool choose_what_to_sync, @@ -250,7 +247,6 @@ MockSyncStarterInlineSigninHelper::MockSyncStarterInlineSigninHelper( const std::string& email, const std::string& gaia_id, const std::string& password, - const std::string& session_index, const std::string& auth_code, const std::string& signin_scoped_device_id, bool choose_what_to_sync, @@ -264,7 +260,6 @@ MockSyncStarterInlineSigninHelper::MockSyncStarterInlineSigninHelper( email, gaia_id, password, - session_index, auth_code, signin_scoped_device_id, choose_what_to_sync, @@ -474,9 +469,9 @@ class InlineLoginHelperBrowserTest : public InProcessBrowserTest { // creating the browser so that a bunch of classes don't register as // observers and end up needing to unregister when the fake is substituted. SigninManagerFactory::GetInstance()->SetTestingFactory( - context, &BuildFakeSigninManagerBase); + context, base::BindRepeating(&BuildFakeSigninManagerBase)); ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( - context, &BuildFakeProfileOAuth2TokenService); + context, base::BindRepeating(&BuildFakeProfileOAuth2TokenService)); } void SetUp() override { @@ -500,13 +495,6 @@ class InlineLoginHelperBrowserTest : public InProcessBrowserTest { host_resolver()->AddRule("*", "127.0.0.1"); - deprecated_client_login_to_oauth2_response_ = - std::make_unique<net::test_server::ControllableHttpResponse>( - embedded_test_server(), - GaiaUrls::GetInstance() - ->deprecated_client_login_to_oauth2_url() - .path(), - /*relative_url_is_prefix=*/true); oauth2_token_exchange_success_ = std::make_unique<net::test_server::ControllableHttpResponse>( embedded_test_server(), @@ -526,14 +514,6 @@ class InlineLoginHelperBrowserTest : public InProcessBrowserTest { ASSERT_TRUE(token_service_); } - void SimulateStartCookieForOAuthLoginTokenExchangeSuccess( - const std::string& cookie_string) { - deprecated_client_login_to_oauth2_response_->WaitForRequest(); - deprecated_client_login_to_oauth2_response_->Send( - net::HTTP_OK, "text/html; charset=utf-8", "", {cookie_string}); - deprecated_client_login_to_oauth2_response_->Done(); - } - void SimulateStartAuthCodeForOAuth2TokenExchangeSuccess( const std::string& json_response) { oauth2_token_exchange_success_->WaitForRequest(); @@ -559,8 +539,6 @@ class InlineLoginHelperBrowserTest : public InProcessBrowserTest { protected: std::unique_ptr<net::test_server::ControllableHttpResponse> - deprecated_client_login_to_oauth2_response_; - std::unique_ptr<net::test_server::ControllableHttpResponse> oauth2_token_exchange_success_; private: @@ -573,34 +551,6 @@ class InlineLoginHelperBrowserTest : public InProcessBrowserTest { DISALLOW_COPY_AND_ASSIGN(InlineLoginHelperBrowserTest); }; -// Test signin helper calls correct fetcher methods when called with a session -// index. -IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, WithSessionIndex) { - base::WeakPtr<InlineLoginHandlerImpl> handler; - MockInlineSigninHelper helper(handler, test_shared_loader_factory(), - browser()->profile(), GURL(), "foo@gmail.com", - "gaiaid-12345", "password", - "0", // session index from above - std::string(), // auth code - std::string(), - false, // choose what to sync - false); // confirm untrusted signin - base::RunLoop run_loop; - EXPECT_CALL(helper, OnClientOAuthSuccess(_)) - .WillOnce(testing::InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); - - SimulateStartCookieForOAuthLoginTokenExchangeSuccess( - "oauth_code=code; secure; httponly"); - - SimulateStartAuthCodeForOAuth2TokenExchangeSuccess( - R"({ - "access_token": "access_token", - "expires_in": 1234567890, - "refresh_token": "refresh_token" - })"); - run_loop.Run(); -} - // Test signin helper calls correct fetcher methods when called with an // auth code. IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, WithAuthCode) { @@ -608,7 +558,6 @@ IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, WithAuthCode) { MockInlineSigninHelper helper(handler, test_shared_loader_factory(), browser()->profile(), GURL(), "foo@gmail.com", "gaiaid-12345", "password", - "", // session index "auth_code", // auth code std::string(), false, // choose what to sync @@ -645,7 +594,6 @@ IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, ->GetURLLoaderFactoryForBrowserProcess(), browser()->profile(), url, "foo@gmail.com", "gaiaid-12345", "password", - "", // session index "auth_code", // auth code std::string(), false, // choose what to sync @@ -689,7 +637,6 @@ IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, new MockSyncStarterInlineSigninHelper( handler, test_shared_loader_factory(), browser()->profile(), url, "foo@gmail.com", "gaiaid-12345", "password", - "", // session index "auth_code", // auth code std::string(), true, // choose what to sync @@ -720,7 +667,6 @@ IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, new MockSyncStarterInlineSigninHelper( handler, test_shared_loader_factory(), browser()->profile(), url, "foo@gmail.com", "gaiaid-12345", "password", - "", // session index "auth_code", // auth code std::string(), false, // choose what to sync @@ -752,7 +698,6 @@ IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, new MockSyncStarterInlineSigninHelper( handler, test_shared_loader_factory(), browser()->profile(), url, "foo@gmail.com", "gaiaid-12345", "password", - "", // session index "auth_code", // auth code std::string(), false, // choose what to sync @@ -784,7 +729,6 @@ IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, browser()->profile(), Profile::CreateStatus::CREATE_STATUS_INITIALIZED, url, "foo@gmail.com", "gaiaid-12345", "password", - "", // session index "auth_code", // auth code std::string(), false, // choose what to sync @@ -809,7 +753,6 @@ IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, browser()->profile(), Profile::CreateStatus::CREATE_STATUS_INITIALIZED, url, "foo@gmail.com", "gaiaid-12345", "password", - "", // session index "auth_code", // auth code std::string(), false, // choose what to sync @@ -830,7 +773,7 @@ IN_PROC_BROWSER_TEST_F(InlineLoginHelperBrowserTest, MockSyncStarterInlineSigninHelper* helper = new MockSyncStarterInlineSigninHelper( handler, test_shared_loader_factory(), browser()->profile(), url, - "foo@gmail.com", "gaiaid-12345", "password", "", "auth_code", + "foo@gmail.com", "gaiaid-12345", "password", "auth_code", std::string(), false, false, true); EXPECT_CALL( *helper, diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc b/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc index f5ca3a721c6..53b61e31173 100644 --- a/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc +++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc @@ -81,7 +81,7 @@ class ConsentBumpActivator : public BrowserListObserver, UnifiedConsentServiceFactory::GetForProfile(profile_); if (consent_service->ShouldShowConsentBump()) { consent_service->RecordConsentBumpSuppressReason( - unified_consent::ConsentBumpSuppressReason::kSyncPaused); + unified_consent::metrics::ConsentBumpSuppressReason::kSyncPaused); } return; } diff --git a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc index fcaa6c1b2a5..789ee86db6e 100644 --- a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc +++ b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc @@ -28,7 +28,6 @@ #include "chrome/browser/signin/signin_error_controller_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_util.h" -#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/user_manager.h" #include "chrome/browser/ui/webui/profile_helper.h" @@ -38,7 +37,6 @@ #include "chrome/common/url_constants.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" -#include "components/browser_sync/profile_sync_service.h" #include "components/prefs/pref_service.h" #include "components/signin/core/browser/signin_error_controller.h" #include "components/strings/grit/components_strings.h" @@ -232,9 +230,11 @@ void SigninCreateProfileHandler::OpenNewWindowForProfile( base::Bind(&SigninCreateProfileHandler::OnBrowserReadyCallback, weak_ptr_factory_.GetWeakPtr()), false, // Don't create a window if one already exists. - true, // Create a first run window. - profile, - status); + true, // Create a first run window. + false, // There is no need to unblock all extensions because we only open + // browser window if the Profile is not locked. Hence there is no + // extension blocked. + profile, status); } void SigninCreateProfileHandler::OpenSigninDialogForProfile(Profile* profile) { diff --git a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc index 12410e53de9..44a3468e871 100644 --- a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc +++ b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc @@ -105,10 +105,6 @@ class SigninCreateProfileHandlerTest : public BrowserWithTestWindowTest { handler_.reset(new TestSigninCreateProfileHandler(web_ui(), profile_manager())); - - TestingProfile::TestingFactories factories; - factories.push_back(std::make_pair(SigninManagerFactory::GetInstance(), - BuildFakeSigninManagerBase)); } void TearDown() override { 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 f9d193e5ae2..5a808d1128d 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 @@ -8,6 +8,7 @@ #include <unordered_map> #include <vector> +#include "base/bind.h" #include "base/bind_helpers.h" #include "base/scoped_observer.h" #include "base/test/metrics/histogram_tester.h" @@ -167,10 +168,13 @@ class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest, } TestingProfile::TestingFactories GetTestingFactories() override { - return {{AccountFetcherServiceFactory::GetInstance(), - FakeAccountFetcherServiceBuilder::BuildForTests}, - {SigninManagerFactory::GetInstance(), BuildFakeSigninManagerBase}, - {ConsentAuditorFactory::GetInstance(), BuildFakeConsentAuditor}}; + return { + {AccountFetcherServiceFactory::GetInstance(), + base::BindRepeating(&FakeAccountFetcherServiceBuilder::BuildForTests)}, + {SigninManagerFactory::GetInstance(), + base::BindRepeating(&BuildFakeSigninManagerBase)}, + {ConsentAuditorFactory::GetInstance(), + base::BindRepeating(&BuildFakeConsentAuditor)}}; } const std::unordered_map<std::string, int>& GetStringToGrdIdMap() { 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 d6285df2ec5..2892d4b3c27 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 @@ -722,36 +722,25 @@ void UserManagerScreenHandler::GetLocalizedValues( // Strings needed for the user_pod_template public account div, but not ever // actually displayed for desktop users. - localized_strings->SetString("publicAccountReminder", base::string16()); - localized_strings->SetString("publicSessionLanguageAndInput", - base::string16()); - localized_strings->SetString("publicAccountEnter", base::string16()); - localized_strings->SetString("publicAccountEnterAccessibleName", - base::string16()); - localized_strings->SetString("publicAccountMonitoringWarning", - base::string16()); - localized_strings->SetString("publicAccountLearnMore", base::string16()); - localized_strings->SetString("publicAccountMonitoringInfo", base::string16()); - localized_strings->SetString("publicAccountMonitoringInfoItem1", - base::string16()); - localized_strings->SetString("publicAccountMonitoringInfoItem2", - base::string16()); - localized_strings->SetString("publicAccountMonitoringInfoItem3", - base::string16()); - localized_strings->SetString("publicAccountMonitoringInfoItem4", - base::string16()); - localized_strings->SetString("publicSessionSelectLanguage", base::string16()); - localized_strings->SetString("publicSessionSelectKeyboard", base::string16()); - localized_strings->SetString("signinBannerText", base::string16()); - localized_strings->SetString("launchAppButton", base::string16()); - localized_strings->SetString("multiProfilesRestrictedPolicyTitle", - base::string16()); - localized_strings->SetString("multiProfilesNotAllowedPolicyMsg", - base::string16()); - localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg", - base::string16()); - localized_strings->SetString("multiProfilesOwnerPrimaryOnlyMsg", - base::string16()); + localized_strings->SetString("publicAccountReminder", ""); + localized_strings->SetString("publicSessionLanguageAndInput", ""); + localized_strings->SetString("publicAccountEnter", ""); + localized_strings->SetString("publicAccountEnterAccessibleName", ""); + localized_strings->SetString("publicAccountMonitoringWarning", ""); + localized_strings->SetString("publicAccountLearnMore", ""); + localized_strings->SetString("publicAccountMonitoringInfo", ""); + localized_strings->SetString("publicAccountMonitoringInfoItem1", ""); + localized_strings->SetString("publicAccountMonitoringInfoItem2", ""); + localized_strings->SetString("publicAccountMonitoringInfoItem3", ""); + localized_strings->SetString("publicAccountMonitoringInfoItem4", ""); + localized_strings->SetString("publicSessionSelectLanguage", ""); + localized_strings->SetString("publicSessionSelectKeyboard", ""); + localized_strings->SetString("signinBannerText", ""); + localized_strings->SetString("launchAppButton", ""); + localized_strings->SetString("multiProfilesRestrictedPolicyTitle", ""); + localized_strings->SetString("multiProfilesNotAllowedPolicyMsg", ""); + localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg", ""); + localized_strings->SetString("multiProfilesOwnerPrimaryOnlyMsg", ""); // Error message when trying to add a profile while all profiles are locked. localized_strings->SetString("addProfileAllProfilesLockedError", 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 a65c05cce6b..3f32dcc185c 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 @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/bind.h" #include "base/command_line.h" #include "base/run_loop.h" #include "base/strings/string_util.h" @@ -163,7 +164,7 @@ IN_PROC_BROWSER_TEST_F(UserManagerUIAuthenticatedUserBrowserTest, entry_->SetSupervisedUserId("supervised_user_id"); MockLoginUIService* service = static_cast<MockLoginUIService*>( LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse( - profile_, CreateLoginUIService)); + profile_, base::BindRepeating(&CreateLoginUIService))); EXPECT_CALL(*service, DisplayLoginResult(_, _, _)); LaunchAuthenticatedUser(""); @@ -180,7 +181,7 @@ IN_PROC_BROWSER_TEST_F(UserManagerUIAuthenticatedUserBrowserTest, entry_->SetActiveTimeToNow(); MockLoginUIService* service = static_cast<MockLoginUIService*>( LoginUIServiceFactory::GetInstance()->SetTestingFactoryAndUse( - profile_, CreateLoginUIService)); + profile_, base::BindRepeating(&CreateLoginUIService))); EXPECT_CALL(*service, SetProfileBlockingErrorMessage()); LaunchAuthenticatedUser(""); diff --git a/chromium/chrome/browser/ui/webui/site_settings_helper.cc b/chromium/chrome/browser/ui/webui/site_settings_helper.cc index f7cfefa7fe5..d39d5f329ed 100644 --- a/chromium/chrome/browser/ui/webui/site_settings_helper.cc +++ b/chromium/chrome/browser/ui/webui/site_settings_helper.cc @@ -98,6 +98,7 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { {CONTENT_SETTINGS_TYPE_ACCESSIBILITY_EVENTS, nullptr}, {CONTENT_SETTINGS_TYPE_CLIPBOARD_WRITE, nullptr}, {CONTENT_SETTINGS_TYPE_PLUGINS_DATA, nullptr}, + {CONTENT_SETTINGS_TYPE_BACKGROUND_FETCH, nullptr}, }; static_assert(arraysize(kContentSettingsTypeGroupNames) == // ContentSettingsType starts at -1, so add 1 here. @@ -318,7 +319,7 @@ std::string GetDisplayNameForGURL( const GURL& url, const extensions::ExtensionRegistry* extension_registry) { const url::Origin origin = url::Origin::Create(url); - if (origin.unique()) + if (origin.opaque()) return url.spec(); std::string display_name = @@ -356,8 +357,7 @@ void GetExceptionsFromHostContentSettingsMap( map->GetSettingsForOneType(type, std::string(), &entries); // Group settings by primary_pattern. AllPatternsSettings all_patterns_settings; - for (ContentSettingsForOneType::iterator i = entries.begin(); - i != entries.end(); ++i) { + for (auto i = entries.begin(); i != entries.end(); ++i) { // Don't add default settings. if (i->primary_pattern == ContentSettingsPattern::Wildcard() && i->secondary_pattern == ContentSettingsPattern::Wildcard() && @@ -388,7 +388,7 @@ void GetExceptionsFromHostContentSettingsMap( // the highest (see operator< in ContentSettingsPattern), so traverse it in // reverse to show the patterns with the highest precedence (the more specific // ones) on the top. - for (AllPatternsSettings::reverse_iterator i = all_patterns_settings.rbegin(); + for (auto i = all_patterns_settings.rbegin(); i != all_patterns_settings.rend(); ++i) { const ContentSettingsPattern& primary_pattern = i->first.first; const OnePatternSettings& one_settings = i->second; @@ -398,8 +398,7 @@ void GetExceptionsFromHostContentSettingsMap( // The "parent" entry either has an identical primary and secondary pattern, // or has a wildcard secondary. The two cases are indistinguishable in the // UI. - OnePatternSettings::const_iterator parent = - one_settings.find(primary_pattern); + auto parent = one_settings.find(primary_pattern); if (parent == one_settings.end()) parent = one_settings.find(ContentSettingsPattern::Wildcard()); @@ -417,8 +416,7 @@ void GetExceptionsFromHostContentSettingsMap( parent_setting, source, incognito)); // Add the "children" for any embedded settings. - for (OnePatternSettings::const_iterator j = one_settings.begin(); - j != one_settings.end(); ++j) { + for (auto j = one_settings.begin(); j != one_settings.end(); ++j) { // Skip the non-embedded setting which we already added above. if (j == parent) continue; diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc b/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc index 039990ee7f7..e5006aac2a8 100644 --- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc +++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/extension_statuses_handler.cc @@ -38,9 +38,7 @@ void ConvertExtensionStatusToDictionary( } base::ListValue list; - for (std::map<GURL, std::string>::const_iterator itr = status_map.begin(); - itr != status_map.end(); - ++itr) { + for (auto itr = status_map.begin(); itr != status_map.end(); ++itr) { std::string extension_id = itr->first.HostNoBrackets(); // Join with human readable extension name. diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc b/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc index 4779edd6b37..67a37f009d0 100644 --- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc +++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/file_metadata_handler.cc @@ -9,7 +9,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/values.h" -#include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_helpers.h" +#include "chrome/browser/apps/platform_apps/api/sync_file_system/sync_file_system_api_helpers.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync_file_system/sync_file_system_service.h" #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h" diff --git a/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc b/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc index bdbe8a704b1..3b9a08915b2 100644 --- a/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc +++ b/chromium/chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_handler.cc @@ -13,14 +13,14 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/values.h" +#include "chrome/browser/apps/platform_apps/api/sync_file_system/sync_file_system_api_helpers.h" #include "chrome/browser/drive/drive_notification_manager_factory.h" -#include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_helpers.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync_file_system/logger.h" #include "chrome/browser/sync_file_system/sync_file_system_service.h" #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h" #include "chrome/browser/sync_file_system/sync_service_state.h" -#include "chrome/common/extensions/api/sync_file_system.h" +#include "chrome/common/apps/platform_apps/api/sync_file_system.h" #include "components/drive/drive_notification_manager.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_ui.h" @@ -78,8 +78,8 @@ void SyncFileSystemInternalsHandler::OnSyncStateUpdated( const GURL& app_origin, sync_file_system::SyncServiceState state, const std::string& description) { - std::string state_string = extensions::api::sync_file_system::ToString( - extensions::SyncServiceStateToExtensionEnum(state)); + std::string state_string = chrome_apps::api::sync_file_system::ToString( + chrome_apps::api::SyncServiceStateToExtensionEnum(state)); if (!description.empty()) state_string += " (" + description + ")"; @@ -118,8 +118,8 @@ void SyncFileSystemInternalsHandler::GetServiceStatus( SyncFileSystemServiceFactory::GetForProfile(profile_); if (sync_service) state_enum = sync_service->GetSyncServiceState(); - const std::string state_string = extensions::api::sync_file_system::ToString( - extensions::SyncServiceStateToExtensionEnum(state_enum)); + const std::string state_string = chrome_apps::api::sync_file_system::ToString( + chrome_apps::api::SyncServiceStateToExtensionEnum(state_enum)); web_ui()->CallJavascriptFunctionUnsafe("SyncService.onGetServiceStatus", base::Value(state_string)); } @@ -147,9 +147,7 @@ void SyncFileSystemInternalsHandler::GetLog( // Collate events which haven't been sent to WebUI yet. base::ListValue list; - for (std::vector<EventLogger::Event>::const_iterator log_entry = log.begin(); - log_entry != log.end(); - ++log_entry) { + for (auto log_entry = log.begin(); log_entry != log.end(); ++log_entry) { if (log_entry->id <= last_log_id_sent) continue; 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 adb42796719..bc6b01b9fa3 100644 --- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc +++ b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc @@ -151,9 +151,16 @@ void SyncInternalsMessageHandler::RegisterMessages() { base::Unretained(this))); web_ui()->RegisterMessageCallback( - syncer::sync_ui_util::kRequestStop, - base::BindRepeating(&SyncInternalsMessageHandler::HandleRequestStop, - base::Unretained(this))); + syncer::sync_ui_util::kRequestStopKeepData, + base::BindRepeating( + &SyncInternalsMessageHandler::HandleRequestStopKeepData, + base::Unretained(this))); + + web_ui()->RegisterMessageCallback( + syncer::sync_ui_util::kRequestStopClearData, + base::BindRepeating( + &SyncInternalsMessageHandler::HandleRequestStopClearData, + base::Unretained(this))); web_ui()->RegisterMessageCallback( syncer::sync_ui_util::kTriggerRefresh, @@ -308,9 +315,24 @@ void SyncInternalsMessageHandler::HandleRequestStart( return; service->RequestStart(); + // If the service was previously stopped with CLEAR_DATA, then the + // "first-setup-complete" bit was also cleared, and now the service wouldn't + // fully start up. So set that too. + service->SetFirstSetupComplete(); +} + +void SyncInternalsMessageHandler::HandleRequestStopKeepData( + const base::ListValue* args) { + DCHECK_EQ(0U, args->GetSize()); + + SyncService* service = GetSyncService(); + if (!service) + return; + + service->RequestStop(SyncService::KEEP_DATA); } -void SyncInternalsMessageHandler::HandleRequestStop( +void SyncInternalsMessageHandler::HandleRequestStopClearData( const base::ListValue* args) { DCHECK_EQ(0U, args->GetSize()); diff --git a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h index 1ba4fc3b769..3f94dce4a93 100644 --- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h +++ b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h @@ -74,8 +74,11 @@ class SyncInternalsMessageHandler : public content::WebUIMessageHandler, // Handler for requestStart message. void HandleRequestStart(const base::ListValue* args); - // Handler for requestStop message. - void HandleRequestStop(const base::ListValue* args); + // Handler for requestStopKeepData message. + void HandleRequestStopKeepData(const base::ListValue* args); + + // Handler for requestStopClearData message. + void HandleRequestStopClearData(const base::ListValue* args); // Handler for triggerRefresh message. void HandleTriggerRefresh(const base::ListValue* args); 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 4478537a51c..04878a3bfdb 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 @@ -7,6 +7,7 @@ #include <memory> #include <utility> +#include "base/bind.h" #include "base/command_line.h" #include "base/memory/ref_counted.h" #include "chrome/browser/sync/profile_sync_service_factory.h" @@ -114,10 +115,11 @@ class SyncInternalsMessageHandlerTest : public ::testing::Test { web_ui_.set_web_contents(web_contents_.get()); test_sync_service_ = static_cast<TestSyncService*>( ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( - &profile_, &BuildTestSyncService)); + &profile_, base::BindRepeating(&BuildTestSyncService))); fake_user_event_service_ = static_cast<FakeUserEventService*>( browser_sync::UserEventServiceFactory::GetInstance() - ->SetTestingFactoryAndUse(&profile_, &BuildFakeUserEventService)); + ->SetTestingFactoryAndUse( + &profile_, base::BindRepeating(&BuildFakeUserEventService))); handler_.reset(new TestableSyncInternalsMessageHandler( &web_ui_, base::BindRepeating( @@ -257,8 +259,8 @@ TEST_F(SyncInternalsMessageHandlerTest, AddRemoveObserversDisallowJavascript) { TEST_F(SyncInternalsMessageHandlerTest, AddRemoveObserversSyncDisabled) { // Simulate completely disabling sync by flag or other mechanism. - ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile(), - nullptr); + ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( + profile(), BrowserContextKeyedServiceFactory::TestingFactory()); ListValue empty_list; handler()->HandleRegisterForEvents(&empty_list); @@ -321,8 +323,8 @@ TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfo) { TEST_F(SyncInternalsMessageHandlerTest, SendAboutInfoSyncDisabled) { // Simulate completely disabling sync by flag or other mechanism. - ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile(), - nullptr); + ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( + profile(), BrowserContextKeyedServiceFactory::TestingFactory()); handler()->AllowJavascriptForTesting(); handler()->OnStateChanged(nullptr); diff --git a/chromium/chrome/browser/ui/webui/system_info_ui.cc b/chromium/chrome/browser/ui/webui/system_info_ui.cc index cde5601016e..4b617b26d71 100644 --- a/chromium/chrome/browser/ui/webui/system_info_ui.cc +++ b/chromium/chrome/browser/ui/webui/system_info_ui.cc @@ -45,6 +45,7 @@ using system_logs::SystemLogsResponse; class SystemInfoUIHTMLSource : public content::URLDataSource{ public: SystemInfoUIHTMLSource(); + ~SystemInfoUIHTMLSource() override {} // content::URLDataSource implementation. std::string GetSource() const override; @@ -66,8 +67,6 @@ class SystemInfoUIHTMLSource : public content::URLDataSource{ } private: - ~SystemInfoUIHTMLSource() override {} - void SysInfoComplete(std::unique_ptr<SystemLogsResponse> response); void RequestComplete(); void WaitForData(); @@ -192,9 +191,8 @@ void SystemInfoHandler::RegisterMessages() { SystemInfoUI::SystemInfoUI(content::WebUI* web_ui) : WebUIController(web_ui) { web_ui->AddMessageHandler(std::make_unique<SystemInfoHandler>()); - SystemInfoUIHTMLSource* html_source = new SystemInfoUIHTMLSource(); // Set up the chrome://system/ source. - Profile* profile = Profile::FromWebUI(web_ui); - content::URLDataSource::Add(profile, html_source); + content::URLDataSource::Add(Profile::FromWebUI(web_ui), + std::make_unique<SystemInfoUIHTMLSource>()); } diff --git a/chromium/chrome/browser/ui/webui/theme_source.cc b/chromium/chrome/browser/ui/webui/theme_source.cc index 69c30d47e93..57f91e6ebc9 100644 --- a/chromium/chrome/browser/ui/webui/theme_source.cc +++ b/chromium/chrome/browser/ui/webui/theme_source.cc @@ -6,6 +6,7 @@ #include "base/memory/ref_counted_memory.h" #include "base/strings/string_number_conversions.h" +#include "base/task/post_task.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/resources_util.h" #include "chrome/browser/search/instant_io_context.h" @@ -19,6 +20,7 @@ #include "chrome/common/url_constants.h" #include "chrome/grit/theme_resources.h" #include "components/version_info/version_info.h" +#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "net/url_request/url_request.h" #include "ui/base/layout.h" @@ -49,7 +51,7 @@ void ProcessImageOnUiThread(const gfx::ImageSkia& image, DCHECK_CURRENTLY_ON(content::BrowserThread::UI); const gfx::ImageSkiaRep& rep = image.GetRepresentation(scale); gfx::PNGCodec::EncodeBGRASkBitmap( - rep.sk_bitmap(), false /* discard transparency */, &data->data()); + rep.GetBitmap(), false /* discard transparency */, &data->data()); } void ProcessResourceOnUiThread(int resource_id, @@ -229,8 +231,8 @@ void ThemeSource::SendThemeImage( DCHECK_CURRENTLY_ON(content::BrowserThread::IO); // Fetching image data in ResourceBundle should happen on the UI thread. See // crbug.com/449277 - content::BrowserThread::PostTaskAndReply( - content::BrowserThread::UI, FROM_HERE, + base::PostTaskWithTraitsAndReply( + FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&ProcessResourceOnUiThread, resource_id, scale, data), base::BindOnce(callback, data)); } diff --git a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc index 220af586aef..2812147d559 100644 --- a/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc +++ b/chromium/chrome/browser/ui/webui/translate_internals/translate_internals_handler.cc @@ -217,7 +217,8 @@ void TranslateInternalsHandler::SendPrefsToJs() { prefs::kOfferTranslateEnabled, translate::TranslatePrefs::kPrefTranslateRecentTarget, translate::TranslatePrefs::kPrefTranslateBlockedLanguages, - translate::TranslatePrefs::kPrefTranslateSiteBlacklist, + translate::TranslatePrefs::kPrefTranslateSiteBlacklistDeprecated, + translate::TranslatePrefs::kPrefTranslateSiteBlacklistWithTime, translate::TranslatePrefs::kPrefTranslateWhitelists, translate::TranslatePrefs::kPrefTranslateDeniedCount, translate::TranslatePrefs::kPrefTranslateIgnoredCount, 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 1613e415212..7bacde2c268 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 @@ -32,8 +32,7 @@ void GetLanguages(base::DictionaryValue* dict) { std::vector<std::string> language_codes; l10n_util::GetAcceptLanguagesForLocale(app_locale, &language_codes); - for (std::vector<std::string>::iterator it = language_codes.begin(); - it != language_codes.end(); ++it) { + 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); diff --git a/chromium/chrome/browser/ui/webui/version_ui.cc b/chromium/chrome/browser/ui/webui/version_ui.cc index 3c38271942a..8093111b645 100644 --- a/chromium/chrome/browser/ui/webui/version_ui.cc +++ b/chromium/chrome/browser/ui/webui/version_ui.cc @@ -129,7 +129,7 @@ WebUIDataSource* CreateVersionUIDataSource() { std::string command_line; typedef std::vector<std::string> ArgvList; const ArgvList& argv = base::CommandLine::ForCurrentProcess()->argv(); - for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++) + for (auto iter = argv.begin(); iter != argv.end(); iter++) command_line += " " + *iter; // TODO(viettrungluu): |command_line| could really have any encoding, whereas // below we assumes it's UTF-8. diff --git a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc index ab0af8cfa9b..31ede0b6ee0 100644 --- a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc +++ b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc @@ -242,8 +242,9 @@ IN_PROC_BROWSER_TEST_F(WebUIWebViewBrowserTest, base::Value(GetTestUrl("empty.html").spec()))); } -#if defined(OS_CHROMEOS) && !defined(NDEBUG) +#if defined(OS_CHROMEOS) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) // TODO(crbug.com/859320) Fails on CrOS dbg with --enable-features=Mash. +// TODO(crbug.com/893472) Flaky on CrOS ASan LSan #define MAYBE_AddContentScriptsWithNewWindowAPI \ DISABLED_AddContentScriptsWithNewWindowAPI #else diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/BUILD.gn b/chromium/chrome/browser/ui/webui/welcome/nux/BUILD.gn new file mode 100644 index 00000000000..718b6efc23d --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/BUILD.gn @@ -0,0 +1,72 @@ +# Copyright 2018 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/chrome_build.gni") + +source_set("constants") { + sources = [ + "constants.cc", + "constants.h", + ] + + public_deps = [ + "//base", + ] +} + +static_library("email_feature") { + sources = [ + "email_handler.cc", + "email_handler.h", + ] + + public_deps = [ + "//base", + "//net", + "//url", + ] + + deps = [ + "//chrome/app:generated_resources", + "//chrome/browser:resources", + "//components/bookmarks/browser", + "//components/bookmarks/common", + "//components/favicon/core", + "//components/pref_registry", + "//components/prefs", + "//components/resources", + "//components/strings", + "//components/variations", + "//content/public/browser", + "//ui/base", + ] +} + +static_library("google_apps_feature") { + sources = [ + "google_apps_handler.cc", + "google_apps_handler.h", + ] + + public_deps = [ + "//base", + "//net", + "//url", + ] + + deps = [ + "//chrome/app:generated_resources", + "//chrome/browser:resources", + "//components/bookmarks/browser", + "//components/bookmarks/common", + "//components/favicon/core", + "//components/pref_registry", + "//components/prefs", + "//components/resources", + "//components/strings", + "//components/variations", + "//content/public/browser", + "//ui/base", + ] +} diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/DEPS b/chromium/chrome/browser/ui/webui/welcome/nux/DEPS new file mode 100644 index 00000000000..cbcb3569274 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/DEPS @@ -0,0 +1,9 @@ +include_rules = [ + "+chrome/grit", + "+components/bookmarks", + "+components/grit", + "+components/prefs", + "+components/favicon", + "+content/public/browser", + "+ui/base", +] diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/OWNERS b/chromium/chrome/browser/ui/webui/welcome/nux/OWNERS new file mode 100644 index 00000000000..589a5fa6331 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/OWNERS @@ -0,0 +1,5 @@ +hcarmona@chromium.org +scottchen@chromium.org + +# COMPONENT: UI>Browser>FirstRun +# LABEL: Proj-Navi
\ No newline at end of file diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/README b/chromium/chrome/browser/ui/webui/welcome/nux/README new file mode 100644 index 00000000000..b2d6888146e --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/README @@ -0,0 +1,3 @@ +New User Experience Experiment (NUX). Code here will prompt new users to go +through an onboarding experience to customize their new browser install to +their common usages.
\ No newline at end of file diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/constants.cc b/chromium/chrome/browser/ui/webui/welcome/nux/constants.cc new file mode 100644 index 00000000000..ce936c04d9b --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/constants.cc @@ -0,0 +1,23 @@ +// 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/constants.h" + +#include "base/feature_list.h" + +namespace nux { + +extern const base::Feature kNuxEmailFeature{"NuxEmail", + base::FEATURE_DISABLED_BY_DEFAULT}; + +extern const base::Feature kNuxGoogleAppsFeature{ + "NuxGoogleApps", base::FEATURE_DISABLED_BY_DEFAULT}; + +extern const base::Feature kNuxOnboardingFeature{ + "NuxOnboarding", base::FEATURE_DISABLED_BY_DEFAULT}; + +extern const char kNuxEmailUrl[] = "chrome://welcome/email"; +extern const char kNuxGoogleAppsUrl[] = "chrome://welcome/apps"; + +} // namespace nux
\ No newline at end of file diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/constants.h b/chromium/chrome/browser/ui/webui/welcome/nux/constants.h new file mode 100644 index 00000000000..8f72a0cec64 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/constants.h @@ -0,0 +1,22 @@ +// 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_CONSTANTS_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_CONSTANTS_H_ + +namespace base { +struct Feature; +} // namespace base + +namespace nux { + +extern const base::Feature kNuxEmailFeature; +extern const base::Feature kNuxGoogleAppsFeature; +extern const base::Feature kNuxOnboardingFeature; +extern const char kNuxEmailUrl[]; +extern const char kNuxGoogleAppsUrl[]; + +} // namespace nux + +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_CONSTANTS_H_ diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.cc b/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.cc new file mode 100644 index 00000000000..5e45b1e1721 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.cc @@ -0,0 +1,171 @@ +// 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/ui/webui/welcome/nux/show_promo_delegate.h" +#include "chrome/grit/browser_resources.h" +#include "chrome/grit/generated_resources.h" +#include "components/bookmarks/common/bookmark_pref_names.h" +#include "components/favicon/core/favicon_service.h" +#include "components/grit/components_resources.h" +#include "components/grit/components_scaled_resources.h" +#include "components/prefs/pref_service.h" +#include "components/strings/grit/components_strings.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_data_source.h" +#include "ui/base/resource/resource_bundle.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, +}; + +struct EmailProviderType { + const EmailProviders id; + const char* name; // Icon in WebUI should use name to match CSS. + const char* url; + const int icon; // Corresponds with resource ID, used for bookmark cache. +}; + +const char* kEmailInteractionHistogram = + "FirstRun.NewUserExperience.EmailInteraction"; + +// Strings in costants not translated because this is an experiment. +// Translate before wide release. +// TODO(hcarmona): populate with icon ids. +const EmailProviderType kEmail[] = { + {EmailProviders::kGmail, "Gmail", + "https://accounts.google.com/b/0/AddMailService", IDR_NUX_EMAIL_GMAIL_1X}, + {EmailProviders::kYahoo, "Yahoo", "https://mail.yahoo.com", + IDR_NUX_EMAIL_YAHOO_1X}, + {EmailProviders::kOutlook, "Outlook", "https://login.live.com/login.srf?", + IDR_NUX_EMAIL_OUTLOOK_1X}, + {EmailProviders::kAol, "AOL", "https://mail.aol.com", IDR_NUX_EMAIL_AOL_1X}, + {EmailProviders::kiCloud, "iCloud", "https://www.icloud.com/mail", + IDR_NUX_EMAIL_ICLOUD_1X}, +}; + +constexpr const int kEmailIconSize = 48; // Pixels. + +static_assert(base::size(kEmail) == (size_t)EmailProviders::kCount, + "names and histograms must match"); + +EmailHandler::EmailHandler(PrefService* prefs, + favicon::FaviconService* favicon_service) + : prefs_(prefs), favicon_service_(favicon_service) {} + +EmailHandler::~EmailHandler() {} + +void EmailHandler::RegisterMessages() { + web_ui()->RegisterMessageCallback( + "cacheEmailIcon", base::BindRepeating(&EmailHandler::HandleCacheEmailIcon, + base::Unretained(this))); + + web_ui()->RegisterMessageCallback( + "toggleBookmarkBar", + base::BindRepeating(&EmailHandler::HandleToggleBookmarkBar, + base::Unretained(this))); +} + +void EmailHandler::HandleCacheEmailIcon(const base::ListValue* args) { + int emailId; + args->GetInteger(0, &emailId); + + const EmailProviderType* selectedEmail = NULL; + for (size_t i = 0; i < base::size(kEmail); i++) { + if ((int)kEmail[i].id == emailId) { + selectedEmail = &kEmail[i]; + 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); + favicon_service_->MergeFavicon( + app_url, app_url, favicon_base::IconType::kFavicon, + ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( + selectedEmail->icon), + gfx::Size(kEmailIconSize, kEmailIconSize)); +} + +void EmailHandler::HandleToggleBookmarkBar(const base::ListValue* args) { + bool show = false; + CHECK(args->GetBoolean(0, &show)); + prefs_->SetBoolean(bookmarks::prefs::kShowBookmarkBar, show); +} + +void EmailHandler::AddSources(content::WebUIDataSource* html_source, + PrefService* prefs) { + // Localized strings. + html_source->AddLocalizedString("noThanks", IDS_NO_THANKS); + html_source->AddLocalizedString("getStarted", IDS_NUX_EMAIL_GET_STARTED); + html_source->AddLocalizedString("welcomeTitle", IDS_NUX_EMAIL_WELCOME_TITLE); + html_source->AddLocalizedString("emailPrompt", IDS_NUX_EMAIL_PROMPT); + html_source->AddLocalizedString("bookmarkAdded", + IDS_NUX_EMAIL_BOOKMARK_ADDED); + html_source->AddLocalizedString("bookmarkRemoved", + IDS_NUX_EMAIL_BOOKMARK_REMOVED); + html_source->AddLocalizedString("bookmarkReplaced", + IDS_NUX_EMAIL_BOOKMARK_REPLACED); + + // Add required resources. + html_source->AddResourcePath("email", IDR_NUX_EMAIL_HTML); + html_source->AddResourcePath("email/nux_email.js", IDR_NUX_EMAIL_JS); + + html_source->AddResourcePath("email/nux_email_proxy.html", + IDR_NUX_EMAIL_PROXY_HTML); + html_source->AddResourcePath("email/nux_email_proxy.js", + IDR_NUX_EMAIL_PROXY_JS); + + html_source->AddResourcePath("email/email_chooser.html", + IDR_NUX_EMAIL_CHOOSER_HTML); + html_source->AddResourcePath("email/email_chooser.js", + IDR_NUX_EMAIL_CHOOSER_JS); + + // Add icons + html_source->AddResourcePath("email/aol_1x.png", IDR_NUX_EMAIL_AOL_1X); + html_source->AddResourcePath("email/aol_2x.png", IDR_NUX_EMAIL_AOL_2X); + html_source->AddResourcePath("email/gmail_1x.png", IDR_NUX_EMAIL_GMAIL_1X); + html_source->AddResourcePath("email/gmail_2x.png", IDR_NUX_EMAIL_GMAIL_2X); + html_source->AddResourcePath("email/icloud_1x.png", IDR_NUX_EMAIL_ICLOUD_1X); + html_source->AddResourcePath("email/icloud_2x.png", IDR_NUX_EMAIL_ICLOUD_2X); + html_source->AddResourcePath("email/outlook_1x.png", + IDR_NUX_EMAIL_OUTLOOK_1X); + html_source->AddResourcePath("email/outlook_2x.png", + IDR_NUX_EMAIL_OUTLOOK_2X); + html_source->AddResourcePath("email/yahoo_1x.png", IDR_NUX_EMAIL_YAHOO_1X); + html_source->AddResourcePath("email/yahoo_2x.png", IDR_NUX_EMAIL_YAHOO_2X); + + // Add constants to loadtime data + for (size_t i = 0; i < (size_t)EmailProviders::kCount; ++i) { + html_source->AddInteger("email_id_" + std::to_string(i), (int)kEmail[i].id); + html_source->AddString("email_name_" + std::to_string(i), kEmail[i].name); + html_source->AddString("email_url_" + std::to_string(i), kEmail[i].url); + } + html_source->AddInteger("email_count", (int)EmailProviders::kCount); + html_source->AddBoolean( + "bookmark_bar_shown", + prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar)); + html_source->SetJsonPath("strings.js"); +} + +} // namespace nux
\ No newline at end of file diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.h b/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.h new file mode 100644 index 00000000000..e66e56e7f8d --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/email_handler.h @@ -0,0 +1,63 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_EMAIL_HANDLER_H_ + +#include "base/macros.h" +#include "base/values.h" +#include "content/public/browser/web_ui_message_handler.h" + +class PrefService; + +namespace content { +class WebUIDataSource; +} // namespace content + +namespace favicon { +class FaviconService; +} // namespace favicon + +namespace nux { + +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(PrefService* prefs, favicon::FaviconService* favicon_service); + ~EmailHandler() override; + + // WebUIMessageHandler: + void RegisterMessages() override; + + // Callbacks for JS APIs. + void HandleCacheEmailIcon(const base::ListValue* args); + void HandleToggleBookmarkBar(const base::ListValue* args); + + // Adds webui sources. + static void AddSources(content::WebUIDataSource* html_source, + PrefService* prefs); + + private: + // Weak reference. + PrefService* prefs_; + + // Weak reference. + favicon::FaviconService* favicon_service_; + + 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/google_apps_handler.cc b/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.cc new file mode 100644 index 00000000000..cef05302dab --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.cc @@ -0,0 +1,188 @@ +// 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/google_apps_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/ui/webui/welcome/nux/show_promo_delegate.h" +#include "chrome/grit/browser_resources.h" +#include "chrome/grit/generated_resources.h" +#include "components/bookmarks/browser/bookmark_model.h" +#include "components/bookmarks/common/bookmark_pref_names.h" +#include "components/favicon/core/favicon_service.h" +#include "components/grit/components_resources.h" +#include "components/grit/components_scaled_resources.h" +#include "components/prefs/pref_service.h" +#include "components/strings/grit/components_strings.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_data_source.h" +#include "ui/base/resource/resource_bundle.h" + +namespace nux { + +// These values are persisted to logs. Entries should not be renumbered and +// numeric values should never be reused. +enum class GoogleApps { + kGmail = 0, + kYouTube = 1, + kMaps = 2, + kTranslate = 3, + kNews = 4, + kChromeWebStore = 5, + kCount, +}; + +const char* kGoogleAppsInteractionHistogram = + "FirstRun.NewUserExperience.GoogleAppsInteraction"; + +// Strings in costants not translated because this is an experiment. +// Translate before wide release. + +constexpr const char* kGoogleAppNames[] = { + "Gmail", "YouTube", "Maps", "Translate", "News", "Chrome Web Store", +}; + +constexpr const char* kGoogleAppUrls[] = { + "https://gmail.com", "https://youtube.com", + "https://maps.google.com", "https://translate.google.com", + "https://news.google.com", "https://chrome.google.com/webstore", +}; + +constexpr const int kGoogleAppIconSize = 48; // Pixels. +constexpr const int kGoogleAppIcons[] = { + IDR_NUX_EMAIL_GMAIL_1X, IDR_NUX_GOOGLE_APPS_YOUTUBE_1X, + IDR_NUX_GOOGLE_APPS_MAPS_1X, IDR_NUX_GOOGLE_APPS_TRANSLATE_1X, + IDR_NUX_GOOGLE_APPS_NEWS_1X, IDR_NUX_GOOGLE_APPS_CHROME_STORE_1X, +}; + +static_assert(base::size(kGoogleAppNames) == base::size(kGoogleAppUrls), + "names and urls must match"); +static_assert(base::size(kGoogleAppNames) == (size_t)GoogleApps::kCount, + "names and histograms must match"); +static_assert(base::size(kGoogleAppNames) == base::size(kGoogleAppIcons), + "names and icons must match"); + +GoogleAppsHandler::GoogleAppsHandler(PrefService* prefs, + favicon::FaviconService* favicon_service, + bookmarks::BookmarkModel* bookmark_model) + : prefs_(prefs), + favicon_service_(favicon_service), + bookmark_model_(bookmark_model) {} + +GoogleAppsHandler::~GoogleAppsHandler() {} + +void GoogleAppsHandler::RegisterMessages() { + web_ui()->RegisterMessageCallback( + "rejectGoogleApps", + base::BindRepeating(&GoogleAppsHandler::HandleRejectGoogleApps, + base::Unretained(this))); + + web_ui()->RegisterMessageCallback( + "addGoogleApps", + base::BindRepeating(&GoogleAppsHandler::HandleAddGoogleApps, + base::Unretained(this))); +} + +void GoogleAppsHandler::HandleRejectGoogleApps(const base::ListValue* args) { + UMA_HISTOGRAM_ENUMERATION(kGoogleAppsInteractionHistogram, + GoogleAppsInteraction::kNoThanks, + GoogleAppsInteraction::kCount); +} + +void GoogleAppsHandler::HandleAddGoogleApps(const base::ListValue* args) { + // Add bookmarks for all selected apps. + int bookmarkIndex = 0; + for (size_t i = 0; i < (size_t)GoogleApps::kCount; ++i) { + bool selected = false; + CHECK(args->GetBoolean(i, &selected)); + if (selected) { + UMA_HISTOGRAM_ENUMERATION( + "FirstRun.NewUserExperience.GoogleAppsSelection", (GoogleApps)i, + GoogleApps::kCount); + GURL app_url = GURL(kGoogleAppUrls[i]); + bookmark_model_->AddURL(bookmark_model_->bookmark_bar_node(), + bookmarkIndex++, + base::ASCIIToUTF16(kGoogleAppNames[i]), app_url); + + // 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. + favicon_service_->MergeFavicon( + app_url, app_url, favicon_base::IconType::kFavicon, + ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( + kGoogleAppIcons[i]), + gfx::Size(kGoogleAppIconSize, kGoogleAppIconSize)); + } + } + + // Enable bookmark bar. + prefs_->SetBoolean(bookmarks::prefs::kShowBookmarkBar, true); + + // Show bookmark bubble. + ShowPromoDelegate::CreatePromoDelegate( + IDS_NUX_GOOGLE_APPS_DESCRIPTION_PROMO_BUBBLE) + ->ShowForNode(bookmark_model_->bookmark_bar_node()->GetChild(0)); + + UMA_HISTOGRAM_ENUMERATION(kGoogleAppsInteractionHistogram, + GoogleAppsInteraction::kGetStarted, + GoogleAppsInteraction::kCount); +} + +void GoogleAppsHandler::AddSources(content::WebUIDataSource* html_source) { + // Localized strings. + html_source->AddLocalizedString("noThanks", IDS_NO_THANKS); + html_source->AddLocalizedString("getStarted", + IDS_NUX_GOOGLE_APPS_GET_STARTED); + html_source->AddLocalizedString("googleAppsDescription", + IDS_NUX_GOOGLE_APPS_DESCRIPTION); + + // Add required resources. + html_source->AddResourcePath("apps", IDR_NUX_GOOGLE_APPS_HTML); + html_source->AddResourcePath("apps/nux_google_apps.js", + IDR_NUX_GOOGLE_APPS_JS); + + html_source->AddResourcePath("apps/nux_google_apps_proxy.html", + IDR_NUX_GOOGLE_APPS_PROXY_HTML); + html_source->AddResourcePath("apps/nux_google_apps_proxy.js", + IDR_NUX_GOOGLE_APPS_PROXY_JS); + + html_source->AddResourcePath("apps/apps_chooser.html", + IDR_NUX_GOOGLE_APPS_CHOOSER_HTML); + html_source->AddResourcePath("apps/apps_chooser.js", + IDR_NUX_GOOGLE_APPS_CHOOSER_JS); + + // Add icons + html_source->AddResourcePath("apps/chrome_store_1x.png", + IDR_NUX_GOOGLE_APPS_CHROME_STORE_1X); + html_source->AddResourcePath("apps/chrome_store_2x.png", + IDR_NUX_GOOGLE_APPS_CHROME_STORE_2X); + // TODO: rename and centralize to make it easier to share icons between NUX. + html_source->AddResourcePath("apps/gmail_1x.png", + IDR_NUX_EMAIL_GMAIL_1X); + html_source->AddResourcePath("apps/gmail_2x.png", + IDR_NUX_EMAIL_GMAIL_2X); + html_source->AddResourcePath("apps/google_apps_1x.png", + IDR_NUX_GOOGLE_APPS_LOGO_1X); + html_source->AddResourcePath("apps/google_apps_2x.png", + IDR_NUX_GOOGLE_APPS_LOGO_2X); + html_source->AddResourcePath("apps/maps_1x.png", IDR_NUX_GOOGLE_APPS_MAPS_1X); + html_source->AddResourcePath("apps/maps_2x.png", IDR_NUX_GOOGLE_APPS_MAPS_2X); + html_source->AddResourcePath("apps/news_1x.png", IDR_NUX_GOOGLE_APPS_NEWS_1X); + html_source->AddResourcePath("apps/news_2x.png", IDR_NUX_GOOGLE_APPS_NEWS_2X); + html_source->AddResourcePath("apps/translate_1x.png", + IDR_NUX_GOOGLE_APPS_TRANSLATE_1X); + html_source->AddResourcePath("apps/translate_2x.png", + IDR_NUX_GOOGLE_APPS_TRANSLATE_2X); + html_source->AddResourcePath("apps/youtube_1x.png", + IDR_NUX_GOOGLE_APPS_YOUTUBE_1X); + html_source->AddResourcePath("apps/youtube_2x.png", + IDR_NUX_GOOGLE_APPS_YOUTUBE_2X); +} + +} // 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 new file mode 100644 index 00000000000..d506d191d96 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/google_apps_handler.h @@ -0,0 +1,71 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_GOOGLE_APPS_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_GOOGLE_APPS_HANDLER_H_ + +#include "base/macros.h" +#include "base/values.h" +#include "content/public/browser/web_ui_message_handler.h" + +class PrefService; + +namespace bookmarks { +class BookmarkModel; +} // namespace bookmarks + +namespace content { +class WebUIDataSource; +} // namespace content + +namespace favicon { +class FaviconService; +} // namespace favicon + +namespace nux { + +extern const char* kGoogleAppsInteractionHistogram; + +// These values are persisted to logs. Entries should not be renumbered and +// numeric values should never be reused. +enum class GoogleAppsInteraction { + kPromptShown = 0, + kNoThanks = 1, + kGetStarted = 2, + kCount, +}; + +class GoogleAppsHandler : public content::WebUIMessageHandler { + public: + GoogleAppsHandler(PrefService* prefs, + favicon::FaviconService* favicon_service, + bookmarks::BookmarkModel* bookmark_model); + ~GoogleAppsHandler() override; + + // WebUIMessageHandler: + void RegisterMessages() override; + + // Callbacks for JS APIs. + void HandleRejectGoogleApps(const base::ListValue* args); + void HandleAddGoogleApps(const base::ListValue* args); + + // Adds webui sources. + static void AddSources(content::WebUIDataSource* html_source); + + private: + // Weak reference. + PrefService* prefs_; + + // Weak reference. + favicon::FaviconService* favicon_service_; + + // Weak reference. + bookmarks::BookmarkModel* bookmark_model_; + + DISALLOW_COPY_AND_ASSIGN(GoogleAppsHandler); +}; + +} // namespace nux + +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_GOOGLE_APPS_HANDLER_H_ 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 new file mode 100644 index 00000000000..88ea473b0fa --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.cc @@ -0,0 +1,42 @@ +// 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/set_as_default_handler.h" + +#include "base/metrics/field_trial_params.h" +#include "base/metrics/histogram_macros.h" +#include "chrome/grit/browser_resources.h" +#include "chrome/grit/generated_resources.h" +#include "components/grit/components_resources.h" +#include "components/strings/grit/components_strings.h" +#include "content/public/browser/web_ui_data_source.h" + +namespace nux { + +SetAsDefaultHandler::SetAsDefaultHandler() + : settings::DefaultBrowserHandler() {} + +SetAsDefaultHandler::~SetAsDefaultHandler() {} + +void SetAsDefaultHandler::RecordSetAsDefaultUMA() { + // TODO(scottchen): Add UMA tracking. +} + +void SetAsDefaultHandler::AddSources(content::WebUIDataSource* html_source) { + // Localized strings. + + // Add required resources. + html_source->AddResourcePath("nux_set_as_default.html", + IDR_NUX_SET_AS_DEFAULT_HTML); + html_source->AddResourcePath("nux_set_as_default.js", + IDR_NUX_SET_AS_DEFAULT_JS); + html_source->AddResourcePath("nux_set_as_default_proxy.html", + IDR_NUX_SET_AS_DEFAULT_PROXY_HTML); + html_source->AddResourcePath("nux_set_as_default_proxy.js", + IDR_NUX_SET_AS_DEFAULT_PROXY_JS); + + // Add icons +} + +} // namespace nux
\ No newline at end of file diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.h b/chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.h new file mode 100644 index 00000000000..9621e65618e --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/set_as_default_handler.h @@ -0,0 +1,33 @@ +// 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_SET_AS_DEFAULT_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_SET_AS_DEFAULT_HANDLER_H_ + +#include "base/macros.h" +#include "chrome/browser/ui/webui/settings/settings_default_browser_handler.h" + +namespace content { +class WebUIDataSource; +} // namespace content + +namespace nux { + +class SetAsDefaultHandler : public settings::DefaultBrowserHandler { + public: + SetAsDefaultHandler(); + ~SetAsDefaultHandler() override; + + // Adds webui sources. + static void AddSources(content::WebUIDataSource* html_source); + + protected: + void RecordSetAsDefaultUMA() override; + + DISALLOW_COPY_AND_ASSIGN(SetAsDefaultHandler); +}; + +} // namespace nux + +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_SET_AS_DEFAULT_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/welcome/nux/show_promo_delegate.h b/chromium/chrome/browser/ui/webui/welcome/nux/show_promo_delegate.h new file mode 100644 index 00000000000..c95b16cc526 --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux/show_promo_delegate.h @@ -0,0 +1,26 @@ +// 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_SHOW_PROMO_DELEGATE_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_SHOW_PROMO_DELEGATE_H_ + +#include <memory> + +namespace bookmarks { +class BookmarkNode; +} // namespace bookmarks + +class ShowPromoDelegate { + public: + virtual ~ShowPromoDelegate() = default; + + // Shows a promotional popup for the specified bookmark node. + virtual void ShowForNode(const bookmarks::BookmarkNode* node) = 0; + + // Return an instance of the promo delegate. + static std::unique_ptr<ShowPromoDelegate> CreatePromoDelegate( + int string_specifier); +}; + +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_SHOW_PROMO_DELEGATE_H_ diff --git a/chromium/chrome/browser/ui/webui/welcome/nux_helper.cc b/chromium/chrome/browser/ui/webui/welcome/nux_helper.cc new file mode 100644 index 00000000000..a9617a4f1be --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux_helper.cc @@ -0,0 +1,33 @@ +// 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_helper.h" +#include "base/feature_list.h" +#include "build/build_config.h" + +// TODO(scottchen): remove #if guard once components/nux/ is moved to +// chrome/browser/ui/webui/welcome/ and included by non-win platforms. +// Also check if it makes sense to merge nux_helper.* with nux/constants.*. +#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) +#include "chrome/browser/ui/webui/welcome/nux/constants.h" +#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) + +namespace nux { +// 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. +extern const base::Feature kNuxOnboardingForceEnabled{ + "NuxOnboardingForceEnabled", base::FEATURE_DISABLED_BY_DEFAULT}; + +bool IsNuxOnboardingEnabled() { + if (base::FeatureList::IsEnabled(nux::kNuxOnboardingForceEnabled)) { + return true; + } else { +#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) + return base::FeatureList::IsEnabled(nux::kNuxOnboardingFeature); +#else + return false; +#endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) + } +} +} // namespace nux diff --git a/chromium/chrome/browser/ui/webui/welcome/nux_helper.h b/chromium/chrome/browser/ui/webui/welcome/nux_helper.h new file mode 100644 index 00000000000..b27b3373ebd --- /dev/null +++ b/chromium/chrome/browser/ui/webui/welcome/nux_helper.h @@ -0,0 +1,14 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_ + +#include "base/macros.h" + +namespace nux { +bool IsNuxOnboardingEnabled(); +}; // namespace nux + +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_HELPER_H_ diff --git a/chromium/chrome/browser/ui/webui/welcome_handler.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc index b092abfbbf9..7c8087386b3 100644 --- a/chromium/chrome/browser/ui/webui/welcome_handler.cc +++ b/chromium/chrome/browser/ui/webui/welcome/welcome_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/welcome_handler.h" +#include "chrome/browser/ui/webui/welcome/welcome_handler.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" @@ -18,6 +18,8 @@ #include "services/identity/public/cpp/identity_manager.h" #include "ui/base/page_transition_types.h" +const char kWelcomeReturningUserUrl[] = "chrome://welcome/returning-user"; + WelcomeHandler::WelcomeHandler(content::WebUI* web_ui) : profile_(Profile::FromWebUI(web_ui)), login_ui_service_(LoginUIServiceFactory::GetForProfile(profile_)), @@ -44,7 +46,13 @@ void WelcomeHandler::OnSyncConfirmationUIClosed( LoginUIService::SyncConfirmationUIClosedResult result) { if (result != LoginUIService::ABORT_SIGNIN) { result_ = WelcomeResult::SIGNED_IN; - GoToNewTabPage(); + + // When signed in from NUX onboarding flow, it's possible to come back to + // chrome://welcome/... after closing sync-confirmation UI. If current URL + // matches such a case, do not navigate away. + GURL current_url = web_ui()->GetWebContents()->GetVisibleURL(); + if (current_url != kWelcomeReturningUserUrl) + GoToNewTabPage(); } } @@ -60,10 +68,18 @@ void WelcomeHandler::HandleActivateSignIn(const base::ListValue* args) { // them away to the NTP instead. GoToNewTabPage(); } else { + GURL redirect_url = GURL::EmptyGURL(); + if (args->GetSize() == 1U) { + std::string url_string; + CHECK(args->GetString(0, &url_string)); + redirect_url = GURL(url_string); + DCHECK(redirect_url.is_valid()); + } + Browser* browser = GetBrowser(); browser->signin_view_controller()->ShowSignin( profiles::BubbleViewMode::BUBBLE_VIEW_MODE_GAIA_SIGNIN, browser, - signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE); + signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE, redirect_url); } } diff --git a/chromium/chrome/browser/ui/webui/welcome_handler.h b/chromium/chrome/browser/ui/webui/welcome/welcome_handler.h index b685467cbec..7959b41750b 100644 --- a/chromium/chrome/browser/ui/webui/welcome_handler.h +++ b/chromium/chrome/browser/ui/webui/welcome/welcome_handler.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_WELCOME_HANDLER_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_HANDLER_H_ #include "base/macros.h" #include "chrome/browser/ui/webui/signin/login_ui_service.h" @@ -57,4 +57,4 @@ class WelcomeHandler : public content::WebUIMessageHandler, DISALLOW_COPY_AND_ASSIGN(WelcomeHandler); }; -#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_HANDLER_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/welcome_ui.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.cc index 36b786ce5fe..a07f37c2307 100644 --- a/chromium/chrome/browser/ui/webui/welcome_ui.cc +++ b/chromium/chrome/browser/ui/webui/welcome/welcome_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/welcome_ui.h" +#include "chrome/browser/ui/webui/welcome/welcome_ui.h" #include <memory> #include <string> @@ -10,14 +10,14 @@ #include "build/build_config.h" #include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/signin/account_consistency_mode_manager.h" -#include "chrome/browser/ui/webui/welcome_handler.h" +#include "chrome/browser/ui/webui/welcome/nux_helper.h" +#include "chrome/browser/ui/webui/welcome/welcome_handler.h" #include "chrome/common/pref_names.h" #include "chrome/grit/browser_resources.h" #include "chrome/grit/chrome_unscaled_resources.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "components/prefs/pref_service.h" -#include "components/sync/driver/sync_service.h" #include "content/public/browser/web_ui_data_source.h" #include "net/base/url_util.h" #include "ui/base/l10n/l10n_util.h" @@ -25,21 +25,22 @@ #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) #include "base/metrics/histogram_macros.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" -#include "components/nux/constants.h" -#include "components/nux/email/email_handler.h" -#include "components/nux/google_apps/google_apps_handler.h" -#include "components/nux/show_promo_delegate.h" +#include "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/set_as_default_handler.h" +#include "chrome/browser/ui/webui/welcome/nux/show_promo_delegate.h" #include "content/public/browser/web_contents.h" #endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) namespace { - const bool kIsBranded = +const bool kIsBranded = #if defined(GOOGLE_CHROME_BUILD) - true; + true; #else - false; + false; #endif -} +} // namespace WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) : content::WebUIController(web_ui) { @@ -67,9 +68,38 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) html_source->AddResourcePath("logo.png", IDR_PRODUCT_LOGO_128); html_source->AddResourcePath("logo2x.png", IDR_PRODUCT_LOGO_256); - // Use special layout if the application is branded and DICE is enabled. - // Otherwise use the default layout. - if (kIsBranded && is_dice) { + if (nux::IsNuxOnboardingEnabled()) { + // Add Onboarding welcome strings. + html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER); + html_source->AddLocalizedString("acceptText", IDS_WELCOME_ACCEPT_BUTTON); + + // Add onboarding welcome resources. + html_source->SetDefaultResource( + IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_HTML); + html_source->AddResourcePath( + "landing_view.html", IDR_WELCOME_ONBOARDING_WELCOME_LANDING_VIEW_HTML); + html_source->AddResourcePath( + "landing_view.js", IDR_WELCOME_ONBOARDING_WELCOME_LANDING_VIEW_JS); + html_source->AddResourcePath( + "navigation_behavior.html", + IDR_WELCOME_ONBOARDING_WELCOME_NAVIGATION_BEHAVIOR_HTML); + html_source->AddResourcePath( + "navigation_behavior.js", + IDR_WELCOME_ONBOARDING_WELCOME_NAVIGATION_BEHAVIOR_JS); + html_source->AddResourcePath("welcome.css", + IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_CSS); + html_source->AddResourcePath( + "welcome_app.html", IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_APP_HTML); + html_source->AddResourcePath("welcome_app.js", + IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_APP_JS); + html_source->AddResourcePath( + "welcome_browser_proxy.html", + IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_BROWSER_PROXY_HTML); + html_source->AddResourcePath( + "welcome_browser_proxy.js", + IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_BROWSER_PROXY_JS); + } else if (kIsBranded && is_dice) { + // Use special layout if the application is branded and DICE is enabled. html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER); html_source->AddLocalizedString("acceptText", IDS_PROFILES_DICE_SIGNIN_BUTTON); @@ -114,6 +144,22 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url) } #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) + // TODO(hcarmona): Move this behind nux::kNuxOnboardingFeature when email and + // apps experiments end. + html_source->AddResourcePath("shared/chooser_shared_css.html", + IDR_NUX_CHOOSER_SHARED_CSS); + html_source->AddResourcePath( + "shared/i18n_setup.html", + IDR_WELCOME_ONBOARDING_WELCOME_SHARED_I18N_SETUP_HTML); + + if (base::FeatureList::IsEnabled(nux::kNuxOnboardingFeature)) { + web_ui->AddMessageHandler(std::make_unique<nux::SetAsDefaultHandler>()); + nux::SetAsDefaultHandler::AddSources(html_source); + + // TODO(scottchen): move all NUX features under this flag once individual + // experiments launch. + } + // To avoid diluting data collection, existing users should not be assigned // an NUX group. So, the kOnboardDuringNUX flag is used to short-circuit the // feature checks below. diff --git a/chromium/chrome/browser/ui/webui/welcome_ui.h b/chromium/chrome/browser/ui/webui/welcome/welcome_ui.h index 7ff85eb9d42..acadd2f3582 100644 --- a/chromium/chrome/browser/ui/webui/welcome_ui.h +++ b/chromium/chrome/browser/ui/webui/welcome/welcome_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_WELCOME_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_WELCOME_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_UI_H_ #include "chrome/browser/profiles/profile.h" #include "content/public/browser/web_ui_controller.h" @@ -22,4 +22,4 @@ class WelcomeUI : public content::WebUIController { void StorePageSeen(Profile* profile, const GURL& url); }; -#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_UI_H_ diff --git a/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.cc index da5eeb1c7f2..f629bf36c28 100644 --- a/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc +++ b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/webui/welcome_win10_handler.h" +#include "chrome/browser/ui/webui/welcome/welcome_win10_handler.h" #include "base/bind.h" #include "base/metrics/histogram_functions.h" diff --git a/chromium/chrome/browser/ui/webui/welcome_win10_handler.h b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.h index 70a0970934d..504dada5d8e 100644 --- a/chromium/chrome/browser/ui/webui/welcome_win10_handler.h +++ b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_handler.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_ -#define CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_WIN10_HANDLER_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_WIN10_HANDLER_H_ #include <string> @@ -64,4 +64,4 @@ class WelcomeWin10Handler : public content::WebUIMessageHandler { DISALLOW_COPY_AND_ASSIGN(WelcomeWin10Handler); }; -#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_HANDLER_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_WIN10_HANDLER_H_ diff --git a/chromium/chrome/browser/ui/webui/welcome_win10_ui.cc b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_ui.cc index 018ed4d2935..111b5beff75 100644 --- a/chromium/chrome/browser/ui/webui/welcome_win10_ui.cc +++ b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_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/welcome_win10_ui.h" +#include "chrome/browser/ui/webui/welcome/welcome_win10_ui.h" #include <memory> #include <string> @@ -10,7 +10,7 @@ #include "base/feature_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/welcome_win10_handler.h" +#include "chrome/browser/ui/webui/welcome/welcome_win10_handler.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" diff --git a/chromium/chrome/browser/ui/webui/welcome_win10_ui.h b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_ui.h index 21c926d9ef2..08c97ead173 100644 --- a/chromium/chrome/browser/ui/webui/welcome_win10_ui.h +++ b/chromium/chrome/browser/ui/webui/welcome/welcome_win10_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_WELCOME_WIN10_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_UI_H_ +#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_WIN10_UI_H_ +#define CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_WIN10_UI_H_ #include "content/public/browser/web_ui_controller.h" @@ -18,4 +18,4 @@ class WelcomeWin10UI : public content::WebUIController { ~WelcomeWin10UI() override; }; -#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_WIN10_UI_H_ +#endif // CHROME_BROWSER_UI_WEBUI_WELCOME_WELCOME_WIN10_UI_H_ |